@@ -49,7 +49,7 @@ public class TwigTemplateGoToDeclarationHandler implements GotoDeclarationHandle
49
49
@ Nullable
50
50
@ Override
51
51
public PsiElement [] getGotoDeclarationTargets (PsiElement psiElement , int offset , Editor editor ) {
52
- if (!Symfony2ProjectComponent .isEnabled (psiElement ) || !PlatformPatterns .psiElement ().withLanguage (TwigLanguage .INSTANCE ).accepts (psiElement )) {
52
+ if (!Symfony2ProjectComponent .isEnabled (psiElement ) || !PlatformPatterns .psiElement ().withLanguage (TwigLanguage .INSTANCE ).accepts (psiElement )) {
53
53
return null ;
54
54
}
55
55
@@ -63,7 +63,7 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int offset,
63
63
targets .addAll (getRouteParameterGoTo (psiElement ));
64
64
}
65
65
66
- if (TwigPattern .getTemplateFileReferenceTagPattern ().accepts (psiElement ) || TwigPattern .getPrintBlockOrTagFunctionPattern ("include" , "source" ).accepts (psiElement )) {
66
+ if (TwigPattern .getTemplateFileReferenceTagPattern ().accepts (psiElement ) || TwigPattern .getPrintBlockOrTagFunctionPattern ("include" , "source" ).accepts (psiElement )) {
67
67
// support: {% include() %}, {{ include() }}
68
68
targets .addAll (getTwigFiles (psiElement , offset ));
69
69
} else if (PlatformPatterns .psiElement (TwigTokenTypes .STRING_TEXT ).withText (PlatformPatterns .string ().endsWith (".twig" )).accepts (psiElement )) {
@@ -72,15 +72,15 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int offset,
72
72
targets .addAll (getTwigFiles (psiElement , offset ));
73
73
}
74
74
75
- if (TwigPattern .getAutocompletableRoutePattern ().accepts (psiElement )) {
75
+ if (TwigPattern .getAutocompletableRoutePattern ().accepts (psiElement )) {
76
76
targets .addAll (getRouteGoTo (psiElement ));
77
77
}
78
78
79
79
// find trans('', {}, '|')
80
80
// tricky way to get the function string trans(...)
81
81
if (TwigPattern .getTransDomainPattern ().accepts (psiElement )) {
82
82
PsiElement psiElementTrans = PsiElementUtils .getPrevSiblingOfType (psiElement , PlatformPatterns .psiElement (TwigTokenTypes .IDENTIFIER ).withText (PlatformPatterns .string ().oneOf ("trans" , "transchoice" )));
83
- if (psiElementTrans != null && TwigUtil .getTwigMethodString (psiElementTrans ) != null ) {
83
+ if (psiElementTrans != null && TwigUtil .getTwigMethodString (psiElementTrans ) != null ) {
84
84
targets .addAll (getTranslationDomainGoto (psiElement ));
85
85
}
86
86
}
@@ -95,15 +95,15 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int offset,
95
95
targets .addAll (getTranslationKeyGoTo (psiElement ));
96
96
}
97
97
98
- if (TwigPattern .getPrintBlockOrTagFunctionPattern ("controller" ).accepts (psiElement ) || TwigPattern .getStringAfterTagNamePattern ("render" ).accepts (psiElement )) {
98
+ if (TwigPattern .getPrintBlockOrTagFunctionPattern ("controller" ).accepts (psiElement ) || TwigPattern .getStringAfterTagNamePattern ("render" ).accepts (psiElement )) {
99
99
targets .addAll (getControllerGoTo (psiElement ));
100
100
}
101
101
102
- if (TwigPattern .getTransDefaultDomainPattern ().accepts (psiElement )) {
102
+ if (TwigPattern .getTransDefaultDomainPattern ().accepts (psiElement )) {
103
103
targets .addAll (TranslationUtil .getDomainPsiFiles (psiElement .getProject (), psiElement .getText ()));
104
104
}
105
105
106
- if (PlatformPatterns .or (TwigPattern .getFilterPattern (), TwigPattern .getApplyFilterPattern ()).accepts (psiElement )) {
106
+ if (PlatformPatterns .or (TwigPattern .getFilterPattern (), TwigPattern .getApplyFilterPattern ()).accepts (psiElement )) {
107
107
targets .addAll (getFilterGoTo (psiElement ));
108
108
}
109
109
@@ -113,9 +113,12 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int offset,
113
113
targets .addAll (getAfterIsToken (psiElement ));
114
114
}
115
115
116
- // {{ goto_me() }}
116
+ // {{ goto<caret>_me() }}
117
+ // {% if goto<caret>_me() %}
118
+ // {% set foo = foo<caret>_test() %}
117
119
if (TwigPattern .getPrintBlockFunctionPattern ().accepts (psiElement )) {
118
120
targets .addAll (this .getMacros (psiElement ));
121
+ targets .addAll (this .getFunctions (psiElement ));
119
122
}
120
123
121
124
// {% from 'boo.html.twig' import goto_me %}
@@ -134,59 +137,45 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int offset,
134
137
targets .addAll (getSets (psiElement ));
135
138
}
136
139
137
- // {{ function( }}
138
- // {{ function }}
139
- if (PlatformPatterns
140
- .psiElement (TwigTokenTypes .IDENTIFIER )
141
- .withParent (PlatformPatterns .or (
142
- PlatformPatterns .psiElement (TwigElementTypes .PRINT_BLOCK ),
143
- PlatformPatterns .psiElement (TwigElementTypes .SET_TAG ),
144
-
145
- PlatformPatterns .psiElement (TwigElementTypes .FUNCTION_CALL )
146
- )).withLanguage (TwigLanguage .INSTANCE ).accepts (psiElement )) {
147
-
148
- targets .addAll (this .getFunctions (psiElement ));
149
- }
150
-
151
140
// {{ foo.fo<caret>o }}
152
- if (TwigPattern .getTypeCompletionPattern ().accepts (psiElement )
141
+ if (TwigPattern .getTypeCompletionPattern ().accepts (psiElement )
153
142
|| TwigPattern .getPrintBlockFunctionPattern ().accepts (psiElement )
154
143
|| TwigPattern .getVariableTypePattern ().accepts (psiElement ))
155
144
{
156
145
targets .addAll (getTypeGoto (psiElement ));
157
146
}
158
147
159
- if (TwigPattern .getTwigDocBlockMatchPattern (ControllerDocVariableCollector .DOC_PATTERN ).accepts (psiElement )) {
148
+ if (TwigPattern .getTwigDocBlockMatchPattern (ControllerDocVariableCollector .DOC_PATTERN ).accepts (psiElement )) {
160
149
targets .addAll (getControllerNameGoto (psiElement ));
161
150
}
162
151
163
152
// {{ parent() }}
164
- if (TwigPattern .getParentFunctionPattern ().accepts (psiElement )) {
153
+ if (TwigPattern .getParentFunctionPattern ().accepts (psiElement )) {
165
154
targets .addAll (getParentGoto (psiElement ));
166
155
}
167
156
168
157
// constant('Post::PUBLISHED')
169
- if (TwigPattern .getPrintBlockOrTagFunctionPattern ("constant" ).accepts (psiElement )) {
158
+ if (TwigPattern .getPrintBlockOrTagFunctionPattern ("constant" ).accepts (psiElement )) {
170
159
targets .addAll (getConstantGoto (psiElement ));
171
160
}
172
161
173
162
// {# @var user \Foo #}
174
- if (TwigPattern .getTwigTypeDocBlockPattern ().accepts (psiElement )) {
163
+ if (TwigPattern .getTwigTypeDocBlockPattern ().accepts (psiElement )) {
175
164
targets .addAll (getVarClassGoto (psiElement ));
176
165
}
177
166
178
167
// {# @see Foo.html.twig #}
179
168
// {# @see \Class #}
180
- if (TwigPattern .getTwigDocSeePattern ().accepts (psiElement )) {
169
+ if (TwigPattern .getTwigDocSeePattern ().accepts (psiElement )) {
181
170
targets .addAll (getSeeDocTagTargets (psiElement ));
182
171
}
183
172
184
173
// {% FOO_TOKEN %}
185
- if (TwigPattern .getTagTokenBlockPattern ().accepts (psiElement )) {
174
+ if (TwigPattern .getTagTokenBlockPattern ().accepts (psiElement )) {
186
175
targets .addAll (getTokenTargets (psiElement ));
187
176
}
188
177
189
- return targets .toArray (new PsiElement [targets . size () ]);
178
+ return targets .toArray (new PsiElement [0 ]);
190
179
}
191
180
192
181
/**
0 commit comments