From 0ed05175fe377dec455da10e98425aa6c09877c5 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 3 Nov 2025 10:38:21 +0100 Subject: [PATCH] [openapi] clean up CompilerPaths: add some nullability annotations GitOrigin-RevId: fc0fce165afe9019050c54d6e2d665b2eca43f5e --- .../com/intellij/openapi/compiler/CompilerPaths.java | 10 +++++----- .../intellij/byteCodeViewer/ByteCodeViewerManager.kt | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java index 56b890ad834b..7d2a735bb6f7 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java @@ -37,14 +37,14 @@ public class CompilerPaths { /** * @return a root directory where generated files for various compilers are stored */ - public static File getGeneratedDataDirectory(Project project) { + public static @NotNull File getGeneratedDataDirectory(@NotNull Project project) { return new File(getCompilerSystemDirectory(project), ".generated"); } /** * @return a root directory where compiler caches for the given project are stored */ - public static @NotNull File getCacheStoreDirectory(final Project project) { + public static @NotNull File getCacheStoreDirectory(@NotNull Project project) { return new File(getCompilerSystemDirectory(project), ".caches"); } @@ -92,7 +92,7 @@ public class CompilerPaths { * The same as {@link #getModuleOutputDirectory} but returns String. * The method still returns a non-null value if the output path is specified in Settings but does not exist on disk. */ - public static @Nullable String getModuleOutputPath(Module module, boolean forTestClasses) { + public static @Nullable String getModuleOutputPath(@Nullable Module module, boolean forTestClasses) { final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module); if (extension == null) { return null; @@ -122,7 +122,7 @@ public class CompilerPaths { return outPathUrl != null ? VirtualFileManager.extractPath(outPathUrl) : null; } - public static @Nullable String getAnnotationProcessorsGenerationPath(Module module, boolean forTests) { + public static @Nullable String getAnnotationProcessorsGenerationPath(@NotNull Module module, boolean forTests) { final AnnotationProcessingConfiguration config = CompilerConfiguration .getInstance(module.getProject()) .getAnnotationProcessingConfiguration(module); @@ -148,7 +148,7 @@ public class CompilerPaths { return StringUtil.isEmpty(sourceDirName) ? path : path + "/" + sourceDirName; } - public static String @NotNull [] getOutputPaths(Module @NotNull [] modules) { + public static @NotNull String @NotNull [] getOutputPaths(@NotNull Module @NotNull [] modules) { Set outputPaths = new OrderedSet<>(); for (Module module : modules) { CompilerModuleExtension compilerModuleExtension = !module.isDisposed() ? CompilerModuleExtension.getInstance(module) : null; diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt index e4d70b38640b..1d0e74aa5a65 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt @@ -50,7 +50,6 @@ public object ByteCodeViewerManager { val fileIndex = ProjectFileIndex.getInstance(psiClass.project) val module = fileIndex.getModuleForFile(file) ?: return null for (compilerOutputPath in CompilerPaths.getOutputPaths(arrayOf(module))) { - if (compilerOutputPath == null) continue val classRoot = VirtualFileManager.getInstance().findFileByNioPath(Path.of(compilerOutputPath)) ?: continue val relativeClassFilePath = jvmClassName.replace('.', '/') + ".class" val classFile = classRoot.resolveFromRootOrRelative(relativeClassFilePath)