OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.dart.constant.utilities_test; | 5 library analyzer.test.src.dart.constant.utilities_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 * Test an annotation that consists solely of an identifier (and hence | 50 * Test an annotation that consists solely of an identifier (and hence |
51 * represents a reference to a compile-time constant variable). | 51 * represents a reference to a compile-time constant variable). |
52 */ | 52 */ |
53 void test_visitAnnotation_constantVariable() { | 53 void test_visitAnnotation_constantVariable() { |
54 CompilationUnitElement compilationUnitElement = | 54 CompilationUnitElement compilationUnitElement = |
55 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; | 55 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; |
56 ElementFactory.library(_context, 'L').definingCompilationUnit = | 56 ElementFactory.library(_context, 'L').definingCompilationUnit = |
57 compilationUnitElement; | 57 compilationUnitElement; |
58 ElementAnnotationImpl elementAnnotation = | 58 ElementAnnotationImpl elementAnnotation = |
59 new ElementAnnotationImpl(compilationUnitElement); | 59 new ElementAnnotationImpl(compilationUnitElement); |
60 _node = elementAnnotation.annotationAst = AstTestFactory.annotation( | 60 _node = elementAnnotation.annotationAst = AstTestFactory |
61 AstTestFactory.identifier3('x'))..elementAnnotation = elementAnnotation; | 61 .annotation(AstTestFactory.identifier3('x')) |
| 62 ..elementAnnotation = elementAnnotation; |
62 expect(_findAnnotations(), contains(_node)); | 63 expect(_findAnnotations(), contains(_node)); |
63 } | 64 } |
64 | 65 |
65 void test_visitAnnotation_enumConstant() { | 66 void test_visitAnnotation_enumConstant() { |
66 // Analyzer ignores annotations on enum constant declarations. | 67 // Analyzer ignores annotations on enum constant declarations. |
67 Annotation annotation = AstTestFactory.annotation2( | 68 Annotation annotation = AstTestFactory.annotation2( |
68 AstTestFactory.identifier3('A'), null, AstTestFactory.argumentList()); | 69 AstTestFactory.identifier3('A'), null, AstTestFactory.argumentList()); |
69 _node = astFactory.enumConstantDeclaration( | 70 _node = astFactory.enumConstantDeclaration( |
70 null, <Annotation>[annotation], AstTestFactory.identifier3('C')); | 71 null, <Annotation>[annotation], AstTestFactory.identifier3('C')); |
71 expect(_findConstants(), isEmpty); | 72 expect(_findConstants(), isEmpty); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 357 |
357 void _visitNode(AstNode node) { | 358 void _visitNode(AstNode node) { |
358 node.accept(_createReferenceFinder(_head)); | 359 node.accept(_createReferenceFinder(_head)); |
359 } | 360 } |
360 } | 361 } |
361 | 362 |
362 class _TestAnalysisContext extends TestAnalysisContext { | 363 class _TestAnalysisContext extends TestAnalysisContext { |
363 @override | 364 @override |
364 InternalAnalysisContext getContextFor(Source source) => this; | 365 InternalAnalysisContext getContextFor(Source source) => this; |
365 } | 366 } |
OLD | NEW |