[platform cleanup] simplify enum values' names of CanISilentlyChange.Result

UH_HUH, UH_UH are not very common words, let's use YES and NO instead.

GitOrigin-RevId: 994a97928c3d2c4a2836f908162ba1b2d97129aa
This commit is contained in:
Max Medvedev
2024-05-03 11:11:39 +02:00
committed by intellij-monorepo-bot
parent 22eb80d15b
commit 56ca3fc2ef
2 changed files with 13 additions and 12 deletions

View File

@@ -51,12 +51,13 @@ final class CanISilentlyChange {
}
enum Result {
UH_HUH, UH_UH, ONLY_WHEN_IN_CONTENT;
YES, NO, ONLY_WHEN_IN_CONTENT;
// can call from any thread
boolean canIReally(boolean isInContent, @NotNull ThreeState extensionsAllowToChangeFileSilently) {
return switch (this) {
case UH_HUH -> extensionsAllowToChangeFileSilently != ThreeState.NO;
case UH_UH -> false;
case YES -> extensionsAllowToChangeFileSilently != ThreeState.NO;
case NO -> false;
case ONLY_WHEN_IN_CONTENT -> extensionsAllowToChangeFileSilently != ThreeState.NO && isInContent;
};
}
@@ -67,14 +68,14 @@ final class CanISilentlyChange {
Project project = file.getProject();
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return Result.UH_UH;
return Result.NO;
}
if (file instanceof PsiCodeFragment) {
return Result.UH_HUH;
return Result.YES;
}
if (ScratchUtil.isScratch(virtualFile)) {
return canUndo(virtualFile, project) ? Result.UH_HUH : Result.UH_UH;
return canUndo(virtualFile, project) ? Result.YES : Result.NO;
}
return canUndo(virtualFile, project) ? Result.ONLY_WHEN_IN_CONTENT : Result.UH_UH;
return canUndo(virtualFile, project) ? Result.ONLY_WHEN_IN_CONTENT : Result.NO;
}
}

View File

@@ -119,7 +119,7 @@ public final class HighlightingSessionImpl implements HighlightingSession {
Map<PsiFile, HighlightingSession> map = progressIndicator.getUserData(HIGHLIGHTING_SESSION);
HighlightingSession session = map == null ? null : map.get(psiFile);
if (session == null) {
createHighlightingSession(psiFile, progressIndicator, null, visibleRange, CanISilentlyChange.Result.UH_UH, 0);
createHighlightingSession(psiFile, progressIndicator, null, visibleRange, CanISilentlyChange.Result.NO, 0);
}
}
@@ -162,8 +162,8 @@ public final class HighlightingSessionImpl implements HighlightingSession {
ApplicationManager.getApplication().assertIsNonDispatchThread();
DaemonProgressIndicator indicator = GlobalInspectionContextBase.assertUnderDaemonProgress();
HighlightingSessionImpl session = createHighlightingSession(file, indicator, editorColorsScheme, visibleRange, canChangeFileSilently
? CanISilentlyChange.Result.UH_HUH
: CanISilentlyChange.Result.UH_UH,
? CanISilentlyChange.Result.YES
: CanISilentlyChange.Result.NO,
0);
try {
session.additionalSetupFromBackground(file);
@@ -187,8 +187,8 @@ public final class HighlightingSessionImpl implements HighlightingSession {
}
DaemonProgressIndicator indicator = GlobalInspectionContextBase.assertUnderDaemonProgress();
HighlightingSessionImpl session = createHighlightingSession(file, indicator, editorColorsScheme, visibleRange, canChangeFileSilently
? CanISilentlyChange.Result.UH_HUH
: CanISilentlyChange.Result.UH_UH,
? CanISilentlyChange.Result.YES
: CanISilentlyChange.Result.NO,
0);
session.myInContent = true;
try {