| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 "By convention, function type alias names usually start with an uppercas
e letter", | 94 "By convention, function type alias names usually start with an uppercas
e letter", |
| 95 showStatusMessages.get(0)); | 95 showStatusMessages.get(0)); |
| 96 // status was warning, so rename was done | 96 // status was warning, so rename was done |
| 97 assertTestUnitContent( | 97 assertTestUnitContent( |
| 98 "// filler filler filler filler filler filler filler filler filler fille
r", | 98 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 99 "typedef newName();", | 99 "typedef newName();", |
| 100 ""); | 100 ""); |
| 101 } | 101 } |
| 102 | 102 |
| 103 public void test_OK_multipleUnits_onReference() throws Exception { | 103 public void test_OK_multipleUnits_onReference() throws Exception { |
| 104 setUnitContent("Test1.dart", new String[] { | 104 setUnitContent( |
| 105 "Test1.dart", |
| 105 "// filler filler filler filler filler filler filler filler filler fille
r", | 106 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 106 "part of test;", | |
| 107 "typedef Test();", | 107 "typedef Test();", |
| 108 ""}); | 108 ""); |
| 109 setUnitContent("Test2.dart", new String[] { | 109 setUnitContent( |
| 110 "Test2.dart", |
| 110 "// filler filler filler filler filler filler filler filler filler fille
r", | 111 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 111 "part of test;", | |
| 112 "f(Test test) {", | 112 "f(Test test) {", |
| 113 "}"}); | 113 "}"); |
| 114 setTestUnitContent( | 114 setTestUnitContent( |
| 115 "// filler filler filler filler filler filler filler filler filler fille
r", | 115 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 116 "library test;", | 116 "#library('test');", |
| 117 "part 'Test1.dart';", | 117 "#source('Test1.dart');", |
| 118 "part 'Test2.dart';"); | 118 "#source('Test2.dart');"); |
| 119 // get units, because they have not library | 119 // get units, because they have not library |
| 120 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); | 120 CompilationUnit unit1 = testProject.getUnit("Test1.dart"); |
| 121 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); | 121 CompilationUnit unit2 = testProject.getUnit("Test2.dart"); |
| 122 // find DartFunctionTypeAlias to rename | 122 // find DartFunctionTypeAlias to rename |
| 123 DartFunctionTypeAlias functionTypeAlias = findElement(unit2, "Test test"); | 123 DartFunctionTypeAlias functionTypeAlias = findElement(unit2, "Test test"); |
| 124 // do rename | 124 // do rename |
| 125 renameType(functionTypeAlias, "NewName"); | 125 renameType(functionTypeAlias, "NewName"); |
| 126 assertUnitContent(unit1, new String[] { | 126 assertUnitContent( |
| 127 unit1, |
| 127 "// filler filler filler filler filler filler filler filler filler fille
r", | 128 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 128 "part of test;", | |
| 129 "typedef NewName();", | 129 "typedef NewName();", |
| 130 ""}); | 130 ""); |
| 131 assertUnitContent(unit2, new String[] { | 131 assertUnitContent( |
| 132 unit2, |
| 132 "// filler filler filler filler filler filler filler filler filler fille
r", | 133 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 133 "part of test;", | |
| 134 "f(NewName test) {", | 134 "f(NewName test) {", |
| 135 "}"}); | 135 "}"); |
| 136 } | 136 } |
| 137 | 137 |
| 138 public void test_OK_singleUnit_onDeclaration() throws Exception { | 138 public void test_OK_singleUnit_onDeclaration() throws Exception { |
| 139 setTestUnitContent( | 139 setTestUnitContent( |
| 140 "// filler filler filler filler filler filler filler filler filler fille
r", | 140 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 141 "typedef Test();", | 141 "typedef Test();", |
| 142 "f(Test test) {", | 142 "f(Test test) {", |
| 143 "}", | 143 "}", |
| 144 ""); | 144 ""); |
| 145 DartFunctionTypeAlias functionTypeAlias = findElement("Test();"); | 145 DartFunctionTypeAlias functionTypeAlias = findElement("Test();"); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 String source = testUnit.getSource(); | 497 String source = testUnit.getSource(); |
| 498 try { | 498 try { |
| 499 renameType(functionTypeAlias, "NewName"); | 499 renameType(functionTypeAlias, "NewName"); |
| 500 fail(); | 500 fail(); |
| 501 } catch (InterruptedException e) { | 501 } catch (InterruptedException e) { |
| 502 } | 502 } |
| 503 // error should be displayed | 503 // error should be displayed |
| 504 assertThat(openInformationMessages).isEmpty(); | 504 assertThat(openInformationMessages).isEmpty(); |
| 505 assertThat(showStatusMessages).hasSize(1); | 505 assertThat(showStatusMessages).hasSize(1); |
| 506 assertEquals(RefactoringStatus.ERROR, showStatusSeverities.get(0).intValue()
); | 506 assertEquals(RefactoringStatus.ERROR, showStatusSeverities.get(0).intValue()
); |
| 507 assertEquals("File 'Test/" | 507 assertEquals("File 'Test/" + unitName + "' in library 'Test' already declare
s top-level " |
| 508 + unitName | 508 + shadowName + " 'NewName'", showStatusMessages.get(0)); |
| 509 + "' in library 'Test' already declares top-level " | |
| 510 + shadowName | |
| 511 + " 'NewName'", showStatusMessages.get(0)); | |
| 512 // no source changes | 509 // no source changes |
| 513 assertEquals(source, testUnit.getSource()); | 510 assertEquals(source, testUnit.getSource()); |
| 514 } | 511 } |
| 515 } | 512 } |
| OLD | NEW |