mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Gradle: code insight
This commit is contained in:
@@ -36,10 +36,12 @@
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleBuildScriptContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleRepositoriesContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleMavenArtifactRepositoryContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleMavenDeployerContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleDependenciesContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleArtifactsContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleSourceSetsContributor"/>
|
||||
<resolve.contributor implementation="org.jetbrains.plugins.gradle.service.resolve.GradleImplicitContributor"/>
|
||||
<!--<projectResolve implementation="org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension"/>-->
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
+2
@@ -57,6 +57,8 @@ public final class GradleCommonClassNames {
|
||||
@NonNls public static final String GRADLE_API_JAVA_ARCHIVES_MANIFEST = "org.gradle.api.java.archives.Manifest";
|
||||
@NonNls public static final String GRADLE_API_NAMED_DOMAIN_OBJECT_COLLECTION = "org.gradle.api.NamedDomainObjectCollection";
|
||||
@NonNls public static final String GRADLE_API_ARTIFACTS_REPOSITORIES_MAVEN_ARTIFACT_REPOSITORY = "org.gradle.api.artifacts.repositories.MavenArtifactRepository";
|
||||
@NonNls public static final String GRADLE_API_ARTIFACTS_MAVEN_MAVEN_DEPLOYER = "org.gradle.api.artifacts.maven.MavenDeployer";
|
||||
@NonNls public static final String GRADLE_API_PLUGINS_MAVEN_REPOSITORY_HANDLER_CONVENTION = "org.gradle.api.plugins.MavenRepositoryHandlerConvention";
|
||||
|
||||
private GradleCommonClassNames() {
|
||||
}
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ public class GradleImplicitContributor implements GradleMethodContextContributor
|
||||
@NotNull PsiElement place) {
|
||||
if (taskName.equals(place.getText())) {
|
||||
if (!(place instanceof GrClosableBlock)) {
|
||||
GrLightMethodBuilder methodBuilder = GradleResolverUtil.createMethodWithClosure(taskName, fqName, fqName, place, psiManager);
|
||||
GrLightMethodBuilder methodBuilder = GradleResolverUtil.createMethodWithClosure(taskName, fqName, null, place, psiManager);
|
||||
if (methodBuilder == null) return;
|
||||
processor.execute(methodBuilder, state);
|
||||
PsiClass contributorClass =
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.ResolveState;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @{GradleMavenArtifactRepositoryContributor} provides gradle MavenArtifactRepository DSL resolving contributor.
|
||||
*
|
||||
* e.g.
|
||||
* repositories {
|
||||
* maven {
|
||||
* url "http://snapshots.repository.codehaus.org/"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @author Vladislav.Soroka
|
||||
* @since 10/21/13
|
||||
*/
|
||||
public class GradleMavenDeployerContributor implements GradleMethodContextContributor {
|
||||
|
||||
@Override
|
||||
public void process(@NotNull List<String> methodCallInfo,
|
||||
@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@NotNull PsiElement place) {
|
||||
if (methodCallInfo.isEmpty() || methodCallInfo.size() < 3 ||
|
||||
!"repositories".equals(methodCallInfo.get(2)) || !"mavenDeployer".equals(methodCallInfo.get(1))) {
|
||||
return;
|
||||
}
|
||||
GroovyPsiManager psiManager = GroovyPsiManager.getInstance(place.getProject());
|
||||
GradleResolverUtil.processDeclarations(
|
||||
psiManager, processor, state, place,
|
||||
GradleCommonClassNames.GRADLE_API_ARTIFACTS_MAVEN_MAVEN_DEPLOYER);
|
||||
PsiClass contributorClass = psiManager.findClassWithCache(
|
||||
GradleCommonClassNames.GRADLE_API_ARTIFACTS_MAVEN_MAVEN_DEPLOYER, place.getResolveScope());
|
||||
if (contributorClass == null) return;
|
||||
GradleResolverUtil.processMethod(methodCallInfo.get(0), contributorClass, processor, state, place);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -21,6 +21,7 @@ package org.jetbrains.plugins.gradle.service.resolve;
|
||||
*/
|
||||
public class GradleRepositoriesContributor extends GradleSimpleContributor {
|
||||
public GradleRepositoriesContributor() {
|
||||
super("repositories", GradleCommonClassNames.GRADLE_API_REPOSITORY_HANDLER);
|
||||
super("repositories", GradleCommonClassNames.GRADLE_API_REPOSITORY_HANDLER,
|
||||
GradleCommonClassNames.GRADLE_API_PLUGINS_MAVEN_REPOSITORY_HANDLER_CONVENTION);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.gradle.service.resolve;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -115,12 +116,12 @@ public class GradleResolverUtil {
|
||||
return methodWithClosure;
|
||||
}
|
||||
|
||||
public static void processMethod(@NotNull String gradleConfigurationName,
|
||||
@NotNull PsiClass dependencyHandlerClass,
|
||||
public static void processMethod(@NotNull String methodName,
|
||||
@NotNull PsiClass handlerClass,
|
||||
@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@NotNull PsiElement place) {
|
||||
processMethod(gradleConfigurationName, dependencyHandlerClass, processor, state, place, null);
|
||||
processMethod(methodName, handlerClass, processor, state, place, null);
|
||||
}
|
||||
|
||||
public static void processMethod(@NotNull String methodName,
|
||||
|
||||
+11
-1
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.service.resolve;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.ResolveState;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
|
||||
|
||||
@@ -31,10 +33,12 @@ public abstract class GradleSimpleContributor implements GradleMethodContextCont
|
||||
|
||||
private final String blockName;
|
||||
private final String fqName;
|
||||
private final List<String> myMixIns;
|
||||
|
||||
protected GradleSimpleContributor(@NotNull String blockName, @NotNull String fqName) {
|
||||
protected GradleSimpleContributor(@NotNull String blockName, @NotNull String fqName, String... mixIns) {
|
||||
this.blockName = blockName;
|
||||
this.fqName = fqName;
|
||||
myMixIns = ContainerUtil.newArrayList(mixIns);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,5 +51,11 @@ public abstract class GradleSimpleContributor implements GradleMethodContextCont
|
||||
}
|
||||
GroovyPsiManager psiManager = GroovyPsiManager.getInstance(place.getProject());
|
||||
GradleResolverUtil.processDeclarations(psiManager, processor, state, place, fqName);
|
||||
for(final String mixin : myMixIns) {
|
||||
PsiClass contributorClass =
|
||||
psiManager.findClassWithCache(mixin, place.getResolveScope());
|
||||
if (contributorClass == null) continue;
|
||||
GradleResolverUtil.processMethod(methodCallInfo.get(0), contributorClass, processor, state, place);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user