Skip to content

Commit

Permalink
Support movement of snippets to JDT-LS
Browse files Browse the repository at this point in the history
Signed-off-by: Hope Hadfield <[email protected]>
  • Loading branch information
hopehadfield authored and rgrunber committed Aug 31, 2023
1 parent 4eadce1 commit d02cf8e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 86 deletions.
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@
"path": "./language-support/properties/JavaProperties.tmLanguage.json"
}
],
"snippets": [
{
"language": "java",
"path": "./snippets/java.json"
}
],
"jsonValidation": [
{
"fileMatch": "package.json",
Expand Down
79 changes: 0 additions & 79 deletions snippets/java.json

This file was deleted.

77 changes: 77 additions & 0 deletions snippets/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 5 additions & 1 deletion src/snippetCompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit d02cf8e

Please sign in to comment.