Skip to content

Commit

Permalink
fix(qsync): Enable basic syntax highlighting in 'analysis disabled' m…
Browse files Browse the repository at this point in the history
…ode (#6941)

* fix(qsync): Enable basic syntax highlighting in 'analysis disabled' mode

* fix(qsync): Less configsing registry key

* Fix xml tag in blaze-base.xml
  • Loading branch information
Tomasz Pasternak authored Oct 29, 2024
1 parent 22a4474 commit 13b1799
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/src/META-INF/blaze-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
<codeInsight.lineMarkerProvider
language="BUILD"
implementationClass="com.google.idea.blaze.base.query.MacroLineMarkerProvider"/>
<defaultHighlightingSettingProvider implementation="com.google.idea.blaze.base.qsync.QuerySyncHighlightingSettingProvider" order="first"/>
<lookup.charFilter implementation="com.google.idea.blaze.base.lang.buildfile.completion.BuildLabelCharFilter"/>
<runLineMarkerContributor
language="BUILD"
Expand Down Expand Up @@ -409,6 +410,9 @@
<registryKey defaultValue="true"
description="Causes the plugin to read external workspace data, enabling features such as code completion for external targets. This may incur the cost of an additional 'bazel mod' call, which could cause issues with older versions or setups."
key="bazel.read.external.workspace.data"/>
<registryKey defaultValue="true"
description="Enable basic syntax highliting in Query Sync's 'Analysis Disabled' mode"
key="bazel.qsync.enable.basic.highlighting.in.non.analysis.mode"/>
<editorNotificationProvider implementation="com.google.idea.blaze.base.wizard2.BazelNotificationProvider"/>
</extensions>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

}
}

0 comments on commit 13b1799

Please sign in to comment.