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

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

Issue 463163002: Initial cut at generating the AnalysisServer.java interface. Currently this generates a commented o… (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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Code generation for the file "AnalysisServer.java".
7 */
8 library CodegenAnalysisServer;
9
10 import 'api.dart';
11 import 'codegen_java.dart';
12 import 'codegen_tools.dart';
13 import 'from_html.dart';
14
15 class CodegenAnalysisServer extends CodegenJavaVisitor {
16 CodegenAnalysisServer(Api api) : super(api);
17
18 @override
19 void visitApi() {
20 outputHeader(javaStyle: true);
21 writeln('package com.google.dart.server;');
22 writeln();
23 writeln('import java.util.List;');
24 writeln('import java.util.Map;');
25 writeln();
26 writeln('''/**
27 * The interface {@code AnalysisServer} defines the behavior of objects that int erface to an
28 * analysis server.
29 *
30 * @coverage dart.server
31 */''');
32 makeClass('public interface AnalysisServer2', () {
33 publicMethod('addAnalysisServerListener', () {
34 writeln('''/**
35 * Add the given listener to the list of listeners that will receive notificat ion when new
36 * analysis results become available.
37 *
38 * @param listener the listener to be added
39 */''');
40 writeln('public void addAnalysisServerListener(AnalysisServerListener li stener);');
41 writeln('''/**
42 * Start the analysis server.
43 *
44 * @param millisToRestart the number of milliseconds to wait for an unresponsi ve server before
45 * restarting it, or zero if the server should not be restarted.
46 */''');
47 writeln('public void start(long millisToRestart) throws Exception;');
48 });
49 super.visitApi();
50 });
51 }
52
53 @override
54 void visitRequest(Request request) {
55 String methodName;
56 switch (request.longMethod) {
57 default:
58 methodName = request.method;
59 }
60 publicMethod(methodName, () {
61 docComment(toHtmlVisitor.collectHtml(() {
62 toHtmlVisitor.write('{@code ${request.longMethod }}');
63 toHtmlVisitor.translateHtml(request.html);
64 toHtmlVisitor.javadocParams(request.params);
65 }), width: 99, javadocStyle: true);
66 write('// public void $methodName(');
67 if (request.params != null) {
68 int i = 0;
69 int length = request.params.fields.length;
70 for (TypeObjectField field in request.params.fields) {
71 write('${javaType(field.type)} ${javaName(field.name)}');
72 if (++i < length) {
73 write(', ');
74 }
75 }
76 }
77 if (request.result != null) {
78 // if we had parameters, put a comma after them, otherwise, don't
79 if (request.params != null) {
80 write(', ');
81 }
82 // write out the consumer name
83 write('${consumerName(request)} consumer');
84 }
85 writeln(');');
86 });
87 }
88
89 /**
90 * Get the name of the consumer class for responses to this request.
91 */
92 String consumerName(Request request) {
93 return camelJoin([request.method, 'consumer'], capitalize: true);
94 }
95 }
96
97 /**
98 * Translate spec_input.html into AnalysisServer.java.
99 */
100 main() {
101 createJavaCode('../../../../editor/tools/plugins/com.google.dart.server/src/co m/google/dart/server/AnalysisServer2.java', new CodegenAnalysisServer(readApi()) );
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698