本文整理汇总了Java中com.intellij.psi.meta.PsiPresentableMetaData类的典型用法代码示例。如果您正苦于以下问题:Java PsiPresentableMetaData类的具体用法?Java PsiPresentableMetaData怎么用?Java PsiPresentableMetaData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiPresentableMetaData类属于com.intellij.psi.meta包,在下文中一共展示了PsiPresentableMetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getElementDescription
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@Override
public String getElementDescription(@NotNull final PsiElement psiElement, @NotNull final ElementDescriptionLocation location) {
if (!(location instanceof UsageViewTypeLocation)) return null;
if (psiElement instanceof PsiMetaOwner) {
final PsiMetaData metaData = ((PsiMetaOwner)psiElement).getMetaData();
if (metaData instanceof PsiPresentableMetaData) {
return ((PsiPresentableMetaData)metaData).getTypeName();
}
}
if (psiElement instanceof PsiFile) {
return LangBundle.message("terms.file");
}
if (psiElement instanceof PsiDirectory) {
return LangBundle.message("terms.directory");
}
final Language lang = psiElement.getLanguage();
FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(lang);
final String type = provider.getType(psiElement);
if (StringUtil.isNotEmpty(type)) {
return type;
}
return TypePresentationService.getService().getTypePresentableName(psiElement.getClass());
}
示例2: create
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
public static ComputableIcon create(final PsiPresentableMetaData data) {
return new ComputableIcon(new Computable<Icon>() {
@Override
public Icon compute() {
return data.getIcon();
}
});
}
示例3: getDefaultProvider
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@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;
}
};
}
示例4: update
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
private void update(PsiElement element) {
if (element != null && element.isValid()) {
final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
myIconOpen = presentation == null ? null : ComputableIcon.create(presentation, true);
myIconClosed = presentation == null ? null : ComputableIcon.create(presentation, false);
myPresentableText = presentation == null ? UsageViewUtil.createNodeText(element) : presentation.getPresentableText();
if (myIconOpen == null || myIconClosed == null) {
if (element instanceof PsiMetaOwner) {
final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element;
final PsiMetaData metaData = psiMetaOwner.getMetaData();
if (metaData instanceof PsiPresentableMetaData) {
final PsiPresentableMetaData psiPresentableMetaData = (PsiPresentableMetaData)metaData;
if (myIconOpen == null) myIconOpen = ComputableIcon.create(psiPresentableMetaData);
if (myIconClosed == null) myIconClosed = ComputableIcon.create(psiPresentableMetaData);
}
}
else if (element instanceof PsiFile) {
final PsiFile psiFile = (PsiFile)element;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null) {
myIconOpen = ComputableIcon.create(virtualFile);
myIconClosed = ComputableIcon.create(virtualFile);
}
}
}
}
}
示例5: getVariants
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@Override
@NotNull
public Object[] getVariants() {
final RngGrammar scope = getScope();
if (scope == null) {
return ResolveResult.EMPTY_ARRAY;
}
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(scope);
if (map == null || map.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY;
return ContainerUtil.mapNotNull(map.values(), new Function<Set<Define>, Object>() {
@Override
public Object fun(Set<Define> defines) {
final Define define = defines.iterator().next();
if (defines.size() == 0) {
return null;
} else {
final PsiElement element = define.getPsiElement();
if (element != null) {
final PsiPresentableMetaData data = (PsiPresentableMetaData)((PsiMetaOwner)element).getMetaData();
if (data != null) {
return LookupValueFactory.createLookupValue(data.getName(), data.getIcon());
} else {
return define.getName();
}
} else {
return define.getName();
}
}
}
}).toArray();
}
示例6: update
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
public void update() {
final PsiElement element = getElement();
if (element != null && element.isValid()) {
final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
myIconOpen = presentation != null ? ComputableIcon.create(presentation, true) : null;
myIconClosed = presentation != null ? ComputableIcon.create(presentation, false) : null;
myPresentableText = presentation != null ? presentation.getPresentableText() : UsageViewUtil.createNodeText(element);
if (myIconOpen == null || myIconClosed == null) {
if (element instanceof PsiMetaOwner) {
final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element;
final PsiMetaData metaData = psiMetaOwner.getMetaData();
if (metaData instanceof PsiPresentableMetaData) {
final PsiPresentableMetaData psiPresentableMetaData = (PsiPresentableMetaData)metaData;
if (myIconOpen == null) myIconOpen = ComputableIcon.create(psiPresentableMetaData);
if (myIconClosed == null) myIconClosed = ComputableIcon.create(psiPresentableMetaData);
}
}
else if (element instanceof PsiFile) {
final PsiFile psiFile = (PsiFile)element;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null) {
myIconOpen = ComputableIcon.create(virtualFile);
myIconClosed = ComputableIcon.create(virtualFile);
}
}
}
}
}
示例7: getVariants
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@NotNull
public Object[] getVariants() {
final RngGrammar scope = getScope();
if (scope == null) {
return ResolveResult.EMPTY_ARRAY;
}
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(scope);
if (map == null || map.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY;
return ContainerUtil.mapNotNull(map.values(), new Function<Set<Define>, Object>() {
public Object fun(Set<Define> defines) {
final Define define = defines.iterator().next();
if (defines.size() == 0) {
return null;
} else {
final PsiElement element = define.getPsiElement();
if (element != null) {
final PsiPresentableMetaData data = (PsiPresentableMetaData)((PsiMetaOwner)element).getMetaData();
if (data != null) {
return LookupValueFactory.createLookupValue(data.getName(), data.getIcon());
} else {
return define.getName();
}
} else {
return define.getName();
}
}
}
}).toArray();
}
示例8: getDefaultProvider
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@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;
}
};
}
示例9: getElementDescription
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@Override
public String getElementDescription(@Nonnull final PsiElement psiElement, @Nonnull final ElementDescriptionLocation location) {
if (!(location instanceof UsageViewTypeLocation)) return null;
if (psiElement instanceof PsiMetaOwner) {
final PsiMetaData metaData = ((PsiMetaOwner)psiElement).getMetaData();
if (metaData instanceof PsiPresentableMetaData) {
return ((PsiPresentableMetaData)metaData).getTypeName();
}
}
if (psiElement instanceof PsiFile) {
return LangBundle.message("terms.file");
}
if (psiElement instanceof PsiDirectory) {
return LangBundle.message("terms.directory");
}
final Language lang = psiElement.getLanguage();
FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(lang);
final String type = provider.getType(psiElement);
if (StringUtil.isNotEmpty(type)) {
return type;
}
return TypePresentationService.getInstance().getTypePresentableName(psiElement.getClass());
}
示例10: getVariants
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@Override
@NotNull
public Object[] getVariants() {
final RngGrammar scope = getScope();
if (scope == null) {
return ResolveResult.EMPTY_ARRAY;
}
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(scope);
if (map == null || map.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY;
return ContainerUtil.mapNotNull(map.values(), defines -> {
final Define define = defines.iterator().next();
if (defines.size() == 0) {
return null;
} else {
final PsiElement element = define.getPsiElement();
if (element != null) {
final PsiPresentableMetaData data = (PsiPresentableMetaData)((PsiMetaOwner)element).getMetaData();
if (data != null) {
return LookupValueFactory.createLookupValue(data.getName(), data.getIcon());
} else {
return define.getName();
}
} else {
return define.getName();
}
}
}).toArray();
}
示例11: testVariableAssignedFromGetter
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
public void testVariableAssignedFromGetter() throws Throwable {
PsiClass clazz = Util.addJavaClassTo(myFixture);
VtlVariable var = assertInstanceOf(resolveReferenceAtCaret(), VtlVariable.class);
PsiType varType = var.getPsiType();
assertInstanceOf(varType, PsiClassType.class);
PsiClass varClass = com.intellij.psi.util.PsiUtil.resolveClassInType(varType);
assertEquals(clazz, varClass);
PsiPresentableMetaData metadata = assertInstanceOf(var, PsiPresentableMetaData.class);
assertEquals(VelocityBundle.message("type.name.variable"), metadata.getTypeName());
}
示例12: testOverrideMacroParam
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
public void testOverrideMacroParam() throws Throwable {
Util.addEmptyJavaClassTo(myFixture);
VtlVariable var = assertInstanceOf(resolveReferenceAtCaret(), VtlVariable.class);
assertNotNull(var.getPsiType());
assertEquals(26, var.getNavigationElement().getTextOffset());
PsiPresentableMetaData metadata = assertInstanceOf(var, PsiPresentableMetaData.class);
assertEquals(VelocityBundle.message("type.name.variable"), metadata.getTypeName());
}
示例13: addVariants
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
private static void addVariants(final CompletionResultSet result,
final XmlAttribute[] attributes,
final XmlAttributeDescriptor[] descriptors,
XmlAttribute attribute,
@Nullable InsertHandler<LookupElement> replacementInsertHandler) {
final XmlTag tag = attribute.getParent();
final PsiFile file = tag.getContainingFile();
final XmlExtension extension = XmlExtension.getExtension(file);
final String prefix = attribute.getName().contains(":") && ((XmlAttributeImpl) attribute).getRealLocalName().length() > 0
? attribute.getNamespacePrefix() + ":"
: null;
CompletionData
completionData = CompletionUtil.getCompletionDataByElement(attribute, attribute.getContainingFile().getOriginalFile());
boolean caseSensitive = !(completionData instanceof HtmlCompletionData) || ((HtmlCompletionData)completionData).isCaseSensitive();
for (XmlAttributeDescriptor descriptor : descriptors) {
if (isValidVariant(attribute, descriptor, attributes, extension)) {
String name = descriptor.getName(tag);
InsertHandler<LookupElement> insertHandler = XmlAttributeInsertHandler.INSTANCE;
if (tag instanceof HtmlTag &&
HtmlUtil.isShortNotationOfBooleanAttributePreferred() &&
HtmlUtil.isBooleanAttribute(descriptor, tag)) {
insertHandler = null;
}
if (replacementInsertHandler != null) {
insertHandler = replacementInsertHandler;
}
else if (descriptor instanceof NamespaceAwareXmlAttributeDescriptor) {
final String namespace = ((NamespaceAwareXmlAttributeDescriptor)descriptor).getNamespace(tag);
if (file instanceof XmlFile &&
namespace != null &&
namespace.length() > 0 &&
!name.contains(":") &&
tag.getPrefixByNamespace(namespace) == null) {
insertHandler = new XmlAttributeInsertHandler(namespace);
}
}
if (prefix == null || name.startsWith(prefix)) {
if (prefix != null && name.length() > prefix.length()) {
name = descriptor.getName(tag).substring(prefix.length());
}
LookupElementBuilder element = LookupElementBuilder.create(name);
if (descriptor instanceof PsiPresentableMetaData) {
element = element.withIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
final int separator = name.indexOf(':');
if (separator > 0) {
element = element.withLookupString(name.substring(separator + 1));
}
element = element
.withCaseSensitivity(caseSensitive)
.withInsertHandler(insertHandler);
result.addElement(
descriptor.isRequired() ? PrioritizedLookupElement.withPriority(element.appendTailText("(required)", true), 100) :
HtmlUtil.isOwnHtmlAttribute(descriptor) ? PrioritizedLookupElement.withPriority(element, 50) : element);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:XmlAttributeReferenceCompletionProvider.java
示例14: addTagNameVariants
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
@Override
public void addTagNameVariants(List<LookupElement> elements, @NotNull XmlTag tag, String prefix) {
final List<String> namespaces;
if (prefix.isEmpty()) {
namespaces = new ArrayList<String>(Arrays.asList(tag.knownNamespaces()));
namespaces.add(XmlUtil.EMPTY_URI); // empty namespace
}
else {
namespaces = new ArrayList<String>(Collections.singletonList(tag.getNamespace()));
}
PsiFile psiFile = tag.getContainingFile();
XmlExtension xmlExtension = XmlExtension.getExtension(psiFile);
List<String> nsInfo = new ArrayList<String>();
List<XmlElementDescriptor> variants = TagNameVariantCollector.getTagDescriptors(tag, namespaces, nsInfo);
if (variants.isEmpty() && psiFile instanceof XmlFile && ((XmlFile)psiFile).getRootTag() == tag) {
getRootTagsVariants(tag, elements);
return;
}
final Set<String> visited = new HashSet<String>();
for (int i = 0; i < variants.size(); i++) {
XmlElementDescriptor descriptor = variants.get(i);
String qname = descriptor.getName(tag);
if (!visited.add(qname)) continue;
if (!prefix.isEmpty() && qname.startsWith(prefix + ":")) {
qname = qname.substring(prefix.length() + 1);
}
PsiElement declaration = descriptor.getDeclaration();
if (declaration != null && !declaration.isValid()) {
LOG.error(descriptor + " contains invalid declaration: " + declaration);
}
LookupElementBuilder lookupElement = declaration == null ? LookupElementBuilder.create(qname) : LookupElementBuilder.create(declaration, qname);
final int separator = qname.indexOf(':');
if (separator > 0) {
lookupElement = lookupElement.withLookupString(qname.substring(separator + 1));
}
String ns = nsInfo.get(i);
if (StringUtil.isNotEmpty(ns)) {
lookupElement = lookupElement.withTypeText(ns, true);
}
if (descriptor instanceof PsiPresentableMetaData) {
lookupElement = lookupElement.withIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
if (xmlExtension.useXmlTagInsertHandler()) {
lookupElement = lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE);
}
elements.add(PrioritizedLookupElement.withPriority(lookupElement, separator > 0 ? 0 : 1));
}
}
示例15: addVariants
import com.intellij.psi.meta.PsiPresentableMetaData; //导入依赖的package包/类
private static void addVariants(final CompletionResultSet result,
final XmlAttribute[] attributes,
final XmlAttributeDescriptor[] descriptors,
XmlAttribute attribute,
@Nullable InsertHandler<LookupElement> replacementInsertHandler) {
final XmlTag tag = attribute.getParent();
final PsiFile file = tag.getContainingFile();
final XmlExtension extension = XmlExtension.getExtension(file);
final String prefix = attribute.getName().contains(":") && ((XmlAttributeImpl) attribute).getRealLocalName().length() > 0
? attribute.getNamespacePrefix() + ":"
: null;
CompletionData
completionData = CompletionUtil.getCompletionDataByElement(attribute, attribute.getContainingFile().getOriginalFile());
boolean caseSensitive = !(completionData instanceof HtmlCompletionData) || ((HtmlCompletionData)completionData).isCaseSensitive();
for (XmlAttributeDescriptor descriptor : descriptors) {
if (isValidVariant(attribute, descriptor, attributes, extension)) {
String name = descriptor.getName(tag);
InsertHandler<LookupElement> insertHandler = XmlAttributeInsertHandler.INSTANCE;
if (replacementInsertHandler != null) {
insertHandler = replacementInsertHandler;
}
else if (descriptor instanceof NamespaceAwareXmlAttributeDescriptor) {
final String namespace = ((NamespaceAwareXmlAttributeDescriptor)descriptor).getNamespace(tag);
if (file instanceof XmlFile &&
namespace != null &&
namespace.length() > 0 &&
!name.contains(":") &&
tag.getPrefixByNamespace(namespace) == null) {
insertHandler = new XmlAttributeInsertHandler(namespace);
}
}
if (prefix == null || name.startsWith(prefix)) {
if (prefix != null && name.length() > prefix.length()) {
name = descriptor.getName(tag).substring(prefix.length());
}
LookupElementBuilder element = LookupElementBuilder.create(name);
if (descriptor instanceof PsiPresentableMetaData) {
element = element.withIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
final int separator = name.indexOf(':');
if (separator > 0) {
element = element.withLookupString(name.substring(separator + 1));
}
element = element
.withCaseSensitivity(caseSensitive)
.withInsertHandler(insertHandler);
result.addElement(
descriptor.isRequired() ? PrioritizedLookupElement.withPriority(element.appendTailText("(required)", true), 100) : element);
}
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:58,代码来源:XmlAttributeReferenceCompletionProvider.java