11import { monaco , registerTextModelContentProvider } from '@codingame/monaco-editor-wrapper'
22import {
3- Disposable ,
4- ServerCapabilities , DocumentSelector , MonacoLanguageClient , Services ,
5- TextDocumentSyncOptions , TextDocument , DidSaveTextDocumentNotification , Emitter , DisposableCollection
3+ Disposable , MonacoLanguageClient , DisposableCollection
64} from 'monaco-languageclient'
75import { StaticFeature , FeatureState , ProtocolRequestType } from 'vscode-languageclient/lib/common/api'
6+ import { DidSaveTextDocumentNotification , DocumentSelector , Emitter , ServerCapabilities , TextDocumentSyncOptions } from 'vscode-languageserver-protocol'
7+ import * as vscode from 'vscode'
88import { updateFile , willShutdownNotificationType , WillShutdownParams } from './customRequests'
99import { Infrastructure } from './infrastructure'
1010import { LanguageClient , LanguageClientManager } from './languageClient'
@@ -28,22 +28,22 @@ export class InitializeTextDocumentFeature implements StaticFeature {
2828 }
2929
3030 const languageClient = this . languageClient
31- async function saveFile ( textDocument : TextDocument ) {
32- if ( Services . get ( ) . languages . match ( documentSelector ! , textDocument ) ) {
33- await updateFile ( textDocument . uri , textDocument . getText ( ) , languageClient )
31+ async function saveFile ( textDocument : vscode . TextDocument ) {
32+ if ( documentSelector != null && vscode . languages . match ( documentSelector , textDocument ) > 0 ) {
33+ await updateFile ( textDocument . uri . toString ( ) , textDocument . getText ( ) , languageClient )
3434
3535 // Always send notification even if the server doesn't support it (because csharp register the didSave feature too late)
36- languageClient . sendNotification ( DidSaveTextDocumentNotification . type , {
36+ await languageClient . sendNotification ( DidSaveTextDocumentNotification . type , {
3737 textDocument : {
38- uri : textDocument . uri
38+ uri : textDocument . uri . toString ( )
3939 } ,
4040 text : textDocument . getText ( )
4141 } )
4242 }
4343 }
4444
45- this . didOpenTextDocumentDisposable = Services . get ( ) . workspace . onDidOpenTextDocument ( saveFile )
46- Services . get ( ) . workspace . textDocuments . forEach ( saveFile )
45+ this . didOpenTextDocumentDisposable = vscode . workspace . onDidOpenTextDocument ( saveFile )
46+ vscode . workspace . textDocuments . forEach ( saveFile )
4747 }
4848
4949 getState ( ) : FeatureState {
@@ -66,18 +66,18 @@ class CobolResolveSubroutineFeature implements StaticFeature {
6666 fillClientCapabilities ( ) : void { }
6767
6868 initialize ( capabilities : ServerCapabilities , documentSelector : DocumentSelector ) : void {
69- this . onRequestDisposable = this . languageClient . onRequest ( ResolveCobolSubroutineRequestType , ( routineName : string ) => {
69+ this . onRequestDisposable = this . languageClient . onRequest ( ResolveCobolSubroutineRequestType , ( routineName : string ) : string => {
7070 const constantRoutinePaths : Partial < Record < string , string > > = {
71- 'assert-equals' : `${ Services . get ( ) . workspace . rootUri ?? 'file: /tmp/project' } /deps/assert-equals.cbl`
71+ 'assert-equals' : `file: ${ vscode . workspace . rootPath ?? '/tmp/project' } /deps/assert-equals.cbl`
7272 }
7373 const contantRoutinePath = constantRoutinePaths [ routineName . toLowerCase ( ) ]
7474 if ( contantRoutinePath != null ) {
7575 return contantRoutinePath
7676 }
77- return Services . get ( ) . workspace . textDocuments
78- . filter ( textDocument => Services . get ( ) . languages . match ( documentSelector , textDocument ) )
77+ return vscode . workspace . textDocuments
78+ . filter ( textDocument => vscode . languages . match ( documentSelector , textDocument ) )
7979 . filter ( document => document . getText ( ) . match ( new RegExp ( `PROGRAM-ID\\.\\W+${ routineName } \\.` , 'gi' ) ) )
80- . sort ( ( a , b ) => a . uri . localeCompare ( b . uri ) ) [ 0 ] ?. uri
80+ . sort ( ( a , b ) => a . uri . toString ( ) . localeCompare ( b . uri . toString ( ) ) ) [ 0 ] ?. uri . toString ( )
8181 } )
8282 }
8383
@@ -131,9 +131,9 @@ export class FileSystemFeature implements StaticFeature {
131131 }
132132 } ) )
133133 disposableCollection . push ( getServices ( ) . workspace . registerSaveDocumentHandler ( {
134- async saveTextContent ( textDocument , reason ) {
135- if ( languageClientManager . isModelManaged ( textDocument ) ) {
136- await infrastructure . saveFileContent ?.( textDocument , reason , languageClientManager )
134+ async saveTextContent ( document , reason ) {
135+ if ( languageClientManager . isModelManaged ( document ) ) {
136+ await infrastructure . saveFileContent ?.( document , reason , languageClientManager )
137137 }
138138 }
139139 } ) )
0 commit comments