Skip to content

Commit dc166be

Browse files
author
Vitaliy
authored
Merge pull request #60 from rogyar/43-jsgraphql-dependency
JSGraphql configured as an optional dependency
2 parents 91bfe0e + e1ddcb2 commit dc166be

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

resources/META-INF/plugin.xml

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<depends>com.jetbrains.php</depends>
3636
<depends>JavaScript</depends>
3737
<depends>com.intellij.modules.platform</depends>
38-
<depends>com.intellij.lang.jsgraphql</depends>
38+
<depends optional="true" config-file="withJsGraphQl.xml">com.intellij.lang.jsgraphql</depends>
3939

4040
<actions>
4141
<group id="MagentoGenerateGroup">
@@ -91,15 +91,12 @@
9191
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.mftf.DataIndex" />
9292
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.mftf.PageIndex" />
9393
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.mftf.StepKeyIndex" />
94-
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.graphql.GraphQlResolverIndex" />
9594
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.js.RequireJsIndex" />
9695
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.js.MagentoLibJsIndex" />
9796

9897
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.PluginLineMarkerProvider"/>
9998
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.ClassConfigurationLineMarkerProvider"/>
10099
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.WebApiLineMarkerProvider"/>
101-
<codeInsight.lineMarkerProvider language="GraphQL" implementationClass="com.magento.idea.magento2plugin.graphql.linemarker.GraphQlResolverClassLineMarkerProvider"/>
102-
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.GraphQlResolverUsageLineMarkerProvider"/>
103100

104101
<directoryProjectConfigurator implementation="com.magento.idea.magento2plugin.project.ProjectDetector"/>
105102

resources/META-INF/withJsGraphQl.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.graphql.GraphQlResolverIndex" />
4+
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.GraphQlResolverUsageLineMarkerProvider"/>
5+
<codeInsight.lineMarkerProvider language="GraphQL" implementationClass="com.magento.idea.magento2plugin.graphql.linemarker.GraphQlResolverClassLineMarkerProvider"/>
6+
</extensions>
7+
</idea-plugin>

src/com/magento/idea/magento2plugin/php/linemarker/GraphQlResolverUsageLineMarkerProvider.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private boolean isResolver(PhpClass psiElement) {
7171

7272
private static class GraphQlUsagesCollector {
7373

74-
private HashMap<String, List<GraphQLQuotedString>> routesCache = new HashMap<>();
74+
private HashMap<String, List<GraphQLQuotedString>> graphQlCache = new HashMap<>();
7575

7676
List<GraphQLQuotedString> getGraphQLUsages(@NotNull PhpClass phpClass) {
7777
List<GraphQLQuotedString> graphQLQuotedStrings = new ArrayList<>();
@@ -83,11 +83,11 @@ List<GraphQLQuotedString> getGraphQLUsages(@NotNull PhpClass phpClass) {
8383

8484
List<GraphQLQuotedString> getUsages(@NotNull PhpClass phpClass) {
8585
String phpClassFQN = phpClass.getFQN();
86-
if (!routesCache.containsKey(phpClassFQN)) {
86+
if (!graphQlCache.containsKey(phpClassFQN)) {
8787
List<GraphQLQuotedString> graphQLStringValues = extractGraphQLQuotesStringsForClass(phpClass);
88-
routesCache.put(phpClassFQN, graphQLStringValues);
88+
graphQlCache.put(phpClassFQN, graphQLStringValues);
8989
}
90-
return routesCache.get(phpClassFQN);
90+
return graphQlCache.get(phpClassFQN);
9191
}
9292

9393
List<GraphQLQuotedString> extractGraphQLQuotesStringsForClass(@NotNull PhpClass phpClass) {

src/com/magento/idea/magento2plugin/stubs/indexes/graphql/GraphQlResolverIndex.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public DataIndexer<String, Void, FileContent> getIndexer() {
3434
return inputData -> {
3535
Map<String, Void> map = new HashMap<>();
3636

37-
GraphQLFile qraphQLFile = (GraphQLFile) inputData.getPsiFile();
38-
PsiElement[] children = qraphQLFile.getChildren();
37+
GraphQLFile graphQLFile = (GraphQLFile) inputData.getPsiFile();
38+
PsiElement[] children = graphQLFile.getChildren();
3939
for (PsiElement child : children) {
40-
if (!(child instanceof GraphQLObjectTypeDefinition)) {
40+
if (!(child instanceof GraphQLObjectTypeDefinition) && !(child instanceof GraphQLInterfaceTypeDefinition)) {
4141
continue;
4242
}
4343
PsiElement[] objectChildren = child.getChildren();

0 commit comments

Comments
 (0)