Java 类com.intellij.psi.ElementDescriptionUtil 实例源码

项目:consulo-java    文件:SliceManager.java   
public static String getElementDescription(String prefix, PsiElement element, String suffix)
{
    PsiElement elementToSlice = element;
    if(element instanceof PsiReferenceExpression)
    {
        elementToSlice = ((PsiReferenceExpression) element).resolve();
    }
    if(elementToSlice == null)
    {
        elementToSlice = element;
    }
    String desc = ElementDescriptionUtil.getElementDescription(elementToSlice, RefactoringDescriptionLocation.WITHOUT_PARENT);
    return "<html><head>" + UIUtil.getCssFontDeclaration(getLabelFont()) + "</head><body>" + (prefix == null ? "" : prefix) + StringUtil.first(desc, 100, true) + (suffix == null ? "" : suffix) +
            "</body></html>";
}
项目:reasonml-idea-plugin    文件:RmlFindUsagesProvider.java   
@NotNull
@Override
public String getType(@NotNull PsiElement element) {
    return ElementDescriptionUtil.getElementDescription(element, UsageViewTypeLocation.INSTANCE);
}
项目:reasonml-idea-plugin    文件:RmlFindUsagesProvider.java   
@NotNull
@Override
public String getDescriptiveName(@NotNull PsiElement element) {
    return ElementDescriptionUtil.getElementDescription(element, UsageViewLongNameLocation.INSTANCE);
}
项目:reasonml-idea-plugin    文件:RmlFindUsagesProvider.java   
@NotNull
@Override
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
    return ElementDescriptionUtil.getElementDescription(element, UsageViewNodeTextLocation.INSTANCE);
}
项目:MultiHighlight    文件:MultiHighlightHandler.java   
private static void highlightPsiElement(@NotNull Project project,
        @NotNull PsiElement psiElement, @NotNull Editor editor, @NotNull PsiFile file,
        boolean shouldClear) {
    final PsiElement target = SmartPointerManager.getInstance(psiElement.getProject())
            .createSmartPsiElementPointer(psiElement)
            .getElement();

    if (target == null) {
        return;
    }

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

    final Couple<List<TextRange>> usages = getUsages(target, file);

    final List<TextRange> readRanges = usages.first;
    final List<TextRange> writeRanges = usages.second;

    final HighlightManager highlightManager = HighlightManager.getInstance(project);
    if (shouldClear) {
        clearHighlights(editor, highlightManager, readRanges);
        clearHighlights(editor, highlightManager, writeRanges);
        WindowManager.getInstance().getStatusBar(project).setInfo("");
        return;
    }

    // TODO: 10/02/2017 pass target?
    final TextAttributes ta = TextAttributesFactory.getInstance().get();
    final Color scrollMarkColor;
    if (ta.getErrorStripeColor() != null) {
        scrollMarkColor = ta.getErrorStripeColor();
    } else if (ta.getBackgroundColor() != null) {
        scrollMarkColor = ta.getBackgroundColor().darker();
    } else {
        scrollMarkColor = null;
    }

    final String elementName = ElementDescriptionUtil.getElementDescription(target,
            HighlightUsagesDescriptionLocation.INSTANCE);

    // TODO: 06/02/2017 highlight write and read access
    ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
    highlight(highlightManager, readRanges, editor, ta, highlighters, scrollMarkColor);
    highlight(highlightManager, writeRanges, editor, ta, highlighters, scrollMarkColor);

    final Document doc = editor.getDocument();
    for (RangeHighlighter highlighter : highlighters) {
        highlighter.setErrorStripeTooltip(
                HighlightHandlerBase.getLineTextErrorStripeTooltip(doc,
                        highlighter.getStartOffset(), true));
    }

    int refCount = readRanges.size() + writeRanges.size();
    String msg;
    if (refCount > 0) {
        msg = MessageFormat.format("{0} {0, choice, 1#usage|2#usages} of {1} found", refCount,
                elementName);
    } else {
        msg = MessageFormat.format("No usages of {0} found", elementName);
    }

    WindowManager.getInstance().getStatusBar(project).setInfo(msg);
}
项目:intellij-ce-playground    文件:UsageViewUtil.java   
public static String createNodeText(PsiElement element) {
  return ElementDescriptionUtil.getElementDescription(element, UsageViewNodeTextLocation.INSTANCE);
}
项目:intellij-ce-playground    文件:UsageViewUtil.java   
public static String getShortName(final PsiElement psiElement) {
  LOG.assertTrue(psiElement.isValid(), psiElement);
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE);
}
项目:intellij-ce-playground    文件:UsageViewUtil.java   
public static String getLongName(final PsiElement psiElement) {
  LOG.assertTrue(psiElement.isValid(), psiElement);
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewLongNameLocation.INSTANCE);
}
项目:intellij-ce-playground    文件:UsageViewUtil.java   
public static String getType(@NotNull PsiElement psiElement) {
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE);
}
项目:intellij-ce-playground    文件:RefactoringUIUtil.java   
public static String getDescription(@NotNull PsiElement element, boolean includeParent) {
  return ElementDescriptionUtil.getElementDescription(element, includeParent
                                                               ? RefactoringDescriptionLocation.WITH_PARENT
                                                               : RefactoringDescriptionLocation.WITHOUT_PARENT);
}
项目:CMaker    文件:CMakeFindUsagesProvider.java   
@NotNull
@Override
public String getType(PsiElement psiElement) {
    return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE);
}
项目:CMaker    文件:CMakeFindUsagesProvider.java   
@NotNull
@Override
public String getDescriptiveName(@NotNull PsiElement psiElement) {
    return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewLongNameLocation.INSTANCE);
}
项目:CMaker    文件:CMakeFindUsagesProvider.java   
@NotNull
@Override
public String getNodeText(@NotNull PsiElement psiElement, boolean b) {
    return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewNodeTextLocation.INSTANCE);
}
项目:intellij-haskforce    文件:HaskellFindUsagesProvider.java   
@NotNull
@Override
public String getType(@NotNull PsiElement element) {
    return ElementDescriptionUtil.getElementDescription(element, UsageViewTypeLocation.INSTANCE);
}
项目:intellij-haskforce    文件:HaskellFindUsagesProvider.java   
@NotNull
@Override
public String getDescriptiveName(@NotNull PsiElement element) {
    return ElementDescriptionUtil.getElementDescription(element, UsageViewLongNameLocation.INSTANCE);
}
项目:intellij-haskforce    文件:HaskellFindUsagesProvider.java   
@NotNull
@Override
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
    return ElementDescriptionUtil.getElementDescription(element, UsageViewNodeTextLocation.INSTANCE);
}
项目:tools-idea    文件:UsageViewUtil.java   
public static String createNodeText(PsiElement element) {
  return ElementDescriptionUtil.getElementDescription(element, UsageViewNodeTextLocation.INSTANCE);
}
项目:tools-idea    文件:UsageViewUtil.java   
public static String getShortName(final PsiElement psiElement) {
  LOG.assertTrue(psiElement.isValid(), psiElement);
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE);
}
项目:tools-idea    文件:UsageViewUtil.java   
public static String getLongName(final PsiElement psiElement) {
  LOG.assertTrue(psiElement.isValid(), psiElement);
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewLongNameLocation.INSTANCE);
}
项目:tools-idea    文件:UsageViewUtil.java   
public static String getType(@NotNull PsiElement psiElement) {
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE);
}
项目:tools-idea    文件:RefactoringUIUtil.java   
public static String getDescription(@NotNull PsiElement element, boolean includeParent) {
  return ElementDescriptionUtil.getElementDescription(element, includeParent
                                                               ? RefactoringDescriptionLocation.WITH_PARENT
                                                               : RefactoringDescriptionLocation.WITHOUT_PARENT);
}
项目:consulo    文件:UsageViewUtil.java   
public static String createNodeText(PsiElement element) {
  return ElementDescriptionUtil.getElementDescription(element, UsageViewNodeTextLocation.INSTANCE);
}
项目:consulo    文件:UsageViewUtil.java   
public static String getShortName(final PsiElement psiElement) {
  LOG.assertTrue(psiElement.isValid(), psiElement);
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE);
}
项目:consulo    文件:UsageViewUtil.java   
public static String getLongName(final PsiElement psiElement) {
  LOG.assertTrue(psiElement.isValid(), psiElement);
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewLongNameLocation.INSTANCE);
}
项目:consulo    文件:UsageViewUtil.java   
public static String getType(@Nonnull PsiElement psiElement) {
  return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewTypeLocation.INSTANCE);
}
项目:consulo    文件:RefactoringUIUtil.java   
public static String getDescription(@Nonnull PsiElement element, boolean includeParent) {
  return ElementDescriptionUtil.getElementDescription(element, includeParent
                                                               ? RefactoringDescriptionLocation.WITH_PARENT
                                                               : RefactoringDescriptionLocation.WITHOUT_PARENT);
}