From bb88c6135e9c670cc269e4e6ec44c729c326a923 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 24 Jul 2013 13:54:18 +0400 Subject: [PATCH] shorten paths in additional command line args for javac (IDEA-97712) --- .../javac/JavacConfigurationMacroFilter.java | 38 +++++++++++++++++++ .../components/impl/BasePathMacroManager.java | 6 ++- resources/src/idea/RichPlatformPlugin.xml | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacConfigurationMacroFilter.java diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacConfigurationMacroFilter.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacConfigurationMacroFilter.java new file mode 100644 index 000000000000..5ca3b9c75ea2 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacConfigurationMacroFilter.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.compiler.impl.javaCompiler.javac; + +import com.intellij.openapi.application.PathMacroFilter; +import org.jdom.Attribute; +import org.jdom.Element; + +/** + * @author nik + */ +public class JavacConfigurationMacroFilter extends PathMacroFilter { + @Override + public boolean recursePathMacros(Attribute attribute) { + if (attribute.getName().equals("value")) { + Element parent = attribute.getParent(); + if (parent != null && "option".equals(parent.getName()) && "ADDITIONAL_OPTIONS_STRING".equals(parent.getAttributeValue("name"))) { + Element grandParent = parent.getParentElement(); + return grandParent != null && grandParent.getName().equals("component") + && grandParent.getAttributeValue("name").equals("JavacSettings"); + } + } + return false; + } +} diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java index 48cf3fc571b3..d90f2d53b9a2 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java @@ -15,12 +15,15 @@ */ package com.intellij.openapi.components.impl; +import com.intellij.application.options.PathMacrosCollector; import com.intellij.application.options.PathMacrosImpl; import com.intellij.application.options.ReplacePathToMacroMap; import com.intellij.openapi.application.PathMacros; +import com.intellij.openapi.components.CompositePathMacroFilter; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.components.TrackingPathMacroSubstitutor; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -37,6 +40,7 @@ import org.jetbrains.jps.model.serialization.PathMacroUtil; import java.util.*; public class BasePathMacroManager extends PathMacroManager { + private static CompositePathMacroFilter ourFilter = new CompositePathMacroFilter(Extensions.getExtensions(PathMacrosCollector.MACRO_FILTER_EXTENSION_POINT_NAME)); private PathMacrosImpl myPathMacros; public BasePathMacroManager(@Nullable PathMacros pathMacros) { @@ -183,7 +187,7 @@ public class BasePathMacroManager extends PathMacroManager { @Override public void collapsePaths(final Element element) { - getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive); + getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, false, ourFilter); } public int hashCode() { diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 609b0103aca0..c3bea58101cd 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -223,6 +223,7 @@ serviceImplementation="com.intellij.compiler.impl.rmiCompiler.RmicConfiguration"/> +