Robot Framework parsing for Notepad++ Function List

A. Kootstra Source

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:

  1. Settings
  2. Variables
  3. Test Cases
  4. 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:

  displayName="Robot Section" 
       <nameExpr expr="^(\w.*?$)"/>

So, the part I'm having trouble with and I'd appreciate some help is:

  <classRange mainExpr="^(\*).*(?=\n\S|\Z)">
        <nameExpr expr="^(\w.*?$)"/>
     <function mainExpr="^(\w.*?$)">
          <nameExpr expr="^(\w.*?$)"/>

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.



answered 7 months ago Sami H #1

With the settings below I am able to use Notepad++ Function List for Robot Framework keywords and test cases:

<association id="robot_syntax"      userDefinedLangName="Robotframework"   />
<association id="robot_syntax"      ext=".robot"                           />

            displayName="Robot Framework"
            id         ="robot_syntax"
            commentExpr="(^(\h*)|(#.*?)|(\[\w.*?)|(Documentation*\w.*?)|(Library*\w.*?)|(Metadata*\w.*?)|(Resource*\w.*?)|(Test (Setup|Teardown|Template|Timeout)*\w.*?)||(Suite (Setup|Teardown)*\w.*?)|((Force|Default) Tags*\w.*?))$"
            <function mainExpr="(?m-s:(?:^)[A-Za-z0-9].*$)"/>

comments powered by Disqus