Result (ExpressionContext context) { final TextResult insertedValue = context.getVariableValue(InplaceRefactoring.PRIMARY_VARIABLE_NAME); if (insertedValue != null) { if (!insertedValue.getText().isEmpty()) return insertedValue; } return new TextResult(myName); }