当前位置: 首页>>代码示例>>Java>>正文


Java LexerEditorHighlighter类代码示例

本文整理汇总了Java中com.intellij.openapi.editor.ex.util.LexerEditorHighlighter的典型用法代码示例。如果您正苦于以下问题:Java LexerEditorHighlighter类的具体用法?Java LexerEditorHighlighter怎么用?Java LexerEditorHighlighter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LexerEditorHighlighter类属于com.intellij.openapi.editor.ex.util包,在下文中一共展示了LexerEditorHighlighter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEditorHighlighterForCachesBuilding

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
@Nullable
public static EditorHighlighter getEditorHighlighterForCachesBuilding(Document document) {
  if (document == null) {
    return null;
  }
  final WeakReference<EditorHighlighter> editorHighlighterWeakReference = document.getUserData(ourSomeEditorSyntaxHighlighter);
  final EditorHighlighter someEditorHighlighter = SoftReference.dereference(editorHighlighterWeakReference);

  if (someEditorHighlighter instanceof LexerEditorHighlighter &&
      ((LexerEditorHighlighter)someEditorHighlighter).isValid()
    ) {
    return someEditorHighlighter;
  }
  document.putUserData(ourSomeEditorSyntaxHighlighter, null);
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorHighlighterCache.java

示例2: showFormSource

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
public void showFormSource() {
  EditorFactory editorFactory = EditorFactory.getInstance();

  Editor editor = editorFactory.createViewer(myDocument, myProject);

  try {
    ((EditorEx)editor).setHighlighter(
      new LexerEditorHighlighter(new XmlFileHighlighter(), EditorColorsManager.getInstance().getGlobalScheme()));

    JComponent component = editor.getComponent();
    component.setPreferredSize(new Dimension(640, 480));

    DialogBuilder dialog = new DialogBuilder(myProject);

    dialog.title("Form - " + myFile.getPresentableName()).dimensionKey("GuiDesigner.FormSource.Dialog");
    dialog.centerPanel(component).setPreferredFocusComponent(editor.getContentComponent());
    dialog.addOkAction();

    dialog.show();
  }
  finally {
    editorFactory.releaseEditor(editor);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GuiEditor.java

示例3: getEditorHighlighterForCachesBuilding

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
@Nullable
public static EditorHighlighter getEditorHighlighterForCachesBuilding(Document document) {
  if (document == null) {
    return null;
  }
  final WeakReference<EditorHighlighter> editorHighlighterWeakReference = document.getUserData(ourSomeEditorSyntaxHighlighter);
  final EditorHighlighter someEditorHighlighter = editorHighlighterWeakReference != null ? editorHighlighterWeakReference.get() : null;

  if (someEditorHighlighter instanceof LexerEditorHighlighter &&
      ((LexerEditorHighlighter)someEditorHighlighter).isValid()
    ) {
    return someEditorHighlighter;
  }
  document.putUserData(ourSomeEditorSyntaxHighlighter, null);
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:EditorHighlighterCache.java

示例4: createHighlighter

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
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());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:FileTemplateConfigurable.java

示例5: reinitSettings

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
private static void reinitSettings(final EditorEx editor) {
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  editor.setColorsScheme(scheme);
  EditorSettings settings = editor.getSettings();
  settings.setLineNumbersShown(false);
  settings.setWhitespacesShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setIndentGuidesShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setAdditionalColumnsCount(0);
  settings.setAdditionalLinesCount(0);
  settings.setRightMarginShown(true);
  settings.setRightMargin(60);

  editor.setHighlighter(new LexerEditorHighlighter(new PropertiesValueHighlighter(), scheme));
  editor.setVerticalScrollbarVisible(true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ResourceBundleEditor.java

示例6: getEditorHighlighterForCachesBuilding

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
@Nullable
public static EditorHighlighter getEditorHighlighterForCachesBuilding(Document document) {
  if (document == null) {
    return null;
  }
  final WeakReference<EditorHighlighter> editorHighlighterWeakReference = document.getUserData(ourSomeEditorSyntaxHighlighter);
  final EditorHighlighter someEditorHighlighter = SoftReference.dereference(editorHighlighterWeakReference);

  if (someEditorHighlighter instanceof LexerEditorHighlighter &&
      ((LexerEditorHighlighter)someEditorHighlighter).isValid()
          ) {
    return someEditorHighlighter;
  }
  document.putUserData(ourSomeEditorSyntaxHighlighter, null);
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:EditorHighlighterCache.java

示例7: printWithHighlighting

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
public static String printWithHighlighting(@Nonnull LanguageConsoleView console, @Nonnull Editor inputEditor, @Nonnull TextRange textRange) {
  String text;
  EditorHighlighter highlighter;
  if (inputEditor instanceof EditorWindow) {
    PsiFile file = ((EditorWindow)inputEditor).getInjectedFile();
    highlighter = HighlighterFactory.createHighlighter(file.getVirtualFile(), EditorColorsManager.getInstance().getGlobalScheme(), console.getProject());
    String fullText = InjectedLanguageUtil.getUnescapedText(file, null, null);
    highlighter.setText(fullText);
    text = textRange.substring(fullText);
  }
  else {
    text = inputEditor.getDocument().getText(textRange);
    highlighter = ((EditorEx)inputEditor).getHighlighter();
  }
  SyntaxHighlighter syntax = highlighter instanceof LexerEditorHighlighter ? ((LexerEditorHighlighter)highlighter).getSyntaxHighlighter() : null;
  ((LanguageConsoleImpl)console).doAddPromptToHistory();
  if (syntax != null) {
    ConsoleViewUtil.printWithHighlighting(console, text, syntax);
  }
  else {
    console.print(text, ConsoleViewContentType.USER_INPUT);
  }
  console.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
  return text;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:LanguageConsoleImpl.java

示例8: canPaintImmediately

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
private boolean canPaintImmediately(char c) {
  return getDocument() instanceof DocumentImpl &&
         getHighlighter() instanceof LexerEditorHighlighter &&
         !getSelectionModel().hasSelection() &&
         arePositionsWithinDocument(getCaretModel().getAllCarets()) &&
         areVisualLinesUnique(getCaretModel().getAllCarets()) &&
         !isInplaceRenamerActive() &&
         !KEY_CHARS_TO_SKIP.contains(c);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ImmediatePainter.java

示例9: printWithHighlighting

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
public static String printWithHighlighting(@NotNull LanguageConsoleView console, @NotNull Editor inputEditor, @NotNull TextRange textRange) {
  String text;
  EditorHighlighter highlighter;
  if (inputEditor instanceof EditorWindow) {
    PsiFile file = ((EditorWindow)inputEditor).getInjectedFile();
    highlighter =
      HighlighterFactory.createHighlighter(file.getVirtualFile(), EditorColorsManager.getInstance().getGlobalScheme(), console.getProject());
    String fullText = InjectedLanguageUtil.getUnescapedText(file, null, null);
    highlighter.setText(fullText);
    text = textRange.substring(fullText);
  }
  else {
    text = inputEditor.getDocument().getText(textRange);
    highlighter = ((EditorEx)inputEditor).getHighlighter();
  }
  SyntaxHighlighter syntax =
    highlighter instanceof LexerEditorHighlighter ? ((LexerEditorHighlighter)highlighter).getSyntaxHighlighter() : null;
  ((LanguageConsoleImpl)console).doAddPromptToHistory();
  if (syntax != null) {
    ConsoleViewUtil.printWithHighlighting(console, text, syntax);
  }
  else {
    console.print(text, ConsoleViewContentType.USER_INPUT);
  }
  console.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:LanguageConsoleImpl.java

示例10: buildBraceMatcherBasedFolding

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
public static void buildBraceMatcherBasedFolding(List<FoldingDescriptor> descriptors,
                                                 PsiElement root,
                                                 Document document,
                                                 SyntaxHighlighter highlighter) {
  LexerEditorHighlighter editorHighlighter = new LexerEditorHighlighter(highlighter, EditorColorsManager.getInstance().getGlobalScheme());
  editorHighlighter.setText(document.getText());
  FileType fileType = root.getContainingFile().getFileType();
  BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, root.getLanguage());
  TextRange totalRange = root.getTextRange();
  final HighlighterIterator iterator = editorHighlighter.createIterator(totalRange.getStartOffset());

  final LinkedList<Trinity<Integer, Integer, IElementType>> stack = new LinkedList<Trinity<Integer, Integer, IElementType>>();
  String editorText = document.getText();
  while (!iterator.atEnd() && iterator.getStart() < totalRange.getEndOffset()) {
    final Trinity<Integer, Integer, IElementType> last;
    if (braceMatcher.isLBraceToken(iterator, editorText, fileType) &&
        braceMatcher.isStructuralBrace(iterator, editorText, fileType)) {
      stack.addLast(Trinity.create(iterator.getStart(), iterator.getEnd(), iterator.getTokenType()));
    }
    else if (braceMatcher.isRBraceToken(iterator, editorText, fileType) &&
             braceMatcher.isStructuralBrace(iterator, editorText, fileType)
             && !stack.isEmpty() && braceMatcher.isPairBraces((last = stack.getLast()).third, iterator.getTokenType())) {
      stack.removeLast();
      TextRange range = new TextRange(last.first, iterator.getEnd());
      if (StringUtil.countChars(document.getText(range), '\n') >= 3) {
        descriptors.add(new FoldingDescriptor(root, range));
      }
    }
    iterator.advance();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:CustomFileTypeFoldingBuilder.java

示例11: createEditorHighlighter

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
@Override
public EditorHighlighter createEditorHighlighter(@NotNull VirtualFile vFile, @NotNull EditorColorsScheme settings, @Nullable Project project) {
  FileType fileType = vFile.getFileType();
  if (fileType instanceof LanguageFileType) {
    LanguageFileType substFileType = substituteFileType(((LanguageFileType)fileType).getLanguage(), vFile, project);
    if (substFileType != null) {
      EditorHighlighterProvider provider = FileTypeEditorHighlighterProviders.INSTANCE.forFileType(substFileType);
      EditorHighlighter editorHighlighter = provider.getEditorHighlighter(project, fileType, vFile, settings);
      boolean isPlain = editorHighlighter.getClass() == LexerEditorHighlighter.class &&
                        ((LexerEditorHighlighter) editorHighlighter).isPlain();
      if (!isPlain) {
        return editorHighlighter;
      }
    }
    return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType).getEditorHighlighter(project, fileType, vFile, settings);
  }

  SyntaxHighlighter highlighter = null;
  for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) {
    boolean applicable;
    try {
      applicable = processor.isApplicable(project, vFile);
    }
    catch (Exception e) {
      LOG.error(e);
      continue;
    }
    if (applicable && processor instanceof ContentBasedClassFileProcessor) {
      highlighter = ((ContentBasedClassFileProcessor)processor).createHighlighter(project, vFile);
    }
  }
  if (highlighter == null) {
    highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, vFile);
  }
  return createEditorHighlighter(highlighter, settings);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:EditorHighlighterFactoryImpl.java

示例12: createHighlighter

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
private EditorHighlighter createHighlighter(EditorColorsScheme settings) {
    Language language = Language.findLanguageByID("JSON");
    if (language == null) {
        language = Language.ANY;
    }
    return new LexerEditorHighlighter(PlainTextSyntaxHighlighterFactory.getSyntaxHighlighter(language, null, null), settings);
}
 
开发者ID:dboissier,项目名称:nosql4idea,代码行数:8,代码来源:QueryPanel.java

示例13: showFormSource

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
public void showFormSource()
{
	EditorFactory editorFactory = EditorFactory.getInstance();

	Editor editor = editorFactory.createViewer(myDocument, myProject);

	try
	{
		((EditorEx) editor).setHighlighter(new LexerEditorHighlighter(new XmlFileHighlighter(),
				EditorColorsManager.getInstance().getGlobalScheme()));

		JComponent component = editor.getComponent();
		component.setPreferredSize(new Dimension(640, 480));

		DialogBuilder dialog = new DialogBuilder(myProject);

		dialog.title("Form - " + myFile.getPresentableName()).dimensionKey("GuiDesigner.FormSource.Dialog");
		dialog.centerPanel(component).setPreferredFocusComponent(editor.getContentComponent());
		dialog.addOkAction();

		dialog.show();
	}
	finally
	{
		editorFactory.releaseEditor(editor);
	}
}
 
开发者ID:consulo,项目名称:consulo-ui-designer,代码行数:28,代码来源:GuiEditor.java

示例14: canPaintImmediately

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
private static boolean canPaintImmediately(final EditorImpl editor) {
  final CaretModel caretModel = editor.getCaretModel();
  final Caret caret = caretModel.getPrimaryCaret();
  final Document document = editor.getDocument();

  return !(editor.getComponent().getParent() instanceof EditorTextField) &&
         document instanceof DocumentImpl &&
         editor.getHighlighter() instanceof LexerEditorHighlighter &&
         !editor.getSelectionModel().hasSelection() &&
         caretModel.getCaretCount() == 1 &&
         !isInVirtualSpace(editor, caret) &&
         !isInsertion(document, caret.getOffset()) &&
         !caret.isAtRtlLocation() &&
         !caret.isAtBidiRunBoundary();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:ImmediatePainter.java

示例15: getLazyParsableHighlighterIfAny

import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; //导入依赖的package包/类
@Nonnull
static EditorHighlighter getLazyParsableHighlighterIfAny(Project project, Editor editor, PsiFile psiFile) {
  if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) {
    return ((EditorEx)editor).getHighlighter();
  }
  PsiElement elementAt = psiFile.findElementAt(editor.getCaretModel().getOffset());
  for (PsiElement e : SyntaxTraverser.psiApi().parents(elementAt).takeWhile(Conditions.notEqualTo(psiFile))) {
    if (!(PsiUtilCore.getElementType(e) instanceof ILazyParseableElementType)) continue;
    Language language = ILazyParseableElementType.LANGUAGE_KEY.get(e.getNode());
    if (language == null) continue;
    TextRange range = e.getTextRange();
    final int offset = range.getStartOffset();
    SyntaxHighlighter syntaxHighlighter =
            SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, psiFile.getVirtualFile());
    LexerEditorHighlighter highlighter = new LexerEditorHighlighter(syntaxHighlighter, editor.getColorsScheme()) {
      @Nonnull
      @Override
      public HighlighterIterator createIterator(int startOffset) {
        return new HighlighterIteratorWrapper(super.createIterator(Math.max(startOffset - offset, 0))) {
          @Override
          public int getStart() {
            return super.getStart() + offset;
          }

          @Override
          public int getEnd() {
            return super.getEnd() + offset;
          }
        };
      }
    };
    highlighter.setText(editor.getDocument().getText(range));
    return highlighter;
  }
  return ((EditorEx)editor).getHighlighter();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:37,代码来源:BraceHighlightingHandler.java


注:本文中的com.intellij.openapi.editor.ex.util.LexerEditorHighlighter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。