Example #1
0
        public void CheckThatObjectIsNotUsed_TMUser()
        {
            var methods = tmWebServices.type().methods();
            Assert.Less(100,methods.size());
            var returnTypeMappings = new Dictionary<string, List<MethodInfo>>();

            //Create a Mapping based on the return Type of all WebServices methods
            foreach (var method in methods)
            {
                var returnType = method.ReturnType;
                if (returnType.IsGenericType)
                    foreach(var genericParameter in returnType.GetGenericArguments())
                        returnTypeMappings.add(genericParameter.Name, method);
                returnTypeMappings.add(returnType.Name, method);
            }
            returnTypeMappings.Keys.toString().info();

            var typeNames = returnTypeMappings.Keys.toList();
            Assert.Less     (15, typeNames.size());

            Assert.IsTrue (typeNames.contains("TeamMentor_Article"));
            Assert.IsTrue (typeNames.contains("TM_Library"));
            Assert.IsTrue (typeNames.contains("Folder_V3"));
            Assert.IsTrue (typeNames.contains("View_V3"));
            Assert.IsTrue (typeNames.contains("Library"));
            Assert.IsTrue (typeNames.contains("Guid"));
            Assert.IsTrue (typeNames.contains("TM_User")  , "TM_User object should be used instead of TMUser");

            Assert.IsFalse(typeNames.contains("TMUser")   , "TMUser object must not be exposed on a WebService (since it contains all user info, including its passwordHash)");

            //returnTypeMappings["TMUser"].names().toString().info();
        }
 public static Dictionary<string, string> queryParameters_Indexed_ByName(this Uri uri)
 {
     var queryParameters = new Dictionary<string,string>();
     if (uri.notNull())
     {
         var query = uri.Query;
         if (query.starts("?"))
             query = query.removeFirstChar();
         foreach(var parameter in query.split("&"))
             if (parameter.valid())
             {
                 var splitParameter = parameter.split("=");
                 if (splitParameter.size()==2)
                     if (queryParameters.hasKey(splitParameter[0]))
                     {
                         "duplicate parameter key in property '{0}', adding extra parameter in a new line".info(splitParameter[0]);
                         queryParameters.add(splitParameter[0], queryParameters[splitParameter[0]].line() + splitParameter[1]);
                     }
                     else
                         queryParameters.add(splitParameter[0], splitParameter[1]);
                 else
                     "Something's wrong with the parameter value, there should only be one = in there: '{0}' ".info(parameter);
             }
     }
     return queryParameters;
 }
 public static Dictionary<string, List<string>> indexed_By_MemberName(this List<ValidationResult> validationResults)
 {
     var mappedData = new Dictionary<string, List<string>>();
     foreach(var validationResult in validationResults)
         foreach (var memberName in validationResult.MemberNames)
             mappedData.add(memberName, validationResult.ErrorMessage);
     return mappedData;
 }
Example #4
0
 public static Dictionary<string, string> GetAvailableScripts()
 {
     var files = HttpContextFactory.Server.MapPath(TBOT_SCRIPTS_FOLDER)
                                   .files(true, "*.cshtml");
     var mappings = new Dictionary<string, string>();
     foreach (var file in files)
         mappings.add(file.fileName_WithoutExtension(), file);
     return mappings;
     //return files.toDictionary((file) => file.fileName_WithoutExtension()); //this doesn't handle duplicate files names
 }
        public static void showInTreeView(this MethodMappings methodMappings, TreeView treeView, string filter, bool showSourceCodeSnippets, bool onlyShowSourceCodeLine)
        {
            treeView.parent().backColor("LightPink");
            treeView.visible(false);
            treeView.clear();
            var indexedMappings = methodMappings.indexedByKey(filter);
            if (onlyShowSourceCodeLine)
            {
                //do this so that we don't add more than one item per line
                var indexedByFileAndLine = new Dictionary<string, MethodMapping>();

                foreach(var item in indexedMappings)
                    foreach(var methodMapping in item.Value)
                        if (methodMapping.File.valid())
                        {
                            var key = "{0}_{1}".format(methodMapping.File, methodMapping.Start_Line);
                            indexedByFileAndLine.add(key, methodMapping);
                        }
                // now group then by the same text in the SourceCodeLine
                var indexedBySourceCodeLine =  new Dictionary<string, List<MethodMapping>>();
                foreach(var methodMapping in indexedByFileAndLine.Values)
                    indexedBySourceCodeLine.add(methodMapping.sourceCodeLine(), methodMapping);

                //Finally show then
                foreach(var item  in indexedBySourceCodeLine)
                {
                    var uniqueTextNode = treeView.add_Node(item.Key, item.Value,true);
                }
            }
            else
            {
                foreach(var item in indexedMappings)
                {
                    var keyNodeText = "{0}                       ({1})".format(item.Key, item.Value.size());
                    var keyNode= treeView.add_Node(keyNodeText, item.Value,true);
                }
                treeView.afterSelect<List<MethodMapping>>(
                    (mappings)=>{
                                    var keyNode = treeView.selected();
                                    keyNode.clear();
                                    foreach(var methodMapping in mappings)
                                    {
                                        var nodeText = (showSourceCodeSnippets)
                                            ? methodMapping.sourceCodeLine()
                                            : "{0} - {1}".format(methodMapping.INodeType,methodMapping.SourceCode);
                                        keyNode.add_Node(nodeText, methodMapping);
                                    }
                    });
            }
            treeView.parent().backColor("Control");
            treeView.visible(true);
        }
     	public static Dictionary<string,string> executeScript_ConvertTo_DicionaryStringString(this API_Azure_via_WebREPL apiAzure, string script, string nameKey, string valueKey)
     	{
     		var data = new Dictionary<string,string>();
     		var response = apiAzure.executeScript(script);
     		if (response.valid())
     		{
     			var items = (Object[])response.json_Deserialize();			
				if (items.notNull())						
					foreach(Dictionary<string,object> item in items)				
						data.add(item[nameKey].str(),item[valueKey].str());						
     		}
     		return data;
     	}	
		public static Dictionary<int, List<Java_Variable>> variables_byIndex(this Java_Method method)
		{
			var variables_byIndex = new Dictionary<int, List<Java_Variable>>();
			foreach(var variable in method.Variables)
				variables_byIndex.add(variable.Index, variable);
			return variables_byIndex;
		}
		public static Dictionary<string, string> methods_MappedTo_EnclosingMethod(this API_IKVMC_Java_Metadata javaMetadata)
		{
			var enclosingMethods = new Dictionary<string, string>();
			foreach(var _class in javaMetadata.Classes)
				if (_class.EnclosingMethod.notNull())
					foreach(var method in _class.Methods)
						enclosingMethods.add(method.Signature, _class.EnclosingMethod);
			return 	enclosingMethods;			
		}		
		public static Dictionary<string, List<Java_Class>> classes_MappedTo_EnclosingMethod(this API_IKVMC_Java_Metadata javaMetadata)
		{
			var enclosingMethods = new Dictionary<string, List<Java_Class>>();
			foreach(var _class in javaMetadata.Classes)
				if (_class.EnclosingMethod.notNull())
					enclosingMethods.add(_class.EnclosingMethod, _class);
			return 	enclosingMethods;	
		}
        public static Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>> externalMethodsAndProperties(this O2MappedAstData astData, IMethod iMethod)
        {        	
        	var externalMethods = new Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>>();
        	// add the current method
        	
        	externalMethods.add(iMethod.DotNetName,  new KeyValuePair<INode,IMethodOrProperty>(astData.methodDeclaration(iMethod) ,iMethod));
        	
        	var iNodesAdded = new List<INode>();
        	
        	foreach (var methodCalled in astData.calledINodesReferences(iMethod))
			 	if (methodCalled is MemberReferenceExpression)
                {                             	
                	var memberRef = (MemberReferenceExpression)methodCalled;                 	
                	{                	
                		var methodOrProperty = astData.fromMemberReferenceExpressionGetIMethodOrProperty(memberRef);
                		if(methodOrProperty.notNull())                     	
                		{
                			externalMethods.add(methodOrProperty.DotNetName, new KeyValuePair<INode,IMethodOrProperty>(memberRef,methodOrProperty)); 
                			iNodesAdded.Add(memberRef);
                		}
                		else
                			externalMethods.add(astData.getTextForINode(memberRef),new KeyValuePair<INode,IMethodOrProperty>(memberRef,null));
                	}
				}
			
			
        	foreach(var mapping in astData.calledIMethods_getMappings(iMethod))
        	{                
                var iMethodMapping = mapping.Key;
                var iNodeMapping = mapping.Value;
                if (iNodesAdded.Contains(iNodeMapping).isFalse())
                	if (iNodeMapping is ObjectCreateExpression ||
                	   ((iNodeMapping is InvocationExpression &&
                	    (iNodeMapping as InvocationExpression).TargetObject.notNull() && 
                	    iNodesAdded.Contains((iNodeMapping as InvocationExpression).TargetObject).isFalse())))
                	 {                	 	
						var nodeText = (iMethodMapping.notNull())
												? iMethodMapping.DotNetName
												: astData.getTextForINode(iNodeMapping);
						externalMethods.add(nodeText, new KeyValuePair<INode,IMethodOrProperty>(iNodeMapping,iMethodMapping)); 				
					 }	
            }
        	
        	return externalMethods;
        }
		public void loadFiles(string filesPath, List<string> filesToLoad)
		{						
			sourceCode.set_Text("Loading files from: {0}".format(filesPath));
			Path.set_Text(filesPath);
			var filesContent = new Dictionary<string,string>();
			var nonBinaryFiles = new List<string>();
			foreach(var file in filesToLoad) 
				if (file.isBinaryFormat().isFalse()) 
					nonBinaryFiles.add(file);
			
			foreach(var file in nonBinaryFiles) 
					filesContent.add(file.remove(filesPath),file.contents());	
					
			searchEngine = new SearchEngine();
			searchEngine.loadFiles(nonBinaryFiles); 			
			
			//searchEngine.fixH2FileLoadingIssue();
			
			leftPanel.clear();
			treeView = leftPanel.add_TreeViewWithFilter(filesContent); 
			treeView.afterSelect<string>(
				(fileContents)=>{					
									sourceCode.open(filesPath + treeView.selected().get_Text());
								});						
			sourceCode.colorCodeForExtension(treeView.selected().str());
			sourceCode.set_Text("");
			textSearch_TextBox = leftPanel.controls<TextBox>(true)[1];
			textSearch_TextBox.onEnter(
				(text)=>{
					var searchResults = searchEngine.searchFor(text);
					dataGridView.loadInDataGridView_textSearchResults(searchResults);  
				});
			
			
		}		
Example #12
0
		public static Dictionary<string, SpringMvcController> controllers_by_JavaClass(this SpringMvcMappings mvcMappings)
		{
			var controllers_by_JavaClass = new Dictionary<string, SpringMvcController>();
			foreach(var controller in mvcMappings.Controllers)
				controllers_by_JavaClass.add(controller.JavaClass, controller);
			return controllers_by_JavaClass;
		}
		public static List<Image> show_ImagesList_In_TreeView(this API_AmazonEC2 amazonEC2, AmazonEC2Client ec2Client, Control control)
		{				
			var treeView = control.clear().add_TreeView_with_PropertyGrid(false).sort();  	 
			treeView.parent().backColor(System.Drawing.Color.Azure);
			treeView.visible(false);
			Application.DoEvents();
			var imagesList = amazonEC2.getImagesList(ec2Client); 
			
			Func<Amazon.EC2.Model.Image,string> imageName = 
				(image)=> (image.Description.valid())
									? "{0} - {1}".format(image.Description, image.Name)
									: "{0}".format(image.Name).trim();
									
			Action<string> mapByProperty  = 
				(propertyName)=>{				
									var byPropertyNode = treeView.add_Node("by {0}".format(propertyName),"");
									foreach(var distinctPropertyValue in imagesList.Select((image)=>image.property(propertyName).str()).Distinct())
									{										
										var byDistinctPropertyValue = byPropertyNode.add_Node(distinctPropertyValue,"");

										var mappedByImageName = new Dictionary<string, List<Image>>();
										foreach(var imageInProperty in imagesList.Where((image) => image.property(propertyName).str() == distinctPropertyValue))
											mappedByImageName.add(imageName(imageInProperty),imageInProperty);																				
											
										foreach(var mappedData in mappedByImageName)
										{
											if (mappedData.Value.size() > 1)
												byDistinctPropertyValue.add_Node("{0}".format(mappedData.Key,mappedData.Value.size()))
														      		   .add_Nodes(mappedData.Value, imageName);
											else
												byDistinctPropertyValue.add_Node(imageName(mappedData.Value.first()),mappedData.Value.first());
										}			     
									}													  			
								};
			mapByProperty("Visibility");
			mapByProperty("ImageOwnerAlias");
			mapByProperty("Platform"); 
			mapByProperty("Architecture"); 
			"Completed processing show_ImagesList_In_TreeView".info();
			if (treeView.nodes().size()>0)
				treeView.backColor(System.Drawing.Color.White); 
			treeView.visible(true);				
			return imagesList;
		}
 public static Dictionary<string, string> files_Indexed_by_FileName(this List<string> files)
 {
     var files_Indexed_By_FileName = new Dictionary<string,string>();
     foreach(var file in files)
         files_Indexed_By_FileName.add(file.fileName(), file);
     return files_Indexed_By_FileName;
 }
 public static Dictionary<string, List<string>> files_Mapped_by_Extension(this List<string> files)
 {
     var files_Indexed_By_FileName = new Dictionary<string,List<string>>();
     foreach(var file in files)
         files_Indexed_By_FileName.add(file.extension(), file);
     return files_Indexed_By_FileName;
 }
		public static Dictionary<string, List<MethodMapping>> indexedByKey(this MethodMappings methodMappings, string filter)
		{
			var result = new Dictionary<string, List<MethodMapping>>(); 
			if (methodMappings.MethodMappingItems.isNull())
				"In IndexedByKey there were no methodMappingsItems (filer = '{0}'".error(filter ?? "");
			else
				foreach(var mappingItem in methodMappings.MethodMappingItems)
				{
					var key = mappingItem.Key;   
					if (filter.valid().isFalse() || key.regEx(filter)) 
						foreach(var methodMapping in mappingItem.MethodMappings)
						{
							methodMapping.Key = key;					//Hack(26-Aug-2010): fix until we create all methodMappings with this Key valu	e
							result.add(key, methodMapping);
						}
				}
			return result;
		}
        public static string add_Properties(this O2MappedAstData astData, string targetFolder)
        {
        	//return methodMappingsIndexedBySignature;
        	//handle Properties
			var propertyMappings = new Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>>();
//			show.info(methodMappingsIndexedBySignature);

            var fileName = "_MethodMapings_For_Properties";
            //var md5Hash = fullName.safeFileName().md5Hash();
            var savedPropertiesMappingsFile = targetFolder.pathCombine(fileName) + ".xml";
            if (savedPropertiesMappingsFile.fileExists())
                return savedPropertiesMappingsFile;

			var propertyRefs = new List<INode>();
			foreach(var propertyDeclaration in astData.MapAstToNRefactory.IPropertyToPropertyDeclaration.Values)
			{
				"Mapping property: {0}".info(propertyDeclaration.Name);
				
				propertyRefs.add(propertyDeclaration.iNodes<INode, MemberReferenceExpression>());
                propertyRefs.add(propertyDeclaration.iNodes<INode, InvocationExpression>());
                propertyRefs.add(propertyDeclaration.iNodes<INode, ObjectCreateExpression>());
                
			}
//			show.info(propertyRefs);
			try
			{
				foreach(Expression propertyRef in propertyRefs)
				{
					var methodOrProperty = astData.fromExpressionGetIMethodOrProperty(propertyRef);				
					var nodeText =	astData.getTextForINode(propertyRef);// propertyRef.str();
					propertyMappings.add(nodeText, new KeyValuePair<INode,IMethodOrProperty>(propertyRef,methodOrProperty)); 
				}			
			}
			catch(Exception ex)
			{
				ex.log("in add_Property");
			}
            var tempFile = astData.saveMappings(propertyMappings);
            if (tempFile.fileExists())
				Files.MoveFile(tempFile, savedPropertiesMappingsFile);            
            return savedPropertiesMappingsFile;
			/// PROPERTIES
        }
        public static Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>> indexedBy_ResolvedSignature( this Dictionary<IMethod, Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>>> iMethodMappings)
        {
        	var o2Timer = new O2Timer("Calculated indexedBy_ResolvedSignature").start();
        	var results = new Dictionary<string,List<KeyValuePair<INode,IMethodOrProperty>>>();
        	foreach(var iMethodMapping in iMethodMappings) 
        		foreach(var mapping in iMethodMapping.Value)
        			foreach(var keyValuePair in mapping.Value)	        			        			
	        			results.add(mapping.Key, keyValuePair);	        		
			o2Timer.stop();
        	return results;        	
        }
 public static Dictionary<string, string> values(this List<FieldDeclaration> fieldDeclarations)
 {
     var values = new Dictionary<string, string>();
     foreach (var variable in fieldDeclarations.variables())
     {
         if (variable.Initializer is PrimitiveExpression)
             values.add(variable.Name, (variable.Initializer as PrimitiveExpression).StringValue);
         else
             values.add(variable.Name, variable.Initializer.str());
     }
     return values;
 }
Example #20
0
		public static Dictionary<string, List<SpringMvcController>> controllers_by_CommandClass(this SpringMvcMappings mvcMappings)
		{
			var byCommandClass = new Dictionary<string, List<SpringMvcController>>();

			foreach(var controller in mvcMappings.Controllers)
			{
				if (controller.CommandClass.valid())
					byCommandClass.add(controller.CommandClass, controller);
				//var commandClass= controller.CommandClass ?? "[no commandName]";
				//byCommandClass.add(commandClass, controller);
			}
			return byCommandClass;
		}
 public static Dictionary<string, VariableDeclaration> filtered_ByName(this List<FieldDeclaration> fieldDeclarations)
 {
     var filtered_ByName = new Dictionary<string, VariableDeclaration>();
     foreach (var fieldDeclaration in fieldDeclarations)
         foreach (var variable in fieldDeclaration.Fields)
             filtered_ByName.add(variable.Name, variable);
     return filtered_ByName;
 }
		public static Dictionary<string,List<IO2Finding>> indexBy(this List<IO2Finding> o2Findings, Func<O2Finding,string> calculateIndex)
		{
			var indexedData = new Dictionary<string,List<IO2Finding>>();
			foreach(var o2Finding in o2Findings)
				indexedData.add(calculateIndex((O2Finding)o2Finding),o2Finding);
			return indexedData;
		}
		public static Dictionary<string,List<RunningInstance>> getEC2Instances(this API_AmazonEC2 amazonEC2,bool onlyShowDefaultRegion)
		{		
			var instances = new Dictionary<string,List<RunningInstance>>();		
			
			var reservations = new List<Reservation>();
			if (onlyShowDefaultRegion)
				reservations.add(amazonEC2.getReservationsInRegion(amazonEC2.DefaultRegion));
			else
				foreach(var region in amazonEC2.getEC2Regions()) 
					reservations.add(amazonEC2.getReservationsInRegion(region));				        
						
			foreach(var reservation in reservations)
					foreach(var runningInstance in reservation.RunningInstance)
						instances.add(reservation.GroupName.Aggregate((a, b) => a + ',' + b),
									  runningInstance); 			
			return instances;			
		}
    	public static API_Veracode_DetailedXmlFindings show_Flaws_In_SourceCodeViewer(this API_Veracode_DetailedXmlFindings apiVeracode, Control control)
    	{
    		var topPanel = control.clear();
    		var codeViewer = topPanel.add_GroupBox("Flaw SourceCode reference").add_SourceCodeViewer();
			var treeView = codeViewer.parent().insert_Left("Flaws").add_TreeView(); 
			var propertyGrid = treeView.insert_Below(150,"Flaw properties")
									   .add_PropertyGrid().helpVisible(false);
			var description = codeViewer.insert_Below(150,"Flaw description")
									    .add_TextArea();
									    
			treeView.afterSelect<FlawType>(
				(flaw)=>{				
							propertyGrid.show(flaw);				
							if (apiVeracode.hasLocalSourceCodeFile(flaw))
							{
								codeViewer.open(apiVeracode.sourceCodeFile(flaw));
								codeViewer.editor().gotoLine((int)flaw.line); 
							}
							else
								codeViewer.set_Text(".. no source code available...");
							description.set_Text(flaw.description.fix_CRLF());
							treeView.focus();
						});
			 												
			treeView.beforeExpand<List<FlawType>>(
				(flaws)=>{
							var selectedNode = treeView.selected();
							if (selectedNode.nodes().size()== 1)
							{
								selectedNode.clear();
								selectedNode.add_Nodes(flaws, 
													   (flaw)=> flaw.type, 
													   (flaw) => apiVeracode.hasLocalSourceCodeFile(flaw)
																		? Color.DarkGreen
																		: Color.DarkRed
													   );
							}
						 });
										
			Action<TreeNode, Dictionary<string, List<FlawType>>> addFlawsToTreeNode =
				(treeNode, mappedFlaws) 
				   =>{
						foreach(var item in mappedFlaws)			
							treeNode.add_Node(item.Key,item.Value,item.Value.size()>0);
									/*.*/
					  };
					  
			Action showData = 		  
				()=>{
						treeView.clear();
						var o2Timer = new O2Timer("Building XRefs for flaws").start();
						var mappedFlawsByType = new Dictionary<string, List<FlawType>>();
						var mappedFlawsByCategoryName = new Dictionary<string, List<FlawType>>();
						var mappedFlawsByFile = new Dictionary<string, List<FlawType>>();
						var mappedFlawsBySeverity = new Dictionary<string, List<FlawType>>();
						
						foreach(var flaw in apiVeracode.flaws()) 
						{
							mappedFlawsByCategoryName.add(flaw.categoryname, flaw);
							mappedFlawsByType.add(flaw.type, flaw);
							mappedFlawsByFile.add(flaw.sourceCodeFile(), flaw);
							mappedFlawsBySeverity.add(flaw.severity.str(), flaw);	
						}
						o2Timer.stop();
						o2Timer = new O2Timer("Populating treeview").start();			
						addFlawsToTreeNode(treeView.add_Node("by Category Name"), mappedFlawsByCategoryName);
						addFlawsToTreeNode(treeView.add_Node("by Type"), mappedFlawsByType);
						addFlawsToTreeNode(treeView.add_Node("by File"), mappedFlawsByFile);
						addFlawsToTreeNode(treeView.add_Node("by Severity"),mappedFlawsBySeverity);
						o2Timer.stop();		
					};
			
			treeView.onDrop(
				(file)=>{
							apiVeracode.load(file);
							showData(); 			
						});
			if (apiVeracode.ReportXmlFile.valid())
				showData(); 
			else
				treeView.add_Node("drop a Veracode DetailedFindings Xml (or zip) file to view it"); 			
			
			
//			"There were {0} Files That Could Not Mapped Locally".error(apiVeracode.FilesThatCouldNotMappedLocally.size());			
			/*if (treeView.nodes()>0))
			{
				treeView.nodes()[0]
					 	.expand().nodes()[2].selected();
			}
			*/
			return apiVeracode;
    	}
 	public static Dictionary<string,string> environmentVariables(this API_Azure_via_WebREPL apiAzure)
 	{
 		var rawData = apiAzure.executeScript(@"return Environment.GetEnvironmentVariables();");
 		var rawDictionary = rawData.json_Deserialize() as Dictionary<string,object>;
 		var environmentVariables = new Dictionary<string,string>();
 		foreach(var item in rawDictionary)
 			environmentVariables.add(item.Key, item.Value.str());
 		return environmentVariables;     		
 	}
Example #26
0
		public static Dictionary<string, List<Java_Class>> classes_MappedTo_Implementations(this API_IKVMC_Java_Metadata javaMetadata)
		{	
			//next map the Interfaces
			var implementations = new Dictionary<string, List<Java_Class>>();
			foreach(var _class in javaMetadata.Classes)			
				foreach(var _interface in _class.Interfaces)
					implementations.add(_interface, _class);
					
					
			//next map the SuperClasses
			var classes_bySignature = javaMetadata.classes_IndexedBySignature();
			foreach(var _class in javaMetadata.Classes)			
				if (_class.SuperClass.valid() && classes_bySignature.hasKey(_class.SuperClass))
					implementations.add(_class.SuperClass, _class);//.Signature, classes_bySignature[_class.SuperClass]);
					
			return implementations;
		}
 public static Dictionary<string,List<KeyValuePair<IO2Finding, IO2Trace>>> filterBy_Traces_Property(this List<IO2Finding> iO2Findings, string propertyName)
 {
 	var filteredData = new Dictionary<string,List<KeyValuePair<IO2Finding, IO2Trace>>>();
 	foreach(var iO2Finding in iO2Findings)
 		foreach(var iO2Trace in iO2Finding.allTraces())
 		{
 			var propertyValue = (iO2Trace as O2Trace).prop(propertyName).str();
 			if (propertyValue.valid())
 			{
 				var keyValuePair = new KeyValuePair<IO2Finding, IO2Trace>(iO2Finding, iO2Trace);        			
 				filteredData.add(propertyValue.trim(), keyValuePair);        				
 			}        			
 		}        
 	return filteredData;
 }	
	public static MethodMappings loadAndMergeMethodMappings (this List<string> targetFiles)
	{
		"Creating MethodMappings from {0} files".info(targetFiles.size());
		var mergedMethodMappings = new Dictionary<string, List<MethodMapping>>();
		foreach(var targetFile in targetFiles)
		{
		
			var tempMethodMappings = loadMethodMappings(targetFile); 
			var indexedMappings = tempMethodMappings.indexedByKey(""); 
			foreach(var item in indexedMappings)
				foreach(var methodMapping in item.Value)									
					mergedMethodMappings.add(item.Key, methodMapping);																	
		}
		var methodMappings = new MethodMappings();							
		foreach(var item in mergedMethodMappings)
		{
			var methodMappingItem = new MethodMappingItem() { Key = item.Key};
			methodMappingItem.MethodMappings = item.Value;
			methodMappings.MethodMappingItems.Add(methodMappingItem); 
		}
		return methodMappings;
	}
		public static Dictionary<string,List<IO2Finding>> indexBy(this List<IO2Finding> o2Findings, string propertyToIndexBy)
		{
			var indexedData = new Dictionary<string,List<IO2Finding>>();
			foreach(var o2Finding in o2Findings)
				indexedData.add(o2Finding.prop(propertyToIndexBy).str(),o2Finding);
			return indexedData;
		}
Example #30
0
		public static Dictionary<string, Java_Class> indexedBySignature(this List<Java_Class> classes)
		{
			var classesBySignature = new Dictionary<string, Java_Class>();
			if (classes.notNull())
				foreach(var _class in classes) 
					classesBySignature.add(_class.Signature, _class);
			return classesBySignature;
		}