I use Visual Studio Code with Robot Framework and Python for test purposes. I also use CANoe application as a simulator.
I installed the Robot Framework Language Server and for some reason when I open VSCode or even just click on it CANoe automatically opens, I know that the extension is causing this because if I disable the extension the application stops to automatically open.
Do you already had any similar behavior with Robot Framework Language Server and any other process? If yes, how did you solve it?
There are 2 different LSP implementations for robot framework. This answer relates mainly to the one Robocorp maintains.
That particular implementation of lsp works by executing each LIBRARY settings section in python interpreter and executing the actual library's constructor to get the data it needs for auto completion / typing / whatnot. If the python library makes any connection to com API thats associated with CANoe during execution of the constructor, it will trigger actual CANoe application to start - even if that's not mandatory at this point but that's how COM works.
I'm quite there are ways to hack around the issue but essentially, the easiest way to fix this is to;
Fix the library that provides your keywords that interact with CANoe and/or ecutest or similar that requires CANoe to be running.
Try switching to https://github.com/d-biehl/robotcode within vsc to provide you autocomplete and the rest ..
If you where using robotcode lsp, see first suggestion.
Related
I use AppleScript in my Mac for automating various processes in my computer. I know that Visual Studio Code does not have an AppleScript dictionary.
Is there any way to programmatically control Visual Studio Code eg using Python or any other programming language?
As an example I would like to programmatically get the path of the frontmost document.
I know that VSC has a JavaScript API . Can I use this for automation purposes?
I guess a lot of such automation / programmatic control can be done via the JavaScript extension API.
There is vscode.window.activeTextEditor, and that gives you document.fileName or document.uri for the filename, and selection.active to get you the cursor position (example).
It looks like this API allows for a lot of automation, e.g. moving cursor around, inserting text, etc.
There is vscode-ext (active fork) to write Python extensions. When you look at the code, you see that this provides a websockets bridge from JavaScript inside VSCode to Python in a separate process. This bridge could be use for controlling VSCode from some external process.
Further, I just learned about the Robot Framework / Robotic Process Automation (RPA) Framework (also with Python backend). I'm not sure but it might be helpful.
I did my best to overcome this problem but it was in vain. I am developing tests in Robot Framework (RF) in Visual Studio Code and I want it to either show "signatures" of keywords from standard libraries or to be able to go to their definitions. Go to definition and signature displaying when hovering with Ctrl key are behaving this way:
works for my keywords written in RF (hoorah!)
works for my keywords written in Python only if a keyword consists of one word (I think conversion between undescores and spaces is failing)
does not work for keywords from standard libraries even if the keyword is one-word (e.g. "Fail"), regardless whether the keyword comes from built-in libraries or other ones (e.g. SeleniumLibrary)
When failing, Robot Framework Intellisense Server gives me message "Keyword definition 'Blah Blah' not found from the workspace".
I am using plugins Robot Framework Intellisense FORK and/or Robot Framework Language Server. I tried to configure them carefully according their documentation (Details), but the best state I reached is described above.
Can you help me please? I do not need to use a specific plugin, I just need to have the signature or documentation (or implementation) of every keyword in my code to be one click far.
According to their documentation they support
Goto definition
For variables
For user keywords
I was able to partially solve this when I not only open the folder with source code, but create a workspace and add the folder containing standard libraries to it as well (Add Folder to Workspace). I do not know exactly which folder is the best to add, it seems ...\Python\Python37\Lib\site-packages\ to me.
I am totally new to creating extensions in VS Code, and all the official examples of extensions are written in Typescript/Javascript, which I have no experience with. Is it possible to create VS Code extensions in other languages, such as Python or C++?
If so, could anyone point me to any resources to get me started?
It is possible by creating a C++ module for Node.js, which can then be loaded like any other node module. Of course, some glue code written in JS or TS is necessary to register the extension and translate calls to/from vscode.
I've gone this way in my ANTLR4 extension, but gave up eventually, because of the troubles I had due to incompatible dependencies (you have to make sure the extension uses the exact same V8 version, which was used to build the underlying Node.js used by vscode, on all supported platforms).
This situation might have change, I don't know, but with that in the background I don't recommend it.
If you want to add support for a new language in vscode you can also write a separate language server, as is mentioned in the linked SO answer. For other type of work, I'm afraid, you have no alternative to use.
No, as #rioV8 said, since VSCode is an electron app and runs on Javascript.
Is it possible to interact with the CSharp syntax tree from my own VS code extension? I have an extension which I made in Visual Studio proper which uses the Roslyn Syntax Tree to do a variety of code editing and sorting tasks and I want to migrate it to VS Code.
My naive assumption is that if I can get access to the OmnisharpServer object by reaching into the Omnisharp VS Code Extension I might be able to pull the relevant information out of there. I can get access to the extension itself by calling:
let csextension = vscode.extensions.getExtension('ms-vscode.csharp')
But the extension itself doesn't expose much so I'm wondering if this is the correct methodology? If so, how do I get access to the running server from my own extension?
The only other strategy I have is to run a .net core exe which uses Roslyn to do the analysis, but this seems to be duplicating a problem which must be solved somewhere in the stack.
I don't think there's any way to do this without going through the Omnisharp VSCode Extension / its extension API (unless perhaps the server implements some custom interface). If an API doesn't already exist, you could consider creating a feature request on the issue tracker?
I'm searching for a method to expose VSCode active 'when Clause Contexts' e.g 'explorerResourceIsFolder'. To give you a better understanding of my use case, here's some background on the project to which a VSCode extension is being developed. My extension will facilitate programming in and controlling VSCode by voice.
Caster is a Dragonfly-Based Voice Programming Toolkit. Dragonfly is a speech recognition framework. It is a Python package which offers a high-level object model and allows its users to easily write scripts, macros, and programs which use speech recognition. The goal behind these projects is to enable those who limited interaction with keyboard or mouse to program or for Devs to boost productivity.
Some current outstanding limitations with Castor and Dragonfly both interact by emulating keystrokes. This is just to name a few issues.
Reliability of IDE of performance different system configurations and IDE versions. This introduces variables such as command execution latency.
Castor is completely unaware of the IDE environment.
Dragon NaturallySpeaking has an upper complexity limit on Grammars.
After the limit is reached, a BadGrammar error will occur.
Limited keyboard combinations and not all functions can be called by shortcuts.
Some examples via Adom editor
find in buffer": R(Key("c-f"), rdescript="Atom: Find in Buffer")
Only a few relevant commands are useful within 'Find in Buffer' context, but Castor commands are global which decreases command speech recognition accuracy and increases grammar complexity. With Caster IDE integration would allow for llimited command sets specified to IDE contexts or focuses.
"split into lines": R(Key("cs-p") + Text("Split Into Lines") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Into lines"),
Not all IDE functions can be called via shortcuts or be easily re-created within castor. My attempt to work around this within Adom was to utilize command palette. While this extended my ability to trigger commands it introduced latency. To fast the wrong command would be triggered. Too slow it a decrease productivity. Indexing latency which based on system load, system specs, number of active plug-ins, and number of characters per command. We tried to mitigate this by using Pause(atom_palette_wait) but the variables in the latency were too complex. The same would be true of Studio Code.
Castor framework IDE integration
Castor would contain IDE functions to pass to IDEs plug-ins/extensions for execution.
For example "Find ": find R(SendFunction("actions.find"), rdescript="VisualStudioCode: Find")
Castor would listen for contexts or focus announced from IDEs .
Castor would store commands and functions based on IDE context or focus. Then activate the only relevant commands containing shortcuts or IDEs functions based the focus announced from the IDE.
IDEs plug-ins/extensions framework
Listen for and execute IDEs specific functions from Caster
Announce current contexts or focus to Caster
As a long-term goal extend functionality of IDE ( e.g. in Visual Studio Code adding numbers to IntelliSense list) The user would speak the number and the appropriate line would be selected and executed.
There will be three parts to the Studio Code Extension.
A websocket running a server and client that allows for bidirectional communication to Castor.
A function that executes 'Command_id' e.g 'editor.debug.action.toggleBreakpoint' In progress - Near completion
A method to expose the editors 'when Clause Contexts' e.g 'explorerResourceIsFolder' - Searching for method - No luck via the APIs thus far - Searching source code to understand implementation.
Any suggestions would be welcome. If you think this is worth opening a github ticket on the VSCode repository let me know.
There is a non public api for getting the when context in effect. You can use getValue(key: string). It is available from the work on this issue ticket:
Lift setContext from a command to proper API Microsoft/vscode#10471
and the source can be viewed here:
contextKeyService.ts
by using getValue(key: string)
It is still work in progress as of May 2017. Thank you. Good day.