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

Unified Diff: pkg/analysis_server/tool/spec/codegen_matchers.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/tool/spec/codegen_matchers.dart
diff --git a/pkg/analysis_server/tool/spec/codegen_matchers.dart b/pkg/analysis_server/tool/spec/codegen_matchers.dart
index 02261da8389bae04730c92316bd16bae5c79c7cd..30a6e142f562b08665ec5d2aaf80cb37c8204469 100644
--- a/pkg/analysis_server/tool/spec/codegen_matchers.dart
+++ b/pkg/analysis_server/tool/spec/codegen_matchers.dart
@@ -15,6 +15,19 @@ import 'from_html.dart';
import 'implied_types.dart';
import 'to_html.dart';
+final GeneratedFile target =
+ new GeneratedFile('../../test/integration/protocol_matchers.dart', () {
+ CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi());
+ return visitor.collectCode(visitor.visitApi);
+});
+
+/**
+ * Translate spec_input.html into protocol_matchers.dart.
+ */
+main() {
+ target.generate();
+}
+
class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
/**
* Visitor used to produce doc comments.
@@ -56,6 +69,36 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
writeln();
}
+ /**
+ * Generate a map describing the given set of fields, for use as the
+ * 'requiredFields' or 'optionalFields' argument to the [MatchesJsonObject]
+ * constructor.
+ */
+ void outputObjectFields(Iterable<TypeObjectField> fields) {
+ if (fields.isEmpty) {
+ write('null');
+ return;
+ }
+ writeln('{');
+ indent(() {
+ bool commaNeeded = false;
+ for (TypeObjectField field in fields) {
+ if (commaNeeded) {
+ writeln(',');
+ }
+ write('${JSON.encode(field.name)}: ');
+ if (field.value != null) {
+ write('equals(${JSON.encode(field.value)})');
+ } else {
+ visitTypeDecl(field.type);
+ }
+ commaNeeded = true;
+ }
+ writeln();
+ });
+ write('}');
+ }
+
@override
visitApi() {
outputHeader();
@@ -113,11 +156,11 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
writeln('new LazyMatcher(() => new MatchesJsonObject(');
indent(() {
write('${JSON.encode(context)}, ');
- Iterable<TypeObjectField> requiredFields = typeObject.fields.where(
- (TypeObjectField field) => !field.optional);
+ Iterable<TypeObjectField> requiredFields =
+ typeObject.fields.where((TypeObjectField field) => !field.optional);
outputObjectFields(requiredFields);
- List<TypeObjectField> optionalFields = typeObject.fields.where(
- (TypeObjectField field) => field.optional).toList();
+ List<TypeObjectField> optionalFields =
+ typeObject.fields.where((TypeObjectField field) => field.optional).toList();
if (optionalFields.isNotEmpty) {
write(', optionalFields: ');
outputObjectFields(optionalFields);
@@ -126,36 +169,6 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
write('))');
}
- /**
- * Generate a map describing the given set of fields, for use as the
- * 'requiredFields' or 'optionalFields' argument to the [MatchesJsonObject]
- * constructor.
- */
- void outputObjectFields(Iterable<TypeObjectField> fields) {
- if (fields.isEmpty) {
- write('null');
- return;
- }
- writeln('{');
- indent(() {
- bool commaNeeded = false;
- for (TypeObjectField field in fields) {
- if (commaNeeded) {
- writeln(',');
- }
- write('${JSON.encode(field.name)}: ');
- if (field.value != null) {
- write('equals(${JSON.encode(field.value)})');
- } else {
- visitTypeDecl(field.type);
- }
- commaNeeded = true;
- }
- writeln();
- });
- write('}');
- }
-
@override
void visitTypeReference(TypeReference typeReference) {
String typeName = typeReference.typeName;
@@ -179,16 +192,3 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
write('])');
}
}
-
-final GeneratedFile target = new GeneratedFile(
- '../../test/integration/protocol_matchers.dart', () {
- CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi());
- return visitor.collectCode(visitor.visitApi);
-});
-
-/**
- * Translate spec_input.html into protocol_matchers.dart.
- */
-main() {
- target.generate();
-}
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_java_types.dart ('k') | pkg/analysis_server/tool/spec/codegen_tools.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698