Skip to content

Commit

Permalink
simplify the extension plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-nhg committed Sep 26, 2023
1 parent 36b0e8e commit 6057a6b
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 292 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ build/Release
# Dependency directories
node_modules/
lib/
out/
jspm_packages/

# TypeScript v1 declaration files
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

# vscode-RosTooling

We introduce a text and graphical IDE based on [VSCode](https://code.visualstudio.com/api) (desktop) and [Theia](https://theia-ide.org/) (web), with the kinematic model descibed in https://github.com/ipa320/ros-model as the base. This IDE allows creating kinematic models from scratch and composing those models.

The text-based editor provides typical IDE features like code completion and navigation to declaration of a symbol. The graphical editor allows editing and visualizing the model as a TF tree. A live visualization of the models can be previewed in a side panel while editing in both tools.
This repository contains the implementation of the [VSCode](https://code.visualstudio.com/api) extension to suport the [RosTooling](https://github.com/ipa320/ros-model) DSLs. Thansk to the extension, a textual editor include features like autocomplete, grammar checker and code generation.

Technical Maintainer: [**ipa-nhg**](https://github.com/ipa-nhg/) (**Nadia Hammoudeh Garcia**, **Fraunhofer IPA**) - **[email protected]**

## Usage from user perspective
Start the server:
```
cd vscode-RosTooling/resources
java -jar de.fraunhofer.ipa.ros.xtext.ide-3.0.0-SNAPSHOT-ls.jar -port 5008 -host 0.0.0.0
```
Start VS code:
```
$ git clone [email protected]:ipa320/vscode-RosTooling.git
$ cd vscode-RosTooling
Expand All @@ -29,12 +33,15 @@ source ~/.nvm/nvm.sh
nvm install 12
```

#### Start the language server
#### Generate the jar files
```
cd vscode-RosTooling/resources
java -jar de.fraunhofer.ipa.ros.xtext.ide-3.0.0-SNAPSHOT-ls.jar -port 5008 -host 0.0.0.0
git clone [email protected]:ipa320/ros-model
cd ros-model/plugins/de.fraunhofer.ipa.ros.xtext.ide
mvn clean install
```

The .jar file will be generated under the folder `ros-model/plugins/de.fraunhofer.ipa.ros.xtext.ide/target`.

## Compile the plugin
```
cd vscode-RosTooling
Expand Down
36 changes: 13 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "ros",
"displayName": "ros",
"description": "ros language support",
"name": "ros1",
"displayName": "ros1",
"description": "ros1 language support",
"version": "0.0.0",
"publisher": "ipa-nhg",
"repository": {
"type": "git",
"url": "https://github.com/ipa-nhg/vscode-rostooling"
"url": "https://github.com/ipa-nhg/vscode-ros1tooling"
},
"engines": {
"vscode": "^1.49.0"
Expand All @@ -15,35 +15,27 @@
"Programming Languages"
],
"activationEvents": [
"onLanguage:ros"
"onLanguage:ros1"
],
"main": "lib/extension.js",
"main": "out/extension",
"contributes": {
"languages": [
{
"id": "ros",
"id": "ros1",
"aliases": [
"ros"
"ros1"
],
"extensions": [
".ros"
".ros1"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "ros",
"scopeName": "source.ros",
"path": "./syntaxes/ros.tmLanguage.json"
}
],
"commands": [
{
"command": "ros.openPreview",
"title": "Open ros components preview window",
"category": "Ros",
"when": "editorLangId == ros"
"language": "ros1",
"scopeName": "source.ros1",
"path": "./syntaxes/ros1.tmLanguage.json"
}
]
},
Expand All @@ -53,7 +45,7 @@
"watch": "tsc -w -p .",
"update-vscode": "node ./node_modules/vscode/bin/install",
"build-viewer": "webpack --mode=production --config ./src/urdf/webpack.config.js",
"antlr4ts": "antlr4ts -visitor src/parser/DebugInternalroscomponents.g",
"antlr4ts": "antlr4ts -visitor src/parser/DebugInternalros1components.g",
"build": "tsc -p ."
},
"devDependencies": {
Expand All @@ -64,13 +56,11 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@types/roslib": "^1.1.8",
"@types/three": "^0.137.0",
"antlr4ts": "^0.5.0-alpha.4",
"assert": "^2.0.0",
"grunt-cli": "^1.4.3",
"resolve-cwd": "^3.0.0",
"roslib": "latest",
"three": "latest",
"util": "^0.12.4",
"vscode-languageclient": "^7.0.0",
Expand Down
24 changes: 14 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import * as net from 'net';

//import {Trace} from 'vscode-jsonrpc';
import { window, workspace, commands, ExtensionContext, Uri } from 'vscode';
//import { window, workspace, commands, ExtensionContext, Uri } from 'vscode';
import { workspace, ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, StreamInfo } from 'vscode-languageclient/node';

let lc: LanguageClient;

export function activate(context: ExtensionContext) {
// The server is a started as a separate app and listens on port 5007
let connectionInfo = {
port: 5008,
host: "0.0.0.0"
host: "localhost",
port: 5008
};
let serverOptions = () => {
// Connect to language server via socket
Expand All @@ -25,7 +26,7 @@ export function activate(context: ExtensionContext) {
};

let clientOptions: LanguageClientOptions = {
documentSelector: ['ros'],
documentSelector: ['ros1'],
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/*.*')
}
Expand All @@ -34,22 +35,25 @@ export function activate(context: ExtensionContext) {
// Create the language client and start the client.
lc = new LanguageClient('Xtext Server', serverOptions, clientOptions);

var disposable2 =commands.registerCommand("ros.a.proxy", async () => {
var disposable = lc.start();
/**
var disposable2 =commands.registerCommand("ros1.a.proxy", async () => {
let activeEditor = window.activeTextEditor;
if (!activeEditor || !activeEditor.document || activeEditor.document.languageId !== 'ros') {
if (!activeEditor || !activeEditor.document || activeEditor.document.languageId !== 'ros1') {
return;
}
if (activeEditor.document.uri instanceof Uri) {
commands.executeCommand("ros.a", activeEditor.document.uri.toString());
commands.executeCommand("ros1.a", activeEditor.document.uri.toString());
}
})
})*/

context.subscriptions.push(disposable2);
//context.subscriptions.push(disposable2);
context.subscriptions.push(disposable);

// enable tracing (.Off, .Messages, Verbose)
//lc.setTrace(Trace.Verbose);
lc.start();
//lc.start();
}
export function deactivate() {
return lc.stop();
Expand Down
81 changes: 32 additions & 49 deletions syntaxes/ros.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,37 @@
{
"name": "rosDSL",
"scopeName": "source.ros",
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "ros1DSL",
"scopeName": "source.ros1",
"fileTypes": [
"ros"
"ros1"
],
"patterns": [
{
"include": "#comments"
},
{
"name": "storage.type.ros",
"match": "\\b(PackageSet|Package|Artifact|CatkinPackage|AmentPackage|Package|FromGitRepo|Node|Publisher|Subscriber|ServiceClient|ServiceServer|ActionClient|ActionServer|Publishers|Subscribers|ServiceClients|ServiceServers|ActionClients|ActionServers|TopicSpec|ServiceSpec|Parameter|Parameters|Specs)\\b"
},
{
"name": "string.quoted.double.ros",
"begin": "\"",
"end": "\""
}

],
"repository":
{
"comments": {
"patterns": [
{
"name": "comment.block.states",
"begin": "/\\*",
"beginCaptures": {
"0": {
"name": "punctuation.definition.comment.states"
}
},
"end": "\\*/",
"endCaptures": {
"0": {
"name": "punctuation.definition.comment.states"
}
}
}, {
"begin": "(^\\s+)?(?=//)",
"beginCaptures": {
"1": {
"name": "punctuation.whitespace.comment.leading.cs"
}
},
"end": "(?=$)",
"name":"comment.line.states"
}
]
}
}
"patterns": [
{
"include": "#keywords"
},
{
"include": "#strings"
}
],
"repository": {
"keywords": {
"patterns": [{
"name": "keyword.control.ros1",
"match": "\\b(msgs|message)\\b"
}]
},
"strings": {
"name": "string.quoted.double.ros1",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.ros1",
"match": "\\\\."
}
]
}
},
"scopeName": "source.ros1"
}

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"es6",
"dom"
],
"sourceMap": true,
"sourceMap": false,
"rootDir": "src",
"outDir": "lib",
"outDir": "out",
"skipLibCheck": true,
"checkJs": false
},
Expand Down
Loading

0 comments on commit 6057a6b

Please sign in to comment.