Skip to content

Commit dae408b

Browse files
committed
fix some npe
1 parent b0872ed commit dae408b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@ public boolean value(PsiElement psiElement) {
9090
}
9191
});
9292

93+
ArrayList<PhpNamedElement> arrayList = new ArrayList<PhpNamedElement>();
94+
if(twigCompositeElement == null) {
95+
return arrayList;
96+
}
9397

9498
Pattern pattern = Pattern.compile("\\{#[\\s]+" + Pattern.quote(variableName) + "[\\s]+([\\w\\\\\\[\\]]+)[\\s]+#}");
9599
Collection<PsiComment> psiComments = PsiTreeUtil.findChildrenOfType(twigCompositeElement, PsiComment.class);
96100

97-
ArrayList<PhpNamedElement> arrayList = new ArrayList<PhpNamedElement>();
98101
for(PsiComment psiComment: psiComments) {
99102
Matcher matcher = pattern.matcher(psiComment.getText());
100103
if (matcher.find()) {
@@ -129,10 +132,13 @@ public boolean value(PsiElement psiElement) {
129132
}
130133
});
131134

132-
Pattern pattern = Pattern.compile(DOC_PATTERN);
135+
HashMap<String, String> variables = new HashMap<String, String>();
136+
if(twigCompositeElement == null) {
137+
return variables;
138+
}
133139

134140
// wtf in completion { | } root we have no comments in child context !?
135-
HashMap<String, String> variables = new HashMap<String, String>();
141+
Pattern pattern = Pattern.compile(DOC_PATTERN);
136142
for(PsiElement psiComment: YamlHelper.getChildrenFix(twigCompositeElement)) {
137143
if(psiComment instanceof PsiComment) {
138144
Matcher matcher = pattern.matcher(psiComment.getText());

0 commit comments

Comments
 (0)