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

Unified Diff: pkg/analyzer/test/generated/incremental_resolver_test.dart

Issue 818173003: Use all library units for hints during incremental resolution. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/incremental_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/incremental_resolver_test.dart b/pkg/analyzer/test/generated/incremental_resolver_test.dart
index 014241d2ec47e941ab0606029c961e4ad3a324a7..b45db86ce3a9f3afbb44bc595450aec7d88e6f6e 100644
--- a/pkg/analyzer/test/generated/incremental_resolver_test.dart
+++ b/pkg/analyzer/test/generated/incremental_resolver_test.dart
@@ -2432,11 +2432,10 @@ class B {
int updateOffset = edit.offset;
int updateEndOld = updateOffset + edit.length;
int updateOldNew = updateOffset + edit.replacement.length;
- IncrementalResolver resolver = new IncrementalResolver(
- unit.element,
- updateOffset,
- updateEndOld,
- updateOldNew);
+ IncrementalResolver resolver =
+ new IncrementalResolver(<Source, CompilationUnit>{
+ source: newUnit
+ }, unit.element, updateOffset, updateEndOld, updateOldNew);
bool success = resolver.resolve(newNode);
expect(success, isTrue);
List<AnalysisError> newErrors = analysisContext.getErrors(source).errors;
@@ -3059,6 +3058,82 @@ class A {
''');
}
+ void test_unusedHint_add_wasUsedOnlyInPart() {
+ Source partSource = addNamedSource('/my_unit.dart', r'''
+part of lib;
+
+f(A a) {
+ a._foo();
+}
+''');
+ _resolveUnit(r'''
+library lib;
+part 'my_unit.dart';
+class A {
+ _foo() {
+ print(1);
+ }
+}
+''');
+ _runTasks();
+ // perform incremental resolution
+ _resetWithIncremental(true);
+ analysisContext2.setContents(partSource, r'''
+part of lib;
+
+f(A a) {
+// a._foo();
+}
+''');
+ // a new hint should be added
+ List<AnalysisError> errors = analysisContext.getErrors(source).errors;
+ expect(errors, hasLength(1));
+ expect(errors[0].errorCode.type, ErrorType.HINT);
+ // the same hint should be reported using a ChangeNotice
+ bool noticeFound = false;
+ AnalysisResult result = analysisContext2.performAnalysisTask();
+ for (ChangeNotice notice in result.changeNotices) {
+ if (notice.source == source) {
+ expect(notice.errors, contains(errors[0]));
+ noticeFound = true;
+ }
+ }
+ expect(noticeFound, isTrue);
+ }
+
+ void test_unusedHint_false_stillUsedInPart() {
+ addNamedSource('/my_unit.dart', r'''
+part of lib;
+
+f(A a) {
+ a._foo();
+}
+''');
+ _resolveUnit(r'''
+library lib;
+part 'my_unit.dart';
+class A {
+ _foo() {
+ print(1);
+ }
+}
+''');
+ // perform incremental resolution
+ _resetWithIncremental(true);
+ analysisContext2.setContents(source, r'''
+library lib;
+part 'my_unit.dart';
+class A {
+ _foo() {
+ print(12);
+ }
+}
+''');
+ // no hints
+ List<AnalysisError> errors = analysisContext.getErrors(source).errors;
+ expect(errors, isEmpty);
+ }
+
void test_updateErrors_addNew_hint() {
_resolveUnit(r'''
int main() {
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698