本文整理汇总了Java中com.intellij.psi.impl.source.html.dtd.HtmlElementDescriptorImpl类的典型用法代码示例。如果您正苦于以下问题:Java HtmlElementDescriptorImpl类的具体用法?Java HtmlElementDescriptorImpl怎么用?Java HtmlElementDescriptorImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HtmlElementDescriptorImpl类属于com.intellij.psi.impl.source.html.dtd包,在下文中一共展示了HtmlElementDescriptorImpl类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTagNameVariants
import com.intellij.psi.impl.source.html.dtd.HtmlElementDescriptorImpl; //导入依赖的package包/类
@Override
public void addTagNameVariants(List<LookupElement> elements, @NotNull XmlTag tag, String prefix)
{
final List<String> namespaces;
if(prefix.isEmpty())
{
namespaces = new ArrayList<>(Arrays.asList(tag.knownNamespaces()));
namespaces.add(XmlUtil.EMPTY_URI); // empty namespace
}
else
{
namespaces = new ArrayList<>(Collections.singletonList(tag.getNamespace()));
}
PsiFile psiFile = tag.getContainingFile();
XmlExtension xmlExtension = XmlExtension.getExtension(psiFile);
List<String> nsInfo = new ArrayList<>();
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<>();
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);
}
lookupElement = lookupElement.withCaseSensitivity(!(descriptor instanceof HtmlElementDescriptorImpl));
elements.add(PrioritizedLookupElement.withPriority(lookupElement, separator > 0 ? 0 : 1));
}
}