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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart

Issue 2731553004: [Fasta] Offset and end offset on procedures (Closed)
Patch Set: Addressed comments 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.kernel_library_builder; 5 library fasta.kernel_library_builder;
6 6
7 import 'package:kernel/ast.dart'; 7 import 'package:kernel/ast.dart';
8 8
9 import 'package:kernel/clone.dart' show CloneVisitor; 9 import 'package:kernel/clone.dart' show CloneVisitor;
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void addProcedure( 153 void addProcedure(
154 List<MetadataBuilder> metadata, 154 List<MetadataBuilder> metadata,
155 int modifiers, 155 int modifiers,
156 KernelTypeBuilder returnType, 156 KernelTypeBuilder returnType,
157 String name, 157 String name,
158 List<TypeVariableBuilder> typeVariables, 158 List<TypeVariableBuilder> typeVariables,
159 List<FormalParameterBuilder> formals, 159 List<FormalParameterBuilder> formals,
160 AsyncMarker asyncModifier, 160 AsyncMarker asyncModifier,
161 ProcedureKind kind, 161 ProcedureKind kind,
162 int charOffset, 162 int charOffset,
163 int charEndOffset,
163 String nativeMethodName, 164 String nativeMethodName,
164 {bool isTopLevel}) { 165 {bool isTopLevel}) {
165 // Nested declaration began in `OutlineBuilder.beginMethod` or 166 // Nested declaration began in `OutlineBuilder.beginMethod` or
166 // `OutlineBuilder.beginTopLevelMethod`. 167 // `OutlineBuilder.beginTopLevelMethod`.
167 endNestedDeclaration().resolveTypes(typeVariables, this); 168 endNestedDeclaration().resolveTypes(typeVariables, this);
168 ProcedureBuilder procedure; 169 ProcedureBuilder procedure;
169 if (!isTopLevel && isConstructorName(name, currentDeclaration.name)) { 170 if (!isTopLevel && isConstructorName(name, currentDeclaration.name)) {
170 int index = name.indexOf("."); 171 int index = name.indexOf(".");
171 name = index == -1 ? "" : name.substring(index + 1); 172 name = index == -1 ? "" : name.substring(index + 1);
172 procedure = new KernelConstructorBuilder( 173 procedure = new KernelConstructorBuilder(
173 metadata, 174 metadata,
174 modifiers & ~abstractMask, 175 modifiers & ~abstractMask,
175 returnType, 176 returnType,
176 name, 177 name,
177 typeVariables, 178 typeVariables,
178 formals, 179 formals,
179 this, 180 this,
180 charOffset, 181 charOffset,
182 charEndOffset,
181 nativeMethodName); 183 nativeMethodName);
182 } else { 184 } else {
183 procedure = new KernelProcedureBuilder( 185 procedure = new KernelProcedureBuilder(
184 metadata, 186 metadata,
185 modifiers, 187 modifiers,
186 returnType, 188 returnType,
187 name, 189 name,
188 typeVariables, 190 typeVariables,
189 formals, 191 formals,
190 asyncModifier, 192 asyncModifier,
191 kind, 193 kind,
192 this, 194 this,
193 charOffset, 195 charOffset,
196 charEndOffset,
194 nativeMethodName); 197 nativeMethodName);
195 } 198 }
196 addBuilder(name, procedure, charOffset); 199 addBuilder(name, procedure, charOffset);
197 if (nativeMethodName != null) { 200 if (nativeMethodName != null) {
198 addNativeMethod(procedure); 201 addNativeMethod(procedure);
199 } 202 }
200 } 203 }
201 204
202 void addFactoryMethod( 205 void addFactoryMethod(
203 List<MetadataBuilder> metadata, 206 List<MetadataBuilder> metadata,
204 int modifiers, 207 int modifiers,
205 ConstructorReferenceBuilder constructorName, 208 ConstructorReferenceBuilder constructorName,
206 List<FormalParameterBuilder> formals, 209 List<FormalParameterBuilder> formals,
207 AsyncMarker asyncModifier, 210 AsyncMarker asyncModifier,
208 ConstructorReferenceBuilder redirectionTarget, 211 ConstructorReferenceBuilder redirectionTarget,
209 int charOffset, 212 int charOffset,
213 int charEndOffset,
210 String nativeMethodName) { 214 String nativeMethodName) {
211 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. 215 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`.
212 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = 216 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration =
213 endNestedDeclaration(); 217 endNestedDeclaration();
214 String name = constructorName.name; 218 String name = constructorName.name;
215 int index = name.indexOf("."); 219 int index = name.indexOf(".");
216 name = index == -1 ? "" : name.substring(index + 1); 220 name = index == -1 ? "" : name.substring(index + 1);
217 assert(constructorName.suffix == null); 221 assert(constructorName.suffix == null);
218 KernelProcedureBuilder procedure = new KernelProcedureBuilder( 222 KernelProcedureBuilder procedure = new KernelProcedureBuilder(
219 metadata, 223 metadata,
220 staticMask | modifiers, 224 staticMask | modifiers,
221 null, 225 null,
222 name, 226 name,
223 <TypeVariableBuilder>[], 227 <TypeVariableBuilder>[],
224 formals, 228 formals,
225 asyncModifier, 229 asyncModifier,
226 ProcedureKind.Factory, 230 ProcedureKind.Factory,
227 this, 231 this,
228 charOffset, 232 charOffset,
233 charEndOffset,
229 nativeMethodName, 234 nativeMethodName,
230 redirectionTarget); 235 redirectionTarget);
231 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration); 236 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration);
232 addBuilder(name, procedure, charOffset); 237 addBuilder(name, procedure, charOffset);
233 if (nativeMethodName != null) { 238 if (nativeMethodName != null) {
234 addNativeMethod(procedure); 239 addNativeMethod(procedure);
235 } 240 }
236 } 241 }
237 242
238 void addEnum(List<MetadataBuilder> metadata, String name, 243 void addEnum(List<MetadataBuilder> metadata, String name,
239 List<String> constants, int charOffset) { 244 List<String> constants, int charOffset, int charEndOffset) {
240 addBuilder( 245 addBuilder(
241 name, 246 name,
242 new KernelEnumBuilder(metadata, name, constants, this, charOffset), 247 new KernelEnumBuilder(
248 metadata, name, constants, this, charOffset, charEndOffset),
243 charOffset); 249 charOffset);
244 } 250 }
245 251
246 void addFunctionTypeAlias( 252 void addFunctionTypeAlias(
247 List<MetadataBuilder> metadata, 253 List<MetadataBuilder> metadata,
248 KernelTypeBuilder returnType, 254 KernelTypeBuilder returnType,
249 String name, 255 String name,
250 List<TypeVariableBuilder> typeVariables, 256 List<TypeVariableBuilder> typeVariables,
251 List<FormalParameterBuilder> formals, 257 List<FormalParameterBuilder> formals,
252 int charOffset) { 258 int charOffset) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 415 }
410 } 416 }
411 417
412 bool isConstructorName(String name, String className) { 418 bool isConstructorName(String name, String className) {
413 if (name.startsWith(className)) { 419 if (name.startsWith(className)) {
414 if (name.length == className.length) return true; 420 if (name.length == className.length) return true;
415 if (name.startsWith(".", className.length)) return true; 421 if (name.startsWith(".", className.length)) return true;
416 } 422 }
417 return false; 423 return false;
418 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698