I have a search template of `$Before$.$MethodCall$...
# intellij
s
I have a search template of
$Before$.$MethodCall$($Parameter$)
, problem is..it matches on
<http://log.info|log.info> { }
as well as
<http://log.info|log.info> ()
, how can i get it to not match on lambda? I set complete match but it still doesn't listen to me, i want it to take the parentheses as is
r
remember that's it is a structural search, and therefore it searches based on structure of the syntax tree. Eg, from AST view,
<http://log.info|log.info> { }
is same as
<http://log.info|log.info>({ })
- and
{ }
gets matched to your
$Parameter$
how to solve it hmmm... I guess only way is to limit what can get matched as parameter. Limiting its type should help you I guess?
s
@Roukanken so, that's the part that confuses me..if you look at the builtin kotlin ones, you get
{ $Parameter$ }
, this matches
<http://log.info|log.info> {}
only
but it seems like if you surround it with other stuff, maybe...it doesn't seem to work the same
if the AST thing you mention were true, it should have matched on my braces, in my original test case, as it does for the builtin example
r
remember that
func { }
is just a syntax sugar for
func( { } )
they have the exact same meaning which means ASTs look something like this: •
func { }
AST is: ◦ call a method (taken from whatever is
func
) and give it as parameters: ▪︎ lambda function •
func({ })
AST is same ↑ •
func { $parameter$ }
is: ◦ call a method (taken from whatever is
func
) and give it as parameters: ▪︎ lambda function • of which content is "return `$parameter$`"
s
yeah i get that part, but i'm saying that it is matching on
{}
which matches
log.debug {}
, and not
log.debug()
. so it definitely treats it differently
r
okay, I took out the big guns, and surprisingly there is a difference between 1st and 2nd This should be the tree JB is operating on
s
hm interesting. thank you. shall i raise a youtrack issue?
r
I'm reasonably sure this is an intended behaviour (as it would make more sense) but yeah, this basically stops you from matching what you want also fun is that
<http://log.info|log.info> { $x$ }
matches only the first one but
<http://log.info|log.info>({ $x$ })
matches both
s
haha right?
it's hilarious becuase it's matching everything i don't want. i just want to match parentheses 😂
@Roukanken btw how do you view the AST like that? also, nice color scheme
r
It's a plugin (PSI viewer I think?) mostly meant for coding plugins to manipulate code. It shows internal tree of code
s
okay, cool
r
(and theme is Palenight, from Material UI)
👍 1