EditorEx () { Project project = getProjectIfValid(); Document document = getDocument(); final EditorFactory factory = EditorFactory.getInstance(); EditorEx editor = (EditorEx)(myIsViewer ? factory.createViewer(document, project) : factory.createEditor(document, project)); editor.putUserData(MANAGED_BY_FIELD, Boolean.TRUE); setupTextFieldEditor(editor); editor.setCaretEnabled(!myIsViewer); if (project != null) { PsiFile psiFile = ReadAction.compute(() -> PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument())); if (psiFile != null) { DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(psiFile, !myIsViewer); } } if (project != null) { EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance(); VirtualFile virtualFile = myDocument == null ? null : FileDocumentManager.getInstance().getFile(myDocument); EditorHighlighter highlighter = virtualFile != null ? highlighterFactory.createEditorHighlighter(project, virtualFile) : myFileType != null ? highlighterFactory.createEditorHighlighter(project, myFileType) : null; if (highlighter != null) editor.setHighlighter(highlighter); } ReadAction.run(() -> { editor.getSettings().setCaretRowShown(false); editor.setOneLineMode(myOneLineMode); editor.getCaretModel().moveToOffset(document.getTextLength()); if (!shouldHaveBorder()) { editor.setBorder(null); } if (myIsViewer) { editor.getSelectionModel().removeSelection(); } else { deferredSelection.execute(editor); deferredSelection = DeferredSelection.None.getInstance(); } editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary); editor.getContentComponent().setFocusCycleRoot(false); editor.getContentComponent().addFocusListener(this); editor.getContentComponent().addMouseListener(this); editor.setPlaceholder(myHintText); editor.setShowPlaceholderWhenFocused(myShowPlaceholderWhenFocused); initOneLineMode(editor); if (myIsRendererWithSelection) { ((EditorImpl)editor).setPaintSelection(true); editor.getColorsScheme().setColor(EditorColors.SELECTION_BACKGROUND_COLOR, myRendererBg); editor.getColorsScheme().setColor(EditorColors.SELECTION_FOREGROUND_COLOR, myRendererFg); editor.getSelectionModel().setSelection(0, document.getTextLength()); editor.setBackgroundColor(myRendererBg); } for (EditorSettingsProvider provider : mySettingsProviders) { provider.customizeSettings(editor); } }); return editor; }