From 13b179917e052ed4ec6e02ea2b7d6b485bd3562a Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Tue, 29 Oct 2024 21:57:53 +0100 Subject: [PATCH] fix(qsync): Enable basic syntax highlighting in 'analysis disabled' mode (#6941) * fix(qsync): Enable basic syntax highlighting in 'analysis disabled' mode * fix(qsync): Less configsing registry key * Fix xml tag in blaze-base.xml --- base/src/META-INF/blaze-base.xml | 4 +++ .../qsync/QuerySyncHighlightingFilter.java | 4 +++ .../QuerySyncHighlightingSettingProvider.java | 25 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingSettingProvider.java diff --git a/base/src/META-INF/blaze-base.xml b/base/src/META-INF/blaze-base.xml index 91966665d5f..381d9ce2bc6 100644 --- a/base/src/META-INF/blaze-base.xml +++ b/base/src/META-INF/blaze-base.xml @@ -377,6 +377,7 @@ + + diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingFilter.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingFilter.java index a51382116a4..6e6bc5a96e8 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingFilter.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingFilter.java @@ -19,6 +19,7 @@ import com.google.idea.blaze.base.settings.BlazeImportSettings.ProjectType; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter; +import com.intellij.openapi.util.registry.Registry; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,6 +29,9 @@ public class QuerySyncHighlightingFilter implements HighlightInfoFilter { @Override public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile psiFile) { + if(Registry.is("bazel.qsync.enable.basic.highlighting.in.non.analysis.mode")) { + return true; + } if (psiFile == null) { return true; } diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingSettingProvider.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingSettingProvider.java new file mode 100644 index 00000000000..57d76863868 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncHighlightingSettingProvider.java @@ -0,0 +1,25 @@ +package com.google.idea.blaze.base.qsync; + +import com.google.idea.blaze.base.settings.Blaze; +import com.google.idea.blaze.base.settings.BlazeImportSettings; +import com.intellij.codeInsight.daemon.impl.analysis.DefaultHighlightingSettingProvider; +import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class QuerySyncHighlightingSettingProvider extends DefaultHighlightingSettingProvider { + @Override + public @Nullable FileHighlightingSetting getDefaultSetting(@NotNull Project project, @NotNull VirtualFile file) { + var psiFile = PsiManager.getInstance(project).findFile(file); + if (Blaze.getProjectType(psiFile.getProject()) == BlazeImportSettings.ProjectType.QUERY_SYNC) { + if(!QuerySyncManager.getInstance(psiFile.getProject()).isReadyForAnalysis(psiFile)){ + return FileHighlightingSetting.ESSENTIAL; + } + } + return null; + + } +}