@@ -104,23 +104,76 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
104
104
if ( fileName . startsWith ( "." ) ) {
105
105
return ;
106
106
}
107
- if ( options . create ) {
108
- return ;
109
- }
110
-
111
- return this . _lookupAsFile ( uri ) . then ( entry => {
112
- this . _fireSoon ( { type : vscode . FileChangeType . Changed , uri } ) ;
113
- } ) ;
107
+ const api = new AtelierAPI ( uri ) ;
108
+ return api
109
+ . actionIndex ( [ fileName ] )
110
+ . then ( data => data . result . content [ 0 ] )
111
+ . then ( info => {
112
+ if ( info . status === "" ) {
113
+ /// file found, everything is Ok
114
+ return ;
115
+ }
116
+ if ( options . create ) {
117
+ const fileExt = fileName
118
+ . split ( "." )
119
+ . pop ( )
120
+ . toLowerCase ( ) ;
121
+ if ( fileExt === "cls" ) {
122
+ const className = fileName
123
+ . split ( "." )
124
+ . slice ( 0 , - 1 )
125
+ . join ( "." ) ;
126
+ return api . putDoc (
127
+ fileName ,
128
+ {
129
+ content : [ `Class ${ className } {}` ] ,
130
+ enc : false ,
131
+ } ,
132
+ false
133
+ ) ;
134
+ } else if ( [ "int" , "inc" , "mac" ] . includes ( fileExt ) ) {
135
+ const api = new AtelierAPI ( uri ) ;
136
+ const routineName = fileName
137
+ . split ( "." )
138
+ . slice ( 0 , - 1 )
139
+ . join ( "." ) ;
140
+ const routineType = `[ type = ${ fileExt } ]` ;
141
+ return api . putDoc (
142
+ fileName ,
143
+ {
144
+ content : [ `ROUTINE ${ routineName } ${ routineType } ` ] ,
145
+ enc : false ,
146
+ } ,
147
+ false
148
+ ) ;
149
+ }
150
+ throw new Error ( "Not implemented" ) ;
151
+ }
152
+ } )
153
+ . then ( ( ) =>
154
+ this . _lookupAsFile ( uri ) . then ( entry => {
155
+ this . _fireSoon ( { type : vscode . FileChangeType . Changed , uri } ) ;
156
+ } )
157
+ ) ;
114
158
}
115
159
116
160
public delete ( uri : vscode . Uri , options : { recursive : boolean } ) : void | Thenable < void > {
117
- return ;
161
+ const { query } = url . parse ( decodeURIComponent ( uri . toString ( ) ) , true ) ;
162
+ const csp = query . csp === "" || query . csp === "1" ;
163
+ const fileName = csp ? uri . path : uri . path . slice ( 1 ) . replace ( / \/ / g, "." ) ;
164
+ if ( fileName . startsWith ( "." ) ) {
165
+ return ;
166
+ }
167
+ const api = new AtelierAPI ( uri ) ;
168
+ return api . deleteDoc ( fileName ) . then ( ( ) => this . _fireSoon ( { type : vscode . FileChangeType . Deleted , uri } ) ) ;
118
169
}
119
170
120
171
public rename ( oldUri : vscode . Uri , newUri : vscode . Uri , options : { overwrite : boolean } ) : void | Thenable < void > {
172
+ throw new Error ( "Not implemented" ) ;
121
173
return ;
122
174
}
123
175
public copy ?( source : vscode . Uri , destination : vscode . Uri , options : { overwrite : boolean } ) : void | Thenable < void > {
176
+ throw new Error ( "Not implemented" ) ;
124
177
return ;
125
178
}
126
179
0 commit comments