GrVariable (@NotNull GrIntroduceContext context, @NotNull GroovyIntroduceVariableSettings settings) { GrStatement anchor = findAnchor(context, settings.replaceAllOccurrences()); PsiElement parent = anchor.getParent(); assert parent instanceof GrStatementOwner; GrVariableDeclaration generated = generateDeclaration(context, settings); GrStatement declaration = ((GrStatementOwner)parent).addStatementBefore(generated, anchor); declaration = (GrStatement)JavaCodeStyleManager.getInstance(context.getProject()).shortenClassReferences(declaration); PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(context.getEditor().getDocument()); return ((GrVariableDeclaration)declaration).getVariables()[0]; }