OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 " }", | 263 " }", |
264 "}", | 264 "}", |
265 "f2() {", | 265 "f2() {", |
266 " A a = new A();", | 266 " A a = new A();", |
267 " String s = 'hello ${a.newName}';", | 267 " String s = 'hello ${a.newName}';", |
268 "}", | 268 "}", |
269 ""); | 269 ""); |
270 } | 270 } |
271 | 271 |
272 public void test_OK_multipleUnits_onReference() throws Exception { | 272 public void test_OK_multipleUnits_onReference() throws Exception { |
273 setUnitContent("Test1.dart", new String[] { | 273 setUnitContent( |
| 274 "Test1.dart", |
274 "// filler filler filler filler filler filler filler filler filler fille
r", | 275 "// filler filler filler filler filler filler filler filler filler fille
r", |
275 "part of test;", | |
276 "class A {", | 276 "class A {", |
277 " int test = 1;", | 277 " int test = 1;", |
278 " int bar = 2;", | 278 " int bar = 2;", |
279 " f1() {", | 279 " f1() {", |
280 " test = 3;", | 280 " test = 3;", |
281 " bar = 4;", | 281 " bar = 4;", |
282 " }", | 282 " }", |
283 "}"}); | 283 "}"); |
284 setUnitContent("Test2.dart", new String[] { | 284 setUnitContent( |
| 285 "Test2.dart", |
285 "// filler filler filler filler filler filler filler filler filler fille
r", | 286 "// filler filler filler filler filler filler filler filler filler fille
r", |
286 "part of test;", | |
287 "f2() {", | 287 "f2() {", |
288 " A a = new A();", | 288 " A a = new A();", |
289 " a.test = 5;", | 289 " a.test = 5;", |
290 "}"}); | 290 "}"); |
291 setUnitContent("Test3.dart", new String[] { | 291 setUnitContent( |
| 292 "Test3.dart", |
292 "// filler filler filler filler filler filler filler filler filler fille
r", | 293 "// filler filler filler filler filler filler filler filler filler fille
r", |
293 "part of test;", | |
294 "class B extends A {", | 294 "class B extends A {", |
295 " f3() {", | 295 " f3() {", |
296 " test = 6;", | 296 " test = 6;", |
297 " }", | 297 " }", |
298 "}"}); | 298 "}"); |
299 setTestUnitContent( | 299 setTestUnitContent( |
300 "// filler filler filler filler filler filler filler filler filler fille
r", | 300 "// filler filler filler filler filler filler filler filler filler fille
r", |
301 "library test;", | 301 "#library('test');", |
302 "part 'Test1.dart';", | 302 "#source('Test1.dart');", |
303 "part 'Test2.dart';", | 303 "#source('Test2.dart');", |
304 "part 'Test3.dart';"); | 304 "#source('Test3.dart');"); |
305 // get units, because they have not library | 305 // get units, because they have not library |
306 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); | 306 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); |
307 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); | 307 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); |
308 CompilationUnit unit3 = testProject.getUnit("Test3.dart"); | 308 CompilationUnit unit3 = testProject.getUnit("Test3.dart"); |
309 // find Field to rename | 309 // find Field to rename |
310 Field field = findElement(unit2, "test = 5;"); | 310 Field field = findElement(unit2, "test = 5;"); |
311 // do rename | 311 // do rename |
312 renameField(field, "newName"); | 312 renameField(field, "newName"); |
313 assertUnitContent(unit1, new String[] { | 313 assertUnitContent( |
| 314 unit1, |
314 "// filler filler filler filler filler filler filler filler filler fille
r", | 315 "// filler filler filler filler filler filler filler filler filler fille
r", |
315 "part of test;", | |
316 "class A {", | 316 "class A {", |
317 " int newName = 1;", | 317 " int newName = 1;", |
318 " int bar = 2;", | 318 " int bar = 2;", |
319 " f1() {", | 319 " f1() {", |
320 " newName = 3;", | 320 " newName = 3;", |
321 " bar = 4;", | 321 " bar = 4;", |
322 " }", | 322 " }", |
323 "}"}); | 323 "}"); |
324 assertUnitContent(unit2, new String[] { | 324 assertUnitContent( |
| 325 unit2, |
325 "// filler filler filler filler filler filler filler filler filler fille
r", | 326 "// filler filler filler filler filler filler filler filler filler fille
r", |
326 "part of test;", | |
327 "f2() {", | 327 "f2() {", |
328 " A a = new A();", | 328 " A a = new A();", |
329 " a.newName = 5;", | 329 " a.newName = 5;", |
330 "}"}); | 330 "}"); |
331 assertUnitContent(unit3, new String[] { | 331 assertUnitContent( |
| 332 unit3, |
332 "// filler filler filler filler filler filler filler filler filler fille
r", | 333 "// filler filler filler filler filler filler filler filler filler fille
r", |
333 "part of test;", | |
334 "class B extends A {", | 334 "class B extends A {", |
335 " f3() {", | 335 " f3() {", |
336 " newName = 6;", | 336 " newName = 6;", |
337 " }", | 337 " }", |
338 "}"}); | 338 "}"); |
339 } | 339 } |
340 | 340 |
341 public void test_OK_singleUnit_onDeclaration() throws Exception { | 341 public void test_OK_singleUnit_onDeclaration() throws Exception { |
342 setTestUnitContent( | 342 setTestUnitContent( |
343 "// filler filler filler filler filler filler filler filler filler fille
r", | 343 "// filler filler filler filler filler filler filler filler filler fille
r", |
344 "class A {", | 344 "class A {", |
345 " int test = 1;", | 345 " int test = 1;", |
346 " int bar = 2;", | 346 " int bar = 2;", |
347 " f1() {", | 347 " f1() {", |
348 " test = 3;", | 348 " test = 3;", |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 "// filler filler filler filler filler filler filler filler filler fille
r", | 882 "// filler filler filler filler filler filler filler filler filler fille
r", |
883 "class A {", | 883 "class A {", |
884 " int newName = 1;", | 884 " int newName = 1;", |
885 " f() {", | 885 " f() {", |
886 " newName = 2;", | 886 " newName = 2;", |
887 " }", | 887 " }", |
888 "}", | 888 "}", |
889 "somethingBad"); | 889 "somethingBad"); |
890 } | 890 } |
891 } | 891 } |
OLD | NEW |