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

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

Issue 1431683002: Refactor analysis server code generation to re-use logic from analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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) 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 library codegen.protocol; 5 library codegen.protocol;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/src/codegen/tools.dart';
9 import 'package:html/dom.dart' as dom; 10 import 'package:html/dom.dart' as dom;
10 11
11 import 'api.dart'; 12 import 'api.dart';
12 import 'codegen_dart.dart'; 13 import 'codegen_dart.dart';
13 import 'codegen_tools.dart';
14 import 'from_html.dart'; 14 import 'from_html.dart';
15 import 'implied_types.dart'; 15 import 'implied_types.dart';
16 import 'to_html.dart'; 16 import 'to_html.dart';
17 17
18 /** 18 /**
19 * Translate spec_input.html into protocol_matchers.dart.
20 */
21 main() {
22 target.generate();
23 }
24
25 /**
26 * Special flags that need to be inserted into the declaration of the Element 19 * Special flags that need to be inserted into the declaration of the Element
27 * class. 20 * class.
28 */ 21 */
29 const Map<String, String> specialElementFlags = const { 22 const Map<String, String> specialElementFlags = const {
30 'abstract': '0x01', 23 'abstract': '0x01',
31 'const': '0x02', 24 'const': '0x02',
32 'final': '0x04', 25 'final': '0x04',
33 'static': '0x08', 26 'static': '0x08',
34 'private': '0x10', 27 'private': '0x10',
35 'deprecated': '0x20' 28 'deprecated': '0x20'
36 }; 29 };
37 30
38 final GeneratedFile target = 31 final GeneratedFile target = new GeneratedFile(
39 new GeneratedFile('../../lib/plugin/protocol/generated_protocol.dart', () { 32 'lib/plugin/protocol/generated_protocol.dart', (String pkgPath) {
40 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); 33 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi(pkgPath));
41 return visitor.collectCode(visitor.visitApi); 34 return visitor.collectCode(visitor.visitApi);
42 }); 35 });
43 36
44 /** 37 /**
45 * Callback type used to represent arbitrary code generation. 38 * Callback type used to represent arbitrary code generation.
46 */ 39 */
47 typedef void CodegenCallback(); 40 typedef void CodegenCallback();
48 41
49 typedef String FromJsonSnippetCallback(String jsonPath, String json); 42 typedef String FromJsonSnippetCallback(String jsonPath, String json);
50 43
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 1233
1241 @override 1234 @override
1242 String get asClosure => '($type value) => ${callback('value')}'; 1235 String get asClosure => '($type value) => ${callback('value')}';
1243 1236
1244 @override 1237 @override
1245 bool get isIdentity => false; 1238 bool get isIdentity => false;
1246 1239
1247 @override 1240 @override
1248 String asSnippet(String value) => callback(value); 1241 String asSnippet(String value) => callback(value);
1249 } 1242 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_analysis_server.dart ('k') | pkg/analysis_server/tool/spec/codegen_inttest_methods.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698