diff --git a/package.json b/package.json index f759360c..2329b124 100644 --- a/package.json +++ b/package.json @@ -95,14 +95,6 @@ ], "menus": { "commandPalette": [ - { - "command": "vscode-objectscript.touchBar.compile", - "when": "false" - }, - { - "command": "vscode-objectscript.touchBar.viewOthers", - "when": "false" - }, { "command": "vscode-objectscript.compile", "when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty" @@ -111,30 +103,14 @@ "command": "vscode-objectscript.refreshLocalFile", "when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty" }, - { - "command": "vscode-objectscript.compileWithFlags", - "when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty" - }, { "command": "vscode-objectscript.compileAll", "when": "vscode-objectscript.connectActive" }, - { - "command": "vscode-objectscript.compileAllWithFlags", - "when": "vscode-objectscript.connectActive" - }, { "command": "vscode-objectscript.viewOthers", "when": "vscode-objectscript.connectActive" }, - { - "command": "vscode-objectscript.subclass", - "when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive" - }, - { - "command": "vscode-objectscript.superclass", - "when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive" - }, { "command": "vscode-objectscript.previewXml", "when": "vscode-objectscript.connectActive && resourceExtname =~ /^\\.xml$/i && !(resourceScheme =~ /^isfs(-readonly)?$/)" @@ -215,10 +191,6 @@ "command": "vscode-objectscript.compileOnly", "when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty" }, - { - "command": "vscode-objectscript.compileOnlyWithFlags", - "when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty" - }, { "command": "vscode-objectscript.editOthers", "when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive" @@ -243,10 +215,6 @@ "command": "vscode-objectscript.exportProjectContents", "when": "workspaceFolderCount != 0" }, - { - "command": "vscode-objectscript.explorer.project.compileProjectContents", - "when": "false" - }, { "command": "vscode-objectscript.explorer.project.openOtherServerNs", "when": "false" @@ -450,11 +418,6 @@ "when": "view == ObjectScriptProjectsExplorer && viewItem == dataNode:projectNode", "group": "5_objectscript_prj@4" }, - { - "command": "vscode-objectscript.explorer.project.compileProjectContents", - "when": "view == ObjectScriptProjectsExplorer && viewItem == dataNode:projectNode", - "group": "5_objectscript_prj@6" - }, { "command": "vscode-objectscript.explorer.project.addWorkspaceFolderForProject", "when": "view == ObjectScriptProjectsExplorer && viewItem == dataNode:projectNode", @@ -552,18 +515,6 @@ "when": "resourceLangId =~ /^objectscript/ && vscode-objectscript.connectActive && activeCustomEditorId == ''" } ], - "touchBar": [ - { - "command": "vscode-objectscript.touchBar.compile", - "group": "objectscript.compile", - "when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty" - }, - { - "command": "vscode-objectscript.touchBar.viewOthers", - "group": "objectscript.viewOthers", - "when": "vscode-objectscript.connectActive" - } - ], "explorer/context": [ { "command": "vscode-objectscript.addServerNamespaceToWorkspace", @@ -848,21 +799,11 @@ "command": "vscode-objectscript.previewXml", "title": "Preview XML as UDL" }, - { - "category": "ObjectScript", - "command": "vscode-objectscript.compileWithFlags", - "title": "Import and Compile Current File with Specified Flags..." - }, { "category": "ObjectScript", "command": "vscode-objectscript.compileAll", "title": "Compile All Namespace Files" }, - { - "category": "ObjectScript", - "command": "vscode-objectscript.compileAllWithFlags", - "title": "Compile All Namespace Files with Specified Flags..." - }, { "command": "vscode-objectscript.explorer.export", "title": "Export", @@ -937,26 +878,6 @@ "enablement": "vscode-objectscript.connectActive", "title": "View Other" }, - { - "category": "ObjectScript", - "command": "vscode-objectscript.subclass", - "enablement": "vscode-objectscript.connectActive", - "title": "Go to Subclass..." - }, - { - "category": "ObjectScript", - "command": "vscode-objectscript.superclass", - "enablement": "vscode-objectscript.connectActive", - "title": "Go to Superclass..." - }, - { - "command": "vscode-objectscript.touchBar.compile", - "title": "➾¹₀⁰₁¹₀" - }, - { - "command": "vscode-objectscript.touchBar.viewOthers", - "title": "↹" - }, { "category": "ObjectScript", "command": "vscode-objectscript.serverActions", @@ -1014,11 +935,6 @@ "command": "vscode-objectscript.compileOnly", "title": "Compile Current File" }, - { - "category": "ObjectScript", - "command": "vscode-objectscript.compileOnlyWithFlags", - "title": "Compile Current File with Specified Flags..." - }, { "category": "ObjectScript", "command": "vscode-objectscript.editOthers", @@ -1070,11 +986,6 @@ "command": "vscode-objectscript.exportProjectContents", "title": "Export Project Contents from Server..." }, - { - "category": "ObjectScript", - "command": "vscode-objectscript.explorer.project.compileProjectContents", - "title": "Compile Project Contents" - }, { "category": "ObjectScript", "command": "vscode-objectscript.explorer.project.openOtherServerNs", diff --git a/src/commands/compile.ts b/src/commands/compile.ts index 1a4281d7..b4b1ed95 100644 --- a/src/commands/compile.ts +++ b/src/commands/compile.ts @@ -38,14 +38,6 @@ import { StudioActions } from "./studio"; import { NodeBase, PackageNode, RootNode } from "../explorer/nodes"; import { getUrisForDocument, updateIndex } from "../utils/documentIndex"; -async function compileFlags(): Promise { - const defaultFlags = config().compileFlags; - return vscode.window.showInputBox({ - prompt: "Compilation flags", - value: defaultFlags, - }); -} - /** * For files being locally edited, get and return its mtime timestamp from workspace-state cache if present there, * else get from server. May update cache. @@ -95,7 +87,7 @@ export async function importFile( ): Promise { if (!file) return; const api = new AtelierAPI(file.uri); - if (!api.active) return; + if (!api.active) return Promise.reject(); if (file.name.split(".").pop().toLowerCase() === "cls" && !skipDeplCheck) { if (await isClassDeployed(file.name, api)) { vscode.window.showErrorMessage(`Cannot import ${file.name} because it is deployed on the server.`, "Dismiss"); @@ -258,12 +250,11 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[] ); } -export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[], flags?: string): Promise { +export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[]): Promise { docs = docs.filter(notNull); if (!docs.length) return; const wsFolder = vscode.workspace.getWorkspaceFolder(docs[0].uri); - const conf = vscode.workspace.getConfiguration("objectscript", wsFolder || docs[0].uri); - flags = flags || conf.get("compileFlags"); + const flags = vscode.workspace.getConfiguration("objectscript", wsFolder || docs[0].uri).get("compileFlags"); const api = new AtelierAPI(docs[0].uri); const docNames = docs.map((d) => d.name); // Determine the line ending to use for other documents affected @@ -314,67 +305,44 @@ export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[], fla .then(loadChanges); } -export async function importAndCompile( - askFlags = false, - document?: vscode.TextDocument, - compileFile = true -): Promise { +export async function importAndCompile(document?: vscode.TextDocument): Promise { const file = currentFile(document); if (!file || filesystemSchemas.includes(file.uri.scheme) || !new AtelierAPI(file.uri).active) { // Not for server-side URIs or folders with inactive server connections return; } - const defaultFlags = config().compileFlags; - const flags = askFlags ? await compileFlags() : defaultFlags; - return importFile(file) - .catch((error) => { - throw error; - }) - .then(() => { - if (compileFile && isCompilable(file.name)) compile([file], flags); - }); + return ( + importFile(file) + .then(() => { + if (isCompilable(file.name)) compile([file]); + }) + // importFile handles any server errors + .catch(() => {}) + ); } -export async function compileOnly(askFlags = false, document?: vscode.TextDocument): Promise { +export async function compileOnly(document?: vscode.TextDocument): Promise { document = document || (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document ? vscode.window.activeTextEditor.document : null); - - if (!document) { - return; - } - + if (!document) return; const file = currentFile(document); - if (!file) { - return; - } - - // Do nothing if it is a local file and objectscript.conn.active is false - if (notIsfs(file.uri) && !config("conn").active) { - return; - } + if (!file || !new AtelierAPI(file.uri).active) return; if (document.isDirty) { // Don't compile if document is dirty - vscode.window.showWarningMessage( - "Cannot compile '" + file.name + "' because it has unpersisted changes.", - "Dismiss" - ); + vscode.window.showWarningMessage(`Cannot compile '${file.name}' because it has unpersisted changes.`, "Dismiss"); return; } - const defaultFlags = config().compileFlags; - const flags = askFlags ? await compileFlags() : defaultFlags; - if (isCompilable(file.name)) { - compile([file], flags); - } + if (isCompilable(file.name)) compile([file]); } // Compiles all files types in the namespace -export async function namespaceCompile(askFlags = false): Promise { +export async function namespaceCompile(): Promise { const api = new AtelierAPI(); const fileTypes = ["*.CLS", "*.MAC", "*.INC", "*.BAS"]; if (!api.active) return; @@ -387,12 +355,6 @@ export async function namespaceCompile(askFlags = false): Promise { // Don't compile without confirmation return; } - const defaultFlags = config().compileFlags; - const flags = askFlags ? await compileFlags() : defaultFlags; - if (flags === undefined) { - // User cancelled - return; - } vscode.window.withProgress( { cancellable: true, @@ -401,7 +363,7 @@ export async function namespaceCompile(askFlags = false): Promise { }, (progress, token: vscode.CancellationToken) => api - .asyncCompile(fileTypes, token, flags) + .asyncCompile(fileTypes, token, vscode.workspace.getConfiguration("objectscript").get("compileFlags")) .then((data) => { if (data.status && data.status.errors && data.status.errors.length) { throw new Error(`Compiling Namespace: ${api.ns} Error`); diff --git a/src/commands/project.ts b/src/commands/project.ts index cc565fb6..88590198 100644 --- a/src/commands/project.ts +++ b/src/commands/project.ts @@ -1,8 +1,8 @@ import * as vscode from "vscode"; import { AtelierAPI } from "../api"; -import { config, filesystemSchemas, projectsExplorerProvider } from "../extension"; +import { filesystemSchemas, projectsExplorerProvider } from "../extension"; import { isfsDocumentName } from "../providers/FileSystemProvider/FileSystemProvider"; -import { compileErrorMsg, getWsFolder, getWsServerConnection, handleError, notNull } from "../utils"; +import { getWsFolder, getWsServerConnection, handleError, notNull } from "../utils"; import { exportList } from "./export"; import { OtherStudioAction, StudioActions } from "./studio"; import { NodeBase, ProjectNode, ProjectRootNode, RoutineNode, CSPFileNode, ClassNode } from "../explorer/nodes"; @@ -918,38 +918,6 @@ export async function exportProjectContents(): Promise { } } -export async function compileProjectContents(node: ProjectNode): Promise { - const { workspaceFolderUri, namespace, label } = node; - const api = new AtelierAPI(workspaceFolderUri); - api.setNamespace(namespace); - const compileList: string[] = await api - .actionQuery( - "SELECT CASE WHEN Type = 'PKG' THEN Name||'.*.cls' WHEN Type = 'CLS' THEN Name||'.cls' ELSE Name END Name " + - "FROM %Studio.Project_ProjectItemsList(?,1) WHERE Type != 'GBL' AND Type != 'DIR' " + - "AND (Type != 'CSP' OR (Type = 'CSP' AND $PIECE(Name,'.',2) %INLIST $LISTFROMSTRING('csp,csr,CSP,CSR'))) " + - "UNION SELECT SUBSTR(sod.Name,2) AS Name FROM %Library.RoutineMgr_StudioOpenDialog('*.csp,*.csr',1,1,1,1,0,1) AS sod " + - "JOIN %Studio.Project_ProjectItemsList(?,1) AS pil ON pil.Type = 'DIR' AND sod.Name %STARTSWITH '/'||pil.Name||'/'", - [label, label] - ) - .then((data) => data.result.content.map((e) => e.Name)); - return vscode.window.withProgress( - { - cancellable: true, - location: vscode.ProgressLocation.Notification, - title: `Compiling project '${label}'`, - }, - (progress, token: vscode.CancellationToken) => - api - .asyncCompile(compileList, token, config().compileFlags) - .then((data) => { - if (data.status && data.status.errors && data.status.errors.length) { - throw new Error("Compile error"); - } - }) - .catch(() => compileErrorMsg()) - ); -} - /** * Returns the index of the first isfs folder in this workspace that is linked to `project`. */ diff --git a/src/commands/subclass.ts b/src/commands/subclass.ts deleted file mode 100644 index df4c5fc8..00000000 --- a/src/commands/subclass.ts +++ /dev/null @@ -1,40 +0,0 @@ -import * as vscode from "vscode"; -import { AtelierAPI } from "../api"; -import { DocumentContentProvider } from "../providers/DocumentContentProvider"; -import { currentFile } from "../utils"; -import { ClassDefinition } from "../utils/classDefinition"; - -export async function subclass(): Promise { - const file = currentFile(); - if (!file || !file.name.toLowerCase().endsWith(".cls")) { - return; - } - const className = file.name.split(".").slice(0, -1).join("."); - const api = new AtelierAPI(file.uri); - if (!api.active) { - return; - } - - const open = (item) => { - const uri = DocumentContentProvider.getUri(ClassDefinition.normalizeClassName(item, true)); - vscode.window.showTextDocument(uri); - }; - - return api - .actionQuery("CALL %Dictionary.ClassDefinitionQuery_SubclassOf(?)", [className]) - .then((data) => { - const list = data.result.content.slice(0, 100) || []; - if (!list.length) { - return; - } - vscode.window - .showQuickPick( - list.map((el) => el.Name), - { title: "Pick a subclass" } - ) - .then((item) => { - open(item); - }); - }) - .catch((err) => console.error(err)); -} diff --git a/src/commands/superclass.ts b/src/commands/superclass.ts deleted file mode 100644 index 2b230b03..00000000 --- a/src/commands/superclass.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as vscode from "vscode"; -import { config } from "../extension"; -import { DocumentContentProvider } from "../providers/DocumentContentProvider"; -import { currentFile, notIsfs } from "../utils"; -import { ClassDefinition } from "../utils/classDefinition"; - -export async function superclass(): Promise { - const file = currentFile(); - if (!file || !file.name.toLowerCase().endsWith(".cls") || (notIsfs(file.uri) && !config("conn").active)) { - return; - } - - const open = (item) => { - const uri = DocumentContentProvider.getUri(ClassDefinition.normalizeClassName(item, true)); - vscode.window.showTextDocument(uri); - }; - - const classDefinition = new ClassDefinition(file.name); - return classDefinition - .super() - .then((data) => { - const list = data || []; - if (!list.length) { - return; - } - vscode.window.showQuickPick(list, { title: "Pick a superclass" }).then((item) => { - open(item); - }); - }) - .catch((err) => console.error(err)); -} diff --git a/src/extension.ts b/src/extension.ts index 677022af..24a0e90a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -42,8 +42,6 @@ import { import { deleteExplorerItems } from "./commands/delete"; import { exportAll, exportCurrentFile, exportDocumentsToXMLFile, exportExplorerItems } from "./commands/export"; import { serverActions } from "./commands/serverActions"; -import { subclass } from "./commands/subclass"; -import { superclass } from "./commands/superclass"; import { viewOthers } from "./commands/viewOthers"; import { extractXMLFileContents, previewXMLAsUDL } from "./commands/xmlToUdl"; import { @@ -123,7 +121,6 @@ export let iscIcon: vscode.Uri; import { CodeActionProvider } from "./providers/CodeActionProvider"; import { addWorkspaceFolderForProject, - compileProjectContents, createProject, deleteProject, exportProjectContents, @@ -1126,23 +1123,11 @@ export async function activate(context: vscode.ExtensionContext): Promise { }), vscode.commands.registerCommand("vscode-objectscript.compile", () => { sendCommandTelemetryEvent("compile"); - importAndCompile(false); - }), - vscode.commands.registerCommand("vscode-objectscript.touchBar.compile", () => { - sendCommandTelemetryEvent("touchBar.compile"); - importAndCompile(false); - }), - vscode.commands.registerCommand("vscode-objectscript.compileWithFlags", () => { - sendCommandTelemetryEvent("compileWithFlags"); - importAndCompile(true); + importAndCompile(); }), vscode.commands.registerCommand("vscode-objectscript.compileAll", () => { sendCommandTelemetryEvent("compileAll"); - namespaceCompile(false); - }), - vscode.commands.registerCommand("vscode-objectscript.compileAllWithFlags", () => { - sendCommandTelemetryEvent("compileAllWithFlags"); - namespaceCompile(true); + namespaceCompile(); }), vscode.commands.registerCommand("vscode-objectscript.refreshLocalFile", async () => { sendCommandTelemetryEvent("refreshLocalFile"); @@ -1301,22 +1286,10 @@ export async function activate(context: vscode.ExtensionContext): Promise { sendCommandTelemetryEvent("serverCommands.contextOther"); contextCommandMenu(uri); }), - vscode.commands.registerCommand("vscode-objectscript.subclass", () => { - sendCommandTelemetryEvent("subclass"); - subclass(); - }), - vscode.commands.registerCommand("vscode-objectscript.superclass", () => { - sendCommandTelemetryEvent("superclass"); - superclass(); - }), vscode.commands.registerCommand("vscode-objectscript.serverActions", () => { sendCommandTelemetryEvent("serverActions"); serverActions(); }), - vscode.commands.registerCommand("vscode-objectscript.touchBar.viewOthers", () => { - sendCommandTelemetryEvent("touchBar.viewOthers"); - viewOthers(false); - }), vscode.commands.registerCommand("vscode-objectscript.explorer.refresh", () => { sendCommandTelemetryEvent("explorer.refresh"); explorerProvider.refresh(); @@ -1402,11 +1375,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { ), vscode.commands.registerCommand("vscode-objectscript.compileOnly", () => { sendCommandTelemetryEvent("compileOnly"); - compileOnly(false); - }), - vscode.commands.registerCommand("vscode-objectscript.compileOnlyWithFlags", () => { - sendCommandTelemetryEvent("compileOnlyWithFlags"); - compileOnly(true); + compileOnly(); }), vscode.languages.registerDocumentLinkProvider({ language: outputLangId }, new DocumentLinkProvider()), vscode.commands.registerCommand("vscode-objectscript.editOthers", () => { @@ -1511,10 +1480,6 @@ export async function activate(context: vscode.ExtensionContext): Promise { sendCommandTelemetryEvent("exportProjectContents"); exportProjectContents(); }), - vscode.commands.registerCommand("vscode-objectscript.explorer.project.compileProjectContents", (node) => { - sendCommandTelemetryEvent("explorer.project.compileProjectContents"); - compileProjectContents(node); - }), vscode.commands.registerCommand("vscode-objectscript.explorer.project.openOtherServerNs", () => { sendCommandTelemetryEvent("explorer.project.openOtherServerNs"); pickServerAndNamespace().then((pick) => {