| 
7 | 7 | import com.intellij.psi.PsiElement;  | 
8 | 8 | import com.intellij.psi.PsiFile;  | 
9 | 9 | import com.intellij.psi.util.PsiTreeUtil;  | 
 | 10 | +import com.jetbrains.php.lang.psi.elements.Field;  | 
10 | 11 | import com.jetbrains.php.lang.psi.elements.Method;  | 
 | 12 | +import com.jetbrains.php.lang.psi.elements.PhpClass;  | 
11 | 13 | import com.jetbrains.twig.TwigLanguage;  | 
12 | 14 | import com.jetbrains.twig.TwigTokenTypes;  | 
13 | 15 | import com.jetbrains.twig.elements.TwigBlockTag;  | 
 | 
26 | 28 | import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil;  | 
27 | 29 | import fr.adrienbrault.idea.symfony2plugin.util.RegexPsiElementFilter;  | 
28 | 30 | import fr.adrienbrault.idea.symfony2plugin.util.controller.ControllerIndex;  | 
 | 31 | +import org.apache.commons.lang.StringUtils;  | 
29 | 32 | import org.jetbrains.annotations.Nullable;  | 
30 | 33 | 
 
  | 
31 | 34 | import java.util.ArrayList;  | 
@@ -95,9 +98,41 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit  | 
95 | 98 |  psiElements.addAll(Arrays.asList(this.getParentGoto(psiElement)));  | 
96 | 99 |  }  | 
97 | 100 | 
 
  | 
 | 101 | + // constant('Post::PUBLISHED')  | 
 | 102 | + if(TwigHelper.getPrintBlockFunctionPattern("constant").accepts(psiElement)) {  | 
 | 103 | + psiElements.addAll(this.getConstantGoto(psiElement));  | 
 | 104 | + }  | 
 | 105 | + | 
98 | 106 |  return psiElements.toArray(new PsiElement[psiElements.size()]);  | 
99 | 107 |  }  | 
100 | 108 | 
 
  | 
 | 109 | + private Collection<PsiElement> getConstantGoto(PsiElement psiElement) {  | 
 | 110 | + | 
 | 111 | + Collection<PsiElement> targetPsiElements = new ArrayList<PsiElement>();  | 
 | 112 | + | 
 | 113 | + String contents = psiElement.getText();  | 
 | 114 | + if(StringUtils.isBlank(contents) || !contents.contains(":")) {  | 
 | 115 | + return targetPsiElements;  | 
 | 116 | + }  | 
 | 117 | + | 
 | 118 | + String[] parts = contents.split("::");  | 
 | 119 | + if(parts.length != 2) {  | 
 | 120 | + return targetPsiElements;  | 
 | 121 | + }  | 
 | 122 | + | 
 | 123 | + PhpClass phpClass = PhpElementsUtil.getClassInterface(psiElement.getProject(), parts[0]);  | 
 | 124 | + if(phpClass == null) {  | 
 | 125 | + return targetPsiElements;  | 
 | 126 | + }  | 
 | 127 | + | 
 | 128 | + Field field = phpClass.findFieldByName(parts[1], true);  | 
 | 129 | + if(field != null) {  | 
 | 130 | + targetPsiElements.add(field);  | 
 | 131 | + }  | 
 | 132 | + | 
 | 133 | + return targetPsiElements;  | 
 | 134 | + }  | 
 | 135 | + | 
101 | 136 |  private PsiElement[] getTypeGoto(PsiElement psiElement) {  | 
102 | 137 | 
 
  | 
103 | 138 |  ArrayList<PsiElement> targetPsiElements = new ArrayList<PsiElement>();  | 
 | 
0 commit comments