use of com.perl5.lang.perl.extensions.packageprocessor.PerlLibProvider in project Perl5-IDEA by Camelcade.
the class PerlPackageUtil method getIncDirsForPsiElement.
/**
* Returns List of lib directories including class roots, current directory and use lib ones
*
* @param psiElement to resolve for
* @return list of lib dirs
*/
@NotNull
public static List<VirtualFile> getIncDirsForPsiElement(@NotNull PsiElement psiElement) {
PsiFile psiFile = psiElement.getContainingFile().getOriginalFile();
List<VirtualFile> result = new ArrayList<>();
// libdirs providers fixme we need to use stubs or psi here
for (PerlUseStatement useStatement : PsiTreeUtil.findChildrenOfType(psiFile, PerlUseStatement.class)) {
PerlPackageProcessor packageProcessor = useStatement.getPackageProcessor();
if (packageProcessor instanceof PerlLibProvider) {
((PerlLibProvider) packageProcessor).addLibDirs(useStatement, result);
}
}
// classpath
result.addAll(PerlProjectManager.getInstance(psiElement.getProject()).getAllLibraryRoots());
// current dir
if (PerlSharedSettings.getInstance(psiFile.getProject()).getTargetPerlVersion().lesserThan(PerlVersion.V5_26)) {
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null && virtualFile.getParent() != null) {
result.add(virtualFile.getParent());
}
}
return result;
}
Aggregations