From 4f8135071ae6faf7abfbc2f4765101ce9c0bb287 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 19 Dec 2024 16:30:17 +0000 Subject: Define methods directly on struct --- .../untyped/UntypedExtendInlineNodeMatcher.java | 54 ---------------------- .../compiler/ast/untyped/UntypedNodeMatchers.java | 4 -- .../UntypedStructDefinitionNodeMatcher.java | 6 +++ 3 files changed, 6 insertions(+), 58 deletions(-) delete mode 100644 src/test/java/org/shedlang/compiler/ast/untyped/UntypedExtendInlineNodeMatcher.java (limited to 'src/test/java/org/shedlang/compiler/ast') diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedExtendInlineNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedExtendInlineNodeMatcher.java deleted file mode 100644 index 1c82f937..00000000 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedExtendInlineNodeMatcher.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.shedlang.compiler.ast.untyped; - -import org.pcollections.PVector; -import org.shedlang.compiler.testing.MatcherBuilder; -import org.shedlang.compiler.util.P; -import org.zwobble.precisely.Matcher; - -import static org.zwobble.precisely.Matchers.has; - -public class UntypedExtendInlineNodeMatcher extends MatcherBuilder< - UntypedNamespaceStatementNode, - UntypedExtendInlineNode, - UntypedExtendInlineNodeMatcher -> { - public static UntypedExtendInlineNodeMatcher empty() { - return new UntypedExtendInlineNodeMatcher(P.vector()); - } - - public UntypedExtendInlineNodeMatcher(PVector> submatchers) { - super(submatchers); - } - - @Override - protected Class expectedType() { - return UntypedExtendInlineNode.class; - } - - @Override - protected UntypedExtendInlineNodeMatcher create( - PVector> submatchers - ) { - return new UntypedExtendInlineNodeMatcher(submatchers); - } - - public UntypedExtendInlineNodeMatcher withExtendedType( - Matcher extendedType - ) { - return with(has( - "extendedType", - x -> x.extendedType(), - extendedType - )); - } - - public UntypedExtendInlineNodeMatcher withMethods( - Matcher> methods - ) { - return with(has( - "methods", - x -> x.methods(), - methods - )); - } -} diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java index 6e98a788..e0597387 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java @@ -141,10 +141,6 @@ public class UntypedNodeMatchers { ); } - public static UntypedExtendInlineNodeMatcher isUntypedExtendInlineNode() { - return UntypedExtendInlineNodeMatcher.empty(); - } - public static Matcher isUntypedFieldAccessNode( Matcher receiver, String fieldName diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructDefinitionNodeMatcher.java index 0c1090b2..acdcff50 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructDefinitionNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedStructDefinitionNodeMatcher.java @@ -57,4 +57,10 @@ public class UntypedStructDefinitionNodeMatcher extends MatcherBuilder x.visibility(), equalTo(visibility))); } + + public UntypedStructDefinitionNodeMatcher withMethods( + Matcher> methods + ) { + return with(has("methods", x -> x.methods(), methods)); + } } -- cgit v1.2.3