diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java index c450af0e1..4f6a68653 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java @@ -147,18 +147,17 @@ protected void addCompletions(@NotNull CompletionParameters completionParameters return; } - PsiElement context = psiElement.getParent(); - if (context == null) { + PsiElement parent = psiElement.getParent(); + if (!(parent instanceof StringLiteralExpression)) { return; } - MethodMatcher.MethodMatchParameter methodMatchParameter = MatcherUtil.matchField(context); + MethodMatcher.MethodMatchParameter methodMatchParameter = MatcherUtil.matchField(parent); if (methodMatchParameter == null) { return; } - StringLiteralExpression parent = (StringLiteralExpression) psiElement.getParent(); - String content = PsiElementUtils.getStringBeforeCursor(parent, completionParameters.getOffset()); + String content = PsiElementUtils.getStringBeforeCursor((StringLiteralExpression) parent, completionParameters.getOffset()); QueryBuilderMethodReferenceParser qb = getQueryBuilderParser(methodMatchParameter.getMethodReference()); QueryBuilderScopeContext collect = qb.collect();