From 396d7862b4e3c4bf5dfa87927301d884503b0557 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 21 Oct 2016 11:13:55 -0700 Subject: [PATCH] More improvements to DeclarationResolver. This CL makes the following improvements: - When visiting an executable element, local variables and labels are rebuilt rather than matching them up to the old element model. This ensures that if the element model was resynthesized from an API summary (which doesn't contain local variables or labels), these elements are not lost. - When matching up existing elements, if the elements did not previously contain offsets, offsets are recorded. If they did previously contain offsets, the offsets are compared to verify that they match. This ensures that if the element model was resynthesized from an API summary (which doesn't contain offsets), the offsets will be correct. R=brianwilkerson@google.com, scheglov@google.com Review URL: https://codereview.chromium.org/2435313002 . --- .../lib/src/dart/element/builder.dart | 51 ++++---- .../lib/src/dart/element/element.dart | 62 +++++---- .../src/generated/declaration_resolver.dart | 121 +++++++++++------- .../generated/declaration_resolver_test.dart | 77 ++++++++++- .../test/src/context/context_test.dart | 6 +- 5 files changed, 215 insertions(+), 102 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart index b45f44e9742..b421e75f13d 100644 --- a/pkg/analyzer/lib/src/dart/element/builder.dart +++ b/pkg/analyzer/lib/src/dart/element/builder.dart @@ -1078,8 +1078,11 @@ class LocalElementBuilder extends _BaseElementBuilder { CompilationUnitElementImpl compilationUnitElement) : super(initialHolder, compilationUnitElement); - @override - Object visitCatchClause(CatchClause node) { + /** + * Builds the variable elements associated with [node] and stores them in + * the element holder. + */ + void buildCatchVariableElements(CatchClause node) { SimpleIdentifier exceptionParameter = node.exceptionParameter; if (exceptionParameter != null) { // exception @@ -1102,6 +1105,26 @@ class LocalElementBuilder extends _BaseElementBuilder { stackTraceParameter.staticElement = stackTrace; } } + } + + /** + * Builds the label elements associated with [labels] and stores them in the + * element holder. + */ + void buildLabelElements( + NodeList