boolean (@NotNull String languageId, @NotNull PsiElement psiElement, @NotNull PsiLanguageInjectionHost host) { final PsiElement target = getTopLevelInjectionTarget(psiElement); final PsiElement parent = target.getParent(); final Project project = psiElement.getProject(); if (parent instanceof GrReturnStatement) { final GrControlFlowOwner owner = ControlFlowUtils.findControlFlowOwner(parent); if (owner instanceof GrOpenBlock && owner.getParent() instanceof GrMethod) { return JavaLanguageInjectionSupport.doInjectInJavaMethod(project, (PsiMethod)owner.getParent(), -1, host, languageId); } } else if (parent instanceof GrMethod) { return JavaLanguageInjectionSupport.doInjectInJavaMethod(project, (GrMethod)parent, -1, host, languageId); } else if (parent instanceof GrAnnotationNameValuePair) { final PsiReference ref = parent.getReference(); if (ref != null) { final PsiElement resolved = ref.resolve(); if (resolved instanceof PsiMethod) { return JavaLanguageInjectionSupport.doInjectInJavaMethod(project, (PsiMethod)resolved, -1, host, languageId); } } } else if (parent instanceof GrArgumentList && parent.getParent() instanceof GrMethodCall) { final PsiMethod method = ((GrMethodCall)parent.getParent()).resolveMethod(); if (method != null) { final int index = GrInjectionUtil.findParameterIndex(target, ((GrMethodCall)parent.getParent())); if (index >= 0) { return JavaLanguageInjectionSupport.doInjectInJavaMethod(project, method, index, host, languageId); } } } else if (parent instanceof GrAssignmentExpression) { final GrExpression expr = ((GrAssignmentExpression)parent).getLValue(); if (expr instanceof GrReferenceExpression) { final PsiElement element = ((GrReferenceExpression)expr).resolve(); if (element != null) { return doInject(languageId, element, host); } } } else { if (parent instanceof PsiVariable) { Processor<PsiLanguageInjectionHost> fixer = getAnnotationFixer(project, languageId); if (JavaLanguageInjectionSupport.doAddLanguageAnnotation(project, (PsiModifierListOwner)parent, host, languageId, fixer)) return true; } else if (target instanceof PsiVariable && !(target instanceof LightElement)) { Processor<PsiLanguageInjectionHost> fixer = getAnnotationFixer(project, languageId); if (JavaLanguageInjectionSupport.doAddLanguageAnnotation(project, (PsiModifierListOwner)target, host, languageId, fixer)) return true; } } return false; }