Giter Club home page Giter Club logo

robocorp / robotframework-lsp Goto Github PK

View Code? Open in Web Editor NEW
198.0 27.0 86.0 19.58 MB

Robocorp extensions for VS Code: Robocorp Code and RFW LSP

Home Page: https://robocorp.com/docs/developer-tools/visual-studio-code

License: Apache License 2.0

Python 72.09% Shell 0.01% RobotFramework 3.52% TypeScript 5.30% Batchfile 0.01% JavaScript 0.02% Java 5.53% Objective-C 0.01% HTML 13.35% CSS 0.07% C 0.11%
automation lsp python robocorp vscode vscode-extension

robotframework-lsp's Introduction

robotframework-lsp's People

Contributors

anton264 avatar avaissi avatar bhirsz avatar bollwyvl avatar custompointofview avatar dependabot[bot] avatar detachhead avatar fabioz avatar glmeece avatar joeygrajciar avatar johanmabille avatar jsmzr avatar kariharju avatar kotlinisland avatar mardukbp avatar mmokko avatar monicabarna avatar mstn avatar otemek avatar sahokas avatar snooz82 avatar viktor1230 avatar weltings avatar xylix avatar zoupers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robotframework-lsp's Issues

Add Keyword parsing (completion and goto) for Keywords in Settings

Hi Fabio,

Currently no Keyword completion and no Go To Definition is possible for Keywords in settings.
Behind Suite Setup or Template in settings Section and also behind [Setup] etc in test cases and keywords

*** Settings ***
Suite Setup    Log    This is SuiteSetup
Test Setup    Set Log Level    Trace
Test Template    This is the Test
Test Teardown    Log    now its over
Suite Teardown    Log To Console    This is the End

*** Test Cases ***
Test1    Hello
Test2    World
Test
    [Template]    None
    [Setup]    Log    this is different
    Log To Console    different test
    [Teardown]    Log    different End

*** Keywords ***
This is the Test
    [Arguments]    ${arg}
    Log To Console    ${arg}
    [Teardown]    Log    Not completed

Keywords with embedded Arguments and Gherkin syntax.

At the moment LSP analyses which keywords can be found.
This leads now to the issues that Keywords with embedded Arguments are errors. Also the prefixes given, when, then, and, but are not ignored and also leads to not finding elements.

See
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#embedding-arguments-into-keyword-name

and
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#embedding-arguments-into-keyword-names

Check that needed requisites are installed

We should check whether extension requisites are available:

  • python:
    • required (needed to run the extension).
    • check which versions should be supported.
    • if not found, ask for path to python executable (and auto-save in user settings).
      • do we want to offer to auto-install python and requisites if not available?
  • robotframework
    • optional (not all features need it).
    • offer to call pip install robotframework if not available.
    • offer to call pip install robotframework --upgrade if an older version is installed.
    • check that extension doesn't fail if it's not installed.

No handling of keywords with Library-Prefix

*** Settings ***
Library    String
Library    Collections

*** Test Cases ***
Test
    BuiltIn.Log    Logging
    String.Should Be Titlecase    Hello World
    ${list}=    BuiltIn.Create List    1    2
    Collections.Append To List    ${list}    3

This is valid syntax to ensure that the keywords have not duplicate names.
The Library name can be prefixed to the keyword.

LSP marks this as unknown keyword even if they are imported and known.
Also no completion or goto definition works.

handling-keywords-with-same-names

image

Adding Arguments to Keyword Documentation

it would be nice to have the arguments of a keyword at the beginning of the documentation.

Example the BuiltIn Keyword Log

Just take these:

<arguments>
  <arg>message</arg>
  <arg>level=INFO</arg>
  <arg>html=False</arg>
  <arg>console=False</arg>
  <arg>repr=False</arg>
  <arg>formatter=str</arg>
</arguments>

and show them as code in the first line seperated by a comma.

message, level=INFO, html=False, console=False, repr=False, formatter=str

Similar to this "old" VSCode Plugin, but not with this ${syntax}...

image

No parsing of *.resource files

Hi @fabioz ,

I tested the Version 0.0.5 and saw, that only .robot files are highlighted and parsed.
robot has by default support for *.robot files for test cases and *.resource files for keywords and variables. basically they are the same syntax. only resource files are not parsed and analyzed for test cases, when robot starts.

Regards
René

Investigate robot api usage

Check robot imports in robotframework-lsp and check if there's a corresponding robot.api import we could use (and if not, check if it's possible to do it).

Syntax Highlighting

image

The Library names and keywords implementation could differ on colors from the statements.

Add `args` placeholder to Robot launch configuration file

When adding a new Robot launch configuration, the following entry is created in the configurations section:

{
    "type": "robotframework-lsp",
    "name": "Robot: Current File",
    "request": "launch",
    "cwd": "${workspaceFolder}",
    "target": "${file}",
    "terminal": "none",
    "env": {}
}

Would it be possible to add "args": []" in the configuration entry to make it more clear that it is possible to pass arguments for the launch? With this change, the entry might look like this:

{
    "type": "robotframework-lsp",
    "name": "Robot: Current File",
    "request": "launch",
    "cwd": "${workspaceFolder}",
    "target": "${file}",
    "terminal": "none",
    "env": {},
    "args": []
}

Tab Completion not working on VSCode

Tab completion is not working on VSCode, even with the setting "editor.tabCompletion": "on"

The suggestion shows up normally, but I need to press RETURN to auto complete not TAB, as usual.

Launch a separate process to load robotframework

The benefits here are:

  • The extension can use a python version independent from the robotframework version (so, we don't need to support older versions of Python).
  • Operations taking time on robotframework don't halt the extension.

Code Completion for path based library imports

Hi Fabio,

When you load a python library that is not installed via pip with the relative or absolute path into a robot file, is is not used in completion.

Assume:

Folder
  Test.robot
  MyLib.py
*** Settings ***
Library    MyLib.py     # relative to current file
Library    /home/temp/MyLib2.py    # absolute path C:/temp/MyLib.py should work as well.

When using abs path, lsp creates a MyLib.libspec in the same folder, but no completion happens.

Doubled Keywords in completion list

Tested with Version 0.0.6
Prio: low

Hi Fabio,

another small issue:
When using a Resource file in settings, the keywords from BuiltIn Library (that is forcefully imported by default) are doubled in completion list.
Example:

*** Settings ***
Resource    keywords.resource

*** Test Cases ***
My Test
    Should Be Equal

The Keyword Should be Equal is 2 times in the list.

The same happens if a library is imported twice.
Example:
The keywords.resource have a Library imported and the the test.robot has the same Library imported and the keywords.resource also.
Then all Keywords from this Library are two time in this list.

It is a real minor bug! because you shouldn't import stuff twice.

Cheers
René

Variables autocomplete only works when they are inside quotes

The autocomplete for variable names only work if we pass the argument in-between "" as shown below:

image

When you type the variable without quotes it doesn't suggest anything.

Also, I'd like to suggest a smarter autocomplete for variables, that search for the variables names that we declared and when it comes do dicts, suggest only the keys of that specific dict and so on.

Today's autocomplete for variables when it works, seems to be more like getting all the words typed in the file that matches my current typing.

Exceptions when using Code Completion

Hi @fabioz

I tested v 0.0.5

depending of the library loaded (if it is small enough) i was able to get a few completions.
But after two or three keywords i got nothing more. just "Loading ..."

Sometime i started with an empty file and BOOM!

The error is the following:

Traceback (most recent call last):
  File "/Users/rener/.vscode-oss/extensions/robocorptech.robotframework-lsp-0.0.5/src/robotframework_ls/jsonrpc/streams.py", line 56, in listen
    message_consumer(json.loads(request_str.decode("utf-8")))
  File "/Users/rener/.pyenv/versions/3.8.0/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Users/rener/.pyenv/versions/3.8.0/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/rener/.pyenv/versions/3.8.0/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 colum/Users/rener/robotframework_ls.2568.logn 65389 (char 65388)
2020-04-01 23:12:54,708 UTC pid: 2568 - Thread-18 - DEBUG - robotframework_ls.jsonrpc.streams
Writing: {'jsonrpc': '2.0', 'id': 29, 'method': 'lint', 'params': {'doc_uri': 'file:///Source/lsp-test/test.robot'}}

The Length of the jsonrpc seems to have something to do with the error.
64389 is pretty close to 64k (65536)
Sometimes the length is a bit longer like 65444 sometime a bit shorter...
But it is always around 64k
the max size of a TCP package is also 65536 Bytes. minus header and so on...

This happens on a mac.

Cheers
robotframework_ls.2568.log

Distribute without relying on installed python?

In the future we could use pyoxidizer or pyinstaller to start-up the extension without any dependency.

Right now we depend on the user to configure the path to the python executable to use and we use that python executable to start the extension.

This isn't ideal as the extension itself has to support and run in that environment (so, for instance, we need to support Python 2.7).

So, the option here would be creating an executable per OS that we'd like to support (using pyoxidizer or pyinstaller) which would start up the python process for us and would call our initial code and then we could put the remainder of the code in a .zip shared for all the platforms.

The downside is that the distribution would be a bigger download, but we wouldn't need to rely on anything else and it would be possible to support only the latest version of Python.

Support for Library Import with 'WITH NAME' syntax

It is necessary to Import a Library 'WITH NAME' Syntax.
e.g. Need two different instances for same library

Library      DataReader      WITH NAME      Rreader1
Library      DataReader       WITH NAME      Rreader2

*** Keywords***
Sample Keyword
   Rreader1.read     File1
   Rreader2.read     File2

Presently it is not supported
image

OUTPUT window constantly displays "[ ERROR ] option -u not recognized"

Detailed description of the bug or suggestion

While I am typing and making changes to my .robot file. I am repeatedly seeing "[ ERROR ] option -u not recognized" in the OUTPUT window. I have this installed on MacOS Mojave (10.14.6), Python Version is 3.7.5, and Robot Framework version is Robot Framework 3.2rc1.

Extension logs (attach as a file)

robotframework_ls.log

Minimal example (if possible)

Here is a screenshot of the problem.

image

I'm also seeing additional errors when I try the code formatting shortcut (on Mac Shift + Option + F). Here is a screenshot.
image

Code completion of keywords are shown as classes not as methods

Hi @fabioz

at the moment the keywords are shown with a "class"-symbol in VSCode and also in PyCharm.
i would expect that it is shown as method/function.

Maybe we should discuss this typing with Pekka.

some ideas:

Keywords -> functions or methods (we could make a difference between "User-Keywords" from Resources and "Library-Keywords" from python/Java Libraries.
I think libraries (python/java) could be methods because they are often related to classes/objects. And User Keywords could be functions, because they are definitely not part of a class.

Variables -> Variables

[Return] -> is a language command like break, return or raise

*** Settings *** -> could maybe completed as "class" even if it is not a class...

@pekkaklarck what do you think?

regards
René

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.