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


Java XmlAttributeDescriptor.getEnumeratedValues方法代码示例

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


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

示例1: 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

示例2: testAttributeDescriptor4

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
public void testAttributeDescriptor4() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<!ELEMENT toc ANY> <!ATTLIST toc remote (true|false) \"false\">");

  final XmlTag tag = tag("toc");
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);

  XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
  assertTrue(!attributeDescriptor.isRequired());
  assertTrue(!attributeDescriptor.isFixed());
  assertTrue(attributeDescriptor.isEnumerated());
  assertEquals("false", attributeDescriptor.getDefaultValue());

  String[] values = attributeDescriptor.getEnumeratedValues();
  assertEquals(2, values.length);
  assertEquals("true", values[0]);
  assertEquals("false", values[1]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XmlDtdTest.java

示例3: testAttributeDescriptor5

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
public void testAttributeDescriptor5() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<!ELEMENT toc ANY> <!ATTLIST toc remote (0|1|2) #REQUIRED>");

  final XmlTag tag = tag("toc");
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);

  XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
  assertTrue(attributeDescriptor.isRequired());
  assertTrue(!attributeDescriptor.isFixed());
  assertTrue(attributeDescriptor.isEnumerated());
  assertNull(attributeDescriptor.getDefaultValue());

  String[] values = attributeDescriptor.getEnumeratedValues();
  assertEquals(3, values.length);
  assertEquals("0", values[0]);
  assertEquals("1", values[1]);
  assertEquals("2", values[2]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XmlDtdTest.java

示例4: testEntityDecl1

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
public void testEntityDecl1() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<!ENTITY % boolean \"(true|false|on|off|yes|no)\"> <!ELEMENT toc ANY> <!ATTLIST toc remote %boolean; \"false\"");

  final XmlTag tag = tag("toc");
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);

  XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
  assertTrue(!attributeDescriptor.isRequired());
  assertTrue(!attributeDescriptor.isFixed());
  assertTrue(attributeDescriptor.isEnumerated());
  assertEquals("false", (attributeDescriptor.getDefaultValue()));

  String[] values = attributeDescriptor.getEnumeratedValues();
  assertEquals(6, values.length);
  assertEquals("true", values[0]);
  assertEquals("false", values[1]);
  assertEquals("on", values[2]);
  assertEquals("off", values[3]);
  assertEquals("yes", values[4]);
  assertEquals("no", values[5]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XmlDtdTest.java

示例5: testEntityDecl4

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
public void testEntityDecl4() throws Exception {
  XmlNSDescriptor NSDescriptor = createDescriptor(
      "<!ENTITY % boolean \'(true|false|on|off|yes|no)\'> <!ENTITY % bool \"%boolean;\">  <!ELEMENT toc ANY> <!ATTLIST toc remote %bool; \"false\"");

  final XmlTag tag = tag("toc");
  XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);

  XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
  assertTrue(!attributeDescriptor.isRequired());
  assertTrue(!attributeDescriptor.isFixed());
  assertTrue(attributeDescriptor.isEnumerated());
  assertEquals("false", attributeDescriptor.getDefaultValue());

  String[] values = attributeDescriptor.getEnumeratedValues();
  assertEquals(6, values.length);
  assertEquals("true", values[0]);
  assertEquals("false", values[1]);
  assertEquals("on", values[2]);
  assertEquals("off", values[3]);
  assertEquals("yes", values[4]);
  assertEquals("no", values[5]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XmlDtdTest.java

示例6: getEnumeratedValues

import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
@Nullable
public static String[] getEnumeratedValues(XmlAttribute attribute) {
  final XmlAttributeDescriptor descriptor = attribute.getDescriptor();
  if (descriptor == null) {
    return ArrayUtil.EMPTY_STRING_ARRAY;
  }
  
  String [] result;
  if (descriptor instanceof BasicXmlAttributeDescriptor) {
    result = ((BasicXmlAttributeDescriptor)descriptor).getEnumeratedValues(attribute);
  }
  else if (descriptor instanceof XmlEnumerationDescriptor) {
    result = ((XmlEnumerationDescriptor)descriptor).getValuesForCompletion();
  }
  else {
    result = descriptor.getEnumeratedValues();
  }
  return result != null ? StringUtil.filterEmptyStrings(result) : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XmlAttributeValueGetter.java


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