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


Java FindUsagesOptions类代码示例

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


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

示例1: findTagUsage

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private int findTagUsage(XmlTag element) {
    final FindUsagesHandler handler = FindUsageUtils.getFindUsagesHandler(element, element.getProject());
    if (handler != null) {
        final FindUsagesOptions findUsagesOptions = handler.getFindUsagesOptions();
        final PsiElement[] primaryElements = handler.getPrimaryElements();
        final PsiElement[] secondaryElements = handler.getSecondaryElements();
        Factory factory = new Factory() {
            public UsageSearcher create() {
                return FindUsageUtils.createUsageSearcher(primaryElements, secondaryElements, handler, findUsagesOptions, (PsiFile) null);
            }
        };
        UsageSearcher usageSearcher = (UsageSearcher)factory.create();
        final AtomicInteger mCount = new AtomicInteger(0);
        usageSearcher.generate(new Processor<Usage>() {
            @Override
            public boolean process(Usage usage) {
                if (ResourceUsageCountUtils.isUsefulUsageToCount(usage)) {
                    mCount.incrementAndGet();
                }
                return true;
            }
        });
        return mCount.get();
    }
    return 0;
}
 
开发者ID:niorgai,项目名称:Android-Resource-Usage-Count,代码行数:27,代码来源:UsageCountLineProvider.java

示例2: findUsages

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@NotNull
public Collection<UsageInfo> findUsages(@NotNull final PsiElement targetElement, @Nullable SearchScope scope) {
  final Project project = getProject();
  final FindUsagesHandler handler =
    ((FindManagerImpl)FindManager.getInstance(project)).getFindUsagesManager().getFindUsagesHandler(targetElement, false);

  final CommonProcessors.CollectProcessor<UsageInfo> processor = new CommonProcessors.CollectProcessor<UsageInfo>();
  Assert.assertNotNull("Cannot find handler for: " + targetElement, handler);
  final PsiElement[] psiElements = ArrayUtil.mergeArrays(handler.getPrimaryElements(), handler.getSecondaryElements());
  final FindUsagesOptions options = handler.getFindUsagesOptions(null);
  if (scope != null) options.searchScope = scope; 
  for (PsiElement psiElement : psiElements) {
    handler.processElementUsages(psiElement, processor, options);
  }
  return processor.getResults();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CodeInsightTestFixtureImpl.java

示例3: findUsage

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
/**
 * Finds all usages of element. Works much like method in {@link com.intellij.testFramework.fixtures.CodeInsightTestFixture#findUsages(com.intellij.psi.PsiElement)},
 * but supports {@link com.intellij.find.findUsages.CustomUsageSearcher} and {@link com.intellij.psi.search.searches.ReferencesSearch} as well
 *
 * @param element what to find
 * @return usages
 */
@NotNull
protected Collection<PsiElement> findUsage(@NotNull final PsiElement element) {
  final Collection<PsiElement> result = new ArrayList<PsiElement>();
  final CollectProcessor<Usage> usageCollector = new CollectProcessor<Usage>();
  for (final CustomUsageSearcher searcher : CustomUsageSearcher.EP_NAME.getExtensions()) {
    searcher.processElementUsages(element, usageCollector, new FindUsagesOptions(myFixture.getProject()));
  }
  for (final Usage usage : usageCollector.getResults()) {
    if (usage instanceof PsiElementUsage) {
      result.add(((PsiElementUsage)usage).getElement());
    }
  }
  for (final PsiReference reference : ReferencesSearch.search(element).findAll()) {
    result.add(reference.getElement());
  }

  for (final UsageInfo info : myFixture.findUsages(element)) {
    result.add(info.getElement());
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PyTestCase.java

示例4: scanCatches

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private static boolean scanCatches(@NotNull PsiElement elem,
                                   @NotNull Processor<UsageInfo> processor,
                                   @NotNull Root root,
                                   @NotNull FindUsagesOptions options,
                                   @NotNull Set<PsiMethod> processed) {
  while (elem != null) {
    final PsiElement parent = elem.getParent();
    if (elem instanceof PsiMethod) {
      final PsiMethod deepestSuperMethod = ((PsiMethod)elem).findDeepestSuperMethod();
      final PsiMethod method = deepestSuperMethod != null ? deepestSuperMethod : (PsiMethod)elem;
      if (!processed.contains(method)) {
        processed.add(method);
        final PsiReference[] refs = MethodReferencesSearch.search(method, options.searchScope, true).toArray(PsiReference.EMPTY_ARRAY);
        for (int i = 0; i != refs.length; ++i) {
          if (!scanCatches(refs[i].getElement(), processor, root, options, processed)) return false;
        }
      }
      return true;
    }
    if (elem instanceof PsiTryStatement) {
      final PsiTryStatement aTry = (PsiTryStatement)elem;
      final PsiParameter[] catches = aTry.getCatchBlockParameters();
      for (int i = 0; i != catches.length; ++i) {
        if (!processExn(catches[i], processor, root)) {
          return false;
        }
      }
    }
    else if (parent instanceof PsiTryStatement) {
      final PsiTryStatement tryStmt = (PsiTryStatement)parent;
      if (elem != tryStmt.getTryBlock()) {
        elem = parent.getParent();
        continue;
      }
    }
    elem = parent;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:ThrowSearchUtil.java

示例5: findUsages

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private static Collection<UsageInfo> findUsages(@NotNull final PsiElement element) {
  final FindUsagesHandler handler = createFindUsageHandler(element);
  if (handler == null) {
    return Lists.newArrayList();
  }
  final CommonProcessors.CollectProcessor<UsageInfo> processor = new CommonProcessors.CollectProcessor<UsageInfo>();
  final PsiElement[] psiElements = ArrayUtil.mergeArrays(handler.getPrimaryElements(), handler.getSecondaryElements());
  final FindUsagesOptions options = handler.getFindUsagesOptions(null);
  for (PsiElement psiElement : psiElements) {
    handler.processElementUsages(psiElement, processor, options);
  }
  return processor.getResults();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PyStaticCallHierarchyUtil.java

示例6: processElementUsages

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@Override
public void processElementUsages(@NotNull PsiElement element, @NotNull Processor<Usage> processor, @NotNull FindUsagesOptions options) {
    if (element instanceof PsiMethod) {
        processJavaUsages((PsiMethod) element, processor);
    } else if (element instanceof RobotKeywordTitle) {
        processKeywordUsages((RobotKeywordTitle) element, processor);
    } else if (element instanceof RobotScalarVariable ||
               element instanceof RobotScalarAssignment ||
               element instanceof RobotScalarAssignmentLhs ||
               element instanceof RobotArgumentDef) {
        processVariableUsages(element, processor);
    }
}
 
开发者ID:charlescapps,项目名称:robot-intellij-plugin,代码行数:14,代码来源:RobotCustomUsagesSearcher.java

示例7: runFindUsageReadAction

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private void runFindUsageReadAction(final PsiElement psiElement, final Processor<UsageInfo> processor, final FindUsagesOptions findUsagesOptions) {
    ApplicationManager.getApplication().runReadAction(() -> {
        if (psiElement instanceof PsiMethod) {
            PsiMethod[] psiMethods = SuperMethodWarningUtil.checkSuperMethods((PsiMethod) psiElement, CustomFUH.getActionString());
            if (psiMethods.length < 1) return;
            for (PsiElement method : psiMethods)
                StepFindUsagesHandler.this.processUsages(method, processor, findUsagesOptions);
        }
        StepFindUsagesHandler.this.processUsages(psiElement, processor, findUsagesOptions);
    });
}
 
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:12,代码来源:StepFindUsagesHandler.java

示例8: getDefaultOptions

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@NotNull
private static FindUsagesOptions getDefaultOptions(@NotNull FindUsagesHandler handler) {
  FindUsagesOptions options =
      handler.getFindUsagesOptions(DataManager.getInstance().getDataContext());
  // by default, scope in FindUsagesOptions is copied from the FindSettings, but we need a default one
  options.searchScope = FindUsagesManager.getMaximalScope(handler);
  return options;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:9,代码来源:ShowUsagesAction.java

示例9: showHint

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private void showHint(@NotNull String text, @Nullable final Editor editor,
    @NotNull final RelativePoint popupPosition, @NotNull FindUsagesHandler handler, int maxUsages,
    @NotNull FindUsagesOptions options) {
  JComponent label =
      createHintComponent(text, handler, popupPosition, editor, HIDE_HINTS_ACTION, maxUsages,
          options);

  HintManager.getInstance().showHint(label, popupPosition, HintManager.HIDE_BY_ANY_KEY |
      HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0);
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:11,代码来源:ShowUsagesAction.java

示例10: createHintComponent

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@NotNull
private JComponent createHintComponent(@NotNull String text,
    @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition,
    final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages,
    @NotNull final FindUsagesOptions options) {
  JComponent label =
      HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + "&nbsp;"));
  InplaceButton button =
      createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction);

  JPanel panel = new JPanel(new BorderLayout()) {
    @Override
    public void addNotify() {
      mySearchEverywhereRunnable = new Runnable() {
        @Override
        public void run() {
          searchEverywhere(options, handler, editor, popupPosition, maxUsages);
        }
      };
      super.addNotify();
    }

    @Override
    public void removeNotify() {
      mySearchEverywhereRunnable = null;
      super.removeNotify();
    }
  };
  button.setBackground(label.getBackground());
  panel.setBackground(label.getBackground());
  label.setOpaque(false);
  label.setBorder(null);
  panel.setBorder(HintUtil.createHintBorder());
  panel.add(label, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:38,代码来源:ShowUsagesAction.java

示例11: notNullizeScope

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@NotNull
private static SearchScope notNullizeScope(@NotNull FindUsagesOptions options,
    @NotNull Project project) {
  SearchScope scope = options.searchScope;
  if (scope == null) return ProjectScope.getAllScope(project);
  return scope;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:8,代码来源:ShowUsagesAction.java

示例12: suggestSecondInvocation

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@NotNull
private static String suggestSecondInvocation(@NotNull FindUsagesOptions options,
    @NotNull FindUsagesHandler handler, @NotNull String text) {
  final String title = getSecondInvocationTitle(options, handler);

  if (title != null) {
    text += "<br><small>Press " + title + "</small>";
  }
  return "<html><body>" + text + "</body></html>";
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:11,代码来源:ShowUsagesAction.java

示例13: getSecondInvocationTitle

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
@Nullable
private static String getSecondInvocationTitle(@NotNull FindUsagesOptions options,
    @NotNull FindUsagesHandler handler) {
  if (getShowUsagesShortcut() != null) {
    GlobalSearchScope maximalScope = FindUsagesManager.getMaximalScope(handler);
    if (!notNullizeScope(options, handler.getProject()).equals(maximalScope)) {
      return "Press "
          + KeymapUtil.getShortcutText(getShowUsagesShortcut())
          + " again to search in "
          + maximalScope.getDisplayName();
    }
  }
  return null;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:15,代码来源:ShowUsagesAction.java

示例14: searchEverywhere

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private void searchEverywhere(@NotNull FindUsagesOptions options,
    @NotNull FindUsagesHandler handler, Editor editor, @NotNull RelativePoint popupPosition,
    int maxUsages) {
  FindUsagesOptions cloned = options.clone();
  cloned.searchScope = FindUsagesManager.getMaximalScope(handler);
  showElementUsages(handler, editor, popupPosition, maxUsages, cloned);
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:8,代码来源:ShowUsagesAction.java

示例15: navigateAndHint

import com.intellij.find.findUsages.FindUsagesOptions; //导入依赖的package包/类
private void navigateAndHint(@NotNull Usage usage, @Nullable final String hint,
    @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition,
    final int maxUsages, @NotNull final FindUsagesOptions options) {
  usage.navigate(true);
  if (hint == null) return;
  final Editor newEditor = getEditorFor(usage);
  if (newEditor == null) return;
  final Project project = handler.getProject();
  //opening editor is performing in invokeLater
  IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
    @Override
    public void run() {
      newEditor.getScrollingModel().runActionOnScrollingFinished(new Runnable() {
        @Override
        public void run() {
          // after new editor created, some editor resizing events are still bubbling. To prevent hiding hint, invokeLater this
          IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
            @Override
            public void run() {
              if (newEditor.getComponent().isShowing()) {
                showHint(hint, newEditor, popupPosition, handler, maxUsages, options);
              }
            }
          });
        }
      });
    }
  });
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:30,代码来源:ShowUsagesAction.java


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