diff --git a/package.json b/package.json index 13aafd6be..ec5137e7a 100644 --- a/package.json +++ b/package.json @@ -188,12 +188,6 @@ "path": "./language-support/properties/JavaProperties.tmLanguage.json" } ], - "snippets": [ - { - "language": "java", - "path": "./snippets/java.json" - } - ], "jsonValidation": [ { "fileMatch": "package.json", diff --git a/snippets/java.json b/snippets/java.json deleted file mode 100644 index 7a76f6d42..000000000 --- a/snippets/java.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "main": { - "prefix": ["main", "psvm"], - "body": [ - "public static void main(String[] args) {", - "\t$0", - "}" - ], - "description": "Public static main method" - }, - "Constructor": { - "prefix": "ctor", - "body": [ - "${1|public,protected,private|} ${2:${TM_FILENAME_BASE}}($3) {", - "\t${4:super();}$0", - "}" - ], - "description": "Constructor" - }, - "trycatch": { - "prefix": "try_catch", - "body": [ - "try {", - "\t${TM_SELECTED_TEXT:$1}", - "} catch (${2:Exception} ${3:e}) {", - "\t$0// TODO: handle exception", - "}" - ], - "description": "try/catch block" - }, - "tryresources": { - "prefix": "try_resources", - "body": [ - "try ($1) {", - "\t$2", - "} catch (${3:Exception} ${4:e}) {", - "\t$0// TODO: handle exception", - "}" - ] - }, - "method": { - "prefix": "method", - "body": [ - "${1|public,protected,private|}${2| , static |}${3:void} ${4:name}($5) {", - "\t$0", - "}" - ], - "description": "Method" - }, - "Switch Statement": { - "prefix": "switch", - "body": [ - "switch (${1:key}) {", - "\tcase ${2:value}:", - "\t\t$0", - "\t\tbreak;", - "", - "\tdefault:", - "\t\tbreak;", - "}" - ], - "description": "Switch Statement" - }, - "newObject": { - "prefix": "new", - "body": [ - "${1:Object} ${2:foo} = new ${1}($3);", - "$0" - ], - "description": "Create new Object" - }, - "Field": { - "prefix": "field", - "body": [ - "${1|public,protected,private|} ${2:String} ${3:name};" - ], - "description": "Field" - } -} \ No newline at end of file diff --git a/snippets/server.json b/snippets/server.json index c7d5493ec..59c4c7026 100644 --- a/snippets/server.json +++ b/snippets/server.json @@ -86,5 +86,82 @@ "} while (${1:condition});" ], "description": "Do-While Statement" + }, + "Switch Statement": { + "prefix": "switch", + "body": [ + "switch (${1:key}) {", + "\tcase ${2:value}:", + "\t\t$0", + "\t\tbreak;", + "", + "\tdefault:", + "\t\tbreak;", + "}" + ], + "description": "Switch Statement" + }, + "trycatch": { + "prefix": "try_catch", + "body": [ + "try {", + "\t${TM_SELECTED_TEXT:$1}", + "} catch (${2:Exception} ${3:e}) {", + "\t$0// TODO: handle exception", + "}" + ], + "description": "try/catch block" + }, + "tryresources": { + "prefix": "try_resources", + "body": [ + "try ($1) {", + "\t$2", + "} catch (${3:Exception} ${4:e}) {", + "\t$0// TODO: handle exception", + "}" + ] + }, + "main": { + "prefix": ["main", "psvm"], + "body": [ + "public static void main(String[] args) {", + "\t$0", + "}" + ], + "description": "Public static main method" + }, + "Constructor": { + "prefix": "ctor", + "body": [ + "${1|public,protected,private|} ${2:${TM_FILENAME_BASE}}($3) {", + "\t${4:super();}$0", + "}" + ], + "description": "Constructor" + }, + "method": { + "prefix": "method", + "body": [ + "${1|public,protected,private|}${2| , static |}${3:void} ${4:name}($5) {", + "\t$0", + "}" + ], + "description": "Method" + }, + "newObject": { + "prefix": "new", + "body": [ + "${1:Object} ${2:foo} = new ${1}($3);", + "$0" + ], + "description": "Create new Object" + }, + "Field": { + "prefix": "field", + "body": [ + "${1|public,protected,private|} ${2:String} ${3:name};" + ], + "description": "Field" } } \ No newline at end of file diff --git a/src/snippetCompletionProvider.ts b/src/snippetCompletionProvider.ts index fda426de3..53601fd19 100644 --- a/src/snippetCompletionProvider.ts +++ b/src/snippetCompletionProvider.ts @@ -56,7 +56,11 @@ class SnippetCompletionProviderImpl implements CompletionItemProvider { } export function beautifyDocument(raw: string): MarkdownString { - const escapedString = raw.replace(/\$\{\d:?(.*?)\}/gm, '$1').replace(/\$\d/gm, ''); + const escapedString = raw.replace(/\$\{\d\|(.*?),.*?\}/gm, '$1') + .replace(/\$\{\d:?(.*?)\}/gm, '$1') + .replace(/\$\d/gm, '') + .replace(/\${TM_SELECTED_TEXT:}/gm, '') + .replace(/\${TM_FILENAME_BASE}/gm, ''); return new MarkdownString().appendCodeblock(escapedString, "java"); }