77import com .intellij .psi .PsiFile ;
88import com .intellij .psi .search .FilenameIndex ;
99import com .intellij .psi .search .GlobalSearchScope ;
10+ import org .jetbrains .annotations .NotNull ;
1011import org .jetbrains .annotations .Nullable ;
1112
1213import java .util .Arrays ;
@@ -19,12 +20,17 @@ public class PathResourceGotoDeclarationHandler implements GotoDeclarationHandle
1920 @ Override
2021 public PsiElement [] getGotoDeclarationTargets (@ Nullable PsiElement sourceElement , int offset , Editor editor ) {
2122 if (!isExtResourcePath (sourceElement )) {
22- return new PsiElement [ 0 ] ;
23+ return emptyPsiElementArray () ;
2324 }
2425
2526 if (sourceElement != null ) {
2627 String text = sourceElement .getText ();
27- String fileName = text .split ("/" )[text .split ("/" ).length - 1 ];
28+ String [] strings = text .split ("/" );
29+ if (strings .length == 0 ) {
30+ return emptyPsiElementArray ();
31+ }
32+
33+ String fileName = strings [strings .length - 1 ];
2834 String relativePath = text .replaceFirst ("EXT:" , "" );
2935
3036 List <PsiFile > psiFiles = Arrays .asList (
@@ -40,6 +46,11 @@ public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement sourceElement
4046 .toArray (PsiElement []::new );
4147 }
4248
49+ return emptyPsiElementArray ();
50+ }
51+
52+ @ NotNull
53+ private PsiElement [] emptyPsiElementArray () {
4354 return new PsiElement [0 ];
4455 }
4556
0 commit comments