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

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

Issue 2228233003: Remove false positive from override hint (issue 27046) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
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.generated.analysis_context_factory; 5 library analyzer.test.generated.analysis_context_factory;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 context.analysisOptions.strongMode; 90 context.analysisOptions.strongMode;
91 // 91 //
92 // dart:core 92 // dart:core
93 // 93 //
94 TestTypeProvider provider = new TestTypeProvider(); 94 TestTypeProvider provider = new TestTypeProvider();
95 CompilationUnitElementImpl coreUnit = 95 CompilationUnitElementImpl coreUnit =
96 new CompilationUnitElementImpl("core.dart"); 96 new CompilationUnitElementImpl("core.dart");
97 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 97 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
98 coreContext.setContents(coreSource, ""); 98 coreContext.setContents(coreSource, "");
99 coreUnit.librarySource = coreUnit.source = coreSource; 99 coreUnit.librarySource = coreUnit.source = coreSource;
100 ClassElementImpl overrideClassElement =
101 ElementFactory.classElement2("_Override");
100 ClassElementImpl proxyClassElement = ElementFactory.classElement2("_Proxy"); 102 ClassElementImpl proxyClassElement = ElementFactory.classElement2("_Proxy");
101 proxyClassElement.constructors = <ConstructorElement>[ 103 proxyClassElement.constructors = <ConstructorElement>[
102 ElementFactory.constructorElement(proxyClassElement, '', true) 104 ElementFactory.constructorElement(proxyClassElement, '', true)
103 ..isCycleFree = true 105 ..isCycleFree = true
104 ..constantInitializers = <ConstructorInitializer>[] 106 ..constantInitializers = <ConstructorInitializer>[]
105 ]; 107 ];
106 ClassElement objectClassElement = provider.objectType.element; 108 ClassElement objectClassElement = provider.objectType.element;
107 coreUnit.types = <ClassElement>[ 109 coreUnit.types = <ClassElement>[
108 provider.boolType.element, 110 provider.boolType.element,
109 provider.deprecatedType.element, 111 provider.deprecatedType.element,
110 provider.doubleType.element, 112 provider.doubleType.element,
111 provider.functionType.element, 113 provider.functionType.element,
112 provider.intType.element, 114 provider.intType.element,
113 provider.iterableType.element, 115 provider.iterableType.element,
114 provider.iteratorType.element, 116 provider.iteratorType.element,
115 provider.listType.element, 117 provider.listType.element,
116 provider.mapType.element, 118 provider.mapType.element,
117 provider.nullType.element, 119 provider.nullType.element,
118 provider.numType.element, 120 provider.numType.element,
119 objectClassElement, 121 objectClassElement,
122 overrideClassElement,
120 proxyClassElement, 123 proxyClassElement,
121 provider.stackTraceType.element, 124 provider.stackTraceType.element,
122 provider.stringType.element, 125 provider.stringType.element,
123 provider.symbolType.element, 126 provider.symbolType.element,
124 provider.typeType.element 127 provider.typeType.element
125 ]; 128 ];
126 coreUnit.functions = <FunctionElement>[ 129 coreUnit.functions = <FunctionElement>[
127 ElementFactory.functionElement3("identical", provider.boolType.element, 130 ElementFactory.functionElement3("identical", provider.boolType.element,
128 <ClassElement>[objectClassElement, objectClassElement], null), 131 <ClassElement>[objectClassElement, objectClassElement], null),
129 ElementFactory.functionElement3("print", VoidTypeImpl.instance.element, 132 ElementFactory.functionElement3("print", VoidTypeImpl.instance.element,
130 <ClassElement>[objectClassElement], null) 133 <ClassElement>[objectClassElement], null)
131 ]; 134 ];
132 TopLevelVariableElement proxyTopLevelVariableElt = ElementFactory 135 TopLevelVariableElement proxyTopLevelVariableElt = ElementFactory
133 .topLevelVariableElement3("proxy", true, false, proxyClassElement.type); 136 .topLevelVariableElement3("proxy", true, false, proxyClassElement.type);
134 ConstTopLevelVariableElementImpl deprecatedTopLevelVariableElt = 137 ConstTopLevelVariableElementImpl deprecatedTopLevelVariableElt =
135 ElementFactory.topLevelVariableElement3( 138 ElementFactory.topLevelVariableElement3(
136 "deprecated", true, false, provider.deprecatedType); 139 "deprecated", true, false, provider.deprecatedType);
140 TopLevelVariableElement overrideTopLevelVariableElt =
141 ElementFactory.topLevelVariableElement3(
142 "override", true, false, overrideClassElement.type);
137 { 143 {
138 ClassElement deprecatedElement = provider.deprecatedType.element; 144 ClassElement deprecatedElement = provider.deprecatedType.element;
139 InstanceCreationExpression initializer = AstFactory 145 InstanceCreationExpression initializer = AstFactory
140 .instanceCreationExpression2( 146 .instanceCreationExpression2(
141 Keyword.CONST, 147 Keyword.CONST,
142 AstFactory.typeName(deprecatedElement), 148 AstFactory.typeName(deprecatedElement),
143 [AstFactory.string2('next release')]); 149 [AstFactory.string2('next release')]);
144 ConstructorElement constructor = deprecatedElement.constructors.single; 150 ConstructorElement constructor = deprecatedElement.constructors.single;
145 initializer.staticElement = constructor; 151 initializer.staticElement = constructor;
146 initializer.constructorName.staticElement = constructor; 152 initializer.constructorName.staticElement = constructor;
147 deprecatedTopLevelVariableElt.constantInitializer = initializer; 153 deprecatedTopLevelVariableElt.constantInitializer = initializer;
148 } 154 }
149 coreUnit.accessors = <PropertyAccessorElement>[ 155 coreUnit.accessors = <PropertyAccessorElement>[
150 proxyTopLevelVariableElt.getter, 156 deprecatedTopLevelVariableElt.getter,
151 deprecatedTopLevelVariableElt.getter 157 overrideTopLevelVariableElt.getter,
158 proxyTopLevelVariableElt.getter
152 ]; 159 ];
153 coreUnit.topLevelVariables = <TopLevelVariableElement>[ 160 coreUnit.topLevelVariables = <TopLevelVariableElement>[
154 proxyTopLevelVariableElt, 161 deprecatedTopLevelVariableElt,
155 deprecatedTopLevelVariableElt 162 overrideTopLevelVariableElt,
163 proxyTopLevelVariableElt
156 ]; 164 ];
157 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode( 165 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
158 coreContext, AstFactory.libraryIdentifier2(["dart", "core"])); 166 coreContext, AstFactory.libraryIdentifier2(["dart", "core"]));
159 coreLibrary.definingCompilationUnit = coreUnit; 167 coreLibrary.definingCompilationUnit = coreUnit;
160 // 168 //
161 // dart:async 169 // dart:async
162 // 170 //
163 Source asyncSource; 171 Source asyncSource;
164 LibraryElementImpl asyncLibrary; 172 LibraryElementImpl asyncLibrary;
165 if (context.analysisOptions.enableAsync) { 173 if (context.analysisOptions.enableAsync) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ElementFactory.constructorElement2(streamElement, null) 234 ElementFactory.constructorElement2(streamElement, null)
227 ]; 235 ];
228 DartType returnType = streamSubscriptionElement.type 236 DartType returnType = streamSubscriptionElement.type
229 .instantiate(streamElement.type.typeArguments); 237 .instantiate(streamElement.type.typeArguments);
230 FunctionElementImpl listenOnData = ElementFactory.functionElement3( 238 FunctionElementImpl listenOnData = ElementFactory.functionElement3(
231 'onData', 239 'onData',
232 VoidTypeImpl.instance.element, 240 VoidTypeImpl.instance.element,
233 <TypeDefiningElement>[streamElement.typeParameters[0]], 241 <TypeDefiningElement>[streamElement.typeParameters[0]],
234 null); 242 null);
235 listenOnData.synthetic = true; 243 listenOnData.synthetic = true;
236 List<DartType> parameterTypes = <DartType>[listenOnData.type,]; 244 List<DartType> parameterTypes = <DartType>[
245 listenOnData.type,
246 ];
237 // TODO(brianwilkerson) This is missing the optional parameters. 247 // TODO(brianwilkerson) This is missing the optional parameters.
238 MethodElementImpl listenMethod = 248 MethodElementImpl listenMethod =
239 ElementFactory.methodElement('listen', returnType, parameterTypes); 249 ElementFactory.methodElement('listen', returnType, parameterTypes);
240 streamElement.methods = <MethodElement>[listenMethod]; 250 streamElement.methods = <MethodElement>[listenMethod];
241 listenMethod.type = new FunctionTypeImpl(listenMethod); 251 listenMethod.type = new FunctionTypeImpl(listenMethod);
242 252
243 FunctionElementImpl listenParamFunction = parameterTypes[0].element; 253 FunctionElementImpl listenParamFunction = parameterTypes[0].element;
244 listenParamFunction.enclosingElement = listenMethod; 254 listenParamFunction.enclosingElement = listenMethod;
245 listenParamFunction.type = new FunctionTypeImpl(listenParamFunction); 255 listenParamFunction.type = new FunctionTypeImpl(listenParamFunction);
246 ParameterElementImpl listenParam = listenMethod.parameters[0]; 256 ParameterElementImpl listenParam = listenMethod.parameters[0];
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 565
556 void _addLibrary(LibraryMap map, String uri, bool isInternal, String path) { 566 void _addLibrary(LibraryMap map, String uri, bool isInternal, String path) {
557 SdkLibraryImpl library = new SdkLibraryImpl(uri); 567 SdkLibraryImpl library = new SdkLibraryImpl(uri);
558 if (isInternal) { 568 if (isInternal) {
559 library.category = "Internal"; 569 library.category = "Internal";
560 } 570 }
561 library.path = path; 571 library.path = path;
562 map.setLibrary(uri, library); 572 map.setLibrary(uri, library);
563 } 573 }
564 } 574 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698