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

Side by Side Diff: pkg/analysis_server/tool/spec/codegen_matchers.dart

Issue 459643002: Improve matchers for enums defined by the analysis server API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/integration/protocol_matchers.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /** 5 /**
6 * Code generation for the file "matchers.dart". 6 * Code generation for the file "matchers.dart".
7 */ 7 */
8 library codegen.matchers; 8 library codegen.matchers;
9 9
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 makeMatcher(camelKind, 'options', refactoring.options); 96 makeMatcher(camelKind, 'options', refactoring.options);
97 } 97 }
98 98
99 @override 99 @override
100 visitTypeDefinition(TypeDefinition typeDefinition) { 100 visitTypeDefinition(TypeDefinition typeDefinition) {
101 makeMatcher(typeDefinition.name, null, typeDefinition.type); 101 makeMatcher(typeDefinition.name, null, typeDefinition.type);
102 } 102 }
103 103
104 @override 104 @override
105 visitTypeEnum(TypeEnum typeEnum) { 105 visitTypeEnum(TypeEnum typeEnum) {
106 writeln('isIn(['); 106 writeln('new MatchesEnum(${JSON.encode(context)}, [');
107 indent(() { 107 indent(() {
108 bool commaNeeded = false; 108 bool commaNeeded = false;
109 for (TypeEnumValue value in typeEnum.values) { 109 for (TypeEnumValue value in typeEnum.values) {
110 if (commaNeeded) { 110 if (commaNeeded) {
111 writeln(','); 111 writeln(',');
112 } 112 }
113 write('${JSON.encode(value.value)}'); 113 write('${JSON.encode(value.value)}');
114 commaNeeded = true; 114 commaNeeded = true;
115 } 115 }
116 writeln(); 116 writeln();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 /** 191 /**
192 * Translate spec_input.html into protocol_matchers.dart. 192 * Translate spec_input.html into protocol_matchers.dart.
193 */ 193 */
194 main() { 194 main() {
195 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); 195 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi());
196 String code = visitor.collectCode(visitor.visitApi); 196 String code = visitor.collectCode(visitor.visitApi);
197 File outputFile = new File('../../test/integration/protocol_matchers.dart'); 197 File outputFile = new File('../../test/integration/protocol_matchers.dart');
198 outputFile.writeAsStringSync(code); 198 outputFile.writeAsStringSync(code);
199 } 199 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/protocol_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698