From 29df5eb307cfaa0970e35f86650212fd31462765 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Sat, 19 Dec 2009 20:50:20 +0300 Subject: [PATCH 1/4] =?UTF-8?q?IDEADEV-41999:=20'=E2=80=8Btrue=E2=80=8B'?= =?UTF-8?q?=E2=80=8B/=E2=80=8B'=E2=80=8Bfalse'=20map=20keys=20generate=20a?= =?UTF-8?q?nalysis=20errors=20"=E2=80=8BProperty=20Selector=20Expected"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/groovy/lang/lexer/TokenSets.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java index f91b4f875526..a94b827e8cc3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java @@ -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); From 2b4e7bd7d94015bba8406a622b6fffc5b8d7f99c Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Sat, 19 Dec 2009 21:30:30 +0300 Subject: [PATCH 2/4] IAE: FileUtil.toSystemIndependentName --- .../plugins/groovy/runner/GroovyScriptRunConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java index 31eaa0a19fb8..e90f8d248f8f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfiguration.java @@ -60,7 +60,7 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration Date: Sun, 20 Dec 2009 21:20:52 +0000 Subject: [PATCH 3/4] bring back add framework support for gradle, don't recognize it as groovy --- .../groovy/config/ui/GroovyFacetEditor.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java index 6abc0e7a4acc..644d4dfb25b1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ui/GroovyFacetEditor.java @@ -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; From cef67ce301d4f31f4c9e119cdad690e2ec04818b Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 20 Dec 2009 21:22:52 +0000 Subject: [PATCH 4/4] [Ken Sipe] gradle: context run for 'task'-property-based task definitions --- .../groovy/gradle/GradleScriptType.java | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleScriptType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleScriptType.java index de7cd8b904c3..5016ccab5373 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleScriptType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gradle/GradleScriptType.java @@ -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() {