com.intellij.psi.ElementDescriptionLocation Java Examples

The following examples show how to use com.intellij.psi.ElementDescriptionLocation. 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: BuildElementDescriptionProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: GLSLDescriptionProvider.java    From glsl4idea with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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();
    }
 
Example #3
Source File: HaskellDescriptionProvider.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #4
Source File: CSharpElementDescriptionProvider.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
@RequiredReadAction
public String getElementDescription(@Nonnull PsiElement element, @Nonnull ElementDescriptionLocation location)
{
	if(location == UsageViewShortNameLocation.INSTANCE && element instanceof CSharpNamedElement)
	{
		return ((CSharpNamedElement) element).getNameWithAt();
	}
	return null;
}
 
Example #5
Source File: PomDescriptionProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public String getElementDescription(@Nonnull PsiElement element, @Nonnull ElementDescriptionLocation location) {
  if (element instanceof PomTargetPsiElement) {
    return getElementDescription(((PomTargetPsiElement)element).getTarget(), location);
  }
  return null;
}
 
Example #6
Source File: HighlightUsagesDescriptionLocation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
    }
  };
}
 
Example #7
Source File: UsageViewLongNameLocation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: UsageViewShortNameLocation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 "";
}
 
Example #9
Source File: DefaultPomTargetDescriptionProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #10
Source File: DeleteNameDescriptionLocation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #11
Source File: PomDescriptionProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public abstract String getElementDescription(@Nonnull PomTarget element, @Nonnull ElementDescriptionLocation location);
 
Example #12
Source File: DefaultRefactoringElementDescriptionProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getElementDescription(@Nonnull final PsiElement element, @Nonnull final ElementDescriptionLocation location) {
  final String typeString = UsageViewUtil.getType(element);
  final String name = DescriptiveNameUtil.getDescriptiveName(element);
  return typeString + " " + CommonRefactoringUtil.htmlEmphasize(name);
}