Skip to content

Commit d88db80

Browse files
committed
fix possible npe in annotation template collector #358
1 parent 654dc5e commit d88db80

File tree

1 file changed

+4
-3
lines changed
  • src/fr/adrienbrault/idea/symfony2plugin/templating/util

1 file changed

+4
-3
lines changed

src/fr/adrienbrault/idea/symfony2plugin/templating/util/TwigUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,25 @@ public static String getControllerMethodShortcut(Method method) {
8484
return shortcutName + ".html.twig";
8585
}
8686

87+
@NotNull
8788
public static Map<String, PsiElement> getTemplateAnnotationFiles(PhpDocTag phpDocTag) {
8889

8990
// @TODO: @Template(template="templatename")
9091
// Also replace "Matcher" with annotation psi elements; now possible
9192
// Wait for "annotation plugin" update; to not implement whole stuff here again?
9293

94+
Map<String, PsiElement> templateFiles = new HashMap<String, PsiElement>();
95+
9396
// find template name on annotation parameter
9497
// @Template("templatename")
9598
PhpPsiElement phpDocAttrList = phpDocTag.getFirstPsiChild();
9699
if(phpDocAttrList == null) {
97-
return null;
100+
return templateFiles;
98101
}
99102

100103
String tagValue = phpDocAttrList.getText();
101104
Matcher matcher = Pattern.compile("\\(\"(.*)\"").matcher(tagValue);
102105

103-
Map<String, PsiElement> templateFiles = new HashMap<String, PsiElement>();
104-
105106
if (matcher.find()) {
106107
// @TODO: only one should possible; refactor getTemplatePsiElements
107108
PsiElement[] psiElement = TwigHelper.getTemplatePsiElements(phpDocTag.getProject(), matcher.group(1));

0 commit comments

Comments
 (0)