[grazie] IJPL-229739 Remove option to enable / disable spellchecking in commit messages

Merge-request: IJ-MR-189274
Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com>

GitOrigin-RevId: e38c0adc28ff8915cb7487f7485e260c0500615a
This commit is contained in:
Ilia Permiashkin
2026-01-27 18:23:19 +00:00
committed by intellij-monorepo-bot
parent 146c3fb156
commit 0b4086bf58
4 changed files with 2 additions and 70 deletions
@@ -137,7 +137,6 @@
<vcs.commitMessageInspection implementation="com.intellij.vcs.commit.message.SubjectBodySeparationInspection"/>
<vcs.commitMessageInspection implementation="com.intellij.vcs.commit.message.SubjectLimitInspection"/>
<vcs.commitMessageInspection implementation="com.intellij.vcs.commit.message.BodyLimitInspection"/>
<vcs.commitMessageInspection implementation="com.intellij.vcs.commit.message.CommitMessageSpellCheckingInspection"/>
<referenceProviderType key="commentsReferenceProvider"
implementationClass="com.intellij.psi.impl.source.resolve.reference.ArbitraryPlaceUrlReferenceProvider"/>
@@ -1,67 +0,0 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.vcs.commit.message;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.LocalInspectionToolSession;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.NullableLazyValue;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static com.intellij.openapi.util.NullableLazyValue.atomicLazyNullable;
@ApiStatus.Internal
public final class CommitMessageSpellCheckingInspection extends BaseCommitMessageInspection {
private static final Logger LOG = Logger.getInstance(CommitMessageSpellCheckingInspection.class);
private static final NullableLazyValue<LocalInspectionTool> ourSpellCheckingInspection = atomicLazyNullable(() -> {
List<InspectionToolWrapper<?, ?>> tools = InspectionToolRegistrar.getInstance().createTools();
InspectionToolWrapper<?, ?> spellCheckingWrapper = ContainerUtil.find(tools, wrapper -> wrapper.getShortName().equals("SpellCheckingInspection"));
if (spellCheckingWrapper == null) {
LOG.info("Could not find default spell checking inspection");
}
else if (!(spellCheckingWrapper instanceof LocalInspectionToolWrapper)) {
LOG.info("Found spell checking wrapper is not local " + spellCheckingWrapper);
}
else {
return ((LocalInspectionToolWrapper)spellCheckingWrapper).getTool();
}
return null;
});
@Override
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder,
boolean isOnTheFly,
@NotNull LocalInspectionToolSession session) {
LocalInspectionTool tool = ourSpellCheckingInspection.getValue();
return tool != null ? tool.buildVisitor(holder, isOnTheFly, session) : super.buildVisitor(holder, isOnTheFly, session);
}
@Override
public @Nls @NotNull String getDisplayName() {
return VcsBundle.message("inspection.CommitMessageSpellCheckingInspection.display.name");
}
@Override
public @NotNull HighlightDisplayLevel getDefaultLevel() {
return ObjectUtils.notNull(HighlightDisplayLevel.find("TYPO"), HighlightDisplayLevel.WARNING);
}
@Override
public boolean isEnabledByDefault() {
return true;
}
}
@@ -18,6 +18,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.ui.CommitMessage;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.util.CachedValuesManager;
@@ -101,7 +102,7 @@ public final class GrazieSpellCheckingInspection extends SpellCheckingInspection
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder,
boolean isOnTheFly,
@NotNull LocalInspectionToolSession session) {
if (!Registry.is("spellchecker.inspection.enabled", true) ||
if (CommitMessage.isCommitMessage(session.getFile()) ||
InspectionProfileManager.hasTooLowSeverity(session, this) ||
InjectedLanguageManager.getInstance(holder.getProject()).isFrankensteinInjection(holder.getFile())) {
return PsiElementVisitor.EMPTY_VISITOR;
@@ -33,7 +33,6 @@
<spellchecker.dictionaryLayersProvider implementation="com.intellij.spellchecker.PlatformSettingsDictionaryLayersProvider" order="first"/>
<registryKey key="spellchecker.corrections.limit" defaultValue="3" description="Spellchecker corrections limit" restartRequired="false"/>
<registryKey key="spellchecker.inspection.enabled" defaultValue="true" description="Enable spellchecking inspection" restartRequired="false"/>
<registryKey key="spellchecker.use.standard.project.dictionary.name" defaultValue="true" description="Enables single project dictionary file"
restartRequired="false"/>