Skip to content

Commit 02a2592

Browse files
authored
Merge pull request #2110 from Haehnchen/feature/FormControllerRelatedGotoCollector-control-flow
use controlflow inside FormControllerRelatedGotoCollector for visiting method references
2 parents 9426919 + e67aa38 commit 02a2592

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/navigation/controller/FormControllerRelatedGotoCollector.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package fr.adrienbrault.idea.symfony2plugin.navigation.controller;
22

33
import com.intellij.psi.PsiElement;
4-
import com.intellij.psi.PsiRecursiveElementVisitor;
4+
import com.jetbrains.php.codeInsight.controlFlow.PhpControlFlowUtil;
5+
import com.jetbrains.php.codeInsight.controlFlow.PhpInstructionProcessor;
6+
import com.jetbrains.php.codeInsight.controlFlow.instructions.PhpCallInstruction;
57
import com.jetbrains.php.lang.psi.elements.MethodReference;
68
import com.jetbrains.php.lang.psi.elements.PhpClass;
79
import fr.adrienbrault.idea.symfony2plugin.Symfony2Icons;
@@ -11,7 +13,6 @@
1113
import fr.adrienbrault.idea.symfony2plugin.form.util.FormUtil;
1214
import fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher;
1315
import org.apache.commons.lang.StringUtils;
14-
import org.jetbrains.annotations.NotNull;
1516

1617
import java.util.ArrayList;
1718
import java.util.Collection;
@@ -27,14 +28,13 @@ public void collectGotoRelatedItems(ControllerActionGotoRelatedCollectorParamete
2728

2829
Collection<MethodReference> methodReferences = new ArrayList<>();
2930

30-
parameter.getMethod().acceptChildren(new PsiRecursiveElementVisitor() {
31+
PhpControlFlowUtil.processFlow(parameter.getMethod().getControlFlow(), new PhpInstructionProcessor() {
3132
@Override
32-
public void visitElement(@NotNull PsiElement element) {
33-
if (element instanceof MethodReference) {
34-
methodReferences.add((MethodReference) element);
33+
public boolean processPhpCallInstruction(PhpCallInstruction instruction) {
34+
if (instruction.getFunctionReference() instanceof MethodReference methodReference) {
35+
methodReferences.add(methodReference);
3536
}
36-
37-
super.visitElement(element);
37+
return super.processPhpCallInstruction(instruction);
3838
}
3939
});
4040

0 commit comments

Comments
 (0)