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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 "By convention, variable names usually start with a lowercase letter", | 92 "By convention, variable names usually start with a lowercase letter", |
93 showStatusMessages.get(0)); | 93 showStatusMessages.get(0)); |
94 // status was warning, so rename was done | 94 // status was warning, so rename was done |
95 assertTestUnitContent( | 95 assertTestUnitContent( |
96 "// filler filler filler filler filler filler filler filler filler fille
r", | 96 "// filler filler filler filler filler filler filler filler filler fille
r", |
97 "var NewName;", | 97 "var NewName;", |
98 ""); | 98 ""); |
99 } | 99 } |
100 | 100 |
101 public void test_OK_multipleUnits_onReference() throws Exception { | 101 public void test_OK_multipleUnits_onReference() throws Exception { |
102 setUnitContent("Test1.dart", new String[] { | 102 setUnitContent( |
| 103 "Test1.dart", |
103 "// filler filler filler filler filler filler filler filler filler fille
r", | 104 "// filler filler filler filler filler filler filler filler filler fille
r", |
104 "part of test;", | |
105 "var test;", | 105 "var test;", |
106 ""}); | 106 ""); |
107 setUnitContent("Test2.dart", new String[] { | 107 setUnitContent( |
| 108 "Test2.dart", |
108 "// filler filler filler filler filler filler filler filler filler fille
r", | 109 "// filler filler filler filler filler filler filler filler filler fille
r", |
109 "part of test;", | |
110 "f() {", | 110 "f() {", |
111 " test = 1;", | 111 " test = 1;", |
112 "}"}); | 112 "}"); |
113 setTestUnitContent( | 113 setTestUnitContent( |
114 "// filler filler filler filler filler filler filler filler filler fille
r", | 114 "// filler filler filler filler filler filler filler filler filler fille
r", |
115 "library test;", | 115 "#library('test');", |
116 "part 'Test1.dart';", | 116 "#source('Test1.dart');", |
117 "part 'Test2.dart';"); | 117 "#source('Test2.dart');"); |
118 // get units, because they have not library | 118 // get units, because they have not library |
119 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); | 119 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); |
120 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); | 120 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); |
121 // find Function to rename | 121 // find Function to rename |
122 DartVariableDeclaration variable = findElement(unit2, "test = 1;"); | 122 DartVariableDeclaration variable = findElement(unit2, "test = 1;"); |
123 // do rename | 123 // do rename |
124 renameVariable(variable, "newName"); | 124 renameVariable(variable, "newName"); |
125 assertUnitContent(unit1, new String[] { | 125 assertUnitContent( |
| 126 unit1, |
126 "// filler filler filler filler filler filler filler filler filler fille
r", | 127 "// filler filler filler filler filler filler filler filler filler fille
r", |
127 "part of test;", | |
128 "var newName;", | 128 "var newName;", |
129 ""}); | 129 ""); |
130 assertUnitContent(unit2, new String[] { | 130 assertUnitContent( |
| 131 unit2, |
131 "// filler filler filler filler filler filler filler filler filler fille
r", | 132 "// filler filler filler filler filler filler filler filler filler fille
r", |
132 "part of test;", | |
133 "f() {", | 133 "f() {", |
134 " newName = 1;", | 134 " newName = 1;", |
135 "}"}); | 135 "}"); |
136 } | 136 } |
137 | 137 |
138 /** | 138 /** |
139 * <p> | 139 * <p> |
140 * http://code.google.com/p/dart/issues/detail?id=2749 | 140 * http://code.google.com/p/dart/issues/detail?id=2749 |
141 */ | 141 */ |
142 public void test_OK_referenceFromQualifiedInvocation() throws Exception { | 142 public void test_OK_referenceFromQualifiedInvocation() throws Exception { |
143 setTestUnitContent( | 143 setTestUnitContent( |
144 "// filler filler filler filler filler filler filler filler filler fille
r", | 144 "// filler filler filler filler filler filler filler filler filler fille
r", |
145 "var test;", | 145 "var test;", |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 String source = testUnit.getSource(); | 531 String source = testUnit.getSource(); |
532 try { | 532 try { |
533 renameVariable(variable, "newName"); | 533 renameVariable(variable, "newName"); |
534 fail(); | 534 fail(); |
535 } catch (InterruptedException e) { | 535 } catch (InterruptedException e) { |
536 } | 536 } |
537 // error should be displayed | 537 // error should be displayed |
538 assertThat(openInformationMessages).isEmpty(); | 538 assertThat(openInformationMessages).isEmpty(); |
539 assertThat(showStatusMessages).hasSize(1); | 539 assertThat(showStatusMessages).hasSize(1); |
540 assertEquals(RefactoringStatus.ERROR, showStatusSeverities.get(0).intValue()
); | 540 assertEquals(RefactoringStatus.ERROR, showStatusSeverities.get(0).intValue()
); |
541 assertEquals("File 'Test/" | 541 assertEquals("File 'Test/" + unitName + "' in library 'Test' already declare
s top-level " |
542 + unitName | 542 + shadowName + " 'newName'", showStatusMessages.get(0)); |
543 + "' in library 'Test' already declares top-level " | |
544 + shadowName | |
545 + " 'newName'", showStatusMessages.get(0)); | |
546 // no source changes | 543 // no source changes |
547 assertEquals(source, testUnit.getSource()); | 544 assertEquals(source, testUnit.getSource()); |
548 } | 545 } |
549 } | 546 } |
OLD | NEW |