Skip to content

Instantly share code, notes, and snippets.

@palkan
Created November 15, 2022 02:25
Show Gist options
  • Save palkan/e0eb0a4c29b148a992e4e9b0a5f39a7d to your computer and use it in GitHub Desktop.
Save palkan/e0eb0a4c29b148a992e4e9b0a5f39a7d to your computer and use it in GitHub Desktop.
Syntax Tree doubles query
# Usage:
# gem install syntax_tree
# stree double_query.txt spec/**/*.rb
#
CallNode[
receiver: NilClass,
message: Ident[value: "double" | "instance_double"],
arguments: ArgParen[
arguments: Args[
parts: [StringLiteral | VarRef[value: Const], BareAssocHash]
]
]
] |
Command[
message: Ident[value: "double" | "instance_double"],
arguments: Args[
parts: [StringLiteral | VarRef[value: Const], BareAssocHash]
]
] |
CommandCall[
receiver: CallNode[
receiver: NilClass,
message: Ident[value: "allow" | "expect"],
arguments: ArgParen
],
operator: Period,
message: Ident[value: "to"],
arguments: Args[
parts: [
CallNode[
receiver: NilClass,
message: Ident[value: "receive"],
arguments: ArgParen[
arguments: Args[
parts: [
SymbolLiteral
]
]
]
] |
CallNode[
receiver: CallNode[
receiver: NilClass,
message: Ident[value: "receive"],
arguments: ArgParen[
arguments: Args[
parts: [
SymbolLiteral
]
]
]
],
operator: Period,
message: SyntaxTree::Ident[value: "with" | "and_return"]
] |
CallNode[
receiver: CallNode[
receiver: CallNode[
receiver: NilClass,
message: Ident[value: "receive"],
arguments: ArgParen[
arguments: Args[
parts: [
SymbolLiteral
]
]
]
],
operator: Period,
message: SyntaxTree::Ident[value: "with" | "and_return"]
],
operator: Period,
message: SyntaxTree::Ident[value: "with" | "and_return"]
] |
MethodAddBlock[
call: CallNode[
receiver: NilClass,
message: Ident[value: "receive"],
arguments: ArgParen[
arguments: Args[
parts: [
SymbolLiteral
]
]
]
],
block: BlockNode
]
]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment