use of com.intellij.xml.XmlNSDescriptor in project intellij-plugins by JetBrains.
the class AngularJSTagDescriptor method getElementDescriptor.
@Override
public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
XmlTag parent = contextTag.getParentTag();
if (parent == null)
return null;
final XmlNSDescriptor descriptor = parent.getNSDescriptor(childTag.getNamespace(), true);
return descriptor == null ? null : descriptor.getElementDescriptor(childTag);
}
use of com.intellij.xml.XmlNSDescriptor in project android by JetBrains.
the class AndroidXmlTagDescriptor method getElementDescriptor.
@Override
public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
final XmlElementDescriptor descriptor = myParentDescriptor.getElementDescriptor(childTag, contextTag);
if (descriptor != null) {
return descriptor;
}
final XmlNSDescriptor nsDescriptor = getNSDescriptor();
return nsDescriptor != null ? new AndroidAnyTagDescriptor(nsDescriptor) : null;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-plugins by JetBrains.
the class FlexHighlightingTest method testAfterRename.
@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithGumboSdk })
@SuppressWarnings({ "ConstantConditions" })
public void testAfterRename() throws Exception {
configureByFile(getBasePath() + "/afterRename.xml");
XmlNSDescriptor nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
assertTrue(nsDescriptor.toString(), nsDescriptor instanceof XmlNSDescriptorImpl);
doDoTest(true, true);
new RenameProcessor(getProject(), getFile(), "afterRename.mxml", false, false).run();
assertEquals("afterRename.mxml", getFile().getName());
assertFalse(myFile.isValid());
myFile = myPsiManager.findFile(getFile().getVirtualFile().getParent().findChild("afterRename.mxml"));
assertTrue(myFile.isValid());
nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
assertTrue(nsDescriptor.toString(), nsDescriptor instanceof FlexMxmlNSDescriptor);
doDoTest(true, true);
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-plugins by JetBrains.
the class AngularJSTagDescriptorsProvider method getDescriptor.
@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag xmlTag) {
final Project project = xmlTag.getProject();
if (!(xmlTag instanceof HtmlTag && AngularIndexUtil.hasAngularJS(project)))
return null;
final String tagName = xmlTag.getName();
final String directiveName = DirectiveUtil.normalizeAttributeName(tagName);
final XmlNSDescriptor nsDescriptor = xmlTag.getNSDescriptor(xmlTag.getNamespace(), false);
final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(xmlTag) : null;
if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) {
return null;
}
if ((NG_CONTAINER.equals(directiveName) || NG_CONTENT.equals(directiveName) || NG_TEMPLATE.equals(directiveName)) && AngularIndexUtil.hasAngularJS2(project)) {
return new AngularJSTagDescriptor(directiveName, createDirective(xmlTag, directiveName));
}
JSImplicitElement directive = DirectiveUtil.getTagDirective(directiveName, project);
if (DirectiveUtil.isAngular2Directive(directive) && !directive.getName().equals(tagName)) {
// we've found directive via normalized name for Angular, it should not work
directive = null;
}
if (directive == null && !tagName.equals(directiveName) && AngularIndexUtil.hasAngularJS2(project)) {
directive = DirectiveUtil.getTagDirective(tagName, project);
if (!DirectiveUtil.isAngular2Directive(directive))
directive = null;
}
return directive != null ? new AngularJSTagDescriptor(directiveName, directive) : null;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XsltContextProviderBase method fillFromSchema.
private static void fillFromSchema(PsiFile file, ElementNames names) {
if (!(file instanceof XmlFile))
return;
final XmlFile f = (XmlFile) file;
final XmlDocument d = f.getDocument();
if (d == null)
return;
final XmlTag rootTag = d.getRootTag();
if (rootTag == null)
return;
//noinspection unchecked
names.dependencies.add(new NSDeclTracker(rootTag));
try {
final Map<String, String> namespaceDeclarations = rootTag.getLocalNamespaceDeclarations();
final Collection<String> prefixes = namespaceDeclarations.keySet();
final XmlElementFactory ef = XmlElementFactory.getInstance(file.getProject());
int noSchemaNamespaces = 0;
for (String prefix : prefixes) {
final String namespace = namespaceDeclarations.get(prefix);
if (isIgnoredNamespace(prefix, namespace))
continue;
final XmlTag tag = ef.createTagFromText("<dummy-tag xmlns='" + namespace + "' />", XMLLanguage.INSTANCE);
final XmlDocument document = PsiTreeUtil.getParentOfType(tag, XmlDocument.class);
final XmlNSDescriptor rootDescriptor = tag.getNSDescriptor(tag.getNamespace(), true);
if (rootDescriptor == null || (rootDescriptor instanceof XmlNSDescriptorImpl && ((XmlNSDescriptorImpl) rootDescriptor).getTag() == null) || !rootDescriptor.getDeclaration().isPhysical()) {
final QName any = QNameUtil.createAnyLocalName(namespace);
names.elementNames.add(any);
names.attributeNames.add(any);
noSchemaNamespaces++;
continue;
}
//noinspection unchecked
names.dependencies.add(rootDescriptor.getDescriptorFile());
//noinspection unchecked
final Set<XmlElementDescriptor> history = new THashSet<>(150);
final XmlElementDescriptor[] e = rootDescriptor.getRootElementsDescriptors(document);
try {
for (XmlElementDescriptor descriptor : e) {
processElementDescriptors(descriptor, tag, names, history, 0);
}
} catch (StopProcessingException e1) {
Logger.getInstance(XsltContextProviderBase.class).error("Maximum recursion depth reached. Missing equals()/hashCode() implementation?", StringUtil.join(history, descriptor -> descriptor.getClass().getName() + "[" + descriptor.getQualifiedName() + "]", ", "));
}
}
names.validateNames = names.elementNames.size() > noSchemaNamespaces;
// final QName any = QNameUtil.createAnyLocalName("");
// names.elementNames.add(any);
// names.attributeNames.add(any);
} catch (IncorrectOperationException e) {
Logger.getInstance(XsltContextProvider.class.getName()).error(e);
}
}
Aggregations