use of org.intellij.plugins.relaxNG.xml.dom.RngDefine in project intellij-community by JetBrains.
the class ApplicationLoader method registerMetaData.
private static void registerMetaData() {
final MetaDataRegistrar registrar = MetaDataRegistrar.getInstance();
registrar.registerMetaData(new AndFilter(new NamespaceFilter(RNG_NAMESPACE), new ClassFilter(XmlDocument.class)), RngNsDescriptor.class);
registrar.registerMetaData(new ClassFilter(RncDocument.class), RngNsDescriptor.class);
registrar.registerMetaData(new ElementFilter() {
@Override
public boolean isAcceptable(Object element, PsiElement context) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag) element;
final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag);
return domElement instanceof RngDefine;
}
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return XmlTag.class.isAssignableFrom(hintClass);
}
}, RngDefineMetaData.class);
}
use of org.intellij.plugins.relaxNG.xml.dom.RngDefine in project intellij-community by JetBrains.
the class RngReferenceConverter method createReferences.
@Override
@NotNull
public PsiReference[] createReferences(GenericDomValue genericDomValue, PsiElement element, ConvertContext context) {
final GenericAttributeValue<String> e = (GenericAttributeValue<String>) genericDomValue;
if (genericDomValue.getParent() instanceof RngDefine) {
final XmlAttributeValue value = e.getXmlAttributeValue();
if (value == null) {
return PsiReference.EMPTY_ARRAY;
}
return new PsiReference[] { new PsiReferenceBase<XmlAttributeValue>(value, true) {
@Override
public PsiElement resolve() {
// }
return myElement.getParent().getParent();
}
@Override
@NotNull
public Object[] getVariants() {
final RngInclude include = e.getParentOfType(RngInclude.class, true);
final RngGrammar scope = e.getParentOfType(RngGrammar.class, true);
if (scope != null && include != null && DomUtil.isAncestor(scope, include, true)) {
final XmlFile file = include.getIncludedFile().getValue();
if (file != null) {
final DomFileElement<DomElement> fileElement = scope.getManager().getFileElement(file, DomElement.class);
if (fileElement == null) {
return EMPTY_ARRAY;
}
final Ref<Object[]> ref = new Ref<>(ArrayUtil.EMPTY_STRING_ARRAY);
fileElement.acceptChildren(new RngDomVisitor() {
@Override
public void visit(RngGrammar grammar) {
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
if (map != null) {
ref.set(map.keySet().toArray());
}
}
});
return ref.get();
}
}
// TODO: look for unresolved refs;
return ArrayUtil.EMPTY_STRING_ARRAY;
}
} };
}
return new PsiReference[] { new DefinitionReference(e) };
}
Aggregations