本文整理汇总了Java中com.intellij.xml.XmlAttributeDescriptor.getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java XmlAttributeDescriptor.getDefaultValue方法的具体用法?Java XmlAttributeDescriptor.getDefaultValue怎么用?Java XmlAttributeDescriptor.getDefaultValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.xml.XmlAttributeDescriptor
的用法示例。
在下文中一共展示了XmlAttributeDescriptor.getDefaultValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: domKnowsBetter
import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
private boolean domKnowsBetter(final CompletionParameters parameters, final CompletionResultSet result) {
final XmlAttributeValue element = PsiTreeUtil.getParentOfType(parameters.getPosition(), XmlAttributeValue.class);
if (element == null) {
return false;
}
if (isSchemaEnumerated(element)) {
return false;
}
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute) {
XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor != null && descriptor.getDefaultValue() != null) {
final PsiReference[] references = myProvider.getReferencesByElement(element, new ProcessingContext());
if (references.length > 0) {
return LegacyCompletionContributor.completeReference(parameters, result);
}
}
}
return false;
}
示例2: 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;
}
示例3: getApplicableAttributeVariants
import com.intellij.xml.XmlAttributeDescriptor; //导入方法依赖的package包/类
private Object[] getApplicableAttributeVariants(PsiElement _context) {
if (_context instanceof XmlTokenImpl && ((XmlTokenImpl)_context).getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) {
XmlAttribute attr = PsiTreeUtil.getParentOfType(_context, XmlAttribute.class);
if (attr != null) {
final XmlAttributeDescriptor descriptor = attr.getDescriptor();
if (descriptor != null) {
if (descriptor.isFixed()) {
final String defaultValue = descriptor.getDefaultValue();
return defaultValue == null ? ArrayUtil.EMPTY_OBJECT_ARRAY : new Object[]{defaultValue};
}
String[] values = getEnumeratedValues(attr);
final String[] strings = addSpecificCompletions(attr);
if (values == null || values.length == 0) {
values = strings;
}
else if (strings != null) {
values = ArrayUtil.mergeArrays(values, strings);
}
return values == null ? ArrayUtil.EMPTY_OBJECT_ARRAY : values;
}
}
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}