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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 assertThat(openInformationMessages).isEmpty(); | 96 assertThat(openInformationMessages).isEmpty(); |
97 assertThat(showStatusMessages).hasSize(1); | 97 assertThat(showStatusMessages).hasSize(1); |
98 assertEquals(RefactoringStatus.FATAL, showStatusSeverities.get(0).intValue()
); | 98 assertEquals(RefactoringStatus.FATAL, showStatusSeverities.get(0).intValue()
); |
99 assertEquals("The prefix 'not-identifier' is not a valid identifier", showSt
atusMessages.get(0)); | 99 assertEquals("The prefix 'not-identifier' is not a valid identifier", showSt
atusMessages.get(0)); |
100 // no source changes | 100 // no source changes |
101 assertEquals(source, testUnit.getSource()); | 101 assertEquals(source, testUnit.getSource()); |
102 } | 102 } |
103 | 103 |
104 public void test_OK_multipleUnits_onReference() throws Exception { | 104 public void test_OK_multipleUnits_onReference() throws Exception { |
105 prepareUniqueLibraries(); | 105 prepareUniqueLibraries(); |
106 setUnitContent("Test1.dart", new String[] { | 106 setUnitContent( |
| 107 "Test1.dart", |
107 "// filler filler filler filler filler filler filler filler filler fille
r", | 108 "// filler filler filler filler filler filler filler filler filler fille
r", |
108 "part of Test;", | |
109 "foo1() {", | 109 "foo1() {", |
110 " test.A a;", | 110 " test.A a;", |
111 " test.B b;", | 111 " test.B b;", |
112 "}", | 112 "}", |
113 ""}); | 113 ""); |
114 setUnitContent("Test2.dart", new String[] { | 114 setUnitContent( |
| 115 "Test2.dart", |
115 "// filler filler filler filler filler filler filler filler filler fille
r", | 116 "// filler filler filler filler filler filler filler filler filler fille
r", |
116 "part of Test;", | |
117 "foo2() {", | 117 "foo2() {", |
118 " test.A a;", | 118 " test.A a;", |
119 " test.B b;", | 119 " test.B b;", |
120 "}", | 120 "}", |
121 ""}); | 121 ""); |
122 setTestUnitContent( | 122 setTestUnitContent( |
123 "// filler filler filler filler filler filler filler filler filler fille
r", | 123 "// filler filler filler filler filler filler filler filler filler fille
r", |
124 "library Test;", | 124 "#library('Test');", |
125 "#import('LibA.dart', prefix: 'test');", | 125 "#import('LibA.dart', prefix: 'test');", |
126 "#import('LibB.dart', prefix: 'test');", | 126 "#import('LibB.dart', prefix: 'test');", |
127 "#source('Test1.dart');", | 127 "#source('Test1.dart');", |
128 "#source('Test2.dart');", | 128 "#source('Test2.dart');", |
129 ""); | 129 ""); |
130 // get units, because they have not library | 130 // get units, because they have not library |
131 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); | 131 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); |
132 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); | 132 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); |
133 DartImport imprt = findElement("#import('LibA.dart"); | 133 DartImport imprt = findElement("#import('LibA.dart"); |
134 // do rename | 134 // do rename |
135 renameImport(imprt, "newName"); | 135 renameImport(imprt, "newName"); |
136 assertTestUnitContent( | 136 assertTestUnitContent( |
137 "// filler filler filler filler filler filler filler filler filler fille
r", | 137 "// filler filler filler filler filler filler filler filler filler fille
r", |
138 "library Test;", | 138 "#library('Test');", |
139 "#import('LibA.dart', prefix: 'newName');", | 139 "#import('LibA.dart', prefix: 'newName');", |
140 "#import('LibB.dart', prefix: 'test');", | 140 "#import('LibB.dart', prefix: 'test');", |
141 "#source('Test1.dart');", | 141 "#source('Test1.dart');", |
142 "#source('Test2.dart');", | 142 "#source('Test2.dart');", |
143 ""); | 143 ""); |
144 assertUnitContent(unit1, new String[] { | 144 assertUnitContent( |
| 145 unit1, |
145 "// filler filler filler filler filler filler filler filler filler fille
r", | 146 "// filler filler filler filler filler filler filler filler filler fille
r", |
146 "part of Test;", | |
147 "foo1() {", | 147 "foo1() {", |
148 " newName.A a;", | 148 " newName.A a;", |
149 " test.B b;", | 149 " test.B b;", |
150 "}", | 150 "}", |
151 ""}); | 151 ""); |
152 assertUnitContent(unit2, new String[] { | 152 assertUnitContent( |
| 153 unit2, |
153 "// filler filler filler filler filler filler filler filler filler fille
r", | 154 "// filler filler filler filler filler filler filler filler filler fille
r", |
154 "part of Test;", | |
155 "foo2() {", | 155 "foo2() {", |
156 " newName.A a;", | 156 " newName.A a;", |
157 " test.B b;", | 157 " test.B b;", |
158 "}", | 158 "}", |
159 ""}); | 159 ""); |
160 } | 160 } |
161 | 161 |
162 public void test_OK_singleUnit_onDeclaration() throws Exception { | 162 public void test_OK_singleUnit_onDeclaration() throws Exception { |
163 prepareUniqueLibraries(); | 163 prepareUniqueLibraries(); |
164 setTestUnitContent( | 164 setTestUnitContent( |
165 "// filler filler filler filler filler filler filler filler filler fille
r", | 165 "// filler filler filler filler filler filler filler filler filler fille
r", |
166 "#import('LibA.dart', prefix: 'test');", | 166 "#import('LibA.dart', prefix: 'test');", |
167 "#import('LibB.dart', prefix: 'test');", | 167 "#import('LibB.dart', prefix: 'test');", |
168 "f() {", | 168 "f() {", |
169 " test.A a;", | 169 " test.A a;", |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 String source = testUnit.getSource(); | 686 String source = testUnit.getSource(); |
687 try { | 687 try { |
688 renameImport(imprt, "newName"); | 688 renameImport(imprt, "newName"); |
689 fail(); | 689 fail(); |
690 } catch (InterruptedException e) { | 690 } catch (InterruptedException e) { |
691 } | 691 } |
692 // error should be displayed | 692 // error should be displayed |
693 assertThat(openInformationMessages).isEmpty(); | 693 assertThat(openInformationMessages).isEmpty(); |
694 assertThat(showStatusMessages).hasSize(1); | 694 assertThat(showStatusMessages).hasSize(1); |
695 assertEquals(RefactoringStatus.ERROR, showStatusSeverities.get(0).intValue()
); | 695 assertEquals(RefactoringStatus.ERROR, showStatusSeverities.get(0).intValue()
); |
696 assertEquals("File 'Test/" | 696 assertEquals("File 'Test/" + unitName + "' in library 'Test' already declare
s top-level " |
697 + unitName | 697 + shadowName + " 'newName'", showStatusMessages.get(0)); |
698 + "' in library 'Test' already declares top-level " | |
699 + shadowName | |
700 + " 'newName'", showStatusMessages.get(0)); | |
701 // no source changes | 698 // no source changes |
702 assertEquals(source, testUnit.getSource()); | 699 assertEquals(source, testUnit.getSource()); |
703 } | 700 } |
704 | 701 |
705 /** | 702 /** |
706 * Prepares "LibA.dart" and "LibB.dart" with classes "A" and "B" respectively. | 703 * Prepares "LibA.dart" and "LibB.dart" with classes "A" and "B" respectively. |
707 */ | 704 */ |
708 private void prepareUniqueLibraries() throws Exception { | 705 private void prepareUniqueLibraries() throws Exception { |
709 testProject.setUnitContent( | 706 testProject.setUnitContent( |
710 "LibA.dart", | 707 "LibA.dart", |
711 makeSource( | 708 makeSource( |
712 "// filler filler filler filler filler filler filler filler filler f
iller", | 709 "// filler filler filler filler filler filler filler filler filler f
iller", |
713 "library libA;", | 710 "#library('A');", |
714 "class A {}", | 711 "class A {}", |
715 "")).getResource(); | 712 "")).getResource(); |
716 testProject.setUnitContent( | 713 testProject.setUnitContent( |
717 "LibB.dart", | 714 "LibB.dart", |
718 makeSource( | 715 makeSource( |
719 "// filler filler filler filler filler filler filler filler filler f
iller", | 716 "// filler filler filler filler filler filler filler filler filler f
iller", |
720 "library libB;", | 717 "#library('B');", |
721 "class B {}", | 718 "class B {}", |
722 "")).getResource(); | 719 "")).getResource(); |
723 } | 720 } |
724 } | 721 } |
OLD | NEW |