Skip to content

Commit 0b678ad

Browse files
committed
Don't show the .graphqlconfig "not included" editor notification before the configuration has been initialized (#164)
1 parent 3e7933b commit 0b678ad

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/com/intellij/lang/jsgraphql/ide/notifications/GraphQLScopeEditorNotificationProvider.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.intellij.openapi.actionSystem.ActionPlaces;
1818
import com.intellij.openapi.actionSystem.AnActionEvent;
1919
import com.intellij.openapi.fileEditor.FileEditor;
20+
import com.intellij.openapi.project.DumbService;
2021
import com.intellij.openapi.project.Project;
2122
import com.intellij.openapi.util.Key;
2223
import com.intellij.openapi.util.Ref;
@@ -57,7 +58,11 @@ public JComponent createNotificationPanel(@NotNull VirtualFile file, @NotNull Fi
5758
}
5859

5960
private boolean showNotification(@NotNull VirtualFile file) {
60-
if (!isGraphQLRelatedFile(file)) {
61+
if (!isGraphQLRelatedFile(file) || DumbService.getInstance(myProject).isDumb()) {
62+
return false;
63+
}
64+
final GraphQLConfigManager graphQLConfigManager = GraphQLConfigManager.getService(myProject);
65+
if (!graphQLConfigManager.isInitialized()) {
6166
return false;
6267
}
6368
if (file.getFileType() != GraphQLFileType.INSTANCE) {
@@ -89,7 +94,6 @@ public void visitElement(PsiElement element) {
8994
}
9095
}
9196
if (GlobalSearchScope.projectScope(myProject).accept(file)) {
92-
final GraphQLConfigManager graphQLConfigManager = GraphQLConfigManager.getService(myProject);
9397
if (graphQLConfigManager.getClosestConfigFile(file) != null) {
9498
if (graphQLConfigManager.getClosestIncludingConfigFile(file) == null) {
9599
// has config, but is not included

src/main/com/intellij/lang/jsgraphql/ide/project/graphqlconfig/GraphQLConfigManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public class GraphQLConfigManager {
101101
private final GraphQLConfigGlobMatcher graphQLConfigGlobMatcher;
102102
public final IdeaPluginDescriptor pluginDescriptor;
103103

104+
private volatile boolean initialized = false;
105+
104106
private volatile Map<VirtualFile, GraphQLConfigData> configPathToConfigurations = Maps.newConcurrentMap();
105107
private volatile Map<GraphQLResolvedConfigData, GraphQLFile> configDataToEntryFiles = Maps.newConcurrentMap();
106108
private volatile Map<GraphQLResolvedConfigData, GraphQLConfigPackageSet> configDataToPackageset = Maps.newConcurrentMap();
@@ -117,6 +119,10 @@ public static GraphQLConfigManager getService(@NotNull Project project) {
117119
return ServiceManager.getService(project, GraphQLConfigManager.class);
118120
}
119121

122+
public boolean isInitialized() {
123+
return initialized;
124+
}
125+
120126
/**
121127
* Gets the closest .graphqlconfig{.yml,.yaml} file that includes the specified file
122128
*
@@ -428,6 +434,8 @@ public void buildConfigurationModel(@Nullable List<VirtualFile> changedConfigura
428434
myProject.getMessageBus().syncPublisher(TOPIC).onGraphQLConfigurationFileChanged();
429435
myProject.getMessageBus().syncPublisher(JSGraphQLConfigurationListener.TOPIC).onEndpointsChanged();
430436

437+
initialized = true;
438+
431439
EditorNotifications.getInstance(myProject).updateAllNotifications();
432440
}
433441

0 commit comments

Comments
 (0)