• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HighlightUsagesHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: highlightExitPoints

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
private void highlightExitPoints(final LuaReturnStatement statement,
                                 final LuaBlock block) {
  final Instruction[] flow = block.getControlFlow();
  final Collection<PsiElement> exitStatements = findExitPointsAndStatements(flow);
  if (!exitStatements.contains(statement)) {
    return;
  }

  final PsiElement originalTarget = getExitTarget(statement);
  for (PsiElement exitStatement : exitStatements) {
    if (getExitTarget(exitStatement) == originalTarget) {
      addOccurrence(exitStatement);
    }
  }
  myStatusText = CodeInsightBundle.message("status.bar.exit.points.highlighted.message",
                                           exitStatements.size(),
                                           HighlightUsagesHandler.getShortcutText());
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:19,代码来源:LuaHighlightExitPointsHandler.java


示例2: highlightUsages

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void highlightUsages(@NotNull PsiFile file, @NotNull Editor editor, boolean clearHighlights) {
  PsiElement target = getElement();

  if (file instanceof PsiCompiledFile) file = ((PsiCompiledFile)file).getDecompiledPsiFile();

  Project project = target.getProject();
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(project)).getFindUsagesManager();
  final FindUsagesHandler handler = findUsagesManager.getFindUsagesHandler(target, true);

  // in case of injected file, use host file to highlight all occurrences of the target in each injected file
  PsiFile context = InjectedLanguageManager.getInstance(project).getTopLevelFile(file);
  SearchScope searchScope = new LocalSearchScope(context);
  Collection<PsiReference> refs = handler == null
                                  ? ReferencesSearch.search(target, searchScope, false).findAll()
                                  : handler.findReferencesToHighlight(target, searchScope);

  new HighlightUsagesHandler.DoHighlightRunnable(new ArrayList<PsiReference>(refs), project, target,
                                                 editor, context, clearHighlights).run();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PsiElement2UsageTargetAdapter.java


示例3: highlightExitPoints

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
private void highlightExitPoints(final PyReturnStatement statement,
                                 final PyFunction function) {
  final ControlFlow flow = ControlFlowCache.getControlFlow(function);
  final Collection<PsiElement> exitStatements = findExitPointsAndStatements(flow);
  if (!exitStatements.contains(statement)) {
    return;
  }

  final PsiElement originalTarget = getExitTarget(statement);
  for (PsiElement exitStatement : exitStatements) {
    if (getExitTarget(exitStatement) == originalTarget) {
      addOccurrence(exitStatement);
    }
  }
  myStatusText = CodeInsightBundle.message("status.bar.exit.points.highlighted.message",
                                           exitStatements.size(),
                                           HighlightUsagesHandler.getShortcutText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PyHighlightExitPointsHandler.java


示例4: assertHighlighted

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
protected void assertHighlighted(VirtualFile file, HighlightInfo... expected) throws IOException {
  Editor editor = getEditor(file);
  HighlightUsagesHandler.invoke(myProject, editor, getTestPsiFile(file));

  RangeHighlighter[] highlighters = editor.getMarkupModel().getAllHighlighters();
  List<HighlightInfo> actual = new ArrayList<HighlightInfo>();
  for (RangeHighlighter each : highlighters) {
    if (!each.isValid()) continue;
    int offset = each.getStartOffset();
    PsiElement element = getTestPsiFile(file).findElementAt(offset);
    element = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    String text = editor.getDocument().getText().substring(offset, each.getEndOffset());
    actual.add(new HighlightInfo(element, text));
  }

  assertUnorderedElementsAreEqual(actual, expected);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenDomTestCase.java


示例5: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext());
  final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
  if (editor == null || project == null) return;
  String commandName = getTemplatePresentation().getText();
  if (commandName == null) commandName = "";

  CommandProcessor.getInstance().executeCommand(
    project,
    new Runnable() {
      @Override
      public void run() {
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        try {
          HighlightUsagesHandler.invoke(project, editor, psiFile);
        }
        catch (IndexNotReadyException ex) {
          DumbService.getInstance(project).showDumbModeNotification(ActionsBundle.message("action.HighlightUsagesInFile.not.ready"));
        }
      }
    },
    commandName,
    null
  );
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:HighlightUsagesAction.java


示例6: highlightUsages

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void highlightUsages(@Nonnull PsiFile file, @Nonnull Editor editor, boolean clearHighlights) {
  PsiElement target = getElement();

  if (file instanceof PsiCompiledFile) file = ((PsiCompiledFile)file).getDecompiledPsiFile();

  Project project = target.getProject();
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(project)).getFindUsagesManager();
  final FindUsagesHandler handler = findUsagesManager.getFindUsagesHandler(target, true);

  // in case of injected file, use host file to highlight all occurrences of the target in each injected file
  PsiFile context = InjectedLanguageManager.getInstance(project).getTopLevelFile(file);
  SearchScope searchScope = new LocalSearchScope(context);
  Collection<PsiReference> refs = handler == null ? ReferencesSearch.search(target, searchScope, false).findAll() : handler.findReferencesToHighlight(target, searchScope);

  new HighlightUsagesHandler.DoHighlightRunnable(new ArrayList<>(refs), project, target, editor, context, clearHighlights).run();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PsiElement2UsageTargetAdapter.java


示例7: modifyHighlightedArea

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Contract
protected void modifyHighlightedArea(
    @NotNull final Editor editor,
    @NotNull final List<PsiElement> column,
    final boolean clear
) {
    Validate.notNull(editor);
    Validate.notNull(column);

    if (null == editor.getProject()) {
        return;
    }

    if (editor.getProject().isDisposed()) {
        return;
    }

    // This list must be modifiable
    // https://bitbucket.org/AlexanderBartash/impex-editor-intellij-idea-plugin/issue/11/unsupportedoperationexception-null
    final List<TextRange> ranges = newArrayList();
    column.forEach((cell) -> ranges.add(cell.getTextRange()));

    HighlightUsagesHandler.highlightRanges(
        HighlightManager.getInstance(editor.getProject()),
        editor,
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES),
        clear,
        ranges
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:31,代码来源:DefaultImpexColumnHighlighterService.java


示例8: modifyHighlightedArea

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Contract(pure = false)
protected void modifyHighlightedArea(
    @NotNull final Editor editor,
    @NotNull final PsiElement impexFullHeaderParameter,
    final boolean clear
) {
    Validate.notNull(editor);
    Validate.notNull(impexFullHeaderParameter);

    if (null == editor.getProject()) {
        return;
    }

    if (editor.getProject().isDisposed()) {
        return;
    }

    // This list must be modifiable
    // https://bitbucket.org/AlexanderBartash/impex-editor-intellij-idea-plugin/issue/11/unsupportedoperationexception-null
    final List<TextRange> ranges = new ArrayList<TextRange>();
    ranges.add(impexFullHeaderParameter.getTextRange());

    HighlightUsagesHandler.highlightRanges(
        HighlightManager.getInstance(editor.getProject()),
        editor,
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES),
        clear,
        ranges
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:31,代码来源:DefaultImpexHeaderNameHighlighterService.java


示例9: handleCustomUsage

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
private static boolean handleCustomUsage(@NotNull Editor editor, @NotNull PsiFile file) {
        final HighlightUsagesHandlerBase handler =
                HighlightUsagesHandler.createCustomHandler(editor, file);
        
        if (handler == null) {
            return false;
        }
        
        final String featureId = handler.getFeatureId();
        if (featureId != null) {
            FeatureUsageTracker.getInstance().triggerFeatureUsed(featureId);
        }
        
        final List targets = handler.getTargets();
        if (targets == null) {
            return false;
        }
        
        try {
            // TODO: 06/02/2017 handle custom usages
            handler.highlightUsages();
//            targets
//            handler.computeUsages(targets);
//            final List readUsages = handler.getReadUsages();
//            final List writeUsages = handler.getWriteUsages();
            Log.className("handleCustomUsage", handler);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        return false;
    }
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:34,代码来源:MultiHighlightHandler.java


示例10: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
  final Project project = e.getProject();
  if (editor == null || project == null) return;

  String commandName = getTemplatePresentation().getText();
  if (commandName == null) commandName = "";

  CommandProcessor.getInstance().executeCommand(
    project,
    new Runnable() {
      @Override
      public void run() {
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        try {
          HighlightUsagesHandler.invoke(project, editor, psiFile);
        }
        catch (IndexNotReadyException ex) {
          DumbService.getInstance(project).showDumbModeNotification(ActionsBundle.message("action.HighlightUsagesInFile.not.ready"));
        }
      }
    },
    commandName,
    null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:HighlightUsagesAction.java


示例11: getHighlightUsages

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
/**
 * Returns read and write usages of psi element inside a single element
 *
 * @param target target psi element
 * @param psiElement psi element to search in
 * @return a pair where first element is read usages and second is write usages
 */
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiElement psiElement, boolean withDeclarations) {
  Collection<TextRange> readRanges = new ArrayList<TextRange>();
  Collection<TextRange> writeRanges = new ArrayList<TextRange>();
  final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
  final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
  final LocalSearchScope scope = new LocalSearchScope(psiElement);
  Collection<PsiReference> refs = findUsagesHandler != null
                            ? findUsagesHandler.findReferencesToHighlight(target, scope)
                            : ReferencesSearch.search(target, scope).findAll();
  for (PsiReference psiReference : refs) {
    if (psiReference == null) {
      LOG.error("Null reference returned, findUsagesHandler=" + findUsagesHandler + "; target=" + target + " of " + target.getClass());
      continue;
    }
    final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
    if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
      readRanges.addAll(textRanges);
    }
    else {
      writeRanges.addAll(textRanges);
    }
  }

  if (withDeclarations) {
    final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(), target);
    if (declRange != null) {
      if (detector != null && detector.isDeclarationWriteAccess(target)) {
        writeRanges.add(declRange);
      }
      else {
        readRanges.add(declRange);
      }
    }
  }

  return Couple.of(readRanges, writeRanges);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:IdentifierHighlighterPass.java


示例12: highlightTargetUsages

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
private void highlightTargetUsages(@NotNull PsiElement target) {
  final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
  final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
  final LocalSearchScope scope = new LocalSearchScope(myFile);
  Collection<PsiReference> refs = findUsagesHandler != null
                            ? findUsagesHandler.findReferencesToHighlight(target, scope)
                            : ReferencesSearch.search(target, scope).findAll();
  for (PsiReference psiReference : refs) {
    final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
    if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
      myReadAccessRanges.addAll(textRanges);
    }
    else {
      myWriteAccessRanges.addAll(textRanges);
    }
  }

  final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(myFile, target);
  if (declRange != null) {
    if (detector != null && detector.isDeclarationWriteAccess(target)) {
      myWriteAccessRanges.add(declRange);
    }
    else {
      myReadAccessRanges.add(declRange);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:IdentifierHighlighterPass.java


示例13: actionPerformed

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final Editor editor = e.getDataContext().getData(PlatformDataKeys.EDITOR);
  final Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  if (editor == null || project == null) return;
  String commandName = getTemplatePresentation().getText();
  if (commandName == null) commandName = "";

  CommandProcessor.getInstance().executeCommand(
    project,
    new Runnable() {
      @Override
      @RequiredDispatchThread
      public void run() {
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        try {
          HighlightUsagesHandler.invoke(project, editor, psiFile);
        }
        catch (IndexNotReadyException ex) {
          DumbService.getInstance(project).showDumbModeNotification(ActionsBundle.message("action.HighlightUsagesInFile.not.ready"));
        }
      }
    },
    commandName,
    null
  );
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:HighlightUsagesAction.java


示例14: IdentifierHighlighterPass

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
IdentifierHighlighterPass(@Nonnull Project project, @Nonnull PsiFile file, @Nonnull Editor editor) {
  super(project, editor.getDocument(), false);
  myFile = file;
  myEditor = editor;
  myCaretOffset = myEditor.getCaretModel().getOffset();
  myHighlightUsagesHandler = HighlightUsagesHandler.createCustomHandler(myEditor, myFile);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:IdentifierHighlighterPass.java


示例15: getUsages

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Nonnull
private static Couple<Collection<TextRange>> getUsages(@Nonnull PsiElement target, PsiElement psiElement, boolean withDeclarations, boolean detectAccess) {
  List<TextRange> readRanges = new ArrayList<>();
  List<TextRange> writeRanges = new ArrayList<>();
  final ReadWriteAccessDetector detector = detectAccess ? ReadWriteAccessDetector.findDetector(target) : null;
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
  final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
  final LocalSearchScope scope = new LocalSearchScope(psiElement);
  Collection<PsiReference> refs = findUsagesHandler != null
                                  ? findUsagesHandler.findReferencesToHighlight(target, scope)
                                  : ReferencesSearch.search(target, scope).findAll();
  for (PsiReference psiReference : refs) {
    if (psiReference == null) {
      LOG.error("Null reference returned, findUsagesHandler=" + findUsagesHandler + "; target=" + target + " of " + target.getClass());
      continue;
    }
    List<TextRange> destination;
    if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
      destination = readRanges;
    }
    else {
      destination = writeRanges;
    }
    HighlightUsagesHandler.collectRangesToHighlight(psiReference, destination);
  }

  if (withDeclarations) {
    final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(), target);
    if (declRange != null) {
      if (detector != null && detector.isDeclarationWriteAccess(target)) {
        writeRanges.add(declRange);
      }
      else {
        readRanges.add(declRange);
      }
    }
  }

  return Couple.<Collection<TextRange>>of(readRanges, writeRanges);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:41,代码来源:IdentifierHighlighterPass.java


示例16: getUsages

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@NotNull
private static Couple<List<TextRange>> getUsages(@NotNull PsiElement target,
        @NotNull PsiElement psiElement) {
    List<TextRange> readRanges = new ArrayList<>();
    List<TextRange> writeRanges = new ArrayList<>();
    final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
    final FindUsagesManager findUsagesManager = ((FindManagerImpl) FindManager.getInstance(
            target.getProject())).getFindUsagesManager();
    final FindUsagesHandler findUsagesHandler =
            findUsagesManager.getFindUsagesHandler(target, true);
    final LocalSearchScope scope = new LocalSearchScope(psiElement);
    Collection<PsiReference> refs =
            findUsagesHandler != null ? findUsagesHandler.findReferencesToHighlight(target,
                    scope) : ReferencesSearch.search(target, scope).findAll();
    for (PsiReference psiReference : refs) {
        if (psiReference == null) {
            Log.error("Null reference returned, findUsagesHandler=" + findUsagesHandler
                    + "; target=" + target + " of " + target.getClass());
            continue;
        }
        List<TextRange> destination;
        if (detector == null || detector.getReferenceAccess(target, psiReference)
                == ReadWriteAccessDetector.Access.Read) {
            destination = readRanges;
        } else {
            destination = writeRanges;
        }
        HighlightUsagesHandler.collectRangesToHighlight(psiReference, destination);
    }
    
    final TextRange declareRange =
            HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(),
                    target);
    if (declareRange != null) {
        if (detector != null && detector.isDeclarationWriteAccess(target)) {
            writeRanges.add(declareRange);
        } else {
            readRanges.add(declareRange);
        }
    }
    
    return Couple.of(readRanges, writeRanges);
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:44,代码来源:MultiHighlightHandler.java


示例17: ctrlShiftF7

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
protected void ctrlShiftF7() {
  HighlightUsagesHandler.invoke(getProject(), getEditor(), getFile());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:LightPlatformCodeInsightTestCase.java


示例18: doCollectInformation

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void doCollectInformation(@NotNull final ProgressIndicator progress) {
  @SuppressWarnings("unchecked") HighlightUsagesHandlerBase<PsiElement> handler = HighlightUsagesHandler.createCustomHandler(myEditor, myFile);
  if (handler != null) {
    List<PsiElement> targets = handler.getTargets();
    handler.computeUsages(targets);
    final List<TextRange> readUsages = handler.getReadUsages();
    for (TextRange readUsage : readUsages) {
      LOG.assertTrue(readUsage != null, "null text range from " + handler);
    }
    myReadAccessRanges.addAll(readUsages);
    final List<TextRange> writeUsages = handler.getWriteUsages();
    for (TextRange writeUsage : writeUsages) {
      LOG.assertTrue(writeUsage != null, "null text range from " + handler);
    }
    myWriteAccessRanges.addAll(writeUsages);
    if (!handler.highlightReferences()) return;
  }

  int flags = TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED;
  PsiElement myTarget;
  try {
    myTarget = TargetElementUtil.getInstance().findTargetElement(myEditor, flags, myCaretOffset);
  }
  catch (IndexNotReadyException e) {
    return;
  }
  
  if (myTarget == null) {
    if (!PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) {
      // when document is committed, try to check injected stuff - it's fast
      Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile, myCaretOffset);
      myTarget = TargetElementUtil.getInstance().findTargetElement(injectedEditor, flags, injectedEditor.getCaretModel().getOffset());
    }
  }
  
  if (myTarget != null) {
    highlightTargetUsages(myTarget);
  } else {
    PsiReference ref = TargetElementUtil.findReference(myEditor);
    if (ref instanceof PsiPolyVariantReference) {
      ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false);
      if (results.length > 0) {
        for (ResolveResult result : results) {
          PsiElement target = result.getElement();
          if (target != null) {
            highlightTargetUsages(target);
          }
        }
      }
    }

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


示例19: doCollectInformation

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
@Override
public void doCollectInformation(@NotNull final ProgressIndicator progress) {
  if (!CodeInsightSettings.getInstance().HIGHLIGHT_IDENTIFIER_UNDER_CARET) {
    return;
  }

  final HighlightUsagesHandlerBase<PsiElement> handler = HighlightUsagesHandler.createCustomHandler(myEditor, myFile);
  if (handler != null) {
    List<PsiElement> targets = handler.getTargets();
    handler.computeUsages(targets);
    final List<TextRange> readUsages = handler.getReadUsages();
    for (TextRange readUsage : readUsages) {
      LOG.assertTrue(readUsage != null, "null text range from " + handler);
    }
    myReadAccessRanges.addAll(readUsages);
    final List<TextRange> writeUsages = handler.getWriteUsages();
    for (TextRange writeUsage : writeUsages) {
      LOG.assertTrue(writeUsage != null, "null text range from " + handler);
    }
    myWriteAccessRanges.addAll(writeUsages);
    return;
  }

  int flags = TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED;
  PsiElement myTarget = TargetElementUtilBase.getInstance().findTargetElement(myEditor, flags, myCaretOffset);
  
  if (myTarget == null) {
    if (!PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) {
      // when document is committed, try to check injected stuff - it's fast
      Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile, myCaretOffset);
      if (injectedEditor != null) {
        myTarget = TargetElementUtilBase.getInstance().findTargetElement(injectedEditor, flags, injectedEditor.getCaretModel().getOffset()); 
      }
    }
  }
  
  if (myTarget != null) {
    highlightTargetUsages(myTarget);
  } else {
    PsiReference ref = TargetElementUtilBase.findReference(myEditor);
    if (ref instanceof PsiPolyVariantReference) {
      ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false);
      if (results.length > 0) {
        for (ResolveResult result : results) {
          PsiElement target = result.getElement();
          if (target != null) {
            highlightTargetUsages(target);
          }
        }
      }
    }

  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:55,代码来源:IdentifierHighlighterPass.java


示例20: ctrlShiftF7

import com.intellij.codeInsight.highlighting.HighlightUsagesHandler; //导入依赖的package包/类
protected void ctrlShiftF7()
{
	HighlightUsagesHandler.invoke(getProject(), getEditor(), getFile());
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:5,代码来源:CodeInsightTestCase.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HazelcastInstanceFactory类代码示例发布时间:2022-05-23
下一篇:
Java Cluster类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap