[openapi] clean up CompilerPaths: add some nullability annotations

GitOrigin-RevId: fc0fce165afe9019050c54d6e2d665b2eca43f5e
This commit is contained in:
Bartek Pacia
2025-11-03 12:07:21 +00:00
committed by intellij-monorepo-bot
parent 8679ed6861
commit 0ed05175fe
2 changed files with 5 additions and 6 deletions
@@ -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<String> outputPaths = new OrderedSet<>();
for (Module module : modules) {
CompilerModuleExtension compilerModuleExtension = !module.isDisposed() ? CompilerModuleExtension.getInstance(module) : null;
@@ -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)