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/source/source_library_builder.dart

Issue 2977713002: Remove deprecated api from LibraryBuilder. (Closed)
Patch Set: Created 3 years, 5 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.source_library_builder; 5 library fasta.source_library_builder;
6 6
7 import 'package:kernel/ast.dart' show ProcedureKind; 7 import 'package:kernel/ast.dart' show ProcedureKind;
8 8
9 import '../../base/resolve_relative_uri.dart' show resolveRelativeUri; 9 import '../../base/resolve_relative_uri.dart' show resolveRelativeUri;
10 10
(...skipping 17 matching lines...) Expand all
28 TypeDeclarationBuilder, 28 TypeDeclarationBuilder,
29 TypeVariableBuilder, 29 TypeVariableBuilder,
30 Unhandled; 30 Unhandled;
31 31
32 import '../combinator.dart' show Combinator; 32 import '../combinator.dart' show Combinator;
33 33
34 import '../deprecated_problems.dart' show deprecated_inputError; 34 import '../deprecated_problems.dart' show deprecated_inputError;
35 35
36 import '../export.dart' show Export; 36 import '../export.dart' show Export;
37 37
38 import '../fasta_codes.dart'
39 show
40 messagePartOfSelf,
41 templateConflictsWithMember,
42 templateConflictsWithSetter,
43 templateDeferredPrefixDuplicated,
44 templateDeferredPrefixDuplicatedCause,
45 templateDuplicatedDefinition,
46 templateMissingPartOf,
47 templatePartOfLibraryNameMismatch,
48 templatePartOfUriMismatch,
49 templatePartOfUseUri,
50 templatePartTwice;
51
38 import '../import.dart' show Import; 52 import '../import.dart' show Import;
39 53
40 import '../problems.dart' show unhandled; 54 import '../problems.dart' show unhandled;
41 55
42 import 'source_loader.dart' show SourceLoader; 56 import 'source_loader.dart' show SourceLoader;
43 57
44 abstract class SourceLibraryBuilder<T extends TypeBuilder, R> 58 abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
45 extends LibraryBuilder<T, R> { 59 extends LibraryBuilder<T, R> {
46 final SourceLoader loader; 60 final SourceLoader loader;
47 61
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 Builder deferred; 318 Builder deferred;
305 Builder other; 319 Builder other;
306 if (builder.deferred) { 320 if (builder.deferred) {
307 deferred = builder; 321 deferred = builder;
308 other = existing; 322 other = existing;
309 } else if (existing.deferred) { 323 } else if (existing.deferred) {
310 deferred = existing; 324 deferred = existing;
311 other = builder; 325 other = builder;
312 } 326 }
313 if (deferred != null) { 327 if (deferred != null) {
314 deprecated_addCompileTimeError( 328 addCompileTimeError(
329 templateDeferredPrefixDuplicated.withArguments(name),
315 deferred.charOffset, 330 deferred.charOffset,
316 "Can't use the name '$name' for a deferred library, " 331 fileUri);
317 "as the name is used elsewhere."); 332 addCompileTimeError(
318 deprecated_addCompileTimeError( 333 templateDeferredPrefixDuplicatedCause.withArguments(name),
319 other.charOffset, "'$name' is used here."); 334 other.charOffset,
335 fileUri);
320 } 336 }
321 return existing 337 return existing
322 ..exports.merge(builder.exports, 338 ..exports.merge(builder.exports,
323 (String name, Builder existing, Builder member) { 339 (String name, Builder existing, Builder member) {
324 return buildAmbiguousBuilder(name, existing, member, charOffset); 340 return buildAmbiguousBuilder(name, existing, member, charOffset);
325 }); 341 });
326 } else if (isDuplicatedDefinition(existing, builder)) { 342 } else if (isDuplicatedDefinition(existing, builder)) {
327 deprecated_addCompileTimeError( 343 addCompileTimeError(templateDuplicatedDefinition.withArguments(name),
328 charOffset, "Duplicated definition of '$name'."); 344 charOffset, fileUri);
329 } 345 }
330 return members[name] = builder; 346 return members[name] = builder;
331 } 347 }
332 348
333 bool isDuplicatedDefinition(Builder existing, Builder other) { 349 bool isDuplicatedDefinition(Builder existing, Builder other) {
334 if (existing == null) return false; 350 if (existing == null) return false;
335 Builder next = existing.next; 351 Builder next = existing.next;
336 if (next == null) { 352 if (next == null) {
337 if (existing.isGetter && other.isSetter) return false; 353 if (existing.isGetter && other.isSetter) return false;
338 if (existing.isSetter && other.isGetter) return false; 354 if (existing.isSetter && other.isGetter) return false;
(...skipping 27 matching lines...) Expand all
366 int charOffset = list[2]; 382 int charOffset = list[2];
367 addBuilder(name, builder, charOffset); 383 addBuilder(name, builder, charOffset);
368 buildBuilder(builder, coreLibrary); 384 buildBuilder(builder, coreLibrary);
369 } 385 }
370 canAddImplementationBuilders = false; 386 canAddImplementationBuilders = false;
371 387
372 scope.setters.forEach((String name, Builder setter) { 388 scope.setters.forEach((String name, Builder setter) {
373 Builder member = scopeBuilder[name]; 389 Builder member = scopeBuilder[name];
374 if (member == null || !member.isField || member.isFinal) return; 390 if (member == null || !member.isField || member.isFinal) return;
375 // TODO(ahe): charOffset is missing. 391 // TODO(ahe): charOffset is missing.
376 deprecated_addCompileTimeError( 392 addCompileTimeError(templateConflictsWithMember.withArguments(name),
377 setter.charOffset, "Conflicts with member '${name}'."); 393 setter.charOffset, fileUri);
378 deprecated_addCompileTimeError( 394 addCompileTimeError(templateConflictsWithSetter.withArguments(name),
379 member.charOffset, "Conflicts with setter '${name}'."); 395 member.charOffset, fileUri);
380 }); 396 });
381 397
382 return null; 398 return null;
383 } 399 }
384 400
385 /// Used to add implementation builder during the call to [build] above. 401 /// Used to add implementation builder during the call to [build] above.
386 /// Currently, only anonymous mixins are using implementation builders (see 402 /// Currently, only anonymous mixins are using implementation builders (see
387 /// [KernelMixinApplicationBuilder] 403 /// [KernelMixinApplicationBuilder]
388 /// (../kernel/kernel_mixin_application_builder.dart)). 404 /// (../kernel/kernel_mixin_application_builder.dart)).
389 void addImplementationBuilder(String name, Builder builder, int charOffset) { 405 void addImplementationBuilder(String name, Builder builder, int charOffset) {
(...skipping 10 matching lines...) Expand all
400 Export export = exporters.first; 416 Export export = exporters.first;
401 deprecated_inputError( 417 deprecated_inputError(
402 export.fileUri, export.charOffset, "A part can't be exported."); 418 export.fileUri, export.charOffset, "A part can't be exported.");
403 } 419 }
404 } 420 }
405 421
406 void includeParts() { 422 void includeParts() {
407 Set<Uri> seenParts = new Set<Uri>(); 423 Set<Uri> seenParts = new Set<Uri>();
408 for (SourceLibraryBuilder<T, R> part in parts.toList()) { 424 for (SourceLibraryBuilder<T, R> part in parts.toList()) {
409 if (part == this) { 425 if (part == this) {
410 deprecated_addCompileTimeError(-1, "A file can't be a part of itself."); 426 addCompileTimeError(messagePartOfSelf, -1, fileUri);
411 } else if (seenParts.add(part.fileUri)) { 427 } else if (seenParts.add(part.fileUri)) {
412 includePart(part); 428 includePart(part);
413 } else { 429 } else {
414 deprecated_addCompileTimeError( 430 addCompileTimeError(
415 -1, "Can't use '${part.fileUri}' as a part more than once."); 431 templatePartTwice.withArguments(part.fileUri), -1, fileUri);
416 } 432 }
417 } 433 }
418 } 434 }
419 435
420 void includePart(SourceLibraryBuilder<T, R> part) { 436 void includePart(SourceLibraryBuilder<T, R> part) {
421 if (part.partOfUri != null) { 437 if (part.partOfUri != null) {
422 if (uri.resolve(part.partOfUri) != uri) { 438 if (uri.resolve(part.partOfUri) != uri) {
423 // This is a warning, but the part is still included. 439 // This is a warning, but the part is still included.
424 deprecated_addWarning( 440 addWarning(
441 templatePartOfUriMismatch.withArguments(
Johnni Winther 2017/07/12 08:10:37 Should this message still refer to the issue?
ahe 2017/07/12 20:07:58 No, the issue was closed as the CL was reverted. I
442 part.fileUri, uri, part.partOfUri),
425 -1, 443 -1,
426 "Using '${part.relativeFileUri}' as part of '$uri' but its " 444 fileUri);
427 "'part of' declaration says '${part.partOfUri}'.");
428 if (uri.scheme == "dart" && relativeFileUri.endsWith(part.partOfUri)) {
429 deprecated_addWarning(
430 -1, "See https://github.com/dart-lang/sdk/issues/30072.");
431 }
432 } 445 }
433 } else if (part.partOfName != null) { 446 } else if (part.partOfName != null) {
434 if (name != null) { 447 if (name != null) {
435 if (part.partOfName != name) { 448 if (part.partOfName != name) {
436 // This is a warning, but the part is still included. 449 // This is a warning, but the part is still included.
437 deprecated_addWarning( 450 addWarning(
451 templatePartOfLibraryNameMismatch.withArguments(
452 part.fileUri, name, part.partOfName),
438 -1, 453 -1,
439 "Using '${part.relativeFileUri}' as part of '$name' but its " 454 fileUri);
440 "'part of' declaration says '${part.partOfName}'.");
441 } 455 }
442 } else { 456 } else {
443 // This is a warning, but the part is still included. 457 // This is a warning, but the part is still included.
444 deprecated_addWarning( 458 addWarning(
459 templatePartOfUseUri.withArguments(
460 part.fileUri, fileUri, part.partOfName),
445 -1, 461 -1,
446 "Using '${part.relativeFileUri}' as part of '${relativeFileUri}' " 462 fileUri);
447 "but its 'part of' declaration says '${part.partOfName}'.\n"
448 "Try changing the 'part of' declaration to use a relative "
449 "file name.");
450 } 463 }
451 } else if (name != null) { 464 } else if (name != null) {
452 // This is an error, and the part isn't included. 465 // This is an error, and the part isn't included.
453 assert(!part.isPart); 466 assert(!part.isPart);
454 deprecated_addCompileTimeError( 467 addCompileTimeError(
455 -1, 468 templateMissingPartOf.withArguments(part.fileUri), -1, fileUri);
456 "Can't use ${part.fileUri} as a part, because it has no 'part of'"
457 " declaration.");
458 parts.remove(part); 469 parts.remove(part);
459 return; 470 return;
460 } 471 }
461 part.forEach((String name, Builder builder) { 472 part.forEach((String name, Builder builder) {
462 if (builder.next != null) { 473 if (builder.next != null) {
463 assert(builder.next.next == null); 474 assert(builder.next.next == null);
464 addBuilder(name, builder.next, builder.next.charOffset); 475 addBuilder(name, builder.next, builder.next.charOffset);
465 } 476 }
466 addBuilder(name, builder, builder.charOffset); 477 addBuilder(name, builder, builder.charOffset);
467 }); 478 });
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 /// synthesize type variables on the factory matching the class'. 645 /// synthesize type variables on the factory matching the class'.
635 void addFactoryDeclaration( 646 void addFactoryDeclaration(
636 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { 647 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) {
637 factoryDeclarations[procedure] = factoryDeclaration; 648 factoryDeclarations[procedure] = factoryDeclaration;
638 } 649 }
639 650
640 Scope toScope(Scope parent) { 651 Scope toScope(Scope parent) {
641 return new Scope(members, setters, parent, isModifiable: false); 652 return new Scope(members, setters, parent, isModifiable: false);
642 } 653 }
643 } 654 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698