GeezerVison is showing github.com — Search History and OR statement · Issue #3 · codeque-co/codeque
Search History and OR statement #3DescriptionI have a function of whose calls scattered over the codebase. It takes 2 arguments: type of action, and second argument that may differ in type
I want to query this function calls, to see what second argument is with each call.
Initially i think that this query can work, but it didn't
myFunction('some_type'|'some_other_type'|'some_very_other_type'
Reading through the docs after, it seems that's theres just AST parsing, so question is: how can i construct OR queries?
And other feature request, it would be awesome to save some queries to inspect/use them later. Like today I spent some time on research of possible refactoring ways, and on other day I want to comeback to my queries to inspect them more.
Overall this extension already provides so much better DX when searching through large codebase, thank you very much for this! Activityjayu commented on Dec 18, 2022 Hey! Thank you so much for the feedback!
Query
I'm not sure If I get you correctly.
My understanding is that you want to find all calls of that specific function that contains 2 arguments.
If so, you can use this query and make sure to choose include mode
If that does not work, can you share some actual code examples?
Search history
I got this feature on my todo list, I'm glad you are asking for it!
I plan to wait a little bit to see which features are in higher demand, but history will be implemented for sure sooner or later! mouettxy commented on Dec 18, 2022 Sadly I tried this type of query, but there's catch, there's examples that I want to match
functionName('string', someVar)
functionName('string')
So when calling functionName($$$, $$$) there's no match for specific 'string', nor the calls with one argument only
Another example with what I query and what result's I expect recieve:
// Query
functionName('add_element'|'delete_element'|'move_element'|'save_element')
// Results
functionName('add_element', data)
functionName('add_element')
functionName('delete_element')
// ... and so on
Obviously query example is pseudo-code with strings and or operator :)
That's awesome to know history will be available, big thanks for your work! jayu commented on Dec 19, 2022 Ah now got what you mean!
I got plans to boolean logic into queries, OR, AND and Not
OR is quite simple to implement, effectively I can allow for adding subsequent queries, and execute all of theme at once.
It's a bit of duplication, but it should be usable.
So you would have to define several queries
// Query 1
functionName('add_element')
// Query 2
functionName('delete_element')
// .. and so on
AND and NOT will be more tricky 😁
Btw while your question is about generic OR operator, if that's the case all your actions have some common part, like _element, you can consider using this query with string wildcard
functionName('$$_element')
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|