Don't add maven references to <outputFileNameMapping> parameter

This commit is contained in:
Sergey Evdokimov
2013-06-25 20:53:05 +04:00
parent bd2c0b8841
commit be31f9f578
4 changed files with 38 additions and 16 deletions
@@ -23,15 +23,14 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.PairProcessor;
import com.intellij.util.ProcessingContext;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.DomManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.MavenPluginDomUtil;
import org.jetbrains.idea.maven.dom.MavenPropertyResolver;
import org.jetbrains.idea.maven.dom.model.MavenDomConfiguration;
import org.jetbrains.idea.maven.plugins.api.MavenPluginParamInfo;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
@@ -50,20 +49,25 @@ public class MavenPropertyPsiReferenceProvider extends PsiReferenceProvider {
private static boolean isElementCanContainReference(PsiElement element) {
if (element instanceof XmlTag) {
if ("delimiter".equals(((XmlTag)element).getName())) {
XmlTag delimitersTag = ((XmlTag)element).getParentTag();
if (delimitersTag != null && "delimiters".equals(delimitersTag.getName())) {
XmlTag configurationTag = delimitersTag.getParentTag();
if (configurationTag != null && "configuration".equals(configurationTag.getName())) {
DomElement configurationDom = DomManager.getDomManager(configurationTag.getProject()).getDomElement(configurationTag);
if (configurationDom != null && configurationDom instanceof MavenDomConfiguration) {
if (MavenPluginDomUtil.isPlugin((MavenDomConfiguration)configurationDom, "org.apache.maven.plugins", "maven-resources-plugin")) {
return false;
}
}
class MyProcessor implements PairProcessor<MavenPluginParamInfo.ParamInfo, MavenDomConfiguration> {
boolean disableReferences = false;
@Override
public boolean process(MavenPluginParamInfo.ParamInfo info, MavenDomConfiguration configuration) {
if (Boolean.TRUE.equals(info.getParam().disableReferences)) {
disableReferences = true;
return false;
}
return true;
}
}
MyProcessor p = new MyProcessor();
MavenPluginParamInfo.processParamInfo((XmlTag)element, p);
return !p.disableReferences;
}
return true;
@@ -72,6 +72,12 @@ public class MavenPluginDescriptor extends AbstractExtensionPointBean {
@Attribute("soft")
public Boolean soft;
/**
* Disallow to add standard maven references to parameter like <delimiter>$$</delimiter>, see MavenPropertyPsiReferenceProvider
*/
@Attribute("disableReferences")
public Boolean disableReferences;
/**
* Language to inject.
*/
@@ -99,9 +99,13 @@ public class MavenPluginParamInfo {
}
public static void processParamInfo(@NotNull XmlText paramValue, @NotNull PairProcessor<ParamInfo, MavenDomConfiguration> processor) {
XmlTag paramTag = paramValue.getParentTag();
if (paramTag == null) return;
XmlTag tag = paramValue.getParentTag();
if (tag != null) {
processParamInfo(tag, processor);
}
}
public static void processParamInfo(@NotNull XmlTag paramTag, @NotNull PairProcessor<ParamInfo, MavenDomConfiguration> processor) {
XmlTag configurationTag = paramTag;
DomElement domElement;
@@ -216,6 +220,10 @@ public class MavenPluginParamInfo {
return myLanguageProvider;
}
public MavenPluginDescriptor.Param getParam() {
return myParam;
}
public String getLanguageInjectionPrefix() {
return myParam.languageInjectionPrefix;
}
@@ -184,6 +184,8 @@
<param name="outputDirectory" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$DirPath"/>
<param name="filters/filter" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$FilePath"/>
<param name="resourceEncoding" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$Encoding"/>
<param name="outputFileNameMapping" disableReferences="true"/>
</pluginDescriptor>
<pluginDescriptor mavenId="org.apache.maven.plugins:maven-acr-plugin">
@@ -243,6 +245,8 @@
<pluginDescriptor mavenId="org.apache.maven.plugins:maven-resources-plugin">
<param name="encoding" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$Encoding"/>
<param name="delimiters/delimiter" disableReferences="true"/>
</pluginDescriptor>
</extensions>