use of com.intellij.psi.impl.source.resolve.reference.impl.providers.PackageReferenceSet in project intellij-community by JetBrains.
the class PsiPackageConverter method createReferences.
@NotNull
public PsiReference[] createReferences(GenericDomValue<PsiPackage> genericDomValue, PsiElement element, ConvertContext context) {
final String s = genericDomValue.getStringValue();
if (s == null) {
return PsiReference.EMPTY_ARRAY;
}
GlobalSearchScope scope = context.getSearchScope();
return new PackageReferenceSet(s, element, ElementManipulators.getOffsetInElement(element), scope != null ? scope : GlobalSearchScope.allScope(element.getProject())).getPsiReferences();
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.PackageReferenceSet in project intellij-plugins by JetBrains.
the class BasePackageParser method getPackageReferences.
protected static PsiReference[] getPackageReferences(PsiElement psiElement) {
String packageName = psiElement.getText();
if (StringUtil.isEmptyOrSpaces(packageName)) {
return PsiReference.EMPTY_ARRAY;
}
int offset = 0;
if (packageName.charAt(0) == '!') {
packageName = packageName.substring(1);
offset = 1;
}
int size = packageName.length() - 1;
if (packageName.charAt(size) == '?') {
packageName = packageName.substring(0, size);
}
PackageReferenceSet refSet = new PackageReferenceSet(packageName, psiElement, offset) {
@Override
public Collection<PsiPackage> resolvePackageName(@Nullable PsiPackage context, String packageName) {
if (context == null)
return Collections.emptyList();
String unwrappedPackageName = packageName.replaceAll("\\s+", "");
return ContainerUtil.filter(context.getSubPackages(), pkg -> unwrappedPackageName.equals(pkg.getName()));
}
};
return refSet.getReferences().toArray(new PsiPackageReference[0]);
}
Aggregations