com.intellij.usages.Usage Java Examples

The following examples show how to use com.intellij.usages.Usage. 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: UsageScopeGroupingRule.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(UsageNode c1, UsageNode c2) {
  if (c1 instanceof StringNode) return 1;
  if (c2 instanceof StringNode) return -1;
  Usage o1 = c1.getUsage();
  Usage o2 = c2.getUsage();
  if (o1 == MORE_USAGES_SEPARATOR) return 1;
  if (o2 == MORE_USAGES_SEPARATOR) return -1;

  VirtualFile v1 = UsageListCellRenderer.getVirtualFile(o1);
  VirtualFile v2 = UsageListCellRenderer.getVirtualFile(o2);
  String name1 = v1 == null ? null : v1.getName();
  String name2 = v2 == null ? null : v2.getName();
  int i = Comparing.compare(name1, name2);
  if (i != 0) return i;

  if (o1 instanceof Comparable && o2 instanceof Comparable) {
    return ((Comparable) o1).compareTo(o2);
  }

  FileEditorLocation loc1 = o1.getLocation();
  FileEditorLocation loc2 = o2.getLocation();
  return Comparing.compare(loc1, loc2);
}
 
Example #3
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(UsageNode c1, UsageNode c2) {
  if (c1 instanceof StringNode) return 1;
  if (c2 instanceof StringNode) return -1;
  Usage o1 = c1.getUsage();
  Usage o2 = c2.getUsage();
  if (o1 == MORE_USAGES_SEPARATOR) return 1;
  if (o2 == MORE_USAGES_SEPARATOR) return -1;

  VirtualFile v1 = UsageListCellRenderer.getVirtualFile(o1);
  VirtualFile v2 = UsageListCellRenderer.getVirtualFile(o2);
  String name1 = v1 == null ? null : v1.getName();
  String name2 = v2 == null ? null : v2.getName();
  int i = Comparing.compare(name1, name2);
  if (i != 0) return i;

  if (o1 instanceof Comparable && o2 instanceof Comparable) {
    return ((Comparable)o1).compareTo(o2);
  }

  FileEditorLocation loc1 = o1.getLocation();
  FileEditorLocation loc2 = o2.getLocation();
  return Comparing.compare(loc1, loc2);
}
 
Example #4
Source File: CSharpTypeGroupRuleProvider.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@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 #5
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private static boolean areAllUsagesInOneLine(@NotNull Usage visibleUsage,
    @NotNull List<Usage> usages) {
  Editor editor = getEditorFor(visibleUsage);
  if (editor == null) return false;
  int offset = getUsageOffset(visibleUsage);
  if (offset == -1) return false;
  int lineNumber = editor.getDocument().getLineNumber(offset);
  for (Usage other : usages) {
    Editor otherEditor = getEditorFor(other);
    if (otherEditor != editor) return false;
    int otherOffset = getUsageOffset(other);
    if (otherOffset == -1) return false;
    int otherLine = otherEditor.getDocument().getLineNumber(otherOffset);
    if (otherLine != lineNumber) return false;
  }
  return true;
}
 
Example #6
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private static List<UsageNode> collectData(@NotNull List<Usage> usages,
    @NotNull Collection<UsageNode> visibleNodes, @NotNull UsageViewImpl usageView,
    @NotNull UsageViewPresentation presentation) {
  @NotNull List<UsageNode> data = new ArrayList<UsageNode>();
  int filtered = filtered(usages, usageView);
  if (filtered != 0) {
    data.add(createStringNode(UsageViewBundle.message("usages.were.filtered.out", filtered)));
  }
  data.addAll(visibleNodes);
  if (data.isEmpty()) {
    String progressText = UsageViewManagerImpl.getProgressTitle(presentation);
    data.add(createStringNode(progressText));
  }
  Collections.sort(data, USAGE_NODE_COMPARATOR);
  return data;
}
 
Example #7
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private static boolean areAllUsagesInOneLine(@NotNull Usage visibleUsage, @NotNull List<Usage> usages) {
  Editor editor = getEditorFor(visibleUsage);
  if (editor == null) return false;
  int offset = getUsageOffset(visibleUsage);
  if (offset == -1) return false;
  int lineNumber = editor.getDocument().getLineNumber(offset);
  for (Usage other : usages) {
    Editor otherEditor = getEditorFor(other);
    if (otherEditor != editor) return false;
    int otherOffset = getUsageOffset(other);
    if (otherOffset == -1) return false;
    int otherLine = otherEditor.getDocument().getLineNumber(otherOffset);
    if (otherLine != lineNumber) return false;
  }
  return true;
}
 
Example #8
Source File: Decider.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@Override public boolean shouldShow(UsageTarget target, Usage usage) {
  PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();

  PsiField field = PsiConsultantImpl.findField(element);
  if (field != null //
      && PsiConsultantImpl.hasAnnotation(field, CLASS_INJECT) //
      && PsiConsultantImpl.hasQuailifierAnnotations(field, qualifierAnnotations)
      && PsiConsultantImpl.hasTypeParameters(field, typeParameters)) {
    return true;
  }

  PsiMethod method = PsiConsultantImpl.findMethod(element);
  if (method != null && (PsiConsultantImpl.hasAnnotation(method, CLASS_INJECT)
          || PsiConsultantImpl.hasAnnotation(method, CLASS_PROVIDES))) {
    for (PsiParameter parameter : method.getParameterList().getParameters()) {
      PsiClass parameterClass = PsiConsultantImpl.checkForLazyOrProvider(parameter);
      if (parameterClass.equals(returnType) && PsiConsultantImpl.hasQuailifierAnnotations(
          parameter, qualifierAnnotations)
          && PsiConsultantImpl.hasTypeParameters(parameter, typeParameters)) {
        return true;
      }
    }
  }

  return false;
}
 
Example #9
Source File: ShowUsagesTableCellRenderer.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #10
Source File: ShowUsagesTableCellRenderer.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: ShowUsagesTableCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #12
Source File: PredefinedSearchScopeProviderImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected static Set<VirtualFile> collectFiles(Set<Usage> usages, boolean findFirst) {
  final Set<VirtualFile> files = new HashSet<>();
  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;
}
 
Example #13
Source File: UsageNodeTreeBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #14
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private static List<UsageNode> collectData(@NotNull List<Usage> usages,
    @NotNull Collection<UsageNode> visibleNodes,
    @NotNull UsageViewImpl usageView,
    @NotNull UsageViewPresentation presentation) {
  @NotNull List<UsageNode> data = new ArrayList<UsageNode>();
  int filtered = filtered(usages, usageView);
  if (filtered != 0) {
    data.add(createStringNode(UsageViewBundle.message("usages.were.filtered.out", filtered)));
  }
  data.addAll(visibleNodes);
  if (data.isEmpty()) {
    String progressText = UsageViewManagerImpl.getProgressTitle(presentation);
    data.add(createStringNode(progressText));
  }
  Collections.sort(data, USAGE_NODE_COMPARATOR);
  return data;
}
 
Example #15
Source File: GroupNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
UsageNode addOrGetUsage(@Nonnull Usage usage, boolean filterDuplicateLines, @Nonnull Consumer<? super Node> edtInsertedUnderQueue) {
  UsageNode newNode;
  synchronized (this) {
    if (filterDuplicateLines) {
      UsageNode mergedWith = tryMerge(usage);
      if (mergedWith != null) {
        return mergedWith;
      }
    }
    newNode = new UsageNode(this, usage);
    int i = getNodeIndex(newNode, myChildren);
    // i>=0 means the usage already there (might happen when e.g. find usages was interrupted by typing and resumed with the same file)
    if (i >= 0) {
      newNode = (UsageNode)myChildren.get(i);
    }
    else {
      int insertionIndex = -i - 1;
      myChildren.add(insertionIndex, newNode);
    }
  }
  edtInsertedUnderQueue.consume(this);
  return newNode;
}
 
Example #16
Source File: NonCodeUsageGroupingRule.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 #17
Source File: UsageListCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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(IconDescriptorUpdaters.getIcon(psiFile, 0));
    }
  }

  TextChunk[] text = presentation.getText();
  for (TextChunk textChunk : text) {
    SimpleTextAttributes simples = textChunk.getSimpleAttributesIgnoreBackground();
    append(textChunk.getText(), simples);
  }
}
 
Example #18
Source File: DirectoryGroupingRule.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 #19
Source File: ModuleGroupingRule.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 #20
Source File: Decider.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@Override public boolean shouldShow(UsageTarget target, Usage usage) {
  PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();
  PsiMethod psimethod = PsiConsultantImpl.findMethod(element);

  PsiAnnotationMemberValue attribValue = PsiConsultantImpl
      .findTypeAttributeOfProvidesAnnotation(psimethod);

  // Is it a @Provides method?
  return psimethod != null
      // Ensure it has an @Provides.
      && PsiConsultantImpl.hasAnnotation(psimethod, CLASS_PROVIDES)
      // Check for Qualifier annotations.
      && PsiConsultantImpl.hasQuailifierAnnotations(psimethod, qualifierAnnotations)
      // Right return type.
      && PsiConsultantImpl.getReturnClassFromMethod(psimethod, false)
      .getName()
      .equals(target.getName())
      // Right type parameters.
      && PsiConsultantImpl.hasTypeParameters(psimethod, typeParameters)
      // @Provides(type=SET)
      && attribValue != null
      && attribValue.textMatches(SET_TYPE);
}
 
Example #21
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
private static int filtered(@NotNull List<Usage> usages, @NotNull UsageViewImpl usageView) {
  int count=0;
  for (Usage usage : usages) {
    if (!usageView.isVisible(usage)) count++;
  }
  return count;
}
 
Example #22
Source File: ReadAccessFilteringRule.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isVisible(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) {
  if (usage instanceof ReadWriteAccessUsage) {
    final ReadWriteAccessUsage readWriteAccessUsage = (ReadWriteAccessUsage)usage;
    final boolean isForReadingOnly = readWriteAccessUsage.isAccessedForReading() && !readWriteAccessUsage.isAccessedForWriting();
    return !isForReadingOnly;
  }
  return true;
}
 
Example #23
Source File: LSPReferencesAction.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
private void showReferences(Editor editor, List<PsiElement2UsageTargetAdapter> targets, LogicalPosition position) {
    if (targets.isEmpty()) {
        short constraint = HintManager.ABOVE;
        int flags = HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING;
        JLabel label = new JLabel("No references found");
        label.setBackground(new JBColor(new Color(150, 0, 0), new Color(150, 0, 0)));
        LightweightHint hint = new LightweightHint(label);
        Point p = HintManagerImpl.getHintPosition(hint, editor, position, constraint);
        HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, flags, 0, false,
                HintManagerImpl.createHintHint(editor, p, hint, constraint).setContentActive(false));
    } else {
        List<Usage> usages = new ArrayList<>();
        targets.forEach(ut -> {
            PsiElement elem = ut.getElement();
            usages.add(new UsageInfo2UsageAdapter(new UsageInfo(elem, -1, -1, false)));
        });

        if (editor == null) {
            return;
        }
        Project project = editor.getProject();
        if (project == null) {
            return;
        }
        UsageViewPresentation presentation = createPresentation(targets.get(0).getElement(),
                new FindUsagesOptions(editor.getProject()), false);
        UsageViewManager.getInstance(project)
                .showUsages(new UsageTarget[] { targets.get(0) }, usages.toArray(new Usage[usages.size()]),
                        presentation);
    }
}
 
Example #24
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
private void addUsageNodes(@NotNull GroupNode root, @NotNull final UsageViewImpl usageView, @NotNull List<UsageNode> outNodes) {
  for (UsageNode node : root.getUsageNodes()) {
    Usage usage = node.getUsage();
    if (usageView.isVisible(usage)) {
      node.setParent(root);
      outNodes.add(node);
    }
  }
  for (GroupNode groupNode : root.getSubGroups()) {
    groupNode.setParent(root);
    addUsageNodes(groupNode, usageView, outNodes);
  }
}
 
Example #25
Source File: ResourceUsageCountUtils.java    From Android-Resource-Usage-Count with MIT License 5 votes vote down vote up
/**
 * It's useless to count build folder
 */
public static boolean isUsefulUsageToCount(Usage usage) {
    if (usage instanceof ReadWriteAccessUsageInfo2UsageAdapter) {
        VirtualFile virtualFile = ((ReadWriteAccessUsageInfo2UsageAdapter) usage).getFile();
        if (virtualFile != null) {
            if (!virtualFile.getPath().contains("/bin/") && !virtualFile.getPath().contains("/build/")) {
                return true;
            }
        }
    }
    return false;
}
 
Example #26
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
protected @Nullable Usage transform(@NotNull Usage usage) {
  if (!decider.shouldShow(usage)) {
    return null;
  } else {
    return usage;
  }
}
 
Example #27
Source File: ShowUsagesAction.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
private void rebuildPopup(@NotNull final UsageViewImpl usageView,
    @NotNull final List<Usage> usages,
    @NotNull List<UsageNode> nodes,
    @NotNull final JTable table,
    @NotNull final JBPopup popup,
    @NotNull final UsageViewPresentation presentation,
    @NotNull final RelativePoint popupPosition,
    boolean findUsagesInProgress) {
  ApplicationManager.getApplication().assertIsDispatchThread();

  boolean shouldShowMoreSeparator = usages.contains(MORE_USAGES_SEPARATOR);
  if (shouldShowMoreSeparator) {
    nodes.add(MORE_USAGES_SEPARATOR_NODE);
  }

  String title = presentation.getTabText();
  String fullTitle = getFullTitle(usages, title, shouldShowMoreSeparator, nodes.size() - (shouldShowMoreSeparator ? 1 : 0), findUsagesInProgress);

  ((AbstractPopup)popup).setCaption(fullTitle);

  List<UsageNode> data = collectData(usages, nodes, usageView, presentation);
  MyModel tableModel = setTableModel(table, usageView, data);
  List<UsageNode> existingData = tableModel.getItems();

  int row = table.getSelectedRow();

  int newSelection = updateModel(tableModel, existingData, data, row == -1 ? 0 : row);
  if (newSelection < 0 || newSelection >= tableModel.getRowCount()) {
    TableScrollingUtil.ensureSelectionExists(table);
    newSelection = table.getSelectedRow();
  }
  else {
    table.getSelectionModel().setSelectionInterval(newSelection, newSelection);
  }
  TableScrollingUtil.ensureIndexIsVisible(table, newSelection, 0);

  setSizeAndDimensions(table, popup, popupPosition, data);
}
 
Example #28
Source File: BackgroundUpdaterTaskBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean tryAppendUsage(@Nonnull T element) {
  final UsageView view = myUsageView.get();
  if (view != null && !((UsageViewImpl)view).isDisposed()) {
    Usage usage = createUsage(element);
    if (usage == null) return false;
    ApplicationManager.getApplication().runReadAction(() -> view.appendUsage(usage));
    return true;
  }
  return false;
}
 
Example #29
Source File: UsageViewUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static Set<UsageInfo> getNotExcludedUsageInfos(final UsageView usageView) {
  Set<Usage> excludedUsages = usageView.getExcludedUsages();

  Set<UsageInfo> usageInfos = new LinkedHashSet<UsageInfo>();
  for (Usage usage : usageView.getUsages()) {
    if (usage instanceof UsageInfo2UsageAdapter && !excludedUsages.contains(usage)) {
      UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      usageInfos.add(usageInfo);
    }
  }
  return usageInfos;
}
 
Example #30
Source File: BusPostDecider.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
@Override public boolean shouldShow(Usage usage) {
  PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();
  PsiMethodCallExpression methodCall = PsiConsultantImpl.findMethodCall(element);
  if (methodCall != null) {
    PsiType[] expressionTypes = methodCall.getArgumentList().getExpressionTypes();
    for (PsiType expressionType : expressionTypes) {
      PsiClass argumentEventClass = PsiConsultantImpl.getClass(expressionType);
      if (argumentEventClass.equals(this.eventClass)) {
        return true;
      }
    }
  }

  return false;
}