Java 类com.intellij.psi.impl.search.LexerEditorHighlighterLexer 实例源码

项目: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-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    文件: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    文件:SyntaxHighlighterOverEditorHighlighter.java   
public void restart(@NotNull CharSequence text) {
  lexer.start(text);

  if (lexer instanceof LexerEditorHighlighterLexer) {
    HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
    if (iterator instanceof LayeredHighlighterIterator) {
      layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
    } else {
      layeredHighlighterIterator = null;
    }
  }
}
项目:intellij-ce-playground    文件:SyntaxHighlighterOverEditorHighlighter.java   
public void resetPosition(int startOffset) {
  if (lexer instanceof LexerEditorHighlighterLexer) {
    ((LexerEditorHighlighterLexer)lexer).resetPosition(startOffset);

    HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
    if (iterator instanceof LayeredHighlighterIterator) {
      layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
    } else {
      layeredHighlighterIterator = null;
    }
  } else {
    CharSequence text = lexer.getBufferSequence();
    lexer.start(text, startOffset, text.length());
  }
}
项目:consulo    文件:SyntaxHighlighterOverEditorHighlighter.java   
public void restart(@Nonnull CharSequence text) {
  lexer.start(text);

  if (lexer instanceof LexerEditorHighlighterLexer) {
    HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
    if (iterator instanceof LayeredHighlighterIterator) {
      layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
    } else {
      layeredHighlighterIterator = null;
    }
  }
}
项目:consulo    文件:SyntaxHighlighterOverEditorHighlighter.java   
public void resetPosition(int startOffset) {
  if (lexer instanceof LexerEditorHighlighterLexer) {
    ((LexerEditorHighlighterLexer)lexer).resetPosition(startOffset);

    HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
    if (iterator instanceof LayeredHighlighterIterator) {
      layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
    } else {
      layeredHighlighterIterator = null;
    }
  } else {
    CharSequence text = lexer.getBufferSequence();
    lexer.start(text, startOffset, text.length());
  }
}