Create proper language ids for application.properties|yml

This commit is contained in:
Kris De Volder
2017-11-23 10:38:33 -08:00
parent c5df8812fa
commit fbaf9680c7
10 changed files with 1458 additions and 28 deletions

View File

@@ -12,6 +12,9 @@ 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";
/** Called when extension is activated */
export function activate(context: VSCode.ExtensionContext) {
let options : commons.ActivatorOptions = {
@@ -19,25 +22,10 @@ export function activate(context: VSCode.ExtensionContext) {
CONNECT_TO_LS: false,
extensionId: 'vscode-boot-properties',
launcher: (context: VSCode.ExtensionContext) => Path.resolve(context.extensionPath, 'jars/language-server.jar'),
jvmHeap: "64m",
clientOptions: {
// HACK!!! documentSelector only takes string|string[] where string is language id, but DocumentFilter object is passed instead
// Reasons:
// 1. documentSelector is just passed over to functions like #registerHoverProvider(documentSelector, ...) that take documentSelector
// parameter in string | DocumentFilter | string[] | DocumentFilter[] format
// 2. Combination of non string|string[] documentSelector parameter and synchronize.textDocumentFilter function makes doc synchronization
// events pass on to Language Server only for documents for which function passed via textDocumentFilter property return true
// TODO: Remove <any> cast ones https://github.com/Microsoft/vscode-languageserver-node/issues/9 is resolved
documentSelector: [
// for application.properties files
<any> {language: 'ini', pattern: '**/application*.properties'},
<any> {language: 'java-properties', pattern: '**/application*.properties'},
<any> {language: 'properties', pattern: '**/application*.properties'},
// for application.yml files
<any> {language: 'yaml', pattern: '**/application*.yml'}
]
documentSelector: [ PROPERTIES_LANGUAGE_ID, YAML_LANGUAGE_ID ]
}
};
commons.activate(options, context);
let clientPromise = commons.activate(options, context);
}

View File

@@ -25,11 +25,45 @@
"application-yaml"
],
"activationEvents": [
"onLanguage:ini",
"onLanguage:java-properties",
"onLanguage:properties",
"onLanguage:yaml"
"onLanguage:spring-boot-properties",
"onLanguage:spring-boot-properties-yaml"
],
"contributes": {
"languages": [
{
"id": "spring-boot-properties-yaml",
"aliases": [
"Spring Boot Properties Yaml"
],
"filenamePatterns": [
"application*.yml"
],
"configuration": "./yaml-support/language-configuration.json"
},
{
"id": "spring-boot-properties",
"aliases": [
"Spring Boot Properties"
],
"filenamePatterns": [
"application*.properties"
],
"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": {
"prepublish": "tsc -p .",

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": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}

View File

@@ -7,6 +7,10 @@ workdir=`pwd`
(cd ../commons-vscode ; npm install)
npm install ../commons-vscode
# 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-properties-language-server
./build.sh

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

View File

@@ -28,12 +28,6 @@
"onLanguage:concourse-task-yaml"
],
"contributes": {
"commands": [
{
"command": "mycommand.sayHello",
"title": "Say Hello"
}
],
"languages": [
{
"id": "concourse-pipeline-yaml",