| OLD | NEW |
| 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 analyzer.test.generated.compile_time_error_code_test; | 5 library analyzer.test.generated.compile_time_error_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
| 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 10 import 'package:analyzer/src/generated/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
| (...skipping 6027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6038 computeLibrarySourceErrors(source); | 6038 computeLibrarySourceErrors(source); |
| 6039 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 6039 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 6040 } | 6040 } |
| 6041 | 6041 |
| 6042 void test_uriDoesNotExist_import() { | 6042 void test_uriDoesNotExist_import() { |
| 6043 Source source = addSource("import 'unknown.dart';"); | 6043 Source source = addSource("import 'unknown.dart';"); |
| 6044 computeLibrarySourceErrors(source); | 6044 computeLibrarySourceErrors(source); |
| 6045 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 6045 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 6046 } | 6046 } |
| 6047 | 6047 |
| 6048 void test_uriDoesNotExist_import_appears_after_deleting_target() { |
| 6049 Source test = addSource("import 'target.dart';"); |
| 6050 Source target = addNamedSource("/target.dart", ""); |
| 6051 computeLibrarySourceErrors(test); |
| 6052 assertErrors(test, [HintCode.UNUSED_IMPORT]); |
| 6053 |
| 6054 // Remove the overlay in the same way as AnalysisServer. |
| 6055 analysisContext2.setContents(target, null); |
| 6056 ChangeSet changeSet = new ChangeSet()..removedSource(target); |
| 6057 analysisContext2.applyChanges(changeSet); |
| 6058 |
| 6059 computeLibrarySourceErrors(test); |
| 6060 assertErrors(test, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 6061 } |
| 6062 |
| 6048 void test_uriDoesNotExist_import_disappears_when_fixed() { | 6063 void test_uriDoesNotExist_import_disappears_when_fixed() { |
| 6049 Source source = addSource("import 'target.dart';"); | 6064 Source source = addSource("import 'target.dart';"); |
| 6050 computeLibrarySourceErrors(source); | 6065 computeLibrarySourceErrors(source); |
| 6051 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 6066 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 6052 | 6067 |
| 6053 // Check that the file is represented as missing. | 6068 // Check that the file is represented as missing. |
| 6054 Source target = | 6069 Source target = |
| 6055 analysisContext2.getSourcesWithFullName("/target.dart").first; | 6070 analysisContext2.getSourcesWithFullName("/target.dart").first; |
| 6056 expect(analysisContext2.getModificationStamp(target), -1); | 6071 expect(analysisContext2.getModificationStamp(target), -1); |
| 6057 | 6072 |
| 6058 // Add an overlay in the same way as AnalysisServer. | 6073 // Add an overlay in the same way as AnalysisServer. |
| 6059 analysisContext2 | 6074 analysisContext2 |
| 6060 ..setContents(target, "") | 6075 ..setContents(target, "") |
| 6061 ..handleContentsChanged(target, null, "", true); | 6076 ..handleContentsChanged(target, null, "", true); |
| 6062 | 6077 |
| 6063 // Make sure the error goes away. | 6078 // Make sure the error goes away. |
| 6064 computeLibrarySourceErrors(source); | 6079 computeLibrarySourceErrors(source); |
| 6065 assertErrors(source, [HintCode.UNUSED_IMPORT]); | 6080 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 6066 } | 6081 } |
| 6067 | 6082 |
| 6068 void test_uriDoesNotExist_import_appears_after_deleting_target() { | |
| 6069 Source test = addSource("import 'target.dart';"); | |
| 6070 Source target = addNamedSource("/target.dart", ""); | |
| 6071 computeLibrarySourceErrors(test); | |
| 6072 assertErrors(test, [HintCode.UNUSED_IMPORT]); | |
| 6073 | |
| 6074 // Remove the overlay in the same way as AnalysisServer. | |
| 6075 analysisContext2.setContents(target, null); | |
| 6076 ChangeSet changeSet = new ChangeSet()..removedSource(target); | |
| 6077 analysisContext2.applyChanges(changeSet); | |
| 6078 | |
| 6079 computeLibrarySourceErrors(test); | |
| 6080 assertErrors(test, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | |
| 6081 } | |
| 6082 | |
| 6083 void test_uriDoesNotExist_part() { | 6083 void test_uriDoesNotExist_part() { |
| 6084 Source source = addSource(r''' | 6084 Source source = addSource(r''' |
| 6085 library lib; | 6085 library lib; |
| 6086 part 'unknown.dart';'''); | 6086 part 'unknown.dart';'''); |
| 6087 computeLibrarySourceErrors(source); | 6087 computeLibrarySourceErrors(source); |
| 6088 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 6088 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 6089 } | 6089 } |
| 6090 | 6090 |
| 6091 void test_uriWithInterpolation_constant() { | 6091 void test_uriWithInterpolation_constant() { |
| 6092 Source source = addSource("import 'stuff_\$platform.dart';"); | 6092 Source source = addSource("import 'stuff_\$platform.dart';"); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6321 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6321 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6322 verify([source]); | 6322 verify([source]); |
| 6323 reset(); | 6323 reset(); |
| 6324 } | 6324 } |
| 6325 | 6325 |
| 6326 void _check_wrongNumberOfParametersForOperator1(String name) { | 6326 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 6327 _check_wrongNumberOfParametersForOperator(name, ""); | 6327 _check_wrongNumberOfParametersForOperator(name, ""); |
| 6328 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6328 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6329 } | 6329 } |
| 6330 } | 6330 } |
| OLD | NEW |