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

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

Issue 2789863002: Sort procedures by source positions. (Closed)
Patch Set: Created 3 years, 8 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_class_builder; 5 library fasta.source_class_builder;
6 6
7 import 'package:kernel/ast.dart' 7 import 'package:kernel/ast.dart'
8 show Class, Constructor, Supertype, TreeNode, setParents; 8 show Class, Constructor, Supertype, TreeNode, setParents;
9 9
10 import '../errors.dart' show internalError; 10 import '../errors.dart' show internalError;
11 11
12 import '../kernel/kernel_builder.dart' 12 import '../kernel/kernel_builder.dart'
13 show 13 show
14 Builder, 14 Builder,
15 ConstructorReferenceBuilder, 15 ConstructorReferenceBuilder,
16 KernelClassBuilder, 16 KernelClassBuilder,
17 KernelFieldBuilder, 17 KernelFieldBuilder,
18 KernelFunctionBuilder, 18 KernelFunctionBuilder,
19 KernelLibraryBuilder, 19 KernelLibraryBuilder,
20 KernelTypeBuilder, 20 KernelTypeBuilder,
21 KernelTypeVariableBuilder, 21 KernelTypeVariableBuilder,
22 LibraryBuilder, 22 LibraryBuilder,
23 MetadataBuilder, 23 MetadataBuilder,
24 ProcedureBuilder, 24 ProcedureBuilder,
25 TypeVariableBuilder; 25 TypeVariableBuilder,
26 compareProcedures;
26 27
27 import '../dill/dill_member_builder.dart' show DillMemberBuilder; 28 import '../dill/dill_member_builder.dart' show DillMemberBuilder;
28 29
29 import '../util/relativize.dart' show relativizeUri; 30 import '../util/relativize.dart' show relativizeUri;
30 31
31 Class initializeClass( 32 Class initializeClass(
32 Class cls, String name, LibraryBuilder parent, int charOffset) { 33 Class cls, String name, LibraryBuilder parent, int charOffset) {
33 cls ??= new Class(name: name); 34 cls ??= new Class(name: name);
34 cls.fileUri ??= relativizeUri(parent.fileUri); 35 cls.fileUri ??= relativizeUri(parent.fileUri);
35 if (cls.fileOffset == TreeNode.noOffset) { 36 if (cls.fileOffset == TreeNode.noOffset) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 cls.isAbstract = isAbstract; 107 cls.isAbstract = isAbstract;
107 if (interfaces != null) { 108 if (interfaces != null) {
108 for (KernelTypeBuilder interface in interfaces) { 109 for (KernelTypeBuilder interface in interfaces) {
109 Supertype supertype = interface.buildSupertype(library); 110 Supertype supertype = interface.buildSupertype(library);
110 if (supertype != null) { 111 if (supertype != null) {
111 // TODO(ahe): Report an error if supertype is null. 112 // TODO(ahe): Report an error if supertype is null.
112 cls.implementedTypes.add(supertype); 113 cls.implementedTypes.add(supertype);
113 } 114 }
114 } 115 }
115 } 116 }
117
118 cls.procedures.sort(compareProcedures);
116 return cls; 119 return cls;
117 } 120 }
118 121
119 Builder findConstructorOrFactory(String name) => constructors[name]; 122 Builder findConstructorOrFactory(String name) => constructors[name];
120 123
121 void addSyntheticConstructor(Constructor constructor) { 124 void addSyntheticConstructor(Constructor constructor) {
122 String name = constructor.name.name; 125 String name = constructor.name.name;
123 cls.constructors.add(constructor); 126 cls.constructors.add(constructor);
124 constructor.parent = cls; 127 constructor.parent = cls;
125 DillMemberBuilder memberBuilder = new DillMemberBuilder(constructor, this); 128 DillMemberBuilder memberBuilder = new DillMemberBuilder(constructor, this);
(...skipping 16 matching lines...) Expand all
142 Map<String, Builder> computeConstructors(Map<String, Builder> members) { 145 Map<String, Builder> computeConstructors(Map<String, Builder> members) {
143 Map<String, Builder> constructors = <String, Builder>{}; 146 Map<String, Builder> constructors = <String, Builder>{};
144 members.forEach((String name, Builder builder) { 147 members.forEach((String name, Builder builder) {
145 if (builder is ProcedureBuilder && 148 if (builder is ProcedureBuilder &&
146 (builder.isConstructor || builder.isFactory)) { 149 (builder.isConstructor || builder.isFactory)) {
147 constructors[name] = builder; 150 constructors[name] = builder;
148 } 151 }
149 }); 152 });
150 return constructors; 153 return constructors;
151 } 154 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart ('k') | pkg/front_end/test/fasta/accessors.dart.direct.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698