Skip to content

Commit fff8824

Browse files
committed
Support for Creating classes and routines on isfs
1 parent a5121f0 commit fff8824

File tree

1 file changed

+61
-8
lines changed

1 file changed

+61
-8
lines changed

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,76 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
104104
if (fileName.startsWith(".")) {
105105
return;
106106
}
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+
);
114158
}
115159

116160
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 }));
118169
}
119170

120171
public rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean }): void | Thenable<void> {
172+
throw new Error("Not implemented");
121173
return;
122174
}
123175
public copy?(source: vscode.Uri, destination: vscode.Uri, options: { overwrite: boolean }): void | Thenable<void> {
176+
throw new Error("Not implemented");
124177
return;
125178
}
126179

0 commit comments

Comments
 (0)