com.intellij.usages.UsageGroup Java Examples
The following examples show how to use
com.intellij.usages.UsageGroup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShowUsagesTableCellRenderer.java From otto-intellij-plugin with Apache License 2.0 | 6 votes |
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) { UsageGroup group = node == null ? null : node.getGroup(); if (group == null) return; GroupNode parentGroup = (GroupNode)node.getParent(); appendGroupText(parentGroup, panel, fileBgColor); if (node.canNavigateToSource()) { SimpleColoredComponent renderer = new SimpleColoredComponent(); renderer.setIcon(group.getIcon(false)); SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor); renderer.append(group.getText(myUsageView), attributes); renderer.append(" ", attributes); renderer.setIpad(new Insets(0,0,0,0)); renderer.setBorder(null); panel.add(renderer); } }
Example #2
Source File: UsageScopeGroupingRule.java From consulo with Apache License 2.0 | 6 votes |
@Override public UsageGroup groupUsage(@Nonnull 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 = TestSourcesFilter.isTestSources(virtualFile, element.getProject()); return isInTest ? TEST : PRODUCTION; }
Example #3
Source File: DirectoryGroupingRule.java From consulo with Apache License 2.0 | 6 votes |
@Override @javax.annotation.Nullable public UsageGroup groupUsage(@Nonnull 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; }
Example #4
Source File: ModuleGroupingRule.java From consulo with Apache License 2.0 | 6 votes |
@Override public UsageGroup groupUsage(@Nonnull 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; }
Example #5
Source File: ExporterToTextFile.java From consulo with Apache License 2.0 | 6 votes |
private void appendNodeText(StringBuilder buf, DefaultMutableTreeNode node, String lineSeparator) { if (node instanceof Node && ((Node)node).isExcluded()) { buf.append("(").append(UsageViewBundle.message("usage.excluded")).append(") "); } if (node instanceof UsageNode) { appendUsageNodeText(buf, (UsageNode)node); } else if (node instanceof GroupNode) { UsageGroup group = ((GroupNode)node).getGroup(); buf.append(group != null ? group.getText(myUsageView) : UsageViewBundle.message("usages.title")); buf.append(" "); int count = ((GroupNode)node).getRecursiveUsageCount(); buf.append(" (").append(UsageViewBundle.message("usages.n", count)).append(")"); } else if (node instanceof UsageTargetNode) { buf.append(((UsageTargetNode)node).getTarget().getPresentation().getPresentableText()); } else { buf.append(node.toString()); } buf.append(lineSeparator); }
Example #6
Source File: UsageNodeTreeBuilder.java From consulo with Apache License 2.0 | 6 votes |
UsageNode appendOrGet(@Nonnull Usage usage, boolean filterDuplicateLines, @Nonnull Consumer<? super Node> edtInsertedUnderQueue) { if (!isVisible(usage)) return null; final boolean dumb = DumbService.isDumb(myProject); GroupNode groupNode = myRoot; for (int i = 0; i < myGroupingRules.length; i++) { UsageGroupingRule rule = myGroupingRules[i]; if (dumb && !DumbService.isDumbAware(rule)) continue; List<UsageGroup> groups = rule.getParentGroupsFor(usage, myTargets); for (UsageGroup group : groups) { groupNode = groupNode.addOrGetGroup(group, i, edtInsertedUnderQueue); } } return groupNode.addOrGetUsage(usage, filterDuplicateLines, edtInsertedUnderQueue); }
Example #7
Source File: NonCodeUsageGroupingRule.java From consulo with Apache License 2.0 | 6 votes |
@Override public UsageGroup groupUsage(@Nonnull Usage usage) { if (usage instanceof UsageInFile) { VirtualFile file = ((UsageInFile)usage).getFile(); if (file != null) { if (GeneratedSourcesFilter.isGenerated(myProject, file)) { return UsageInGeneratedCodeGroup.INSTANCE; } } } if (usage instanceof PsiElementUsage) { if (usage instanceof UsageInfo2UsageAdapter) { final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo(); if (usageInfo.isDynamicUsage()) { return DynamicUsageGroup.INSTANCE; } } if (((PsiElementUsage)usage).isNonCodeUsage()) { return NonCodeUsageGroup.INSTANCE; } else { return CodeUsageGroup.INSTANCE; } } return null; }
Example #8
Source File: ShowUsagesTableCellRenderer.java From consulo with Apache License 2.0 | 6 votes |
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) { UsageGroup group = node == null ? null : node.getGroup(); if (group == null) return; GroupNode parentGroup = (GroupNode)node.getParent(); appendGroupText(parentGroup, panel, fileBgColor); if (node.canNavigateToSource()) { SimpleColoredComponent renderer = new SimpleColoredComponent(); renderer.setIcon(group.getIcon()); SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor); renderer.append(group.getText(myUsageView), attributes); renderer.append(" ", attributes); renderer.setIpad(new Insets(0,0,0,0)); renderer.setBorder(null); panel.add(renderer); } }
Example #9
Source File: ShowUsagesTableCellRenderer.java From dagger-intellij-plugin with Apache License 2.0 | 6 votes |
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) { UsageGroup group = node == null ? null : node.getGroup(); if (group == null) return; GroupNode parentGroup = (GroupNode) node.getParent(); appendGroupText(parentGroup, panel, fileBgColor); if (node.canNavigateToSource()) { SimpleColoredComponent renderer = new SimpleColoredComponent(); renderer.setIcon(group.getIcon(false)); SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor); renderer.append(group.getText(myUsageView), attributes); renderer.append(" ", attributes); renderer.setIpad(new Insets(0, 0, 0, 0)); renderer.setBorder(null); panel.add(renderer); } }
Example #10
Source File: CSharpCodeBlockOwnerGroupRuleProvider.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nullable @Override public UsageGroupingRule getUsageGroupingRule(Project project) { return new UsageGroupingRule() { @Nullable @Override public UsageGroup groupUsage(@Nonnull Usage usage) { if(!(usage instanceof PsiElementUsage)) { return null; } PsiElement element = ((PsiElementUsage) usage).getElement(); DotNetCodeBlockOwner codeBlockOwner = PsiTreeUtil.getParentOfType(element, DotNetCodeBlockOwner.class); if(codeBlockOwner != null) { return new CSharpBaseGroupingRule<DotNetCodeBlockOwner>(codeBlockOwner); } return null; } }; }
Example #11
Source File: CSharpTypeGroupRuleProvider.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nullable @Override public UsageGroupingRule getUsageGroupingRule(Project project) { return new UsageGroupingRule() { @Nullable @Override public UsageGroup groupUsage(@Nonnull Usage usage) { if(!(usage instanceof PsiElementUsage)) { return null; } PsiElement element = ((PsiElementUsage) usage).getElement(); DotNetTypeDeclaration typeDeclaration = PsiTreeUtil.getParentOfType(element, DotNetTypeDeclaration.class); if(typeDeclaration != null) { return new CSharpBaseGroupingRule<DotNetTypeDeclaration>(typeDeclaration); } return null; } }; }
Example #12
Source File: NonCodeUsageGroupingRule.java From consulo with Apache License 2.0 | 5 votes |
@Override public int compareTo(@Nonnull UsageGroup usageGroup) { if (usageGroup instanceof DynamicUsageGroup) { return -1; } return usageGroup == this ? 0 : 1; }
Example #13
Source File: GroupNode.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull GroupNode addOrGetGroup(@Nonnull UsageGroup group, int ruleIndex, @Nonnull Consumer<? super Node> edtInsertedUnderQueue) { GroupNode newNode; synchronized (this) { newNode = new GroupNode(this, group, ruleIndex); int i = getNodeIndex(newNode, myChildren); if (i >= 0) { return (GroupNode)myChildren.get(i); } int insertionIndex = -i - 1; myChildren.add(insertionIndex, newNode); } edtInsertedUnderQueue.consume(this); return newNode; }
Example #14
Source File: DirectoryGroupingRule.java From consulo with Apache License 2.0 | 5 votes |
protected UsageGroup getGroupForFile(final VirtualFile dir) { PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(dir); if (psiDirectory != null) { PsiPackage aPackage = PsiPackageManager.getInstance(myProject).findAnyPackage(psiDirectory); if (aPackage != null) { return new PackageGroup(aPackage); } } return new DirectoryGroup(dir); }
Example #15
Source File: BuildFileGroupingRule.java From intellij with Apache License 2.0 | 5 votes |
@Override @Nullable public UsageGroup getParentGroupFor(Usage usage, UsageTarget[] targets) { // give the delegate a chance to refuse the usage UsageGroup base = delegate.getParentGroupFor(usage, targets); if (base == null || !(usage instanceof UsageInFile)) { return null; } VirtualFile vf = ((UsageInFile) usage).getFile(); if (vf == null || vf.getFileType() != BuildFileType.INSTANCE) { return base; } return new FileUsageGroup(project, vf) { String name; @Override public void update() { super.update(); if (isValid()) { name = BuildFile.getBuildFileString(project, vf.getPath()); } } @Override public String getPresentableName() { return name; } @Override public String getText(UsageView view) { return name; } }; }
Example #16
Source File: NonCodeUsageGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(@Nonnull UsageGroup usageGroup) { return usageGroup == this ? 0 : 1; }
Example #17
Source File: NonCodeUsageGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(@Nonnull UsageGroup usageGroup) { return usageGroup == this ? 0 : -1; }
Example #18
Source File: NonCodeUsageGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(@Nonnull UsageGroup usageGroup) { return usageGroup == this ? 0 : -1; }
Example #19
Source File: DirectoryGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(UsageGroup usageGroup) { return getText(null).compareToIgnoreCase(usageGroup.getText(null)); }
Example #20
Source File: DirectoryGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(UsageGroup usageGroup) { return getText(null).compareToIgnoreCase(usageGroup.getText(null)); }
Example #21
Source File: UsageScopeGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(UsageGroup usageGroup) { return getText(null).compareTo(usageGroup.getText(null)); }
Example #22
Source File: GroupNode.java From consulo with Apache License 2.0 | 4 votes |
public synchronized UsageGroup getGroup() { return (UsageGroup)getUserObject(); }
Example #23
Source File: ModuleGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(UsageGroup o) { if (o instanceof LibraryUsageGroup) return -1; return getText(null).compareToIgnoreCase(o.getText(null)); }
Example #24
Source File: ModuleGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Override public int compareTo(UsageGroup usageGroup) { if (usageGroup instanceof ModuleUsageGroup) return 1; return getText(null).compareToIgnoreCase(usageGroup.getText(null)); }
Example #25
Source File: GroupNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected boolean isDataValid() { UsageGroup group = getGroup(); return group == null || group.isValid(); }
Example #26
Source File: GroupNode.java From consulo with Apache License 2.0 | 4 votes |
private GroupNode(@Nonnull Node parent, @Nonnull UsageGroup group, int ruleIndex) { setUserObject(group); setParent(parent); myRuleIndex = ruleIndex; }
Example #27
Source File: SingleParentUsageGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
/** * @deprecated override {@link #getParentGroupFor(Usage, UsageTarget[])} instead */ @Override public UsageGroup groupUsage(@Nonnull Usage usage) { return getParentGroupFor(usage, UsageTarget.EMPTY_ARRAY); }
Example #28
Source File: SingleParentUsageGroupingRule.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public final List<UsageGroup> getParentGroupsFor(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) { return ContainerUtil.createMaybeSingletonList(getParentGroupFor(usage, targets)); }
Example #29
Source File: UsageGroupingRuleEx.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override default List<UsageGroup> getParentGroupsFor(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) { return ContainerUtil.createMaybeSingletonList(groupUsage(usage, targets)); }
Example #30
Source File: UsageGroupingRuleEx.java From consulo with Apache License 2.0 | 4 votes |
@javax.annotation.Nullable UsageGroup groupUsage(@Nonnull Usage usage, @Nonnull UsageTarget[] targets);