@@ -13,6 +13,7 @@ import { ExtensionServiceClientImpl, IExtensionNodeClientService } from '@alipay
1313import { IExtensionMetadata } from '@alipay/alex-shared' ;
1414import { IFileServiceClient } from '@ali/ide-file-service' ;
1515import { KaitianExtFsProvider } from '@alipay/alex-core' ;
16+ import { CodeModelService } from '@alipay/alex-code-service' ;
1617
1718import {
1819 StaticResourceContribution ,
@@ -72,6 +73,12 @@ class ExtensionServiceClient extends ExtensionServiceClientImpl {
7273
7374@Domain ( CommandContribution )
7475export class AlexAppContribution implements CommandContribution {
76+ @Autowired ( )
77+ codeModel : CodeModelService ;
78+
79+ private ticket : number = 0 ;
80+ private tickets : number [ ] = [ ] ;
81+
7582 registerCommands ( commands : CommandRegistry ) : void {
7683 // 保持和 api-server 一致
7784 commands . registerCommand (
@@ -91,11 +98,56 @@ export class AlexAppContribution implements CommandContribution {
9198 ) ;
9299
93100 commands . registerCommand (
94- { id : 'alex.command. env.language' } ,
101+ { id : 'alex.env.language' } ,
95102 {
96103 execute : ( ) => getLanguageId ( ) ,
97104 }
98105 ) ;
106+
107+ commands . registerCommand (
108+ { id : 'alex.languages.setTextDocumentLanguage' } ,
109+ {
110+ execute : ( uri : string , languageId : string ) => {
111+ const modelService = ( monaco as any ) . services . StaticServices . modelService . get ( ) ;
112+ const modeService = ( monaco as any ) . services . StaticServices . modeService . get ( ) ;
113+ const model = modelService . getModel ( uri ) ;
114+ if ( ! model ) {
115+ return Promise . reject ( new Error ( 'Invalid uri' ) ) ;
116+ }
117+ const languageIdentifier = modeService . getLanguageIdentifier ( languageId ) ;
118+ if ( ! languageIdentifier || languageIdentifier . language !== languageId ) {
119+ return Promise . reject ( new Error ( `Unknown language id: ${ languageId } ` ) ) ;
120+ }
121+ modelService . setMode ( model , modeService . create ( languageId ) ) ;
122+ return Promise . resolve ( undefined ) ;
123+ } ,
124+ }
125+ ) ;
126+
127+ commands . registerCommand (
128+ { id : 'alex.codeServiceProject' } ,
129+ {
130+ execute : ( ) => {
131+ return {
132+ platform : this . codeModel . platform ,
133+ project : this . codeModel . project ,
134+ projectId : this . codeModel . projectId ,
135+ commit : this . codeModel . commit ,
136+ } ;
137+ } ,
138+ }
139+ ) ;
140+
141+ commands . registerCommand (
142+ { id : 'alex.subscribe' } ,
143+ {
144+ execute : ( ) => {
145+ this . ticket ++ ;
146+ this . tickets . push ( this . ticket ) ;
147+ return this . ticket ;
148+ } ,
149+ }
150+ ) ;
99151 }
100152}
101153
0 commit comments