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_enum_builder.dart

Issue 2990873002: Add Member.documentationComment and use it to resynthesize documentation from Kernel. (Closed)
Patch Set: Created 3 years, 4 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_enum_builder; 5 library fasta.kernel_enum_builder;
6 6
7 import 'package:kernel/ast.dart' 7 import 'package:kernel/ast.dart'
8 show 8 show
9 Arguments, 9 Arguments,
10 Class, 10 Class,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 /// From Dart Programming Language Specification 4th Edition/December 2015: 118 /// From Dart Programming Language Specification 4th Edition/December 2015:
119 /// metadata class E { 119 /// metadata class E {
120 /// final int index; 120 /// final int index;
121 /// const E(this.index); 121 /// const E(this.index);
122 /// static const E id0 = const E(0); 122 /// static const E id0 = const E(0);
123 /// ... 123 /// ...
124 /// static const E idn-1 = const E(n - 1); 124 /// static const E idn-1 = const E(n - 1);
125 /// static const List<E> values = const <E>[id0, ..., idn-1]; 125 /// static const List<E> values = const <E>[id0, ..., idn-1];
126 /// String toString() => { 0: ‘E.id0’, . . ., n-1: ‘E.idn-1’}[index] 126 /// String toString() => { 0: ‘E.id0’, . . ., n-1: ‘E.idn-1’}[index]
127 /// } 127 /// }
128 members["index"] = new KernelFieldBuilder( 128 members["index"] = new KernelFieldBuilder(null, null, intType, "index",
129 null, intType, "index", finalMask, parent, charOffset, null, true); 129 finalMask, parent, charOffset, null, true);
130 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder( 130 KernelConstructorBuilder constructorBuilder = new KernelConstructorBuilder(
131 null, 131 null,
132 null,
132 constMask, 133 constMask,
133 null, 134 null,
134 "", 135 "",
135 null, 136 null,
136 <FormalParameterBuilder>[ 137 <FormalParameterBuilder>[
137 new KernelFormalParameterBuilder( 138 new KernelFormalParameterBuilder(
138 null, 0, intType, "index", true, parent, charOffset) 139 null, 0, intType, "index", true, parent, charOffset)
139 ], 140 ],
140 parent, 141 parent,
141 charOffset, 142 charOffset,
142 charOffset, 143 charOffset,
143 charEndOffset); 144 charEndOffset);
144 constructors[""] = constructorBuilder; 145 constructors[""] = constructorBuilder;
145 int index = 0; 146 int index = 0;
146 List<MapEntry> toStringEntries = <MapEntry>[]; 147 List<MapEntry> toStringEntries = <MapEntry>[];
147 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder(null, listType, 148 KernelFieldBuilder valuesBuilder = new KernelFieldBuilder(
148 "values", constMask | staticMask, parent, charOffset, null, true); 149 null,
150 null,
151 listType,
152 "values",
153 constMask | staticMask,
154 parent,
155 charOffset,
156 null,
157 true);
149 members["values"] = valuesBuilder; 158 members["values"] = valuesBuilder;
150 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder( 159 KernelProcedureBuilder toStringBuilder = new KernelProcedureBuilder(
151 null, 160 null,
161 null,
152 0, 162 0,
153 stringType, 163 stringType,
154 "toString", 164 "toString",
155 null, 165 null,
156 null, 166 null,
157 ProcedureKind.Method, 167 ProcedureKind.Method,
158 parent, 168 parent,
159 charOffset, 169 charOffset,
160 charOffset, 170 charOffset,
161 charEndOffset); 171 charEndOffset);
162 members["toString"] = toStringBuilder; 172 members["toString"] = toStringBuilder;
163 String className = name; 173 String className = name;
164 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) { 174 for (int i = 0; i < constantNamesAndOffsets.length; i += 2) {
165 String name = constantNamesAndOffsets[i]; 175 String name = constantNamesAndOffsets[i];
166 int charOffset = constantNamesAndOffsets[i + 1]; 176 int charOffset = constantNamesAndOffsets[i + 1];
167 if (members.containsKey(name)) { 177 if (members.containsKey(name)) {
168 parent.addCompileTimeError(templateDuplicatedName.withArguments(name), 178 parent.addCompileTimeError(templateDuplicatedName.withArguments(name),
169 charOffset, parent.fileUri); 179 charOffset, parent.fileUri);
170 constantNamesAndOffsets[i] = null; 180 constantNamesAndOffsets[i] = null;
171 continue; 181 continue;
172 } 182 }
173 if (name == className) { 183 if (name == className) {
174 parent.addCompileTimeError( 184 parent.addCompileTimeError(
175 templateEnumConstantSameNameAsEnclosing.withArguments(name), 185 templateEnumConstantSameNameAsEnclosing.withArguments(name),
176 charOffset, 186 charOffset,
177 parent.fileUri); 187 parent.fileUri);
178 constantNamesAndOffsets[i] = null; 188 constantNamesAndOffsets[i] = null;
179 continue; 189 continue;
180 } 190 }
181 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder(null, selfType, 191 KernelFieldBuilder fieldBuilder = new KernelFieldBuilder(
182 name, constMask | staticMask, parent, charOffset, null, true); 192 null,
193 null,
194 selfType,
195 name,
196 constMask | staticMask,
197 parent,
198 charOffset,
199 null,
200 true);
183 members[name] = fieldBuilder; 201 members[name] = fieldBuilder;
184 toStringEntries.add(new MapEntry( 202 toStringEntries.add(new MapEntry(
185 new IntLiteral(index), new StringLiteral("$className.$name"))); 203 new IntLiteral(index), new StringLiteral("$className.$name")));
186 index++; 204 index++;
187 } 205 }
188 MapLiteral toStringMap = new MapLiteral(toStringEntries, isConst: true); 206 MapLiteral toStringMap = new MapLiteral(toStringEntries, isConst: true);
189 KernelEnumBuilder enumBuilder = new KernelEnumBuilder.internal( 207 KernelEnumBuilder enumBuilder = new KernelEnumBuilder.internal(
190 null, 208 null,
191 metadata, 209 metadata,
192 name, 210 name,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 306 }
289 return super.build(libraryBuilder, coreLibrary); 307 return super.build(libraryBuilder, coreLibrary);
290 } 308 }
291 309
292 @override 310 @override
293 Builder findConstructorOrFactory( 311 Builder findConstructorOrFactory(
294 String name, int charOffset, Uri uri, LibraryBuilder library) { 312 String name, int charOffset, Uri uri, LibraryBuilder library) {
295 return null; 313 return null;
296 } 314 }
297 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698