| OLD | NEW |
| 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 server.generator.java; | 8 library server.generator.java; |
| 9 | 9 |
| 10 import 'api.dart'; | 10 import 'api.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 writeln(); | 22 writeln(); |
| 23 writeln('import java.util.List;'); | 23 writeln('import java.util.List;'); |
| 24 writeln('import java.util.Map;'); | 24 writeln('import java.util.Map;'); |
| 25 writeln(); | 25 writeln(); |
| 26 writeln('''/** | 26 writeln('''/** |
| 27 * The interface {@code AnalysisServer} defines the behavior of objects that int
erface to an | 27 * The interface {@code AnalysisServer} defines the behavior of objects that int
erface to an |
| 28 * analysis server. | 28 * analysis server. |
| 29 * | 29 * |
| 30 * @coverage dart.server | 30 * @coverage dart.server |
| 31 */'''); | 31 */'''); |
| 32 makeClass('public interface AnalysisServer2', () { | 32 makeClass('public interface AnalysisServer', () { |
| 33 // |
| 34 // addAnalysisServerListener(..) |
| 35 // |
| 33 publicMethod('addAnalysisServerListener', () { | 36 publicMethod('addAnalysisServerListener', () { |
| 34 writeln('''/** | 37 writeln('''/** |
| 35 * Add the given listener to the list of listeners that will receive notificatio
n when new | 38 * Add the given listener to the list of listeners that will receive notificatio
n when new |
| 36 * analysis results become available. | 39 * analysis results become available. |
| 37 * | 40 * |
| 38 * @param listener the listener to be added | 41 * @param listener the listener to be added |
| 39 */'''); | 42 */'''); |
| 40 writeln('public void addAnalysisServerListener(AnalysisServerListener li
stener);'); | 43 writeln('public void addAnalysisServerListener(AnalysisServerListener li
stener);'); |
| 44 }); |
| 45 |
| 46 // |
| 47 // removeAnalysisServerListener(..) |
| 48 // |
| 49 publicMethod('removeAnalysisServerListener', () { |
| 50 writeln('''/** |
| 51 * Remove the given listener from the list of listeners that will receive notifi
cation when new |
| 52 * analysis results become available. |
| 53 * |
| 54 * @param listener the listener to be removed |
| 55 */'''); |
| 56 writeln('public void removeAnalysisServerListener(AnalysisServerListener
listener);'); |
| 57 }); |
| 58 |
| 59 // |
| 60 // start(..) |
| 61 // |
| 62 publicMethod('start', () { |
| 41 writeln('''/** | 63 writeln('''/** |
| 42 * Start the analysis server. | 64 * Start the analysis server. |
| 43 * | 65 * |
| 44 * @param millisToRestart the number of milliseconds to wait for an unresponsive
server before | 66 * @param millisToRestart the number of milliseconds to wait for an unresponsive
server before |
| 45 * restarting it, or zero if the server should not be restarted. | 67 * restarting it, or zero if the server should not be restarted. |
| 46 */'''); | 68 */'''); |
| 47 writeln('public void start(long millisToRestart) throws Exception;'); | 69 writeln('public void start(long millisToRestart) throws Exception;'); |
| 48 }); | 70 }); |
| 49 super.visitApi(); | 71 super.visitApi(); |
| 50 }); | 72 }); |
| 51 } | 73 } |
| 52 | 74 |
| 53 @override | 75 @override |
| 54 void visitRequest(Request request) { | 76 void visitRequest(Request request) { |
| 55 String methodName = '${request.domainName}_${request.method}'; | 77 String methodName = '${request.domainName}_${request.method}'; |
| 56 publicMethod(methodName, () { | 78 publicMethod(methodName, () { |
| 57 docComment(toHtmlVisitor.collectHtml(() { | 79 docComment(toHtmlVisitor.collectHtml(() { |
| 58 toHtmlVisitor.write('{@code ${request.longMethod }}'); | 80 toHtmlVisitor.write('{@code ${request.longMethod }}'); |
| 59 toHtmlVisitor.translateHtml(request.html); | 81 toHtmlVisitor.translateHtml(request.html); |
| 60 toHtmlVisitor.javadocParams(request.params); | 82 toHtmlVisitor.javadocParams(request.params); |
| 61 }), width: 99, javadocStyle: true); | 83 }), width: 99, javadocStyle: true); |
| 62 write('// public void $methodName('); | 84 write('public void $methodName('); |
| 63 List<String> arguments = []; | 85 List<String> arguments = []; |
| 64 if (request.params != null) { | 86 if (request.params != null) { |
| 65 for (TypeObjectField field in request.params.fields) { | 87 for (TypeObjectField field in request.params.fields) { |
| 66 arguments.add('${javaType(field.type)} ${javaName(field.name)}'); | 88 arguments.add('${javaType(field.type)} ${javaName(field.name)}'); |
| 67 } | 89 } |
| 68 } | 90 } |
| 69 if (request.result != null) { | 91 if (request.result != null) { |
| 70 arguments.add('${consumerName(request)} consumer'); | 92 arguments.add('${consumerName(request)} consumer'); |
| 71 } | 93 } |
| 72 write(arguments.join(', ')); | 94 write(arguments.join(', ')); |
| 73 writeln(');'); | 95 writeln(');'); |
| 74 }); | 96 }); |
| 75 } | 97 } |
| 76 | 98 |
| 77 /** | 99 /** |
| 78 * Get the name of the consumer class for responses to this request. | 100 * Get the name of the consumer class for responses to this request. |
| 79 */ | 101 */ |
| 80 String consumerName(Request request) { | 102 String consumerName(Request request) { |
| 81 return camelJoin([request.method, 'consumer'], capitalize: true); | 103 return camelJoin([request.method, 'consumer'], capitalize: true); |
| 82 } | 104 } |
| 83 } | 105 } |
| 84 | 106 |
| 85 /** | 107 /** |
| 86 * Translate spec_input.html into AnalysisServer.java. | 108 * Translate spec_input.html into AnalysisServer.java. |
| 87 */ | 109 */ |
| 88 main() { | 110 main() { |
| 89 createJavaCode('../../../../editor/tools/plugins/com.google.dart.server/src/co
m/google/dart/server/AnalysisServer2.java', new CodegenAnalysisServer(readApi())
); | 111 createJavaCode('../../../../editor/tools/plugins/com.google.dart.server/src/co
m/google/dart/server/AnalysisServer.java', new CodegenAnalysisServer(readApi()))
; |
| 90 } | 112 } |
| OLD | NEW |