I'm trying to create a Notepad++ function list for Robot Framework scripts using the class structure to encapsulate the 4 different sections in a robot file:
- Settings
- Variables
- Test Cases
- Keywords
Using the documentation and some experimentation I created a simple filter that will return the keywords and test cases based on the fact that they start at the beginning of the line. But the more complex class grouping I need some regex help with. It seems that the *** should help with clear marking.
This is what I have thusfar:
I have installed the User Defined Robot Syntax Highlighting and have added the following section to the %app%\notepad++\functionList.xml
<association userDefinedLangName="Robotframework" id="robot_function"/>
And then in the parser section:
<parser
id="robot_function"
displayName="Robot Section"
commentExpr="((#.*?$)|(^Documentation*\w.*?$)|(^Meta*\w.*?$))|(^Library*\w.*?$)">
<function
mainExpr="^(\w.*?$)"
displayMode="$functionName">
<functionName>
<nameExpr expr="^(\w.*?$)"/>
</functionName>
</function>
</parser>
So, the part I'm having trouble with and I'd appreciate some help is:
<classRange mainExpr="^(\*).*(?=\n\S|\Z)">
<className>
<nameExpr expr="^(\w.*?$)"/>
</className>
<function mainExpr="^(\w.*?$)">
<functionName>
<nameExpr expr="^(\w.*?$)"/>
</functionName>
</function>
</classRange>
Below is an example robot file
*** Variables ***
${variable} variable value
*** Settings ***
Documentation multi
... line
... documentation.
Metadata Version 0.1
Library LibraryName some variable
Library String
*** Test Cases ***
Test Case RF 01
Run Keyword ${TEST_NAME}
Test Case RF 02
Run Keyword ${TEST_NAME}
*** Keywords ***
Test Case RF ${tc}
Sleep 30ms
Test Keyword
Sleep 300ms
I'm sure that if I can make it work for one of the sections, for example test cases, then that will allow me to also apply it to the other sections. Predominantly I'm interested in the test cases and keywords.