Java 类com.intellij.openapi.editor.highlighter.EditorHighlighterFactory 实例源码

项目:mule-intellij-plugins    文件:WeaveEditor.java   
private void updateTab(@NotNull JBTabsPaneImpl tabsPane, int index, WeaveIdentifier identifier, @NotNull WeaveDataType dataType) {
    Icon icon = iconsMap.containsKey(dataType.getText()) ? iconsMap.get(dataType.getText()) : AllIcons.FileTypes.Any_type;

    String title = (identifier == null ? "output" : identifier.getName());

    tabsPane.setTitleAt(index, title);
    tabsPane.setIconAt(index, icon);
    contentTypes.put(title, dataType.getText());

    VirtualFile vfile = inputOutputFiles.get(title);
    if (vfile != null) {
        vfile.putUserData(newFileDataTypeKey, dataType.getText());
        FileContentUtilCore.reparseFiles(vfile);
    }

    Editor oldEditor = editors.get(title);
    FileType newType = fileTypes.containsKey(dataType.getText()) ? fileTypes.get(dataType.getText()) : FileTypes.UNKNOWN;
    ((EditorEx) oldEditor).setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(project, newType));
}
项目:intellij-ce-playground    文件:FileTypeEditorHighlighterProviders.java   
@NotNull
@Override
protected List<EditorHighlighterProvider> buildExtensions(@NotNull String stringKey, @NotNull final FileType key) {
  List<EditorHighlighterProvider> fromEP = super.buildExtensions(stringKey, key);
  if (fromEP.isEmpty()) {
    EditorHighlighterProvider defaultProvider = new EditorHighlighterProvider() {
      @Override
      public EditorHighlighter getEditorHighlighter(@Nullable Project project,
                                                    @NotNull FileType fileType,
                                                    @Nullable VirtualFile virtualFile,
                                                    @NotNull EditorColorsScheme colors) {
        return EditorHighlighterFactory.getInstance().createEditorHighlighter(
          SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, virtualFile), colors);
      }
    };
    return Collections.singletonList(defaultProvider);
  }
  return fromEP;
}
项目:intellij-ce-playground    文件:EditorHighlighterCache.java   
@Nullable
public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) {
  EditorHighlighter highlighter = null;

  PsiFile psiFile = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
  final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
  final EditorHighlighter cachedEditorHighlighter;
  boolean alreadyInitializedHighlighter = false;

  if (document != null &&
      (cachedEditorHighlighter = getEditorHighlighterForCachesBuilding(document)) != null &&
      PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(text, cachedEditorHighlighter)) {
    highlighter = cachedEditorHighlighter;
    alreadyInitializedHighlighter = true;
  }
  else if (virtualFile != null) {
    highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, virtualFile);
  }

  if (highlighter != null) {
    return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
  }
  return null;
}
项目:intellij-ce-playground    文件:TemplateEditorUtil.java   
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project));
  editor.getContentComponent().setFocusable(!isReadOnly);

  EditorSettings editorSettings = editor.getSettings();
  editorSettings.setVirtualSpace(false);
  editorSettings.setLineMarkerAreaShown(false);
  editorSettings.setIndentGuidesShown(false);
  editorSettings.setLineNumbersShown(false);
  editorSettings.setFoldingOutlineShown(false);
  editorSettings.setCaretRowShown(false);

  EditorColorsScheme scheme = editor.getColorsScheme();
  VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file != null) {
    EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
    ((EditorEx) editor).setHighlighter(highlighter);

  }

  return editor;
}
项目:intellij-ce-playground    文件:FileTemplateConfigurable.java   
private EditorHighlighter createHighlighter() {
  if (myTemplate != null && myVelocityFileType != FileTypes.UNKNOWN) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
  }

  FileType fileType = null;
  if (myTemplate != null) {
    fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension());
  }
  if (fileType == null) {
    fileType = FileTypes.PLAIN_TEXT;
  }

  SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
  if (originalHighlighter == null) {
    originalHighlighter = new PlainSyntaxHighlighter();
  }

  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme);
  highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, ""));
  return highlighter;
}
项目:intellij-ce-playground    文件:PyUtil.java   
/**
 * Force re-highlighting in all open editors that belong to specified project.
 */
public static void rehighlightOpenEditors(final @NotNull Project project) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {

      for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
        if (editor instanceof EditorEx && editor.getProject() == project) {
          final VirtualFile vFile = ((EditorEx)editor).getVirtualFile();
          if (vFile != null) {
            final EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, vFile);
            ((EditorEx)editor).setHighlighter(highlighter);
          }
        }
      }
    }
  });
}
项目:tools-idea    文件:FileTypeEditorHighlighterProviders.java   
@Override
protected List<EditorHighlighterProvider> buildExtensions(String stringKey, final FileType key) {
  List<EditorHighlighterProvider> fromEP = super.buildExtensions(stringKey, key);
  if (fromEP.isEmpty()) {
    EditorHighlighterProvider defaultProvider = new EditorHighlighterProvider() {
      @Override
      public EditorHighlighter getEditorHighlighter(@Nullable Project project,
                                                    @NotNull FileType fileType,
                                                    @Nullable VirtualFile virtualFile,
                                                    @NotNull EditorColorsScheme colors) {
        return EditorHighlighterFactory.getInstance().createEditorHighlighter(
          SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, virtualFile), colors);
      }
    };
    return Collections.singletonList(defaultProvider);
  }
  return fromEP;
}
项目:tools-idea    文件:TextEditorComponent.java   
/**
 * @return created editor. This editor should be released by {@link #disposeEditor(Editor) }
 * method.
 */
@NotNull
private Editor createEditor(){
  Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
  ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject);
  ((EditorEx) editor).setHighlighter(highlighter);
  ((EditorEx) editor).setFile(myFile);

  editor.addEditorMouseListener(myEditorMouseListener);

  ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));

  TextEditorProvider.putTextEditor(editor, myTextEditor);
  return editor;
}
项目:tools-idea    文件:TemplateEditorUtil.java   
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project));

  EditorSettings editorSettings = editor.getSettings();
  editorSettings.setVirtualSpace(false);
  editorSettings.setLineMarkerAreaShown(false);
  editorSettings.setIndentGuidesShown(false);
  editorSettings.setLineNumbersShown(false);
  editorSettings.setFoldingOutlineShown(false);

  EditorColorsScheme scheme = editor.getColorsScheme();
  scheme.setColor(EditorColors.CARET_ROW_COLOR, null);

  VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file != null) {
    EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
    ((EditorEx) editor).setHighlighter(highlighter);
  }

  return editor;
}
项目:tools-idea    文件:FileTemplateConfigurable.java   
private EditorHighlighter createHighlighter() {
  if (myTemplate != null && myProject != null && myVelocityFileType != FileTypes.UNKNOWN) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
  }

  FileType fileType = null;
  if (myTemplate != null) {
    fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension());
  }
  if (fileType == null) {
    fileType = FileTypes.PLAIN_TEXT;
  }
  SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
  if (originalHighlighter == null) originalHighlighter = new PlainSyntaxHighlighter();
  return new LexerEditorHighlighter(new TemplateHighlighter(originalHighlighter), EditorColorsManager.getInstance().getGlobalScheme());
}
项目:intellij-latte    文件:LatteIndexPatternBuilder.java   
@Nullable
@Override
public Lexer getIndexingLexer(@NotNull PsiFile file) {
    if (!(file instanceof LatteFile)) {
        return null;
    }
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null) {
        virtualFile = file.getViewProvider().getVirtualFile();
    }

    try {
        LayeredLexer.ourDisableLayersFlag.set(Boolean.TRUE);
        EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file.getProject(), virtualFile);
        return new LexerEditorHighlighterLexer(highlighter, false);
    } finally {
        LayeredLexer.ourDisableLayersFlag.set(Boolean.FALSE);
    }
}
项目:consulo    文件:DiffUtil.java   
@javax.annotation.Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @Nonnull DocumentContent content) {
  FileType type = content.getContentType();
  VirtualFile file = content.getHighlightFile();
  Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  if (language != null) {
    SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
    return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
  }
  if (file != null) {
    if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
      return highlighterFactory.createEditorHighlighter(project, file);
    }
  }
  if (type != null) {
    return highlighterFactory.createEditorHighlighter(project, type);
  }
  return null;
}
项目:consulo    文件:FileTypeEditorHighlighterProviders.java   
@Override
protected List<EditorHighlighterProvider> buildExtensions(String stringKey, final FileType key) {
  List<EditorHighlighterProvider> fromEP = super.buildExtensions(stringKey, key);
  if (fromEP.isEmpty()) {
    EditorHighlighterProvider defaultProvider = new EditorHighlighterProvider() {
      @Override
      public EditorHighlighter getEditorHighlighter(@Nullable Project project,
                                                    @Nonnull FileType fileType,
                                                    @Nullable VirtualFile virtualFile,
                                                    @Nonnull EditorColorsScheme colors) {
        return EditorHighlighterFactory.getInstance().createEditorHighlighter(
          SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, virtualFile), colors);
      }
    };
    return Collections.singletonList(defaultProvider);
  }
  return fromEP;
}
项目:consulo    文件:EditorHighlighterCache.java   
@Nullable
public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) {
  EditorHighlighter highlighter = null;

  PsiFile psiFile = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
  final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
  final EditorHighlighter cachedEditorHighlighter;
  boolean alreadyInitializedHighlighter = false;

  if (document != null &&
      (cachedEditorHighlighter = getEditorHighlighterForCachesBuilding(document)) != null &&
      PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(text, cachedEditorHighlighter)) {
    highlighter = cachedEditorHighlighter;
    alreadyInitializedHighlighter = true;
  }
  else if (virtualFile != null) {
    highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, virtualFile);
  }

  if (highlighter != null) {
    return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
  }
  return null;
}
项目:consulo    文件:TemplateEditorUtil.java   
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) {
  EditorFactory editorFactory = EditorFactory.getInstance();
  Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project));

  EditorSettings editorSettings = editor.getSettings();
  editorSettings.setVirtualSpace(false);
  editorSettings.setLineMarkerAreaShown(false);
  editorSettings.setIndentGuidesShown(false);
  editorSettings.setLineNumbersShown(false);
  editorSettings.setFoldingOutlineShown(false);

  EditorColorsScheme scheme = editor.getColorsScheme();
  scheme.setColor(EditorColors.CARET_ROW_COLOR, null);

  VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file != null) {
    EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
    ((EditorEx) editor).setHighlighter(highlighter);
  }

  return editor;
}
项目:consulo    文件:DetailViewImpl.java   
@Nonnull
protected Editor createEditor(@Nullable Project project, Document document, VirtualFile file) {
  EditorEx editor = (EditorEx)EditorFactory.getInstance().createViewer(document, project);

  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);

  editor.setFile(file);
  editor.setHighlighter(highlighter);

  EditorSettings settings = editor.getSettings();
  settings.setAnimatedScrolling(false);
  settings.setRefrainFromScrolling(false);
  settings.setLineNumbersShown(true);
  settings.setFoldingOutlineShown(false);
  if (settings instanceof SettingsImpl) {
    ((SettingsImpl)settings).setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.PREVIEW);
  }
  editor.getFoldingModel().setFoldingEnabled(false);

  return editor;
}
项目:consulo    文件:FileTemplateConfigurable.java   
private EditorHighlighter createHighlighter() {
  if (myTemplate != null && myVelocityFileType != UnknownFileType.INSTANCE) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
  }

  FileType fileType = null;
  if (myTemplate != null) {
    fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension());
  }
  if (fileType == null) {
    fileType = PlainTextFileType.INSTANCE;
  }

  SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
  if (originalHighlighter == null) {
    originalHighlighter = new PlainSyntaxHighlighter();
  }

  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme);
  highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, ""));
  return highlighter;
}
项目:GravSupport    文件:LanguageFileEditorGUI.java   
public Editor createEditor(Document document, Project project, @Nullable FileType fileType) {
    EditorImpl editor = (EditorImpl) EditorFactory.getInstance().createEditor(document, project);
    if (fileType != null) {
        editor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(project, fileType));
    }
    return editor;
}
项目:intellij-ce-playground    文件:DiffUtil.java   
@Nullable
public static EditorHighlighter createEditorHighlighter(@Nullable Project project, @NotNull DocumentContent content) {
  FileType type = content.getContentType();
  VirtualFile file = content.getHighlightFile();

  if ((file != null && file.getFileType() == type) || file instanceof LightVirtualFile) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(project, file);
  }
  if (type != null) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(project, type);
  }

  return null;
}
项目:intellij-ce-playground    文件:TextEditorComponent.java   
@NotNull
private Editor createEditor(){
  Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
  ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject);
  ((EditorEx) editor).setHighlighter(highlighter);
  ((EditorEx) editor).setFile(myFile);

  ((EditorEx)editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP);

  ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor));

  TextEditorProvider.putTextEditor(editor, myTextEditor);
  return editor;
}
项目:intellij-ce-playground    文件:TextEditorComponent.java   
/**
 * Updates editors' highlighters. This should be done when the opened file
 * changes its file type.
 */
private void updateHighlighters(){
  if (!myProject.isDisposed() && !myEditor.isDisposed()) {
    final EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile);
    ((EditorEx)myEditor).setHighlighter(highlighter);
  }
}
项目:intellij-ce-playground    文件:MergePanel2.java   
private void setHighlighterSettings(@Nullable EditorColorsScheme settings, @NotNull EditorPlace place) {
  if (settings == null) {
    settings = EditorColorsManager.getInstance().getGlobalScheme();
  }
  Editor editor = place.getEditor();
  DiffEditorState editorState = place.getState();
  if (editor != null) {
    ((EditorEx)editor).setHighlighter(EditorHighlighterFactory.getInstance().
      createEditorHighlighter(editorState.getFileType(), settings, editorState.getProject()));
  }
}
项目:intellij-ce-playground    文件:DiffHighlighterFactoryImpl.java   
public EditorHighlighter createHighlighter() {
  if (myFileType == null || myProject == null) return null;
  if ((myFile != null && myFile.getFileType() == myFileType) || myFile instanceof LightVirtualFile) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile);
  }
  return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFileType);
}
项目:intellij-ce-playground    文件:LineStatusTrackerDrawing.java   
@NotNull
private static Pair<JComponent, Integer> createEditorComponent(@NotNull Range range,
                                                               @NotNull Editor editor,
                                                               @NotNull LineStatusTracker tracker,
                                                               @Nullable List<DiffFragment> wordDiff) {
  if (range.getType() == Range.INSERTED) return Pair.create(null, 0);

  DocumentEx doc = (DocumentEx)tracker.getVcsDocument();
  EditorEx uEditor = (EditorEx)EditorFactory.getInstance().createViewer(doc, tracker.getProject());
  uEditor.setColorsScheme(editor.getColorsScheme());

  FileType fileType = tracker.getVirtualFile().getFileType();
  DiffUtil.setEditorCodeStyle(tracker.getProject(), uEditor, fileType);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  EditorHighlighter highlighter = highlighterFactory.createEditorHighlighter(tracker.getProject(), getFileName(tracker.getDocument()));
  uEditor.setHighlighter(highlighter);

  if (wordDiff != null) {
    int vcsStartShift = tracker.getVcsTextRange(range).getStartOffset();
    for (DiffFragment fragment : wordDiff) {
      int vcsStart = vcsStartShift + fragment.getStartOffset1();
      int vcsEnd = vcsStartShift + fragment.getEndOffset1();
      TextDiffType type = getDiffType(fragment);

      DiffDrawUtil.createInlineHighlighter(uEditor, vcsStart, vcsEnd, type);
    }
  }

  JComponent fragmentComponent =
    EditorFragmentComponent.createEditorFragmentComponent(uEditor, range.getVcsLine1(), range.getVcsLine2(), false, false);
  int leftBorder = fragmentComponent.getBorder().getBorderInsets(fragmentComponent).left;

  EditorFactory.getInstance().releaseEditor(uEditor);

  return Pair.create(fragmentComponent, leftBorder);
}
项目:intellij-ce-playground    文件:ActionUsagePanel.java   
private void configureByText(final String usageText, FileType fileType) {
  Document document = myEditor.getDocument();
  String text = StringUtil.convertLineSeparators(usageText);
  document.replaceString(0, document.getTextLength(), text);
  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  myEditor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(fileType, scheme, null));
  setupSpots(document);
}
项目:intellij-ce-playground    文件:LanguageConsoleImpl.java   
private void setupComponents() {
  myHelper.setupEditor(myConsoleEditor);
  myHelper.setupEditor(myHistoryViewer);

  myHistoryViewer.getComponent().setMinimumSize(JBUI.emptySize());
  myHistoryViewer.getComponent().setPreferredSize(JBUI.emptySize());
  myHistoryViewer.setCaretEnabled(false);

  myConsoleEditor.setContextMenuGroupId(IdeActions.GROUP_CONSOLE_EDITOR_POPUP);
  myConsoleEditor.setHighlighter(
    EditorHighlighterFactory.getInstance().createEditorHighlighter(getVirtualFile(), myConsoleEditor.getColorsScheme(), getProject()));

  myConsoleEditor.getScrollPane().getHorizontalScrollBar().setModel(
    myHistoryViewer.getScrollPane().getHorizontalScrollBar().getModel());
  setHistoryScrollBarVisible(false);

  myHistoryViewer.getContentComponent().addKeyListener(new KeyAdapter() {
    @Override
    public void keyTyped(KeyEvent event) {
      if (isConsoleEditorEnabled() && UIUtil.isReallyTypedEvent(event)) {
        myConsoleEditor.getContentComponent().requestFocus();
        myConsoleEditor.processKeyTyped(event);
      }
    }
  });

  EmptyAction.registerActionShortcuts(myHistoryViewer.getComponent(), myConsoleEditor.getComponent());
}
项目:intellij-ce-playground    文件:MethodSignatureComponent.java   
@Override
protected EditorEx createEditor() {
  EditorEx editor = super.createEditor();
  final String fileName = getFileName();
  if (fileName != null) {
    editor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(getProject(), fileName));
  }
  editor.getSettings().setWhitespacesShown(false);
  editor.setHorizontalScrollbarVisible(true);
  editor.setVerticalScrollbarVisible(true);
  return editor;
}
项目:intellij-ce-playground    文件:ByteCodeViewerComponent.java   
public ByteCodeViewerComponent(Project project, AnAction[] additionalActions) {
  super(new BorderLayout());
  final EditorFactory factory = EditorFactory.getInstance();
  final Document doc = ((EditorFactoryImpl)factory).createDocument("", true, false);
  doc.setReadOnly(true);
  myEditor = factory.createEditor(doc, project);
  EditorHighlighterFactory editorHighlighterFactory = EditorHighlighterFactory.getInstance();
  final SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JAVA, project, null);
  ((EditorEx)myEditor).setHighlighter(editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme()));
  ((EditorEx)myEditor).setCaretVisible(true);

  final EditorSettings settings = myEditor.getSettings();
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setLineNumbersShown(false);
  settings.setFoldingOutlineShown(false);

  myEditor.setBorder(null);
  add(myEditor.getComponent(), BorderLayout.CENTER);
  final ActionManager actionManager = ActionManager.getInstance();
  final DefaultActionGroup actions = new DefaultActionGroup();
  if (additionalActions != null) {
    for (final AnAction action : additionalActions) {
      actions.add(action);
    }
  }
  add(actionManager.createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true).getComponent(), BorderLayout.NORTH);
}
项目:tools-idea    文件:JspIndexPatternBuilder.java   
@Override
public Lexer getIndexingLexer(final PsiFile file) {
  if (JspPsiUtil.isInJspFile(file)) {
    EditorHighlighter highlighter = null;

    final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    final EditorHighlighter cachedEditorHighlighter;
    boolean alreadyInitializedHighlighter = false;

    if ((cachedEditorHighlighter = EditorHighlighterCache.getEditorHighlighterForCachesBuilding(document)) != null &&
        PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(file.getText(), cachedEditorHighlighter)) {
      highlighter = cachedEditorHighlighter;
      alreadyInitializedHighlighter = true;
    }
    else {
      final VirtualFile virtualFile = file.getVirtualFile();
      if (virtualFile != null) {
        highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file.getProject(), virtualFile);
      }
    }

    if (highlighter != null) {
      return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
    }
  }

  return null;
}
项目:tools-idea    文件:TextEditorComponent.java   
/**
 * Updates editors' highlighters. This should be done when the opened file
 * changes its file type.
 */
private void updateHighlighters(){
  if (!myProject.isDisposed()) {
    final EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile);
    ((EditorEx)myEditor).setHighlighter(highlighter);
  }
}
项目:tools-idea    文件:MergePanel2.java   
private void setHighlighterSettings(@Nullable EditorColorsScheme settings, @NotNull EditorPlace place) {
  if (settings == null) {
    settings = EditorColorsManager.getInstance().getGlobalScheme();
  }
  Editor editor = place.getEditor();
  DiffEditorState editorState = place.getState();
  if (editor != null) {
    ((EditorEx)editor).setHighlighter(EditorHighlighterFactory.getInstance().
      createEditorHighlighter(editorState.getFileType(), settings, editorState.getProject()));
  }
}
项目:tools-idea    文件:DiffHighlighterFactoryImpl.java   
public EditorHighlighter createHighlighter() {
  if (myFileType == null || myProject == null) return null;
  if ((myFile != null && myFile.getFileType() == myFileType) || myFile instanceof LightVirtualFile) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile);
  }
  return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFileType);
}
项目:tools-idea    文件:IntentionUsagePanel.java   
private void configureByText(final String usageText, FileType fileType) {
  Document document = myEditor.getDocument();
  String text = StringUtil.convertLineSeparators(usageText);
  document.replaceString(0, document.getTextLength(), text);
  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  myEditor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(fileType, scheme, null));
  setupSpots(document);
}
项目:tools-idea    文件:MethodSignatureComponent.java   
@Override
protected EditorEx createEditor() {
  EditorEx editor = super.createEditor();
  final String fileName = getFileName();
  if (fileName != null) {
    editor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(getProject(), fileName));
  }
  editor.getSettings().setWhitespacesShown(false);
  editor.setHorizontalScrollbarVisible(true);
  editor.setVerticalScrollbarVisible(true);
  return editor;
}
项目:tools-idea    文件:ByteCodeViewerComponent.java   
public ByteCodeViewerComponent(Project project, AnAction[] additionalActions) {
  super(new BorderLayout());
  final EditorFactory factory = EditorFactory.getInstance();
  final Document doc = factory.createDocument("");
  doc.setReadOnly(true);
  myEditor = factory.createEditor(doc, project);
  EditorHighlighterFactory editorHighlighterFactory = EditorHighlighterFactory.getInstance();
  final SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(StdFileTypes.JAVA, project, null);
  ((EditorEx)myEditor).setHighlighter(editorHighlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme()));
  ((EditorEx)myEditor).setBackgroundColor(EditorFragmentComponent.getBackgroundColor(myEditor));
  myEditor.getColorsScheme().setColor(EditorColors.CARET_ROW_COLOR, LightColors.SLIGHTLY_GRAY);
  ((EditorEx)myEditor).setCaretVisible(true);

  final EditorSettings settings = myEditor.getSettings();
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setLineNumbersShown(false);
  settings.setFoldingOutlineShown(false);

  myEditor.setBorder(null);
  add(myEditor.getComponent(), BorderLayout.CENTER);
  final ActionManager actionManager = ActionManager.getInstance();
  final DefaultActionGroup actions = new DefaultActionGroup();
  if (additionalActions != null) {
    for (final AnAction action : additionalActions) {
      actions.add(action);
    }
  }
  add(actionManager.createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true).getComponent(), BorderLayout.NORTH);
}
项目:consulo    文件:TextEditorImpl.java   
@Nonnull
protected Runnable loadEditorInBackground() {
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, scheme, myProject);
  EditorEx editor = (EditorEx)getEditor();
  highlighter.setText(editor.getDocument().getImmutableCharSequence());
  return () -> editor.setHighlighter(highlighter);
}
项目:consulo    文件:AsyncHighlighterUpdater.java   
@Override
public Continuation performInReadAction(@Nonnull ProgressIndicator indicator) throws ProcessCanceledException {
  if (!isEverythingValid()) return null;

  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile);
  return new Continuation(() -> ((EditorEx)myEditor).setHighlighter(highlighter));
}
项目:consulo    文件:MergePanel2.java   
private void setHighlighterSettings(@Nullable EditorColorsScheme settings, @Nonnull EditorPlace place) {
  if (settings == null) {
    settings = EditorColorsManager.getInstance().getGlobalScheme();
  }
  Editor editor = place.getEditor();
  DiffEditorState editorState = place.getState();
  if (editor != null) {
    ((EditorEx)editor).setHighlighter(EditorHighlighterFactory.getInstance().
            createEditorHighlighter(editorState.getFileType(), settings, editorState.getProject()));
  }
}
项目:consulo    文件:DiffHighlighterFactoryImpl.java   
public EditorHighlighter createHighlighter() {
  if (myFileType == null || myProject == null) return null;
  if ((myFile != null && myFile.getFileType() == myFileType) || myFile instanceof LightVirtualFile) {
    return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFile);
  }
  return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFileType);
}
项目:consulo    文件:LineStatusMarkerPopup.java   
@Nullable
private EditorFragmentComponent createEditorComponent(@Nullable FileType fileType, @Nullable List<DiffFragment> wordDiff) {
  if (myRange.getType() == Range.INSERTED) return null;

  EditorEx uEditor = (EditorEx)EditorFactory.getInstance().createViewer(myTracker.getVcsDocument(), myTracker.getProject());
  uEditor.setColorsScheme(myEditor.getColorsScheme());

  DiffUtil.setEditorCodeStyle(myTracker.getProject(), uEditor, fileType);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  uEditor.setHighlighter(highlighterFactory.createEditorHighlighter(myTracker.getProject(), getFileName(myTracker.getDocument())));

  if (wordDiff != null) {
    int vcsStartShift = myTracker.getVcsTextRange(myRange).getStartOffset();
    for (DiffFragment fragment : wordDiff) {
      int vcsStart = vcsStartShift + fragment.getStartOffset1();
      int vcsEnd = vcsStartShift + fragment.getEndOffset1();
      TextDiffType type = getDiffType(fragment);

      DiffDrawUtil.createInlineHighlighter(uEditor, vcsStart, vcsEnd, type);
    }
  }

  EditorFragmentComponent fragmentComponent =
          EditorFragmentComponent.createEditorFragmentComponent(uEditor, myRange.getVcsLine1(), myRange.getVcsLine2(), false, false);

  EditorFactory.getInstance().releaseEditor(uEditor);

  return fragmentComponent;
}