use of com.intellij.xml.impl.schema.XmlAttributeDescriptorImpl in project intellij-community by JetBrains.
the class HtmlUtil method getCustomAttributeDescriptors.
public static XmlAttributeDescriptor[] getCustomAttributeDescriptors(XmlElement context) {
String entitiesString = getEntitiesString(context, XmlEntitiesInspection.ATTRIBUTE_SHORT_NAME);
if (entitiesString == null)
return XmlAttributeDescriptor.EMPTY;
StringTokenizer tokenizer = new StringTokenizer(entitiesString, ",");
XmlAttributeDescriptor[] descriptors = new XmlAttributeDescriptor[tokenizer.countTokens()];
int index = 0;
while (tokenizer.hasMoreElements()) {
final String customName = tokenizer.nextToken();
if (customName.length() == 0)
continue;
descriptors[index++] = new XmlAttributeDescriptorImpl() {
@Override
public String getName(PsiElement context) {
return customName;
}
@Override
public String getName() {
return customName;
}
};
}
return descriptors;
}
use of com.intellij.xml.impl.schema.XmlAttributeDescriptorImpl in project intellij-community by JetBrains.
the class XmlPrefixReferenceProvider method getReferencesByElement.
@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) {
XmlTag tag = ((XmlAttribute) parent).getParent();
if (tag != null && !XmlNSDescriptorImpl.checkSchemaNamespace(tag)) {
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;
}
Aggregations