use of com.intellij.util.xml.DomManager in project intellij-community by JetBrains.
the class MockDomElementsEditor method addEditedElement.
protected final <T extends DomElement> T addEditedElement(final Class<T> aClass, final EditedElementDescription<T> description) {
final DomManager domManager = DomManager.getDomManager(myModule.getProject());
final T t = domManager.createStableValue(() -> {
T t1 = description.find();
if (t1 == null) {
return createMockElement(aClass);
}
return t1;
});
myDomElements.put(description, t);
return t;
}
use of com.intellij.util.xml.DomManager in project android by JetBrains.
the class AndroidUtils method loadDomElementWithReadPermission.
/** This method should be called under a read action. */
@Nullable
public static <T extends DomElement> T loadDomElementWithReadPermission(@NotNull Project project, @NotNull XmlFile xmlFile, @NotNull Class<T> aClass) {
getApplication().assertReadAccessAllowed();
DomManager domManager = DomManager.getDomManager(project);
DomFileElement<T> element = domManager.getFileElement(xmlFile, aClass);
if (element == null)
return null;
return element.getRootElement();
}
use of com.intellij.util.xml.DomManager 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.DomManager in project android by JetBrains.
the class AndroidExtractAsIncludeAction method isEnabledForPsiRange.
@Override
protected boolean isEnabledForPsiRange(@NotNull PsiElement from, @Nullable PsiElement to) {
final DomManager domManager = DomManager.getDomManager(from.getProject());
PsiElement e = from;
boolean containsViewElement = false;
while (e != null) {
if (e instanceof XmlTag) {
final DomElement domElement = domManager.getDomElement((XmlTag) e);
if (!isSuitableDomElement(domElement)) {
return false;
}
if (domElement instanceof LayoutViewElement) {
containsViewElement = true;
}
}
if (e == to) {
break;
}
e = e.getNextSibling();
}
return containsViewElement;
}
use of com.intellij.util.xml.DomManager in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineStandardFacet method getAppEngineStandardWebXml.
@Nullable
public AppEngineStandardWebApp getAppEngineStandardWebXml() {
XmlFile appengineWebXmlFile = AppEngineAssetProvider.getInstance().loadAppEngineStandardWebXml(getModule().getProject(), ImmutableList.of(getModule()));
final DomManager domManager = DomManager.getDomManager(getModule().getProject());
DomFileElement<AppEngineStandardWebApp> appEngineWebXmlDom = domManager.getFileElement(appengineWebXmlFile, AppEngineStandardWebApp.class);
if (appEngineWebXmlDom == null) {
return null;
}
return appEngineWebXmlDom.getRootElement();
}
Aggregations