IDEA-146198 Gradle: cannot resolve sourceSets

This commit is contained in:
Vladislav.Soroka
2016-11-29 20:50:24 +03:00
parent df1bd75257
commit 1b6bccf022
2 changed files with 15 additions and 2 deletions
@@ -55,6 +55,8 @@ class GradleJavaContributor : GradleMethodContextContributor {
groovyClosure().withAncestor(2, sourceSetClosure),
groovyClosure().inMethod(or(psiMethod(GRADLE_API_SOURCE_SET, "java"),
psiMethod(GRADLE_API_SOURCE_SET, "resources"))))
val sourceDirectorySetClosureCandidate = groovyClosure().inMethod(psiMethodInClass(GRADLE_API_SOURCE_SET))
}
override fun getDelegatesToInfo(closure: GrClosableBlock): DelegatesToInfo? {
@@ -93,10 +95,18 @@ class GradleJavaContributor : GradleMethodContextContributor {
if (!processor.execute(methodBuilder, state)) return false
}
}
if (place.parent is GrReferenceExpression || psiElement.withTreeParent(sourceSetsClosure).accepts(place)) {
if (!psiElement.inside(sourceDirectorySetClosureCandidate).accepts(place)
&& (place.parent is GrReferenceExpression || psiElement.withTreeParent(sourceSetsClosure).accepts(place))) {
val variable = GrLightVariable(place.manager, name, GRADLE_API_SOURCE_SET, place)
if (!processor.execute(variable, state)) return false
}
if (psiElement.inside(sourceDirectorySetClosureCandidate).accepts(place)) {
if (!GradleResolverUtil.processDeclarations(psiManager, processor, state, place, GRADLE_API_SOURCE_DIRECTORY_SET)) {
return false
}
}
}
return true
@@ -24,6 +24,7 @@ import com.intellij.psi.scope.BaseScopeProcessor
import com.intellij.psi.scope.ElementClassHint
import com.intellij.psi.scope.NameHint.KEY
import com.intellij.psi.scope.PsiScopeProcessor
import org.jetbrains.plugins.groovy.lang.psi.patterns.GroovyPatterns
/**
* @author Vladislav.Soroka
@@ -67,4 +68,6 @@ class ComponentProcessor(val delegate: PsiScopeProcessor, val place: PsiElement,
else {
null
}
}
}
fun psiMethodInClass(containingClass: String) = GroovyPatterns.psiMethod().definedInClass(containingClass)