Create vscode-boot extension

This will become the 'merged' vscode-boot-java + vscode-boot-propertues
extension.
This commit is contained in:
Kris De Volder
2018-02-13 11:12:13 -08:00
parent b3fa404a41
commit 6e678863e9
24 changed files with 1813 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
out
node_modules
target
*.log
*.log.*
classpath.txt
*.vsix
repo
.idea
*.iml
.DS_Store
**/.DS_Store
src/test/resources/test-projects/**/.classpath
src/test/resources/test-projects/**/.project
src/test/resources/test-projects/**/.factorypath
src/test/resources/test-projects/**/.settings/**
src/test/resources/test-projects/**/bin/**

View File

@@ -0,0 +1,31 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [
{
"type": "extensionHost",
"request": "launch",
"name": "Launch Extension",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/**/*.js"
],
"preLaunchTask": "npm"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out/test",
"preLaunchTask": "npm"
}
]
}

View File

@@ -0,0 +1,12 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": true, // set this to true to hide the "out" folder with the compiled JS files
"node_modules": false,
"target": true
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
}

View File

@@ -0,0 +1,30 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile"], //, "--loglevel", "silent"],
// The tsc compiler is started in watching mode
"isWatching": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}

View File

@@ -0,0 +1,30 @@
# IDE configs
.vscode/**
.idea/**
*.iml
javaconfig.json
classpath.txt
tsconfig.json
tsd.json
*.xml
# Logs
*.log*
# Sources
typings/**
src/**
test/**
lib/**
!lib/javaconfig.schema.json
repo/**
scripts/**
# Compiler output
out/test/**
target/**
!target/vscode-boot-properties-*.jar
# Extensions
.gitignore
**/*.map

View File

@@ -0,0 +1,60 @@
# Developer notes
## Bulding and Running
This project consists of three pieces:
- a vscode-extension which is a language-server client implemented in TypeScript.
- commons-vscode: a local npm module with some utilities implemented in TypeScript.
- a language server implemented in Java.
To build all these pieces you normally only need to run:
npm install
**However, the first time you build** it might fail trying to
find the `commons-vscode` module on npm central. Once we publish a stable
version of that module on npm central that will no longer be a problem.
Until that time, you can work around this by doing a one time manual
run of the `preinstall` script prior to running `npm install`:
./scripts/preinstall.sh
npm install
Now you can open the client-app in vscode. From the root of this project.
code .
To launch the language server in a vscode runtime, press F5.
## Debugging
### Method 1: attach remote debugger to Language Server
To debug the language server, open `lib/Main.ts` and edit to set the
`DEBUG` option to `true`. When you launch the app next by pressing
`F5` it will launch with debug options being passed to the server JVM.
You can then connect a 'Remote Java' debugger on port 8000.
### Method 2: Launch a 'standalone' Language Server
To debug the language server, open `lib/Main.ts` and edit to set the
`CONNECT_TO_LS` option to `true`. When you launch the app next by pressing
`F5`... When it needs a language server it not launch a process but instead
try to connect to an already running server on port `5007`. It is up to you
to ensure a server is running on that port by launching it beforehand
with a commandline arguments: `-Dstandalone-startup=true`.
## Packaging as a vscode extension
First make sure the stuff is all built locally:
./scripts/preinstall.sh # only needed if this is the first build.
npm install
Then package it:
npm run vsce-package
This produces a `.vsix` file which you can install directly into vscode.

View File

@@ -0,0 +1,58 @@
# VS Code Language Server for Spring Boot Application Properties
VSCode extension and Language Server providing support for working with Spring Boot
`application.properties` and `application.yml` files.
# Usage:
The extension will automatically activate when you edit files with the following
name patterns:
- `application*.properties` => activates support for Spring Boot properties in `.properties`format.
- `application*.yml` => activates support for Spring Boot properties in `.yml` format.
You can also define your own patterns and map them to the language-ids
`spring-boot-properties` or `spring-boot-properties-yaml` by defining `files.associations`
in workspace settings. See [vscode documentation](https://code.visualstudio.com/Docs/languages/overview#_adding-a-file-extension-to-a-language) for details.
# Functionality
This extension analyzes your project's classpath and parses and indexes any [Spring Boot
Properties Metadata](https://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.html) it finds. Both Maven and Gradle projects are supported.
The data in the index is used to provide validation, code completions and information
hovers while editing Spring Boot Properties in either `.properties` or `.yml` format.
## Validation
![application-yaml-validation][yaml-validation]
![application-properties-validation][properties-validation]
## Code Completions
![application-yaml-completions][yaml-completion]
![application-properties-completions][properties-completion]
## Information Hovers
![application-yaml-hovers][yaml-hovers]
## Issues and Feature Requests
Please report bugs, issues and feature requests on the [Github STS4 issue tracker](https://github.com/spring-projects/sts4/issues).
# Releases:
Released versions of this extension can be installed directly from the vscode marketplace.
There are also development snapshots available with the latest fixes and improvements as a `.vsix` file
that can be donwloaded from
[here](http://dist.springsource.com/snapshot/STS4/nightly-distributions.html). To install it
open vscode, press `CTRL-SHIFT-P` and search for VSIX, then select `Extension: Install from VSIX`
[yaml-completion]: https://github.com/spring-projects/sts4/raw/5360ae4fabf9245da58f5897c54e9a14786d0622/vscode-extensions/vscode-boot-properties/readme-imgs/yaml-completion.png
[properties-completion]: https://github.com/spring-projects/sts4/raw/5360ae4fabf9245da58f5897c54e9a14786d0622/vscode-extensions/vscode-boot-properties/readme-imgs/properties-completion.png
[yaml-validation]: https://github.com/spring-projects/sts4/raw/5360ae4fabf9245da58f5897c54e9a14786d0622/vscode-extensions/vscode-boot-properties/readme-imgs/yaml-validation.png
[properties-validation]: https://github.com/spring-projects/sts4/raw/5360ae4fabf9245da58f5897c54e9a14786d0622/vscode-extensions/vscode-boot-properties/readme-imgs/properties-validation.png
[yaml-hovers]: https://github.com/spring-projects/sts4/raw/1d731ed1ad5c8defcca4e4abb3cf5f2d89daba43/vscode-extensions/vscode-boot-properties/readme-imgs/yaml-hover.png

View File

@@ -0,0 +1 @@
*.js

View File

@@ -0,0 +1,32 @@
'use strict';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as VSCode from 'vscode';
import * as Path from 'path';
import * as FS from 'fs';
import * as Net from 'net';
import * as ChildProcess from 'child_process';
import {LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo} from 'vscode-languageclient';
import {TextDocument} from 'vscode';
import * as commons from 'commons-vscode';
const PROPERTIES_LANGUAGE_ID = "spring-boot-properties";
const YAML_LANGUAGE_ID = "spring-boot-properties-yaml";
const JAVA_LANGUAGE_ID = "java";
/** Called when extension is activated */
export function activate(context: VSCode.ExtensionContext) {
let options : commons.ActivatorOptions = {
DEBUG: false,
CONNECT_TO_LS: false,
extensionId: 'vscode-boot',
launcher: (context: VSCode.ExtensionContext) => Path.resolve(context.extensionPath, 'jars/language-server.jar'),
jvmHeap: "160m",
clientOptions: {
documentSelector: [ PROPERTIES_LANGUAGE_ID, YAML_LANGUAGE_ID, JAVA_LANGUAGE_ID ]
}
};
let clientPromise = commons.activate(options, context);
}

View File

@@ -0,0 +1,91 @@
{
"name": "vscode-boot",
"displayName": "Spring Boot Support",
"description": "Provides validation and content assist for Spring Boot `application.properties`, `application.yml` properties files. As well as Boot-specific support for `.java` files.",
"icon": "spring-boot-logo.png",
"version": "0.1.4",
"publisher": "Pivotal",
"repository": {
"type": "git",
"url": "https://github.com/spring-projects/sts4.git"
},
"license": "EPL-1.0",
"engines": {
"npm": "^3.0.0",
"vscode": "^1.19.0"
},
"categories": [
"Languages",
"Linters"
],
"keywords": [
"java-properties",
"spring-boot",
"java",
"application-properties",
"application-yaml"
],
"activationEvents": [
"onLanguage:spring-boot-properties",
"onLanguage:spring-boot-properties-yaml",
"onLanguage:java"
],
"contributes": {
"languages": [
{
"id": "spring-boot-properties-yaml",
"aliases": [
"Spring Boot Properties Yaml"
],
"filenamePatterns": [
"application*.yml",
"bootstrap*.yml"
],
"configuration": "./yaml-support/language-configuration.json"
},
{
"id": "spring-boot-properties",
"aliases": [
"Spring Boot Properties"
],
"filenamePatterns": [
"application*.properties",
"bootstrap*.yml"
],
"configuration": "./properties-support/language-configuration.json"
}
],
"grammars": [
{
"language": "spring-boot-properties-yaml",
"scopeName": "source.yaml",
"path": "./yaml-support/yaml.tmLanguage"
},
{
"language": "spring-boot-properties",
"scopeName": "source.java-properties",
"path": "./properties-support/java-properties.tmLanguage"
}
]
},
"main": "./out/lib/Main",
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"clean": "rm -fr node_modules out *.vsix package-lock.json",
"preinstall": "./scripts/preinstall.sh",
"postinstall": "node ./node_modules/vscode/bin/install",
"vsce-package": "vsce package"
},
"dependencies": {
"commons-vscode": "file:../commons-vscode/commons-vscode-0.1.4.tgz",
"vscode-languageclient": "^3.4.2"
},
"devDependencies": {
"vsce": "^1.36.1",
"typescript": "2.6.1",
"@types/node": "^7.0.43",
"vscode": "^1.1.10"
}
}

View File

@@ -0,0 +1,13 @@
// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS:
[{
"name": "textmate/java.tmbundle",
"version": "0.0.0",
"repositoryURL": "https://github.com/textmate/java.tmbundle/blob/master/Syntaxes/JavaProperties.plist",
"licenseDetail": [
"Permission to copy, use, modify, sell and distribute this",
"software is granted. This software is provided \"as is\" without",
"express or implied warranty, and with no claim as to its",
"suitability for any purpose."
]
}]

View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>properties</string>
</array>
<key>foldingStartMarker</key>
<string>^[a-zA-Z0-9.-_]+=.*\
</string>
<key>foldingStopMarker</key>
<string>^(.*(?&lt;!\)
)</string>
<key>keyEquivalent</key>
<string>^~J</string>
<key>name</key>
<string>Java Properties</string>
<key>patterns</key>
<array>
<dict>
<key>comment</key>
<string>Ignore blank lines</string>
<key>match</key>
<string>^\s*$</string>
</dict>
<dict>
<key>include</key>
<string>#comment-line</string>
</dict>
<dict>
<key>include</key>
<string>#property-name</string>
</dict>
<dict>
<key>include</key>
<string>#property-definition</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>comment-line</key>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.whitespace.comment.leading.java-properties</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.java-properties</string>
</dict>
</dict>
<key>match</key>
<string>^(\s*)([#!])(.+)?$\n?</string>
<key>name</key>
<string>comment.line.java-properties</string>
</dict>
<key>property-definition</key>
<dict>
<key>begin</key>
<string>^(\s*)((?:\\[ \t]|\\:|\\=|[^:=\s])+)(?:\s*([:=]))?\s*</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.whitespace.leading.java-properties</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>support.constant.java-properties</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\(?:[ \t:=\\ntfr\"']|u[0-9A-Fa-f]{4})</string>
<key>name</key>
<string>constant.character.escape.java-properties</string>
</dict>
</array>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.separator.key-value.java-properties</string>
</dict>
</dict>
<key>contentName</key>
<string>string.unquoted.java-properties</string>
<key>end</key>
<string>(?&lt;!\\{1})$\n</string>
<key>name</key>
<string>meta.key-value.java-properties</string>
<key>patterns</key>
<array>
<dict>
<key>comment</key>
<string>Leading space on a continued line is ignored</string>
<key>match</key>
<string>^\s*</string>
<key>name</key>
<string>punctuation.whitespace.leading.java-properties</string>
</dict>
<dict>
<key>match</key>
<string>(\\{1})(?=$\n)</string>
<key>name</key>
<string>punctuation.separator.continuation.java-properties</string>
</dict>
<dict>
<key>match</key>
<string>\\(?:[\\ntfr\"']|u[0-9A-Fa-f]{4})</string>
<key>name</key>
<string>constant.character.escape.java-properties</string>
</dict>
</array>
</dict>
<key>property-name</key>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.whitespace.comment.leading.java-properties</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>support.constant.java-properties</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\(?:[ \t:=\\ntfr\"']|u[0-9A-Fa-f]{4})</string>
<key>name</key>
<string>constant.character.escape.java-properties</string>
</dict>
</array>
</dict>
</dict>
<key>comment</key>
<string>A property name with no value</string>
<key>match</key>
<string>^(\s*)((?:\\[ \t]|\\:|\\=|[^:=\s])+)(?:\s*([:=]))?\s*$\n</string>
<key>name</key>
<string>meta.key-value.java-properties</string>
</dict>
</dict>
<key>scopeName</key>
<string>source.java-properties</string>
<key>uuid</key>
<string>D364E829-7643-4AFF-948D-3C0D6B4EA8A4</string>
</dict>
</plist>

View File

@@ -0,0 +1,21 @@
{
"comments": {
"lineComment": "#"
},
"brackets": [
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@@ -0,0 +1,20 @@
#!/bin/bash
set -e
workdir=`pwd`
# Preinstall commons-vscode package
(cd ../commons-vscode ; npm install ; npm pack)
npm install ../commons-vscode/commons-vscode-*.tgz
# Copy grammar files for .properties and .yml format
curl https://raw.githubusercontent.com/textmate/yaml.tmbundle/master/Syntaxes/YAML.tmLanguage > yaml-support/yaml.tmLanguage
curl https://raw.githubusercontent.com/textmate/java.tmbundle/master/Syntaxes/JavaProperties.plist > properties-support/java-properties.tmLanguage
# Use maven to build fat jar of the language server
cd ../../headless-services/boot-language-server
./build.sh
mkdir -p ${workdir}/jars
cp target/*.jar ${workdir}/jars/language-server.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"lib": [
"es6"
],
"declaration": true,
"outDir": "out",
"sourceMap": true,
"rootDir": "."
},
"include": [
"typings/*.d.ts",
"lib/**/*.ts"
],
"exclude": [
"node_modules"
]
}

View File

@@ -0,0 +1,28 @@
// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS:
[{
"name": "textmate/yaml.tmbundle",
"version": "0.0.0",
"license": "TextMate Bundle License",
"repositoryURL": "https://github.com/textmate/yaml.tmbundle",
"licenseDetail": [
"Copyright (c) 2015 FichteFoll <fichtefoll2@googlemail.com>",
"",
"Permission is hereby granted, free of charge, to any person obtaining a copy",
"of this software and associated documentation files (the \"Software\"), to deal",
"in the Software without restriction, including without limitation the rights",
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell",
"copies of the Software, and to permit persons to whom the Software is",
"furnished to do so, subject to the following conditions:",
"",
"The above copyright notice and this permission notice shall be included in all",
"copies or substantial portions of the Software.",
"",
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
]
}]

View File

@@ -0,0 +1,24 @@
{
"comments": {
"lineComment": "#"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}

File diff suppressed because it is too large Load Diff