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

项目:reasonml-idea-plugin    文件:DescriptionProvider.java   
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    if (location == UsageViewNodeTextLocation.INSTANCE && element instanceof PsiNamedElement) {
        return getElementDescription(element, UsageViewShortNameLocation.INSTANCE);
    }

    if (location == UsageViewShortNameLocation.INSTANCE || location == UsageViewLongNameLocation.INSTANCE) {
        if (element instanceof PsiNamedElement) {
            return ((PsiNamedElement) element).getName();
        }
    }

    if (location == UsageViewTypeLocation.INSTANCE) {
        if (element instanceof PsiModuleName) {
            return "module";
        } else if (element instanceof PsiTypeName) {
            return "type";
        } else if (element instanceof PsiVarName) {
            return "let";
        }
    }

    return element.toString();
}
项目:intellij-ce-playground    文件:PyMagicLiteralElementDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (element instanceof PyStringLiteralExpression) {
    final PyMagicLiteralExtensionPoint point = PyMagicLiteralTools.getPoint((PyStringLiteralExpression)element);
    if (point != null) {
      if (location instanceof UsageViewTypeLocation) {
        return point.getLiteralType();
      }
      if ((location instanceof UsageViewShortNameLocation) || (location instanceof UsageViewLongNameLocation)) {
        return ((StringLiteralExpression)element).getStringValue();
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:DefaultDomTargetDescriptionProvider.java   
@Override
public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) {
  if (!(element instanceof DomTarget)) return null;

  final DomTarget target = (DomTarget)element;

  DomElement domElement = target.getDomElement();
  final ElementPresentationTemplate template = domElement.getChildDescription().getPresentationTemplate();
  final ElementPresentation presentation = template != null ? template.createPresentation(domElement) : domElement.getPresentation();

  if (location == UsageViewTypeLocation.INSTANCE) {
    return presentation.getTypeName();
  }
  if (location == UsageViewNodeTextLocation.INSTANCE || location == UsageViewLongNameLocation.INSTANCE) {
    return presentation.getTypeName() + " " + StringUtil.notNullize(presentation.getElementName(), "''");
  }
  if (location instanceof HighlightUsagesDescriptionLocation) {
    return presentation.getTypeName();
  }
  return null;
}
项目:intellij-ce-playground    文件:XmlUsageViewDescriptionProvider.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof UsageViewShortNameLocation) {
    if (element instanceof XmlAttributeValue) {
      return ((XmlAttributeValue)element).getValue();
    }
  }

  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof XmlTag) {
      return ((XmlTag)element).getName();
    }
    else if (element instanceof XmlAttributeValue) {
      return ((XmlAttributeValue)element).getValue();
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:XmlNonCodeSearchElementDescriptionProvider.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof NonCodeSearchDescriptionLocation)) return null;
  final NonCodeSearchDescriptionLocation ncdLocation = (NonCodeSearchDescriptionLocation)location;
  if (ncdLocation.isNonJava()) return null;
  if (element instanceof XmlTag) {
    return ((XmlTag)element).getValue().getTrimmedText();
  }
  else if (element instanceof XmlAttribute) {
    return ((XmlAttribute)element).getValue();
  }
  else if (element instanceof XmlAttributeValue) {
    return ((XmlAttributeValue)element).getValue();
  }
  return null;
}
项目:intellij    文件:BuildElementDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(PsiElement element, ElementDescriptionLocation location) {
  if (!(element instanceof BuildElement)) {
    return null;
  }
  if (location instanceof UsageViewLongNameLocation) {
    return ((BuildElement) element).getPresentableText();
  }
  if (location instanceof UsageViewShortNameLocation) {
    if (element instanceof PsiNameIdentifierOwner) {
      // this is used by rename operations, so needs to be accurate
      return ((PsiNameIdentifierOwner) element).getName();
    }
    if (element instanceof PsiFile) {
      return ((PsiFile) element).getName();
    }
    return ((BuildElement) element).getPresentableText();
  }
  return null;
}
项目:epigraph    文件:SchemaElementDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
  // https://intellij-support.jetbrains.com/hc/en-us/community/posts/206765785-Custom-name-for-Find-Usages-of-symbol
  if (location instanceof UsageViewLongNameLocation ||
      location instanceof UsageViewShortNameLocation) {

    if (element instanceof SchemaTypeDef) {
      SchemaTypeDef schemaTypeDef = (SchemaTypeDef) element;
      return SchemaPresentationUtil.getName(schemaTypeDef, true);
    }

    if (element instanceof SchemaQnSegment) {
      SchemaQnSegment fqnSegment = (SchemaQnSegment) element;
      return fqnSegment.getQn().toString();
    }

    if (element instanceof SchemaEntityTagRef) {
      SchemaEntityTagRef tagRef = (SchemaEntityTagRef) element;
      return tagRef.getQid().getText();
    }
  }

  return null;
}
项目:glsl4idea    文件:GLSLDescriptionProvider.java   
@Override
    @Nullable
    public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
        if (!(element instanceof GLSLDeclarator)) return null;
        GLSLDeclarator declarator = (GLSLDeclarator) element;
        GLSLDeclaration declaration = declarator.getParentDeclaration();
        if (declaration == null) return null;

        if (location instanceof UsageViewTypeLocation) {
            return declaration.getDeclarationDescription();
        }

        if (location instanceof UsageViewLongNameLocation) {
            return declaration.getDeclarationDescription() + " '" + declarator.getName() + "'";
        }

        if (location instanceof UsageViewNodeTextLocation) {
            return declarator.getName();
        }
        return null;
//        return location.toString();
    }
项目:tools-idea    文件:DefaultDomTargetDescriptionProvider.java   
public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) {
  if (!(element instanceof DomTarget)) return null;

  final DomTarget target = (DomTarget)element;

  DomElement domElement = target.getDomElement();
  final ElementPresentationTemplate template = domElement.getChildDescription().getPresentationTemplate();
  final ElementPresentation presentation = template != null ? template.createPresentation(domElement) : domElement.getPresentation();

  if (location == UsageViewTypeLocation.INSTANCE) {
    return presentation.getTypeName();
  }
  if (location == UsageViewNodeTextLocation.INSTANCE || location == UsageViewLongNameLocation.INSTANCE) {
    return presentation.getTypeName() + " " + StringUtil.notNullize(presentation.getElementName(), "''");
  }
  if (location instanceof HighlightUsagesDescriptionLocation) {
    return presentation.getTypeName();
  }
  return null;
}
项目:tools-idea    文件:XmlUsageViewDescriptionProvider.java   
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof UsageViewShortNameLocation) {
    if (element instanceof XmlAttributeValue) {
      return ((XmlAttributeValue)element).getValue();
    }
  }

  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof XmlTag) {
      return ((XmlTag)element).getName();
    }
    else if (element instanceof XmlAttributeValue) {
      return ((XmlAttributeValue)element).getValue();
    }
  }

  return null;
}
项目:ouzo-phpstorm-plugin    文件:TranslationKeyDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    if (!TranslationUtils.isTranslationFile(element.getContainingFile())) {
        return null;
    }

    if (location instanceof UsageViewTypeLocation) {
        return "Translation key";
    }

    if (location instanceof UsageViewNodeTextLocation || location instanceof UsageViewShortNameLocation || location instanceof UsageViewLongNameLocation) {
        return TranslationHashElement.newInstance(element).getFullKey();
    }

    return null;
}
项目:consulo-xml    文件:DefaultDomTargetDescriptionProvider.java   
public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) {
  if (!(element instanceof DomTarget)) return null;

  final DomTarget target = (DomTarget)element;

  DomElement domElement = target.getDomElement();
  final ElementPresentationTemplate template = domElement.getChildDescription().getPresentationTemplate();
  final ElementPresentation presentation = template != null ? template.createPresentation(domElement) : domElement.getPresentation();

  if (location == UsageViewTypeLocation.INSTANCE) {
    return presentation.getTypeName();
  }
  if (location == UsageViewNodeTextLocation.INSTANCE || location == UsageViewLongNameLocation.INSTANCE) {
    return presentation.getTypeName() + " " + StringUtil.notNullize(presentation.getElementName(), "''");
  }
  if (location instanceof HighlightUsagesDescriptionLocation) {
    return presentation.getTypeName();
  }
  return null;
}
项目:consulo-xml    文件:XmlUsageViewDescriptionProvider.java   
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof UsageViewShortNameLocation) {
    if (element instanceof XmlAttributeValue) {
      return ((XmlAttributeValue)element).getValue();
    }
  }

  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof XmlTag) {
      return ((XmlTag)element).getName();
    }
    else if (element instanceof XmlAttributeValue) {
      return ((XmlAttributeValue)element).getValue();
    }
  }

  return null;
}
项目:IntelliFrog    文件:FrogElementDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    if (location instanceof UsageViewTypeLocation) {
        if (element instanceof FrogAttribute) {
            return "Attribute";
        }
    } else if (location instanceof UsageViewNodeTextLocation
            || location instanceof UsageViewShortNameLocation
            || location instanceof UsageViewLongNameLocation) {
        if (element instanceof FrogAttribute) {
            return ((FrogAttribute) element).getName();
        }
    }

    return null;
}
项目:AppleScript-IDEA    文件:AppleScriptElementDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof PsiNamedElement && element instanceof AppleScriptPsiElement) {
      return ((PsiNamedElement) element).getName();
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PomDescriptionProvider.java   
@Override
@Nullable
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
  if (element instanceof PomTargetPsiElement) {
    return getElementDescription(((PomTargetPsiElement)element).getTarget(), location);
  }
  return null;
}
项目:intellij-ce-playground    文件:HighlightUsagesDescriptionLocation.java   
@Override
public ElementDescriptionProvider getDefaultProvider() {
  return new ElementDescriptionProvider() {
    @Override
    public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
      if (element instanceof PsiPresentableMetaData) {
        return ((PsiPresentableMetaData)element).getTypeName();
      }
      return null;
    }
  };
}
项目:intellij-ce-playground    文件:UsageViewLongNameLocation.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof PsiDirectory) {
      return PsiDirectoryFactory.getInstance(element.getProject()).getQualifiedName((PsiDirectory)element, true);
    }
    return "";
  }
  return null;
}
项目:intellij-ce-playground    文件:UsageViewShortNameLocation.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof UsageViewShortNameLocation)) return null;

  if (element instanceof PsiMetaOwner) {
    PsiMetaData metaData = ((PsiMetaOwner)element).getMetaData();
    if (metaData!=null) return DescriptiveNameUtil.getMetaDataName(metaData);
  }

  if (element instanceof PsiNamedElement) {
    return ((PsiNamedElement)element).getName();
  }
  return "";
}
项目:intellij-ce-playground    文件:DefaultPomTargetDescriptionProvider.java   
@Override
public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) {
  if (element instanceof PsiElement) return null;

  if (location == UsageViewTypeLocation.INSTANCE) {
    return getTypeName(element);
  }
  if (location == UsageViewNodeTextLocation.INSTANCE) {
    return getTypeName(element) + " " + StringUtil.notNullize(element instanceof PomNamedTarget ? ((PomNamedTarget)element).getName() : null, "''");
  }
  if (location instanceof HighlightUsagesDescriptionLocation) {
    return getTypeName(element);
  }
  return null;
}
项目:intellij-ce-playground    文件:DeleteNameDescriptionLocation.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof DeleteNameDescriptionLocation) {
    if (element instanceof PsiNamedElement) {
      return ((PsiNamedElement)element).getName();
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PyElementDescriptionProvider.java   
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof PsiNamedElement && element instanceof PyElement) {
      return ((PsiNamedElement)element).getName();
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PropertiesDescriptionProvider.java   
public String getElementDescription(@NotNull final PsiElement element, @Nullable final ElementDescriptionLocation location) {
  if (element instanceof IProperty) {
    if (location instanceof DeleteTypeDescriptionLocation) {
      int count = ((DeleteTypeDescriptionLocation) location).isPlural() ? 2 : 1;
      return IdeBundle.message("prompt.delete.property", count);
    }
    if (location instanceof UsageViewLongNameLocation) {
      return ((IProperty) element).getKey();
    }
  }
  return null;
}
项目:intellij-haskforce    文件:HaskellDescriptionProvider.java   
@Nullable
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    if (!element.getLanguage().is(HaskellLanguage.INSTANCE)) return null;
    if (!(element instanceof HaskellNamedElement)) return null;
    return ((HaskellNamedElement) element).getName();
}
项目:tools-idea    文件:PomDescriptionProvider.java   
@Override
@Nullable
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
  if (element instanceof PomTargetPsiElement) {
    return getElementDescription(((PomTargetPsiElement)element).getTarget(), location);
  }
  return null;
}
项目:tools-idea    文件:HighlightUsagesDescriptionLocation.java   
@Override
public ElementDescriptionProvider getDefaultProvider() {
  return new ElementDescriptionProvider() {
    @Override
    public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
      if (element instanceof PsiPresentableMetaData) {
        return ((PsiPresentableMetaData)element).getTypeName();
      }
      return null;
    }
  };
}
项目:tools-idea    文件:UsageViewLongNameLocation.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof PsiDirectory) {
      return PsiDirectoryFactory.getInstance(element.getProject()).getQualifiedName((PsiDirectory)element, true);
    }
    return "";
  }
  return null;
}
项目:tools-idea    文件:UsageViewShortNameLocation.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof UsageViewShortNameLocation)) return null;

  if (element instanceof PsiMetaOwner) {
    PsiMetaData metaData = ((PsiMetaOwner)element).getMetaData();
    if (metaData!=null) return DescriptiveNameUtil.getMetaDataName(metaData);
  }

  if (element instanceof PsiNamedElement) {
    return ((PsiNamedElement)element).getName();
  }
  return "";
}
项目:tools-idea    文件:DefaultPomTargetDescriptionProvider.java   
@Override
public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) {
  if (element instanceof PsiElement) return null;

  if (location == UsageViewTypeLocation.INSTANCE) {
    return getTypeName(element);
  }
  if (location == UsageViewNodeTextLocation.INSTANCE) {
    return getTypeName(element) + " " + StringUtil.notNullize(element instanceof PomNamedTarget ? ((PomNamedTarget)element).getName() : null, "''");
  }
  if (location instanceof HighlightUsagesDescriptionLocation) {
    return getTypeName(element);
  }
  return null;
}
项目:tools-idea    文件:DeleteNameDescriptionLocation.java   
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (location instanceof DeleteNameDescriptionLocation) {
    if (element instanceof PsiNamedElement) {
      return ((PsiNamedElement)element).getName();
    }
  }
  return null;
}
项目:tools-idea    文件:XmlNonCodeSearchElementDescriptionProvider.java   
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof NonCodeSearchDescriptionLocation)) return null;
  final NonCodeSearchDescriptionLocation ncdLocation = (NonCodeSearchDescriptionLocation)location;
  if (ncdLocation.isNonJava()) return null;
  if (element instanceof XmlTag) {
    return ((XmlTag)element).getValue().getTrimmedText();
  }
  else if (element instanceof XmlAttribute) {
    return ((XmlAttribute)element).getValue();
  }
  else if (element instanceof XmlAttributeValue) {
    return ((XmlAttributeValue)element).getValue();
  }
  return null;
}
项目:tools-idea    文件:PropertiesDescriptionProvider.java   
public String getElementDescription(@NotNull final PsiElement element, @Nullable final ElementDescriptionLocation location) {
  if (element instanceof IProperty) {
    if (location instanceof DeleteTypeDescriptionLocation) {
      int count = ((DeleteTypeDescriptionLocation) location).isPlural() ? 2 : 1;
      return IdeBundle.message("prompt.delete.property", count);
    }
    if (location instanceof UsageViewLongNameLocation) {
      return ((IProperty) element).getKey();
    }
  }
  return null;
}
项目:consulo-csharp    文件:CSharpElementDescriptionProvider.java   
@Nullable
@Override
@RequiredReadAction
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location)
{
    if(location == UsageViewShortNameLocation.INSTANCE && element instanceof CSharpNamedElement)
    {
        return ((CSharpNamedElement) element).getNameWithAt();
    }
    return null;
}
项目:emberjs-plugin    文件:EmberJSComponentRenameProcessor.java   
@Nullable
@Override
public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
    JSNamedElementProxy directive = ComponentUtil.getComponent(element);
    if (directive != null) {
        if (location instanceof UsageViewTypeLocation) return "component";
        return ComponentUtil.attributeToComponent(directive.getName());
    }
    return null;
}
项目:consulo    文件:PomDescriptionProvider.java   
@Override
@Nullable
public String getElementDescription(@Nonnull PsiElement element, @Nonnull ElementDescriptionLocation location) {
  if (element instanceof PomTargetPsiElement) {
    return getElementDescription(((PomTargetPsiElement)element).getTarget(), location);
  }
  return null;
}
项目:consulo    文件:HighlightUsagesDescriptionLocation.java   
@Override
public ElementDescriptionProvider getDefaultProvider() {
  return new ElementDescriptionProvider() {
    @Override
    public String getElementDescription(@Nonnull PsiElement element, @Nonnull ElementDescriptionLocation location) {
      if (element instanceof PsiPresentableMetaData) {
        return ((PsiPresentableMetaData)element).getTypeName();
      }
      return null;
    }
  };
}
项目:consulo    文件:UsageViewLongNameLocation.java   
@Override
public String getElementDescription(@Nonnull final PsiElement element, @Nonnull final ElementDescriptionLocation location) {
  if (location instanceof UsageViewLongNameLocation) {
    if (element instanceof PsiDirectory) {
      return PsiPackageHelper.getInstance(element.getProject()).getQualifiedName((PsiDirectory)element, true);
    }
    return "";
  }
  return null;
}
项目:consulo    文件:UsageViewShortNameLocation.java   
@Override
public String getElementDescription(@Nonnull final PsiElement element, @Nonnull final ElementDescriptionLocation location) {
  if (!(location instanceof UsageViewShortNameLocation)) return null;

  if (element instanceof PsiMetaOwner) {
    PsiMetaData metaData = ((PsiMetaOwner)element).getMetaData();
    if (metaData!=null) return DescriptiveNameUtil.getMetaDataName(metaData);
  }

  if (element instanceof PsiNamedElement) {
    return ((PsiNamedElement)element).getName();
  }
  return "";
}
项目:consulo    文件:DefaultPomTargetDescriptionProvider.java   
@Override
public String getElementDescription(@Nonnull PomTarget element, @Nonnull ElementDescriptionLocation location) {
  if (element instanceof PsiElement) return null;

  if (location == UsageViewTypeLocation.INSTANCE) {
    return getTypeName(element);
  }
  if (location == UsageViewNodeTextLocation.INSTANCE) {
    return getTypeName(element) + " " + StringUtil.notNullize(element instanceof PomNamedTarget ? ((PomNamedTarget)element).getName() : null, "''");
  }
  if (location instanceof HighlightUsagesDescriptionLocation) {
    return getTypeName(element);
  }
  return null;
}
项目:consulo    文件:DeleteNameDescriptionLocation.java   
@Override
public String getElementDescription(@Nonnull final PsiElement element, @Nonnull final ElementDescriptionLocation location) {
  if (location instanceof DeleteNameDescriptionLocation) {
    if (element instanceof PsiNamedElement) {
      return ((PsiNamedElement)element).getName();
    }
  }
  return null;
}