From 25d5d2e93222984c71f7eb7d11eb0e4f550fbced Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Thu, 30 Jan 2014 17:20:55 +0400 Subject: [PATCH] Groovy: in-place introduce field from reference to local var --- .../introduce/GrIntroduceHandlerBase.java | 22 ++++++--- .../field/GrInplaceFieldIntroducer.java | 49 ++++++++++--------- .../field/GrIntroduceFieldProcessor.java | 1 + 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java index 30a7228d9336..1cfabe0d6cdf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java @@ -741,19 +741,29 @@ public abstract class GrIntroduceHandlerBase result = ContainerUtil.newArrayList(myLocalVar.getName()); + + GrExpression initializer = myLocalVar.getInitializerGroovy(); + if (initializer != null) { + ContainerUtil.addAll(result, GroovyNameSuggestionUtil.suggestVariableNames(initializer, new GroovyInplaceFieldValidator(getContext()), false)); + } + mySuggestedNames = ArrayUtil.toStringArray(result); + } + else { + mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(context.getExpression(), new GroovyInplaceFieldValidator(getContext()), false); + } + myApplicablePlaces = getApplicableInitPlaces(); + } @Nullable @Override @@ -72,28 +95,6 @@ public class GrInplaceFieldIntroducer extends GrAbstractInplaceIntroducer result = ContainerUtil.newArrayList(var.getName()); - - GrExpression initializer = var.getInitializerGroovy(); - if (initializer != null) { - ContainerUtil.addAll(result, GroovyNameSuggestionUtil.suggestVariableNames(initializer, new GroovyInplaceFieldValidator(getContext()), false)); - } - mySuggestedNames = ArrayUtil.toStringArray(result); - } - else { - mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(context.getExpression(), new GroovyInplaceFieldValidator(getContext()), false); - } - myApplicablePlaces = getApplicableInitPlaces(); - } - @Override protected GrVariable runRefactoring(GrIntroduceContext context, GrIntroduceFieldSettings settings, boolean processUsages) { GrIntroduceFieldProcessor processor = new GrIntroduceFieldProcessor(context, settings); @@ -146,7 +147,7 @@ public class GrInplaceFieldIntroducer extends GrAbstractInplaceIntroducer