本文整理匯總了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));
}
}