diff --git a/package.json b/package.json index 228f4177..0d67c555 100644 --- a/package.json +++ b/package.json @@ -206,6 +206,10 @@ "when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive", "group": "objectscript@2" }, + { + "command": "vscode-objectscript.studio.actions", + "when": "resourceScheme == isfs && vscode-objectscript.connectActive" + }, { "command": "vscode-objectscript.previewXml", "when": "editorLangId =~ /^xml/", diff --git a/src/api/index.ts b/src/api/index.ts index d305249d..e5790389 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -24,6 +24,16 @@ export class AtelierAPI { return workspaceState.get(this.workspaceFolder + ":iris", false); } + private transformNameIfCsp(filename: string): string { + // If a CSP file, change from + // \csp\user\... to + // csp/user/... + if (filename.startsWith("\\")) { + return filename.substring(1).replace(/\\/g, "/"); + } + return filename; + } + public constructor(wsOrFile?: string | vscode.Uri) { let workspaceFolderName = ""; if (wsOrFile) { @@ -265,6 +275,7 @@ export class AtelierAPI { format, }; } + name = this.transformNameIfCsp(name); return this.request(1, "GET", `${this.ns}/doc/${name}`, params); } // api v1+ @@ -274,6 +285,7 @@ export class AtelierAPI { // v1+ public putDoc(name: string, data: { enc: boolean; content: string[] }, ignoreConflict?: boolean): Promise { const params = { ignoreConflict }; + name = this.transformNameIfCsp(name); return this.request(1, "PUT", `${this.ns}/doc/${name}`, data, params); } // v1+ @@ -315,6 +327,7 @@ export class AtelierAPI { } // v1+ public actionCompile(docs: string[], flags?: string, source = false): Promise { + docs = docs.map((doc) => this.transformNameIfCsp(doc)); return this.request(1, "POST", `${this.ns}/action/compile`, docs, { flags, source, diff --git a/src/explorer/models/rootNode.ts b/src/explorer/models/rootNode.ts index 2197fc2a..bfbcf255 100644 --- a/src/explorer/models/rootNode.ts +++ b/src/explorer/models/rootNode.ts @@ -9,11 +9,20 @@ import { ClassNode } from "./classesNode"; export class RootNode extends NodeBase { public readonly contextValue: string; private readonly _category: string; + private readonly isCsp: boolean; - public constructor(label: string, fullName: string, contextValue: string, category: string, options: NodeOptions) { + public constructor( + label: string, + fullName: string, + contextValue: string, + category: string, + options: NodeOptions, + isCsp = false + ) { super(label, fullName, options); this.contextValue = contextValue; this._category = category; + this.isCsp = isCsp; } public get category(): string { @@ -29,7 +38,7 @@ export class RootNode extends NodeBase { } public async getChildren(element): Promise { - const path = this instanceof PackageNode ? this.fullName + "/" : ""; + const path = this instanceof PackageNode || this.isCsp ? this.fullName + "/" : ""; return this.getItems(path, this._category); } @@ -42,7 +51,7 @@ export class RootNode extends NodeBase { spec = "*.cls"; break; case "RTN": - spec = "*.mac,*.int"; + spec = "*.mac,*.int,*.bas"; break; case "INC": spec = "*.inc"; @@ -50,6 +59,12 @@ export class RootNode extends NodeBase { case "ALL": spec = "*.cls,*.mac,*.int,*.inc"; break; + case "CSP": + spec = "*"; + break; + case "OTH": + spec = "*"; + break; default: return; } @@ -72,7 +87,12 @@ export class RootNode extends NodeBase { }) .then((data) => data.map((el) => { - const fullName = (this instanceof PackageNode ? this.fullName + "." : "") + el.Name; + let fullName = el.Name; + if (this instanceof PackageNode) { + fullName = this.fullName + "." + el.Name; + } else if (this.isCsp) { + fullName = this.fullName + "/" + el.Name; + } return { ...el, fullName, @@ -84,16 +104,31 @@ export class RootNode extends NodeBase { public getItems(path: string, category: string): Promise { return this.getList(path, category, false).then((data) => data + .filter((el) => { + if (category === "OTH") { + return el.Type === "100"; + } else if (category === "CSP") { + return el.Type === "10" || el.Type === "5"; + } else { + return true; + } + }) .map((el) => { switch (el.Type) { case "9": return new PackageNode(el.Name, el.fullName, category, this.options); case "4": + case "5": + case "100": return new ClassNode(el.Name, el.fullName, this.options); case "0": case "1": case "2": + case "3": + case "11": return new RoutineNode(el.Name, el.fullName, this.options); + case "10": + return new RootNode(el.Name, el.fullName, "dataNode:CSPApplication", this._category, this.options, true); default: return null; } diff --git a/src/explorer/models/workspaceNode.ts b/src/explorer/models/workspaceNode.ts index 00635bb1..95e80276 100644 --- a/src/explorer/models/workspaceNode.ts +++ b/src/explorer/models/workspaceNode.ts @@ -35,6 +35,12 @@ export class WorkspaceNode extends NodeBase { node = new RootNode("Includes", "", "dataRootNode:routinesRootNode", "INC", this.options); children.push(node); + node = new RootNode("CSP Files", "", "dataRootNode:cspRootNode", "CSP", this.options); + children.push(node); + + node = new RootNode("Other", "", "dataRootNode:otherRootNode", "OTH", this.options); + children.push(node); + return children; } } diff --git a/src/providers/DocumentContentProvider.ts b/src/providers/DocumentContentProvider.ts index a88886cd..5dddc438 100644 --- a/src/providers/DocumentContentProvider.ts +++ b/src/providers/DocumentContentProvider.ts @@ -61,10 +61,17 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid }); } } + const isCsp = name.includes("/"); if (namespace && namespace !== "") { - uri = uri.with({ - query: `ns=${namespace}`, - }); + if (isCsp) { + uri = uri.with({ + query: `ns=${namespace}&csp=1`, + }); + } else { + uri = uri.with({ + query: `ns=${namespace}`, + }); + } } return uri; } diff --git a/src/utils/index.ts b/src/utils/index.ts index 714ed43f..934a1f10 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -53,13 +53,15 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile { if (match) { [, name, ext = "cls"] = match; } - } else { + } else if (fileExt.match(/(mac|int|inc)/i)) { const match = content.match(/^ROUTINE ([^\s]+)(?:\s*\[\s*Type\s*=\s*\b([a-z]{3})\b)?/i); if (match) { [, name, ext = "mac"] = match; } else { [name, ext = "mac"] = path.basename(document.fileName).split("."); } + } else { + name = fileName; } if (!name) { return null;