Skip to content

Commit e7492e8

Browse files
committed
Decouple import validation from export settings
1 parent c67be21 commit e7492e8

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

src/commands/compile.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,9 @@ export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<
321321
let globpattern = "*.{cls,inc,int,mac}";
322322
const workspace = currentWorkspaceFolder();
323323
const workspacePath = workspaceFolderUri(workspace).fsPath;
324-
const { folder } = config("export", workspace);
325324
const folderPathNoWorkspaceArr = uripath.replace(workspacePath + path.sep, "").split(path.sep);
326-
if (folderPathNoWorkspaceArr[0] === folder) {
327-
// This folder is in the export tree, so import all files
325+
if (folderPathNoWorkspaceArr.includes("csp")) {
326+
// This folder is a CSP application, so import all files
328327
// We need to include eveything becuase CSP applications can
329328
// include non-InterSystems files
330329
globpattern = "*";

src/utils/index.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function outputConsole(data: string[]): void {
3232
}
3333

3434
import { InputBoxManager } from "./inputBoxManager";
35-
import { getCategory } from "../commands/export";
3635
export { InputBoxManager };
3736

3837
// tslint:disable-next-line: interface-name
@@ -62,16 +61,9 @@ export interface ConnectionTarget {
6261
* @param workspace The workspace the file is in.
6362
*/
6463
function getServerDocName(localPath: string, workspace: string): string {
65-
let result = localPath;
6664
const workspacePath = workspaceFolderUri(workspace).fsPath;
67-
result = result.replace(workspacePath + path.sep, "");
68-
const { folder, addCategory } = config("export", workspace);
69-
result = result.replace(folder + path.sep, "");
70-
const cat = addCategory ? getCategory(localPath, addCategory) : null;
71-
if (cat !== null) {
72-
result = result.replace(cat + path.sep, "");
73-
}
74-
return result.replace(path.sep, "/");
65+
const filePathNoWorkspaceArr = localPath.replace(workspacePath + path.sep, "").split(path.sep);
66+
return filePathNoWorkspaceArr.slice(filePathNoWorkspaceArr.indexOf("csp")).join("/");
7567
}
7668

7769
/**
@@ -80,18 +72,10 @@ function getServerDocName(localPath: string, workspace: string): string {
8072
* @param file The file to check.
8173
*/
8274
export function isImportableLocalFile(file: vscode.TextDocument): boolean {
83-
let result = false;
8475
const workspace = currentWorkspaceFolder(file);
8576
const workspacePath = workspaceFolderUri(workspace).fsPath;
86-
const { folder, addCategory } = config("export", workspace);
8777
const filePathNoWorkspaceArr = file.fileName.replace(workspacePath + path.sep, "").split(path.sep);
88-
const cat = addCategory ? getCategory(file.fileName, addCategory) : null;
89-
if (filePathNoWorkspaceArr[0] === folder) {
90-
if (cat === null || (cat !== null && filePathNoWorkspaceArr[1] === cat)) {
91-
result = true;
92-
}
93-
}
94-
return result;
78+
return filePathNoWorkspaceArr.includes("csp");
9579
}
9680

9781
export function currentFile(document?: vscode.TextDocument): CurrentFile {
@@ -142,6 +126,10 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
142126
}
143127
} else {
144128
if (document.uri.scheme === "file") {
129+
if (fileExt.match(/(csp|csr)/i) && !isImportableLocalFile(document)) {
130+
// This is a csp or csr file that's not in a csp directory
131+
return null;
132+
}
145133
name = getServerDocName(fileName, currentWorkspaceFolder(document));
146134
} else {
147135
name = fileName;

0 commit comments

Comments
 (0)