autocomplete-robot-framework

Robot Framework autocomplete for Atom

gliviu

34,241

3

Bug Reports

3.10.0

MIT

GitHub

This package provides the following services:

autocomplete-robot-framework

An autocomplete-plus provider for Robot Framework.

Demo

Install

apm install language-robot-framework
apm install autocomplete-robot-framework

Usage

Opening a robot file will scan the parent project for keywords that will later be available as suggestions.

Works only for files that are included in an Atom project. Opening an independent robot resource won't provide any suggestions. Space separated .robot and .txt files are supported.

Suggestions

Keywords may be suggested by partial keyword name separated or not by spaces, or even acronyms.

run if             # suggests 'Run Keyword If'
sheq               # suggests 'Should Be Equal'
cfl                # acronyms also work and suggest 'Continue For Loop', ...

Sugestions are not limited to keywords. Library or resource names are suggested by prefixing their name.

Library    OperatingSystem
Library    robot.libraries.DateTime
Resource   path/MyKeywords.robot

oper               # Suggests OperatingSystem
date               # Suggests robot.libraries.DateTime
robot              # Also suggests robot.libraries.DateTime
my                 # Suggest MyKeywords

Note that library names are suggested as long as they are successfully imported. See below.

Using 'WITH NAME' on a library is not taken in consideration at this time.

Scopes

By default suggestions are limited to imported libraries and resources. Scope modifiers allow us to override the default scope and search for keywords beyond current imports.

Collections.       # Suggests all keywords from Collections
Collections.copy   # As above but limits suggestions
MyKeywords.        # Same rules apply for resources as well
this.              # Show only local keywords
.append            # Search 'append' through all indexed keywords

Library import

Python libraries have to be scanned for keywords just as regular robot files are. For this mechanism to work following requirements should be met.

Be sure to have PYTHONPATH, JYTHONPATH, CLASSPATH and IRONPYTHONPATH environment properly defined.

At this time libraries with mandatory parameters in constructor are not supported.
Libraries identified by path do not work - 'Library path/PythonLibrary.py'
Take a look at Status panel below for troubleshooting wrong imports and python environment problems .

Fallback libraries

Official Robot Framework libraries are included for convenience, just in case library import mechanism is not working for some reasons. This could be the case for example if using the RF Jar distribution without any python interpreter available.

Fallback libraries are libdoc xml files generated with libdoc tool. Any such .xml file encountered in Atom project will be parsed for keywords together with the other .robot files.

To create a fallback library of your own use libdoc tool and copy the result somewhere in robot project so it can be scanned. Note that name of the file must be the fully qualified library name. If you use the import below

*** Settings ***
Library    my.utilities.Arrays

it would need a libdoc named my.utilities.Arrays.xml.

Status

Status pane shows imported libraries and python environment information together with any error occurred during import process.

It can be activated from Packages->Robot Framework->Show autocomplete status.

Troubleshooting

API

An API is available to enable cooperation with other packages by providing access to underlying keyword repository.

Resource

  {
    resourceKey: 'unique resource identifier',
    path: 'resource path',
    name : 'resource name',
    libraryPath : 'python library source path if available',
    hasTestCases: true/false,
    hasKeywords: true/false,
    isLibrary : true/false,
    imports : {
      libraries : [{name : '', alias : ''}],
      resources : [{
	      name : '',
	      extension : '',
	      resourceKey: '' // available if import is resolved
	      }]
    },
    keywords: [keyword1, ...]
  }

Keyword

  {
    name: 'keyword name',
    documentation : 'documentation',
    arguments : ['arg1', ...],
    startRowNo : 0,
    startColNo : 0,
    resourceKey : 'parent resource key'
  }

Testing

apm test python/robot framework must be installed and operational. 'python' command must be available in PATH.

Links

Changelog