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


Java XmlAttributeDescriptor类代码示例

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


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

示例1: getAttributeDescriptor

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
@Nullable
@Override
public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) {
  if (myPsiClass == null) return null;
  if (myPsiClass.findFieldByName(attributeName, true) == null) {
    if (FxmlConstants.FX_DEFAULT_PROPERTIES.contains(attributeName)){
      return new JavaFxDefaultAttributeDescriptor(attributeName, myPsiClass);
    } else {
      final PsiMethod propertySetter = JavaFxPsiUtil.findPropertySetter(attributeName, context);
      if (propertySetter != null) {
        return new JavaFxStaticPropertyAttributeDescriptor(propertySetter, attributeName);
      }
      final PsiMethod getter = JavaFxPsiUtil.findPropertyGetter(attributeName, myPsiClass);
      if (getter != null) {
        return new JavaFxPropertyAttributeDescriptor(attributeName, myPsiClass);
      }
      return null;
    }
  }
  return new JavaFxPropertyAttributeDescriptor(attributeName, myPsiClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaFxClassBackedElementDescriptor.java

示例2: getAttributesDescriptors

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
@Override
public XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable XmlTag context) {
  if (context != null) {
    final String name = context.getName();
    if (Comparing.equal(name, getName()) && myPsiClass != null) {
      final List<XmlAttributeDescriptor> simpleAttrs = new ArrayList<XmlAttributeDescriptor>();
      collectInstanceProperties(simpleAttrs);
      collectStaticAttributesDescriptors(context, simpleAttrs);
      for (String defaultProperty : FxmlConstants.FX_DEFAULT_PROPERTIES) {
        simpleAttrs.add(new JavaFxDefaultAttributeDescriptor(defaultProperty, myPsiClass));
      }
      return simpleAttrs.isEmpty() ? XmlAttributeDescriptor.EMPTY : simpleAttrs.toArray(new XmlAttributeDescriptor[simpleAttrs.size()]);
    }
  }
  return XmlAttributeDescriptor.EMPTY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaFxClassBackedElementDescriptor.java

示例3: isSchemaEnumerated

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public static boolean isSchemaEnumerated(final PsiElement element) {
  if (element instanceof XmlTag) {
    final XmlTag simpleContent = XmlUtil.getSchemaSimpleContent((XmlTag)element);
    if (simpleContent != null && XmlUtil.collectEnumerationValues(simpleContent, new HashSet<String>())) {
      return true;
    }                  
  }
  if (element instanceof XmlAttributeValue) {
    final PsiElement parent = element.getParent();
    if (parent instanceof XmlAttribute) {
      final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
      if (descriptor != null && descriptor.isEnumerated()) {
        return true;
      }

      String[] enumeratedValues = XmlAttributeValueGetter.getEnumeratedValues((XmlAttribute)parent);
      if (enumeratedValues != null && enumeratedValues.length > 0) {
        String value = descriptor == null ? null : descriptor.getDefaultValue();
        if (value == null || enumeratedValues.length != 1 || !value.equals(enumeratedValues[0])) {
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DomCompletionContributor.java

示例4: visitXmlAttributeValue

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
@Override public void visitXmlAttributeValue(XmlAttributeValue value) {
  checkReferences(value);

  final PsiElement parent = value.getParent();
  if (!(parent instanceof XmlAttribute)) {
    return;
  }

  XmlAttribute attribute = (XmlAttribute)parent;

  XmlTag tag = attribute.getParent();

  XmlElementDescriptor elementDescriptor = tag.getDescriptor();
  XmlAttributeDescriptor attributeDescriptor = elementDescriptor != null ? elementDescriptor.getAttributeDescriptor(attribute):null;

  if (attributeDescriptor != null && !skipValidation(value)) {
    String error = attributeDescriptor.validateValue(value, attribute.getValue());

    if (error != null) {
      HighlightInfoType type = getTagProblemInfoType(tag);
      addToResults(HighlightInfo.newHighlightInfo(type).range(value).descriptionAndTooltip(error).create());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:XmlHighlightVisitor.java

示例5: isBooleanAttribute

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public static boolean isBooleanAttribute(@NotNull XmlAttributeDescriptor descriptor, @Nullable PsiElement context) {
  if (descriptor instanceof HtmlAttributeDescriptorImpl && descriptor.isEnumerated()) {
    final String[] values = descriptor.getEnumeratedValues();
    if (values == null) {
      return false;
    }
    if (values.length == 2) {
      return values[0].isEmpty() && values[1].equals(descriptor.getName())
             || values[1].isEmpty() && values[0].equals(descriptor.getName());
    }
    else if (values.length == 1) {
      return descriptor.getName().equals(values[0]);
    }
  }
  return context != null && isCustomBooleanAttribute(descriptor.getName(), context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:HtmlUtil.java

示例6: getReferencesByElement

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
  XmlAttributeValue attributeValue = (XmlAttributeValue)element;
  String value = attributeValue.getValue();
  if (value == null) return PsiReference.EMPTY_ARRAY;
  int i = value.indexOf(':');
  if (i <= 0) return PsiReference.EMPTY_ARRAY;
  PsiElement parent = attributeValue.getParent();
  if (parent instanceof XmlAttribute && !XmlNSDescriptorImpl.checkSchemaNamespace(((XmlAttribute)parent).getParent())) {
    XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
    if (descriptor instanceof XmlAttributeDescriptorImpl) {
      String type = ((XmlAttributeDescriptorImpl)descriptor).getType();
      if (type != null && type.endsWith(":QName")) {
        String prefix = XmlUtil.findPrefixByQualifiedName(type);
        String ns = ((XmlTag)descriptor.getDeclaration()).getNamespaceByPrefix(prefix);
        if (XmlNSDescriptorImpl.checkSchemaNamespace(ns)) {
          return new PsiReference[] {
            new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i), null)
          };
        }
      }
    }
  }
  return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XmlPrefixReferenceProvider.java

示例7: getRootAttributeDescriptors

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public XmlAttributeDescriptor[] getRootAttributeDescriptors(final XmlTag context) {
  class CollectAttributesProcessor implements PsiElementProcessor<XmlTag> {
    final List<XmlAttributeDescriptor> result = new ArrayList<XmlAttributeDescriptor>();

    @Override
    public boolean execute(@NotNull final XmlTag element) {
      result.add(createAttributeDescriptor(element));
      return true;
    }
  }

  CollectAttributesProcessor processor = new CollectAttributesProcessor();
  processTagsInNamespace(myTag, new String[] {ATTRIBUTE_TAG_NAME}, processor);

  return processor.result.toArray(new XmlAttributeDescriptor[processor.result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XmlNSDescriptorImpl.java

示例8: getAttributeDescriptor

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
@Override
public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) {
  String caseSensitiveAttributeName =  !myCaseSensitive ? attributeName.toLowerCase() : attributeName;
  XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(caseSensitiveAttributeName, context);
  if (descriptor == null) descriptor = RelaxedHtmlFromSchemaElementDescriptor.getAttributeDescriptorFromFacelets(attributeName, context);
  
  if (descriptor == null) {
    String prefix = XmlUtil.findPrefixByQualifiedName(attributeName);
    
    if ("xml".equals(prefix)) { // todo this is not technically correct dtd document references namespaces but we should handle it at least for xml stuff
      XmlNSDescriptor nsdescriptor = context.getNSDescriptor(XmlUtil.XML_NAMESPACE_URI, true);
      if (nsdescriptor instanceof XmlNSDescriptorImpl) {
        descriptor = ((XmlNSDescriptorImpl)nsdescriptor).getAttribute(
          XmlUtil.findLocalNameByQualifiedName(caseSensitiveAttributeName), XmlUtil.XML_NAMESPACE_URI, context);
      }
    }
  }
  if (descriptor == null && HtmlUtil.isHtml5Context(context)) {
    descriptor = myDelegate.getAttributeDescriptor(attributeName, context);
  }
  return descriptor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:HtmlElementDescriptorImpl.java

示例9: testElementDescriptor2

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public void testElementDescriptor2() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"comment\" type=\"xsd:string\"/>" +
      "</xsd:schema>");

  XmlTag tag = XmlTestUtil.tag("comment", getProject());
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);

  XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
  assertEquals(0, elements.length);

  XmlAttributeDescriptor[] descriptors = elementDescriptor.getAttributesDescriptors(tag);
  assertEquals(0, descriptors.length);

  assertEquals(elementDescriptor.getContentType(), XmlElementDescriptor.CONTENT_TYPE_MIXED);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XmlSchemaTest.java

示例10: testElementDescriptor10

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public void testElementDescriptor10() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" +
      "<xsd:complexType name=\"PurchaseOrderType\">" +
      "    <xsd:attributeGroup ref=\"ddd:bookAttributes\"/>" +
      "</xsd:complexType>" +
      "<xsd:attributeGroup name=\"bookAttributes\">" +
      "   <xsd:attribute name=\"isbn\" type=\"xs:string\" use=\"required\"/>" +
      "   <xsd:attribute name=\"available\" type=\"xs:string\"/>" +
      "</xsd:attributeGroup>" +
      "</xsd:schema>");

  final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);

  XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);

  assertEquals(2, attributes.length);
  assertEquals("isbn", attributes[0].getName());
  assertEquals("available", attributes[1].getName());

  assertEquals("isbn", elementDescriptor.getAttributeDescriptor("isbn", tag).getName());

  assertNull(elementDescriptor.getAttributeDescriptor("xxx", tag));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XmlSchemaTest.java

示例11: testAttributeDescriptor1

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public void testAttributeDescriptor1() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" +
      "<xsd:complexType name=\"PurchaseOrderType\">" +
      "   <xsd:attribute name=\"orderDate\" type=\"xsd:date\"/>" +
      "</xsd:complexType>" +
      "</xsd:schema>");

  final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
  XmlAttributeDescriptor attribute = elementDescriptor.getAttributeDescriptor("orderDate", tag);

  assertTrue(!attribute.isEnumerated());
  assertTrue(!attribute.isFixed());
  assertTrue(!attribute.isRequired());
  assertNull(attribute.getDefaultValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XmlSchemaTest.java

示例12: computeAttributeDescriptors

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
protected XmlAttributeDescriptor[] computeAttributeDescriptors(final Map<DAttributePattern, Pair<? extends Map<String, String>, Boolean>> map) {
  final Map<QName, RngXmlAttributeDescriptor> name2descriptor = new HashMap<QName, RngXmlAttributeDescriptor>();

  for (DAttributePattern pattern : map.keySet()) {
    final Pair<? extends Map<String, String>, Boolean> value = map.get(pattern);
    for (QName name : pattern.getName().listNames()) {
      RngXmlAttributeDescriptor descriptor = name2descriptor.get(name);
      final RngXmlAttributeDescriptor newDescriptor = new RngXmlAttributeDescriptor(this, pattern, value.first, value.second);
      if (descriptor == null) {
        descriptor = newDescriptor;
      }
      else {
        descriptor = descriptor.mergeWith(newDescriptor);
      }
      name2descriptor.put(name, descriptor);
    }
  }

  final Collection<RngXmlAttributeDescriptor> result = name2descriptor.values();
  return result.toArray(new RngXmlAttributeDescriptor[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RngElementDescriptor.java

示例13: testAttributeDescriptor2

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public void testAttributeDescriptor2() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" +
      "<xsd:complexType name=\"PurchaseOrderType\">" +
      "   <xsd:attribute name=\"orderDate\" type=\"xsd:date\" use=\"required\" default=\" 2002 \"/>" +
      "</xsd:complexType>" +
      "</xsd:schema>");

  final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
  XmlAttributeDescriptor attribute = elementDescriptor.getAttributeDescriptor("orderDate", tag);

  assertTrue(!attribute.isEnumerated());
  assertTrue(!attribute.isFixed());
  assertTrue(attribute.isRequired());
  assertEquals(" 2002 ", attribute.getDefaultValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XmlSchemaTest.java

示例14: testAttributeDescriptor3

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public void testAttributeDescriptor3() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" +
      "<xsd:complexType name=\"PurchaseOrderType\">" +
      "   <xsd:attribute name=\"orderDate\" type=\"xsd:date\" fixed=\"1 01 2001\"/>" +
      "</xsd:complexType>" +
      "</xsd:schema>");

  final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
  XmlAttributeDescriptor attribute = elementDescriptor.getAttributeDescriptor("orderDate", tag);

  assertTrue(!attribute.isEnumerated());
  assertTrue(attribute.isFixed());
  assertTrue(!attribute.isRequired());
  assertEquals("1 01 2001", attribute.getDefaultValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XmlSchemaTest.java

示例15: testAttributeDescriptor4

import com.intellij.xml.XmlAttributeDescriptor; //导入依赖的package包/类
public void testAttributeDescriptor4() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" +
      "<xsd:complexType name=\"PurchaseOrderType\">" +
      "   <xsd:attribute ref=\"orderDate\" use=\"required\"/>" +
      "</xsd:complexType>" +
      "   <xsd:attribute name=\"orderDate\" type=\"xsd:date\" fixed=\"1 01 2001\"/>" +
      "</xsd:schema>");

  final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
  XmlAttributeDescriptor attribute = elementDescriptor.getAttributeDescriptor("orderDate", tag);

  assertNotNull(attribute);
  assertTrue(!attribute.isEnumerated());
  assertTrue(attribute.isFixed());
  assertTrue(attribute.isRequired());
  assertEquals("1 01 2001", attribute.getDefaultValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:XmlSchemaTest.java


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