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


Java XmlNSDescriptor类代码示例

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


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

示例1: getDescriptor

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag xmlTag) {
  final Project project = xmlTag.getProject();
  CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(project);

  if (!(xmlTag instanceof HtmlTag && manager.isCatberryEnabled())) return null;

  final XmlNSDescriptor nsDescriptor = xmlTag.getNSDescriptor(xmlTag.getNamespace(), false);
  final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(xmlTag) : null;
  final boolean special = CatberryConstants.SPECIAL_COMPONENT_NAMES.contains(xmlTag.getName());
  if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor || special)) return null;

  final String name = CatberryComponentUtils.normalizeName(xmlTag.getName());
  final PsiFile file = CatberryComponentUtils.findComponent(project, name);
  return file != null ? new CatberryComponentTagDescriptor(xmlTag.getName(), file) : null;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:18,代码来源:CatberryComponentTagDescriptorsProvider.java

示例2: collectInformation

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
@Nullable
@Override
public MyHost collectInformation(@NotNull PsiFile file) {
  if (!(file instanceof XmlFile)) return null;
  final XmlDocument document = ((XmlFile)file).getDocument();
  if (document == null) return null;
  XmlTag rootTag = document.getRootTag();
  XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false);

  if (nsDescriptor instanceof Validator) {
    //noinspection unchecked
    MyHost host = new MyHost();
    ((Validator<XmlDocument>)nsDescriptor).validate(document, host);
    return host;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XMLExternalAnnotator.java

示例3: getElementDescriptor

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
private static XmlElementDescriptor getElementDescriptor(final String text, final XmlNSDescriptor NSDescriptor) {
  XmlElementDescriptor element = null;
  if (NSDescriptor instanceof XmlNSDescriptorImpl) {
    element = ((XmlNSDescriptorImpl)NSDescriptor).getElementDescriptor(text);
  }
  else if (NSDescriptor instanceof XmlNSDescriptorSequence) {
    final List<XmlNSDescriptor> sequence = ((XmlNSDescriptorSequence)NSDescriptor).getSequence();
    for (XmlNSDescriptor xmlNSDescriptor : sequence) {
      if (xmlNSDescriptor instanceof XmlNSDescriptorImpl) {
        element = ((XmlNSDescriptorImpl)xmlNSDescriptor).getElementDescriptor(text);
        if(element != null) break;
      }
    }
  }
  else {
    element = null;
  }
  return element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XmlElementDescriptorImpl.java

示例4: testElementDescriptor3

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
public void testElementDescriptor3() throws Exception {
  XmlFile file = createFile("<root><a><b/><c></c></a><a><c/></a></root>");
  XmlNSDescriptor descriptor = createDescriptor(file);

  XmlTag rootTag = file.getDocument().getRootTag();
  XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
  element = element.getElementsDescriptors(rootTag)[0];

  XmlElementDescriptor[] elements = element.getElementsDescriptors(rootTag.getSubTags()[0]);

  assertEquals(2, elements.length);
  assertEquals("b", elements[0].getName());
  //assertTrue(elements[0].getContentType() == XmlElementDescriptor.CONTENT_TYPE_EMPTY);

  assertEquals("c", elements[1].getName());
  //assertTrue(elements[1].getContentType() == XmlElementDescriptor.CONTENT_TYPE_CHILDREN);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XmlInsightTest.java

示例5: testElementDescriptor2

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

示例6: testElementDescriptor4

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
public void testElementDescriptor4() 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:attribute name=\"name\" type=\"xsd:string\"/>" +
      "</xsd:complexType>" +
      "</xsd:schema>");

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

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

  assertEquals(2, attributes.length);
  assertEquals("orderDate", attributes[0].getName());
  assertEquals("name", attributes[1].getName());

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

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

示例7: testElementDescriptor8

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
public void testElementDescriptor8() 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:sequence>" +
      "     <xsd:element ref=\"items\"/>" +
      "   </xsd:sequence>" +
      "</xsd:complexType>" +
      "<xsd:element name=\"items\" type=\"xsd:string\"/>" +
      "</xsd:schema>");

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

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

  assertEquals("items", elementDescriptor.getElementDescriptor(XmlTestUtil.tag("items", getProject()), null).getName());
  assertNull(elementDescriptor.getElementDescriptor(UNKNOWN_TAG, null));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XmlSchemaTest.java

示例8: testElementDescriptor10

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

示例9: testElementDescriptor13

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
public void testElementDescriptor13() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      "<xsd:element name=\"purchaseOrder\">" +
      "<xsd:complexType name=\"PurchaseOrderType\">" +
      "   <xsd:sequence>" +
      "     <xsd:element ref=\"shipTo\"/>" +
      "   </xsd:sequence>" +
      "</xsd:complexType>" +
      "</xsd:element>" +
      "<xsd:element name=\"shipTo\" abstract=\"true\">" +
      "</xsd:schema>");

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

  final XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
  assertEquals(0, elements.length);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XmlSchemaTest.java

示例10: testAttributeDescriptor1

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

示例11: testAttributeDescriptor2

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

示例12: testAttributeDescriptor3

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

示例13: testAttributeDescriptor4

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

示例14: testNamespace2

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

  XmlTag tag = XmlTestUtil.tag("purchaseOrder", "http://www.w3.org/2001/XMLSchema", getProject());
  XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)NSDescriptor.getElementDescriptor(tag);

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

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

示例15: testAny3

import com.intellij.xml.XmlNSDescriptor; //导入依赖的package包/类
public void testAny3() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<xsd:schema targetNamespace=\"http://foo\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" +
      "  <xsd:element name=\"root\">" +
      "    <xsd:complexType>" +
      "        <xsd:anyAttribute namespace=\"##other\" processContents=\"skip\"/>" +
      "    </xsd:complexType>" +
      "  </xsd:element>" +
      "</xsd:schema>"
  );

  XmlFile xmlFile = (XmlFile)createFile("file.xml",
                                        "<root xmlns=\"http://foo\" y:a=\"1\">" +
                                        "</root>"
  );

  final XmlTag rootTag = xmlFile.getDocument().getRootTag();
  XmlElementDescriptor rootDescriptor = NSDescriptor.getElementDescriptor(rootTag);
  assertNotNull(rootDescriptor);

  XmlAttribute attribute = rootTag.getAttribute("y:a", XmlUtil.EMPTY_URI);
  assertNotNull(attribute);
  XmlAttributeDescriptor aDescriptor = rootDescriptor.getAttributeDescriptor("y:a", rootTag);
  assertNotNull(aDescriptor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlSchemaTest.java


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