'use strict' ; import * as vscode from 'vscode' ; import * as cp from 'child_process' ; import * as rpc from 'vscode-jsonrpc' ; import { ToolsDocumentSymbolsRequest } from './toolsDocumentSymbolsRequest' ; import { ToolsDocumentSymbolsResponse } from './toolsDocumentSymbolsResponse' ; import { ToolsPackageSymbolsRequest } from './toolsPackageSymbolsRequest' ; import { ToolsPackageSymbolsResponse } from './toolsPackageSymbolsResponse' ; import { ToolsProjectSymbolsRequest } from './toolsProjectSymbolsRequest' ; import { ToolsProjectSymbolsResponse } from './toolsProjectSymbolsResponse' ; import { ToolsLibrarySymbolsDetailsRequest } from './toolsLibrarySymbolsDetailsRequest' ; import { ToolsLibrarySymbolsDetailsResponse } from './toolsLibrarySymbolsDetailsResponse' ; import { ToolsCloseSymbolsLibraryRequest } from './toolsCloseSymbolsLibraryRequest' ; import { ToolsGetSyntaxTreeRequest } from './toolsGetSyntaxTreeRequest' ; import { ToolsGetSyntaxTreeResponse } from './toolsGetSyntaxTreeResponse' ; import { ToolsGetSyntaxTreeSymbolResponse } from './toolsGetSyntaxTreeSymbolResponse' ; import { ToolsGetSyntaxTreeSymbolsRequest } from './toolsGetSyntaxTreeSymbolRequest' ; import { ToolsCloseSyntaxTreeRequest } from './toolsCloseSyntaxTreeRequest' ; import { ToolsGetCodeAnalyzersRulesRequest } from './toolsGetCodeAnalyzersRulesRequest' ; import { ToolsGetCodeAnalyzersRulesResponse } from './toolsGetCodeAnalyzersRulesResponse' ; import { ToolsGetFullSyntaxTreeRequest } from './toolsGetFullSyntaxTreeRequest' ; import { ToolsGetFullSyntaxTreeResponse } from './toolsGetFullSyntaxTreeResponse' ; import { ALFullSyntaxTreeHelper } from '../symbollibraries/alFullSyntaxTreeHelper' ; import { ToolsWorkspaceCommandRequest } from './toolsWorkspaceCommandRequest' ; import { ToolsWorkspaceCommandResponse } from './toolsWorkspaceCommandResponse' ; import { Version } from '../tools/version' ; import { ToolsWorkspaceFoldersChangeRequest } from './toolsWorkspaceFoldersChangeRequest' ; import { ToolsDocumentChangeRequest } from './toolsDocumentChangeRequest' ; import { ToolsFilesRequest } from './toolsFilesRequest' ; import { ToolsFilesRenameRequest } from './toolsFilesRenameRequest' ; import { ToolsGetTableFieldsListRequest } from './symbolsinformation/toolsGetTableFieldsListRequest' ; import { ToolsSymbolInformationRequest } from './symbolsinformation/toolsSymbolInformationRequest' ; import { ToolsGetTablesListResponse } from './symbolsinformation/toolsGetTablesListResponse' ; import { ToolsGetCodeunitsListResponse } from './symbolsinformation/toolsGetCodeunitsListResponse' ; import { ToolsGetEnumsListResponse } from './symbolsinformation/toolsGetEnumsListResponse' ; import { ToolsGetInterfacesListResponse } from './symbolsinformation/toolsGetInterfacesListResponse' ; import { ToolsFileSystemFileChangeRequest } from './toolsFileSystemFileChangeRequest' ; import { ToolsGetTableFieldsListResponse } from './symbolsinformation/toolsGetTableFieldsListResponse' ; import { ToolsGetPageDetailsRequest } from './symbolsinformation/toolsGetPageDetailsRequest' ; import { ToolsGetPageDetailsResponse } from './symbolsinformation/toolsGetPageDetailsResponse' ; import { ToolsDocumentContentChangeRequest } from './toolsDocumentContentChangeRequest' ; import { ToolsDocumentContentChangeResponse } from './toolsDocumentContentChangeResponse' ; import { ToolsGetXmlPortTableElementDetailsRequest } from './symbolsinformation/toolsGetXmlPortTableElementDetailsRequest' ; import { toolsGetXmlPortTableElementDetailsResponse } from './symbolsinformation/toolsGetXmlPortTableElementDetailsResponse' ; import { ToolsGetReportDataItemDetailsRequest } from './symbolsinformation/toolsGetReportDataItemDetailsRequest' ; import { ToolsGetReportDataItemDetailsResponse } from './symbolsinformation/toolsGetReportDataItemDetailsResponse' ; import { ToolsGetQueryDataItemDetailsRequest } from './symbolsinformation/toolsGetQueryDataItemDetailsRequest' ; import { ToolsGetQueryDataItemDetailsResponse } from './symbolsinformation/toolsGetQueryDataItemDetailsResponse' ; import { ToolsGetPagesListResponse } from './symbolsinformation/toolsGetPagesListResponse' ; import { ToolsGetReportsListResponse } from './symbolsinformation/toolsGetReportsListResponse' ; import { ToolsGetQueriesListResponse } from './symbolsinformation/toolsGetQueriesListResponse' ; import { ToolsGetXmlPortsListResponse } from './symbolsinformation/toolsGetXmlPortsListResponse' ; import { ToolsGetProjectSettingsRequest } from './toolsGetProjectSettingsRequest' ; import { ToolsGetProjectSettingsResponse } from './toolsGetProjectSettingsResponse' ; import { ToolsGetLibrarySymbolLocationRequest } from './toolsGetLibrarySymbolLocationRequest' ; import { ToolsGetLibrarySymbolLocationResponse } from './toolsGetLibrarySymbolLocationResponse' ; import { ToolsGetALAppContentRequest } from './toolsGetALAppContentRequest' ; import { ToolsGetALAppContentResponse } from './toolsGetALAppContentResponse' ; import { ToolsGetImagesRequest } from './languageInformation/toolsGetImagesRequest' ; import { ToolsGetImagesResponse } from './languageInformation/toolsGetImagesResponse' ; import { ToolsGetProjectSymbolLocationRequest } from './toolsGetProjectSymbolLocationRequest' ; import { ToolsGetProjectSymbolLocationResponse } from './toolsGetProjectSymbolLocationResponse' ; import { ToolsGetNextObjectIdRequest } from './symbolsinformation/toolsGetNextObjectIdRequest' ; import { ToolsGetNextObjectIdResponse } from './symbolsinformation/toolsGetNextObjectIdResponse' ; import { ToolsGetObjectsListRequest } from './symbolsinformation/toolsGetObjectsListRequest' ; import { ToolsGetObjectsListResponse } from './symbolsinformation/toolsGetObjectsListResponse' ; import { ToolsGetPermissionSetsListResponse } from './symbolsinformation/toolsGetPermissionSetsListResponse' ; import { ToolsGetReportDetailsRequest } from './symbolsinformation/toolsGetReportDetailsRequest' ; import { ToolsGetReportDetailsResponse } from './symbolsinformation/toolsGetReportDetailsResponse' ; import { toolsGetInterfaceMethodsListRequest } from './symbolsinformation/toolsGetInterfaceMethodsListRequest' ; import { ToolsGetInterfaceMethodsListResponse } from './symbolsinformation/toolsGetInterfaceMethodsListResponse' ; import { ToolsGetDependenciesListRequest } from './symbolsinformation/toolsGetDependenciesListRequest' ; import { ToolsGetDependenciesListResponse } from './symbolsinformation/toolsGetDependenciesListResponse' ; import { ToolsGetPageFieldAvailableToolTipsRequest } from './symbolsinformation/toolsGetPageFieldAvailableToolTipsRequest' ; import { ToolsGetPageFieldAvailableToolTipsResponse } from './symbolsinformation/toolsGetPageFieldAvailableToolTipsResponse' ; export class ToolsLangServerClient implements vscode . Disposable { _context : vscode . ExtensionContext ; _childProcess : cp . ChildProcess | undefined ; _connection : rpc . MessageConnection | undefined ; _alExtensionPath : string ; _alExtensionVersion : Version ; errorLogUri : vscode . Uri | undefined ; constructor ( context , alExtensionPath , alExtensionVersion ) { this . _context = context ; this . _childProcess = undefined ; this . _connection = undefined ; this . _alExtensionPath = alExtensionPath ; this . _alExtensionVersion = alExtensionVersion ; this . errorLogUri = undefined ; this . initialize ( ) ; } dispose ( ) { if ( this . _connection ) { this . exit ( ) ; this . _connection . dispose ( ) ; this . _connection = undefined ; } } protected initialize ( ) { try { let os = require ( 'os' ) ; let platform = os . platform ( ) ; let langServerPath ; if ( this . _alExtensionVersion . major <= 1 ) { langServerPath = this . _context . asAbsolutePath ( "bin/netframeworknav2018/AZALDevToolsServer.NetFrameworkNav2018.exe" ) ; this . errorLogUri = vscode . Uri . file ( this . _context . asAbsolutePath ( "bin/netframeworknav2018/log.txt" ) ) ; } else { langServerPath = this . _context . asAbsolutePath ( "bin/netcore/" + platform + "/AZALDevToolsServer.NetCore" ) ; this . errorLogUri = vscode . Uri . file ( this . _context . asAbsolutePath ( "bin/netcore/" + platform + "/log.txt" ) ) ; if ( platform == "darwin" ) { let fs = require ( 'fs' ) ; fs . chmodSync ( langServerPath , 0o755 ) ; } } this . _childProcess = cp . spawn ( langServerPath , [ this . _alExtensionPath ] ) ; if ( this . _childProcess ) { let stdOutStream = this . _childProcess . stdout ; let stdInStream = this . _childProcess . stdin ; if ( ( stdOutStream != null ) && ( stdInStream != null ) ) { this . _connection = rpc . createMessageConnection ( new rpc . StreamMessageReader ( stdOutStream ) , new rpc . StreamMessageWriter ( stdInStream ) ) ; this . _connection . listen ( ) ; } } } catch ( e ) { } } public async getALDocumentSymbols ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsDocumentSymbolsRequest , ToolsDocumentSymbolsResponse , void , void > ( 'al/documentsymbols' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public async getAppPackageSymbols ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsPackageSymbolsRequest , ToolsPackageSymbolsResponse , void , void > ( 'al/packagesymbols' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public async getProjectSymbols ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsProjectSymbolsRequest , ToolsProjectSymbolsResponse , void , void > ( 'al/projectsymbols' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public async getLibrarySymbolsDetails ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsLibrarySymbolsDetailsRequest , ToolsLibrarySymbolsDetailsResponse , void , void > ( 'al/librarysymbolsdetails' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public closeSymbolsLibrary ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . NotificationType < ToolsCloseSymbolsLibraryRequest , void > ( 'al/closesymbolslibrary' ) ; ; this . _connection . sendNotification ( reqType , params ) ; } catch ( e ) { } } public async getSyntaxTree ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsGetSyntaxTreeRequest , ToolsGetSyntaxTreeResponse , void , void > ( 'al/getsyntaxtree' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public async getSyntaxTreeSymbol ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsGetSyntaxTreeSymbolsRequest , ToolsGetSyntaxTreeSymbolResponse , void , void > ( 'al/getsyntaxtreesymbol' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public closeSyntaxTree ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . NotificationType < ToolsCloseSyntaxTreeRequest , void > ( 'al/closesyntaxtree' ) ; ; this . _connection . sendNotification ( reqType , params ) ; } catch ( e ) { } } public async getFullSyntaxTree ( params , restoreParent ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsGetFullSyntaxTreeRequest , ToolsGetFullSyntaxTreeResponse , void , void > ( 'al/getfullsyntaxtree' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; if ( ( restoreParent ) && ( val ) && ( val . root ) ) ALFullSyntaxTreeHelper . restoreNodeParent ( val . root , undefined ) ; return val ; } catch ( e ) { return undefined ; } } public async getCodeAnalyzersRules ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsGetCodeAnalyzersRulesRequest , ToolsGetCodeAnalyzersRulesResponse , void , void > ( 'al/getcodeanalyzersrules' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public async workspaceCommand ( params ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < ToolsWorkspaceCommandRequest , ToolsWorkspaceCommandResponse , void , void > ( 'al/workspacecommand' ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public exit ( ) { this . sendNotification ( { } , 'exit' ) ; } public getLibrarySymbolLocation ( params ) { return this . sendRequest < ToolsGetLibrarySymbolLocationRequest , ToolsGetLibrarySymbolLocationResponse > ( params , 'al/librarysymbollocation' ) ; } public getProjectSymbolLocation ( params ) { return this . sendRequest < ToolsGetProjectSymbolLocationRequest , ToolsGetProjectSymbolLocationResponse > ( params , 'al/projectsymbollocation' ) ; } public getALAppContent ( params ) { return this . sendRequest < ToolsGetALAppContentRequest , ToolsGetALAppContentResponse > ( params , 'al/getalappcontent' ) ; } public getObjectsList ( params ) { return this . sendRequest < ToolsGetObjectsListRequest , ToolsGetObjectsListResponse > ( params , 'al/getobjectslist' ) ; } public getTablesList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetTablesListResponse > ( params , 'al/gettableslist' ) ; } public getCodeunitsList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetCodeunitsListResponse > ( params , 'al/getcodeunitslist' ) ; } public getEnumsList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetEnumsListResponse > ( params , 'al/getenumslist' ) ; } public getInterfacesList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetInterfacesListResponse > ( params , 'al/getinterfaceslist' ) ; } public getInterfaceMethodsList ( params ) { return this . sendRequest < toolsGetInterfaceMethodsListRequest , ToolsGetInterfaceMethodsListResponse > ( params , 'al/getinterfacemethodslist' ) ; } public getPagesList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetPagesListResponse > ( params , 'al/getpageslist' ) ; } public getReportsList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetReportsListResponse > ( params , 'al/getreportslist' ) ; } public getQueriesList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetQueriesListResponse > ( params , 'al/getquerieslist' ) ; } public getXmlPortsList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetXmlPortsListResponse > ( params , 'al/getxmlportslist' ) ; } public getPermissionSetsList ( params ) { return this . sendRequest < ToolsSymbolInformationRequest , ToolsGetPermissionSetsListResponse > ( params , 'al/getpermissionsetslist' ) ; } public getTableFieldsList ( params ) { return this . sendRequest < ToolsGetTableFieldsListRequest , ToolsGetTableFieldsListResponse > ( params , 'al/gettablefieldslist' ) ; } public getPageDetails ( params ) { return this . sendRequest < ToolsGetPageDetailsRequest , ToolsGetPageDetailsResponse > ( params , 'al/getpagedetails' ) ; } public getXmlPortTableElementDetails ( params ) { return this . sendRequest < ToolsGetXmlPortTableElementDetailsRequest , toolsGetXmlPortTableElementDetailsResponse > ( params , 'al/getxmlporttableelementdetails' ) ; } public getReportDataItemDetails ( params ) { return this . sendRequest < ToolsGetReportDataItemDetailsRequest , ToolsGetReportDataItemDetailsResponse > ( params , 'al/getreportdataitemdetails' ) ; } public getReportDetails ( params ) { return this . sendRequest < ToolsGetReportDetailsRequest , ToolsGetReportDetailsResponse > ( params , 'al/getreportdetails' ) ; } public getQueryDataItemDetails ( params ) { return this . sendRequest < ToolsGetQueryDataItemDetailsRequest , ToolsGetQueryDataItemDetailsResponse > ( params , 'al/getquerydataitemdetails' ) ; } public getProjectSettings ( params ) { return this . sendRequest < ToolsGetProjectSettingsRequest , ToolsGetProjectSettingsResponse > ( params , 'al/getprojectsettings' ) ; } public getDependenciesList ( params ) { return this . sendRequest < ToolsGetDependenciesListRequest , ToolsGetDependenciesListResponse > ( params , 'al/getdependencieslist' ) ; } public getPageFieldAvailableToolTips ( params ) { return this . sendRequest < ToolsGetPageFieldAvailableToolTipsRequest , ToolsGetPageFieldAvailableToolTipsResponse > ( params , 'al/getpagefieldtooltips' ) ; } public async getNextObjectId ( path , objectType ) { let response = await this . sendRequest < ToolsGetNextObjectIdRequest , ToolsGetNextObjectIdResponse > ( new ToolsGetNextObjectIdRequest ( path , objectType ) , 'al/getnextobjectid' ) ; if ( ( response ) && ( response . id ) ) return response . id ; return 0 ; } public getImages ( params ) { return this . sendRequest < ToolsGetImagesRequest , ToolsGetImagesResponse > ( params , "al/getimages" ) ; } public workspaceFolderChange ( params ) { this . sendNotification ( params , 'ws/workspaceFoldersChange' ) ; } public async documentOpen ( params ) { this . sendNotification ( params , "ws/documentOpen" ) ; } public async documentChange ( params ) { return this . sendRequest < ToolsDocumentContentChangeRequest , ToolsDocumentContentChangeResponse > ( params , "ws/documentContentChange" ) ; } public async documentSave ( params ) { this . sendNotification ( params , "ws/documentSave" ) ; } public documentClose ( params ) { this . sendNotification ( params , "ws/documentClose" ) ; } public fileCreate ( params ) { this . sendNotification ( params , "ws/fileCreate" ) ; } public fileDelete ( params ) { this . sendNotification ( params , "ws/fileDelete" ) ; } public fileRename ( params ) { this . sendNotification ( params , "ws/fileRename" ) ; } public async fileSystemFileChange ( params ) { this . sendNotification ( params , "ws/fsFileChange" ) ; } public async fileSystemFileCreate ( params ) { this . sendNotification ( params , "ws/fsFileCreate" ) ; } public async fileSystemFileDelete ( params ) { this . sendNotification ( params , "ws/fsFileDelete" ) ; } protected sendNotification < T > ( params , command ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . NotificationType < T , void > ( command ) ; this . _connection . sendNotification ( reqType , params ) ; } catch ( e ) { } } protected async sendRequest < Req , Res > ( params , command ) { try { if ( ! this . _connection ) return undefined ; let reqType = new rpc . RequestType < Req , Res , void , void > ( command ) ; let val = await this . _connection . sendRequest ( reqType , params ) ; return val ; } catch ( e ) { return undefined ; } } public isEnabled ( ) { if ( this . _connection ) return true ; return false ; } }