analyzer.analyze();
}
+ @Test
+ public void testShadowingAssignedField() throws Exception {
+ IMethod testDataMethod = getTestDataMethod("iHaveALocalVariableShadowingAFieldAndIsNotAnUnfix");
+
+ SearchBasedRefactorAnalyzer<ExtractLocalVariableCandidate> analyzer = new SearchBasedRefactorAnalyzer<ExtractLocalVariableCandidate>(testDataMethod, new FavorNoUnfixesComparator<ExtractLocalVariableCandidate>(), new ExtractLocalVariableFactory());
+ analyzer.analyze();
+
+ assertThat("b.c".equals(analyzer.getCandidate().getTextSelection().getText()));
+
+ int methodOffset = testDataMethod.getSourceRange().getOffset();
+
+ CompilationUnitTextSelection textSelection = new CompilationUnitTextSelection(testDataMethod.getCompilationUnit(), methodOffset + 186, 3);
+
+ System.out.println("Currently " + textSelection.getText());
+ System.out.println(textSelection);
+ System.out.println("Should be equal to " + analyzer.getCandidate().getTextSelection().getText());
+ System.out.println(analyzer.getCandidate().getTextSelection());
+ assertThat(textSelection.isEquivalentTo(analyzer.getCandidate().getTextSelection()));
+
+// ASTNode coveredNode = textSelection.getCoveredNode();
+// assertThat(coveredNode, instanceOf(ExpressionStatement.class));
+//
+// ExpressionStatement expressionStatement = (ExpressionStatement) coveredNode;
+// assertThat(expressionStatement.getExpression(), instanceOf(MethodInvocation.class));
+//
+// MethodInvocation methodInvocation = (MethodInvocation) expressionStatement.getExpression();
+// Prefix prefix = new Prefix(methodInvocation);
+// assertTrue(prefix.getVariableBindingOfFirstExpression().isEqualTo(analyzer.getCandidate().calculateOriginalTarget()));
+ }
+
@Test(expected=NoTargetFoundException.class)
public void testNoTargetNullInElse() {
IMethod testDataMethod = getTestDataMethod("iWillBeNullInElse");