public Thread processCodeViewerContents(bool useAstCachedData) { "Processing source code: {0}".info(MethodStreamFile); //O2AstResolver cachedO2AstResolver = null; //if (AstData_MethodStream != null) // cachedO2AstResolver = AstData_MethodStream.O2AstResolver; ParametersTreeView.backColor(Color.LightPink); MethodsCalledTreeView.backColor(Color.LightPink); return(O2Thread.mtaThread( () => { mapTaintRules(); //AstData_MethodStream = new O2MappedAstData(); //AstData_MethodStream.loadFile(MethodStreamFile); if (AstData_MethodStream.notNull() && useAstCachedData.isFalse()) { "Disposing previously used AstData_MethodStream".debug(); AstData_MethodStream.dispose(); PublicDI.config.gcCollect(); } AstData_MethodStream = MethodStreamFile.getAstData(useAstCachedData); //new List<string>(),false); AstData_MethodStream.showMethodStreamDetailsInTreeViews(ParametersTreeView, MethodsCalledTreeView); ParametersTreeView.backColor(Color.White); MethodsCalledTreeView.backColor(Color.White); })); }
public void createAndShowCodeStream(INode iNode) { O2Thread.mtaThread( () => { CodeStream = AstData_MethodStream.createO2CodeStream(TaintRules, MethodStreamFile, iNode); showCodeStream(); }); }
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 createMethodStreamAndShowInGui(IMethod iMethod) { O2Thread.mtaThread( () => { createMethodStream(iMethod); ParametersTreeView.clear(); MethodsCalledTreeView.clear(); AstData_MethodStream.showMethodStreamDetailsInTreeViews(ParametersTreeView, MethodsCalledTreeView); }); }
public void createMethodStream(IMethod iMethod) { MethodStream = AstEngine.AstData.createO2MethodStream(iMethod); MethodStreamFile = MethodStream.csharpCode().saveWithExtension(".cs"); CodeViewer.open(MethodStreamFile); CodeStreamCodeViewer.open(MethodStreamFile); if (AstData_MethodStream.notNull()) { AstData_MethodStream.Dispose(); } AstData_MethodStream = new O2MappedAstData(); AstData_MethodStream.loadFile(MethodStreamFile); }
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 findINodeAtCaretLocation(ICSharpCode.TextEditor.Caret caret) { if (AstData_MethodStream != null) { var iNode = AstData_MethodStream.iNode(MethodStreamFile, caret); if (iNode != null) { //CodeViewer.editor().selectTextWithColor(iNode); if (iNode is TypeReference) { iNode = iNode.Parent; } CurrentINode = iNode; CurrentINodeLabel.set_Text("current iNode:{0}".format(iNode.typeName())); //"current iNode:{0} : {1}".debug(iNode.typeName(), iNode); //createAndShowCodeStream(iNode); } } }