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 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 void test_isServerLibrary_html() { | 1456 void test_isServerLibrary_html() { |
1457 Source source = addSource("/test.html", "<html></html>"); | 1457 Source source = addSource("/test.html", "<html></html>"); |
1458 expect(context.isServerLibrary(source), isFalse); | 1458 expect(context.isServerLibrary(source), isFalse); |
1459 } | 1459 } |
1460 | 1460 |
1461 void test_isServerLibrary_unknown() { | 1461 void test_isServerLibrary_unknown() { |
1462 Source source = newSource("/test.dart"); | 1462 Source source = newSource("/test.dart"); |
1463 expect(context.isServerLibrary(source), isFalse); | 1463 expect(context.isServerLibrary(source), isFalse); |
1464 } | 1464 } |
1465 | 1465 |
| 1466 void test_onResultInvalidated_removeSource() { |
| 1467 Source source = addSource('/test.dart', 'main() {}'); |
| 1468 bool listenerInvoked = false; |
| 1469 context |
| 1470 .onResultInvalidated(RESOLVED_UNIT) |
| 1471 .listen((InvalidatedResult event) { |
| 1472 Source eventSource = event.entry.target.source; |
| 1473 expect(event.descriptor, RESOLVED_UNIT); |
| 1474 expect(eventSource, source); |
| 1475 listenerInvoked = true; |
| 1476 }); |
| 1477 _analyzeAll_assertFinished(); |
| 1478 // apply changes |
| 1479 expect(listenerInvoked, false); |
| 1480 context.applyChanges(new ChangeSet()..removedSource(source)); |
| 1481 // verify |
| 1482 expect(listenerInvoked, isTrue); |
| 1483 } |
| 1484 |
| 1485 void test_onResultInvalidated_setContents() { |
| 1486 Source source = addSource('/test.dart', 'main() {}'); |
| 1487 bool listenerInvoked = false; |
| 1488 context |
| 1489 .onResultInvalidated(RESOLVED_UNIT) |
| 1490 .listen((InvalidatedResult event) { |
| 1491 Source eventSource = event.entry.target.source; |
| 1492 expect(event.descriptor, RESOLVED_UNIT); |
| 1493 expect(eventSource, source); |
| 1494 listenerInvoked = true; |
| 1495 }); |
| 1496 _analyzeAll_assertFinished(); |
| 1497 // apply changes |
| 1498 expect(listenerInvoked, false); |
| 1499 context.setContents(source, 'class B {}'); |
| 1500 // verify |
| 1501 expect(listenerInvoked, isTrue); |
| 1502 } |
| 1503 |
1466 void test_parseCompilationUnit_errors() { | 1504 void test_parseCompilationUnit_errors() { |
1467 Source source = addSource("/lib.dart", "library {"); | 1505 Source source = addSource("/lib.dart", "library {"); |
1468 CompilationUnit compilationUnit = context.parseCompilationUnit(source); | 1506 CompilationUnit compilationUnit = context.parseCompilationUnit(source); |
1469 expect(compilationUnit, isNotNull); | 1507 expect(compilationUnit, isNotNull); |
1470 var errorInfo = context.getErrors(source); | 1508 var errorInfo = context.getErrors(source); |
1471 expect(errorInfo, isNotNull); | 1509 expect(errorInfo, isNotNull); |
1472 List<AnalysisError> errors = errorInfo.errors; | 1510 List<AnalysisError> errors = errorInfo.errors; |
1473 expect(errors, isNotNull); | 1511 expect(errors, isNotNull); |
1474 expect(errors.length > 0, isTrue); | 1512 expect(errors.length > 0, isTrue); |
1475 } | 1513 } |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2880 * Initialize the visitor. | 2918 * Initialize the visitor. |
2881 */ | 2919 */ |
2882 _ElementGatherer(); | 2920 _ElementGatherer(); |
2883 | 2921 |
2884 @override | 2922 @override |
2885 void visitElement(Element element) { | 2923 void visitElement(Element element) { |
2886 elements[element] = element; | 2924 elements[element] = element; |
2887 super.visitElement(element); | 2925 super.visitElement(element); |
2888 } | 2926 } |
2889 } | 2927 } |
OLD | NEW |