Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flat and type isfs query parameters #1208

Merged
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
19 changes: 0 additions & 19 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,25 +1336,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
);
reporter && reporter.sendTelemetryEvent("extensionActivated");

// Report the use of deprecated query parameters
(vscode.workspace.workspaceFolders || []).forEach(async (wf) => {
if (filesystemSchemas.includes(wf.uri.scheme)) {
const params = new URLSearchParams(wf.uri.query);
if (params.has("flat") || params.has("type")) {
const qp = params.has("flat") ? "flat" : "type";
await vscode.window
.showWarningMessage(
`Workspace folder '${wf.name}' is using deprecated query parameter '${qp}'. Modify it now?`,
"Yes",
"No"
)
.then(
(answer) => answer == "Yes" && vscode.commands.executeCommand("vscode-objectscript.modifyWsFolder", wf.uri)
);
}
}
});

// The API we export
const extensionApi = {
serverForUri(uri: vscode.Uri): any {
Expand Down
5 changes: 2 additions & 3 deletions src/providers/DocumentContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
if (authorityParts.length === 2 && namespace?.toLowerCase() === authorityParts[1]) {
namespace = "";
}
const flat = new URLSearchParams(wFolderUri.query).get("flat") == "1";
const fileExt = name.split(".").pop();
const fileName = name
.split(".")
.slice(0, -1)
.join(/cls|mac|int|inc/i.test(fileExt) && !flat ? "/" : ".");
if (/.\.G?[1-9]\.int$/i.test(name) && !flat) {
.join(/cls|mac|int|inc/i.test(fileExt) ? "/" : ".");
if (/.\.G?[1-9]\.int$/i.test(name)) {
// This is a generated INT file
name =
fileName.slice(0, fileName.lastIndexOf("/")) +
Expand Down
63 changes: 18 additions & 45 deletions src/providers/FileSystemProvider/TextSearchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,31 +377,28 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
max: options.maxResults ?? 100000,
};

// Generate the include and exclude filters, except for if 'flat' is present
// because there isn't an easy way to convert all dots to slashes except for file extensions.
// Generate the include and exclude filters.
// The matching is case sensitive and file names are normalized so that the first character
// and path separator are '/' (for example, '/%Api/Atelier/v6.cls' and '/csp/user/menu.csp').
if (params.has("flat") && params.get("flat").length ? params.get("flat") != "1" : true) {
let includesArr = options.includes;
let excludesArr = removeConfigExcludes(options.folder, options.excludes);
if (!["", "/"].includes(options.folder.path)) {
// Prepend path with a trailing slash
const prefix = !options.folder.path.endsWith("/") ? `${options.folder.path}/` : options.folder.path;
includesArr = includesArr.map((e) => `${prefix}${e}`);
excludesArr = excludesArr.map((e) => `${prefix}${e}`);
}
let includesArr = options.includes;
let excludesArr = removeConfigExcludes(options.folder, options.excludes);
if (!["", "/"].includes(options.folder.path)) {
// Prepend path with a trailing slash
const prefix = !options.folder.path.endsWith("/") ? `${options.folder.path}/` : options.folder.path;
includesArr = includesArr.map((e) => `${prefix}${e}`);
excludesArr = excludesArr.map((e) => `${prefix}${e}`);
}

// Add leading slash if we don't start with **/
includesArr = includesArr.map((e) => (!e.startsWith("**/") ? `/${e}` : e));
excludesArr = excludesArr.map((e) => (!e.startsWith("**/") ? `/${e}` : e));
// Add leading slash if we don't start with **/
includesArr = includesArr.map((e) => (!e.startsWith("**/") ? `/${e}` : e));
excludesArr = excludesArr.map((e) => (!e.startsWith("**/") ? `/${e}` : e));

// Convert the array of glob patterns into a single regular expression
if (includesArr.length) {
request.include = includesArr.map((e) => makeRe(e).source).join("|");
}
if (excludesArr.length) {
request.exclude = excludesArr.map((e) => makeRe(e).source).join("|");
}
// Convert the array of glob patterns into a single regular expression
if (includesArr.length) {
request.include = includesArr.map((e) => makeRe(e).source).join("|");
}
if (excludesArr.length) {
request.exclude = excludesArr.map((e) => makeRe(e).source).join("|");
}

// Send the queue request
Expand Down Expand Up @@ -596,30 +593,6 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
}
}

// Don't report matches in filetypes we don't want or don't handle
const fileType = file.doc.split(".").pop().toLowerCase();
if (!csp) {
switch (params.get("type")) {
case "cls":
if (fileType !== "cls") {
return;
}
break;

case "rtn":
if (!["inc", "int", "mac"].includes(fileType)) {
return;
}
break;

default:
if (!["cls", "inc", "int", "mac"].includes(fileType)) {
return;
}
break;
}
}

return reportMatchesForFile(file);
})
)
Expand Down
11 changes: 1 addition & 10 deletions src/utils/FileProviderUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export async function projectContentsFromUri(uri: vscode.Uri, overrideFlat?: boo
export function fileSpecFromURI(uri: vscode.Uri): string {
const params = new URLSearchParams(uri.query);
const csp = params.has("csp") && ["", "1"].includes(params.get("csp"));
const type = params.has("type") && params.get("type").length ? params.get("type") : csp ? "csp" : "all";

const folder = !csp
? uri.path.replace(/\//g, ".")
Expand All @@ -122,10 +121,6 @@ export function fileSpecFromURI(uri: vscode.Uri): string {
} // otherwise, reference the type to get the desired files.
else if (csp) {
specOpts = folder.length > 1 ? "*" : "*.cspall";
} else if (type === "rtn") {
specOpts = "*.inc,*.mac,*.int";
} else if (type === "cls") {
specOpts = "*.cls";
} else {
specOpts = "*.cls,*.inc,*.mac,*.int";
}
Expand All @@ -142,18 +137,14 @@ export function studioOpenDialogFromURI(
}
const sql = `SELECT Name, Type FROM %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?,?,?,?)`;
const params = new URLSearchParams(uri.query);
const csp = params.has("csp") && ["", "1"].includes(params.get("csp"));
const spec = fileSpecFromURI(uri);
const notStudio = "0";
const dir = "1";
const orderBy = "1";
const generated = params.has("generated") && params.get("generated").length ? params.get("generated") : "0";
const system =
params.has("system") && params.get("system").length ? params.get("system") : api.ns === "%SYS" ? "1" : "0";
let flat = !csp && params.has("flat") && params.get("flat").length ? params.get("flat") : "0";
if (overrides && overrides.flat) {
flat = "1";
}
const flat = overrides && overrides.flat ? "1" : "0";
const mapped = params.has("mapped") && params.get("mapped") == "0" ? "0" : "1";
return api.actionQuery(sql, [spec, dir, orderBy, system, flat, notStudio, generated, overrides.filter, "0", mapped]);
}