Skip to content

Commit

Permalink
Make resources also handle absolute labels
Browse files Browse the repository at this point in the history
  • Loading branch information
guw committed Dec 14, 2024
1 parent 794f5f5 commit 484a05f
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ public JavaSourceInfo getTestSourceInfo() {
"Test source info not computed. Did you call analyzeProjectRecommendations?");
}

private Entry newLabelEntry(String relativeOrAbsoluteLabel) {
// handle absolute labels first
var mayBeAbsoluteLaybel = Label.createIfValid(relativeOrAbsoluteLabel);
if (mayBeAbsoluteLaybel != null) {
return new LabelEntry(new BazelLabel(mayBeAbsoluteLaybel.toString()));
}
// treat as relative label
return new LabelEntry(bazelPackage.getBazelTarget(relativeOrAbsoluteLabel).getLabel());
}

/**
* Checks whether the specified string is a label pointing into this package of this project and make it relative in
* this case.
Expand Down Expand Up @@ -393,13 +403,7 @@ private Entry toJavaSourceFileOrLabelEntry(String srcFileOrLabel) throws CoreExc

// treat as label if it looks like one
if (shouldTreatAsLabel(srcFileOrLabel)) {
// handle absolute labels first
var mayBeAbsoluteLaybel = Label.createIfValid(srcFileOrLabel);
if (mayBeAbsoluteLaybel != null) {
return new LabelEntry(new BazelLabel(mayBeAbsoluteLaybel.toString()));
}
// treat as relative label
return new LabelEntry(bazelPackage.getBazelTarget(srcFileOrLabel).getLabel());
return newLabelEntry(srcFileOrLabel);
}

// treat as file
Expand All @@ -411,7 +415,7 @@ private Entry toResourceFileOrLabelEntry(String srcFileOrLabel, String resourceS

// treat as label if it looks like one
if (shouldTreatAsLabel(srcFileOrLabel)) {
return new LabelEntry(bazelPackage.getBazelTarget(srcFileOrLabel).getLabel());
return newLabelEntry(srcFileOrLabel);
}

// treat as file
Expand Down

0 comments on commit 484a05f

Please sign in to comment.