本文整理汇总了Java中com.intellij.codeInsight.completion.XmlTagInsertHandler类的典型用法代码示例。如果您正苦于以下问题:Java XmlTagInsertHandler类的具体用法?Java XmlTagInsertHandler怎么用?Java XmlTagInsertHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlTagInsertHandler类属于com.intellij.codeInsight.completion包,在下文中一共展示了XmlTagInsertHandler类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addTagNameVariants
import com.intellij.codeInsight.completion.XmlTagInsertHandler; //导入依赖的package包/类
@Override
public void addTagNameVariants(final List<LookupElement> elements, @NotNull XmlTag xmlTag, String prefix) {
CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(xmlTag.getProject());
if (!(xmlTag instanceof HtmlTag && manager.isCatberryEnabled())) return;
final Project project = xmlTag.getProject();
Map<String, PsiFile> map = CatberryComponentUtils.findComponents(project);
for(Map.Entry<String, PsiFile> entry : map.entrySet()) {
String key = entry.getKey();
if(!CatberryConstants.SPECIAL_COMPONENT_NAMES.contains(entry.getKey()))
key = CatberryConstants.CATBERRY_COMPONENT_TAG_PREFIX + key;
elements.add(LookupElementBuilder.create(entry.getValue(), key).withInsertHandler(XmlTagInsertHandler.INSTANCE));
}
}
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:16,代码来源:CatberryComponentTagDescriptorsProvider.java
示例2: addTagNameVariants
import com.intellij.codeInsight.completion.XmlTagInsertHandler; //导入依赖的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()));
}
XmlExtension xmlExtension = XmlExtension.getExtension(tag.getContainingFile());
List<String> nsInfo = new ArrayList<String>();
@SuppressWarnings("unchecked") List<XmlElementDescriptor> variants = TagNameVariantCollector
.getTagDescriptors(tag, namespaces, nsInfo);
for (int i = 0; i < variants.size(); i++) {
XmlElementDescriptor descriptor = variants.get(i);
String qname = descriptor.getName(tag);
if (!prefix.isEmpty() && qname.startsWith(prefix + ":")) {
qname = qname.substring(prefix.length() + 1);
}
PsiElement declaration = descriptor.getDeclaration();
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 (xmlExtension.useXmlTagInsertHandler()) {
elements.add(lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE));
}
else {
elements.add(lookupElement);
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:DefaultXmlTagNameProvider.java
示例3: addTagNameVariants
import com.intellij.codeInsight.completion.XmlTagInsertHandler; //导入依赖的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));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:53,代码来源:DefaultXmlTagNameProvider.java
示例4: addLookupItem
import com.intellij.codeInsight.completion.XmlTagInsertHandler; //导入依赖的package包/类
private static void addLookupItem(List<LookupElement> elements, JSNamedElementProxy component) {
elements.add(LookupElementBuilder.create(component).withInsertHandler(XmlTagInsertHandler.INSTANCE));
}
开发者ID:kristianmandrup,项目名称:emberjs-plugin,代码行数:4,代码来源:EmberJSTagDescriptorsProvider.java
示例5: addTagNameVariants
import com.intellij.codeInsight.completion.XmlTagInsertHandler; //导入依赖的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));
}
}
开发者ID:consulo,项目名称:consulo-xml,代码行数:67,代码来源:DefaultXmlTagNameProvider.java
注:本文中的com.intellij.codeInsight.completion.XmlTagInsertHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论