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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/outline_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.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show ProcedureKind; 7 import 'package:kernel/ast.dart' show ProcedureKind;
8 8
9 import '../../scanner/token.dart' show Token; 9 import '../../scanner/token.dart' show Token;
10 10
11 import '../builder/builder.dart'; 11 import '../builder/builder.dart';
12 12
13 import '../combinator.dart' show Combinator; 13 import '../combinator.dart' show Combinator;
14 14
15 import '../fasta_codes.dart' show Message, codeExpectedBlockToSkip; 15 import '../fasta_codes.dart'
16 show
17 Message,
18 codeExpectedBlockToSkip,
19 messageOperatorWithOptionalFormals,
20 messageTypedefNotFunction,
21 templateDuplicatedParameterName,
22 templateDuplicatedParameterNameCause,
23 templateOperatorParameterMismatch;
16 24
17 import '../modifier.dart' show abstractMask, externalMask, Modifier; 25 import '../modifier.dart' show abstractMask, externalMask, Modifier;
18 26
19 import '../operator.dart' 27 import '../operator.dart'
20 show 28 show
21 Operator, 29 Operator,
22 operatorFromString, 30 operatorFromString,
23 operatorToString, 31 operatorToString,
24 operatorRequiredArgumentCount; 32 operatorRequiredArgumentCount;
25 33
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (Operator.subtract == nameOrOperator && formals == null) { 375 if (Operator.subtract == nameOrOperator && formals == null) {
368 nameOrOperator = Operator.unaryMinus; 376 nameOrOperator = Operator.unaryMinus;
369 } 377 }
370 String name; 378 String name;
371 ProcedureKind kind; 379 ProcedureKind kind;
372 if (nameOrOperator is Operator) { 380 if (nameOrOperator is Operator) {
373 name = operatorToString(nameOrOperator); 381 name = operatorToString(nameOrOperator);
374 kind = ProcedureKind.Operator; 382 kind = ProcedureKind.Operator;
375 int requiredArgumentCount = operatorRequiredArgumentCount(nameOrOperator); 383 int requiredArgumentCount = operatorRequiredArgumentCount(nameOrOperator);
376 if ((formals?.length ?? 0) != requiredArgumentCount) { 384 if ((formals?.length ?? 0) != requiredArgumentCount) {
377 library.deprecated_addCompileTimeError( 385 addCompileTimeError(
378 charOffset, 386 templateOperatorParameterMismatch.withArguments(
379 "Operator '$name' must have exactly $requiredArgumentCount " 387 name, requiredArgumentCount),
380 "parameters."); 388 charOffset);
381 } else { 389 } else {
382 if (formals != null) { 390 if (formals != null) {
383 for (FormalParameterBuilder formal in formals) { 391 for (FormalParameterBuilder formal in formals) {
384 if (!formal.isRequired) { 392 if (!formal.isRequired) {
385 library.deprecated_addCompileTimeError(formal.charOffset, 393 addCompileTimeError(
386 "An operator can't have optional parameters."); 394 messageOperatorWithOptionalFormals, formal.charOffset);
387 } 395 }
388 } 396 }
389 } 397 }
390 } 398 }
391 } else { 399 } else {
392 name = nameOrOperator; 400 name = nameOrOperator;
393 kind = computeProcedureKind(getOrSet); 401 kind = computeProcedureKind(getOrSet);
394 } 402 }
395 TypeBuilder returnType = pop(); 403 TypeBuilder returnType = pop();
396 int modifiers = 404 int modifiers =
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 formals = new List<FormalParameterBuilder>.filled(count + 1, null, 554 formals = new List<FormalParameterBuilder>.filled(count + 1, null,
547 growable: true); 555 growable: true);
548 formals[count] = last; 556 formals[count] = last;
549 } 557 }
550 popList(count, formals); 558 popList(count, formals);
551 } 559 }
552 if (formals != null) { 560 if (formals != null) {
553 if (formals.length == 2) { 561 if (formals.length == 2) {
554 // The name may be null for generalized function types. 562 // The name may be null for generalized function types.
555 if (formals[0].name != null && formals[0].name == formals[1].name) { 563 if (formals[0].name != null && formals[0].name == formals[1].name) {
556 library.deprecated_addCompileTimeError(formals[1].charOffset, 564 addCompileTimeError(
557 "Duplicated parameter name '${formals[1].name}'."); 565 templateDuplicatedParameterName.withArguments(formals[1].name),
558 library.deprecated_addCompileTimeError(formals[0].charOffset, 566 formals[1].charOffset);
559 "Other parameter named '${formals[1].name}'."); 567 addCompileTimeError(
568 templateDuplicatedParameterNameCause
569 .withArguments(formals[1].name),
570 formals[0].charOffset);
560 } 571 }
561 } else if (formals.length > 2) { 572 } else if (formals.length > 2) {
562 Map<String, FormalParameterBuilder> seenNames = 573 Map<String, FormalParameterBuilder> seenNames =
563 <String, FormalParameterBuilder>{}; 574 <String, FormalParameterBuilder>{};
564 for (FormalParameterBuilder formal in formals) { 575 for (FormalParameterBuilder formal in formals) {
565 if (formal.name == null) continue; 576 if (formal.name == null) continue;
566 if (seenNames.containsKey(formal.name)) { 577 if (seenNames.containsKey(formal.name)) {
567 library.deprecated_addCompileTimeError(formal.charOffset, 578 addCompileTimeError(
568 "Duplicated parameter name '${formal.name}'."); 579 templateDuplicatedParameterName.withArguments(formal.name),
569 library.deprecated_addCompileTimeError( 580 formal.charOffset);
570 seenNames[formal.name].charOffset, 581 addCompileTimeError(
571 "Other parameter named '${formal.name}'."); 582 templateDuplicatedParameterNameCause.withArguments(formal.name),
583 seenNames[formal.name].charOffset);
572 } else { 584 } else {
573 seenNames[formal.name] = formal; 585 seenNames[formal.name] = formal;
574 } 586 }
575 } 587 }
576 } 588 }
577 } 589 }
578 push(beginToken.charOffset); 590 push(beginToken.charOffset);
579 push(formals ?? NullValue.FormalParameters); 591 push(formals ?? NullValue.FormalParameters);
580 } 592 }
581 593
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 name = pop(); 675 name = pop();
664 if (type is FunctionTypeBuilder) { 676 if (type is FunctionTypeBuilder) {
665 // TODO(ahe): We need to start a nested declaration when parsing the 677 // TODO(ahe): We need to start a nested declaration when parsing the
666 // formals and return type so we can correctly bind 678 // formals and return type so we can correctly bind
667 // `type.typeVariables`. A typedef can have type variables, and a new 679 // `type.typeVariables`. A typedef can have type variables, and a new
668 // function type can also have type variables (representing the type of 680 // function type can also have type variables (representing the type of
669 // a generic function). 681 // a generic function).
670 functionType = type; 682 functionType = type;
671 } else { 683 } else {
672 // TODO(ahe): Improve this error message. 684 // TODO(ahe): Improve this error message.
673 library.deprecated_addCompileTimeError( 685 addCompileTimeError(messageTypedefNotFunction, equals.charOffset);
674 equals.charOffset, "Can't create typedef from non-function type.");
675 } 686 }
676 } 687 }
677 List<MetadataBuilder> metadata = pop(); 688 List<MetadataBuilder> metadata = pop();
678 library.addFunctionTypeAlias( 689 library.addFunctionTypeAlias(
679 metadata, name, typeVariables, functionType, charOffset); 690 metadata, name, typeVariables, functionType, charOffset);
680 checkEmpty(typedefKeyword.charOffset); 691 checkEmpty(typedefKeyword.charOffset);
681 silenceParserErrors = true; 692 silenceParserErrors = true;
682 } 693 }
683 694
684 @override 695 @override
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 nativeMethodName = 872 nativeMethodName =
862 stringExpectedAfterNative ? extractNativeMethodName(token) : ""; 873 stringExpectedAfterNative ? extractNativeMethodName(token) : "";
863 return recover; 874 return recover;
864 } 875 }
865 } 876 }
866 return super.handleUnrecoverableError(token, message); 877 return super.handleUnrecoverableError(token, message);
867 } 878 }
868 879
869 @override 880 @override
870 void addCompileTimeError(Message message, int charOffset) { 881 void addCompileTimeError(Message message, int charOffset) {
871 library.deprecated_addCompileTimeError(charOffset, message.message, 882 library.addCompileTimeError(message, charOffset, uri);
872 fileUri: uri);
873 } 883 }
874 884
875 @override 885 @override
876 Link<Token> handleMemberName(Link<Token> identifiers) { 886 Link<Token> handleMemberName(Link<Token> identifiers) {
877 if (!enableNative || identifiers.isEmpty) return identifiers; 887 if (!enableNative || identifiers.isEmpty) return identifiers;
878 return removeNativeClause(identifiers, stringExpectedAfterNative); 888 return removeNativeClause(identifiers, stringExpectedAfterNative);
879 } 889 }
880 890
881 @override 891 @override
882 void debugEvent(String name) { 892 void debugEvent(String name) {
883 // printEvent(name); 893 // printEvent(name);
884 } 894 }
885 } 895 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698