GrField () { final PsiClass targetClass = settings.getTargetClass(); if (targetClass == null) return null; if (checkErrors(targetClass)) { return null; } final GrVariableDeclaration declaration = addDeclaration(targetClass); final GrField field = (GrField)declaration.getVariables()[0]; GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context); if (localVar != null) { assert localVar.getInitializerGroovy() != null : "initializer should exist: " + localVar.getText(); GrIntroduceHandlerBase.deleteLocalVar(localVar); if (settings.replaceAllOccurrences()) { processOccurrences(field); } else { replaceOccurrence(field, localVar.getInitializerGroovy(), isEscalateVisibility()); } } else if (context.getStringPart() != null) { final GrExpression ref = context.getStringPart().replaceLiteralWithConcatenation(field.getName()); final PsiElement element = replaceOccurrence(field, ref, isEscalateVisibility()); updateCaretPosition(element); } else if (context.getExpression() != null) { if (settings.replaceAllOccurrences()) { processOccurrences(field); } else { replaceOccurrence(field, context.getExpression(), isEscalateVisibility()); } } return field; }