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

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2249833002: Reset analysis driver after incremental changes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « pkg/analyzer/lib/src/context/context.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 analyzer.test.src.context.context_test; 5 library analyzer.test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 CacheState.INVALID); 336 CacheState.INVALID);
337 expect( 337 expect(
338 context.getCacheEntry(source).modificationTime, file.modificationStamp); 338 context.getCacheEntry(source).modificationTime, file.modificationStamp);
339 } 339 }
340 340
341 void test_applyChanges_empty() { 341 void test_applyChanges_empty() {
342 context.applyChanges(new ChangeSet()); 342 context.applyChanges(new ChangeSet());
343 expect(context.performAnalysisTask().changeNotices, isNull); 343 expect(context.performAnalysisTask().changeNotices, isNull);
344 } 344 }
345 345
346 void test_applyChanges_incremental_resetDriver() {
347 context.analysisOptions = new AnalysisOptionsImpl()..incremental = true;
348 Source source = addSource(
349 "/test.dart",
350 r'''
351 main() {
352 print(42);
353 }
354 ''');
355 _performPendingAnalysisTasks();
356 expect(context.getErrors(source).errors, hasLength(0));
357 // Update the source to have a parse error.
358 // This is an incremental change, but we always invalidate DART_ERRORS.
359 context.setContents(
360 source,
361 r'''
362 main() {
363 print(42)
364 }
365 ''');
366 AnalysisCache cache = context.analysisCache;
367 expect(cache.getValue(source, PARSE_ERRORS), hasLength(1));
368 expect(cache.getState(source, DART_ERRORS), CacheState.INVALID);
369 // Perform enough analysis to prepare inputs (is not actually tested) for
370 // the DART_ERRORS computing task, but don't compute it yet.
371 context.performAnalysisTask();
372 context.performAnalysisTask();
373 expect(cache.getState(source, DART_ERRORS), CacheState.INVALID);
374 // Update the source so that PARSE_ERRORS is empty.
375 context.setContents(
376 source,
377 r'''
378 main() {
379 print(42);
380 }
381 ''');
382 expect(cache.getValue(source, PARSE_ERRORS), hasLength(0));
383 // After full analysis DART_ERRORS should also be empty.
384 _performPendingAnalysisTasks();
385 expect(cache.getValue(source, DART_ERRORS), hasLength(0));
386 expect(context.getErrors(source).errors, hasLength(0));
387 }
388
346 void test_applyChanges_overriddenSource() { 389 void test_applyChanges_overriddenSource() {
347 String content = "library test;"; 390 String content = "library test;";
348 Source source = addSource("/test.dart", content); 391 Source source = addSource("/test.dart", content);
349 context.setContents(source, content); 392 context.setContents(source, content);
350 context.computeErrors(source); 393 context.computeErrors(source);
351 while (!context.sourcesNeedingProcessing.isEmpty) { 394 while (!context.sourcesNeedingProcessing.isEmpty) {
352 context.performAnalysisTask(); 395 context.performAnalysisTask();
353 } 396 }
354 // Adding the source as a changedSource should have no effect since 397 // Adding the source as a changedSource should have no effect since
355 // it is already overridden in the content cache. 398 // it is already overridden in the content cache.
(...skipping 4826 matching lines...) Expand 10 before | Expand all | Expand 10 after
5182 * Initialize the visitor. 5225 * Initialize the visitor.
5183 */ 5226 */
5184 _ElementGatherer(); 5227 _ElementGatherer();
5185 5228
5186 @override 5229 @override
5187 void visitElement(Element element) { 5230 void visitElement(Element element) {
5188 elements[element] = element; 5231 elements[element] = element;
5189 super.visitElement(element); 5232 super.visitElement(element);
5190 } 5233 }
5191 } 5234 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698