Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
outTxt = ['No Dependencies Found'];
}
else {
ret.shift();
const reducer = (accumulator, currentValue) => `${accumulator}\n ↖ ${currentValue}`;
outTxt.push(` ↖ ${ret.reduce(reducer)}`);
}
vscode.workspace.openTextDocument({content: outTxt.join("\n"), language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
}
break;
case "ftrace":
// contract::func, all, files
ret = surya.ftrace(args[0], args[1] || 'all', files, {}, true);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
break;
case "mdreport":
ret = surya.mdreport(files);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => {
if(solidityVAConfig.preview.markdown){
vscode.commands.executeCommand("markdown-preview-enhanced.openPreview", doc.uri)
.catch(error => {
//command does not exist
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside)
.then(editor => {
vscode.commands.executeCommand("markdown.extension.togglePreview")
.catch(error => {
//command does not exist
files = uris.map(function (uri) {
return uri.fsPath;
});
});
} else {
files = [document.uri.fsPath, ...Object.keys(this.g_parser.sourceUnits)]; //better only add imported files. need to resolve that somehow
}
switch(command) {
case "describe":
ret = surya.describe(files, {}, true);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
break;
case "graph":
ret = surya.graph(args || files, {colorScheme: suryaDefaultColorSchemeDark});
//solidity-va.preview.render.markdown
vscode.workspace.openTextDocument({content: ret, language: "dot"})
.then(doc => {
if(solidityVAConfig.preview.dot){
vscode.commands.executeCommand("interactive-graphviz.preview.beside", {document: doc, content:ret, callback:null})
.catch(error =>{
vscode.commands.executeCommand("graphviz.previewToSide", doc.uri)
.catch(error => {
//command not available. fallback open as text and try graphviz.showPreview
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside)
.then(editor => {
vscode.commands.executeCommand("graphviz.showPreview", editor) // creates new pane
.catch(error => {
//command not available - do nothing
});
});
});
});
});
});
} else {
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside);
}
});
/*
vscode.env.openExternal(vscode.Uri.file("/Users/tintin/workspace/vscode/solidity-auditor/images/icon.png"))
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside))
*/
break;
case "inheritance":
ret = surya.inheritance(files,{draggable:false});
vscode.workspace.openTextDocument({content: ret, language: "dot"})
.then(doc => {
if(solidityVAConfig.preview.dot){
vscode.commands.executeCommand("interactive-graphviz.preview.beside", {document: doc, content:ret, callback:null})
.catch(error =>{
vscode.commands.executeCommand("graphviz.previewToSide", doc.uri)
.catch(error => {
//command not available. fallback open as text and try graphviz.showPreview
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside)
.then(editor => {
vscode.commands.executeCommand("graphviz.showPreview", editor) // creates new pane
.catch(error => {
//command not available - do nothing
});
});
});
outTxt.push(` ↖ ${ret.reduce(reducer)}`);
}
vscode.workspace.openTextDocument({content: outTxt.join("\n"), language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
}
break;
case "ftrace":
// contract::func, all, files
ret = surya.ftrace(args[0], args[1] || 'all', files, {}, true);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
break;
case "mdreport":
ret = surya.mdreport(files);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => {
if(solidityVAConfig.preview.markdown){
vscode.commands.executeCommand("markdown-preview-enhanced.openPreview", doc.uri)
.catch(error => {
//command does not exist
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside)
.then(editor => {
vscode.commands.executeCommand("markdown.extension.togglePreview")
.catch(error => {
//command does not exist
});
});
});
} else {
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside);
}
});
/*
let draggable = surya.inheritance(files,{draggable:true})
console.error(draggable)
createWebViewBesides('imgPreview','imgPreview',draggable)
*/
break;
case "parse":
ret = surya.parse(document.uri.fsPath);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
break;
case "dependencies":
ret = surya.dependencies(files, args[0]);
let outTxt = [];
if(ret){
outTxt.push(ret[0]);
if (ret.length < 2) {
outTxt = ['No Dependencies Found'];
}
else {
ret.shift();
const reducer = (accumulator, currentValue) => `${accumulator}\n ↖ ${currentValue}`;
outTxt.push(` ↖ ${ret.reduce(reducer)}`);
}
});
});
});
} else {
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside);
}
});
/*
let draggable = surya.inheritance(files,{draggable:true})
console.error(draggable)
createWebViewBesides('imgPreview','imgPreview',draggable)
*/
break;
case "parse":
ret = surya.parse(document.uri.fsPath);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
break;
case "dependencies":
ret = surya.dependencies(files, args[0]);
let outTxt = [];
if(ret){
outTxt.push(ret[0]);
if (ret.length < 2) {
outTxt = ['No Dependencies Found'];
}
else {
ret.shift();
let files;
if(solidityVAConfig.tools.surya.input.contracts=="workspace"){
await vscode.workspace.findFiles("**/*.sol",'**/node_modules', 500)
.then(uris => {
files = uris.map(function (uri) {
return uri.fsPath;
});
});
} else {
files = [document.uri.fsPath, ...Object.keys(this.g_parser.sourceUnits)]; //better only add imported files. need to resolve that somehow
}
switch(command) {
case "describe":
ret = surya.describe(files, {}, true);
vscode.workspace.openTextDocument({content: ret, language: "markdown"})
.then(doc => vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside));
break;
case "graph":
ret = surya.graph(args || files, {colorScheme: suryaDefaultColorSchemeDark});
//solidity-va.preview.render.markdown
vscode.workspace.openTextDocument({content: ret, language: "dot"})
.then(doc => {
if(solidityVAConfig.preview.dot){
vscode.commands.executeCommand("interactive-graphviz.preview.beside", {document: doc, content:ret, callback:null})
.catch(error =>{
vscode.commands.executeCommand("graphviz.previewToSide", doc.uri)
.catch(error => {
//command not available. fallback open as text and try graphviz.showPreview
vscode.window.showTextDocument(doc, vscode.ViewColumn.Beside)
.then(editor => {