IDEA-112560 process only applicable mixins to a ref

This commit is contained in:
Max Medvedev
2013-08-25 21:10:02 -07:00
parent c33dc4a870
commit 7e993a0353
3 changed files with 27 additions and 2 deletions
@@ -55,6 +55,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrRefer
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrGdkMethodImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
import org.jetbrains.plugins.groovy.lang.resolve.noncode.MixinMemberContributor;
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint;
import org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor;
@@ -226,7 +227,7 @@ public class GdkMethodUtil {
final DelegatingScopeProcessor delegate = new MixinMemberContributor.MixinProcessor(processor, subjectType, qualifier);
for (GrMethod method : methods) {
delegate.execute(method, ResolveState.initial());
ResolveUtil.processElement(delegate, method, state);
}
}
}
@@ -95,7 +95,7 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase {
final ref = configureByText(text)
assertNotNull(ref)
final resolved = ref.resolve()
assertInstanceOf(resolved, type)
if (type != null) assertInstanceOf(resolved, type)
return resolved
}
@@ -1431,6 +1431,30 @@ class _a {
''', PsiMethod)
}
void testRuntimeMixin22() {
assertNull resolveByText('''\
class ReentrantLock {}
ReentrantLock.metaClass.withLock = { nestedCode -> }
new ReentrantLock().withLock {
fo<caret>o(3)
}
''')
}
void testRuntimeMixin23() {
assertNotNull resolveByText('''\
class ReentrantLock {}
ReentrantLock.metaClass.withLock = { nestedCode -> }
new ReentrantLock().withLock {
withL<caret>ock(2)
}
''')
}
void testRunnableVsCallable() {
final PsiMethod method = resolveByText('''\
import java.util.concurrent.Callable