mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'idea90' of git.labs.intellij.net:idea/community into idea90
This commit is contained in:
@@ -26,6 +26,7 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContaine
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -211,11 +212,22 @@ public class GroovyFacetEditor {
|
||||
|
||||
@Nullable
|
||||
private static AbstractGroovyLibraryManager findManager(VirtualFile dir) {
|
||||
for (AbstractGroovyLibraryManager manager : AbstractGroovyLibraryManager.EP_NAME.getExtensions()) {
|
||||
if (GroovyUtils.getFilesInDirectoryByPattern(dir.getPath() + "/lib", "groovy.*\\.jar").length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String name = dir.getName();
|
||||
|
||||
final AbstractGroovyLibraryManager[] managers = AbstractGroovyLibraryManager.EP_NAME.getExtensions();
|
||||
for (final AbstractGroovyLibraryManager manager : managers) {
|
||||
if (StringUtil.startsWithIgnoreCase(name, manager.getLibraryPrefix())) {
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
|
||||
for (final AbstractGroovyLibraryManager manager : managers) {
|
||||
if (manager.isSDKHome(dir)) {
|
||||
if (GroovyUtils.getFilesInDirectoryByPattern(dir.getPath() + "/lib", "groovy.*\\.jar").length > 0) {
|
||||
return manager;
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -41,9 +41,12 @@ import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyScriptType;
|
||||
import org.jetbrains.plugins.groovy.gant.GantUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic.GrShiftExpressionImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfiguration;
|
||||
import org.jetbrains.plugins.groovy.runner.GroovyScriptRunner;
|
||||
@@ -80,10 +83,9 @@ public class GradleScriptType extends GroovyScriptType {
|
||||
pp = pp.getParent();
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (pp != null && parent instanceof GrMethodCallExpression && PsiUtil.isMethodCall((GrMethodCallExpression)parent, "createTask")) {
|
||||
final GrExpression[] arguments = ((GrMethodCallExpression)parent).getArgumentList().getExpressionArguments();
|
||||
if (arguments.length > 0 && arguments[0] instanceof GrLiteral && ((GrLiteral)arguments[0]).getValue() instanceof String) {
|
||||
String target = (String)((GrLiteral)arguments[0]).getValue();
|
||||
if (pp != null) {
|
||||
String target = getTaskTarget(parent);
|
||||
if (target != null) {
|
||||
configuration.scriptParams = target;
|
||||
configuration.setName(configuration.getName() + "." + target);
|
||||
}
|
||||
@@ -95,6 +97,37 @@ public class GradleScriptType extends GroovyScriptType {
|
||||
}
|
||||
}
|
||||
|
||||
private String getTaskTarget(PsiElement parent) {
|
||||
String target = null;
|
||||
if (isCreateTaskMethod(parent)) {
|
||||
final GrExpression[] arguments = ((GrMethodCallExpression)parent).getArgumentList().getExpressionArguments();
|
||||
if (arguments.length > 0 && arguments[0] instanceof GrLiteral && ((GrLiteral)arguments[0]).getValue() instanceof String) {
|
||||
target = (String)((GrLiteral)arguments[0]).getValue();
|
||||
}
|
||||
}
|
||||
else if (parent instanceof GrApplicationStatement) {
|
||||
PsiElement shiftExpression = parent.getChildren()[1].getChildren()[0];
|
||||
if (shiftExpression instanceof GrShiftExpressionImpl) {
|
||||
PsiElement shiftiesChild = shiftExpression.getChildren()[0];
|
||||
if (shiftiesChild instanceof GrReferenceExpression) {
|
||||
target = shiftiesChild.getText();
|
||||
}
|
||||
else if (shiftiesChild instanceof GrMethodCallExpression) {
|
||||
target = shiftiesChild.getChildren()[0].getText();
|
||||
}
|
||||
}
|
||||
else if (shiftExpression instanceof GrMethodCallExpression) {
|
||||
target = shiftExpression.getChildren()[0].getText();
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
private boolean isCreateTaskMethod(PsiElement parent) {
|
||||
return parent instanceof GrMethodCallExpression && PsiUtil.isMethodCall((GrMethodCallExpression)parent, "createTask");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroovyScriptRunner getRunner() {
|
||||
return new GroovyScriptRunner() {
|
||||
|
||||
@@ -85,22 +85,14 @@ public abstract class TokenSets implements GroovyTokenTypes {
|
||||
kDOUBLE
|
||||
);
|
||||
|
||||
public static TokenSet KEYWORD_REFERENCE_NAMES = TokenSet.orSet(TokenSet.create(
|
||||
kCLASS,
|
||||
kIN,
|
||||
kAS,
|
||||
kDEF,
|
||||
kIF,
|
||||
kELSE,
|
||||
kFOR,
|
||||
kWHILE,
|
||||
kSWITCH,
|
||||
kTRY,
|
||||
kCATCH,
|
||||
kFINALLY,
|
||||
kSTATIC,
|
||||
kDEFAULT
|
||||
), BUILT_IN_TYPE);
|
||||
/**
|
||||
* all keywords except 'this' and 'super'
|
||||
*/
|
||||
public static TokenSet KEYWORD_REFERENCE_NAMES = TokenSet
|
||||
.create(kPACKAGE, kIMPORT, kSTATIC, kDEF, kCLASS, kINTERFACE, kENUM, kEXTENDS, kSUPER, kVOID, kBOOLEAN, kBYTE, kCHAR, kSHORT, kINT,
|
||||
kFLOAT, kLONG, kDOUBLE, kAS, kPRIVATE, kPUBLIC, kPROTECTED, kTRANSIENT, kNATIVE, kSYNCHRONIZED, kVOLATILE, kDEFAULT, kTHROWS,
|
||||
kIMPLEMENTS, kIF, kELSE, kWHILE, kSWITCH, kFOR, kIN, kRETURN, kBREAK, kCONTINUE, kTHROW, kASSERT, kCASE, kTRY, kFINALLY, kCATCH,
|
||||
kINSTANCEOF, kNEW, kTRUE, kNULL);
|
||||
|
||||
public static final TokenSet PROPERTY_NAMES = TokenSet.create(mIDENT, mSTRING_LITERAL, mGSTRING_LITERAL);
|
||||
|
||||
|
||||
+2
-1
@@ -60,7 +60,7 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration<RunCo
|
||||
public String workDir;
|
||||
public boolean isDebugEnabled;
|
||||
public String scriptParams;
|
||||
public String scriptPath;
|
||||
@Nullable public String scriptPath;
|
||||
|
||||
public GroovyScriptRunConfiguration(final String name, final Project project, final ConfigurationFactory factory) {
|
||||
super(name, new RunConfigurationModule(project), factory);
|
||||
@@ -196,6 +196,7 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration<RunCo
|
||||
|
||||
@Nullable
|
||||
private VirtualFile getScriptFile() {
|
||||
if (scriptPath == null) return null;
|
||||
return LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(scriptPath));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user