use of org.jetbrains.idea.devkit.dom.Extensions 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 org.jetbrains.idea.devkit.dom.Extensions in project intellij-community by JetBrains.
the class PluginDescriptorChooser method findOrCreateExtensionsForEP.
@NotNull
public static Extensions findOrCreateExtensionsForEP(DomFileElement<IdeaPlugin> domFileElement, String epName) {
final IdeaPlugin ideaPlugin = domFileElement.getRootElement();
final List<Extensions> extensionsList = ideaPlugin.getExtensions();
for (Extensions extensions : extensionsList) {
if (extensions.getXmlTag() instanceof IncludedXmlTag) {
continue;
}
String s = extensions.getDefaultExtensionNs().getStringValue();
if (s != null && epName.startsWith(s)) {
return extensions;
}
}
Extensions extensions = ideaPlugin.addExtensions();
final String epPrefix = StringUtil.getPackageName(epName);
extensions.getDefaultExtensionNs().setStringValue(epPrefix);
return extensions;
}
use of org.jetbrains.idea.devkit.dom.Extensions in project intellij-community by JetBrains.
the class RegisterExtensionFix method registerExtension.
private void registerExtension(final DomFileElement<IdeaPlugin> selectedValue, final ExtensionPointCandidate candidate) {
PsiElement navTarget = new WriteCommandAction<PsiElement>(selectedValue.getFile().getProject(), selectedValue.getFile()) {
@Override
protected void run(@NotNull Result<PsiElement> result) throws Throwable {
Extensions extensions = PluginDescriptorChooser.findOrCreateExtensionsForEP(selectedValue, candidate.epName);
Extension extension = extensions.addExtension(candidate.epName);
XmlTag tag = extension.getXmlTag();
PsiElement navTarget = null;
String keyAttrName = KEY_MAP.get(candidate.beanClassName);
if (keyAttrName != null) {
XmlAttribute attr = tag.setAttribute(keyAttrName, "");
navTarget = attr.getValueElement();
}
if (candidate.attributeName != null) {
tag.setAttribute(candidate.attributeName, myExtensionClass.getQualifiedName());
} else {
XmlTag subTag = tag.createChildTag(candidate.tagName, null, myExtensionClass.getQualifiedName(), false);
tag.addSubTag(subTag, false);
}
result.setResult(navTarget != null ? navTarget : extension.getXmlTag());
}
}.execute().throwException().getResultObject();
PsiNavigateUtil.navigate(navTarget);
}
use of org.jetbrains.idea.devkit.dom.Extensions in project intellij-community by JetBrains.
the class RegisterInspectionFix method doFix.
private void doFix(final DomFileElement<IdeaPlugin> selectedValue, final Project project, final PsiFile file) {
Extension extension = new WriteCommandAction<Extension>(project, file) {
@Override
protected void run(@NotNull Result<Extension> result) throws Throwable {
final Extensions extensions = PluginDescriptorChooser.findOrCreateExtensionsForEP(selectedValue, myEp.getName());
Extension extension = extensions.addExtension(myEp.getName());
XmlTag tag = extension.getXmlTag();
tag.setAttribute("implementationClass", myPsiClass.getQualifiedName());
result.setResult(extension);
}
}.execute().throwException().getResultObject();
PsiNavigateUtil.navigate(extension.getXmlTag());
}
Aggregations