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

Side by Side Diff: pkg/analyzer/test/generated/element_test.dart

Issue 1162013007: associate @deprecated with enum element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 6 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/generated/resolver.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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element_test; 8 library engine.element_test;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 30 matching lines...) Expand all
41 runReflectiveTests(ParameterElementImplTest); 41 runReflectiveTests(ParameterElementImplTest);
42 } 42 }
43 43
44 @reflectiveTest 44 @reflectiveTest
45 class ClassElementImplTest extends EngineTestCase { 45 class ClassElementImplTest extends EngineTestCase {
46 void test_computeNode_ClassDeclaration() { 46 void test_computeNode_ClassDeclaration() {
47 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); 47 AnalysisContextHelper contextHelper = new AnalysisContextHelper();
48 AnalysisContext context = contextHelper.context; 48 AnalysisContext context = contextHelper.context;
49 Source source = contextHelper.addSource("/test.dart", r''' 49 Source source = contextHelper.addSource("/test.dart", r'''
50 class A {} 50 class A {}
51 class B {} 51 @deprecated class B {}
52 enum C {C1, C2, C3}'''); 52 enum C {C1, C2, C3}
53 @deprecated enum D {D1, D2, D3}''');
53 // prepare CompilationUnitElement 54 // prepare CompilationUnitElement
54 LibraryElement libraryElement = context.computeLibraryElement(source); 55 LibraryElement libraryElement = context.computeLibraryElement(source);
55 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; 56 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit;
56 // A 57 // A
57 { 58 {
58 ClassElement elementA = unitElement.getType("A"); 59 ClassElement elementA = unitElement.getType("A");
60 expect(elementA.isDeprecated, isFalse);
61 expect(elementA.isEnum, isFalse);
59 ClassDeclaration nodeA = elementA.computeNode(); 62 ClassDeclaration nodeA = elementA.computeNode();
60 expect(nodeA, isNotNull); 63 expect(nodeA, isNotNull);
61 expect(nodeA.name.name, "A"); 64 expect(nodeA.name.name, "A");
62 expect(nodeA.element, same(elementA)); 65 expect(nodeA.element, same(elementA));
63 } 66 }
64 // B 67 // B
65 { 68 {
66 ClassElement elementB = unitElement.getType("B"); 69 ClassElement elementB = unitElement.getType("B");
70 expect(elementB.isDeprecated, isTrue);
71 expect(elementB.isEnum, isFalse);
67 ClassDeclaration nodeB = elementB.computeNode(); 72 ClassDeclaration nodeB = elementB.computeNode();
68 expect(nodeB, isNotNull); 73 expect(nodeB, isNotNull);
69 expect(nodeB.name.name, "B"); 74 expect(nodeB.name.name, "B");
70 expect(nodeB.element, same(elementB)); 75 expect(nodeB.element, same(elementB));
71 } 76 }
72 // C 77 // C
73 { 78 {
74 ClassElement elementC = unitElement.getEnum("C"); 79 ClassElement elementC = unitElement.getEnum("C");
80 expect(elementC.isDeprecated, isFalse);
81 expect(elementC.isEnum, isTrue);
75 EnumDeclaration nodeC = elementC.computeNode(); 82 EnumDeclaration nodeC = elementC.computeNode();
76 expect(nodeC, isNotNull); 83 expect(nodeC, isNotNull);
77 expect(nodeC.name.name, "C"); 84 expect(nodeC.name.name, "C");
78 expect(nodeC.element, same(elementC)); 85 expect(nodeC.element, same(elementC));
79 } 86 }
87 // D
88 {
89 ClassElement elementD = unitElement.getEnum("D");
90 expect(elementD.isDeprecated, isTrue);
91 expect(elementD.isEnum, isTrue);
92 EnumDeclaration nodeC = elementD.computeNode();
93 expect(nodeC, isNotNull);
94 expect(nodeC.name.name, "D");
95 expect(nodeC.element, same(elementD));
96 }
80 } 97 }
81 98
82 void test_computeNode_ClassTypeAlias() { 99 void test_computeNode_ClassTypeAlias() {
83 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); 100 AnalysisContextHelper contextHelper = new AnalysisContextHelper();
84 AnalysisContext context = contextHelper.context; 101 AnalysisContext context = contextHelper.context;
85 Source source = contextHelper.addSource("/test.dart", r''' 102 Source source = contextHelper.addSource("/test.dart", r'''
86 abstract class A<K, V> = Object with MapMixin<K, V>; 103 abstract class A<K, V> = Object with MapMixin<K, V>;
87 '''); 104 ''');
88 // prepare CompilationUnitElement 105 // prepare CompilationUnitElement
89 LibraryElement libraryElement = context.computeLibraryElement(source); 106 LibraryElement libraryElement = context.computeLibraryElement(source);
(...skipping 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 } 4237 }
4221 4238
4222 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction 4239 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction
4223 extends InterfaceTypeImpl { 4240 extends InterfaceTypeImpl {
4224 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) 4241 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0)
4225 : super(arg0); 4242 : super(arg0);
4226 4243
4227 @override 4244 @override
4228 bool get isDartCoreFunction => true; 4245 bool get isDartCoreFunction => true;
4229 } 4246 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698