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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2524903002: Rename AstFactory -> AstTestFactory. (Closed)
Patch Set: Created 4 years 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 | « no previous file | pkg/analyzer/lib/src/generated/testing/ast_factory.dart » ('j') | 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 library analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
11 import 'package:analyzer/dart/ast/token.dart'; 11 import 'package:analyzer/dart/ast/token.dart';
12 import 'package:analyzer/dart/constant/value.dart'; 12 import 'package:analyzer/dart/constant/value.dart';
13 import 'package:analyzer/dart/element/element.dart'; 13 import 'package:analyzer/dart/element/element.dart';
14 import 'package:analyzer/dart/element/type.dart'; 14 import 'package:analyzer/dart/element/type.dart';
15 import 'package:analyzer/dart/element/visitor.dart'; 15 import 'package:analyzer/dart/element/visitor.dart';
16 import 'package:analyzer/src/dart/ast/utilities.dart'; 16 import 'package:analyzer/src/dart/ast/utilities.dart';
17 import 'package:analyzer/src/dart/constant/value.dart'; 17 import 'package:analyzer/src/dart/constant/value.dart';
18 import 'package:analyzer/src/dart/element/handle.dart'; 18 import 'package:analyzer/src/dart/element/handle.dart';
19 import 'package:analyzer/src/dart/element/type.dart'; 19 import 'package:analyzer/src/dart/element/type.dart';
20 import 'package:analyzer/src/error/codes.dart' show CompileTimeErrorCode; 20 import 'package:analyzer/src/error/codes.dart' show CompileTimeErrorCode;
21 import 'package:analyzer/src/generated/constant.dart' show EvaluationResultImpl; 21 import 'package:analyzer/src/generated/constant.dart' show EvaluationResultImpl;
22 import 'package:analyzer/src/generated/engine.dart' 22 import 'package:analyzer/src/generated/engine.dart'
23 show AnalysisContext, AnalysisEngine; 23 show AnalysisContext, AnalysisEngine;
24 import 'package:analyzer/src/generated/java_engine.dart'; 24 import 'package:analyzer/src/generated/java_engine.dart';
25 import 'package:analyzer/src/generated/resolver.dart'; 25 import 'package:analyzer/src/generated/resolver.dart';
26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
27 import 'package:analyzer/src/generated/source.dart'; 27 import 'package:analyzer/src/generated/source.dart';
28 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 28 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
29 import 'package:analyzer/src/generated/utilities_collection.dart'; 29 import 'package:analyzer/src/generated/utilities_collection.dart';
30 import 'package:analyzer/src/generated/utilities_dart.dart'; 30 import 'package:analyzer/src/generated/utilities_dart.dart';
31 import 'package:analyzer/src/generated/utilities_general.dart'; 31 import 'package:analyzer/src/generated/utilities_general.dart';
32 import 'package:analyzer/src/summary/idl.dart'; 32 import 'package:analyzer/src/summary/idl.dart';
33 import 'package:analyzer/src/task/dart.dart'; 33 import 'package:analyzer/src/task/dart.dart';
34 34
35 /** 35 /**
36 * Assert that the given [object] is null, which in the places where this 36 * Assert that the given [object] is null, which in the places where this
37 * function is called means that the element is not resynthesized. 37 * function is called means that the element is not resynthesized.
38 */ 38 */
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 String name = serialized.name; 2210 String name = serialized.name;
2211 List<Expression> arguments = <Expression>[]; 2211 List<Expression> arguments = <Expression>[];
2212 { 2212 {
2213 int numArguments = serialized.arguments.length; 2213 int numArguments = serialized.arguments.length;
2214 int numNames = serialized.argumentNames.length; 2214 int numNames = serialized.argumentNames.length;
2215 for (int i = 0; i < numArguments; i++) { 2215 for (int i = 0; i < numArguments; i++) {
2216 Expression expression = enclosingUnit.resynthesizerContext 2216 Expression expression = enclosingUnit.resynthesizerContext
2217 .buildExpression(this, serialized.arguments[i]); 2217 .buildExpression(this, serialized.arguments[i]);
2218 int nameIndex = numNames + i - numArguments; 2218 int nameIndex = numNames + i - numArguments;
2219 if (nameIndex >= 0) { 2219 if (nameIndex >= 0) {
2220 expression = AstFactory.namedExpression2( 2220 expression = AstTestFactory.namedExpression2(
2221 serialized.argumentNames[nameIndex], expression); 2221 serialized.argumentNames[nameIndex], expression);
2222 } 2222 }
2223 arguments.add(expression); 2223 arguments.add(expression);
2224 } 2224 }
2225 } 2225 }
2226 switch (kind) { 2226 switch (kind) {
2227 case UnlinkedConstructorInitializerKind.field: 2227 case UnlinkedConstructorInitializerKind.field:
2228 ConstructorFieldInitializer initializer = 2228 ConstructorFieldInitializer initializer =
2229 AstFactory.constructorFieldInitializer( 2229 AstTestFactory.constructorFieldInitializer(
2230 false, 2230 false,
2231 name, 2231 name,
2232 enclosingUnit.resynthesizerContext 2232 enclosingUnit.resynthesizerContext
2233 .buildExpression(this, serialized.expression)); 2233 .buildExpression(this, serialized.expression));
2234 initializer.fieldName.staticElement = enclosingElement.getField(name); 2234 initializer.fieldName.staticElement = enclosingElement.getField(name);
2235 return initializer; 2235 return initializer;
2236 case UnlinkedConstructorInitializerKind.superInvocation: 2236 case UnlinkedConstructorInitializerKind.superInvocation:
2237 SuperConstructorInvocation initializer = 2237 SuperConstructorInvocation initializer =
2238 AstFactory.superConstructorInvocation2( 2238 AstTestFactory.superConstructorInvocation2(
2239 name.isNotEmpty ? name : null, arguments); 2239 name.isNotEmpty ? name : null, arguments);
2240 ClassElement superElement = enclosingElement.supertype.element; 2240 ClassElement superElement = enclosingElement.supertype.element;
2241 ConstructorElement element = name.isEmpty 2241 ConstructorElement element = name.isEmpty
2242 ? superElement.unnamedConstructor 2242 ? superElement.unnamedConstructor
2243 : superElement.getNamedConstructor(name); 2243 : superElement.getNamedConstructor(name);
2244 initializer.staticElement = element; 2244 initializer.staticElement = element;
2245 initializer.constructorName?.staticElement = element; 2245 initializer.constructorName?.staticElement = element;
2246 return initializer; 2246 return initializer;
2247 case UnlinkedConstructorInitializerKind.thisInvocation: 2247 case UnlinkedConstructorInitializerKind.thisInvocation:
2248 RedirectingConstructorInvocation initializer = 2248 RedirectingConstructorInvocation initializer =
2249 AstFactory.redirectingConstructorInvocation2( 2249 AstTestFactory.redirectingConstructorInvocation2(
2250 name.isNotEmpty ? name : null, arguments); 2250 name.isNotEmpty ? name : null, arguments);
2251 ConstructorElement element = name.isEmpty 2251 ConstructorElement element = name.isEmpty
2252 ? enclosingElement.unnamedConstructor 2252 ? enclosingElement.unnamedConstructor
2253 : enclosingElement.getNamedConstructor(name); 2253 : enclosingElement.getNamedConstructor(name);
2254 initializer.staticElement = element; 2254 initializer.staticElement = element;
2255 initializer.constructorName?.staticElement = element; 2255 initializer.constructorName?.staticElement = element;
2256 return initializer; 2256 return initializer;
2257 } 2257 }
2258 return null; 2258 return null;
2259 } 2259 }
(...skipping 6227 matching lines...) Expand 10 before | Expand all | Expand 10 after
8487 8487
8488 @override 8488 @override
8489 void visitElement(Element element) { 8489 void visitElement(Element element) {
8490 int offset = element.nameOffset; 8490 int offset = element.nameOffset;
8491 if (offset != -1) { 8491 if (offset != -1) {
8492 map[offset] = element; 8492 map[offset] = element;
8493 } 8493 }
8494 super.visitElement(element); 8494 super.visitElement(element);
8495 } 8495 }
8496 } 8496 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/testing/ast_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698