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


Java Usage类代码示例

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


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

示例1: setSelected

import com.intellij.usages.Usage; //导入依赖的package包/类
@Override
public void setSelected(AnActionEvent e, boolean state) {
    JGivenSettings.getInstance().setJGivenFilteringEnabled(state);
    if (e.getProject() == null) {
        return;
    }
    Set<Usage> scenarioStateUsages = usageView.getUsages().stream()
            .filter(u -> u instanceof ReadWriteAccessUsageInfo2UsageAdapter &&
                    scenarioStateAnnotationProvider.isJGivenScenarioState(((ReadWriteAccessUsageInfo2UsageAdapter) u).getElement()))
            .collect(Collectors.toSet());

    if (state) {
        excludedUsages.stream()
                .filter(u -> !scenarioStateUsages.contains(u))
                .forEach(usageView::appendUsage);
    } else {
        excludedUsages = usageView.getUsages().stream()
                .filter(scenarioStateUsages::contains)
                .collect(Collectors.toSet());
        excludedUsages.forEach(usageView::removeUsage);
    }
    e.getProject().getMessageBus().syncPublisher(UsageFilteringRuleProvider.RULES_CHANGED).run();
}
 
开发者ID:TNG,项目名称:jgiven-intellij-plugin,代码行数:24,代码来源:FilterByJGivenStateAction.java

示例2: findTagUsage

import com.intellij.usages.Usage; //导入依赖的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

示例3: customizeCellRenderer

import com.intellij.usages.Usage; //导入依赖的package包/类
@Override
public void customizeCellRenderer(@NotNull SliceUsageCellRendererBase renderer,
                                  @NotNull JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
  Usage usage = getValue();
  renderer.append("Value: ", SimpleTextAttributes.REGULAR_ATTRIBUTES);

  if (usage instanceof UsageInfo2UsageAdapter) {
    PsiElement element = ((UsageInfo2UsageAdapter)usage).getElement();
    if (element == null) {
      renderer.append(UsageViewBundle.message("node.invalid") + " ", SliceUsageCellRenderer.ourInvalidAttributes);
    }
    else {
      appendElementText((UsageInfo2UsageAdapter)usage, element, renderer);
    }
  }
  else {
    renderer.append("Other", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SliceLeafValueRootNode.java

示例4: testFindWholeWords

import com.intellij.usages.Usage; //导入依赖的package包/类
public void testFindWholeWords() {
  configureByText(FileTypes.PLAIN_TEXT, "-- -- ---");
  FindModel model = new FindModel();
  model.setStringToFind("--");
  model.setWholeWordsOnly(true);

  List<Usage> usages = FindUtil.findAll(myProject, myEditor, model);
  assertNotNull(usages);
  assertEquals(2, usages.size());

  configureByText(FileTypes.PLAIN_TEXT, "[email protected]");
  model = new FindModel();
  model.setStringToFind("@AspectJ");
  model.setWholeWordsOnly(true);
  usages = FindUtil.findAll(myProject, myEditor, model);
  assertNotNull(usages);
  assertEquals(1, usages.size());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FindManagerTest.java

示例5: appendUsage

import com.intellij.usages.Usage; //导入依赖的package包/类
@Nullable
UsageNode appendUsage(@NotNull Usage usage, @NotNull Consumer<Runnable> edtQueue) {
  if (!isVisible(usage)) return null;

  final boolean dumb = DumbService.isDumb(myProject);

  GroupNode lastGroupNode = myRoot;
  for (int i = 0; i < myGroupingRules.length; i++) {
    final UsageGroupingRule rule = myGroupingRules[i];
    if (dumb && !DumbService.isDumbAware(rule)) continue;
    
    final UsageGroup group;
    if (rule instanceof UsageGroupingRuleEx) {
      group = ((UsageGroupingRuleEx) rule).groupUsage(usage, myTargets);
    }
    else {
      group = rule.groupUsage(usage);
    }
    if (group != null) {
      lastGroupNode = lastGroupNode.addGroup(group, i, edtQueue);
    }
  }

  return lastGroupNode.addUsage(usage, edtQueue);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:UsageNodeTreeBuilder.java

示例6: tryMerge

import com.intellij.usages.Usage; //导入依赖的package包/类
@Nullable UsageNode tryMerge(@NotNull Usage usage) {
  if (!(usage instanceof MergeableUsage)) return null;
  MergeableUsage mergeableUsage = (MergeableUsage)usage;
  for (UsageNode node : myUsageNodes) {
    Usage original = node.getUsage();
    if (original == mergeableUsage) {
      // search returned duplicate usage, ignore
      return node;
    }
    if (original instanceof MergeableUsage) {
      if (((MergeableUsage)original).merge(mergeableUsage)) return node;
    }
  }

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

示例7: addUsage

import com.intellij.usages.Usage; //导入依赖的package包/类
public UsageNode addUsage(@NotNull Usage usage, @NotNull Consumer<Runnable> edtQueue) {
  final UsageNode node;
  synchronized (lock) {
    if (myUsageTreeModel.isFilterDuplicatedLine()) {
      UsageNode mergedWith = tryMerge(usage);
      if (mergedWith != null) {
        return mergedWith;
      }
    }
    node = new UsageNode(usage, getBuilder());
    myUsageNodes.add(node);
  }

  if (!getBuilder().isDetachedMode()) {
    edtQueue.consume(new Runnable() {
      @Override
      public void run() {
        myTreeModel.insertNodeInto(node, GroupNode.this, getNodeIndex(node));
        incrementUsageCount();
      }
    });
  }
  return node;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GroupNode.java

示例8: groupUsage

import com.intellij.usages.Usage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (usage instanceof UsageInModule) {
    UsageInModule usageInModule = (UsageInModule)usage;
    Module module = usageInModule.getModule();
    if (module != null) return new ModuleUsageGroup(module);
  }

  if (usage instanceof UsageInLibrary) {
    UsageInLibrary usageInLibrary = (UsageInLibrary)usage;
    OrderEntry entry = usageInLibrary.getLibraryEntry();
    if (entry != null) return new LibraryUsageGroup(entry);
  }

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

示例9: groupUsage

import com.intellij.usages.Usage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (!(usage instanceof PsiElementUsage)) {
    return null;
  }
  PsiElementUsage elementUsage = (PsiElementUsage)usage;

  PsiElement element = elementUsage.getElement();
  VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);

  if (virtualFile == null) {
    return null;
  }
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
  boolean isInLib = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
  if (isInLib) return LIBRARY;
  boolean isInTest = fileIndex.isInTestSourceContent(virtualFile);
  return isInTest ? TEST : PRODUCTION;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsageScopeGroupingRule.java

示例10: groupUsage

import com.intellij.usages.Usage; //导入依赖的package包/类
@Override
@Nullable
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (usage instanceof UsageInFile) {
    UsageInFile usageInFile = (UsageInFile)usage;
    VirtualFile file = usageInFile.getFile();
    if (file != null) {
      if (file instanceof VirtualFileWindow) {
        file = ((VirtualFileWindow)file).getDelegate();
      }
      VirtualFile dir = file.getParent();
      if (dir == null) return null;
      return getGroupForFile(dir);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DirectoryGroupingRule.java

示例11: collectFiles

import com.intellij.usages.Usage; //导入依赖的package包/类
protected static Set<VirtualFile> collectFiles(Set<Usage> usages, boolean findFirst) {
  final Set<VirtualFile> files = new HashSet<VirtualFile>();
  for (Usage usage : usages) {
    if (usage instanceof PsiElementUsage) {
      PsiElement psiElement = ((PsiElementUsage)usage).getElement();
      if (psiElement != null && psiElement.isValid()) {
        PsiFile psiFile = psiElement.getContainingFile();
        if (psiFile != null) {
          VirtualFile file = psiFile.getVirtualFile();
          if (file != null) {
            files.add(file);
            if (findFirst) return files;
          }
        }
      }
    }
  }
  return files;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PredefinedSearchScopeProviderImpl.java

示例12: getBackgroundColor

import com.intellij.usages.Usage; //导入依赖的package包/类
private Color getBackgroundColor(boolean isSelected, Usage usage) {
  Color fileBgColor = null;
  if (isSelected) {
    fileBgColor = UIUtil.getListSelectionBackground();
  }
  else {
    VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
    if (virtualFile != null) {
      Project project = myUsageView.getProject();
      PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
      if (psiFile != null && psiFile.isValid()) {
        final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile);
        if (color != null) fileBgColor = color;
      }
    }
  }
  return fileBgColor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ShowUsagesTableCellRenderer.java

示例13: customizeCellRenderer

import com.intellij.usages.Usage; //导入依赖的package包/类
@Override
protected void customizeCellRenderer(final JList list,
                                     final Object value,
                                     final int index,
                                     final boolean selected,
                                     final boolean hasFocus) {
  Usage usage = (Usage)value;
  UsagePresentation presentation = usage.getPresentation();
  setIcon(presentation.getIcon());
  VirtualFile virtualFile = getVirtualFile(usage);
  if (virtualFile != null) {
    append(virtualFile.getName() + ": ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
    setIcon(virtualFile.getFileType().getIcon());
    PsiFile psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
    if (psiFile != null) {
      setIcon(psiFile.getIcon(0));
    }
  }

  TextChunk[] text = presentation.getText();
  for (TextChunk textChunk : text) {
    SimpleTextAttributes simples = textChunk.getSimpleAttributesIgnoreBackground();
    append(textChunk.getText(), simples);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:UsageListCellRenderer.java

示例14: showConflicts

import com.intellij.usages.Usage; //导入依赖的package包/类
/**
 * Shows a panel with name redefinition conflicts, if needed.
 * @param project
 * @param conflicts what {@link #findDefinitions} would return
 * @param obscured name or its topmost qualifier that is obscured, used at top of pane.
 * @param name full name (maybe qualified) to show as obscured and display as qualifier in "would be" chunks.
 * @return true iff conflicts is not empty and the panel is shown.
 */
public static boolean showConflicts(Project project, List<Pair<PsiElement, PsiElement>> conflicts, String obscured, @Nullable String name) {
  if (conflicts.size() > 0) {
    Usage[] usages = new Usage[conflicts.size()];
    int i = 0;
    for (Pair<PsiElement, PsiElement> pair : conflicts) {
      usages[i] = new NameUsage(pair.getFirst(), pair.getSecond(), name != null? name : obscured, name != null);
      i += 1;
    }
    UsageViewPresentation prsnt = new UsageViewPresentation();
    prsnt.setTabText(PyBundle.message("CONFLICT.name.$0.obscured", obscured));
    prsnt.setCodeUsagesString(PyBundle.message("CONFLICT.name.$0.obscured.cannot.convert", obscured));
    prsnt.setUsagesWord(PyBundle.message("CONFLICT.occurrence.sing"));
    prsnt.setUsagesString(PyBundle.message("CONFLICT.occurrence.pl"));
    UsageViewManager.getInstance(project).showUsages(UsageTarget.EMPTY_ARRAY, usages, prsnt);
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DeclarationConflictChecker.java

示例15: findUsage

import com.intellij.usages.Usage; //导入依赖的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


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