Skip to content

Detect a pattern of two consequtive lines, anywhere. #11937

Answered by dvandersluis
amomchilov asked this question in Q&A
Discussion options

You must be logged in to vote

I briefly looked at your PR. You're looking for a begin node, which is going to capture the entire body of the method in your example. As you discussed in the PR, you would need use ... to make the matcher match when there is extra code (likely before and after the nodes you're looking for), but this will still be matching the entire begin node.

You can use capturing within your pattern to return the exact child nodes within the begin that you are concerned about, and pass those into your correction rather than the parent begin node.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dvandersluis
Comment options

@amomchilov
Comment options

@amomchilov
Comment options

@dvandersluis
Comment options

@amomchilov
Comment options

Answer selected by amomchilov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants