Skip to content

Commit

Permalink
WIDs correctly recognized by the BPMN Editor now
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagobento committed Dec 29, 2023
1 parent 1f0c45d commit 5fedef4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/bpmn-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint": "run-script-if --bool \"$(build-env linters.run)\" --then \"kie-tools--eslint ./src\"",
"pack:prod": "vsce package --githubBranch main --no-dependencies -o ./dist/bpmn_vscode_extension_$npm_package_version.vsix",
"run:webmode": "pnpm vscode-test-web --browserType=chromium --extensionDevelopmentPath=. --version=stable",
"watch": "webpack"
"watch": "export WEBPACK__sourceMaps=true; WEBPACK__minimize=false; webpack --env dev"
},
"dependencies": {
"@kie-tools-core/backend": "workspace:*",
Expand Down
6 changes: 6 additions & 0 deletions packages/bpmn-vscode-extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const commonConfig = (env) =>
umdNamedDefine: true,
globalObject: "this",
},
plugins: [
new ProvidePlugin({
process: require.resolve("process/browser.js"),
Buffer: ["buffer", "Buffer"],
}),
],
externals: {
vscode: "commonjs vscode",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class DmnResourceContentFetcher {
private final DmnLanguageServiceServiceProducer dmnLanguageServiceServiceProducer;
private Map<String, String> fileNames = new HashMap<>();
private List<String> decisions = new ArrayList<>();
private final static String fileMatcher = "*.dmn";
private final static String fileMatcher = "**/*.dmn";

@Inject
public DmnResourceContentFetcher(final ResourceContentService resourceContentService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,39 @@ export class VsCodeResourceContentServiceForWorkspaces implements ResourceConten
console.debug("VS CODE RESOURCE CONTENT API IMPL FOR WORKSPACES: Trying to use isomorphic-git to read dir.");
const normalizedPosixPathsRelativeToTheBasePath = await listFiles({
fs: this.isomorphicGitFs,
dir: baseAbsoluteFsPath,
dir: this.args.workspaceRootAbsoluteFsPath,
});
console.debug("VS CODE RESOURCE CONTENT API IMPL FOR WORKSPACES: Success on using isomorphic-git!");

const minimatch = new Minimatch(pattern);
const regexp = minimatch.makeRe(); // The regexp is ~50x faster than the direct match using glob.
const openFileDirectoryNormalizedPosixPathRelativeToTheWorkspaceRoot = __path.dirname(
getNormalizedPosixPathRelativeToWorkspaceRoot(this.args.document)
);

const matchingNormalizedPosixPathsRelativeToTheBasePath = normalizedPosixPathsRelativeToTheBasePath.filter(
(p) =>
regexp.test(
"/" + p // Adding a leading slash here to make the regex have the same behavior as the glob with **/* pattern.
) || regexp.test(__path.relative(getNormalizedPosixPathRelativeToWorkspaceRoot(this.args.document), p)) // check on the asset folder for *.{ext} pattern
(p) => {
const matchesPattern =
// Adding a leading slash here to make the regex have the same behavior as the glob with **/* pattern.
regexp.test("/" + p) ||
// check on the asset folder for *.{ext} pattern
regexp.test(__path.relative(openFileDirectoryNormalizedPosixPathRelativeToTheWorkspaceRoot, p));

const conformsToSearchType =
!opts ||
opts.type === SearchType.TRAVERSAL ||
(opts.type === SearchType.ASSET_FOLDER &&
__path
.join(baseAbsoluteFsPath, toFsPath(p))
.startsWith(
__path.join(
baseAbsoluteFsPath,
toFsPath(openFileDirectoryNormalizedPosixPathRelativeToTheWorkspaceRoot)
)
));

return matchesPattern && conformsToSearchType;
}
);
return new ResourcesList(pattern, matchingNormalizedPosixPathsRelativeToTheBasePath);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { PromiseFsClient } from "isomorphic-git";
import * as vscode from "vscode";

export class ReadonlyIsomorphicGitFsForVsCodeWorkspaceFolders {
Expand Down Expand Up @@ -47,7 +46,6 @@ export class ReadonlyIsomorphicGitFsForVsCodeWorkspaceFolders {
async readdir(path: string) {
const contentPath = vscode.Uri.parse(path);
try {
console.debug("vscode.workspace.fs.readDirectory", "path:", contentPath);
return vscode.workspace.fs.readDirectory(contentPath);
} catch (error) {
console.debug("ERROR on vscode.workspace.fs.readDirectory", "error:", error, "path:", contentPath);
Expand All @@ -57,7 +55,6 @@ export class ReadonlyIsomorphicGitFsForVsCodeWorkspaceFolders {
async read(path: string) {
const contentPath = vscode.Uri.parse(path);
try {
console.debug("vscode.workspace.fs.readFile", "path:", contentPath);
const uint8Array = await vscode.workspace.fs.readFile(contentPath);
return Buffer.from(uint8Array);
} catch (error) {
Expand All @@ -72,7 +69,6 @@ export class ReadonlyIsomorphicGitFsForVsCodeWorkspaceFolders {
async write(path: string, buffer: Buffer) {
const contentPath = vscode.Uri.parse(path);
try {
console.debug("vscode.workspace.fs.write", "path:", contentPath);
return vscode.workspace.fs.writeFile(contentPath, buffer);
} catch (error) {
console.debug("ERROR on vscode.workspace.fs.write", "error:", error, "path:", contentPath);
Expand All @@ -82,7 +78,6 @@ export class ReadonlyIsomorphicGitFsForVsCodeWorkspaceFolders {
async lstat(path: string) {
const contentPath = vscode.Uri.parse(path);
try {
console.debug("vscode.workspace.fs.stat", "path:", contentPath);
return vscode.workspace.fs.stat(contentPath);
} catch (error) {
console.debug("ERROR on vscode.workspace.fs.stat", "error:", error, "path:", contentPath);
Expand Down

0 comments on commit 5fedef4

Please sign in to comment.