From f821605ec8919529ef74891c9b4d5e1c847cbdff Mon Sep 17 00:00:00 2001 From: Elena Shaverdova Date: Wed, 27 Mar 2024 21:13:46 +0100 Subject: [PATCH] Minimize nullability of parameters for StubInconsistencyReportUtil.reportStubTreeAndIndexDoNotMatch for IDEA-331326 GitOrigin-RevId: 47bb118c811852bcc96453bd03113f7a7b1370c0 --- .../intellij/psi/stubs/StubInconsistencyReporter.java | 2 +- .../src/com/intellij/psi/stubs/StubTreeLoader.java | 6 +++--- .../com/intellij/psi/stubs/StubProcessingHelperBase.java | 4 ++-- .../indexing/diagnostic/StubInconsistencyReportUtil.kt | 9 ++------- .../diagnostic/StubInconsistencyReporterImpl.java | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/platform/core-impl/src/com/intellij/psi/stubs/StubInconsistencyReporter.java b/platform/core-impl/src/com/intellij/psi/stubs/StubInconsistencyReporter.java index 74dc4a74d46a..1c6648b77c85 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/StubInconsistencyReporter.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/StubInconsistencyReporter.java @@ -80,5 +80,5 @@ public interface StubInconsistencyReporter { */ enum StubTreeAndIndexDoNotMatchSource {FileTreesPsiReconciliation, WrongPsiFileClassInNonPsiStub, ZeroStubIdList, StubPsiCheck} - void reportStubTreeAndIndexDoNotMatch(@NotNull Project project, @Nullable StubTreeAndIndexDoNotMatchSource source); + void reportStubTreeAndIndexDoNotMatch(@NotNull Project project, @NotNull StubTreeAndIndexDoNotMatchSource source); } diff --git a/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java b/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java index c9d13c57bdda..30b682819513 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java @@ -68,7 +68,7 @@ public abstract class StubTreeLoader { @Nullable ObjectStubTree stubTree, @NotNull PsiFileWithStubSupport psiFile, @Nullable Throwable cause, - @Nullable StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source + @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source ) { return ProgressManager.getInstance().computeInNonCancelableSection(() -> { return doCreateCoarseExceptionStubTreeAndIndexDoNotMatch(stubTree, psiFile, cause, source).doCreateCompleteException(); @@ -84,7 +84,7 @@ public abstract class StubTreeLoader { @Nullable ObjectStubTree stubTree, @NotNull PsiFileWithStubSupport psiFile, @Nullable Throwable cause, - @Nullable StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source + @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source ) { return ProgressManager.getInstance().computeInNonCancelableSection(() -> { return doCreateCoarseExceptionStubTreeAndIndexDoNotMatch(stubTree, psiFile, cause, source); @@ -95,7 +95,7 @@ public abstract class StubTreeLoader { @Nullable ObjectStubTree stubTree, @NotNull PsiFileWithStubSupport psiFile, @Nullable Throwable cause, - @Nullable StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source + @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source ) { return ProgressManager.getInstance().computeInNonCancelableSection(() -> { VirtualFile file = psiFile.getViewProvider().getVirtualFile(); diff --git a/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java b/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java index 37f74f708ff5..5dd48396b292 100644 --- a/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java +++ b/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java @@ -82,7 +82,7 @@ public abstract class StubProcessingHelperBase { private boolean checkType(@NotNull Class requiredClass, PsiFile psiFile, @Nullable PsiElement psiElement, @NotNull Computable debugOperationName, @NotNull StubIdList debugStubIdList, - @Nullable StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source) { + @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source) { if (requiredClass.isInstance(psiElement)) return true; String extraMessage = "psiElement is not instance of requiredClass.\n" + @@ -159,7 +159,7 @@ public abstract class StubProcessingHelperBase { @Nullable ObjectStubTree stubTree, @NotNull PsiFileWithStubSupport psiFile, @NotNull String extraMessage, - @Nullable StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source + @NotNull StubInconsistencyReporter.StubTreeAndIndexDoNotMatchSource source ) { try { StubTextInconsistencyException.checkStubTextConsistency(psiFile, SourceOfCheck.WrongTypePsiInStubHelper); diff --git a/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReportUtil.kt b/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReportUtil.kt index 17395e699349..9f62cb7e90af 100644 --- a/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReportUtil.kt +++ b/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReportUtil.kt @@ -47,13 +47,8 @@ object StubInconsistencyReportUtil { ) @JvmStatic - fun reportStubTreeAndIndexDoNotMatch(project: Project, source: StubTreeAndIndexDoNotMatchSource?) { - if (source == null) { - STUB_TREE_AND_INDEX_DO_NOT_MATCH_EVENT.log(project) - } - else { - STUB_TREE_AND_INDEX_DO_NOT_MATCH_EVENT.log(project, EventPair(STUB_TREE_AND_INDEX_DO_NOT_MATCH_SOURCE_FIELD, source)) - } + fun reportStubTreeAndIndexDoNotMatch(project: Project, source: StubTreeAndIndexDoNotMatchSource) { + STUB_TREE_AND_INDEX_DO_NOT_MATCH_EVENT.log(project, EventPair(STUB_TREE_AND_INDEX_DO_NOT_MATCH_SOURCE_FIELD, source)) } private val CHECK_REASON_FIELD = EventFields.Enum("reason") diff --git a/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReporterImpl.java b/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReporterImpl.java index 5e9bf6248877..b8d0870943e8 100644 --- a/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReporterImpl.java +++ b/platform/indexing-impl/src/com/intellij/util/indexing/diagnostic/StubInconsistencyReporterImpl.java @@ -44,7 +44,7 @@ public class StubInconsistencyReporterImpl implements StubInconsistencyReporter } @Override - public void reportStubTreeAndIndexDoNotMatch(@NotNull Project project, @Nullable StubTreeAndIndexDoNotMatchSource source) { + public void reportStubTreeAndIndexDoNotMatch(@NotNull Project project, @NotNull StubTreeAndIndexDoNotMatchSource source) { StubInconsistencyReportUtil.reportStubTreeAndIndexDoNotMatch(project, source); } } \ No newline at end of file