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

Unified Diff: pkg/analysis_server/tool/spec/codegen_matchers.dart

Issue 479043002: Code generate Dart classes representing the analysis server API. (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 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 07a1b68961f2e2376fb4bba3acebdc5f5a3eede2..9795510797b3bfe6fb6d0ac03531f3ed08d187e1 100644
--- a/pkg/analysis_server/tool/spec/codegen_matchers.dart
+++ b/pkg/analysis_server/tool/spec/codegen_matchers.dart
@@ -12,6 +12,7 @@ import 'dart:convert';
import 'api.dart';
import 'codegen_tools.dart';
import 'from_html.dart';
+import 'implied_types.dart';
import 'to_html.dart';
class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
@@ -35,27 +36,21 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
* clarified by [nameSuffix]. The matcher should verify that its input
* matches the given [type].
*/
- void makeMatcher(String name, String nameSuffix, TypeDecl type) {
- context = name;
- List<String> nameParts = ['is'];
- nameParts.addAll(name.split('.'));
- if (nameSuffix != null) {
- context += ' $nameSuffix';
- nameParts.add(nameSuffix);
- }
+ void makeMatcher(ImpliedType impliedType) {
+ context = impliedType.humanReadableName;
docComment(toHtmlVisitor.collectHtml(() {
toHtmlVisitor.p(() {
toHtmlVisitor.write(context);
});
- if (type != null) {
- toHtmlVisitor.showType(null, type);
+ if (impliedType.type != null) {
+ toHtmlVisitor.showType(null, impliedType.type);
}
}));
- write('final Matcher ${camelJoin(nameParts)} = ');
- if (type == null) {
+ write('final Matcher ${camelJoin(['is', impliedType.camelName])} = ');
+ if (impliedType.type == null) {
write('isNull');
} else {
- visitTypeDecl(type);
+ visitTypeDecl(impliedType.type);
}
writeln(';');
writeln();
@@ -75,30 +70,9 @@ class CodegenMatchersVisitor extends HierarchicalApiVisitor with CodeGenerator {
writeln("import 'integration_tests.dart';");
writeln();
writeln();
- super.visitApi();
- }
-
- @override
- visitNotification(Notification notification) {
- makeMatcher(notification.longEvent, 'params', notification.params);
- }
-
- @override
- visitRequest(Request request) {
- makeMatcher(request.longMethod, 'params', request.params);
- makeMatcher(request.longMethod, 'result', request.result);
- }
-
- @override
- visitRefactoring(Refactoring refactoring) {
- String camelKind = camelJoin(refactoring.kind.toLowerCase().split('_'));
- makeMatcher(camelKind, 'feedback', refactoring.feedback);
- makeMatcher(camelKind, 'options', refactoring.options);
- }
-
- @override
- visitTypeDefinition(TypeDefinition typeDefinition) {
- makeMatcher(typeDefinition.name, null, typeDefinition.type);
+ for (ImpliedType impliedType in computeImpliedTypes(api).values) {
+ makeMatcher(impliedType);
+ }
}
@override

Powered by Google App Engine
This is Rietveld 408576698