From a34dfe8ade0721a91e86fc98a6a54ba1ad2508f9 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Sun, 20 Jan 2013 10:25:11 +0100 Subject: [PATCH] DevKit: * support AppCode 1.6 and 2.0) (cherry picked from commit ca2b8ed) * allow specifying idea.platform.prefix in Plugin run configuration. --- .../configurations/ParametersList.java | 5 +-- .../src/com/intellij/util/PlatformUtils.java | 4 +- .../src/run/PluginRunConfiguration.java | 44 +++++++++++-------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index 1c22a7e51613..503d217ba1f7 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -47,10 +47,7 @@ public class ParametersList implements Cloneable { } public boolean hasProperty(@NonNls final String name) { - for (@NonNls String parameter : myParameters) { - if (parameter.startsWith("-D" + name + '=')) return true; - } - return false; + return getPropertyValue(name) != null; } @Nullable diff --git a/platform/platform-api/src/com/intellij/util/PlatformUtils.java b/platform/platform-api/src/com/intellij/util/PlatformUtils.java index 79b69414162f..ad6840591f15 100644 --- a/platform/platform-api/src/com/intellij/util/PlatformUtils.java +++ b/platform/platform-api/src/com/intellij/util/PlatformUtils.java @@ -23,6 +23,8 @@ import org.jetbrains.annotations.Nullable; * @author Konstantin Bulenkov */ public class PlatformUtils { + public static final String PLATFORM_PREFIX_KEY = "idea.platform.prefix"; + public static final String IDEA_PREFIX = "idea"; public static final String COMMUNITY_PREFIX = "Idea"; public static final String APPCODE_PREFIX = "AppCode"; @@ -40,7 +42,7 @@ public class PlatformUtils { } public static String getPlatformPrefix(String defaultPrefix) { - return System.getProperty("idea.platform.prefix", defaultPrefix); + return System.getProperty(PLATFORM_PREFIX_KEY, defaultPrefix); } public static boolean isIdea() { diff --git a/plugins/devkit/src/run/PluginRunConfiguration.java b/plugins/devkit/src/run/PluginRunConfiguration.java index 597eb02ccda3..e71ee7e155e6 100644 --- a/plugins/devkit/src/run/PluginRunConfiguration.java +++ b/plugins/devkit/src/run/PluginRunConfiguration.java @@ -33,6 +33,7 @@ import com.intellij.openapi.projectRoots.SdkModificator; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.PlatformUtils; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -144,25 +145,30 @@ public class PluginRunConfiguration extends RunConfigurationBase implements Modu } } - String buildNumber = IdeaJdk.getBuildNumber(usedIdeaJdk.getHomePath()); - if (buildNumber != null) { - if (buildNumber.startsWith("IC")) { - vm.defineProperty("idea.platform.prefix", "Idea"); - } - else if (buildNumber.startsWith("PY")) { - vm.defineProperty("idea.platform.prefix", "Python"); - } - else if (buildNumber.startsWith("RM")) { - vm.defineProperty("idea.platform.prefix", "Ruby"); - } - else if (buildNumber.startsWith("PS")) { - vm.defineProperty("idea.platform.prefix", "PhpStorm"); - } - else if (buildNumber.startsWith("WS")) { - vm.defineProperty("idea.platform.prefix", "WebStorm"); - } - else if (buildNumber.startsWith("OC")) { - vm.defineProperty("idea.platform.prefix", "AppCode"); + if (!vm.hasProperty(PlatformUtils.PLATFORM_PREFIX_KEY)) { + String buildNumber = IdeaJdk.getBuildNumber(usedIdeaJdk.getHomePath()); + if (buildNumber != null) { + String prefix = null; + + if (buildNumber.startsWith("IC")) { + prefix = PlatformUtils.COMMUNITY_PREFIX; + } + else if (buildNumber.startsWith("PY")) { + prefix = PlatformUtils.PYCHARM_PREFIX; + } + else if (buildNumber.startsWith("RM")) { + prefix = PlatformUtils.RUBY_PREFIX; + } + else if (buildNumber.startsWith("PS")) { + prefix = PlatformUtils.PHP_PREFIX; + } + else if (buildNumber.startsWith("WS")) { + prefix = PlatformUtils.WEB_PREFIX; + } + else if (buildNumber.startsWith("OC")) { + prefix = buildNumber.contains("121") ? "CIDR" : PlatformUtils.APPCODE_PREFIX; + } + if (prefix != null) vm.defineProperty(PlatformUtils.PLATFORM_PREFIX_KEY, prefix); } }