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

Unified Diff: tools/dom/scripts/idlrenderer.dart

Issue 2827793002: Format all files under tools and utils directory. (Closed)
Patch Set: Format all files under tools and utils directory. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/docs/test/docs_test.dart ('k') | tools/dom/src/AttributeMap.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/idlrenderer.dart
diff --git a/tools/dom/scripts/idlrenderer.dart b/tools/dom/scripts/idlrenderer.dart
index 9b7bd320d926db82a7ed2d1991d485c15c80c464..75a77a0222848cc186b2ee126b730eced516d591 100644
--- a/tools/dom/scripts/idlrenderer.dart
+++ b/tools/dom/scripts/idlrenderer.dart
@@ -4,24 +4,23 @@
List sorted(Iterable input, [compare, key]) {
comparator(compare, key) {
- if (compare == null && key == null)
- return (a, b) => a.compareTo(b);
- if (compare == null)
- return (a, b) => key(a).compareTo(key(b));
- if (key == null)
- return compare;
+ if (compare == null && key == null) return (a, b) => a.compareTo(b);
+ if (compare == null) return (a, b) => key(a).compareTo(key(b));
+ if (key == null) return compare;
return (a, b) => compare(key(a), key(b));
}
+
List copy = new List.from(input);
copy.sort(comparator(compare, key));
return copy;
}
-render(idl_node, [indent_str=' ']) {
+render(idl_node, [indent_str = ' ']) {
var output = [''];
var indent_stack = [];
- indented(action) { // TODO: revert to indented(action()) {
+ // TODO: revert to indented(action()) {
+ indented(action) {
indent_stack.add(indent_str);
action();
indent_stack.removeLast();
@@ -48,8 +47,7 @@ render(idl_node, [indent_str=' ']) {
if (node == null) {
return;
} else if (node is String) {
- if (output.last.endsWith('\n'))
- output.addAll(indent_stack);
+ if (output.last.endsWith('\n')) output.addAll(indent_stack);
output.add(node);
} else if (node is List) {
var separator = null;
@@ -66,32 +64,33 @@ render(idl_node, [indent_str=' ']) {
w(node.extAttrs);
wln('module ${node.id} {');
indented(() {
- w(node.interfaces);
- w(node.typedefs);
- });
+ w(node.interfaces);
+ w(node.typedefs);
+ });
wln('};');
} else if (node is IDLInterface) {
w(node.annotations);
w(node.extAttrs);
w('interface ${node.id}');
indented(() {
- if (!node.parents.isEmpty) {
- wln(' :');
- w(node.parents, ',\n');
- }
- wln(' {');
- section(list, comment) {
- if (list != null && !list.isEmpty) {
- wln();
- wln(comment);
- w(sort(list));
- }
+ if (!node.parents.isEmpty) {
+ wln(' :');
+ w(node.parents, ',\n');
+ }
+ wln(' {');
+ section(list, comment) {
+ if (list != null && !list.isEmpty) {
+ wln();
+ wln(comment);
+ w(sort(list));
}
- section(node.constants, '/* Constants */');
- section(node.attributes, '/* Attributes */');
- section(node.operations, '/* Operations */');
- section(node.snippets, '/* Snippets */');
- });
+ }
+
+ section(node.constants, '/* Constants */');
+ section(node.attributes, '/* Attributes */');
+ section(node.operations, '/* Operations */');
+ section(node.snippets, '/* Snippets */');
+ });
wln('};');
} else if (node is IDLParentInterface) {
w(node.annotations);
@@ -116,7 +115,7 @@ render(idl_node, [indent_str=' ']) {
w(' ');
}
} else if (node is IDLExtAttrs) {
- if(!node.map.isEmpty) {
+ if (!node.map.isEmpty) {
w('[');
var sep = null;
for (var name in sorted(node.map.keys)) {
@@ -160,8 +159,7 @@ render(idl_node, [indent_str=' ']) {
} else if (node is IDLArgument) {
w(node.extAttrs);
w('in ');
- if (node.isOptional)
- w('optional ');
+ if (node.isOptional) w('optional ');
w('${node.type.id} ${node.id}');
} else if (node is IDLExtAttrFunctionValue) {
w(node.name);
« no previous file with comments | « tools/dom/docs/test/docs_test.dart ('k') | tools/dom/src/AttributeMap.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698