Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/internal/refactoring/ExtractMethodRefactoringImplTest.java

Issue 587743002: Version 1.7.0-dev.3.2 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, the Dart project authors. 2 * Copyright (c) 2013, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 setSelectionFromStartEndComments(); 136 setSelectionFromStartEndComments();
137 createRefactoring(); 137 createRefactoring();
138 // check conditions 138 // check conditions
139 assertRefactoringStatus( 139 assertRefactoringStatus(
140 refactoringStatus, 140 refactoringStatus,
141 RefactoringStatusSeverity.ERROR, 141 RefactoringStatusSeverity.ERROR,
142 "Created method will shadow method 'A.res'.", 142 "Created method will shadow method 'A.res'.",
143 findRangeIdentifier("res() {} // marker")); 143 findRangeIdentifier("res() {} // marker"));
144 } 144 }
145 145
146 public void test_bad_conflict_topLevel_alreadyDeclaresFunction() throws Except ion {
147 parseTestUnit(
148 "// filler filler filler filler filler filler filler filler filler fille r",
149 "void res() {}",
150 "main() {",
151 "// start",
152 " print(0);",
153 "// end",
154 "}",
155 "");
156 setSelectionFromStartEndComments();
157 createRefactoring();
158 // check conditions
159 assertRefactoringStatus(
160 refactoringStatus,
161 RefactoringStatusSeverity.ERROR,
162 "Library already declares function with name 'res'.",
163 findRangeIdentifier("res() {}"));
164 }
165
146 // TODO(scheglov) waiting for "library namespace" in Engine 166 // TODO(scheglov) waiting for "library namespace" in Engine
147 // public void test_bad_conflict_method_willHideTopLevel() throws Exception { 167 // public void test_bad_conflict_method_willHideTopLevel() throws Exception {
148 // indexTestUnit( 168 // indexTestUnit(
149 // "// filler filler filler filler filler filler filler filler filler fil ler", 169 // "// filler filler filler filler filler filler filler filler filler fil ler",
150 // "void res() {} // marker", 170 // "void res() {} // marker",
151 // "class B {", 171 // "class B {",
152 // " main() {", 172 // " main() {",
153 // "// start", 173 // "// start",
154 // " print(0);", 174 // " print(0);",
155 // "// end", 175 // "// end",
(...skipping 13 matching lines...) Expand all
169 // findRangeIdentifier("res() {} // marker")); 189 // findRangeIdentifier("res() {} // marker"));
170 //// assertTrue(refactoringStatus.hasError()); 190 //// assertTrue(refactoringStatus.hasError());
171 //// { 191 //// {
172 //// String msg = refactoringStatus.getMessageMatchingSeverity(RefactoringS tatus.ERROR); 192 //// String msg = refactoringStatus.getMessageMatchingSeverity(RefactoringS tatus.ERROR);
173 //// assertEquals( 193 //// assertEquals(
174 //// "Usage of function 'res' in file 'Test/Test.dart' in library 'Test ' will be shadowed by created function", 194 //// "Usage of function 'res' in file 'Test/Test.dart' in library 'Test ' will be shadowed by created function",
175 //// msg); 195 //// msg);
176 //// } 196 //// }
177 // } 197 // }
178 198
179 public void test_bad_conflict_topLevel_alreadyDeclaresFunction() throws Except ion {
180 parseTestUnit(
181 "// filler filler filler filler filler filler filler filler filler fille r",
182 "void res() {}",
183 "main() {",
184 "// start",
185 " print(0);",
186 "// end",
187 "}",
188 "");
189 setSelectionFromStartEndComments();
190 createRefactoring();
191 // check conditions
192 assertRefactoringStatus(
193 refactoringStatus,
194 RefactoringStatusSeverity.ERROR,
195 "Library already declares function with name 'res'.",
196 findRangeIdentifier("res() {}"));
197 }
198
199 public void test_bad_conflict_topLevel_willHideInheritedMemberUsage() throws E xception { 199 public void test_bad_conflict_topLevel_willHideInheritedMemberUsage() throws E xception {
200 indexTestUnit( 200 indexTestUnit(
201 "// filler filler filler filler filler filler filler filler filler fille r", 201 "// filler filler filler filler filler filler filler filler filler fille r",
202 "class A {", 202 "class A {",
203 " void res() {}", 203 " void res() {}",
204 "}", 204 "}",
205 "class B extends A {", 205 "class B extends A {",
206 " foo() {", 206 " foo() {",
207 " res(); // marker", 207 " res(); // marker",
208 " }", 208 " }",
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 /** 2553 /**
2554 * Checks that all conditions are <code>OK</code> and applying {@link Change} to the 2554 * Checks that all conditions are <code>OK</code> and applying {@link Change} to the
2555 * {@link #testUnit} is same source as given lines. 2555 * {@link #testUnit} is same source as given lines.
2556 */ 2556 */
2557 protected final void assertSuccessfulRefactoring(String... lines) throws Excep tion { 2557 protected final void assertSuccessfulRefactoring(String... lines) throws Excep tion {
2558 assertRefactoringStatus(refactoringStatus, RefactoringStatusSeverity.OK, nul l); 2558 assertRefactoringStatus(refactoringStatus, RefactoringStatusSeverity.OK, nul l);
2559 Change change = refactoring.createChange(pm); 2559 Change change = refactoring.createChange(pm);
2560 assertTestChangeResult(change, makeSource(lines)); 2560 assertTestChangeResult(change, makeSource(lines));
2561 } 2561 }
2562 2562
2563 @Override
2564 protected void tearDown() throws Exception {
2565 refactoring = null;
2566 refactoringStatus = null;
2567 super.tearDown();
2568 }
2569
2563 /** 2570 /**
2564 * Creates {@link ExtractMethodRefactoring} in {@link #refactoring}. 2571 * Creates {@link ExtractMethodRefactoring} in {@link #refactoring}.
2565 */ 2572 */
2566 private void createRefactoring() throws Exception { 2573 private void createRefactoring() throws Exception {
2567 int selectionLength = selectionEnd - selectionStart; 2574 int selectionLength = selectionEnd - selectionStart;
2568 AssistContext context = new AssistContext( 2575 AssistContext context = new AssistContext(
2569 searchEngine, 2576 searchEngine,
2570 analysisContext, 2577 analysisContext,
2571 null, 2578 null,
2572 testSource, 2579 testSource,
(...skipping 19 matching lines...) Expand all
2592 } 2599 }
2593 2600
2594 /** 2601 /**
2595 * Sets selection to the start of the first occurrence of the given string. 2602 * Sets selection to the start of the first occurrence of the given string.
2596 */ 2603 */
2597 private void setSelectionString(String pattern) { 2604 private void setSelectionString(String pattern) {
2598 selectionStart = findOffset(pattern); 2605 selectionStart = findOffset(pattern);
2599 selectionEnd = findEnd(pattern); 2606 selectionEnd = findEnd(pattern);
2600 } 2607 }
2601 } 2608 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698