File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
src/org/atoum/intellij/plugin/atoum Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import com .intellij .openapi .project .Project ;
4
4
import com .intellij .psi .PsiElement ;
5
- import com .jetbrains .php .lang .psi .elements .ClassReference ;
6
- import com .jetbrains .php .lang .psi .elements .NewExpression ;
7
- import com .jetbrains .php .lang .psi .elements .PhpNamedElement ;
5
+ import com .jetbrains .php .lang .psi .elements .*;
8
6
import com .jetbrains .php .lang .psi .resolve .types .PhpType ;
9
7
import com .jetbrains .php .lang .psi .resolve .types .PhpTypeProvider3 ;
10
8
import org .jetbrains .annotations .Nullable ;
@@ -29,6 +27,26 @@ public PhpType getType(PsiElement psiElement) {
29
27
if (ref != null && ref .getFQN () != null && ref .getFQN ().startsWith ("\\ mock\\ " )) {
30
28
return new PhpType ().add (ref .getFQN ().substring ("\\ mock" .length ()));
31
29
}
30
+ } else if (psiElement instanceof MethodReference ) {
31
+ MethodReference expr = (MethodReference ) psiElement ;
32
+ if (expr .getName () == null || !expr .getName ().equals ("newMockInstance" )) {
33
+ return null ;
34
+ }
35
+
36
+ if (expr .getParameters ().length == 0 ) {
37
+ return null ;
38
+ }
39
+
40
+ PsiElement param = expr .getParameters ()[0 ];
41
+
42
+ if (param instanceof ClassConstantReference ) {
43
+ PhpExpression ref = ((ClassConstantReference ) param ).getClassReference ();
44
+ if (ref instanceof ClassReference ) {
45
+ return new PhpType ().add (ref );
46
+ }
47
+ } else if (param instanceof StringLiteralExpression ) {
48
+ return new PhpType ().add (((StringLiteralExpression ) param ).getContents ());
49
+ }
32
50
}
33
51
34
52
return null ;
You can’t perform that action at this time.
0 commit comments