From 4728bf7d0b299d8d714c7bf9297c6564c5fc7f4a Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Fri, 31 Mar 2023 22:41:11 +0530 Subject: [PATCH] feat(lsp/java): add more snippets --- .../data/editor/java/snippets.local.json | 27 ++++++++++ .../data/editor/java/snippets.member.json | 54 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 lsp/java/src/main/assets/data/editor/java/snippets.member.json diff --git a/lsp/java/src/main/assets/data/editor/java/snippets.local.json b/lsp/java/src/main/assets/data/editor/java/snippets.local.json index c1506bb06..702e6b792 100644 --- a/lsp/java/src/main/assets/data/editor/java/snippets.local.json +++ b/lsp/java/src/main/assets/data/editor/java/snippets.local.json @@ -72,5 +72,32 @@ "\t$0", "}" ] + }, + "new_object": { + "desc": "Create a new object", + "body": [ + "${1:Object} ${2:foo} = new $1($3);", + "$0" + ] + }, + "trycatch": { + "desc": "A try-catch statement", + "body": [ + "try {", + "\t$0", + "} catch(${1:Exception} ${2:err}) {", + "\t", + "}" + ] + }, + "tryresources": { + "desc": "A try-with-resources statement", + "body": [ + "try ($1) {", + "\t$0", + "} catch(${2:Exception} ${3:err}) {", + "\t", + "}" + ] } } \ No newline at end of file diff --git a/lsp/java/src/main/assets/data/editor/java/snippets.member.json b/lsp/java/src/main/assets/data/editor/java/snippets.member.json new file mode 100644 index 000000000..cc3551a3b --- /dev/null +++ b/lsp/java/src/main/assets/data/editor/java/snippets.member.json @@ -0,0 +1,54 @@ +{ + "const": { + "desc": "Create a constant field", + "body": [ + "public static final ${1:type} ${2/(.*)/${1:/upcase}/} = ${3:value};" + ] + }, + "ctor": { + "desc": "Public constructor", + "body": [ + "public " + ] + }, + "public_method": { + "desc": "Create a new public method", + "body": [ + "public ${1:void} ${2:method}(${3:params}) {", + "\t$0", + "}" + ] + }, + "protected_method": { + "desc": "Create a new protected method", + "body": [ + "protected ${1:void} ${2:method}(${3:params}) {", + "\t$0", + "}" + ] + }, + "private_method": { + "desc": "Create a new private method", + "body": [ + "private ${1:void} ${2:method}(${3:params}) {", + "\t$0", + "}" + ] + }, + "public_static_method": { + "desc": "Create a new public static method", + "body": [ + "public static ${1:void} ${2:method}(${3:params}) {", + "\t$0", + "}" + ] + }, + "private_static_method": { + "desc": "Create a new private stataic method", + "body": [ + "private static ${1:void} ${2:method}(${3:params}) {", + "\t$0", + "}" + ] + } +} \ No newline at end of file