use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class ExtensionPointLocator method isRegisteredExtension.
public static boolean isRegisteredExtension(@NotNull PsiClass psiClass) {
String name = psiClass.getQualifiedName();
if (name == null)
return false;
Project project = psiClass.getProject();
GlobalSearchScope scope = getCandidatesScope(project);
return !PsiSearchHelper.SERVICE.getInstance(project).processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
@Override
public boolean process(PsiFile file, int startOffset, int endOffset) {
PsiElement at = file.findElementAt(startOffset);
String tokenText = at instanceof XmlToken ? at.getText() : null;
if (!StringUtil.equals(name, tokenText))
return true;
XmlTag tag = PsiTreeUtil.getParentOfType(at, XmlTag.class);
if (tag == null)
return true;
DomElement dom = DomUtil.getDomElement(tag);
return !(dom instanceof Extension && ((Extension) dom).getExtensionPoint() != null);
}
}, scope);
}
use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.
the class AppEngineFacet method getRootElement.
//todo[nik] copied from JamCommonUtil
@Nullable
private static <T> T getRootElement(final PsiFile file, final Class<T> domClass, final Module module) {
if (!(file instanceof XmlFile))
return null;
final DomManager domManager = DomManager.getDomManager(file.getProject());
final DomFileElement<DomElement> element = domManager.getFileElement((XmlFile) file, DomElement.class);
if (element == null)
return null;
final DomElement root = element.getRootElement();
if (!ReflectionUtil.isAssignable(domClass, root.getClass()))
return null;
return (T) root;
}
use of com.intellij.util.xml.DomElement in project android by JetBrains.
the class AndroidXmlTagDescriptor method getElementsDescriptors.
@Override
public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) {
final XmlElementDescriptor[] descriptors = myParentDescriptor.getElementsDescriptors(context);
if (myBaseClassName == null || context == null) {
return descriptors;
}
final AndroidFacet facet = AndroidFacet.getInstance(context);
if (facet == null) {
return descriptors;
}
final XmlElementDescriptor[] androidDescriptors = new XmlElementDescriptor[descriptors.length];
final DomElement domElement = DomManager.getDomManager(context.getProject()).getDomElement(context);
final PsiClass baseClass = JavaPsiFacade.getInstance(context.getProject()).findClass(myBaseClassName, facet.getModule().getModuleWithLibrariesScope());
for (int i = 0; i < descriptors.length; i++) {
final XmlElementDescriptor descriptor = descriptors[i];
final String tagName = descriptor.getName();
final PsiClass aClass = tagName != null && baseClass != null ? LayoutViewClassUtils.findClassByTagName(facet, tagName, baseClass) : null;
final Icon icon = AndroidDomElementDescriptorProvider.getIconForTag(tagName, domElement);
androidDescriptors[i] = new AndroidXmlTagDescriptor(aClass, descriptor, myBaseClassName, icon);
}
return androidDescriptors;
}
use of com.intellij.util.xml.DomElement in project android by JetBrains.
the class AndroidXmlSpellcheckingStrategy method isAttributeValueContext.
private static boolean isAttributeValueContext(@NotNull PsiElement element) {
if (!(element instanceof XmlAttributeValue)) {
return false;
}
PsiElement parent = element.getParent();
parent = parent != null ? parent.getParent() : null;
if (!(parent instanceof XmlTag)) {
return false;
}
DomElement domElement = DomManager.getDomManager(element.getProject()).getDomElement((XmlTag) parent);
if (domElement instanceof AndroidDomElement) {
return inEnglish(element);
}
return false;
}
use of com.intellij.util.xml.DomElement in project android by JetBrains.
the class AndroidFindUsagesHandlerFactory method correctResourceElement.
@Nullable
private static PsiElement correctResourceElement(PsiElement element) {
if (element instanceof XmlElement && !(element instanceof XmlFile)) {
XmlTag tag = element instanceof XmlTag ? (XmlTag) element : PsiTreeUtil.getParentOfType(element, XmlTag.class);
DomElement domElement = DomManager.getDomManager(element.getProject()).getDomElement(tag);
if (domElement instanceof ResourceElement) {
return tag;
}
return null;
}
return element;
}
Aggregations