Minor refactoring: Extract a method for Fileset-specific logic in completion context.
RELNOTES: None
@@ -77,10 +77,23 @@ public abstract class CompletionContext {
if (artifact.isMiddlemanArtifact()) {
continue;
} else if (artifact.isFileset()) {
- if (!expandFilesets()) {
- continue;
+ if (expandFilesets()) {
+ visitFileset(artifact, receiver);
+ }
+ } else if (artifact.isTreeArtifact()) {
+ List<Artifact> expandedArtifacts = new ArrayList<>();
+ expander().expand(artifact, expandedArtifacts);
+ for (Artifact expandedArtifact : expandedArtifacts) {
+ receiver.accept(expandedArtifact);
+ }
+ } else {
+ receiver.accept(artifact);
+ }
+ }
}
- ImmutableList<FilesetOutputSymlink> links = expander().getFileset(artifact);
+
+ private void visitFileset(Artifact filesetArtifact, ArtifactReceiver receiver) {
+ ImmutableList<FilesetOutputSymlink> links = expander().getFileset(filesetArtifact);
FilesetManifest filesetManifest;
try {
filesetManifest =
@@ -95,17 +108,7 @@ public abstract class CompletionContext {
String targetFile = mapping.getValue();
PathFragment locationInFileset = mapping.getKey();
receiver.acceptFilesetMapping(
- artifact, locationInFileset, execRoot().getRelative(targetFile));
- }
- } else if (artifact.isTreeArtifact()) {
- List<Artifact> expandedArtifacts = new ArrayList<>();
- expander().expand(artifact, expandedArtifacts);
- for (Artifact expandedArtifact : expandedArtifacts) {
- receiver.accept(expandedArtifact);
- }
- } else {
- receiver.accept(artifact);
- }
+ filesetArtifact, locationInFileset, execRoot().getRelative(targetFile));
}
}
