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

Side by Side Diff: pkg/analysis_server/tool/spec/codegen_tools.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: nit 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
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 * Tools for code generation. 6 * Tools for code generation.
7 */ 7 */
8 library codegen.tools; 8 library codegen.tools;
9 9
10 import 'package:html5lib/dom.dart' as dom; 10 import 'package:html5lib/dom.dart' as dom;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 * Measure the width of the current indentation level. 99 * Measure the width of the current indentation level.
100 */ 100 */
101 int get indentWidth => _state.nextIndent.length; 101 int get indentWidth => _state.nextIndent.length;
102 102
103 /** 103 /**
104 * Generate a doc comment based on the HTML in [docs]. 104 * Generate a doc comment based on the HTML in [docs].
105 * 105 *
106 * If [javadocStyle] is true, then the output is compatable with Javadoc, 106 * If [javadocStyle] is true, then the output is compatable with Javadoc,
107 * which understands certain HTML constructs. 107 * which understands certain HTML constructs.
108 */ 108 */
109 void docComment(List<dom.Node> docs, bool javadocStyle) { 109 void docComment(List<dom.Node> docs, {int width: 79, bool javadocStyle: false} ) {
110 writeln('/**'); 110 writeln('/**');
111 indentBy(' * ', () { 111 indentBy(' * ', () {
112 write(nodesToText(docs, 79 - _state.indent.length, javadocStyle)); 112 write(nodesToText(docs, width - _state.indent.length, javadocStyle));
113 }); 113 });
114 writeln(' */'); 114 writeln(' */');
115 } 115 }
116 116
117 void outputHeader() { 117 void outputHeader({bool javaStyle: false}) {
118 String header = 118 String header;
119 ''' 119 if(javaStyle) {
120 header = '''
121 /*
122 * Copyright (c) 2014, the Dart project authors.
123 *
124 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
125 * in compliance with the License. You may obtain a copy of the License at
126 *
127 * http://www.eclipse.org/legal/epl-v10.html
128 *
129 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
130 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
131 * or implied. See the License for the specific language governing permissions a nd limitations under
132 * the License.
133 *
134 * This file has been automatically generated. Please do not edit it manually.
135 * To regenerate the file, use the script "pkg/analysis_server/spec/generate_fil es".
136 */''';
137 }
138 else {
139 header = '''
120 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 140 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
121 // for details. All rights reserved. Use of this source code is governed by a 141 // for details. All rights reserved. Use of this source code is governed by a
122 // BSD-style license that can be found in the LICENSE file. 142 // BSD-style license that can be found in the LICENSE file.
123 // 143 //
124 // This file has been automatically generated. Please do not edit it manually. 144 // This file has been automatically generated. Please do not edit it manually.
125 // To regenerate the file, use the script 145 // To regenerate the file, use the script
126 // "pkg/analysis_server/spec/generate_files". 146 // "pkg/analysis_server/spec/generate_files".
127 '''; 147 ''';
148 }
128 writeln(header.trim()); 149 writeln(header.trim());
129 writeln();
130 } 150 }
131 } 151 }
132 152
133 /** 153 /**
134 * State used by [CodeGenerator]. 154 * State used by [CodeGenerator].
135 */ 155 */
136 class _CodeGeneratorState { 156 class _CodeGeneratorState {
137 StringBuffer buffer = new StringBuffer(); 157 StringBuffer buffer = new StringBuffer();
138 String nextIndent = ''; 158 String nextIndent = '';
139 String indent = ''; 159 String indent = '';
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (lines.last.isEmpty) { 283 if (lines.last.isEmpty) {
264 lines.removeLast(); 284 lines.removeLast();
265 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); 285 buffer.add(new dom.Text(lines.join('\n$indent') + '\n'));
266 indentNeeded = true; 286 indentNeeded = true;
267 } else { 287 } else {
268 buffer.add(new dom.Text(lines.join('\n$indent'))); 288 buffer.add(new dom.Text(lines.join('\n$indent')));
269 indentNeeded = false; 289 indentNeeded = false;
270 } 290 }
271 } 291 }
272 } 292 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_matchers.dart ('k') | pkg/analysis_server/tool/spec/generate_files » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698