Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Python Syntax Highlighting in Robot Framework Files #230

Open
3 of 4 tasks
gohierf opened this issue Mar 1, 2024 · 6 comments
Open
3 of 4 tasks

[ENHANCEMENT] Python Syntax Highlighting in Robot Framework Files #230

gohierf opened this issue Mar 1, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@gohierf
Copy link

gohierf commented Mar 1, 2024

Is your enhancement request related to a problem? Please describe.
The absence of syntax highlighting for Python statements in Robot Framework files hinders code readability and increases the likelihood of errors.

Describe the solution you'd like
Integrate syntax highlighting for Python statements in Robot files, using a distinctive color scheme to enhance visibility and comprehension.

  • Python Syntax Highlightning in ${{}} expressions
  • Python Syntax Highlightning in IF Statements
  • Python Syntax Highlightning in WHILE Statements
  • Python Syntax Highlightning in special keywords like Evaluate, Run Keyword If, etc.

Note
Partially related to #229

@gohierf gohierf added the enhancement New feature or request label Mar 1, 2024
@d-biehl d-biehl self-assigned this Mar 4, 2024
@d-biehl d-biehl added this to robotcode Mar 4, 2024
@github-project-automation github-project-automation bot moved this to To do in robotcode Mar 4, 2024
@d-biehl d-biehl moved this from To do to In progress in robotcode Mar 4, 2024
d-biehl added a commit that referenced this issue Mar 4, 2024
@gohierf
Copy link
Author

gohierf commented Mar 5, 2024

Python Syntax Highlightning in special keywords like Evaluate, Run Keyword If, etc.

It is implicitly mentioned in "etc." but it looks like most of the keyword ending by If can receive a python expression. As well as Should Be True and Should Not Be True.

But what about the keywords which are not in BuiltIn? Like for Browser library assertions, or even custom libraries. Could this be implemented?

Python Syntax Highlightning in IF Statements

No "etc." here, so I would like to add that WHILE is also evaluating python expression.

d-biehl added a commit that referenced this issue Mar 6, 2024
@d-biehl
Copy link
Member

d-biehl commented Mar 7, 2024

@gohierf and @touchedthecode published a new version with support for python syntax in IF and WHILE expressions. Can you please test it and give me a short feedback?

I have released a new version with support for Python syntax highlighting in IF and WHILE expressions. Can you please test it and give me some feedback?

I'm not sure how to do the highlighting for keywords yet, it might take a while.
Because I have to find out whether the keyword is really the keyword, these can also be nested arbitrarily, i.e. Run Keyword If $a==1 Should Be True $b==2 ELSE Should Be False $c==3 this has a significant performance impact on the highlighting.

As a workaround you can also use an inline python expression variable, something like this:

*** Test Cases ***
forth
    VAR  ${a_var}  1
    Should Be True     ${{ $a_var == '1' }}

@gohierf
Copy link
Author

gohierf commented Mar 7, 2024

Hei Daniel, nice work! It looks good on my side. I will keep an eye open on the topic, but so far no problem!

@gohierf
Copy link
Author

gohierf commented Mar 7, 2024

Well actually here is something:
image

In IF statements the $ has a different color than the variable name.

In ${{}} expressions the $ has the same color than the variable name.

It is somewhat disturbing and would be better if homogeneous.

@gohierf
Copy link
Author

gohierf commented Mar 7, 2024

Also, I see that you have fixed the ${{}} being red sometimes (and thanks for that too).

But it was nice when all five characters of ${{...}} had the same color, it was more obvious that it was the same "symbol", now it is a bit heavier to read...

Sorry to be picky, I hope it reads as constructive feedback.

@d-biehl
Copy link
Member

d-biehl commented Mar 10, 2024

I cannot really do this, because that's depending of VSCode editor.bracketPairColorization.enabled setting, wich is enabled by default, and also by the color theme you are use. one of the main problems is that VSCode's Bracket Pair Colorization algorithm does only work with single characters, if I define a bracket pair like ["${{", "}}"] then it works not correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants