IDEA-60902 Groovy: false error "Variable 'args' already defined" is shown for variabl...
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Sat, 27 Nov 2010 13:02:59 +0000 (16:02 +0300)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Sat, 27 Nov 2010 13:02:59 +0000 (16:02 +0300)
plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java

index aaced50fb93db6054d1e5e8d1dc59cfbef9f5ed3..74fdb53de99afd47f3cc1b3e33348ae7f2a98d12 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.light.LightElement;
 import com.intellij.psi.infos.CandidateInfo;
 import com.intellij.psi.search.searches.SuperMethodsSearch;
 import com.intellij.psi.util.InheritanceUtil;
@@ -419,6 +420,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
         if (parent instanceof GrClosableBlock) {
           duplicate = ResolveUtil
             .resolveExistingElement((GrClosableBlock)parent, new DuplicateVariablesProcessor(variable), GrVariable.class, GrReferenceExpression.class);
+          if (duplicate instanceof LightElement) {
+            duplicate = null;
+          }
         }
       }
     }
index 7ef644df7851eba2a1affcdba04a447f2cc4ba5c..a553310d51273297b0966949623f86bb742fe56b 100644 (file)
@@ -54,6 +54,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -102,8 +103,8 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
 
   private GrParameter getSyntheticArgsParameter() {
     if (mySyntheticArgsParameter == null) {
-      final GrParameter candidate =
-        GroovyPsiElementFactory.getInstance(getProject()).createParameter(SYNTHETIC_PARAMETER_NAME, "java.lang.String[]", this);
+      final PsiType psiType = JavaPsiFacade.getElementFactory(getProject()).createTypeFromText("java.lang.String[]", this);
+      final GrParameter candidate = new GrLightParameter(SYNTHETIC_PARAMETER_NAME, psiType, this);
       synchronized (lock) {
         if (mySyntheticArgsParameter == null) {
           mySyntheticArgsParameter = candidate;