com.intellij.util.xml.DomElement Java Examples
The following examples show how to use
com.intellij.util.xml.DomElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FolivoraAttrProcessing.java From Folivora with Apache License 2.0 | 6 votes |
private static void registerAttributes(/*NotNull*/ AndroidFacet facet, /*NotNull*/ DomElement element, /*NotNull*/ String styleableName, /*NotNull*/ AttributeProcessingUtil.AttributeProcessor callback) { ResourceManager manager = AndroidFacetCompat.getAppResourceManager(facet); if (manager == null) { return; } AttributeDefinitions attrDefs = manager.getAttributeDefinitions(); if (attrDefs == null) { return; } String namespace = getNamespaceUriByResourcePackage(facet, null); StyleableDefinition styleable = attrDefs.getStyleableByName(styleableName); if (styleable != null) { registerStyleableAttributes(element, styleable, namespace, callback); } // It's a good idea to add a warning when styleable not found, to make sure that code doesn't // try to use attributes that don't exist. However, current AndroidDomExtender code relies on // a lot of "heuristics" that fail quite a lot (like adding a bunch of suffixes to short // class names) // TODO: add a warning when rest of the code of AndroidDomExtender is cleaned up }
Example #2
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@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; }
Example #3
Source File: FolivoraAttrProcessing.java From Folivora with Apache License 2.0 | 5 votes |
private static void registerStyleableAttributes( /*NotNull*/ DomElement element, /*NotNull*/ StyleableDefinition styleable, /*Nullable*/ String namespaceUri, /*NotNull*/ AttributeProcessingUtil.AttributeProcessor callback) { for (AttributeDefinition attrDef : styleable.getAttributes()) { registerAttribute(attrDef, styleable.getName(), namespaceUri, element, callback); } }
Example #4
Source File: FolivoraAttrProcessing.java From Folivora with Apache License 2.0 | 5 votes |
private static void registerAttribute( AttributeDefinition attrDef, String parentStyleableName, String namespaceKey, DomElement element, AttributeProcessingUtil.AttributeProcessor callback) { String name = attrDef.getName(); if (!SdkConstants.ANDROID_URI.equals(namespaceKey) && name.startsWith(SdkConstants.ANDROID_NS_NAME_PREFIX)) { name = name.substring(SdkConstants.ANDROID_NS_NAME_PREFIX.length()); namespaceKey = SdkConstants.ANDROID_URI; } XmlName xmlName = new XmlName(name, namespaceKey); DomExtension extension = callback.processAttribute(xmlName, attrDef, parentStyleableName); if (extension != null) { Converter converter = AndroidDomUtil.getSpecificConverter(xmlName, element); if ("drawableName".equals(name)) { converter = DRAWABLE_CLASS_CONVERTER; } if ("drawableId".equals(name)) { converter = DRAWABLE_ID_CONVERTER; } if (converter == null) { if (SdkConstants.TOOLS_URI.equals(namespaceKey)) { converter = ToolsAttributeUtil.getConverter(attrDef); } else { converter = AndroidDomUtil.getConverter(attrDef); } } if (converter != null) { extension.setConverter(converter, mustBeSoft(converter, attrDef.getFormats())); } } }
Example #5
Source File: FlowGoToSymbol.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override protected void addNames(@NotNull Module module, Set<String> set) { set.addAll(ContainerUtil.mapNotNull(MuleConfigUtils.getFlows(module), new Function<DomElement, String>() { @Override public String fun(DomElement domElement) { return domElement.getXmlTag().getAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE); } })); }
Example #6
Source File: DefaultActivityLocatorCompat.java From intellij with Apache License 2.0 | 5 votes |
@Nullable public static String getQualifiedName(@NotNull ActivityAlias alias) { ApplicationManager.getApplication().assertReadAccessAllowed(); String name = alias.getName().getStringValue(); if (name == null) { return null; } int dotIndex = name.indexOf('.'); if (dotIndex > 0) { // fully qualified return name; } // attempt to retrieve the package name from the manifest in which this alias was defined String pkg = null; DomElement parent = alias.getParent(); if (parent instanceof Application) { parent = parent.getParent(); if (parent instanceof Manifest) { Manifest manifest = (Manifest) parent; pkg = manifest.getPackage().getStringValue(); } } // if we have a package name, prepend that to the activity alias return pkg == null ? name : pkg + (dotIndex == -1 ? "." : "") + name; }
Example #7
Source File: SlingModuleFacet.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
@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; }
Example #8
Source File: FlowRefPsiReference.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
@NotNull @Override public Object[] getVariants() { final List<DomElement> flow = MuleConfigUtils.getFlows(getElement().getProject()); return mapNotNull(flow, (Function<DomElement, Object>) domElement -> domElement.getXmlTag().getAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE)).toArray(); }
Example #9
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
public static List<DomElement> getFlows(Module module) { final GlobalSearchScope searchScope = GlobalSearchScope.moduleWithDependenciesScope(module); return getFlowsInScope(module.getProject(), searchScope); }
Example #10
Source File: MuleConfigUtils.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
public static List<DomElement> getFlows(Project project) { final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project); return getFlowsInScope(project, searchScope); }