@@ -58,41 +58,7 @@ export function activate(context: ExtensionContext) {
5858 serverOptions = visualVmConfig ( context ) ;
5959 }
6060
61- // Copied from typescript
62- languages . setLanguageConfiguration ( 'java' , {
63- indentationRules : {
64- // ^(.*\*/)?\s*\ }.*$
65- decreaseIndentPattern : / ^ ( (? ! .* ?\/ \* ) .* \* \/ ) ? \s * [ \} \] \) ] .* $ / ,
66- // ^.*\{[^}"']*$
67- increaseIndentPattern : / ^ ( (? ! \/ \/ ) .) * ( \{ [ ^ } " ' ` ] * | \( [ ^ ) " ' ` ] * | \[ [ ^ \] " ' ` ] * ) $ / ,
68- indentNextLinePattern : / ^ \s * ( f o r | w h i l e | i f | e l s e ) \b (? ! .* [ ; { } ] \s * ( \/ \/ .* | \/ [ * ] .* [ * ] \/ \s * ) ? $ ) /
69- } ,
70- onEnterRules : [
71- {
72- // e.g. /** | */
73- beforeText : / ^ \s * \/ \* \* (? ! \/ ) ( [ ^ \* ] | \* (? ! \/ ) ) * $ / ,
74- afterText : / ^ \s * \* \/ $ / ,
75- action : { indentAction : IndentAction . IndentOutdent , appendText : ' * ' }
76- } , {
77- // e.g. /** ...|
78- beforeText : / ^ \s * \/ \* \* (? ! \/ ) ( [ ^ \* ] | \* (? ! \/ ) ) * $ / ,
79- action : { indentAction : IndentAction . None , appendText : ' * ' }
80- } , {
81- // e.g. * ...|
82- beforeText : / ^ ( \t | ( \ \ ) ) * \ \* ( \ ( [ ^ \* ] | \* (? ! \/ ) ) * ) ? $ / ,
83- action : { indentAction : IndentAction . None , appendText : '* ' }
84- } , {
85- // e.g. */|
86- beforeText : / ^ ( \t | ( \ \ ) ) * \ \* \/ \s * $ / ,
87- action : { indentAction : IndentAction . None , removeText : 1 }
88- } ,
89- {
90- // e.g. *-----*/|
91- beforeText : / ^ ( \t | ( \ \ ) ) * \ \* [ ^ / ] * \* \/ \s * $ / ,
92- action : { indentAction : IndentAction . None , removeText : 1 }
93- }
94- ]
95- } )
61+ enableJavadocSymbols ( ) ;
9662
9763 // Create the language client and start the client.
9864 let client = new LanguageClient ( 'java' , 'Java Language Server' , serverOptions , clientOptions ) ;
@@ -424,4 +390,46 @@ function findJavaExecutableInJavaHome(javaHome: string, binname: string) {
424390 }
425391
426392 return null ;
393+ }
394+
395+ function enableJavadocSymbols ( ) {
396+ // Let's enable Javadoc symbols autocompletion, shamelessly copied from MIT licensed code at
397+ // https://github.com/Microsoft/vscode/blob/9d611d4dfd5a4a101b5201b8c9e21af97f06e7a7/extensions/typescript/src/typescriptMain.ts#L186
398+ languages . setLanguageConfiguration ( 'java' , {
399+ indentationRules : {
400+ // ^(.*\*/)?\s*\ }.*$
401+ decreaseIndentPattern : / ^ ( .* \* \/ ) ? \s * \} .* $ / ,
402+ // ^.*\{[^}"']*$
403+ increaseIndentPattern : / ^ .* \{ [ ^ } " ' ] * $ /
404+ } ,
405+ wordPattern : / ( - ? \d * \. \d \w * ) | ( [ ^ \` \~ \! \@ \# \% \^ \& \* \( \) \- \= \+ \[ \{ \] \} \\ \| \; \: \' \" \, \. \< \> \/ \? \s ] + ) / g,
406+ onEnterRules : [
407+ {
408+ // e.g. /** | */
409+ beforeText : / ^ \s * \/ \* \* (? ! \/ ) ( [ ^ \* ] | \* (? ! \/ ) ) * $ / ,
410+ afterText : / ^ \s * \* \/ $ / ,
411+ action : { indentAction : IndentAction . IndentOutdent , appendText : ' * ' }
412+ } ,
413+ {
414+ // e.g. /** ...|
415+ beforeText : / ^ \s * \/ \* \* (? ! \/ ) ( [ ^ \* ] | \* (? ! \/ ) ) * $ / ,
416+ action : { indentAction : IndentAction . None , appendText : ' * ' }
417+ } ,
418+ {
419+ // e.g. * ...|
420+ beforeText : / ^ ( \t | ( \ \ ) ) * \ \* ( \ ( [ ^ \* ] | \* (? ! \/ ) ) * ) ? $ / ,
421+ action : { indentAction : IndentAction . None , appendText : '* ' }
422+ } ,
423+ {
424+ // e.g. */|
425+ beforeText : / ^ ( \t | ( \ \ ) ) * \ \* \/ \s * $ / ,
426+ action : { indentAction : IndentAction . None , removeText : 1 }
427+ } ,
428+ {
429+ // e.g. *-----*/|
430+ beforeText : / ^ ( \t | ( \ \ ) ) * \ \* [ ^ / ] * \* \/ \s * $ / ,
431+ action : { indentAction : IndentAction . None , removeText : 1 }
432+ }
433+ ]
434+ } ) ;
427435}
0 commit comments