Skip to content

Commit

Permalink
Include tasklet contents in graph search (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun committed May 8, 2024
1 parent 8941e11 commit 2ceba1d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spcl/sdfv",
"version": "1.2.3",
"version": "1.2.4",
"description": "A standalone viewer for SDFGs",
"homepage": "https://github.com/spcl/dace-webclient",
"main": "out/index.js",
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/renderer_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ export class SDFGElement {
return this.data.label;
}

// Text used for matching the element during a search
public text_for_find(): string {
return this.label();
}

// Produces HTML for a hover-tooltip
public tooltip(container: HTMLElement): void {
container.className = 'sdfvtooltip';
Expand Down Expand Up @@ -2182,6 +2187,12 @@ export class Tasklet extends SDFGNode {
this.highlightCode();
}

public text_for_find(): string {
// Include code when searching
const code = this.attributes().code.string_data;
return this.label() + " " + code;
}

private highlightedCode: TaskletCodeToken[][] = [];
public readonly inputTokens: Set<TaskletCodeToken> = new Set();
public readonly outputTokens: Set<TaskletCodeToken> = new Set();
Expand Down
6 changes: 3 additions & 3 deletions src/sdfv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,10 @@ export function find_in_graph(
query = query.toLowerCase();
find_in_graph_predicate(
sdfv, renderer, sdfg, (graph: DagreGraph, element: SDFGElement) => {
let label = element.label();
let text = element.text_for_find();
if (!case_sensitive)
label = label.toLowerCase();
return label.indexOf(query) !== -1;
text = text.toLowerCase();
return text.indexOf(query) !== -1;
}
);
sdfv.sidebar_set_title('Search Results for "' + query + '"');
Expand Down

0 comments on commit 2ceba1d

Please sign in to comment.