Skip to content

Commit

Permalink
Added defaultSnippets to json schema
Browse files Browse the repository at this point in the history
Also
- added markdownDescription statements to json schema
- modularized editorconfig settings, and added more files
- resolved markdownlint warnings

This change relates to #233

Signed-off-by: Siddharth Sharma <[email protected]>
  • Loading branch information
esmasth committed Mar 16, 2024
1 parent 60b30d2 commit 3e7d43e
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 150 deletions.
17 changes: 16 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[*.json]
[{*.json,yang.settings}]
indent_style = space
indent_size = 2

Expand All @@ -24,3 +24,18 @@ indent_size = 4

[gradlew.bat]
end_of_line = crlf

[*.yml]
indent_style = space
indent_size = 2

[*.gradle]
indent_style = tab
indent_size = 4

[gradlew]
indent_style = space
indent_size = 4

[gradlew.bat]
end_of_line = crlf
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Gradle Build",
"type": "shell",
"command": "cd yang-lsp && ./gradlew build",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Gradle Build Distribution",
"type": "shell",
"command": "cd yang-lsp && ./gradlew --no-daemon build copyDist",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": false
}
}
]
}
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# yang-lsp
[![GH Build Status](https://github.com/theia-ide/yang-lsp/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/theia-ide/yang-lsp/actions/workflows/main.yml)

[![GH Build Status](https://github.com/TypeFox/yang-lsp/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/TypeFox/yang-lsp/actions/workflows/main.yml)
[![Build status](https://ci.appveyor.com/api/projects/status/96eo9k5yo0wtpj50/branch/master?svg=true)](https://ci.appveyor.com/project/kittaakos/yang-lsp/branch/master)

A language server for YANG (see [Language Server Protocol](https://github.com/Microsoft/language-server-protocol)).
Expand All @@ -8,34 +9,34 @@ A language server for YANG (see [Language Server Protocol](https://github.com/Mi

The language server application is available in two distributions:

- `yang-language-server_<version>.zip` (plain language server)
- `yang-language-server_diagram-extension_<version>.zip` (language server with diagram extension for [sprotty](https://github.com/theia-ide/sprotty))
- `yang-language-server_<version>.zip` (plain language server)
- `yang-language-server_diagram-extension_<version>.zip` (language server with diagram extension for [sprotty](https://github.com/theia-ide/sprotty))

Both variants include start scripts to launch the background process. Connect its input/output streams to your host application in order to communicate with the language server.

The YANG Language Server is currently being used in
- [YANGSTER](https://github.com/theia-ide/yangster) based on [Theia](https://github.com/theia-ide/theia) (incl. diagram extension)
- [Yang VS Code](https://github.com/theia-ide/yang-vscode) available on the [VS Marketplace](https://marketplace.visualstudio.com/items?itemName=typefox.yang-vscode)
- [Yang Eclipse](https://github.com/theia-ide/yang-eclipse)

## Build

git clone https://github.com/theia-ide/yang-lsp.git \
&& cd yang-lsp/yang-lsp \
&& ./gradlew build
- [YANGSTER](https://github.com/theia-ide/yangster) based on [Theia](https://github.com/theia-ide/theia) (incl. diagram extension)
- [Yang VS Code](https://github.com/TypeFox/yang-vscode) available on the [VS Marketplace](https://marketplace.visualstudio.com/items?itemName=typefox.yang-vscode)
- [Yang Eclipse](https://github.com/theia-ide/yang-eclipse)

## Build

# Release Engineering
```shell
git clone https://github.com/TypeFox/yang-lsp.git
cd yang-lsp/yang-lsp
./gradlew build
```

The yang-lsp is the base of multiple binaries
## Release Engineering

The yang-lsp is the base of multiple binaries

| Repository | Client | Binary | Bin Repo | CI | Trigger |
| ---------- | ------ | ------ | -------- | --- | ---------- |
| [yang-lsp](https://github.com/theia-ide/yangs-lsp) | LSP | JAR + script | GH Action Artifacts | [GH Action](https://github.com/theia-ide/yang-lsp/actions/workflows/main.yml) | GH Commit / PR |
| [yangster](https://github.com/theia-ide/yangster) | Theia Browser | Docker image | Docker Hub | [Docker Hub](https://hub.docker.com/r/typefox/yangster/builds) | GitHub hook / Jenkins pipeline|
| | Theia | Theia extension| npm | [Jenkins](http://services.typefox.io/open-source/jenkins/job/yangster/) | `yarn run publish` |
| ---------- | ------ | ------ | -------- | --- | ------- |
| [yang-lsp](https://github.com/TypeFox/yangs-lsp) | LSP | JAR + script | GH Action Artifacts | [GH Action](https://github.com/TypeFox/yang-lsp/actions/workflows/main.yml) | GH Commit / PR |
| [yangster](https://github.com/theia-ide/yangster) | Theia Browser | Docker image | Docker Hub | [Docker Hub](https://hub.docker.com/r/typefox/yangster/builds) | GitHub hook / Jenkins pipeline|
| | Theia | Theia extension| npm | [Jenkins](http://services.typefox.io/open-source/jenkins/job/yangster/) | `yarn run publish` |
| [yangster-electron](https://github.com/theia-ide/yangster-electron) | Theia Electron | executables | ? | ? | ? |
| [yang-eclipse](https://github.com/theia-ide/yang-eclipse) | Eclipse | p2 update site | Eclipse Marketplace | [Jenkins](http://services.typefox.io/open-source/jenkins/job/yang-eclipse/) | GitHub hook / Jenkins pipeline |
| [yang-vscode](https://github.com/theia-ide/yang-vscode) | VSCode | VSCode extension | VSCode Marketplace | - | `vsce` |

| [yang-vscode](https://github.com/TypeFox/yang-vscode) | VSCode | VSCode extension | VSCode Marketplace | - | `vsce` |
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ build_script:
- ./yang-lsp/gradlew.bat -p yang-lsp build --refresh-dependencies --no-daemon

cache:
- C:\Users\appveyor\.gradle
- C:\Users\appveyor\.m2
- C:\Users\appveyor\.gradle
- C:\Users\appveyor\.m2
108 changes: 57 additions & 51 deletions docs/Extensions.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Extensions

The yang-lsp allows to have additional third party extensions, configured through the [`yang.settings` file](Settings.md).
That file must be located in the root of an opened directory must conform to JSON syntax.
The yang-lsp allows to have additional third party extensions, configured through `yang.settings`.
For details on file format and schema see [Settings.md](./Settings.md).

So far two different kinds of extensions are supported :
- Validators (`IValidatorExtension`)
- Commands (`ICommandExtension`)

- Validators (`IValidatorExtension`)
- Commands (`ICommandExtension`)

## Create a Validator

A validator extension is a Java class that implements the interface `io.typefox.yang.validation.IValidatorExtension`.
A validator extension is a Java class that implements the interface `io.typefox.yang.validation.IValidatorExtension`.
Here is a small example:

```java
Expand All @@ -19,72 +20,77 @@ package my.pack;

public class MyExampleValidator implements IValidatorExtension {

public static final String BAD_NAME = "bad_name";
public static final String BAD_NAME = "bad_name";

@Override
public void validate(AbstractModule module, IAcceptor<Issue> issueAcceptor, CancelIndicator cancelIndicator) {
if (module.getName().equals("foo")) {
issueAcceptor.accept(IssueFactory.createIssue(module, YangPackage.Literals.ABSTRACT_MODULE__NAME, "'foo' is a bad name", BAD_NAME));
}
}
@Override
public void validate(AbstractModule module, IAcceptor<Issue> issueAcceptor, CancelIndicator cancelIndicator) {
if (module.getName().equals("foo")) {
issue = IssueFactory.createIssue(module, YangPackage.Literals.ABSTRACT_MODULE__NAME,
"'foo' is a bad name", BAD_NAME)
issueAcceptor.accept();
}
}

}
```
```

## Create a Command Extension

A command extension contributes actions, that will be shown in the context menu of a supporting client (currently only Yangster supports it).
A command extension contributes actions, that will be shown in the context menu
of a supporting client (currently only Yangster supports it).

Here is an example:

```xtend
```java
class MyCommand implements ICommandExtension {

static val COMMAND = "Create a file name 'foo.txt'."
/**
* return a list of commands. A command string is used as ID internally and as a label in the UI.
*/
override getCommands() {
#[COMMAND]
}
/**
* Called when the user asked to execute a certain command.
*/
override executeCommand(String command, Resource resource, LanguageClient client) {
if (COMMAND == command) {
// get the project directory
val uri = ProjectConfigAdapter.findInEmfObject(resource.resourceSet)?.projectConfig?.path.toFileString
val f = new File(uri, 'foo.txt')
if (f.exists) {
client.showMessage(new MessageParams => [
message = 'Such a file already exists.'
])
} else {
f.createNewFile
}
}
}
static val COMMAND = "Create a file name 'foo.txt'."

/**
* return a list of commands. A command string is used as ID internally and as a label in the UI.
*/
override getCommands() {
#[COMMAND]
}

/**
* Called when the user asked to execute a certain command.
*/
override executeCommand(String command, Resource resource, LanguageClient client) {
if (COMMAND == command) {
// get the project directory
val uri = ProjectConfigAdapter.findInEmfObject(resource.resourceSet)?.projectConfig?.path.toFileString
val f = new File(uri, 'foo.txt')
if (f.exists) {
client.showMessage(new MessageParams => [
message = 'Such a file already exists.'
])
} else {
f.createNewFile
}
}
}

}
```


## Package an extension

The class needs to be packaged in a jar. So simply use the java build tool of your preference to create a jar from it. Put the jar somewhere relative to the project's root directory.
The class needs to be packaged in a jar. So simply use the java build tool of
your preference to create a jar from it. Put the jar somewhere relative to the
project's root directory.

## Add the plugin

Create (or open) the `yang.settings` file and add the plugin using the following configuration:
Create (or open) the `yang.settings` file and add the plugin using the following
configuration:

```json
"extension" : {
"classpath" : "extension.jar",
"validators" : "my.pack.MyExampleValidator",
"commands" : "my.pack.MyCommand"
}
"extension" : {
"classpath" : "extension.jar",
"validators" : "my.pack.MyExampleValidator",
"commands" : "my.pack.MyCommand"
}
```

The language server will automatically pick up the extension.

Loading

0 comments on commit 3e7d43e

Please sign in to comment.