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

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

Issue 2736373004: Gracefully degrade summarization when an annotation is not a valid const expression (issue 28992) (Closed)
Patch Set: Created 3 years, 9 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 serialization.summarize_ast; 5 library serialization.summarize_ast;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/type.dart' show DartType; 10 import 'package:analyzer/dart/element/type.dart' show DartType;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 NodeList<Annotation> annotations) { 407 NodeList<Annotation> annotations) {
408 if (annotations == null || annotations.isEmpty) { 408 if (annotations == null || annotations.isEmpty) {
409 return const <UnlinkedExprBuilder>[]; 409 return const <UnlinkedExprBuilder>[];
410 } 410 }
411 return annotations.map((Annotation a) { 411 return annotations.map((Annotation a) {
412 // Closures can't appear inside annotations, so we don't need a 412 // Closures can't appear inside annotations, so we don't need a
413 // localClosureIndexMap. 413 // localClosureIndexMap.
414 Map<int, int> localClosureIndexMap = null; 414 Map<int, int> localClosureIndexMap = null;
415 _ConstExprSerializer serializer = 415 _ConstExprSerializer serializer =
416 new _ConstExprSerializer(this, localClosureIndexMap, null); 416 new _ConstExprSerializer(this, localClosureIndexMap, null);
417 serializer.serializeAnnotation(a); 417 try {
418 serializer.serializeAnnotation(a);
419 } on StateError {
420 return new UnlinkedExprBuilder()..isValidConst = false;
421 }
418 return serializer.toBuilder(); 422 return serializer.toBuilder();
419 }).toList(); 423 }).toList();
420 } 424 }
421 425
422 /** 426 /**
423 * Serialize a [ClassDeclaration] or [ClassTypeAlias] into an [UnlinkedClass] 427 * Serialize a [ClassDeclaration] or [ClassTypeAlias] into an [UnlinkedClass]
424 * and store the result in [classes]. 428 * and store the result in [classes].
425 */ 429 */
426 void serializeClass( 430 void serializeClass(
427 AstNode node, 431 AstNode node,
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 /** 1421 /**
1418 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1422 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1419 */ 1423 */
1420 class _TypeParameterScope extends _Scope { 1424 class _TypeParameterScope extends _Scope {
1421 /** 1425 /**
1422 * Get the number of [_ScopedTypeParameter]s defined in this 1426 * Get the number of [_ScopedTypeParameter]s defined in this
1423 * [_TypeParameterScope]. 1427 * [_TypeParameterScope].
1424 */ 1428 */
1425 int get length => _definedNames.length; 1429 int get length => _definedNames.length;
1426 } 1430 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | pkg/analyzer/test/src/summary/summary_common.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698