6
6
import com .intellij .patterns .PlatformPatterns ;
7
7
import com .intellij .psi .PsiElement ;
8
8
import com .intellij .psi .PsiFile ;
9
+ import com .jetbrains .php .lang .psi .elements .Method ;
10
+ import com .jetbrains .php .lang .psi .elements .PhpClass ;
9
11
import fr .adrienbrault .idea .symfony2plugin .Symfony2ProjectComponent ;
10
12
import fr .adrienbrault .idea .symfony2plugin .TwigHelper ;
11
13
import fr .adrienbrault .idea .symfony2plugin .stubs .ContainerCollectionResolver ;
18
20
import org .jetbrains .yaml .YAMLLanguage ;
19
21
import org .jetbrains .yaml .YAMLTokenTypes ;
20
22
21
- import java .util .ArrayList ;
22
- import java .util .Arrays ;
23
- import java .util .Collection ;
24
- import java .util .List ;
23
+ import java .util .*;
25
24
26
25
/**
27
26
* @author Daniel Espendiller <daniel@espendiller.net>
@@ -61,7 +60,7 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
61
60
}
62
61
63
62
if (psiText .contains ("\\ " )) {
64
- psiElements .addAll (Arrays . asList ( classGoToDeclaration (psiElement , psiText ) )) ;
63
+ psiElements .addAll (classGoToDeclaration (psiElement , psiText )) ;
65
64
}
66
65
67
66
if (psiText .endsWith (".twig" ) || psiText .endsWith (".php" )) {
@@ -71,8 +70,30 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
71
70
return psiElements .toArray (new PsiElement [psiElements .size ()]);
72
71
}
73
72
74
- protected PsiElement [] classGoToDeclaration (PsiElement psiElement , String className ) {
75
- return PhpElementsUtil .getClassInterfacePsiElements (psiElement .getProject (), className );
73
+ protected Collection <PsiElement > classGoToDeclaration (PsiElement psiElement , String className ) {
74
+
75
+ Collection <PsiElement > psiElements = new HashSet <PsiElement >();
76
+
77
+ // Class::method
78
+ // Class::FooAction
79
+ // Class:Foo
80
+ if (className .contains (":" )) {
81
+ String [] split = className .replaceAll ("(:)\\ 1" , "$1" ).split (":" );
82
+ if (split .length == 2 ) {
83
+ for (String append : new String [] {"" , "Action" }) {
84
+ Method classMethod = PhpElementsUtil .getClassMethod (psiElement .getProject (), split [0 ], split [1 ] + append );
85
+ if (classMethod != null ) {
86
+ psiElements .add (classMethod );
87
+ }
88
+ }
89
+ }
90
+
91
+ return psiElements ;
92
+ }
93
+
94
+ // ClassName
95
+ psiElements .addAll (PhpElementsUtil .getClassesInterface (psiElement .getProject (), className ));
96
+ return psiElements ;
76
97
}
77
98
78
99
protected PsiElement [] serviceGoToDeclaration (PsiElement psiElement , String serviceId ) {
0 commit comments