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

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

Issue 1842563003: Format everything in analyzer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 SourceFactory sourceFactory = new SourceFactory(resolvers); 86 SourceFactory sourceFactory = new SourceFactory(resolvers);
87 context.sourceFactory = sourceFactory; 87 context.sourceFactory = sourceFactory;
88 AnalysisContext coreContext = sdk.context; 88 AnalysisContext coreContext = sdk.context;
89 (coreContext.analysisOptions as AnalysisOptionsImpl).strongMode = 89 (coreContext.analysisOptions as AnalysisOptionsImpl).strongMode =
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 proxyClassElement = ElementFactory.classElement2("_Proxy"); 100 ClassElementImpl proxyClassElement = ElementFactory.classElement2("_Proxy");
101 proxyClassElement.constructors = <ConstructorElement>[ 101 proxyClassElement.constructors = <ConstructorElement>[
102 ElementFactory.constructorElement(proxyClassElement, '', true) 102 ElementFactory.constructorElement(proxyClassElement, '', true)
103 ..isCycleFree = true 103 ..isCycleFree = true
104 ..constantInitializers = <ConstructorInitializer>[] 104 ..constantInitializers = <ConstructorInitializer>[]
105 ]; 105 ];
106 ClassElement objectClassElement = provider.objectType.element; 106 ClassElement objectClassElement = provider.objectType.element;
(...skipping 18 matching lines...) Expand all
125 ]; 125 ];
126 coreUnit.functions = <FunctionElement>[ 126 coreUnit.functions = <FunctionElement>[
127 ElementFactory.functionElement3("identical", provider.boolType.element, 127 ElementFactory.functionElement3("identical", provider.boolType.element,
128 <ClassElement>[objectClassElement, objectClassElement], null), 128 <ClassElement>[objectClassElement, objectClassElement], null),
129 ElementFactory.functionElement3("print", VoidTypeImpl.instance.element, 129 ElementFactory.functionElement3("print", VoidTypeImpl.instance.element,
130 <ClassElement>[objectClassElement], null) 130 <ClassElement>[objectClassElement], null)
131 ]; 131 ];
132 TopLevelVariableElement proxyTopLevelVariableElt = ElementFactory 132 TopLevelVariableElement proxyTopLevelVariableElt = ElementFactory
133 .topLevelVariableElement3("proxy", true, false, proxyClassElement.type); 133 .topLevelVariableElement3("proxy", true, false, proxyClassElement.type);
134 ConstTopLevelVariableElementImpl deprecatedTopLevelVariableElt = 134 ConstTopLevelVariableElementImpl deprecatedTopLevelVariableElt =
135 ElementFactory.topLevelVariableElement3( 135 ElementFactory.topLevelVariableElement3(
136 "deprecated", true, false, provider.deprecatedType); 136 "deprecated", true, false, provider.deprecatedType);
137 { 137 {
138 ClassElement deprecatedElement = provider.deprecatedType.element; 138 ClassElement deprecatedElement = provider.deprecatedType.element;
139 InstanceCreationExpression initializer = AstFactory 139 InstanceCreationExpression initializer = AstFactory
140 .instanceCreationExpression2( 140 .instanceCreationExpression2(
141 Keyword.CONST, 141 Keyword.CONST,
142 AstFactory.typeName(deprecatedElement), 142 AstFactory.typeName(deprecatedElement),
143 [AstFactory.string2('next release')]); 143 [AstFactory.string2('next release')]);
144 ConstructorElement constructor = deprecatedElement.constructors.single; 144 ConstructorElement constructor = deprecatedElement.constructors.single;
145 initializer.staticElement = constructor; 145 initializer.staticElement = constructor;
146 initializer.constructorName.staticElement = constructor; 146 initializer.constructorName.staticElement = constructor;
147 deprecatedTopLevelVariableElt.constantInitializer = initializer; 147 deprecatedTopLevelVariableElt.constantInitializer = initializer;
148 } 148 }
149 coreUnit.accessors = <PropertyAccessorElement>[ 149 coreUnit.accessors = <PropertyAccessorElement>[
150 proxyTopLevelVariableElt.getter, 150 proxyTopLevelVariableElt.getter,
151 deprecatedTopLevelVariableElt.getter 151 deprecatedTopLevelVariableElt.getter
152 ]; 152 ];
153 coreUnit.topLevelVariables = <TopLevelVariableElement>[ 153 coreUnit.topLevelVariables = <TopLevelVariableElement>[
154 proxyTopLevelVariableElt, 154 proxyTopLevelVariableElt,
155 deprecatedTopLevelVariableElt 155 deprecatedTopLevelVariableElt
156 ]; 156 ];
157 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode( 157 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
158 coreContext, AstFactory.libraryIdentifier2(["dart", "core"])); 158 coreContext, AstFactory.libraryIdentifier2(["dart", "core"]));
159 coreLibrary.definingCompilationUnit = coreUnit; 159 coreLibrary.definingCompilationUnit = coreUnit;
160 // 160 //
161 // dart:async 161 // dart:async
162 // 162 //
163 Source asyncSource; 163 Source asyncSource;
164 LibraryElementImpl asyncLibrary; 164 LibraryElementImpl asyncLibrary;
165 if (context.analysisOptions.enableAsync) { 165 if (context.analysisOptions.enableAsync) {
166 asyncLibrary = new LibraryElementImpl.forNode( 166 asyncLibrary = new LibraryElementImpl.forNode(
167 coreContext, AstFactory.libraryIdentifier2(["dart", "async"])); 167 coreContext, AstFactory.libraryIdentifier2(["dart", "async"]));
168 CompilationUnitElementImpl asyncUnit = 168 CompilationUnitElementImpl asyncUnit =
169 new CompilationUnitElementImpl("async.dart"); 169 new CompilationUnitElementImpl("async.dart");
170 asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); 170 asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
171 coreContext.setContents(asyncSource, ""); 171 coreContext.setContents(asyncSource, "");
172 asyncUnit.librarySource = asyncUnit.source = asyncSource; 172 asyncUnit.librarySource = asyncUnit.source = asyncSource;
173 asyncLibrary.definingCompilationUnit = asyncUnit; 173 asyncLibrary.definingCompilationUnit = asyncUnit;
174 // Future 174 // Future
175 ClassElementImpl futureElement = 175 ClassElementImpl futureElement =
176 ElementFactory.classElement2("Future", ["T"]); 176 ElementFactory.classElement2("Future", ["T"]);
177 futureElement.enclosingElement = asyncUnit; 177 futureElement.enclosingElement = asyncUnit;
178 // factory Future.value([value]) 178 // factory Future.value([value])
179 ConstructorElementImpl futureConstructor = 179 ConstructorElementImpl futureConstructor =
180 ElementFactory.constructorElement2(futureElement, "value"); 180 ElementFactory.constructorElement2(futureElement, "value");
181 futureConstructor.parameters = <ParameterElement>[ 181 futureConstructor.parameters = <ParameterElement>[
182 ElementFactory.positionalParameter2("value", provider.dynamicType) 182 ElementFactory.positionalParameter2("value", provider.dynamicType)
183 ]; 183 ];
184 futureConstructor.factory = true; 184 futureConstructor.factory = true;
185 futureElement.constructors = <ConstructorElement>[futureConstructor]; 185 futureElement.constructors = <ConstructorElement>[futureConstructor];
186 // Future then(onValue(T value), { Function onError }); 186 // Future then(onValue(T value), { Function onError });
187 TypeDefiningElement futureThenR = DynamicElementImpl.instance; 187 TypeDefiningElement futureThenR = DynamicElementImpl.instance;
188 if (context.analysisOptions.strongMode) { 188 if (context.analysisOptions.strongMode) {
189 futureThenR = ElementFactory.typeParameterWithType('R'); 189 futureThenR = ElementFactory.typeParameterWithType('R');
190 } 190 }
(...skipping 12 matching lines...) Expand all
203 } 203 }
204 thenOnValue.enclosingElement = thenMethod; 204 thenOnValue.enclosingElement = thenMethod;
205 thenOnValue.type = new FunctionTypeImpl(thenOnValue); 205 thenOnValue.type = new FunctionTypeImpl(thenOnValue);
206 (thenMethod.parameters[0] as ParameterElementImpl).type = 206 (thenMethod.parameters[0] as ParameterElementImpl).type =
207 thenOnValue.type; 207 thenOnValue.type;
208 thenMethod.type = new FunctionTypeImpl(thenMethod); 208 thenMethod.type = new FunctionTypeImpl(thenMethod);
209 209
210 futureElement.methods = <MethodElement>[thenMethod]; 210 futureElement.methods = <MethodElement>[thenMethod];
211 // Completer 211 // Completer
212 ClassElementImpl completerElement = 212 ClassElementImpl completerElement =
213 ElementFactory.classElement2("Completer", ["T"]); 213 ElementFactory.classElement2("Completer", ["T"]);
214 ConstructorElementImpl completerConstructor = 214 ConstructorElementImpl completerConstructor =
215 ElementFactory.constructorElement2(completerElement, null); 215 ElementFactory.constructorElement2(completerElement, null);
216 completerElement.constructors = <ConstructorElement>[ 216 completerElement.constructors = <ConstructorElement>[
217 completerConstructor 217 completerConstructor
218 ]; 218 ];
219 // StreamSubscription 219 // StreamSubscription
220 ClassElementImpl streamSubscriptionElement = 220 ClassElementImpl streamSubscriptionElement =
221 ElementFactory.classElement2("StreamSubscription", ["T"]); 221 ElementFactory.classElement2("StreamSubscription", ["T"]);
222 // Stream 222 // Stream
223 ClassElementImpl streamElement = 223 ClassElementImpl streamElement =
224 ElementFactory.classElement2("Stream", ["T"]); 224 ElementFactory.classElement2("Stream", ["T"]);
225 streamElement.constructors = <ConstructorElement>[ 225 streamElement.constructors = <ConstructorElement>[
226 ElementFactory.constructorElement2(streamElement, null) 226 ElementFactory.constructorElement2(streamElement, null)
227 ]; 227 ];
228 DartType returnType = streamSubscriptionElement.type 228 DartType returnType = streamSubscriptionElement.type
229 .instantiate(streamElement.type.typeArguments); 229 .instantiate(streamElement.type.typeArguments);
230 FunctionElementImpl listenOnData = ElementFactory.functionElement3( 230 FunctionElementImpl listenOnData = ElementFactory.functionElement3(
231 'onData', 231 'onData',
232 VoidTypeImpl.instance.element, 232 VoidTypeImpl.instance.element,
233 <TypeDefiningElement>[streamElement.typeParameters[0]], 233 <TypeDefiningElement>[streamElement.typeParameters[0]],
234 null); 234 null);
235 listenOnData.synthetic = true; 235 listenOnData.synthetic = true;
236 List<DartType> parameterTypes = <DartType>[listenOnData.type,]; 236 List<DartType> parameterTypes = <DartType>[listenOnData.type,];
237 // TODO(brianwilkerson) This is missing the optional parameters. 237 // TODO(brianwilkerson) This is missing the optional parameters.
238 MethodElementImpl listenMethod = 238 MethodElementImpl listenMethod =
239 ElementFactory.methodElement('listen', returnType, parameterTypes); 239 ElementFactory.methodElement('listen', returnType, parameterTypes);
240 streamElement.methods = <MethodElement>[listenMethod]; 240 streamElement.methods = <MethodElement>[listenMethod];
241 listenMethod.type = new FunctionTypeImpl(listenMethod); 241 listenMethod.type = new FunctionTypeImpl(listenMethod);
242 242
243 FunctionElementImpl listenParamFunction = parameterTypes[0].element; 243 FunctionElementImpl listenParamFunction = parameterTypes[0].element;
244 listenParamFunction.enclosingElement = listenMethod; 244 listenParamFunction.enclosingElement = listenMethod;
245 listenParamFunction.type = new FunctionTypeImpl(listenParamFunction); 245 listenParamFunction.type = new FunctionTypeImpl(listenParamFunction);
246 ParameterElementImpl listenParam = listenMethod.parameters[0]; 246 ParameterElementImpl listenParam = listenMethod.parameters[0];
247 listenParam.type = listenParamFunction.type; 247 listenParam.type = listenParamFunction.type;
248 248
249 asyncUnit.types = <ClassElement>[ 249 asyncUnit.types = <ClassElement>[
250 completerElement, 250 completerElement,
251 futureElement, 251 futureElement,
252 streamElement, 252 streamElement,
253 streamSubscriptionElement 253 streamSubscriptionElement
254 ]; 254 ];
255 } 255 }
256 // 256 //
257 // dart:html 257 // dart:html
258 // 258 //
259 CompilationUnitElementImpl htmlUnit = 259 CompilationUnitElementImpl htmlUnit =
260 new CompilationUnitElementImpl("html_dartium.dart"); 260 new CompilationUnitElementImpl("html_dartium.dart");
261 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 261 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
262 coreContext.setContents(htmlSource, ""); 262 coreContext.setContents(htmlSource, "");
263 htmlUnit.librarySource = htmlUnit.source = htmlSource; 263 htmlUnit.librarySource = htmlUnit.source = htmlSource;
264 ClassElementImpl elementElement = ElementFactory.classElement2("Element"); 264 ClassElementImpl elementElement = ElementFactory.classElement2("Element");
265 InterfaceType elementType = elementElement.type; 265 InterfaceType elementType = elementElement.type;
266 ClassElementImpl canvasElement = 266 ClassElementImpl canvasElement =
267 ElementFactory.classElement("CanvasElement", elementType); 267 ElementFactory.classElement("CanvasElement", elementType);
268 ClassElementImpl contextElement = 268 ClassElementImpl contextElement =
269 ElementFactory.classElement2("CanvasRenderingContext"); 269 ElementFactory.classElement2("CanvasRenderingContext");
270 InterfaceType contextElementType = contextElement.type; 270 InterfaceType contextElementType = contextElement.type;
271 ClassElementImpl context2dElement = ElementFactory.classElement( 271 ClassElementImpl context2dElement = ElementFactory.classElement(
272 "CanvasRenderingContext2D", contextElementType); 272 "CanvasRenderingContext2D", contextElementType);
273 canvasElement.methods = <MethodElement>[ 273 canvasElement.methods = <MethodElement>[
274 ElementFactory.methodElement( 274 ElementFactory.methodElement(
275 "getContext", contextElementType, [provider.stringType]) 275 "getContext", contextElementType, [provider.stringType])
276 ]; 276 ];
277 canvasElement.accessors = <PropertyAccessorElement>[ 277 canvasElement.accessors = <PropertyAccessorElement>[
278 ElementFactory.getterElement("context2D", false, context2dElement.type) 278 ElementFactory.getterElement("context2D", false, context2dElement.type)
279 ]; 279 ];
280 canvasElement.fields = canvasElement.accessors 280 canvasElement.fields = canvasElement.accessors
281 .map((PropertyAccessorElement accessor) => accessor.variable) 281 .map((PropertyAccessorElement accessor) => accessor.variable)
282 .toList(); 282 .toList();
283 ClassElementImpl documentElement = 283 ClassElementImpl documentElement =
284 ElementFactory.classElement("Document", elementType); 284 ElementFactory.classElement("Document", elementType);
285 ClassElementImpl htmlDocumentElement = 285 ClassElementImpl htmlDocumentElement =
286 ElementFactory.classElement("HtmlDocument", documentElement.type); 286 ElementFactory.classElement("HtmlDocument", documentElement.type);
287 htmlDocumentElement.methods = <MethodElement>[ 287 htmlDocumentElement.methods = <MethodElement>[
288 ElementFactory 288 ElementFactory
289 .methodElement("query", elementType, <DartType>[provider.stringType]) 289 .methodElement("query", elementType, <DartType>[provider.stringType])
290 ]; 290 ];
291 htmlUnit.types = <ClassElement>[ 291 htmlUnit.types = <ClassElement>[
292 ElementFactory.classElement("AnchorElement", elementType), 292 ElementFactory.classElement("AnchorElement", elementType),
293 ElementFactory.classElement("BodyElement", elementType), 293 ElementFactory.classElement("BodyElement", elementType),
294 ElementFactory.classElement("ButtonElement", elementType), 294 ElementFactory.classElement("ButtonElement", elementType),
295 canvasElement, 295 canvasElement,
296 contextElement, 296 contextElement,
297 context2dElement, 297 context2dElement,
298 ElementFactory.classElement("DivElement", elementType), 298 ElementFactory.classElement("DivElement", elementType),
299 documentElement, 299 documentElement,
300 elementElement, 300 elementElement,
301 htmlDocumentElement, 301 htmlDocumentElement,
302 ElementFactory.classElement("InputElement", elementType), 302 ElementFactory.classElement("InputElement", elementType),
303 ElementFactory.classElement("SelectElement", elementType) 303 ElementFactory.classElement("SelectElement", elementType)
304 ]; 304 ];
305 htmlUnit.functions = <FunctionElement>[ 305 htmlUnit.functions = <FunctionElement>[
306 ElementFactory.functionElement3("query", elementElement, 306 ElementFactory.functionElement3("query", elementElement,
307 <ClassElement>[provider.stringType.element], ClassElement.EMPTY_LIST) 307 <ClassElement>[provider.stringType.element], ClassElement.EMPTY_LIST)
308 ]; 308 ];
309 TopLevelVariableElementImpl document = 309 TopLevelVariableElementImpl document =
310 ElementFactory.topLevelVariableElement3( 310 ElementFactory.topLevelVariableElement3(
311 "document", false, true, htmlDocumentElement.type); 311 "document", false, true, htmlDocumentElement.type);
312 htmlUnit.topLevelVariables = <TopLevelVariableElement>[document]; 312 htmlUnit.topLevelVariables = <TopLevelVariableElement>[document];
313 htmlUnit.accessors = <PropertyAccessorElement>[document.getter]; 313 htmlUnit.accessors = <PropertyAccessorElement>[document.getter];
314 LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode( 314 LibraryElementImpl htmlLibrary = new LibraryElementImpl.forNode(
315 coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"])); 315 coreContext, AstFactory.libraryIdentifier2(["dart", "dom", "html"]));
316 htmlLibrary.definingCompilationUnit = htmlUnit; 316 htmlLibrary.definingCompilationUnit = htmlUnit;
317 // 317 //
318 // dart:math 318 // dart:math
319 // 319 //
320 CompilationUnitElementImpl mathUnit = 320 CompilationUnitElementImpl mathUnit =
321 new CompilationUnitElementImpl("math.dart"); 321 new CompilationUnitElementImpl("math.dart");
322 Source mathSource = sourceFactory.forUri(_DART_MATH); 322 Source mathSource = sourceFactory.forUri(_DART_MATH);
323 coreContext.setContents(mathSource, ""); 323 coreContext.setContents(mathSource, "");
324 mathUnit.librarySource = mathUnit.source = mathSource; 324 mathUnit.librarySource = mathUnit.source = mathSource;
325 FunctionElement cosElement = ElementFactory.functionElement3( 325 FunctionElement cosElement = ElementFactory.functionElement3(
326 "cos", 326 "cos",
327 provider.doubleType.element, 327 provider.doubleType.element,
328 <ClassElement>[provider.numType.element], 328 <ClassElement>[provider.numType.element],
329 ClassElement.EMPTY_LIST); 329 ClassElement.EMPTY_LIST);
330 TopLevelVariableElement ln10Element = ElementFactory 330 TopLevelVariableElement ln10Element = ElementFactory
331 .topLevelVariableElement3("LN10", true, false, provider.doubleType); 331 .topLevelVariableElement3("LN10", true, false, provider.doubleType);
332 TypeParameterElement maxT = 332 TypeParameterElement maxT =
333 ElementFactory.typeParameterWithType('T', provider.numType); 333 ElementFactory.typeParameterWithType('T', provider.numType);
334 FunctionElementImpl maxElement = ElementFactory.functionElement3( 334 FunctionElementImpl maxElement = ElementFactory.functionElement3(
335 "max", maxT, [maxT, maxT], ClassElement.EMPTY_LIST); 335 "max", maxT, [maxT, maxT], ClassElement.EMPTY_LIST);
336 maxElement.typeParameters = [maxT]; 336 maxElement.typeParameters = [maxT];
337 maxElement.type = new FunctionTypeImpl(maxElement); 337 maxElement.type = new FunctionTypeImpl(maxElement);
338 TopLevelVariableElement piElement = ElementFactory.topLevelVariableElement3( 338 TopLevelVariableElement piElement = ElementFactory.topLevelVariableElement3(
339 "PI", true, false, provider.doubleType); 339 "PI", true, false, provider.doubleType);
340 ClassElementImpl randomElement = ElementFactory.classElement2("Random"); 340 ClassElementImpl randomElement = ElementFactory.classElement2("Random");
341 randomElement.abstract = true; 341 randomElement.abstract = true;
342 ConstructorElementImpl randomConstructor = 342 ConstructorElementImpl randomConstructor =
343 ElementFactory.constructorElement2(randomElement, null); 343 ElementFactory.constructorElement2(randomElement, null);
344 randomConstructor.factory = true; 344 randomConstructor.factory = true;
345 ParameterElementImpl seedParam = new ParameterElementImpl("seed", 0); 345 ParameterElementImpl seedParam = new ParameterElementImpl("seed", 0);
346 seedParam.parameterKind = ParameterKind.POSITIONAL; 346 seedParam.parameterKind = ParameterKind.POSITIONAL;
347 seedParam.type = provider.intType; 347 seedParam.type = provider.intType;
348 randomConstructor.parameters = <ParameterElement>[seedParam]; 348 randomConstructor.parameters = <ParameterElement>[seedParam];
349 randomElement.constructors = <ConstructorElement>[randomConstructor]; 349 randomElement.constructors = <ConstructorElement>[randomConstructor];
350 FunctionElement sinElement = ElementFactory.functionElement3( 350 FunctionElement sinElement = ElementFactory.functionElement3(
351 "sin", 351 "sin",
352 provider.doubleType.element, 352 provider.doubleType.element,
353 <ClassElement>[provider.numType.element], 353 <ClassElement>[provider.numType.element],
(...skipping 25 matching lines...) Expand all
379 // Set empty sources for the rest of the libraries. 379 // Set empty sources for the rest of the libraries.
380 // 380 //
381 Source source = sourceFactory.forUri(_DART_INTERCEPTORS); 381 Source source = sourceFactory.forUri(_DART_INTERCEPTORS);
382 coreContext.setContents(source, ""); 382 coreContext.setContents(source, "");
383 source = sourceFactory.forUri(_DART_JS_HELPER); 383 source = sourceFactory.forUri(_DART_JS_HELPER);
384 coreContext.setContents(source, ""); 384 coreContext.setContents(source, "");
385 // 385 //
386 // Record the elements. 386 // Record the elements.
387 // 387 //
388 HashMap<Source, LibraryElement> elementMap = 388 HashMap<Source, LibraryElement> elementMap =
389 new HashMap<Source, LibraryElement>(); 389 new HashMap<Source, LibraryElement>();
390 elementMap[coreSource] = coreLibrary; 390 elementMap[coreSource] = coreLibrary;
391 if (asyncSource != null) { 391 if (asyncSource != null) {
392 elementMap[asyncSource] = asyncLibrary; 392 elementMap[asyncSource] = asyncLibrary;
393 } 393 }
394 elementMap[htmlSource] = htmlLibrary; 394 elementMap[htmlSource] = htmlLibrary;
395 elementMap[mathSource] = mathLibrary; 395 elementMap[mathSource] = mathLibrary;
396 // 396 //
397 // Set the public and export namespaces. We don't use exports in the fake 397 // Set the public and export namespaces. We don't use exports in the fake
398 // core library so public and export namespaces are the same. 398 // core library so public and export namespaces are the same.
399 // 399 //
400 for (LibraryElementImpl library in elementMap.values) { 400 for (LibraryElementImpl library in elementMap.values) {
401 Namespace namespace = 401 Namespace namespace =
402 new NamespaceBuilder().createPublicNamespaceForLibrary(library); 402 new NamespaceBuilder().createPublicNamespaceForLibrary(library);
403 library.exportNamespace = namespace; 403 library.exportNamespace = namespace;
404 library.publicNamespace = namespace; 404 library.publicNamespace = namespace;
405 } 405 }
406 context.recordLibraryElements(elementMap); 406 context.recordLibraryElements(elementMap);
407 // Create the synthetic element for `loadLibrary`. 407 // Create the synthetic element for `loadLibrary`.
408 for (LibraryElementImpl library in elementMap.values) { 408 for (LibraryElementImpl library in elementMap.values) {
409 library.createLoadLibraryFunction(context.typeProvider); 409 library.createLoadLibraryFunction(context.typeProvider);
410 } 410 }
411 return context; 411 return context;
412 } 412 }
413 } 413 }
414 414
415 /** 415 /**
416 * An analysis context that has a fake SDK that is much smaller and faster for 416 * An analysis context that has a fake SDK that is much smaller and faster for
417 * testing purposes. 417 * testing purposes.
418 */ 418 */
419 class AnalysisContextForTests extends AnalysisContextImpl { 419 class AnalysisContextForTests extends AnalysisContextImpl {
420 @override 420 @override
421 void set analysisOptions(AnalysisOptions options) { 421 void set analysisOptions(AnalysisOptions options) {
422 AnalysisOptions currentOptions = analysisOptions; 422 AnalysisOptions currentOptions = analysisOptions;
423 bool needsRecompute = currentOptions.analyzeFunctionBodiesPredicate != 423 bool needsRecompute = currentOptions.analyzeFunctionBodiesPredicate !=
424 options.analyzeFunctionBodiesPredicate || 424 options.analyzeFunctionBodiesPredicate ||
425 currentOptions.generateImplicitErrors != 425 currentOptions.generateImplicitErrors !=
426 options.generateImplicitErrors || 426 options.generateImplicitErrors ||
427 currentOptions.generateSdkErrors != options.generateSdkErrors || 427 currentOptions.generateSdkErrors != options.generateSdkErrors ||
428 currentOptions.dart2jsHint != options.dart2jsHint || 428 currentOptions.dart2jsHint != options.dart2jsHint ||
429 (currentOptions.hint && !options.hint) || 429 (currentOptions.hint && !options.hint) ||
430 currentOptions.preserveComments != options.preserveComments || 430 currentOptions.preserveComments != options.preserveComments ||
431 currentOptions.enableStrictCallChecks != options.enableStrictCallChecks; 431 currentOptions.enableStrictCallChecks != options.enableStrictCallChecks;
432 if (needsRecompute) { 432 if (needsRecompute) {
433 fail( 433 fail(
434 "Cannot set options that cause the sources to be reanalyzed in a test context"); 434 "Cannot set options that cause the sources to be reanalyzed in a test context");
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 510 }
511 } 511 }
512 } 512 }
513 513
514 class TestPackageUriResolver extends UriResolver { 514 class TestPackageUriResolver extends UriResolver {
515 Map<Uri, Source> sourceMap = new HashMap<Uri, Source>(); 515 Map<Uri, Source> sourceMap = new HashMap<Uri, Source>();
516 516
517 TestPackageUriResolver(Map<String, String> map) { 517 TestPackageUriResolver(Map<String, String> map) {
518 map.forEach((String uri, String contents) { 518 map.forEach((String uri, String contents) {
519 sourceMap[Uri.parse(uri)] = 519 sourceMap[Uri.parse(uri)] =
520 new StringSource(contents, '/test_pkg_source.dart'); 520 new StringSource(contents, '/test_pkg_source.dart');
521 }); 521 });
522 } 522 }
523 523
524 @override 524 @override
525 Source resolveAbsolute(Uri uri, [Uri actualUri]) => sourceMap[uri]; 525 Source resolveAbsolute(Uri uri, [Uri actualUri]) => sourceMap[uri];
526 526
527 @override 527 @override
528 Uri restoreAbsolute(Source source) => throw new UnimplementedError(); 528 Uri restoreAbsolute(Source source) => throw new UnimplementedError();
529 } 529 }
530 530
(...skipping 22 matching lines...) Expand all
553 553
554 void _addLibrary(LibraryMap map, String uri, bool isInternal, String path) { 554 void _addLibrary(LibraryMap map, String uri, bool isInternal, String path) {
555 SdkLibraryImpl library = new SdkLibraryImpl(uri); 555 SdkLibraryImpl library = new SdkLibraryImpl(uri);
556 if (isInternal) { 556 if (isInternal) {
557 library.category = "Internal"; 557 library.category = "Internal";
558 } 558 }
559 library.path = path; 559 library.path = path;
560 map.setLibrary(uri, library); 560 map.setLibrary(uri, library);
561 } 561 }
562 } 562 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/cancelable_future_test.dart ('k') | pkg/analyzer/test/generated/element_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698