@@ -54,20 +54,30 @@ async function handleNewJavaFiles(e: FileCreateEvent) {
5454 }
5555
5656 for ( let i = 0 ; i < emptyFiles . length ; i ++ ) {
57- const packageName = resolvePackageName ( sourcePaths , emptyFiles [ i ] . fsPath ) ;
5857 const typeName : string = resolveTypeName ( textDocuments [ i ] . fileName ) ;
58+ const isPackageInfo = typeName === 'package-info' ;
59+ const isModuleInfo = typeName === 'module-info' ;
5960 const snippets : string [ ] = [ ] ;
60- if ( packageName ) {
61- snippets . push ( `package ${ packageName } ;` ) ;
61+ if ( ! isModuleInfo ) {
62+ const packageName = resolvePackageName ( sourcePaths , emptyFiles [ i ] . fsPath ) ;
63+ if ( packageName ) {
64+ snippets . push ( `package ${ packageName } ;` ) ;
65+ if ( ! isPackageInfo ) {
66+ snippets . push ( "" ) ;
67+ }
68+ }
6269 }
63- snippets . push ( "" ) ;
64- if ( ! serverReady || await isVersionLessThan ( emptyFiles [ i ] . toString ( ) , 14 ) ) {
65- snippets . push ( `public \${1|class,interface,enum|} ${ typeName } {` ) ;
66- } else {
67- snippets . push ( `public \${1|class ${ typeName } ,interface ${ typeName } ,enum ${ typeName } ,record ${ typeName } ()|} {` ) ;
70+ if ( ! isPackageInfo ) {
71+ if ( isModuleInfo ) {
72+ snippets . push ( `module \${1:name} {` ) ;
73+ } else if ( ! serverReady || await isVersionLessThan ( emptyFiles [ i ] . toString ( ) , 14 ) ) {
74+ snippets . push ( `public \${1|class,interface,enum|} ${ typeName } {` ) ;
75+ } else {
76+ snippets . push ( `public \${1|class ${ typeName } ,interface ${ typeName } ,enum ${ typeName } ,record ${ typeName } ()|} {` ) ;
77+ }
78+ snippets . push ( "\t${0}" ) ;
79+ snippets . push ( "}" ) ;
6880 }
69- snippets . push ( "" ) ;
70- snippets . push ( "}" ) ;
7181 const textEditor = await window . showTextDocument ( textDocuments [ i ] ) ;
7282 textEditor . insertSnippet ( new SnippetString ( snippets . join ( "\n" ) ) ) ;
7383 }
0 commit comments