Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
...argdownConfig,
input: input,
findElementAtPosition: {
line: line + 1,
character: character + 1
},
process: [
"parse-input",
"build-model",
"build-map",
"colorize",
"find-element-at-position"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
if (response.elementAtPosition) {
const title = response.elementAtPosition.title;
let nodeType = ArgdownTypes.ARGUMENT_MAP_NODE;
if (response.elementAtPosition.type === ArgdownTypes.EQUIVALENCE_CLASS) {
nodeType = ArgdownTypes.STATEMENT_MAP_NODE;
}
const node = this.findNodeInMapNodeTree(
response.map!.nodes,
n => n.title === title && n.type === nodeType
);
if (!node) {
return "";
}
return node.id || "";
}
return "";
): Promise {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request = {
...argdownConfig,
input: input,
process: [
"parse-input",
"build-model",
"build-map",
"transform-closed-groups",
"colorize"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.map!;
}
public async exportMapJson(
): Promise {
const argdownConfig = config.argdownConfig || {};
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: [
"parse-input",
"build-model",
"build-map",
"colorize",
"export-graphml"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.graphml!;
}
public async loadConfig(
public async getRangeOfMapNode(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration,
id: string
): Promise {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: ["parse-input", "build-model", "build-map", "colorize"],
throwExceptions: true
};
const response = await argdown.runAsync(request);
const node = this.findNodeInMapNodeTree(
response.map!.nodes,
(n: any) => n.id === id
);
if (node && node.type === ArgdownTypes.ARGUMENT_MAP_NODE) {
const argument = response.arguments![node.title!];
const desc = IArgument.getCanonicalMember(argument);
if (desc) {
return new vscode.Range(
(desc.startLine || 1) - 1,
(desc.startColumn || 1) - 1,
(desc.endLine || 1) - 1,
desc.endColumn || 1
);
}
} else if (node && node.type === ArgdownTypes.STATEMENT_MAP_NODE) {
const argdownConfig = config.argdownConfig || {};
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: [
"parse-input",
"build-model",
"build-map",
"transform-closed-groups",
"colorize",
"export-dot"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.dot!;
}
public async exportGraphML(
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request = {
...argdownConfig,
input: input,
process: [
"parse-input",
"build-model",
"build-map",
"transform-closed-groups",
"colorize",
"export-json"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.json!;
}
public async exportDot(
public async getRangeOfHeading(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration,
headingText: string
): Promise {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: ["parse-input", "build-model"],
throwExceptions: true
};
const response = await argdown.runAsync(request);
if (!response.sections || response.sections.length == 0) {
return new vscode.Range(0, 0, 0, 0);
}
const section = this.findSection(response.sections, headingText);
if (section) {
return new vscode.Range(
(section.startLine || 1) - 1,
(section.startColumn || 1) - 1,
(section.startLine || 1) - 1,
(section.startColumn || 1) - 1
);
}
return new vscode.Range(0, 0, 0, 0);
}
private findSection(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration
): Promise {
const argdownConfig = config.argdownConfig || {};
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: ["parse-input", "build-model", "export-html"],
html: {
...argdownConfig.html,
headless: true
},
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.html!;
}
public async getMapNodeId(