CPP-44970 Enable ClangFormat without creating .clangformat file doesn't change status bar

GitOrigin-RevId: 7f6aa50f8cde121c03a3b36416a08cb9ce0ce662
This commit is contained in:
Alexey Utkin
2025-06-08 18:57:25 +04:00
committed by intellij-monorepo-bot
parent 5f00a0b869
commit 0d0cd711bb
2 changed files with 23 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ package com.intellij.psi.codeStyle.modifier;
import com.intellij.application.options.CodeStyle;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.ModificationTracker;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
@@ -93,8 +94,18 @@ public final class TransientCodeStyleSettings extends CodeStyleSettings {
applyIndentOptionsFromProviders(file.getProject(), file.getVirtualFile());
}
private static final Key<Boolean> INDENT_OPTIONS_APPLY_PROGRESS = Key.create("INDENT_OPTIONS_APPLY_PROGRESS");
@ApiStatus.Internal
public void applyIndentOptionsFromProviders(@NotNull Project project, @NotNull VirtualFile file) {
if (file.getUserData(INDENT_OPTIONS_APPLY_PROGRESS) != null) {
return;
}
// ClsElementImpl.getIndentSize is called inside document generation procedure,
// which can trigger code style computation based on the document => Stack Overflow.
file.putUserData(INDENT_OPTIONS_APPLY_PROGRESS, Boolean.TRUE);
try {
for (FileIndentOptionsProvider provider : FileIndentOptionsProvider.EP_NAME.getExtensionList()) {
if (provider.useOnFullReformat()) {
IndentOptions indentOptions = provider.getIndentOptions(project, this, file);
@@ -107,6 +118,10 @@ public final class TransientCodeStyleSettings extends CodeStyleSettings {
}
}
}
finally {
file.putUserData(INDENT_OPTIONS_APPLY_PROGRESS, null);
}
}
public void addDependency(@NotNull ModificationTracker dependency) {
myDependencies.add(dependency);

View File

@@ -197,7 +197,7 @@ internal class CodeStyleCachedValueProvider(val fileSupplier: Supplier<VirtualFi
LOG.debug { "Created TransientCodeStyleSettings for ${file.name}" }
for (modifier in CodeStyleSettingsModifier.EP_NAME.extensionList) {
LOG.debug { "Modifying ${file.name}: ${modifier.javaClass.name}" }
if (modifier.modifySettingsAndUiCustomization(modifiableSettings, psiFile)) {
if (modifier.modifySettingsAndUiCustomization(modifiableSettings, psiFile) || modifiableSettings.modifier != null) {
LOG.debug { "Modified ${file.name}: ${modifier.javaClass.name}" }
currSettings = modifiableSettings
}