use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class AntDomElement method getContextAntProject.
public final AntDomProject getContextAntProject() {
final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(getManager().getProject());
final XmlElement xmlElement = getXmlElement();
if (xmlElement == null) {
return getAntProject();
}
PsiFile containingFile = xmlElement.getContainingFile();
if (containingFile != null) {
containingFile = containingFile.getOriginalFile();
}
if (!(containingFile instanceof XmlFile)) {
return getAntProject();
}
final XmlFile contextFile = antConfig.getEffectiveContextFile(((XmlFile) containingFile));
if (contextFile == null) {
return getAntProject();
}
return AntSupport.getAntDomProject(contextFile);
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class AntBuildFileImpl method getAntFile.
@Nullable
public XmlFile getAntFile() {
final PsiFile psiFile = myVFile.isValid() ? PsiManager.getInstance(getProject()).findFile(myVFile) : null;
if (!(psiFile instanceof XmlFile)) {
return null;
}
final XmlFile xmlFile = (XmlFile) psiFile;
return AntDomFileDescription.isAntFile(xmlFile) ? xmlFile : null;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class PrepareToDeployAction method collectJpsPluginModules.
@NotNull
private static Map<Module, String> collectJpsPluginModules(@NotNull Module module) {
XmlFile pluginXml = PluginModuleType.getPluginXml(module);
if (pluginXml == null)
return Collections.emptyMap();
DomFileElement<IdeaPlugin> fileElement = DomManager.getDomManager(module.getProject()).getFileElement(pluginXml, IdeaPlugin.class);
if (fileElement == null)
return Collections.emptyMap();
Map<Module, String> jpsPluginToOutputPath = new HashMap<>();
IdeaPlugin plugin = fileElement.getRootElement();
List<Extensions> extensions = plugin.getExtensions();
for (Extensions extensionGroup : extensions) {
XmlTag extensionsTag = extensionGroup.getXmlTag();
String defaultExtensionNs = extensionsTag.getAttributeValue("defaultExtensionNs");
for (XmlTag tag : extensionsTag.getSubTags()) {
String name = tag.getLocalName();
String qualifiedName = defaultExtensionNs != null ? defaultExtensionNs + "." + name : name;
if (CompileServerPlugin.EP_NAME.getName().equals(qualifiedName)) {
String classpath = tag.getAttributeValue("classpath");
if (classpath != null) {
for (String path : StringUtil.split(classpath, ";")) {
String moduleName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(path));
Module jpsModule = ModuleManager.getInstance(module.getProject()).findModuleByName(moduleName);
if (jpsModule != null) {
jpsPluginToOutputPath.put(jpsModule, path);
}
}
}
}
}
}
return jpsPluginToOutputPath;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class RegistrationCheckerUtil method checkModule.
@Nullable
private static Set<PsiClass> checkModule(Module module, PsiClass psiClass, @Nullable Set<PsiClass> types, boolean includeActions) {
final XmlFile pluginXml = PluginModuleType.getPluginXml(module);
if (pluginXml == null)
return null;
final DomFileElement<IdeaPlugin> fileElement = DescriptorUtil.getIdeaPlugin(pluginXml);
if (fileElement == null)
return null;
final String qualifiedName = psiClass.getQualifiedName();
if (qualifiedName != null) {
final RegistrationTypeFinder finder = new RegistrationTypeFinder(psiClass, types);
// "main" plugin.xml
processPluginXml(pluginXml, finder, includeActions);
// <depends> plugin.xml files
for (Dependency dependency : fileElement.getRootElement().getDependencies()) {
final GenericAttributeValue<PathReference> configFileAttribute = dependency.getConfigFile();
if (!DomUtil.hasXml(configFileAttribute))
continue;
final PathReference configFile = configFileAttribute.getValue();
if (configFile != null) {
final PsiElement resolve = configFile.resolve();
if (!(resolve instanceof XmlFile))
continue;
final XmlFile depPluginXml = (XmlFile) resolve;
if (DescriptorUtil.isPluginXml(depPluginXml)) {
processPluginXml(depPluginXml, finder, includeActions);
}
}
}
types = finder.getTypes();
}
return types;
}
use of com.intellij.psi.xml.XmlFile in project intellij-community by JetBrains.
the class AddAntBuildFile method update.
public void update(@NotNull AnActionEvent e) {
final Presentation presentation = e.getPresentation();
final Project project = e.getProject();
if (project != null) {
final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (files != null && files.length > 0) {
for (VirtualFile file : files) {
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) {
continue;
}
final XmlFile xmlFile = (XmlFile) psiFile;
final XmlDocument document = xmlFile.getDocument();
if (document == null) {
continue;
}
final XmlTag rootTag = document.getRootTag();
if (rootTag == null) {
continue;
}
if (!"project".equals(rootTag.getName())) {
continue;
}
if (AntConfigurationBase.getInstance(project).getAntBuildFile(psiFile) != null) {
continue;
}
// found at least one candidate file
enable(presentation);
return;
}
}
}
disable(presentation);
}
Aggregations