import com.intellij.openapi.editor.event.EditorFactoryListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
*/
public abstract Editor createEditor(@NotNull Document document, Project project, @NotNull FileType fileType, boolean isViewer);
+ /**
+ * Creates an editor for the specified document associated with the specified project.
+ *
+ * @param document the document to create the editor for.
+ * @param project the project for which highlighter should be created
+ * @param file the file according to which the editor contents is highlighted.
+ * @param isViewer true if read-only editor should be created
+ * @return the editor instance.
+ * @see Editor#getProject()
+ * @see #releaseEditor(Editor)
+ */
+ public abstract Editor createEditor(@NotNull Document document, Project project, @NotNull VirtualFile file, boolean isViewer);
+
/**
* Creates a read-only editor for the specified document associated with the specified project.
*
import com.intellij.openapi.project.ProjectManagerAdapter;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.EventDispatcher;
import com.intellij.util.SmartList;
import com.intellij.util.text.CharArrayCharSequence;
return editor;
}
+ public Editor createEditor(@NotNull Document document, Project project, @NotNull VirtualFile file, boolean isViewer) {
+ Editor editor = createEditor(document, isViewer, project);
+ ((EditorEx)editor).setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(project, file));
+ return editor;
+ }
+
private Editor createEditor(@NotNull Document document, boolean isViewer, Project project) {
Document hostDocument = document instanceof DocumentWindow ? ((DocumentWindow)document).getDelegate() : document;
EditorImpl editor = new EditorImpl(hostDocument, isViewer, project);
import com.intellij.openapi.editor.impl.DocumentImpl;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.CharArrayCharSequence;
import org.jetbrains.annotations.NotNull;
return null;
}
+ public Editor createEditor(@NotNull Document document, Project project, @NotNull VirtualFile file, boolean isViewer) {
+ return null;
+ }
+
public Editor createEditor(@NotNull final Document document, final Project project, @NotNull final FileType fileType, final boolean isViewer) {
return null;
}
if (isDisposed) return null;
Project project = psiFile.getProject();
- Editor editor = EditorFactory.getInstance().createEditor(document, project, psiFile.getFileType(), true);
+ Editor editor = EditorFactory.getInstance().createEditor(document, project, psiFile.getVirtualFile(), true);
EditorSettings settings = editor.getSettings();
settings.setLineMarkerAreaShown(false);