public void showCodeStream() { CodeStream.show(CodeViewer.editor()); CodeStream.show(CodeStreamCodeViewer.editor()); CodeStream.show(CodeStreamTreeView); O2Thread.mtaThread( () => { if (ShowGraphInNewWindow) { if (JoinGraphData.isFalse()) { CodeStreamGraph = O2Gui.open <Panel>("O2 Ast Engine Graph", 400, 400).add_Graph(); } CodeStream.show(CodeStreamGraph); } else { if (JoinGraphData.isFalse()) { CodeStreamGraphPanel.clear(); CodeStreamGraph = CodeStreamGraphPanel.add_Graph(); } CodeStream.show(CodeStreamGraph); } CodeStreamGraphScript.InvocationParameters.add("graph", CodeStreamGraph); }); }
public void createAndShowCodeStream(INode iNode) { try { if (iNode != null) { CodeViewer.editor().caret(iNode.StartLocation.Line, iNode.StartLocation.Column); CodeViewer.editor().selectTextWithColor(iNode); var codeStream = AstData_MethodStream.createO2CodeStream(TaintRules, MethodStreamFile, iNode); //var codeStream = AstData_MethodStream.createO2CodeStream(MethodStreamFile,iNode); if (codeStream.hasPaths()) { showCodeStream(codeStream); } } } catch (Exception ex) { ex.log("in createAndShowCodeStream"); } }
public void showCodeStream(O2CodeStream codeStream) { codeStream.show(CodeViewer.editor()); codeStream.show(CodeStreamTreeView); CodeStreamTreeView.expand(); }
public ascx_ManualMethodStreams buildGui(bool addLogViewer) { //AstEngine.HostPanel.clear(); var topPanel = this.add_1x1("Methods & Parameters", "Source Code", true); var tabControl = topPanel[1].add_TabControl(); //CodeViewer = tabControl.add_Tab("Source Code").add_SourceCodeViewer(); CodeViewer = topPanel[0].add_SourceCodeViewer(); CodeViewer.editor().colorCodeForExtension(".cs"); CodeStreamTreeViewTab = tabControl.add_Tab("CodeStream TreeView"); TaintRulesTab = tabControl.add_Tab("Taint Rules"); //CodeStreamGraphTab = tabControl.add_Tab("CodeStream Graph"); //CodeStreamGraphTab.backColor(Color.White); //CodeStreamCodeViewer = CodeStreamTreeViewTab.add_SourceCodeViewer(); //CodeStreamTreeView = CodeStreamCodeViewer.insert_Left<TreeView>(200); CodeStreamTreeView = CodeStreamTreeViewTab.add_TreeView(); TaintRulesList = TaintRulesTab.add_GroupBox("Taint Propagators").add_TextArea(); //CodeStreamGraph = CodeStreamGraphTab.add_Panel().add_Graph(); ParametersTreeView = CodeViewer.insert_Below <TreeView>(100) .showSelection() .sort(); MethodsCalledTreeView = ParametersTreeView.insert_Right <TreeView>(250) .showSelection() .sort(); var commandsPanel = CodeViewer.insert_Below <Panel>(20); SaveCodeLink = commandsPanel.add_Link("save code", 0, 0, () => saveEditorContents()); showINodeLink = commandsPanel.add_Link("show INode CodeStream", 0, 60, () => showCurrentINodeCodeStream()); CurrentINodeLabel = commandsPanel.add_Label("current INode: ", 0, 200); commandsPanel.add_Label("Search:", 0, 350) .top(2) .append_TextBox("") .top(0) .onTextChange((text) => CodeViewer.editor().invoke("searchForTextInTextEditor_findNext", text)) .onEnter((text) => CodeViewer.editor().invoke("searchForTextInTextEditor_findNext", text)) .align_Right(commandsPanel); // context menu CodeStreamTreeView.add_ContextMenu() .add_MenuItem("Expand Selectd Node", () => { var selectedNode = CodeStreamTreeView.selected(); if (selectedNode.notNull()) { selectedNode.ExpandAll(); } selectedNode.selected(); }); /*MethodsCalledTreeView.add_ContextMenu() * .add_MenuItem("Show Method Stream Details", ()=> showMethodStreamDetails(CodeViewer.get_Text())); */ //events CodeStreamTreeView.afterSelect <O2CodeStreamNode> ((streamNode) => CodeViewer.editor().setSelectionText(streamNode.INode.StartLocation, streamNode.INode.EndLocation)); MethodsCalledTreeView.afterSelect <INode>((iNode) => createAndShowCodeStream(iNode)); ParametersTreeView.afterSelect <INode>((iNode) => createAndShowCodeStream(iNode)); CodeViewer.onCaretMove((caret) => findINodeAtCaretLocation(caret)); //CodeViewer.editor().eDocumentDataChanged += (text)=> saveEditorContents(); if (addLogViewer) { this.insert_Below <Panel>(100).add_LogViewer(); } commandsPanel.onDrop( (file) => { if (file.fileExists()) { loadFile(file); } }); loadDefaultTaintRules(); return(this); }
public void buildGui() { var topPanel = this; CodeViewer = topPanel.add_SourceCodeViewer(); DataTreeView = CodeViewer.insert_Left <TreeView>(200).showSelection().sort(); Options = DataTreeView.insert_Below <Panel>(40); Options.add_CheckBox("View AST", 0, 0, (value) => { this.Show_Ast = value; }).check(); Options.add_CheckBox("View CodeDom", 0, 95, (value) => { this.Show_CodeDom = value; }).front(); Options.add_CheckBox("View NRefactory", 20, 0, (value) => { this.Show_NRefactory = value; }).front().autoSize(); DataTreeView.showSelection(); DataTreeView.configureTreeViewForCodeDomViewAndNRefactoryDom(); AstData.afterSelect_ShowInSourceCodeEditor(DataTreeView, CodeViewer.editor()); DataTreeView.onDrop( (fileOrFolder) => { DataTreeView.backColor(Color.LightPink); O2Thread.mtaThread( () => { AstData.dispose(); AstData = new O2MappedAstData(); if (fileOrFolder.fileExists()) { AstData.loadFile(fileOrFolder); } else { AstData.loadFiles(fileOrFolder.files("*.cs", true)); } loadDataInGui(); DataTreeView.backColor(Color.White); }); }); DataTreeView.afterSelect <string>( (file) => { if (file.fileExists()) { CodeViewer.open(file); } }); DataTreeView.beforeExpand <CompilationUnit>( (compilationUnit) => { var treeNode = DataTreeView.selected(); treeNode.clear(); if (Show_Ast) { if (compilationUnit != null) { treeNode.add_Node("AST", null) .show_Ast(compilationUnit) .show_Asts(compilationUnit.types(true)) .show_Asts(compilationUnit.methods()); } //treeNode.show_Ast(compilationUnit); } if (Show_CodeDom) { var codeNamespace = AstData.MapAstToDom.CompilationUnitToNameSpaces[compilationUnit]; var domNode = treeNode.add_Node("CodeDom"); domNode.add_Node("CodeNamespaces").show_CodeDom(codeNamespace); domNode.add_Node("CodeTypeDeclarations").show_CodeDom(AstData.codeTypeDeclarations()); domNode.add_Node("CodeMemberMethods").show_CodeDom(AstData.codeMemberMethods()); //domNode.add_Node("CodeMemberMethods").show_CodeDom(o2MappedAstData.codeMemberMethods()); } if (Show_NRefactory) { var iCompilationUnit = AstData.MapAstToNRefactory.CompilationUnitToICompilationUnit[compilationUnit]; treeNode.add_Node("NRefactory") .add_Nodes_WithPropertiesAsChildNodes <ICompilationUnit>(iCompilationUnit); //.show_NRefactoryDom(o2MappedAstData.iClasses()) //.show_NRefactoryDom(o2MappedAstData.iMethods()); } }); }
public void buildGui() { AstEngine.HostPanel.clear(); var topPanel = AstEngine.HostPanel.add_1x1("Methods & Parameters", "Source Code", true, 400); //CodeViewer = topPanel[1].add_SourceCodeViewer(); var tabControl = topPanel[1].add_TabControl(); CodeViewer = tabControl.add_Tab("Source Code").add_SourceCodeViewer(); CodeStreamTreeViewTab = tabControl.add_Tab("CodeStream TreeView"); CodeStreamGraphTab = tabControl.add_Tab("CodeStream Graph"); CodeStreamCodeViewer = CodeStreamTreeViewTab.add_SourceCodeViewer(); CodeStreamTreeView = CodeStreamCodeViewer.insert_Left <TreeView>(200); CodeStreamGraphPanel = CodeStreamGraphTab.add_Panel().backColor(Color.White); CodeStreamGraph = CodeStreamGraphPanel.add_Graph(); CodeStreamGraphScript = CodeStreamGraphPanel.insert_Below <Panel>().add_Script(); CodeStreamTreeView.afterSelect <O2CodeStreamNode> ((streamNode) => CodeStreamCodeViewer.editor().setSelectionText(streamNode.INode.StartLocation, streamNode.INode.EndLocation)); MethodsTreeView = topPanel[0].add_TreeView() .sort() .showSelection(); MethodsTreeView.insert_Above <TextBox>(20).onTextChange_AlertOnRegExFail() .onEnter((value) => { MethodsFilter = value; loadDataInGui(); }); MethodsTreeView.afterSelect <IMethod>( (iMethod) => { createMethodStreamAndShowInGui(iMethod); }); var optionsPanel = MethodsTreeView.insert_Below <Panel>(25); optionsPanel.add_CheckBox("Open Graph in New Window", 0, 0, (value) => ShowGraphInNewWindow = value) .autoSize(); optionsPanel.add_CheckBox("Join Graph Data", 0, 200, (value) => JoinGraphData = value) .autoSize().bringToFront(); ParametersTreeView = MethodsTreeView.insert_Below <TreeView>(100); MethodsCalledTreeView = ParametersTreeView.insert_Right <TreeView>(200); AstData_MethodStream.afterSelect_ShowInSourceCodeEditor(MethodsCalledTreeView, CodeViewer.editor()); AstData_MethodStream.afterSelect_ShowInSourceCodeEditor(ParametersTreeView, CodeViewer.editor()); MethodsCalledTreeView.afterSelect <INode>((iNode) => createAndShowCodeStream(iNode)); ParametersTreeView.afterSelect <INode>((iNode) => createAndShowCodeStream(iNode)); MethodsTreeView.beforeExpand_PopulateWithList <ISpecial>(); }
public void buildGui() { AstEngine.HostPanel.clear(); var topPanel = AstEngine.HostPanel.add_1x1("Comment's Values", "Source Code", true, 400); CodeViewer = topPanel[1].add_SourceCodeViewer(); CommentsTreeView = topPanel[0].add_TreeView() .sort() .showSelection(); CommentsTreeView.insert_Above <TextBox>(20).onTextChange_AlertOnRegExFail() .onEnter((value) => { CommentsFilter = value; loadDataInGui(); }); AstEngine.AstData.afterSelect_ShowInSourceCodeEditor(CommentsTreeView, CodeViewer.editor()); CommentsTreeView.beforeExpand_PopulateWithList <ISpecial>(); }
public void buildGui() { //..clear(); var topPanel = this.add_1x1("AST INode Value", "Source Code", true, 400); CodeViewer = topPanel[1].add_SourceCodeViewer(); AstValueTreeView = topPanel[0].add_TreeView() .sort() .showSelection() .beforeExpand <List <INode> >( (selectedNode, nodes) => { selectedNode.add_Nodes(nodes); }); AstTypeTreeView = topPanel[0].insert_Left <GroupBox>(200) .set_Text("AST INode Type") .add_TreeView() .sort() .showSelection() .afterSelect <List <INode> >( (iNodes) => { showINodes(iNodes); }); INodeFilter_TextBox = AstTypeTreeView.insert_Above(40, "Filter").add_TextBox("Filter", "") .onTextChange_AlertOnRegExFail() .onEnter((value) => { INodeTypeFilter = value; loadDataInGui(); }); //nodeFilterTextBox.onTextChange_AlertOnRegExFail(); //nodeTypeTextBox.onTextChange_AlertOnRegExFail(); SelectedINodeFilter_TextBox = AstValueTreeView.insert_Above(40, "Search on selected INode Type").add_TextBox("Filter", "") .onTextChange_AlertOnRegExFail() .onEnter( (value) => { INodeValueFilter = value; showINodes(null); }); AllINodesFilter_TextBox = AstValueTreeView.insert_Above(40, "Search on ALL INodes Type").add_TextBox("Filter", "") .onTextChange_AlertOnRegExFail() .onEnter( (value) => { INodeValueFilter = value; showINodes(AstData.iNodes()); }); AstTypeTreeView.onDrop( (fileOrFolder) => { if (fileOrFolder.fileExists()) { AstData.loadFile(fileOrFolder); } else { AstData.loadFiles(fileOrFolder.files(true, "*.cs", "*.vb")); } loadDataInGui(); }); SourceCodeLines = CodeViewer.insert_Below(200, "Source Code Lines").add_TreeView().sort(); AstData.afterSelect_ShowInSourceCodeEditor(AstValueTreeView, CodeViewer.editor()); AstData.afterSelect_ShowInSourceCodeEditor(SourceCodeLines, CodeViewer.editor()); AstValueTreeView.afterSelect <List <INode> >( (iNodes) => { SourceCodeLines.clear(); var addedLines = new List <string>(); foreach (var iNode in iNodes) { var line = iNode.StartLocation.Line; if (line > 0) { var file = AstData.file(iNode); if (file.valid()) { var addedLine = "{0}:{1}".format(file, line); if (addedLines.contains(addedLine).isFalse()) { addedLines.add(addedLine); var fileContents = file.fileContents(); if (fileContents.valid()) { var lineText = fileContents.split_onLines()[line - 1]; var location = "[{0}:{1}] {2} ".format(file.fileName(), line, file); SourceCodeLines.add_Node(lineText, iNode) .add_Node(location); } } } } } //show.info(iNodes[0]); //SourceCodeLines.add_Nodes(iNodes, (iNode)=>iNode.sourceCode); //.showDetails(); //"treeNode selected: {0}".info(tag.typeFullName()); }); }