Skip to content

Commit

Permalink
Use IJ getExtension instead of defining our own.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 586697303
  • Loading branch information
Googler authored and copybara-github committed Nov 30, 2023
1 parent e4b55b0 commit da499b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit da499b2

Please sign in to comment.