use of com.google.idea.blaze.base.lang.buildfile.search.BlazePackage in project intellij by bazelbuild.
the class LabelReference method getSkylarkExtensionLookups.
private BuildLookupElement[] getSkylarkExtensionLookups(String labelString) {
if (!skylarkExtensionReference(myElement)) {
return BuildLookupElement.EMPTY_ARRAY;
}
String packagePrefix = LabelUtils.getPackagePathComponent(labelString);
BuildFile parentFile = myElement.getContainingFile();
if (parentFile == null) {
return BuildLookupElement.EMPTY_ARRAY;
}
BlazePackage containingPackage = BlazePackage.getContainingPackage(parentFile);
if (containingPackage == null) {
return BuildLookupElement.EMPTY_ARRAY;
}
BuildFile referencedBuildFile = LabelUtils.getReferencedBuildFile(containingPackage.buildFile, packagePrefix);
// Directories before the colon are already covered.
// We're only concerned with package-local directories.
boolean hasColon = labelString.indexOf(':') != -1;
VirtualFileFilter filter = file -> ("bzl".equals(file.getExtension()) && !file.getPath().equals(parentFile.getFilePath())) || (hasColon && file.isDirectory());
FileLookupData lookupData = FileLookupData.packageLocalFileLookup(labelString, myElement, referencedBuildFile, filter);
return lookupData != null ? getReferenceManager().resolvePackageLookupElements(lookupData) : BuildLookupElement.EMPTY_ARRAY;
}
Aggregations