* support AppCode 1.6 and 2.0) (cherry picked from commit ca2b8ed)
* allow specifying idea.platform.prefix in Plugin run configuration.
This commit is contained in:
Anton Makeev
2013-01-20 12:40:42 +01:00
parent 33cf795861
commit a34dfe8ade
3 changed files with 29 additions and 24 deletions
@@ -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
@@ -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() {
@@ -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);
}
}