diff --git a/headless-services/bosh-language-server/.classpath b/headless-services/bosh-language-server/.classpath new file mode 100644 index 000000000..fae1a2b37 --- /dev/null +++ b/headless-services/bosh-language-server/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/headless-services/bosh-language-server/.project b/headless-services/bosh-language-server/.project new file mode 100644 index 000000000..3dbfe1b29 --- /dev/null +++ b/headless-services/bosh-language-server/.project @@ -0,0 +1,23 @@ + + + bosh-language-server + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/headless-services/bosh-language-server/.settings/org.eclipse.core.resources.prefs b/headless-services/bosh-language-server/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..29abf9995 --- /dev/null +++ b/headless-services/bosh-language-server/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/headless-services/bosh-language-server/.settings/org.eclipse.jdt.core.prefs b/headless-services/bosh-language-server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..714351aec --- /dev/null +++ b/headless-services/bosh-language-server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/headless-services/bosh-language-server/.settings/org.eclipse.m2e.core.prefs b/headless-services/bosh-language-server/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/headless-services/bosh-language-server/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/vscode-extensions/vscode-bosh/.gitignore b/vscode-extensions/vscode-bosh/.gitignore new file mode 100644 index 000000000..2932a75be --- /dev/null +++ b/vscode-extensions/vscode-bosh/.gitignore @@ -0,0 +1,11 @@ +out +node_modules +target +*.log +*.log.* +.idea +*.iml +dependency-reduced-pom.xml +classpath.txt +*.vsix +repo \ No newline at end of file diff --git a/vscode-extensions/vscode-bosh/.vscode/launch.json b/vscode-extensions/vscode-bosh/.vscode/launch.json new file mode 100644 index 000000000..51d437ae0 --- /dev/null +++ b/vscode-extensions/vscode-bosh/.vscode/launch.json @@ -0,0 +1,29 @@ +// A launch configuration that compiles the extension and then opens it inside a new window +{ + "version": "0.1.0", + "configurations": [ + + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], + "stopOnEntry": false, + "sourceMaps": true, + "outDir": "${workspaceRoot}/out/lib", + "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" + } + ] +} diff --git a/vscode-extensions/vscode-bosh/.vscode/settings.json b/vscode-extensions/vscode-bosh/.vscode/settings.json new file mode 100644 index 000000000..7b54d1cef --- /dev/null +++ b/vscode-extensions/vscode-bosh/.vscode/settings.json @@ -0,0 +1,13 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "editor.wordWrap": false, + "files.exclude": { + "out": false, // 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 +} \ No newline at end of file diff --git a/vscode-extensions/vscode-bosh/.vscode/tasks.json b/vscode-extensions/vscode-bosh/.vscode/tasks.json new file mode 100644 index 000000000..108f5e94d --- /dev/null +++ b/vscode-extensions/vscode-bosh/.vscode/tasks.json @@ -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": "always", + + // we run the custom script "compile" as defined in package.json + "args": ["run", "compile"], + + // 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" +} \ No newline at end of file diff --git a/vscode-extensions/vscode-bosh/.vscodeignore b/vscode-extensions/vscode-bosh/.vscodeignore new file mode 100644 index 000000000..f7be2f963 --- /dev/null +++ b/vscode-extensions/vscode-bosh/.vscodeignore @@ -0,0 +1,29 @@ +# 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/** + +# Extensions +.gitignore +**/*.map diff --git a/vscode-extensions/vscode-bosh/README.md b/vscode-extensions/vscode-bosh/README.md new file mode 100644 index 000000000..c3fbd6e47 --- /dev/null +++ b/vscode-extensions/vscode-bosh/README.md @@ -0,0 +1,91 @@ +# Concourse Pipeline and Task Editor for Visual Studio Code + +This extension provides validation, content assist and documentation hovers +for editing [Concourse](https://concourse.ci/) Pipeline and Task configuration files. + +## Usage + +The Concourse editor automatically activates when the name of the `.yml` file you are editing +follows a certain pattern: + + - `**/*pipeline*.yml` : activates support for editing pipelines + - `**/tasks/*.yml` : activates support for editing tasks. + +You can also define your own patterns and map them to the language-ids `concourse-pipeline-yaml` +or `concourse-task-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 + +### Validation + +As you type the text is parsed and checked for basic syntactic and structural correctness. Hover over +an error marker to see an explanation: + +![Linting Screenshot][linting] + +### Content assist + +Having trouble remembering all the names of the attributes, and their spelling? Or can't remember +which resource properties to set in the `get` task params versus its `source` attributes? Or +don't remember what 'special' values are acceptable for a certain property? Content assist +to the rescue: + +![Content Assist Screenshot][ca1] + +![Content Assist Screenshot][ca2] + +### Documentation Hovers + +Having trouble remembering exactly what the meaning of each attribute is? Hover over an attribute and +read its detailed documentation: + +![Hover Docs Screenshot][hovers] + +### Goto Symbol in File + +Is your Pipeline yaml file getting larger and is it becoming harder to find a particular Job, Resource or +Resource Type declaration? The "Goto Symbol in File" command helps you quickly jump to a specific +definition. + +Type `CTRL-SHIFT-O` to popup a list of all symbols in your current Pipeline file. Start typing a name +(or portion thereof) to narrow down the list. Select a symbol to jump directly to its location in the +file. + +![Goto Symbol Screenshot][goto_symbol] + +### Goto/Peek Definition + +Use "Goto Defition" or "Peek Definition" to quickly go (or peek) from a a Job- or Resource name +to its corresponding definition. + +![Peek Definition Screenshot][peek] + +## Limitations + +This Vscode Extension is still a work in progress. At the moment only a select few of the [built-in resource-types](https://concourse.ci/resource-types.html) +have been fully defined in the Editor's Schema. + +The resource-types that are already defined in the schema are: + + - git + - docker-image + - s3 + - pool + - semver + - time + +For other resource-types content assist and checking is still very limited. We intend +to grow this list and provide a similar level of support for all of the built-in resource types in +the near future. + +## Issues and Feature Requests + +Please report bugs, issues and feature requests on the [Github STS4 issue tracker](https://github.com/spring-projects/sts4/issues). + +[linting]: https://raw.githubusercontent.com/spring-projects/sts4/98148c08b608ff365fb87b2de955d6833f7ee082/vscode-extensions/vscode-concourse/readme-imgs/linting.png +[ca1]: https://raw.githubusercontent.com/spring-projects/sts4/98148c08b608ff365fb87b2de955d6833f7ee082/vscode-extensions/vscode-concourse/readme-imgs/content-assist-1.png +[ca2]: https://raw.githubusercontent.com/spring-projects/sts4/98148c08b608ff365fb87b2de955d6833f7ee082/vscode-extensions/vscode-concourse/readme-imgs/content-assist-2.png +[hovers]: https://raw.githubusercontent.com/spring-projects/sts4/98148c08b608ff365fb87b2de955d6833f7ee082/vscode-extensions/vscode-concourse/readme-imgs/hover.png +[peek]: https://raw.githubusercontent.com/spring-projects/sts4/98148c08b608ff365fb87b2de955d6833f7ee082/vscode-extensions/vscode-concourse/readme-imgs/peek.png +[goto_symbol]: https://raw.githubusercontent.com/spring-projects/sts4/d095208cfb34b0f129e6b66d41d099955a712f81/vscode-extensions/vscode-concourse/readme-imgs/goto-symbol.png diff --git a/vscode-extensions/vscode-bosh/developer-notes.md b/vscode-extensions/vscode-bosh/developer-notes.md new file mode 100644 index 000000000..9f0eabc21 --- /dev/null +++ b/vscode-extensions/vscode-bosh/developer-notes.md @@ -0,0 +1,64 @@ +# VS Code Language Server Developer notes + +## Getting and installing latest snapshot + +The latest snapshot .vsix file can be downloaded from here: + +http://dist.springsource.com/snapshot/STS4/nightly-distributions.html + +You should get the file called `vscode-bosh-.vsix`. + +To install it in vscode follow these steps: + + - open vscode + - Press `CTRL-SHIFT-P` and type 'vsix' in the search box + - Select the `Extensions: Install from vsix file` command + - Install the `.vsix` you downloaded earlier. + +## 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 + +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 JVM. + +You can then connect a 'Remote Java' Eclipse debugger on port 8000. + +## 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. diff --git a/vscode-extensions/vscode-bosh/icon.png b/vscode-extensions/vscode-bosh/icon.png new file mode 100644 index 000000000..9df9781f9 Binary files /dev/null and b/vscode-extensions/vscode-bosh/icon.png differ diff --git a/vscode-extensions/vscode-bosh/lib/.gitignore b/vscode-extensions/vscode-bosh/lib/.gitignore new file mode 100644 index 000000000..a6c7c2852 --- /dev/null +++ b/vscode-extensions/vscode-bosh/lib/.gitignore @@ -0,0 +1 @@ +*.js diff --git a/vscode-extensions/vscode-bosh/lib/Main.ts b/vscode-extensions/vscode-bosh/lib/Main.ts new file mode 100644 index 000000000..67b75429d --- /dev/null +++ b/vscode-extensions/vscode-bosh/lib/Main.ts @@ -0,0 +1,45 @@ +'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 commons from 'commons-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, OutputChannel} from 'vscode'; + +var log_output : OutputChannel = null; + +const PIPELINE_LANGUAGE_ID = "concourse-pipeline-yaml"; +const TASK_LANGUAGE_ID = "concourse-task-yaml"; + +function log(msg : string) { + if (log_output) { + log_output.append(msg +"\n"); + } +} + +function error(msg : string) { + if (log_output) { + log_output.append("ERR: "+msg+"\n"); + } +} + +/** Called when extension is activated */ +export function activate(context: VSCode.ExtensionContext) { + let options : commons.ActivatorOptions = { + DEBUG : false, + CONNECT_TO_LS: false, + extensionId: 'vscode-concourse', + fatJarFile: 'jars/language-server.jar', + jvmHeap: "48m", + clientOptions: { + documentSelector: [ PIPELINE_LANGUAGE_ID, TASK_LANGUAGE_ID ] + } + }; + let clientPromise = commons.activate(options, context); +} + diff --git a/vscode-extensions/vscode-bosh/package.json b/vscode-extensions/vscode-bosh/package.json new file mode 100644 index 000000000..35ddf7045 --- /dev/null +++ b/vscode-extensions/vscode-bosh/package.json @@ -0,0 +1,68 @@ +{ + "name": "vscode-bosh", + "displayName": "Bosh Editor", + "description": "Provides validation and content assist for various Bosh configuration files", + "icon": "icon.png", + "version": "0.0.9", + "publisher": "Pivotal", + "repository": { + "type": "git", + "url": "https://github.com/spring-projects/sts4.git" + }, + "license": "EPL-1.0", + "engines": { + "npm": "^3.0.0", + "vscode": "^1.8.0" + }, + "categories": [ + "Languages", + "Linters" + ], + "keywords": [ + "yaml", + "bosh" + ], + "activationEvents": [ + "onLanguage:bosh-deployment-manifest" + ], + "contributes": { + "languages": [ + { + "id": "bosh-deployment-manifest", + "aliases": [ + "Bosh Deployment Manifest" + ], + "filenamePatterns": [ + "*deployment*.yml" + ], + "configuration": "./yaml-support/language-configuration.json" + } + ], + "grammars": [ + { + "language": "bosh-deployment-manifest", + "scopeName": "source.yaml", + "path": "./yaml-support/yaml.tmLanguage" + } + ] + }, + "main": "./out/lib/Main", + "scripts": { + "prepublish": "tsc -p .", + "clean": "rm -fr node_modules out *.vsix", + "compile": "tsc -watch -p ./", + "preinstall": "./scripts/preinstall.sh", + "postinstall": "node ./node_modules/vscode/bin/install", + "vsce-package": "vsce package" + }, + "dependencies": { + "vscode-languageclient": "^3.2.x", + "commons-vscode": "^0.0.6" + }, + "devDependencies": { + "vsce": "1.29.0", + "typescript": "^2.3.0", + "@types/node": "^6.0.68", + "vscode": "^1.1.0" + } +} diff --git a/vscode-extensions/vscode-bosh/readme-imgs/content-assist-1.png b/vscode-extensions/vscode-bosh/readme-imgs/content-assist-1.png new file mode 100644 index 000000000..c43f39bb6 Binary files /dev/null and b/vscode-extensions/vscode-bosh/readme-imgs/content-assist-1.png differ diff --git a/vscode-extensions/vscode-bosh/readme-imgs/content-assist-2.png b/vscode-extensions/vscode-bosh/readme-imgs/content-assist-2.png new file mode 100644 index 000000000..ff4e1c964 Binary files /dev/null and b/vscode-extensions/vscode-bosh/readme-imgs/content-assist-2.png differ diff --git a/vscode-extensions/vscode-bosh/readme-imgs/goto-symbol.png b/vscode-extensions/vscode-bosh/readme-imgs/goto-symbol.png new file mode 100644 index 000000000..a9e544665 Binary files /dev/null and b/vscode-extensions/vscode-bosh/readme-imgs/goto-symbol.png differ diff --git a/vscode-extensions/vscode-bosh/readme-imgs/hover.png b/vscode-extensions/vscode-bosh/readme-imgs/hover.png new file mode 100644 index 000000000..ca14b9d44 Binary files /dev/null and b/vscode-extensions/vscode-bosh/readme-imgs/hover.png differ diff --git a/vscode-extensions/vscode-bosh/readme-imgs/linting.png b/vscode-extensions/vscode-bosh/readme-imgs/linting.png new file mode 100644 index 000000000..93860ed82 Binary files /dev/null and b/vscode-extensions/vscode-bosh/readme-imgs/linting.png differ diff --git a/vscode-extensions/vscode-bosh/readme-imgs/peek.png b/vscode-extensions/vscode-bosh/readme-imgs/peek.png new file mode 100644 index 000000000..c8e025510 Binary files /dev/null and b/vscode-extensions/vscode-bosh/readme-imgs/peek.png differ diff --git a/vscode-extensions/vscode-bosh/scripts/preinstall.sh b/vscode-extensions/vscode-bosh/scripts/preinstall.sh new file mode 100755 index 000000000..a7fb9223b --- /dev/null +++ b/vscode-extensions/vscode-bosh/scripts/preinstall.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +workdir=`pwd` + +# Download yaml TextMate grammar +curl https://raw.githubusercontent.com/textmate/yaml.tmbundle/master/Syntaxes/YAML.tmLanguage > yaml-support/yaml.tmLanguage + +# Preinstall commons-vscode package +(cd ../commons-vscode ; npm install) +npm install ../commons-vscode + +# Use maven to build fat jar of the language server +cd ../../headless-services/concourse-language-server +./build.sh + +mkdir -p ${workdir}/jars +cp target/*.jar ${workdir}/jars/language-server.jar + diff --git a/vscode-extensions/vscode-bosh/tsconfig.json b/vscode-extensions/vscode-bosh/tsconfig.json new file mode 100644 index 000000000..1905ffea7 --- /dev/null +++ b/vscode-extensions/vscode-bosh/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/vscode-extensions/vscode-bosh/tsd.json b/vscode-extensions/vscode-bosh/tsd.json new file mode 100644 index 000000000..50cd71dcf --- /dev/null +++ b/vscode-extensions/vscode-bosh/tsd.json @@ -0,0 +1,12 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "typings", + "bundle": "typings/tsd.d.ts", + "installed": { + "node/node.d.ts": { + "commit": "d22516f9f089de107d7e7d5938566377370631f6" + } + } +} diff --git a/vscode-extensions/vscode-bosh/yaml-support/.gitignore b/vscode-extensions/vscode-bosh/yaml-support/.gitignore new file mode 100644 index 000000000..ddc0ef4f6 --- /dev/null +++ b/vscode-extensions/vscode-bosh/yaml-support/.gitignore @@ -0,0 +1 @@ +yaml.tmLanguage \ No newline at end of file diff --git a/vscode-extensions/vscode-bosh/yaml-support/OSSREADME.json b/vscode-extensions/vscode-bosh/yaml-support/OSSREADME.json new file mode 100644 index 000000000..bcdae2a4c --- /dev/null +++ b/vscode-extensions/vscode-bosh/yaml-support/OSSREADME.json @@ -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 ", + "", + "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." + ] +}] diff --git a/vscode-extensions/vscode-bosh/yaml-support/language-configuration.json b/vscode-extensions/vscode-bosh/yaml-support/language-configuration.json new file mode 100644 index 000000000..cab4f6602 --- /dev/null +++ b/vscode-extensions/vscode-bosh/yaml-support/language-configuration.json @@ -0,0 +1,24 @@ +{ + "comments": { + "lineComment": "#" + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ] +} \ No newline at end of file