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

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 556573002: Make SdkLibrary.shortName consistently include 'dart:' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/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
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
8 import 'package:analysis_server/src/services/correction/fix.dart'; 8 import 'package:analysis_server/src/services/correction/fix.dart';
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, ''' 1017 assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
1018 import 'lib.dart'; 1018 import 'lib.dart';
1019 1019
1020 main() { 1020 main() {
1021 Test t = null; 1021 Test t = null;
1022 } 1022 }
1023 '''); 1023 ''');
1024 } 1024 }
1025 1025
1026 void test_importLibrarySdk_withTopLevelVariable() { 1026 void test_importLibrarySdk_withTopLevelVariable() {
1027 _ensureSdkMathLibraryResolved();
1028 _indexTestUnit(''' 1027 _indexTestUnit('''
1029 main() { 1028 main() {
1030 print(PI); 1029 print(PI);
1031 } 1030 }
1032 '''); 1031 ''');
1033 performAllAnalysisTasks(); 1032 performAllAnalysisTasks();
1034 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, ''' 1033 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
1035 import 'dart:math'; 1034 import 'dart:math';
1036 1035
1037 main() { 1036 main() {
1038 print(PI); 1037 print(PI);
1039 } 1038 }
1040 '''); 1039 ''');
1041 } 1040 }
1042 1041
1043 void test_importLibrarySdk_withType_invocationTarget() { 1042 void test_importLibrarySdk_withType_invocationTarget() {
1044 _ensureSdkAsyncLibraryResolved();
1045 _indexTestUnit(''' 1043 _indexTestUnit('''
1046 main() { 1044 main() {
1047 Future.wait(null); 1045 Future.wait(null);
1048 } 1046 }
1049 '''); 1047 ''');
1050 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, ''' 1048 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
1051 import 'dart:async'; 1049 import 'dart:async';
1052 1050
1053 main() { 1051 main() {
1054 Future.wait(null); 1052 Future.wait(null);
1055 } 1053 }
1056 '''); 1054 ''');
1057 } 1055 }
1058 1056
1059 void test_importLibrarySdk_withType_typeAnnotation() { 1057 void test_importLibrarySdk_withType_typeAnnotation() {
1060 _ensureSdkAsyncLibraryResolved();
1061 _indexTestUnit(''' 1058 _indexTestUnit('''
1062 main() { 1059 main() {
1063 Future f = null; 1060 Future f = null;
1064 } 1061 }
1065 '''); 1062 ''');
1066 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, ''' 1063 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
1067 import 'dart:async'; 1064 import 'dart:async';
1068 1065
1069 main() { 1066 main() {
1070 Future f = null; 1067 Future f = null;
1071 } 1068 }
1072 '''); 1069 ''');
1073 } 1070 }
1074 1071
1075 void test_importLibrarySdk_withType_typeAnnotation_PrefixedIdentifier() { 1072 void test_importLibrarySdk_withType_typeAnnotation_PrefixedIdentifier() {
1076 _ensureSdkAsyncLibraryResolved();
1077 _indexTestUnit(''' 1073 _indexTestUnit('''
1078 main() { 1074 main() {
1079 Future.wait; 1075 Future.wait;
1080 } 1076 }
1081 '''); 1077 ''');
1082 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, ''' 1078 assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
1083 import 'dart:async'; 1079 import 'dart:async';
1084 1080
1085 main() { 1081 main() {
1086 Future.wait; 1082 Future.wait;
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 1802
1807 void _assertLinkedGroup(LinkedEditGroup group, List<String> expectedStrings, 1803 void _assertLinkedGroup(LinkedEditGroup group, List<String> expectedStrings,
1808 [List<LinkedEditSuggestion> expectedSuggestions]) { 1804 [List<LinkedEditSuggestion> expectedSuggestions]) {
1809 List<Position> expectedPositions = _findResultPositions(expectedStrings); 1805 List<Position> expectedPositions = _findResultPositions(expectedStrings);
1810 expect(group.positions, unorderedEquals(expectedPositions)); 1806 expect(group.positions, unorderedEquals(expectedPositions));
1811 if (expectedSuggestions != null) { 1807 if (expectedSuggestions != null) {
1812 expect(group.suggestions, unorderedEquals(expectedSuggestions)); 1808 expect(group.suggestions, unorderedEquals(expectedSuggestions));
1813 } 1809 }
1814 } 1810 }
1815 1811
1816 /**
1817 * We search for elements only already resolved lbiraries, and we use
1818 * `dart:async` elements in tests.
1819 */
1820 void _ensureSdkAsyncLibraryResolved() {
1821 resolveLibraryUnit(addSource('/other.dart', 'import "dart:async";'));
1822 }
1823
1824 /**
1825 * We search for elements only already resolved lbiraries, and we use
1826 * `dart:async` elements in tests.
1827 */
1828 void _ensureSdkMathLibraryResolved() {
1829 resolveLibraryUnit(addSource('/other.dart', 'import "dart:math";'));
1830 }
1831
1832 AnalysisError _findErrorToFix() { 1812 AnalysisError _findErrorToFix() {
1833 List<AnalysisError> errors = context.computeErrors(testSource); 1813 List<AnalysisError> errors = context.computeErrors(testSource);
1834 expect( 1814 expect(
1835 errors, 1815 errors,
1836 hasLength(1), 1816 hasLength(1),
1837 reason: 'Exactly 1 error expected, but ${errors.length} found:\n' + 1817 reason: 'Exactly 1 error expected, but ${errors.length} found:\n' +
1838 errors.join('\n')); 1818 errors.join('\n'));
1839 return errors[0]; 1819 return errors[0];
1840 } 1820 }
1841 1821
1842 List<Position> _findResultPositions(List<String> searchStrings) { 1822 List<Position> _findResultPositions(List<String> searchStrings) {
1843 List<Position> positions = <Position>[]; 1823 List<Position> positions = <Position>[];
1844 for (String search in searchStrings) { 1824 for (String search in searchStrings) {
1845 int offset = resultCode.indexOf(search); 1825 int offset = resultCode.indexOf(search);
1846 int length = getLeadingIdentifierLength(search); 1826 int length = getLeadingIdentifierLength(search);
1847 positions.add(new Position(testFile, offset)); 1827 positions.add(new Position(testFile, offset));
1848 } 1828 }
1849 return positions; 1829 return positions;
1850 } 1830 }
1851 1831
1852 void _indexTestUnit(String code) { 1832 void _indexTestUnit(String code) {
1853 resolveTestUnit(code); 1833 resolveTestUnit(code);
1854 index.indexUnit(context, testUnit); 1834 index.indexUnit(context, testUnit);
1855 } 1835 }
1856 } 1836 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698