Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 0 additions & 89 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)?$/)"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
76 changes: 19 additions & 57 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
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.
Expand Down Expand Up @@ -95,7 +87,7 @@ export async function importFile(
): Promise<any> {
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");
Expand Down Expand Up @@ -258,12 +250,11 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
);
}

export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[], flags?: string): Promise<any> {
export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[]): Promise<any> {
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<string>("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
Expand Down Expand Up @@ -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<any> {
export async function importAndCompile(document?: vscode.TextDocument): Promise<any> {
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<any> {
export async function compileOnly(document?: vscode.TextDocument): Promise<any> {
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<any> {
export async function namespaceCompile(): Promise<any> {
const api = new AtelierAPI();
const fileTypes = ["*.CLS", "*.MAC", "*.INC", "*.BAS"];
if (!api.active) return;
Expand All @@ -387,12 +355,6 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
// 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,
Expand All @@ -401,7 +363,7 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
},
(progress, token: vscode.CancellationToken) =>
api
.asyncCompile(fileTypes, token, flags)
.asyncCompile(fileTypes, token, vscode.workspace.getConfiguration("objectscript").get<string>("compileFlags"))
.then((data) => {
if (data.status && data.status.errors && data.status.errors.length) {
throw new Error(`Compiling Namespace: ${api.ns} Error`);
Expand Down
36 changes: 2 additions & 34 deletions src/commands/project.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -918,38 +918,6 @@ export async function exportProjectContents(): Promise<any> {
}
}

export async function compileProjectContents(node: ProjectNode): Promise<any> {
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`.
*/
Expand Down
Loading