/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
import java.util.ArrayList;
Map<String, List<CandidateInfo>> allMethods = new HashMap<String, List<CandidateInfo>>();
Map<String, CandidateInfo> allInnerClasses = new HashMap<String, CandidateInfo>();
- processClass(aClass, allFields, allMethods, allInnerClasses, new HashSet<PsiClass>(), PsiSubstitutor.EMPTY, includeSynthetic);
+ processClass(aClass, allFields, allMethods, allInnerClasses, new HashSet<PsiClass>(), PsiSubstitutor.EMPTY, includeSynthetic, true);
return Result.create(Trinity.create(allFields, allMethods, allInnerClasses), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
}, false);
}
- private static void processClass(PsiClass aClass, Map<String, CandidateInfo> allFields, Map<String, List<CandidateInfo>> allMethods, Map<String, CandidateInfo> allInnerClasses, Set<PsiClass> visitedClasses, PsiSubstitutor substitutor, boolean includeSynthetic) {
+ private static void processClass(PsiClass aClass, Map<String, CandidateInfo> allFields, Map<String, List<CandidateInfo>> allMethods, Map<String, CandidateInfo> allInnerClasses, Set<PsiClass> visitedClasses, PsiSubstitutor substitutor, boolean includeSynthetic, boolean shouldProcessInnerClasses) {
if (visitedClasses.contains(aClass)) return;
visitedClasses.add(aClass);
addMethod(allMethods, method, substitutor);
}
- for (final PsiClass inner : aClass.getInnerClasses()) {
- final String name = inner.getName();
- if (name != null && !allInnerClasses.containsKey(name)) {
- allInnerClasses.put(name, new CandidateInfo(inner, substitutor));
+ if (shouldProcessInnerClasses) {
+ for (final PsiClass inner : aClass.getInnerClasses()) {
+ final String name = inner.getName();
+ if (name != null && !allInnerClasses.containsKey(name)) {
+ allInnerClasses.put(name, new CandidateInfo(inner, substitutor));
+ }
}
}
PsiClass superClass = superType.resolve();
if (superClass != null) {
final PsiSubstitutor superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, substitutor);
- processClass(superClass, allFields, allMethods, allInnerClasses, visitedClasses, superSubstitutor, includeSynthetic);
+ processClass(superClass, allFields, allMethods, allInnerClasses, visitedClasses, superSubstitutor, includeSynthetic,
+ shouldProcessInnerClasses && !(aClass instanceof GrAnonymousClassDefinition));
}
}
}
/*
- * Copyright 2000-2007 JetBrains s.r.o.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Copyright 2000-2010 JetBrains s.r.o.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.resolve;
doTest()
}
+ public void testInnerClassIsNotResolvedInAnonymous() {
+ myFixture.addFileToProject "/p/Super.groovy", """
+package p
+
+interface Super {
+ class Inner {
+ }
+
+ def foo(Inner i);
+}"""
+ assertNull resolve("A.groovy");
+ }
+
+ public void testInnerClassIsResolvedInAnonymous() {
+ myFixture.addFileToProject "/p/Super.groovy", """
+package p
+
+interface Super {
+ class Inner {
+ }
+
+ def foo(Inner i);
+}"""
+ assertInstanceOf resolve("A.groovy"), PsiClass;
+ }
+
private void doTest() {
doTest(getTestName(true) + "/" + getTestName(false) + ".groovy");
}
--- /dev/null
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import p.Super
+
+def an = new Super() {
+ def foo(Inn<ref>er i) {
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import p.Super
+import p.Super.Inner
+def an = new Super() {
+ def foo(Inn<ref>er i) {
+
+ }
+}
\ No newline at end of file