| 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.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 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 _analyzeAll_assertFinished(); | 1390 _analyzeAll_assertFinished(); |
| 1391 expect(context.getResolvedCompilationUnit2(source, source), isNotNull); | 1391 expect(context.getResolvedCompilationUnit2(source, source), isNotNull); |
| 1392 // new contents | 1392 // new contents |
| 1393 contentCache.setContents(source, newContents); | 1393 contentCache.setContents(source, newContents); |
| 1394 context.handleContentsChanged(source, oldContents, newContents, true); | 1394 context.handleContentsChanged(source, oldContents, newContents, true); |
| 1395 // there is some work to do | 1395 // there is some work to do |
| 1396 AnalysisResult analysisResult = context.performAnalysisTask(); | 1396 AnalysisResult analysisResult = context.performAnalysisTask(); |
| 1397 expect(analysisResult.changeNotices, isNotNull); | 1397 expect(analysisResult.changeNotices, isNotNull); |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 void test_handleContentsChanged_incremental_newContentsNull() { |
| 1401 context.analysisOptions = new AnalysisOptionsImpl()..incremental = true; |
| 1402 ContentCache contentCache = new ContentCache(); |
| 1403 context.contentCache = contentCache; |
| 1404 // old contents |
| 1405 String oldContents = 'foo() {}'; |
| 1406 Source source = resourceProvider.getFile('/test.dart').createSource(); |
| 1407 contentCache.setContents(source, oldContents); |
| 1408 expect(context.computeLibraryElement(source), isNotNull); |
| 1409 // new contents |
| 1410 String newContents = null; |
| 1411 contentCache.setContents(source, newContents); |
| 1412 context.handleContentsChanged(source, oldContents, newContents, true); |
| 1413 expect(context.getLibraryElement(source), isNull); |
| 1414 } |
| 1415 |
| 1400 Future test_implicitAnalysisEvents_added() async { | 1416 Future test_implicitAnalysisEvents_added() async { |
| 1401 AnalyzedSourcesListener listener = new AnalyzedSourcesListener(); | 1417 AnalyzedSourcesListener listener = new AnalyzedSourcesListener(); |
| 1402 context.implicitAnalysisEvents.listen(listener.onData); | 1418 context.implicitAnalysisEvents.listen(listener.onData); |
| 1403 // | 1419 // |
| 1404 // Create a file that references an file that is not explicitly being | 1420 // Create a file that references an file that is not explicitly being |
| 1405 // analyzed and fully analyze it. Ensure that the listener is told about | 1421 // analyzed and fully analyze it. Ensure that the listener is told about |
| 1406 // the implicitly analyzed file. | 1422 // the implicitly analyzed file. |
| 1407 // | 1423 // |
| 1408 Source sourceA = newSource('/a.dart', "library a; import 'b.dart';"); | 1424 Source sourceA = newSource('/a.dart', "library a; import 'b.dart';"); |
| 1409 Source sourceB = newSource('/b.dart', "library b;"); | 1425 Source sourceB = newSource('/b.dart', "library b;"); |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2926 * Initialize the visitor. | 2942 * Initialize the visitor. |
| 2927 */ | 2943 */ |
| 2928 _ElementGatherer(); | 2944 _ElementGatherer(); |
| 2929 | 2945 |
| 2930 @override | 2946 @override |
| 2931 void visitElement(Element element) { | 2947 void visitElement(Element element) { |
| 2932 elements[element] = element; | 2948 elements[element] = element; |
| 2933 super.visitElement(element); | 2949 super.visitElement(element); |
| 2934 } | 2950 } |
| 2935 } | 2951 } |
| OLD | NEW |