1
- import vscode = require( " vscode" ) ;
1
+ import vscode = require( ' vscode' ) ;
2
2
const { workspace, window } = vscode ;
3
- import http = require( " http" ) ;
3
+ import http = require( ' http' ) ;
4
4
5
- const API = require ( " cos-api4node" ) ;
6
- const LOG = require ( " ./log" ) ;
7
- const panel = require ( " ./status-bar-panel" ) ;
8
- const CmdExport = require ( " ./commands/export" ) ;
9
- const { CurrentDoc } = require ( " ./commands/currentdoc" ) ;
10
- const IsApiError = require ( " ./is-api-error" ) ;
5
+ const API = require ( ' cos-api4node' ) ;
6
+ const LOG = require ( ' ./log' ) ;
7
+ const panel = require ( ' ./status-bar-panel' ) ;
8
+ const CmdExport = require ( ' ./commands/export' ) ;
9
+ const { CurrentDoc } = require ( ' ./commands/currentdoc' ) ;
10
+ const IsApiError = require ( ' ./is-api-error' ) ;
11
11
12
- import { COSExplorerProvider } from "./explorer/explorer" ;
12
+ import { ObjectScriptSymbolProvider } from './providers/ObjectScriptSymbolProvider' ;
13
+
14
+ import { COSExplorerProvider } from './explorer/explorer' ;
13
15
export var cosExplorerProvider : COSExplorerProvider ;
14
16
15
17
export async function activate ( context : vscode . ExtensionContext ) : Promise < void > {
16
- const languages = require ( context . asAbsolutePath ( " ./package.json" ) ) [ " contributes" ] [ " languages" ] . map ( lang => lang . id ) ;
18
+ const languages = require ( context . asAbsolutePath ( ' ./package.json' ) ) [ ' contributes' ] [ ' languages' ] . map ( lang => lang . id ) ;
17
19
18
20
const log = LOG ( window ) ;
19
21
20
22
cosExplorerProvider = new COSExplorerProvider ( ) ;
21
- vscode . window . registerTreeDataProvider ( " cosExplorer" , cosExplorerProvider ) ;
23
+ vscode . window . registerTreeDataProvider ( ' cosExplorer' , cosExplorerProvider ) ;
22
24
23
25
const Config = workspace => {
24
26
let options = null ;
25
27
const init = ( ) => {
26
- options = workspace . getConfiguration ( " cos" ) ;
28
+ options = workspace . getConfiguration ( ' cos' ) ;
27
29
} ;
28
30
init ( ) ;
29
31
30
32
return {
31
33
init,
32
34
get : option => options . get ( option ) ,
33
35
conn : ( ) => {
34
- const _conn = options . get ( " conn" ) ;
35
- _conn . toString = ( ) => JSON . stringify ( Object . assign ( { } , _conn , { password : " ***" } ) , null , 4 ) ;
36
+ const _conn = options . get ( ' conn' ) ;
37
+ _conn . toString = ( ) => JSON . stringify ( Object . assign ( { } , _conn , { password : ' ***' } ) , null , 4 ) ;
36
38
return _conn ;
37
39
} ,
38
40
export : ( ) => {
39
41
const root = workspace . rootPath ;
40
- return Object . assign ( { } , options . get ( " export" ) , { root } ) ;
42
+ return Object . assign ( { } , options . get ( ' export' ) , { root } ) ;
41
43
}
42
44
} ;
43
45
} ;
@@ -47,8 +49,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
47
49
api = API ( conn ) ;
48
50
api . headServer ( err => {
49
51
const conn = config . conn ( ) ;
50
- if ( err ) return log ( " Connection FAILED: " + conn , err ) ;
51
- log ( " Connected " + conn ) ;
52
+ if ( err ) return log ( ' Connection FAILED: ' + conn , err ) ;
53
+ log ( ' Connected ' + conn ) ;
52
54
panel . set ( conn ) ;
53
55
} ) ;
54
56
cosExplorerProvider . setAPI ( api , conn . ns ) ;
@@ -77,7 +79,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
77
79
) ; //reload config on event
78
80
79
81
workspace . onDidSaveTextDocument ( file => {
80
- if ( ! config . get ( " autoCompile" ) ) {
82
+ if ( ! config . get ( ' autoCompile' ) ) {
81
83
return ;
82
84
}
83
85
if ( languages . includes ( file . languageId ) ) {
@@ -89,18 +91,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
89
91
90
92
const Save = ( { name, log, fileName } ) => ( err , data ) => {
91
93
// IsApiError, ExportDoc - global
92
- const isGetDocError = IsApiError ( name , " getDoc" , log , window ) ;
94
+ const isGetDocError = IsApiError ( name , ' getDoc' , log , window ) ;
93
95
if ( isGetDocError ( { err, data } ) ) return ;
94
96
95
- const completed = ( ) => log ( " Completed." ) ;
97
+ const completed = ( ) => log ( ' Completed.' ) ;
96
98
const exportDoc = ExportDoc ( { name, cat : data . result . cat , fileName } , completed ) ;
97
99
98
100
exportDoc ( { err, data } ) ;
99
101
} ;
100
102
101
103
const Export = ( { api, name, log, fileName } ) => ( err , data ) => {
102
104
// IsApiError, Save - from upper scope
103
- const isCompileError = IsApiError ( name , " compile" , log , window ) ;
105
+ const isCompileError = IsApiError ( name , ' compile' , log , window ) ;
104
106
if ( isCompileError ( { err, data } ) ) return ;
105
107
// after compilation API returns updated storage definition
106
108
// but, currently, we don`t have any AST implementation
@@ -113,7 +115,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
113
115
114
116
const Compile = ( { api, name, log, fileName } ) => ( err , data ) => {
115
117
// IsApiError, Export
116
- const isImportError = IsApiError ( name , " import" , log , window ) ;
118
+ const isImportError = IsApiError ( name , ' import' , log , window ) ;
117
119
if ( isImportError ( { err, data } ) ) return ;
118
120
119
121
const exportCurrent = Export ( { api, name, log, fileName } ) ;
@@ -135,21 +137,27 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
135
137
} ;
136
138
137
139
context . subscriptions . push (
138
- vscode . commands . registerCommand ( " cos.compile" , importCompileExport ) ,
139
- vscode . commands . registerCommand ( " cos.export" , exportAll ) ,
140
- vscode . commands . registerCommand ( " vscode-cos.explorer.refresh" , ( ) => cosExplorerProvider . refresh ( ) ) ,
141
- vscode . commands . registerCommand ( " vscode-cos.explorer.openClass" , vscode . window . showTextDocument ) ,
142
- vscode . commands . registerCommand ( " vscode-cos.explorer.openRoutine" , vscode . window . showTextDocument ) ,
143
- vscode . commands . registerCommand ( " vscode-cos.explorer.showSystem" , ( ) => {
144
- vscode . commands . executeCommand ( " setContext" , " vscode-cos.explorer.showSystem" , true ) ;
140
+ vscode . commands . registerCommand ( ' cos.compile' , importCompileExport ) ,
141
+ vscode . commands . registerCommand ( ' cos.export' , exportAll ) ,
142
+ vscode . commands . registerCommand ( ' vscode-cos.explorer.refresh' , ( ) => cosExplorerProvider . refresh ( ) ) ,
143
+ vscode . commands . registerCommand ( ' vscode-cos.explorer.openClass' , vscode . window . showTextDocument ) ,
144
+ vscode . commands . registerCommand ( ' vscode-cos.explorer.openRoutine' , vscode . window . showTextDocument ) ,
145
+ vscode . commands . registerCommand ( ' vscode-cos.explorer.showSystem' , ( ) => {
146
+ vscode . commands . executeCommand ( ' setContext' , ' vscode-cos.explorer.showSystem' , true ) ;
145
147
cosExplorerProvider . showSystem = true ;
146
148
} ) ,
147
- vscode . commands . registerCommand ( " vscode-cos.explorer.hideSystem" , ( ) => {
148
- vscode . commands . executeCommand ( " setContext" , " vscode-cos.explorer.showSystem" , false ) ;
149
+ vscode . commands . registerCommand ( ' vscode-cos.explorer.hideSystem' , ( ) => {
150
+ vscode . commands . executeCommand ( ' setContext' , ' vscode-cos.explorer.showSystem' , false ) ;
149
151
cosExplorerProvider . showSystem = false ;
150
152
} ) ,
151
153
152
- vscode . workspace . registerTextDocumentContentProvider ( "cos" , cosExplorerProvider )
154
+ vscode . workspace . registerTextDocumentContentProvider ( 'cos' , cosExplorerProvider ) ,
155
+ vscode . languages . registerDocumentSymbolProvider (
156
+ {
157
+ language : 'cacheobjectscript'
158
+ } ,
159
+ new ObjectScriptSymbolProvider ( )
160
+ )
153
161
) ;
154
162
}
155
163
0 commit comments