本文整理汇总了Java中com.intellij.util.xml.DomUtil类的典型用法代码示例。如果您正苦于以下问题:Java DomUtil类的具体用法?Java DomUtil怎么用?Java DomUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DomUtil类属于com.intellij.util.xml包,在下文中一共展示了DomUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DomElementsToggleAction
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
public DomElementsToggleAction(final DomModelTreeView treeView, final Class aClass) {
myTreeView = treeView;
myClass = aClass;
Icon myIcon = ElementPresentationManager.getIcon(myClass);
if (myIcon == null) {
myIcon = AllIcons.Nodes.Pointcut;
}
this.myIcon = myIcon;
myText = TypePresentationService.getService().getTypePresentableName(myClass);
if(getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()).putUserData(AbstractDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap<Class, Boolean>());
if(getHiders().get(myClass) == null) getHiders().put(myClass, true);
}
示例2: createAddingAction
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@Override
protected AnAction createAddingAction(final AnActionEvent e,
final String name,
final Icon icon,
final Type type,
final DomCollectionChildDescription description) {
final DomElement parentDomElement = getParentDomElement(e);
if (parentDomElement instanceof MergedObject) {
final List<DomElement> implementations = (List<DomElement>)((MergedObject)parentDomElement).getImplementations();
final DefaultActionGroup actionGroup = new DefaultActionGroup(name, true);
for (DomElement implementation : implementations) {
final XmlFile xmlFile = DomUtil.getFile(implementation);
actionGroup.add(new MyDefaultAddAction(implementation, xmlFile.getName(), xmlFile.getIcon(0), e, type, description));
}
return actionGroup;
}
return new MyDefaultAddAction(parentDomElement, name, icon, e, type, description);
}
示例3: actionPerformed
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
final SimpleNode selectedNode = treeView.getTree().getSelectedNode();
if (selectedNode instanceof BaseDomElementNode) {
if (selectedNode instanceof DomFileElementNode) {
e.getPresentation().setVisible(false);
return;
}
final DomElement domElement = ((BaseDomElementNode)selectedNode).getDomElement();
final int ret = Messages.showOkCancelDialog(getPresentationText(selectedNode, "Remove") + "?", "Remove",
Messages.getQuestionIcon());
if (ret == Messages.OK) {
new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {
@Override
protected void run(@NotNull final Result result) throws Throwable {
domElement.undefine();
}
}.execute();
}
}
}
示例4: getProblemHolder
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@Override
@NotNull
public DomElementsProblemsHolder getProblemHolder(DomElement element) {
if (element == null || !element.isValid()) return EMPTY_PROBLEMS_HOLDER;
final DomFileElement<DomElement> fileElement = DomUtil.getFileElement(element);
synchronized (LOCK) {
final XmlTag tag = fileElement.getRootElement().getXmlTag();
if (tag != null) {
final DomElementsProblemsHolder readyHolder = tag.getUserData(DOM_PROBLEM_HOLDER_KEY);
if (readyHolder != null) {
return readyHolder;
}
}
return EMPTY_PROBLEMS_HOLDER;
}
}
示例5: getHighlightStatus
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@NotNull
public DomHighlightStatus getHighlightStatus(final DomElement element) {
synchronized (LOCK) {
final DomFileElement<DomElement> root = DomUtil.getFileElement(element);
if (!isHolderOutdated(root.getFile())) {
final DomElementsProblemsHolder holder = getProblemHolder(element);
if (holder instanceof DomElementsProblemsHolderImpl) {
DomElementsProblemsHolderImpl holderImpl = (DomElementsProblemsHolderImpl)holder;
final List<DomElementsInspection> suitableInspections = getSuitableDomInspections(root, true);
final DomElementsInspection mockInspection = getMockInspection(root);
final boolean annotatorsFinished = mockInspection == null || holderImpl.isInspectionCompleted(mockInspection);
final boolean inspectionsFinished = areInspectionsFinished(holderImpl, suitableInspections);
if (annotatorsFinished) {
if (suitableInspections.isEmpty() || inspectionsFinished) return DomHighlightStatus.INSPECTIONS_FINISHED;
return DomHighlightStatus.ANNOTATORS_FINISHED;
}
}
}
return DomHighlightStatus.NONE;
}
}
示例6: shouldBeShown
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
protected boolean shouldBeShown(final Type type) {
final Map<Class, Boolean> hiders = DomUtil.getFile(getDomElement()).getUserData(TREE_NODES_HIDERS_KEY);
if (type == null || hiders == null || hiders.size() == 0) return true;
final Class aClass = ReflectionUtil.getRawType(type);
List<Class> allParents = new ArrayList<Class>();
for (Map.Entry<Class, Boolean> entry : hiders.entrySet()) {
if (entry.getKey().isAssignableFrom(aClass)) {
allParents.add(entry.getKey());
}
}
if (allParents.size() == 0) return false;
Collections.sort(allParents, INHERITORS_COMPARATOR);
return hiders.get(allParents.get(0)).booleanValue();
}
示例7: process
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@Nullable
public T process(@NotNull MavenDomProjectModel projectDom) {
MavenDomParent parent = projectDom.getMavenParent();
MavenParentDesc parentDesc = null;
if (DomUtil.hasXml(parent)) {
String parentGroupId = parent.getGroupId().getStringValue();
String parentArtifactId = parent.getArtifactId().getStringValue();
String parentVersion = parent.getVersion().getStringValue();
String parentRelativePath = parent.getRelativePath().getStringValue();
if (StringUtil.isEmptyOrSpaces(parentRelativePath)) parentRelativePath = "../pom.xml";
MavenId parentId = new MavenId(parentGroupId, parentArtifactId, parentVersion);
parentDesc = new MavenParentDesc(parentId, parentRelativePath);
}
return process(myManager.getGeneralSettings(), MavenDomUtil.getVirtualFile(projectDom), parentDesc);
}
示例8: changeLanguageLevel
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@Override
public Promise<Void> changeLanguageLevel(@NotNull Module module, @NotNull final LanguageLevel level) {
if (!myProjectsManager.isMavenizedModule(module)) return null;
MavenProject mavenProject = myProjectsManager.findProject(module);
if (mavenProject == null) return null;
final MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(myProject, mavenProject.getFile());
if (model == null) return null;
new WriteCommandAction(myProject, "Add Maven Dependency", DomUtil.getFile(model)) {
@Override
protected void run(@NotNull Result result) throws Throwable {
MavenDomConfiguration configuration = getCompilerPlugin(model).getConfiguration();
XmlTag tag = configuration.ensureTagExists();
setChildTagValue(tag, "source", level.getCompilerComplianceDefaultOption());
setChildTagValue(tag, "target", level.getCompilerComplianceDefaultOption());
Document document = PsiDocumentManager.getInstance(myProject).getDocument(DomUtil.getFile(model));
if (document != null) {
FileDocumentManager.getInstance().saveDocument(document);
}
}
}.execute();
return myProjectsManager.forceUpdateProjects(Collections.singleton(mavenProject));
}
示例9: resolve
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
public PsiElement resolve(@NotNull PsiReference psiReference, boolean incompleteCode) {
final PsiElement element = psiReference.getElement();
if (element == null) {
return null;
}
final DomElement domElement = DomUtil.getDomElement(element);
if (domElement == null) {
return null;
}
final AntDomMacroDef macrodef = domElement.getParentOfType(AntDomMacroDef.class, false);
if (macrodef == null) {
return null;
}
final String name = AntStringResolver.computeString(domElement, psiReference.getCanonicalText());
for (AntDomMacrodefAttribute attribute : macrodef.getMacroAttributes()) {
if (name.equals(attribute.getName().getStringValue())) {
final DomTarget target = DomTarget.getTarget(attribute);
return target != null? PomService.convertToPsi(target) : null;
}
}
return null;
}
示例10: createLookupElement
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@Nullable
@Override
public LookupElement createLookupElement(ActionOrGroup actionOrGroup) {
if (actionOrGroup instanceof Action) {
Action action = (Action)actionOrGroup;
final PsiElement element = getPsiElement(actionOrGroup);
if (element == null) {
throw new IllegalStateException(action.getId().getStringValue() + " in " + DomUtil.getFile(action) + " " + action.isValid() + " ");
}
LookupElementBuilder builder =
LookupElementBuilder.create(ObjectUtils.assertNotNull(element),
ObjectUtils.assertNotNull(getName(action)));
final String text = action.getText().getStringValue();
if (StringUtil.isNotEmpty(text)) {
String withoutMnemonic = StringUtil.replace(text, "_", "");
builder = builder.withTailText(" \"" + withoutMnemonic + "\"", true);
}
return builder;
}
return super.createLookupElement(actionOrGroup);
}
示例11: checkIncludes
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
private boolean checkIncludes(PsiFile layoutFile, PsiElement idElement) {
AndroidFacet facet = AndroidFacet.getInstance(idElement);
PsiFile containingFile = idElement.getContainingFile();
DomFileElement<AndroidDomElement> fileElement = DomManager.getDomManager(layoutFile.getProject()).getFileElement((XmlFile) layoutFile, AndroidDomElement.class);
boolean found = false;
if (fileElement != null) {
AndroidDomElement rootElement = fileElement.getRootElement();
List<Include> includes = DomUtil.getChildrenOfType(rootElement, Include.class);
for (Include include : includes) {
ResourceValue value = include.getLayout().getValue();
if (value != null) {
if (facet != null) {
if (value.getResourceType() != null && value.getResourceName() != null) {
List<PsiFile> resourceFiles = facet.getLocalResourceManager().findResourceFiles(value.getResourceType(), value.getResourceName());
if (!resourceFiles.isEmpty()) {
found = isInAllIncludes(idElement, found, resourceFiles);
}
}
}
}
}
}
return found;
}
示例12: DomElementsToggleAction
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
public DomElementsToggleAction(final DomModelTreeView treeView, final Class aClass) {
myTreeView = treeView;
myClass = aClass;
Icon myIcon = ElementPresentationManager.getIcon(myClass);
if (myIcon == null) {
myIcon = AllIcons.Nodes.Pointcut;
}
this.myIcon = myIcon;
myText = TypePresentationService.getService().getTypePresentableName(myClass);
if(getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()).putUserData(BaseDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap<Class, Boolean>());
if(getHiders().get(myClass) == null) getHiders().put(myClass, true);
}
示例13: createAddingAction
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
protected AnAction createAddingAction(final AnActionEvent e,
final String name,
final Icon icon,
final Type type,
final DomCollectionChildDescription description) {
final DomElement parentDomElement = getParentDomElement(e);
if (parentDomElement instanceof MergedObject) {
final List<DomElement> implementations = (List<DomElement>)((MergedObject)parentDomElement).getImplementations();
final DefaultActionGroup actionGroup = new DefaultActionGroup(name, true);
for (DomElement implementation : implementations) {
final XmlFile xmlFile = DomUtil.getFile(implementation);
actionGroup.add(new MyDefaultAddAction(implementation, xmlFile.getName(), xmlFile.getIcon(0), e, type, description));
}
return actionGroup;
}
return new MyDefaultAddAction(parentDomElement, name, icon, e, type, description);
}
示例14: actionPerformed
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
final SimpleNode selectedNode = treeView.getTree().getSelectedNode();
if (selectedNode instanceof BaseDomElementNode) {
if (selectedNode instanceof DomFileElementNode) {
e.getPresentation().setVisible(false);
return;
}
final DomElement domElement = ((BaseDomElementNode)selectedNode).getDomElement();
final int ret = Messages.showOkCancelDialog(getPresentationText(selectedNode) + "?", ApplicationBundle.message("action.remove"),
Messages.getQuestionIcon());
if (ret == 0) {
new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {
protected void run(final Result result) throws Throwable {
domElement.undefine();
}
}.execute();
}
}
}
示例15: getProblemsMap
import com.intellij.util.xml.DomUtil; //导入依赖的package包/类
@NotNull
private Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> getProblemsMap(final DomElement domElement) {
final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> map = myCachedChildrenErrors.get(domElement);
if (map != null) {
return map;
}
final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> problems = new THashMap<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>>();
if (domElement == myElement) {
for (Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> listMap : myCachedErrors.values()) {
mergeMaps(problems, listMap);
}
} else {
mergeMaps(problems, myCachedErrors.get(domElement));
if (DomUtil.hasXml(domElement)) {
domElement.acceptChildren(new DomElementVisitor() {
public void visitDomElement(DomElement element) {
mergeMaps(problems, getProblemsMap(element));
}
});
}
}
myCachedChildrenErrors.put(domElement, problems);
return problems;
}