boolean (GrStatement injected, PsiElement next) { if (next.getTextLength() == 0) next = next.getNextSibling(); char nextChar = next.getText().charAt(0); if (nextChar == '"' || nextChar == '$') { return true; } final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(injected.getProject()); final GrExpression gString; try { gString = elementFactory.createExpressionFromText("\"$" + injected.getText() + next.getText() + '"'); } catch (Exception e) { return false; } if (!(gString instanceof GrString)) return false; PsiElement child = gString.getFirstChild(); if (!(child.getNode().getElementType() == GroovyTokenTypes.mGSTRING_BEGIN)) return false; child = child.getNextSibling(); if (!(child instanceof GrStringInjection)) return false; final PsiElement refExprCopy = ((GrStringInjection)child).getExpression(); if (!(refExprCopy instanceof GrReferenceExpression)) return false; final GrReferenceExpression refExpr = (GrReferenceExpression)injected; return PsiUtil.checkPsiElementsAreEqual(refExpr, refExprCopy); }