File tree 1 file changed +9
-1
lines changed
src/main/java/com/redhat/devtools/intellij/lsp4mp4ij/psi/internal/core/providers
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 16
16
import java .util .Collections ;
17
17
import java .util .List ;
18
18
19
+ import com .intellij .ide .plugins .PluginManager ;
20
+ import com .intellij .openapi .extensions .PluginId ;
19
21
import com .intellij .openapi .externalSystem .util .ExternalSystemApiUtil ;
20
22
import com .intellij .openapi .module .Module ;
21
23
import com .redhat .devtools .intellij .lsp4mp4ij .psi .core .IProjectLabelProvider ;
31
33
public class GradleProjectLabelProvider implements IProjectLabelProvider {
32
34
33
35
public static final String GRADLE_LABEL = "gradle" ;
36
+ private static final PluginManager instance = PluginManager .getInstance ();
37
+ private static final PluginId gradlePluginId = PluginId .findId ("com.intellij.gradle" );
34
38
private static final String GRADLE_NATURE_ID = "org.eclipse.buildship.core.gradleprojectnature" ;
35
39
36
40
@ Override
37
41
public List <String > getProjectLabels (Module project ) {
38
- if (GradleProjectLabelProvider .isGradleProject (project )) {
42
+ // The IntelliJ Gradle plugin is declared as "optional" in plugin.xml. Don't try
43
+ // to access any IntelliJ Gradle plugin classes unless it is actually enabled.
44
+ if (gradlePluginId != null &&
45
+ instance .findEnabledPlugin (gradlePluginId ) != null &&
46
+ GradleProjectLabelProvider .isGradleProject (project )) {
39
47
return Collections .singletonList (GRADLE_LABEL );
40
48
}
41
49
return Collections .emptyList ();
You can’t perform that action at this time.
0 commit comments