IDEA-64561 Provide navigation for XSD enum values

This commit is contained in:
Dmitry Avdeev
2013-08-21 13:51:51 +04:00
parent ba7e2a748a
commit f7725fbf1f
4 changed files with 13 additions and 9 deletions
@@ -127,7 +127,7 @@ public class XmlCompletionData extends CompletionData {
}
protected XmlAttributeValueGetter getAttributeValueGetter() {
return null;
return new XmlAttributeValueGetter();
}
protected ElementFilter createAttributeCompletionFilter() {
@@ -51,7 +51,8 @@ public class XmlAttributeValueReferenceProvider extends PsiReferenceProvider {
PsiElement parent = value.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor instanceof BasicXmlAttributeDescriptor && (descriptor.isFixed() || descriptor.isEnumerated())) {
if (descriptor instanceof BasicXmlAttributeDescriptor &&
(descriptor.isFixed() || descriptor.isEnumerated() || unquotedValue.equals(descriptor.getDefaultValue()))) { // todo case insensitive
return ((BasicXmlAttributeDescriptor)descriptor).getValueReferences(value);
}
}
@@ -58,18 +58,17 @@ public abstract class BasicXmlAttributeDescriptor implements XmlAttributeDescrip
}
public PsiElement getValueDeclaration(XmlAttributeValue attributeValue, String value) {
if (isFixed()) {
String defaultValue = getDefaultValue();
return Comparing.equal(defaultValue, value) ? getDefaultValueDeclaration() : null;
}
else {
return getEnumeratedValueDeclaration(attributeValue, value);
String defaultValue = getDefaultValue();
if (Comparing.equal(defaultValue, value)) {
return getDefaultValueDeclaration();
}
return isFixed() ? null : getEnumeratedValueDeclaration(attributeValue, value);
}
protected PsiElement getEnumeratedValueDeclaration(XmlAttributeValue attributeValue, String value) {
String[] values = getEnumeratedValues();
return values != null && ArrayUtilRt.find(values, value) != -1 ? getDeclaration() : null;
if (values == null || values.length == 0) return getDeclaration();
return ArrayUtilRt.find(values, value) != -1 ? getDeclaration() : null;
}
protected PsiElement getDefaultValueDeclaration() {
@@ -134,6 +134,10 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl
return true;
}
});
String defaultValue = getDefaultValue();
if (defaultValue != null) {
list.add(defaultValue);
}
return ArrayUtil.toStringArray(list);
}