本文整理汇总了Java中com.intellij.util.xml.DomManager类的典型用法代码示例。如果您正苦于以下问题:Java DomManager类的具体用法?Java DomManager怎么用?Java DomManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DomManager类属于com.intellij.util.xml包,在下文中一共展示了DomManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expectDomAttributeValue
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
public static <T extends DomElement, V> GenericAttributeValue<V> expectDomAttributeValue(
@NotNull final PsiElement element,
@NotNull final Class<? extends T> domTagClass,
@NotNull final Function<T, GenericAttributeValue<V>> domGetter
) {
final DomManager domManager = DomManager.getDomManager(element.getProject());
if (!(element instanceof XmlElement)) {
return null;
}
final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(element, XmlAttribute.class, false);
if (xmlAttribute == null) {
return null;
}
final XmlTag xmlParentTag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
DomElement domParentTag = domManager.getDomElement(xmlParentTag);
return Optional.ofNullable(domParentTag)
.map(o -> ObjectUtils.tryCast(o, domTagClass))
.map(domGetter)
.filter(val -> val == domManager.getDomElement(xmlAttribute))
.orElse(null);
}
示例2: getRoot
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Override
@NotNull
public StructureViewTreeElement getRoot() {
XmlFile myFile = getPsiFile();
final DomFileElement<DomElement> fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(
myFile,
DomElement.class
);
return fileElement == null ?
new XmlFileTreeElement(myFile) :
new TSStructureTreeElement(
fileElement.getRootElement().createStableCopy(),
myDescriptor,
myNavigationProvider
);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:TSStructureViewTreeModel.java
示例3: getFlowsInScope
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@NotNull
private static List<DomElement> getFlowsInScope(Project project, GlobalSearchScope searchScope) {
final List<DomElement> result = new ArrayList<>();
final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
final DomManager manager = DomManager.getDomManager(project);
for (VirtualFile file : files) {
final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
if (isMuleFile(xmlFile)) {
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
result.addAll(rootElement.getFlows());
result.addAll(rootElement.getSubFlows());
}
}
}
return result;
}
示例4: findGlobalElementInFile
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Nullable
private static XmlTag findGlobalElementInFile(Project project, String elementName, VirtualFile file) {
final DomManager manager = DomManager.getDomManager(project);
final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
if (isMuleFile(xmlFile)) {
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
final XmlTag[] subTags = rootElement.getXmlTag().getSubTags();
for (XmlTag subTag : subTags) {
if (isGlobalElement(subTag)) {
if (elementName.equals(subTag.getAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE))) {
return subTag;
}
}
}
}
}
return null;
}
示例5: findFlowInFile
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Nullable
private static XmlTag findFlowInFile(Project project, String flowName, VirtualFile file) {
final DomManager manager = DomManager.getDomManager(project);
final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
if (isMuleFile(xmlFile)) {
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
final List<Flow> flows = rootElement.getFlows();
for (Flow flow : flows) {
if (flowName.equals(flow.getName().getValue())) {
return flow.getXmlTag();
}
}
final List<SubFlow> subFlows = rootElement.getSubFlows();
for (SubFlow subFlow : subFlows) {
if (flowName.equals(subFlow.getName().getValue())) {
return subFlow.getXmlTag();
}
}
}
}
return null;
}
示例6: getGlobalElementsInScope
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@NotNull
private static List<XmlTag> getGlobalElementsInScope(Project project, GlobalSearchScope searchScope) {
final List<XmlTag> result = new ArrayList<>();
final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
final DomManager manager = DomManager.getDomManager(project);
for (VirtualFile file : files) {
final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
if (isMuleFile(xmlFile)) {
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
final XmlTag[] subTags = rootElement.getXmlTag().getSubTags();
for (XmlTag subTag : subTags) {
if (isGlobalElement(subTag)) {
result.add(subTag);
}
}
}
}
}
return result;
}
示例7: buildChildren
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Override
protected SimpleNode[] buildChildren() {
List<SimpleNode> myConfigNodes = new ArrayList<>();
final DomManager manager = DomManager.getDomManager(myProject);
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) myXmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
XmlTag[] subTags = rootElement.getXmlTag().getSubTags();
for (XmlTag nextTag : subTags) {
MuleElementType muleElementType = MuleConfigUtils.getMuleElementTypeFromXmlElement(nextTag);
if (muleElementType != null && //This is a global config
(MuleElementType.CONFIG.equals(muleElementType) || (MuleElementType.TRANSPORT_CONNECTOR.equals(muleElementType)))) {
GlobalConfigNode nextConfigNode = new GlobalConfigNode(this, nextTag);
myConfigNodes.add(nextConfigNode);
}
}
}
return myConfigNodes.toArray(new SimpleNode[]{});
}
示例8: getGlobalDefinitions
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
private List<String> getGlobalDefinitions(VirtualFile file) {
List<String> globalDefs = new ArrayList<>();
final DomManager manager = DomManager.getDomManager(project);
final XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(file);
final XmlDocument document = xmlFile.getDocument();
final XmlTag rootTag = document.getRootTag();
try {
final XmlTag globalFunctions = rootTag.findFirstSubTag("configuration")
.findFirstSubTag("expression-language")
.findFirstSubTag("global-functions");
String nextFunction = globalFunctions.getValue().getText();
if (nextFunction != null && StringUtils.isNotEmpty(nextFunction)) {
globalDefs.add(nextFunction);
}
} catch (Exception e) {//If the global functions config does not exist, we get NPE - but it's expected :)
//Do nothing for now
}
return globalDefs;
}
示例9: createStructureView
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Override
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, @NotNull final Project project) {
return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project, true) {
@Override
public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) {
if (element instanceof XmlElement && ((XmlElement)element).isValid()) {
final XmlElement xmlElement = (XmlElement)element;
XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false);
while (tag != null) {
final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag);
if (domElement != null) {
for (DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) {
if (myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) {
return super.expandPathToElement(curElement.getXmlElement());
}
}
}
tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true);
}
}
return super.expandPathToElement(element);
}
};
}
示例10: contributeMetaData
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Override
public void contributeMetaData(MetaDataRegistrar registrar) {
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);
if (domElement != null) {
return domElement.getGenericInfo().getNameDomElement(domElement) != null;
}
}
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return XmlTag.class.isAssignableFrom(hintClass);
}
}, DomMetaData.class);
}
示例11: createMockElement
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
private <T extends DomElement> T createMockElement(final Class<T> aClass, final Module module) {
final Project project = module.getProject();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myFileEditor.isInitialised()) {
myContents.reset();
}
}
});
final DomManager domManager = DomManager.getDomManager(project);
final T mockElement = domManager.createMockElement(aClass, module, true);
if (myFileEditor != null) {
myFileEditor.addWatchedElement(mockElement);
}
return mockElement;
}
示例12: addAndroidPrefixElement
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
private static void addAndroidPrefixElement(PsiElement position, PsiElement parent, CompletionResultSet resultSet) {
if (position.getText().startsWith("android:")) {
return;
}
final PsiElement gp = parent.getParent();
if (!(gp instanceof XmlTag)) {
return;
}
final DomElement element = DomManager.getDomManager(gp.getProject()).getDomElement((XmlTag)gp);
if (!(element instanceof LayoutElement) &&
!(element instanceof PreferenceElement)) {
return;
}
final String prefix = ((XmlTag)gp).getPrefixByNamespace(SdkConstants.NS_RESOURCES);
if (prefix == null || prefix.length() < 3) {
return;
}
final LookupElementBuilder e = LookupElementBuilder.create(prefix + ":").withTypeText("[Namespace Prefix]", true);
resultSet.addElement(PrioritizedLookupElement.withPriority(e, Double.MAX_VALUE));
}
示例13: isAttributeValueContext
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
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;
}
final DomElement domElement = DomManager.getDomManager(
element.getProject()).getDomElement((XmlTag)parent);
if (domElement instanceof AndroidDomElement) {
return inEnglish(element);
}
return false;
}
示例14: getContextSpecificSettings
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Nullable
private static ContextSpecificSettingsProviders.Provider getContextSpecificSettings(PsiElement context) {
final PsiFile file = context.getContainingFile();
if (!(file instanceof XmlFile) ||
AndroidFacet.getInstance(file) == null) {
return null;
}
final DomFileDescription<?> description = DomManager.getDomManager(
context.getProject()).getDomFileDescription((XmlFile)file);
if (description instanceof LayoutDomFileDescription) {
return ContextSpecificSettingsProviders.LAYOUT;
}
else if (description instanceof ManifestDomFileDescription) {
return ContextSpecificSettingsProviders.MANIFEST;
}
else if (description instanceof ResourcesDomFileDescription ||
description instanceof DrawableStateListDomFileDescription ||
description instanceof ColorDomFileDescription) {
return ContextSpecificSettingsProviders.VALUE_RESOURCE_FILE;
}
else if (description instanceof AndroidResourceDomFileDescription) {
return ContextSpecificSettingsProviders.OTHER;
}
return null;
}
示例15: checkFile
import com.intellij.util.xml.DomManager; //导入依赖的package包/类
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof XmlFile)) {
return ProblemDescriptor.EMPTY_ARRAY;
}
final AndroidFacet facet = AndroidFacet.getInstance(file);
if (facet == null) {
return ProblemDescriptor.EMPTY_ARRAY;
}
final DomFileDescription<?> description = DomManager.getDomManager(file.getProject()).getDomFileDescription((XmlFile)file);
if (!(description instanceof LayoutDomFileDescription) &&
!(description instanceof MenuDomFileDescription)) {
return ProblemDescriptor.EMPTY_ARRAY;
}
final Collection<PsiClass> activities = findRelatedActivities((XmlFile)file, facet, description);
final MyVisitor visitor = new MyVisitor(manager, isOnTheFly, activities);
file.accept(visitor);
return visitor.myResult.toArray(new ProblemDescriptor[visitor.myResult.size()]);
}