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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2725973004: Correctly recover from incorrect imports, etc. (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 fasta.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; 7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind;
8 8
9 import '../parser/parser.dart' show FormalParameterType, optional; 9 import '../parser/parser.dart' show FormalParameterType, optional;
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 push(popList(count) ?? NullValue.Combinators); 114 push(popList(count) ?? NullValue.Combinators);
115 } 115 }
116 116
117 @override 117 @override
118 void endExport(Token exportKeyword, Token semicolon) { 118 void endExport(Token exportKeyword, Token semicolon) {
119 debugEvent("Export"); 119 debugEvent("Export");
120 List<Combinator> combinators = pop(); 120 List<Combinator> combinators = pop();
121 Unhandled conditionalUris = pop(); 121 Unhandled conditionalUris = pop();
122 String uri = pop(); 122 String uri = pop();
123 List<MetadataBuilder> metadata = pop(); 123 List<MetadataBuilder> metadata = pop();
124 library.addExport( 124 if (uri != null) {
125 metadata, uri, conditionalUris, combinators, exportKeyword.charOffset); 125 library.addExport(metadata, uri, conditionalUris, combinators,
126 exportKeyword.charOffset);
127 }
126 checkEmpty(exportKeyword.charOffset); 128 checkEmpty(exportKeyword.charOffset);
127 } 129 }
128 130
129 @override 131 @override
130 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, 132 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword,
131 Token semicolon) { 133 Token semicolon) {
132 debugEvent("endImport"); 134 debugEvent("endImport");
133 List<Combinator> combinators = pop(); 135 List<Combinator> combinators = pop();
134 String prefix = popIfNotNull(asKeyword); 136 String prefix = popIfNotNull(asKeyword);
135 Unhandled conditionalUris = pop(); 137 Unhandled conditionalUris = pop();
136 String uri = pop(); 138 String uri = pop();
137 List<MetadataBuilder> metadata = pop(); 139 List<MetadataBuilder> metadata = pop();
138 library.addImport( 140 if (uri != null) {
139 metadata, 141 library.addImport(
140 uri, 142 metadata,
141 conditionalUris, 143 uri,
142 prefix, 144 conditionalUris,
143 combinators, 145 prefix,
144 deferredKeyword != null, 146 combinators,
145 importKeyword.charOffset, 147 deferredKeyword != null,
146 asKeyword?.next?.charOffset ?? -1); 148 importKeyword.charOffset,
149 asKeyword?.next?.charOffset ?? -1);
150 }
147 checkEmpty(importKeyword.charOffset); 151 checkEmpty(importKeyword.charOffset);
148 } 152 }
149 153
150 @override 154 @override
155 void handleRecoverExpression(Token token) {
156 debugEvent("RecoverExpression");
157 push(NullValue.Expression);
158 }
159
160 @override
151 void endPart(Token partKeyword, Token semicolon) { 161 void endPart(Token partKeyword, Token semicolon) {
152 debugEvent("Part"); 162 debugEvent("Part");
153 String uri = pop(); 163 String uri = pop();
154 List<MetadataBuilder> metadata = pop(); 164 List<MetadataBuilder> metadata = pop();
155 library.addPart(metadata, uri); 165 if (uri != null) {
166 library.addPart(metadata, uri);
167 }
156 checkEmpty(partKeyword.charOffset); 168 checkEmpty(partKeyword.charOffset);
157 } 169 }
158 170
159 @override 171 @override
160 void handleOperatorName(Token operatorKeyword, Token token) { 172 void handleOperatorName(Token operatorKeyword, Token token) {
161 debugEvent("OperatorName"); 173 debugEvent("OperatorName");
162 push(operatorFromString(token.stringValue)); 174 push(operatorFromString(token.stringValue));
163 } 175 }
164 176
165 @override 177 @override
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 Link<Token> handleMemberName(Link<Token> identifiers) { 637 Link<Token> handleMemberName(Link<Token> identifiers) {
626 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 638 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
627 return removeNativeClause(identifiers); 639 return removeNativeClause(identifiers);
628 } 640 }
629 641
630 @override 642 @override
631 void debugEvent(String name) { 643 void debugEvent(String name) {
632 // printEvent(name); 644 // printEvent(name);
633 } 645 }
634 } 646 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/parser.dart ('k') | pkg/front_end/lib/src/fasta/source/stack_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698