Add search syntax to the editor's Output panel search filter#107223
Draft
FilipeAlexCosta wants to merge 1 commit intogodotengine:masterfrom
Draft
Add search syntax to the editor's Output panel search filter#107223FilipeAlexCosta wants to merge 1 commit intogodotengine:masterfrom
FilipeAlexCosta wants to merge 1 commit intogodotengine:masterfrom
Conversation
Currently the editor allows filtering log messages by whether or not
they contain a given substring.
This commit adds boolean operators (AND, OR, NOT) to this filter
through a Pratt parser (EditorLogSearchParser class) that builds an AST
(EditorLogSearchFilter class) which is then used to accept or reject
log messages.
The syntax is as follows:
expr: LITERAL (must contain LITERAL, ignoring case)
| QUOTED_LITERAL (must contain QUOTED_LITERAL)
| expr || expr (logical OR)
| '-' expr (logical NOT)
| '(' expr ')'
;
Logical ANDs are implicit (i.e. the parser injects an AND when it
expects an infix operator but reads the FIRST of an expression instead).
A literal may be quoted using either " or ', and it is possible to nest
quotation marks by escaping with \.
OR has the lowest precedence, followed by AND, with NOT having the
highest.
As an example, searching for 'Godot "Engine"' -foo || bar"baz" should
match all logs that either contain Godot "Engine" but not foo, or that
contain bar and baz.
Co-authored-by: Rafael Cruz <rafael.gueifao.cruz@tecnico.ulisboa.pt>
6ba4ed7 to
9931c65
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, you can only filter Godot's panel output logs by their category and whether or not they contain a given substring.
@rafaelgcruz and I implemented a filter that can do boolean operations (AND, OR and NOT) between search terms (this draft PR is a possible implementation of godotengine/godot-proposals#11244).
The syntax is similar to Google and GitHub, with a few differences. You can:
Consecutive spaces are ignored.
Note: < and > are there just to distinguish the PR message and what the user searched for/what the filter is trying to match.
Also, NOT has the highest precedence, followed by AND and lastly OR.
Here are some more examples of how the parser would parse some inputs:
Naturally, we're open to discussing and changing the syntax. We encourage everyone to try out the feature for themselves and give feedback on what to improve.
We also hope you can give us pointers on how to better adapt our design to match Godot's.
Finally, regarding the code itself, we essentially made two classes: EditorLogSearchFilter and EditorLogSearchParser (this one has a tokenizer class inside). As the names suggest, the latter parses the search text into an AST we then traverse it to accept/reject each message. The filter itself is just a thin refcounted wrapper over the root node of the AST. It essentially just has two tasks: own the entire tree and provide the empty filter functionality (i.e. accept everything if there are no nodes).
If you have any questions about the feature (i.e. something about the syntax we failed to explain, etc...), you're welcome to ask 😃
See also: