| 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/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/ast/token.dart'; | 10 import 'package:analyzer/src/dart/ast/token.dart'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; | 54 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; |
| 55 ElementFactory.library(_context, 'L').definingCompilationUnit = | 55 ElementFactory.library(_context, 'L').definingCompilationUnit = |
| 56 compilationUnitElement; | 56 compilationUnitElement; |
| 57 ElementAnnotationImpl elementAnnotation = | 57 ElementAnnotationImpl elementAnnotation = |
| 58 new ElementAnnotationImpl(compilationUnitElement); | 58 new ElementAnnotationImpl(compilationUnitElement); |
| 59 _node = elementAnnotation.annotationAst = AstFactory.annotation( | 59 _node = elementAnnotation.annotationAst = AstFactory.annotation( |
| 60 AstFactory.identifier3('x'))..elementAnnotation = elementAnnotation; | 60 AstFactory.identifier3('x'))..elementAnnotation = elementAnnotation; |
| 61 expect(_findAnnotations(), contains(_node)); | 61 expect(_findAnnotations(), contains(_node)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void test_visitAnnotation_enumConstant() { |
| 65 // Analyzer ignores annotations on enum constant declarations. |
| 66 Annotation annotation = AstFactory.annotation2( |
| 67 AstFactory.identifier3('A'), null, AstFactory.argumentList()); |
| 68 _node = new EnumConstantDeclaration( |
| 69 null, <Annotation>[annotation], AstFactory.identifier3('C')); |
| 70 expect(_findConstants(), isEmpty); |
| 71 } |
| 72 |
| 64 /** | 73 /** |
| 65 * Test an annotation that represents the invocation of a constant | 74 * Test an annotation that represents the invocation of a constant |
| 66 * constructor. | 75 * constructor. |
| 67 */ | 76 */ |
| 68 void test_visitAnnotation_invocation() { | 77 void test_visitAnnotation_invocation() { |
| 69 CompilationUnitElement compilationUnitElement = | 78 CompilationUnitElement compilationUnitElement = |
| 70 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; | 79 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; |
| 71 ElementFactory.library(_context, 'L').definingCompilationUnit = | 80 ElementFactory.library(_context, 'L').definingCompilationUnit = |
| 72 compilationUnitElement; | 81 compilationUnitElement; |
| 73 ElementAnnotationImpl elementAnnotation = | 82 ElementAnnotationImpl elementAnnotation = |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 354 |
| 346 void _visitNode(AstNode node) { | 355 void _visitNode(AstNode node) { |
| 347 node.accept(_createReferenceFinder(_head)); | 356 node.accept(_createReferenceFinder(_head)); |
| 348 } | 357 } |
| 349 } | 358 } |
| 350 | 359 |
| 351 class _TestAnalysisContext extends TestAnalysisContext { | 360 class _TestAnalysisContext extends TestAnalysisContext { |
| 352 @override | 361 @override |
| 353 InternalAnalysisContext getContextFor(Source source) => this; | 362 InternalAnalysisContext getContextFor(Source source) => this; |
| 354 } | 363 } |
| OLD | NEW |