当前位置: 首页>>代码示例>>Java>>正文


Java XmlAttributeDescriptor.getName方法代码示例

本文整理汇总了Java中com.intellij.xml.XmlAttributeDescriptor.getName方法的典型用法代码示例。如果您正苦于以下问题:Java XmlAttributeDescriptor.getName方法的具体用法?Java XmlAttributeDescriptor.getName怎么用?Java XmlAttributeDescriptor.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.xml.XmlAttributeDescriptor的用法示例。


在下文中一共展示了XmlAttributeDescriptor.getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processElementDescriptors

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
private static void processElementDescriptors(XmlElementDescriptor descriptor, XmlTag tag, ElementNames names, Set<XmlElementDescriptor> history, int depth)
  throws StopProcessingException {
  if (!history.add(descriptor) || ++depth == 200) {
    if (depth == 200) {
      throw new StopProcessingException();
    }
    return;
  }
  final String namespace = descriptor instanceof XmlElementDescriptorImpl
          ? ((XmlElementDescriptorImpl)descriptor).getNamespace()
          : tag.getNamespace();
  names.elementNames.add(new QName(namespace, descriptor.getName()));

  final XmlAttributeDescriptor[] attributesDescriptors = descriptor.getAttributesDescriptors(null);
  for (XmlAttributeDescriptor attributesDescriptor : attributesDescriptors) {
    final String localPart = attributesDescriptor.getName();
    if (!"xmlns".equals(localPart)) names.attributeNames.add(new QName(localPart));
  }

  final XmlElementDescriptor[] descriptors = descriptor.getElementsDescriptors(tag);
  for (XmlElementDescriptor elem : descriptors) {
    processElementDescriptors(elem, tag, names, history, depth);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:XsltContextProviderBase.java

示例2: isValidVariant

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
private static boolean isValidVariant(XmlAttribute attribute,
                                      @NotNull XmlAttributeDescriptor descriptor,
                                      final XmlAttribute[] attributes,
                                      final XmlExtension extension) {
  if (extension.isIndirectSyntax(descriptor)) return false;
  String descriptorName = descriptor.getName(attribute.getParent());
  if (descriptorName == null) {
    LOG.error("Null descriptor name for " + descriptor + " " + descriptor.getClass() + " ");
    return false;
  }
  for (final XmlAttribute otherAttr : attributes) {
    if (otherAttr != attribute && otherAttr.getName().equals(descriptorName)) return false;
  }
  return !descriptorName.contains(DUMMY_IDENTIFIER_TRIMMED);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:XmlAttributeReferenceCompletionProvider.java

示例3: addVariants

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的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


注:本文中的com.intellij.xml.XmlAttributeDescriptor.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。