diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml
index 614bc08d2233..b0f1fbfb1ee6 100644
--- a/plugins/gradle/src/META-INF/plugin.xml
+++ b/plugins/gradle/src/META-INF/plugin.xml
@@ -61,6 +61,12 @@
+
+
+
+
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleProjectApplyArgsProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleProjectApplyArgsProvider.java
new file mode 100644
index 000000000000..3f1792b9468d
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleProjectApplyArgsProvider.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2013 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.
+ */
+package org.jetbrains.plugins.gradle.service.resolve;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider;
+import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall;
+
+import java.util.Map;
+
+/**
+ * @author Denis Zhdanov
+ * @since 7/23/13 5:53 PM
+ */
+public class GradleProjectApplyArgsProvider extends GroovyNamedArgumentProvider {
+
+ @Override
+ public void getNamedArguments(@NotNull GrCall call,
+ @Nullable PsiElement resolve,
+ @Nullable String argumentName,
+ boolean forCompletion,
+ Map result)
+ {
+ result.put("plugin", new NamedArgumentDescriptor());
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java
new file mode 100644
index 000000000000..2dc07f9a185a
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2000-2013 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.
+ */
+package org.jetbrains.plugins.gradle.service.resolve;
+
+import com.intellij.psi.*;
+import com.intellij.psi.scope.PsiScopeProcessor;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.containers.ContainerUtilRt;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.gradle.util.GradleConstants;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
+import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor;
+
+import java.util.Map;
+
+/**
+ * @author Denis Zhdanov
+ * @since 7/23/13 4:21 PM
+ */
+public class GradleScriptContributor extends NonCodeMembersContributor {
+
+ // TODO den add doc
+ @NotNull private static final Map CONTRIBUTORS = ContainerUtilRt.newHashMap();
+ static {
+ CONTRIBUTORS.put("repositories", "org.gradle.api.artifacts.dsl.RepositoryHandler");
+ CONTRIBUTORS.put("dependencies", "org.gradle.api.artifacts.dsl.DependencyHandler");
+ }
+
+ @NotNull @NonNls private static final String ROOT_CONTRIBUTOR_CLASS_NAME = "org.gradle.api.Project";
+
+ @Override
+ public void processDynamicElements(@NotNull PsiType qualifierType,
+ PsiClass aClass,
+ PsiScopeProcessor processor,
+ PsiElement place,
+ ResolveState state) {
+ if (place == null) {
+ return;
+ }
+
+ if (!(aClass instanceof GroovyScriptClass)) {
+ return;
+ }
+
+ PsiFile file = aClass.getContainingFile();
+ if (file == null || !file.getName().endsWith(GradleConstants.EXTENSION)) {
+ return;
+ }
+
+ GroovyPsiManager psiManager = GroovyPsiManager.getInstance(aClass.getProject());
+ String contributorClassName = ROOT_CONTRIBUTOR_CLASS_NAME;
+ for (GrMethodCall current = PsiTreeUtil.getParentOfType(place, GrMethodCall.class);
+ current != null;
+ current = PsiTreeUtil.getParentOfType(current, GrMethodCall.class))
+ {
+ GrExpression expression = current.getInvokedExpression();
+ if (expression != null) {
+ String text = expression.getText();
+ if (text == null || text.equals(place.getText())) {
+ continue;
+ }
+ String s = CONTRIBUTORS.get(text);
+ if (s != null) {
+ contributorClassName = s;
+ break;
+ }
+ }
+ }
+
+ PsiClass contributorClass = psiManager.findClassWithCache(contributorClassName, place.getResolveScope());
+ if (contributorClass != null) {
+ contributorClass.processDeclarations(processor, state, null, place);
+ }
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java
index 4f498e85a588..9ed33e925729 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java
@@ -14,17 +14,17 @@ import java.util.concurrent.TimeUnit;
*/
public class GradleConstants {
- @NotNull public static final ProjectSystemId SYSTEM_ID = new ProjectSystemId("GRADLE");
+ @NotNull @NonNls public static final ProjectSystemId SYSTEM_ID = new ProjectSystemId("GRADLE");
- @NonNls public static final String EXTENSION = "gradle";
- @NonNls public static final String DEFAULT_SCRIPT_NAME = "build.gradle";
- @NonNls public static final String SETTINGS_FILE_NAME = "settings.gradle";
+ @NotNull @NonNls public static final String EXTENSION = "gradle";
+ @NotNull @NonNls public static final String DEFAULT_SCRIPT_NAME = "build.gradle";
+ @NotNull @NonNls public static final String SETTINGS_FILE_NAME = "settings.gradle";
- public static final String SYSTEM_DIRECTORY_PATH_KEY = "GRADLE_USER_HOME";
+ @NotNull @NonNls public static final String SYSTEM_DIRECTORY_PATH_KEY = "GRADLE_USER_HOME";
- @NonNls public static final String TOOL_WINDOW_TOOLBAR_PLACE = "GRADLE_SYNC_CHANGES_TOOLBAR";
+ @NotNull @NonNls public static final String TOOL_WINDOW_TOOLBAR_PLACE = "GRADLE_SYNC_CHANGES_TOOLBAR";
- @NonNls public static final String HELP_TOPIC_TOOL_WINDOW = "reference.toolwindows.gradle";
+ @NotNull @NonNls public static final String HELP_TOPIC_TOOL_WINDOW = "reference.toolwindows.gradle";
private GradleConstants() {
}