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

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1837063002: Resynthesize any type reference in constant expressions. (Closed) Base URL: git@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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 summary_resynthesizer; 5 library summary_resynthesizer;
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 orElse: () => throw new StateError( 473 orElse: () => throw new StateError(
474 'Unable to resolve constructor parameter: $name')); 474 'Unable to resolve constructor parameter: $name'));
475 _push(identifier); 475 _push(identifier);
476 break; 476 break;
477 } 477 }
478 } 478 }
479 return stack.single; 479 return stack.single;
480 } 480 }
481 481
482 TypeName _buildTypeAst(DartType type) { 482 TypeName _buildTypeAst(DartType type) {
483 if (type is DynamicTypeImpl) { 483 List<TypeName> argumentNodes;
484 TypeName node = AstFactory.typeName4('dynamic'); 484 if (type is ParameterizedType) {
485 node.type = type;
486 (node.name as SimpleIdentifier).staticElement = type.element;
487 return node;
488 } else if (type is InterfaceType) {
489 List<DartType> typeArguments = type.typeArguments; 485 List<DartType> typeArguments = type.typeArguments;
490 List<TypeName> argumentNodes = typeArguments.every((a) => a.isDynamic) 486 argumentNodes = typeArguments.every((a) => a.isDynamic)
491 ? null 487 ? null
492 : typeArguments.map(_buildTypeAst).toList(); 488 : typeArguments.map(_buildTypeAst).toList();
493 TypeName node = AstFactory.typeName4(type.name, argumentNodes);
494 node.type = type;
495 (node.name as SimpleIdentifier).staticElement = type.element;
496 return node;
497 } 489 }
498 throw new StateError('Unsupported type $type'); 490 TypeName node = AstFactory.typeName4(type.name, argumentNodes);
491 node.type = type;
492 (node.name as SimpleIdentifier).staticElement = type.element;
493 return node;
499 } 494 }
500 495
501 InterpolationElement _newInterpolationElement(Expression expr) { 496 InterpolationElement _newInterpolationElement(Expression expr) {
502 if (expr is SimpleStringLiteral) { 497 if (expr is SimpleStringLiteral) {
503 return new InterpolationString(expr.literal, expr.value); 498 return new InterpolationString(expr.literal, expr.value);
504 } else { 499 } else {
505 return new InterpolationExpression( 500 return new InterpolationExpression(
506 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION), 501 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION),
507 expr, 502 expr,
508 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); 503 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET));
(...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 static String _getElementIdentifier(String name, ReferenceKind kind) { 2591 static String _getElementIdentifier(String name, ReferenceKind kind) {
2597 if (kind == ReferenceKind.topLevelPropertyAccessor || 2592 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2598 kind == ReferenceKind.propertyAccessor) { 2593 kind == ReferenceKind.propertyAccessor) {
2599 if (!name.endsWith('=')) { 2594 if (!name.endsWith('=')) {
2600 return name + '?'; 2595 return name + '?';
2601 } 2596 }
2602 } 2597 }
2603 return name; 2598 return name;
2604 } 2599 }
2605 } 2600 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698