//----< write summary analysis items to MainWindow ListBox >------- private void packageAndSendSummary() { Repository rep = Repository.getInstance(); foreach (string key in rep.LocationsTable.Keys) { string filename = System.IO.Path.GetFileName(key); foreach (Elem e in rep.LocationsTable[key]) { if (e.type.Contains("public")) { AnalDataPublic ad = new AnalDataPublic(); ad.itemFileName = filename.Truncate(33); ad.itemMethodName = (e.type + " " + e.name).Truncate(33); ad.itemStart = e.beginLine; Action act = () => addAnalPublic(ad); Dispatcher.Invoke(act); } if (e.type == "function") { int size = e.endLine - e.beginLine + 1; int complexity = e.endScopeCount - e.beginScopeCount + 1; if (size > 50 || complexity > 10) { AnalDataItem ai = new AnalDataItem(); ai.itemFileName = filename.Truncate(33); ai.itemMethodName = e.name.Truncate(33); ai.itemStart = e.beginLine; ai.itemSize = size; ai.itemComplexity = complexity; Action act = () => addAnalItem(ai); Dispatcher.Invoke(act); } } } } }
//----< Write full analysis items to MainWindow ListBox >---------- private void packageAndSendResults() { Repository rep = Repository.getInstance(); foreach (string key in rep.LocationsTable.Keys) { string filename = System.IO.Path.GetFileName(key); foreach (Elem e in rep.LocationsTable[key]) { if (e.type.Contains("public")) { AnalDataPublic ad = new AnalDataPublic(); ad.itemFileName = filename.Truncate(33); ad.itemMethodName = (e.type + " " + e.name).Truncate(33); ad.itemStart = e.beginLine; Action act = () => addAnalPublic(ad); Dispatcher.Invoke(act); } else { int size = e.endLine - e.beginLine + 1; int complexity = e.endScopeCount - e.beginScopeCount + 1; string item = String.Format("{0,25} {1,-25} {2,7} {3,7}", filename, e.name, size, complexity); AnalDataItem ai = new AnalDataItem(); ai.itemFileName = filename.Truncate(33); ai.itemMethodName = (e.type + " " + e.name).Truncate(33); ai.itemStart = e.beginLine; ai.itemSize = size; ai.itemComplexity = complexity; Action actItem = () => addAnalItem(ai); Dispatcher.Invoke(actItem); } } } }
void addAnalPublic(AnalDataPublic ad) { listBox1.Items.Add(ad); }
//----< write summary analysis items to MainWindow ListBox >------- private void packageAndSendSummary() { //Repository rep = Repository.getInstance(); foreach (string key in rep.LocationsTable.Keys) { string filename = System.IO.Path.GetFileName(key); foreach (Elem e in rep.LocationsTable[key]) { if (e.type.Contains("public")) { AnalDataPublic ad = new AnalDataPublic(); ad.itemFileName = filename.Truncate(33); ad.itemMethodName = (e.type + " " + e.name).Truncate(33); ad.itemStart = e.beginLine; ad.itemDependency = e.dependency; Action act = () => addAnalPublic(ad); Dispatcher.Invoke(act); } if (e.type == "function") { int size = e.endLine - e.beginLine + 1; int complexity = e.endScopeCount - e.beginScopeCount + 1; if (size > 50 || complexity > 10) { AnalDataItem ai = new AnalDataItem(); ai.itemFileName = filename.Truncate(33); ai.itemMethodName = e.name.Truncate(33); ai.itemStart = e.beginLine; ai.itemSize = size; ai.itemComplexity = complexity; ai.itemDependency = e.dependency; Action act = () => addAnalItem(ai); Dispatcher.Invoke(act); } } } } }
//----< Write full analysis items to MainWindow ListBox >---------- private void packageAndSendResults() { //Repository rep = Repository.getInstance(); foreach (string key in rep.LocationsTable.Keys) { string fullfilename = key; string filename = System.IO.Path.GetFileName(key); List<string> currentfiledependency = CodeAnalysis.Analyzer.fileDependencyTable[fullfilename];// extract file dependency information AnalDataItem fd = new AnalDataItem(); fd.itemFileName = filename; fd.itemMethodName = "file"; foreach (string st in currentfiledependency) { string tmp = st.Substring(st.LastIndexOf("\\")+ 1); fd.itemDependency += tmp + ' ' + ' '; } Action actFile = () => addFileDependency(fd); // #129 Dispatcher.Invoke(actFile); foreach (Elem e in rep.LocationsTable[key])// extract type dependency information { if (e.type.Contains("public")) { AnalDataPublic ad = new AnalDataPublic(); ad.itemFileName = filename.Truncate(33); ad.itemMethodName = (e.type + " " + e.name).Truncate(33); ad.itemStart = e.beginLine; ad.itemDependency = e.dependency; Action act = () => addAnalPublic(ad); // #125 Dispatcher.Invoke(act); } else { int size = e.endLine - e.beginLine + 1; int complexity = e.endScopeCount - e.beginScopeCount + 1; string item = String.Format("{0,25} {1,-25} {2,7} {3,7}", filename, e.name, size, complexity); AnalDataItem ai = new AnalDataItem(); ai.itemFileName = filename.Truncate(33); ai.itemMethodName = (e.type + " " + e.name).Truncate(33); ai.itemStart = e.beginLine; ai.itemSize = size; ai.itemComplexity = complexity; ai.itemDependency = e.dependency; Action actItem = () => addAnalItem(ai); // #129 Dispatcher.Invoke(actItem); } // print out currentfiledependency } } }
// #500 void addAnalPublic(AnalDataPublic ad) { listBox1.Items.Add(ad); // Adds an item to the ItemCollection, ItemCollection: Holds the list of items that constitute the content of an ItemsControl. }