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

Add missing copyrights #211

Merged
merged 2 commits into from
Jul 27, 2023
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
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[The "BSD licence"]
Copyright (c) 2017 Kevin Jones (All other contributions)
All rights reserved.

Expand Down
21 changes: 12 additions & 9 deletions js/npm/lib/apex-ls.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/*
* Copyright (c) 2022 FinancialForce.com, inc. All rights reserved.
*/
declare module "@apexdevtools/apex-ls" {
export class WorkspaceException {
message: string;
}
export class WorkspaceException {
message: string;
}

export class Workspace {
findType(name: string): string[];
}
export class Workspace {
findType(name: string): string[];
}

export class Workspaces {
static get(path: string): Workspace;
}
export class Workspaces {
static get(path: string): Workspace;
}
}
23 changes: 13 additions & 10 deletions js/npm/snapshots/resolver.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/*
* Copyright (c) 2022 FinancialForce.com, inc. All rights reserved.
*/
module.exports = {
// resolves from test to snapshot path
resolveSnapshotPath: (testPath, snapshotExtension) =>
testPath.replace('src/__tests__', 'snapshots') + snapshotExtension,
// resolves from test to snapshot path
resolveSnapshotPath: (testPath, snapshotExtension) =>
testPath.replace("src/__tests__", "snapshots") + snapshotExtension,

// resolves from snapshot to test path
resolveTestPath: (snapshotFilePath, snapshotExtension) =>
snapshotFilePath
.replace('snapshots', 'src/__tests__')
.slice(0, -snapshotExtension.length),
// resolves from snapshot to test path
resolveTestPath: (snapshotFilePath, snapshotExtension) =>
snapshotFilePath
.replace("snapshots", "src/__tests__")
.slice(0, -snapshotExtension.length),

// Example test path, used for preflight consistency check of the implementation above
testPathForConsistencyCheck: 'src/__tests__/example.test.ts',
// Example test path, used for preflight consistency check of the implementation above
testPathForConsistencyCheck: "src/__tests__/example.test.ts",
};
134 changes: 74 additions & 60 deletions js/npm/src/__tests__/WorkspaceTest.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,95 @@
/*
Copyright (c) 2019 Kevin Jones, All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
*/
import { Workspaces } from "@apexdevtools/apex-ls";
import { vol } from "memfs";
import { patchFs } from "fs-monkey";

test("Bad directory", () => {
try {
Workspaces.get("foo");
expect(true).toBe(false);
} catch (err) {
expect(err.message).toMatch(/.*No directory at .*/);
}
try {
Workspaces.get("foo");
expect(true).toBe(false);
} catch (err) {
expect(err.message).toMatch(/.*No directory at .*/);
}
});

test("Empty directory", () => {
vol.fromJSON({ "/pkg1/README.md": "" });
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg1");
expect(workspace).toBeDefined();
expect(workspace.findType("Foo")).toEqual([]);
} finally {
unpatch();
}
vol.fromJSON({ "/pkg1/README.md": "" });
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg1");
expect(workspace).toBeDefined();
expect(workspace.findType("Foo")).toEqual([]);
} finally {
unpatch();
}
});

test("MDAPI Class", () => {
vol.fromJSON({ "/pkg2/classes/Foo.cls": "" });
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg2");
expect(workspace).toBeDefined();
expect(workspace.findType("Foo")).toEqual(["/pkg2/classes/Foo.cls"]);
} finally {
unpatch();
}
vol.fromJSON({ "/pkg2/classes/Foo.cls": "" });
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg2");
expect(workspace).toBeDefined();
expect(workspace.findType("Foo")).toEqual(["/pkg2/classes/Foo.cls"]);
} finally {
unpatch();
}
});

test("SFDX Bad Project file", () => {
vol.fromJSON({ "/pkg3/sfdx-project.json": "" });
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg3");
expect(true).toBe(false);
} catch (err) {
expect(err.message).toMatch(
"Error: line 1: Failed to parse - ujson.IncompleteParseException: exhausted input"
);
} finally {
unpatch();
}
vol.fromJSON({ "/pkg3/sfdx-project.json": "" });
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg3");
expect(true).toBe(false);
} catch (err) {
expect(err.message).toMatch(
"Error: line 1: Failed to parse - ujson.IncompleteParseException: exhausted input"
);
} finally {
unpatch();
}
});

test("SFDX without namespace", () => {
vol.fromJSON({
"/pkg4/sfdx-project.json": '{ "packageDirectories": [{"path": "classes"}]}',
"/pkg4/classes/Foo.cls": "",
});
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg4");
expect(workspace).toBeDefined();
expect(workspace.findType("Foo")).toEqual(["/pkg4/classes/Foo.cls"]);
} finally {
unpatch();
}
vol.fromJSON({
"/pkg4/sfdx-project.json": '{ "packageDirectories": [{"path": "classes"}]}',
"/pkg4/classes/Foo.cls": "",
});
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg4");
expect(workspace).toBeDefined();
expect(workspace.findType("Foo")).toEqual(["/pkg4/classes/Foo.cls"]);
} finally {
unpatch();
}
});

test("SFDX with namespace", () => {
vol.fromJSON({
"/pkg5/sfdx-project.json": '{ "packageDirectories": [{"path": "classes"}], "namespace": "ns001"}',
"/pkg5/classes/Foo.cls": "",
});
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg5");
expect(workspace).toBeDefined();
expect(workspace.findType("ns001.Foo")).toEqual(["/pkg5/classes/Foo.cls"]);
} finally {
unpatch();
}
vol.fromJSON({
"/pkg5/sfdx-project.json":
'{ "packageDirectories": [{"path": "classes"}], "namespace": "ns001"}',
"/pkg5/classes/Foo.cls": "",
});
const unpatch = patchFs(vol);
try {
const workspace = Workspaces.get("/pkg5");
expect(workspace).toBeDefined();
expect(workspace.findType("ns001.Foo")).toEqual(["/pkg5/classes/Foo.cls"]);
} finally {
unpatch();
}
});
Loading