diff --git a/plugins/gradle/java/intellij.gradle.java.tests.iml b/plugins/gradle/java/intellij.gradle.java.tests.iml
index a878159d7136..d46f1ba946e9 100644
--- a/plugins/gradle/java/intellij.gradle.java.tests.iml
+++ b/plugins/gradle/java/intellij.gradle.java.tests.iml
@@ -21,5 +21,6 @@
+
\ No newline at end of file
diff --git a/plugins/gradle/java/testSources/dsl/GradleConfigurationsTest.groovy b/plugins/gradle/java/testSources/dsl/GradleConfigurationsTest.groovy
new file mode 100644
index 000000000000..243cb06330f7
--- /dev/null
+++ b/plugins/gradle/java/testSources/dsl/GradleConfigurationsTest.groovy
@@ -0,0 +1,104 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.gradle.dsl
+
+import groovy.transform.CompileStatic
+import org.jetbrains.plugins.gradle.highlighting.GradleHighlightingBaseTest
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
+import org.jetbrains.plugins.groovy.util.ResolveTest
+import org.junit.Test
+
+import static org.jetbrains.plugins.gradle.service.resolve.GradleCommonClassNames.GRADLE_API_CONFIGURATION
+import static org.jetbrains.plugins.gradle.service.resolve.GradleCommonClassNames.GRADLE_API_CONFIGURATION_CONTAINER
+import static org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesToUtilKt.getDelegatesToInfo
+
+@CompileStatic
+class GradleConfigurationsTest extends GradleHighlightingBaseTest implements ResolveTest {
+
+ @Test
+ void 'configurations closure delegate'() {
+ doTest('configurations { }') {
+ def closure = elementUnderCaret(GrClosableBlock)
+ def delegatesToInfo = getDelegatesToInfo(closure)
+ assert delegatesToInfo.typeToDelegate.equalsToText(GRADLE_API_CONFIGURATION_CONTAINER)
+ assert delegatesToInfo.strategy == 1
+ }
+ }
+
+ @Test
+ void 'configuration via unqualified property reference'() {
+ doTest('configurations { foo }') {
+ def ref = elementUnderCaret(GrReferenceExpression)
+ assert ref.resolve() != null
+ assert ref.type.equalsToText(GRADLE_API_CONFIGURATION)
+ }
+ }
+
+ @Test
+ void 'configuration via unqualified method call'() {
+ doTest('configurations { foo {} }') {
+ def call = elementUnderCaret(GrMethodCall)
+ assert call.resolveMethod() != null
+ assert call.type.equalsToText(GRADLE_API_CONFIGURATION)
+ }
+ }
+
+ @Test
+ void 'configuration closure delegate in unqualified method call'() {
+ doTest('configurations { foo { } }') {
+ def closure = elementUnderCaret(GrClosableBlock)
+ def delegatesToInfo = getDelegatesToInfo(closure)
+ assert delegatesToInfo.typeToDelegate.equalsToText(GRADLE_API_CONFIGURATION)
+ assert delegatesToInfo.strategy == 1
+ }
+ }
+
+ @Test
+ void 'configuration member via unqualified method call closure delegate'() {
+ doTest('configurations { foo { extendsFrom() } }') {
+ def call = elementUnderCaret(GrMethodCall)
+ def method = call.resolveMethod()
+ assert method != null
+ assert method.containingClass.qualifiedName == GRADLE_API_CONFIGURATION
+ }
+ }
+
+ @Test
+ void 'configuration via qualified property reference'() {
+ doTest('configurations { foo }; configurations.foo') {
+ def ref = elementUnderCaret(GrReferenceExpression)
+ assert ref.resolve() != null
+ assert ref.type.equalsToText(GRADLE_API_CONFIGURATION)
+ }
+ }
+
+ @Test
+ void 'configuration via qualified method call'() {
+ doTest('configurations { foo }; configurations.foo {}') {
+ def call = elementUnderCaret(GrMethodCall)
+ assert call.resolveMethod() != null
+ assert call.type.equalsToText(GRADLE_API_CONFIGURATION)
+ }
+ }
+
+ @Test
+ void 'configuration closure delegate in qualified method call'() {
+ doTest('configurations { foo }; configurations.foo { }') {
+ def closure = elementUnderCaret(GrClosableBlock)
+ def delegatesToInfo = getDelegatesToInfo(closure)
+ assert delegatesToInfo.typeToDelegate.equalsToText(GRADLE_API_CONFIGURATION)
+ assert delegatesToInfo.strategy == 1
+ }
+ }
+
+ @Test
+ void 'configuration member via qualified method call closure delegate'() {
+ doTest('configurations { foo }; configurations.foo { extendsFrom() }') {
+ def call = elementUnderCaret(GrMethodCall)
+ def method = call.resolveMethod()
+ assert method != null
+ assert method.containingClass.qualifiedName == GRADLE_API_CONFIGURATION
+ }
+ }
+}
diff --git a/plugins/gradle/java/testSources/highlighting/GradleHighlightingBaseTest.groovy b/plugins/gradle/java/testSources/highlighting/GradleHighlightingBaseTest.groovy
index bc30126a6abc..c9919090bbed 100644
--- a/plugins/gradle/java/testSources/highlighting/GradleHighlightingBaseTest.groovy
+++ b/plugins/gradle/java/testSources/highlighting/GradleHighlightingBaseTest.groovy
@@ -55,6 +55,13 @@ abstract class GradleHighlightingBaseTest extends GradleImportingTestCase {
}
}
+ void doTest(@NotNull String text, Closure test) {
+ VirtualFile vFile = createProjectSubFile 'build.gradle', text
+ fixture.configureFromExistingVirtualFile(vFile)
+ importProject()
+ ReadAction.run(test)
+ }
+
@Override
void tearDownFixtures() {
fixture.tearDown()