documents.md: do not use deflist

This commit is contained in:
Yann Cébron 2021-10-13 16:44:59 +02:00
parent d3a93e544e
commit 87b8f78185

View File

@ -9,14 +9,14 @@ The IntelliJ Platform handles encoding and line break conversions when loading a
## How do I get a Document?
From an Action
: `e.getData(CommonDataKeys.EDITOR).getDocument()`
#### From an Action
`e.getData(CommonDataKeys.EDITOR).getDocument()`
From a Virtual File
: `FileDocumentManager.getDocument()`. This call forces the document content to be loaded from disk if it wasn't loaded previously. If only open documents or documents which may have been modified are considered relevant, use `FileDocumentManager.getCachedDocument()` instead.
#### From a Virtual File
`FileDocumentManager.getDocument()`. This call forces the document content to be loaded from disk if it wasn't loaded previously. If only open documents or documents which may have been modified are considered relevant, use `FileDocumentManager.getCachedDocument()` instead.
From a PSI File
: `PsiDocumentManager.getInstance().getDocument()` or `PsiDocumentManager.getInstance().getCachedDocument()`
#### From a PSI File
`PsiDocumentManager.getInstance().getDocument()` or `PsiDocumentManager.getInstance().getCachedDocument()`
## What can I do with a Document?
@ -58,11 +58,11 @@ If the file corresponding to a `Document` is read-only (for example, not checked
Thus, before modifying the `Document`, it is necessary to call `ReadonlyStatusHandler.getInstance(project).ensureFilesWritable()` to check out the file.
All text strings passed to `Document` modification methods (`setText()`, `insertString()`, `replaceString()`) must use only `\n` as line separators.
See also [Working with Text](working_with_text.md#safely-replacing-selected-text-in-the-document) in Editors Basics tutorial.
## Are there any utilities available for working with Documents?
[`DocumentUtil`](upsource:///platform/core-impl/src/com/intellij/util/DocumentUtil.java) contains utility methods for `Document` processing.
This allows you to get information like the text offsets of particular lines.
This is particularly useful when you need text location/offset information about a given `PsiElement`.
This is particularly useful when you need text location/offset information about a given `PsiElement`.