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

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

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/tool/spec/api.dart ('k') | pkg/analysis_server/tool/spec/codegen_dart.dart » ('j') | 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 "AnalysisServer.java". 6 * Code generation for the file "AnalysisServer.java".
7 */ 7 */
8 library java.generator.server; 8 library java.generator.server;
9 9
10 import 'api.dart'; 10 import 'api.dart';
11 import 'codegen_java.dart'; 11 import 'codegen_java.dart';
12 import 'codegen_tools.dart'; 12 import 'codegen_tools.dart';
13 13
14 final GeneratedFile target = javaGeneratedFile(
15 '../../../../editor/tools/plugins/com.google.dart.server/src/com/google/dart /server/AnalysisServer.java',
16 (Api api) => new CodegenAnalysisServer(api));
17
18 /**
19 * Translate spec_input.html into AnalysisServer.java.
20 */
21 main() {
22 target.generate();
23 }
24
14 class CodegenAnalysisServer extends CodegenJavaVisitor { 25 class CodegenAnalysisServer extends CodegenJavaVisitor {
15 CodegenAnalysisServer(Api api) : super(api); 26 CodegenAnalysisServer(Api api) : super(api);
16 27
28 /**
29 * Get the name of the consumer class for responses to this request.
30 */
31 String consumerName(Request request) {
32 return camelJoin([request.method, 'consumer'], doCapitalize: true);
33 }
34
17 @override 35 @override
18 void visitApi() { 36 void visitApi() {
19 outputHeader(javaStyle: true); 37 outputHeader(javaStyle: true);
20 writeln('package com.google.dart.server;'); 38 writeln('package com.google.dart.server;');
21 writeln(); 39 writeln();
22 writeln('import com.google.dart.server.generated.types.*;'); 40 writeln('import com.google.dart.server.generated.types.*;');
23 writeln(); 41 writeln();
24 writeln('import java.util.List;'); 42 writeln('import java.util.List;');
25 writeln('import java.util.Map;'); 43 writeln('import java.util.Map;');
26 writeln(); 44 writeln();
27 writeln( 45 writeln('''/**
28 '''/**
29 * The interface {@code AnalysisServer} defines the behavior of objects that int erface to an 46 * The interface {@code AnalysisServer} defines the behavior of objects that int erface to an
30 * analysis server. 47 * analysis server.
31 * 48 *
32 * @coverage dart.server 49 * @coverage dart.server
33 */''' 50 */''');
34 );
35 makeClass('public interface AnalysisServer', () { 51 makeClass('public interface AnalysisServer', () {
36 // 52 //
37 // addAnalysisServerListener(..) 53 // addAnalysisServerListener(..)
38 // 54 //
39 publicMethod('addAnalysisServerListener', () { 55 publicMethod('addAnalysisServerListener', () {
40 writeln( 56 writeln('''/**
41 '''/**
42 * Add the given listener to the list of listeners that will receive notificatio n when new 57 * Add the given listener to the list of listeners that will receive notificatio n when new
43 * analysis results become available. 58 * analysis results become available.
44 * 59 *
45 * @param listener the listener to be added 60 * @param listener the listener to be added
46 */''' 61 */''');
47 );
48 writeln( 62 writeln(
49 'public void addAnalysisServerListener(AnalysisServerListener listen er);'); 63 'public void addAnalysisServerListener(AnalysisServerListener listen er);');
50 }); 64 });
51 65
52 // 66 //
53 // removeAnalysisServerListener(..) 67 // removeAnalysisServerListener(..)
54 // 68 //
55 publicMethod('removeAnalysisServerListener', () { 69 publicMethod('removeAnalysisServerListener', () {
56 writeln( 70 writeln('''/**
57 '''/**
58 * Remove the given listener from the list of listeners that will receive notifi cation when new 71 * Remove the given listener from the list of listeners that will receive notifi cation when new
59 * analysis results become available. 72 * analysis results become available.
60 * 73 *
61 * @param listener the listener to be removed 74 * @param listener the listener to be removed
62 */''' 75 */''');
63 );
64 writeln( 76 writeln(
65 'public void removeAnalysisServerListener(AnalysisServerListener lis tener);'); 77 'public void removeAnalysisServerListener(AnalysisServerListener lis tener);');
66 }); 78 });
67 79
68 // 80 //
69 // start(..) 81 // start(..)
70 // 82 //
71 publicMethod('start', () { 83 publicMethod('start', () {
72 writeln( 84 writeln('''/**
73 '''/**
74 * Start the analysis server. 85 * Start the analysis server.
75 */''' 86 */''');
76 );
77 writeln('public void start() throws Exception;'); 87 writeln('public void start() throws Exception;');
78 }); 88 });
79 super.visitApi(); 89 super.visitApi();
80 }); 90 });
81 } 91 }
82 92
83 @override 93 @override
84 void visitRequest(Request request) { 94 void visitRequest(Request request) {
85 String methodName = '${request.domainName}_${request.method}'; 95 String methodName = '${request.domainName}_${request.method}';
86 publicMethod(methodName, () { 96 publicMethod(methodName, () {
87 docComment(toHtmlVisitor.collectHtml(() { 97 docComment(toHtmlVisitor.collectHtml(() {
88 toHtmlVisitor.write('{@code ${request.longMethod }}'); 98 toHtmlVisitor.write('{@code ${request.longMethod }}');
89 toHtmlVisitor.translateHtml(request.html); 99 toHtmlVisitor.translateHtml(request.html);
90 toHtmlVisitor.javadocParams(request.params); 100 toHtmlVisitor.javadocParams(request.params);
91 }), width: 99, javadocStyle: true); 101 }), width: 99, javadocStyle: true);
92 write('public void $methodName('); 102 write('public void $methodName(');
93 List<String> arguments = []; 103 List<String> arguments = [];
94 if (request.params != null) { 104 if (request.params != null) {
95 for (TypeObjectField field in request.params.fields) { 105 for (TypeObjectField field in request.params.fields) {
96 arguments.add('${javaType(field.type)} ${javaName(field.name)}'); 106 arguments.add('${javaType(field.type)} ${javaName(field.name)}');
97 } 107 }
98 } 108 }
99 if (request.result != null) { 109 if (request.result != null) {
100 arguments.add('${consumerName(request)} consumer'); 110 arguments.add('${consumerName(request)} consumer');
101 } 111 }
102 write(arguments.join(', ')); 112 write(arguments.join(', '));
103 writeln(');'); 113 writeln(');');
104 }); 114 });
105 } 115 }
106
107 /**
108 * Get the name of the consumer class for responses to this request.
109 */
110 String consumerName(Request request) {
111 return camelJoin([request.method, 'consumer'], doCapitalize: true);
112 }
113 } 116 }
114
115 final GeneratedFile target = javaGeneratedFile(
116 '../../../../editor/tools/plugins/com.google.dart.server/src/com/google/dart /server/AnalysisServer.java',
117 (Api api) => new CodegenAnalysisServer(api));
118
119 /**
120 * Translate spec_input.html into AnalysisServer.java.
121 */
122 main() {
123 target.generate();
124 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/tool/spec/api.dart ('k') | pkg/analysis_server/tool/spec/codegen_dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698