Skip to content

Commit 484a05f

Browse files
committed
Make resources also handle absolute labels
1 parent 794f5f5 commit 484a05f

File tree

1 file changed

+12
-8
lines changed
  • bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/projects

1 file changed

+12
-8
lines changed

bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/projects/JavaProjectInfo.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ public JavaSourceInfo getTestSourceInfo() {
291291
"Test source info not computed. Did you call analyzeProjectRecommendations?");
292292
}
293293

294+
private Entry newLabelEntry(String relativeOrAbsoluteLabel) {
295+
// handle absolute labels first
296+
var mayBeAbsoluteLaybel = Label.createIfValid(relativeOrAbsoluteLabel);
297+
if (mayBeAbsoluteLaybel != null) {
298+
return new LabelEntry(new BazelLabel(mayBeAbsoluteLaybel.toString()));
299+
}
300+
// treat as relative label
301+
return new LabelEntry(bazelPackage.getBazelTarget(relativeOrAbsoluteLabel).getLabel());
302+
}
303+
294304
/**
295305
* Checks whether the specified string is a label pointing into this package of this project and make it relative in
296306
* this case.
@@ -393,13 +403,7 @@ private Entry toJavaSourceFileOrLabelEntry(String srcFileOrLabel) throws CoreExc
393403

394404
// treat as label if it looks like one
395405
if (shouldTreatAsLabel(srcFileOrLabel)) {
396-
// handle absolute labels first
397-
var mayBeAbsoluteLaybel = Label.createIfValid(srcFileOrLabel);
398-
if (mayBeAbsoluteLaybel != null) {
399-
return new LabelEntry(new BazelLabel(mayBeAbsoluteLaybel.toString()));
400-
}
401-
// treat as relative label
402-
return new LabelEntry(bazelPackage.getBazelTarget(srcFileOrLabel).getLabel());
406+
return newLabelEntry(srcFileOrLabel);
403407
}
404408

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

412416
// treat as label if it looks like one
413417
if (shouldTreatAsLabel(srcFileOrLabel)) {
414-
return new LabelEntry(bazelPackage.getBazelTarget(srcFileOrLabel).getLabel());
418+
return newLabelEntry(srcFileOrLabel);
415419
}
416420

417421
// treat as file

0 commit comments

Comments
 (0)