Skip to content

Commit

Permalink
Merge branch 'python-in-extension' into release-0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tmr232 committed Sep 18, 2024
2 parents b283057 + dab12cd commit e2a0c49
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/vscode/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Graphviz } from "@hpcc-js/wasm-graphviz";
import { graphToDot } from "../control-flow/render";
import { simplifyCFG, trimFor } from "../control-flow/graph-ops";
import { newCFGBuilder, type Language } from "../control-flow/cfg";
import { mergeNodeAttrs } from "../control-flow/cfg-defs";

let graphviz: Graphviz;
interface SupportedLanguage {
Expand All @@ -24,11 +25,17 @@ const supportedLanguages: SupportedLanguage[] = [
language: "Go" as Language,
parserName: "tree-sitter-go.wasm",
},
{
languageId: "python",
language: "Python" as Language,
parserName: "tree-sitter-python.wasm",
},
];

const functionNodeTypes: { [key: string]: string[] } = {
go: ["function_declaration", "method_declaration", "func_literal"],
c: ["function_definition"],
python: ["function_definition"],
};

const supportedLanguageIds = supportedLanguages.map((lang) => lang.languageId);
Expand Down Expand Up @@ -176,7 +183,7 @@ export async function activate(context: vscode.ExtensionContext) {
.getConfiguration("functionGraphOverview")
.get("simplify")
) {
cfg = simplifyCFG(cfg);
cfg = simplifyCFG(cfg, mergeNodeAttrs);
}
const dot = graphToDot(cfg);
const svg = graphviz.dot(dot);
Expand All @@ -189,7 +196,7 @@ export async function activate(context: vscode.ExtensionContext) {
}

// This method is called when your extension is deactivated
export function deactivate() {}
export function deactivate() { }

//------------------------------------------------

Expand All @@ -198,7 +205,7 @@ class OverviewViewProvider implements vscode.WebviewViewProvider {

private _view?: vscode.WebviewView;

constructor(private readonly _extensionUri: vscode.Uri) {}
constructor(private readonly _extensionUri: vscode.Uri) { }

public setSVG(svg: string) {
if (this._view) {
Expand Down

0 comments on commit e2a0c49

Please sign in to comment.