• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IdentifierHighlighterPass类的典型用法和代码示例

java 2次浏览

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

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

示例1: clearAllIdentifierHighlighters

点赞 2

import com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass; //导入依赖的package包/类
private static void clearAllIdentifierHighlighters() {
  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
      if (fileEditor instanceof TextEditor) {
        Document document = ((TextEditor)fileEditor).getEditor().getDocument();
        IdentifierHighlighterPass.clearMyHighlights(document, project);
      }
    }
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:EditorOptionsPanel.java

示例2: findNearest

点赞 2

import com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass; //导入依赖的package包/类
public static SourcePosition findNearest(@NotNull DebuggerContextImpl context, @NotNull PsiElement psi, @NotNull PsiFile file) {
  final DebuggerSession session = context.getDebuggerSession();
  if (session != null) {
    try {
      final XDebugSession debugSession = session.getXDebugSession();
      if (debugSession != null) {
        final XSourcePosition position = debugSession.getCurrentPosition();
        Editor editor = ((FileEditorManagerImpl)FileEditorManager.getInstance(file.getProject())).getSelectedTextEditor(true);

        //final Editor editor = fileEditor instanceof TextEditorImpl ? ((TextEditorImpl)fileEditor).getEditor() : null;
        if (editor != null && position != null && file.getVirtualFile().equals(position.getFile())) {
          PsiMethod method = PsiTreeUtil.getParentOfType(PositionUtil.getContextElement(context), PsiMethod.class, false);
          final Couple<Collection<TextRange>> usages =
            IdentifierHighlighterPass.getHighlightUsages(psi, method != null ? method : file, false);
          final List<TextRange> ranges = new ArrayList<TextRange>();
          ranges.addAll(usages.first);
          ranges.addAll(usages.second);
          final int breakPointLine = position.getLine();
          int bestLine = -1;
          int bestOffset = -1;
          for (TextRange range : ranges) {
            final int line = editor.offsetToLogicalPosition(range.getStartOffset()).line;
            if (line > bestLine && line < breakPointLine) {
              bestLine = line;
              bestOffset = range.getStartOffset();
            } else if (line == breakPointLine) {
              bestOffset = range.getStartOffset();
              break;
            }
          }
          if (bestOffset > -1) {
            return SourcePosition.createFromOffset(file, bestOffset);
          }
        }
      }
    }
    catch (Exception ignore) {
    }
  }
  return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:42,
代码来源:DebuggerContextUtil.java

示例3: findNearest

点赞 2

import com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass; //导入依赖的package包/类
public static SourcePosition findNearest(@NotNull DebuggerContextImpl context, @NotNull PsiElement psi, @NotNull PsiFile file)
{
	final DebuggerSession session = context.getDebuggerSession();
	if(session != null)
	{
		try
		{
			final XDebugSession debugSession = session.getXDebugSession();
			if(debugSession != null)
			{
				final XSourcePosition position = debugSession.getCurrentPosition();
				Editor editor = ((FileEditorManagerImpl) FileEditorManager.getInstance(file.getProject())).getSelectedTextEditor(true);

				//final Editor editor = fileEditor instanceof TextEditorImpl ? ((TextEditorImpl)fileEditor).getEditor() : null;
				if(editor != null && position != null && file.getVirtualFile().equals(position.getFile()))
				{
					PsiMethod method = PsiTreeUtil.getParentOfType(PositionUtil.getContextElement(context), PsiMethod.class, false);
					final Couple<Collection<TextRange>> usages = IdentifierHighlighterPass.getHighlightUsages(psi, method != null ? method : file, false);
					final List<TextRange> ranges = new ArrayList<TextRange>();
					ranges.addAll(usages.first);
					ranges.addAll(usages.second);
					final int breakPointLine = position.getLine();
					int bestLine = -1;
					int bestOffset = -1;
					for(TextRange range : ranges)
					{
						final int line = editor.offsetToLogicalPosition(range.getStartOffset()).line;
						if(line > bestLine && line < breakPointLine)
						{
							bestLine = line;
							bestOffset = range.getStartOffset();
						}
						else if(line == breakPointLine)
						{
							bestOffset = range.getStartOffset();
							break;
						}
					}
					if(bestOffset > -1)
					{
						return SourcePosition.createFromOffset(file, bestOffset);
					}
				}
			}
		}
		catch(Exception ignore)
		{
		}
	}
	return null;
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:52,
代码来源:DebuggerContextUtil.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)