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 |