From da499b2133a3b84c82ddb4f06085652769097d3a Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 30 Nov 2023 09:24:36 -0800 Subject: [PATCH] Use IJ `getExtension` instead of defining our own. PiperOrigin-RevId: 586697303 --- .../qsync/cache/JavaSourcesArchiveCacheLayout.java | 12 +++--------- .../base/qsync/cache/JavaSourcesCacheLayout.java | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesArchiveCacheLayout.java b/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesArchiveCacheLayout.java index 0d40a9dc700..a038517cfcc 100644 --- a/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesArchiveCacheLayout.java +++ b/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesArchiveCacheLayout.java @@ -15,6 +15,8 @@ */ package com.google.idea.blaze.base.qsync.cache; +import static com.intellij.openapi.util.io.FileUtilRt.getExtension; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.idea.blaze.base.command.buildresult.OutputArtifactInfo; @@ -39,20 +41,12 @@ public JavaSourcesArchiveCacheLayout(Path cacheDirectory) { this.cacheDirectory = cacheDirectory; } - private static String getExtension(Path p) { - String name = p.getFileName().toString(); - if (name.contains(".")) { - return name.substring(name.indexOf('.') + 1); - } - return ""; - } - @Nullable @Override public OutputArtifactDestinationAndLayout getOutputArtifactDestinationAndLayout( OutputArtifactInfo outputArtifact) { Path artifactPath = Path.of(outputArtifact.getRelativePath()); - if (!JAVA_ARCHIVE_EXTENSIONS.contains(getExtension(artifactPath))) { + if (!JAVA_ARCHIVE_EXTENSIONS.contains(getExtension(artifactPath.toString()))) { return null; } String key = CacheDirectoryManager.cacheKeyForArtifact(outputArtifact); diff --git a/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesCacheLayout.java b/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesCacheLayout.java index 7206de6915e..9b2d95b6001 100644 --- a/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesCacheLayout.java +++ b/base/src/com/google/idea/blaze/base/qsync/cache/JavaSourcesCacheLayout.java @@ -15,6 +15,8 @@ */ package com.google.idea.blaze.base.qsync.cache; +import static com.intellij.openapi.util.io.FileUtilRt.getExtension; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.idea.blaze.base.command.buildresult.OutputArtifactInfo; @@ -40,20 +42,12 @@ public JavaSourcesCacheLayout(Path cacheDirectory) { this.dotCacheDirectory = cacheDirectory.resolveSibling("." + cacheDirectory.getFileName()); } - private static String getExtension(Path p) { - String name = p.getFileName().toString(); - if (name.contains(".")) { - return name.substring(name.indexOf('.') + 1); - } - return ""; - } - @Nullable @Override public OutputArtifactDestinationAndLayout getOutputArtifactDestinationAndLayout( OutputArtifactInfo outputArtifact) { Path artifactPath = Path.of(outputArtifact.getRelativePath()); - if (!JAVA_EXTENSIONS.contains(getExtension(artifactPath))) { + if (!JAVA_EXTENSIONS.contains(getExtension(artifactPath.toString()))) { return null; } String key = CacheDirectoryManager.cacheKeyForArtifact(outputArtifact);