1
1
import type { LanguagePlugin } from "@volar/language-core" ;
2
2
import type { InitializeParams } from "@volar/language-service" ;
3
- import type { TypeScriptExtraServiceScript } from "@volar/typescript" ;
4
3
import type ts from "typescript" ;
5
4
import type { URI } from "vscode-uri" ;
6
5
import { forEachEmbeddedCode } from "@volar/language-core" ;
@@ -25,31 +24,21 @@ export async function createJsrsLanguagePlugin(_params: InitializeParams): Promi
25
24
}
26
25
} ,
27
26
typescript : {
28
- extraFileExtensions : [ { extension : "jsrs" , isMixedContent : true , scriptKind : 7 satisfies ts . ScriptKind . Deferred } ] ,
29
- getServiceScript ( ) {
30
- return void 0 ;
31
- } ,
32
- getExtraServiceScripts ( fileName , root ) {
33
- const scripts : TypeScriptExtraServiceScript [ ] = [ ] ;
27
+ extraFileExtensions : [ {
28
+ extension : "jsrs" ,
29
+ isMixedContent : true ,
30
+ scriptKind : 7 satisfies ts . ScriptKind . Deferred ,
31
+ } ] ,
32
+ getServiceScript ( root ) {
34
33
for ( const code of forEachEmbeddedCode ( root ) ) {
35
- if ( code . languageId === "javascript" ) {
36
- scripts . push ( {
37
- fileName : `${ fileName } .${ code . id } .js` ,
38
- code,
39
- extension : ".js" ,
40
- scriptKind : 1 satisfies ts . ScriptKind . JS ,
41
- } ) ;
42
- }
43
- else if ( code . languageId === "typescript" ) {
44
- scripts . push ( {
45
- fileName : `${ fileName } .${ code . id } .ts` ,
34
+ if ( code . id === "jsrs" ) {
35
+ return {
46
36
code,
47
37
extension : ".ts" ,
48
38
scriptKind : 3 satisfies ts . ScriptKind . TS ,
49
- } ) ;
39
+ } ;
50
40
}
51
41
}
52
- return scripts ;
53
42
} ,
54
43
} ,
55
44
} ;
0 commit comments