You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/08/07 18:27:08 UTC

svn commit: r429424 - /incubator/xap/trunk/src/xap/util/ObjectHierarchyAnalyzer.js

Author: mturyn
Date: Mon Aug  7 11:27:07 2006
New Revision: 429424

URL: http://svn.apache.org/viewvc?rev=429424&view=rev
Log:
Now can analyze a hierarchy (or a list of files) and produce a name of all the xap.,dojo ., and google.  objects referenced in the code for each of them.

Modified:
    incubator/xap/trunk/src/xap/util/ObjectHierarchyAnalyzer.js

Modified: incubator/xap/trunk/src/xap/util/ObjectHierarchyAnalyzer.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/ObjectHierarchyAnalyzer.js?rev=429424&r1=429423&r2=429424&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/util/ObjectHierarchyAnalyzer.js (original)
+++ incubator/xap/trunk/src/xap/util/ObjectHierarchyAnalyzer.js Mon Aug  7 11:27:07 2006
@@ -162,5 +162,58 @@
 			return theHolder;
 		}
 	}
-}
+} 
+
+// 
+
+
+xap.util.ObjectHierarchyAnalyzer.objectReferenceRegexp = /\b(xap|google|dojo)\.[a-z][a-z\.]+\.[A-Z][^\.\s \("'#,;=]+/g ;
+
+xap.util.ObjectHierarchyAnalyzer.getReferencedObjects = function(classStringArray,printP){
+
+	var dependencies = new Object() ;
 
+	var all_class_names = classStringArray ;
+
+	if (!xap.util.ObjectHierarchyAnalyzer._requestService) {
+		xap.util.ObjectHierarchyAnalyzer._requestService = new xap.requestservice.RequestService(this);
+	}
+
+	var srcDir = Xap._sourceRootDir+"/src/" ;
+	
+	if(!classStringArray){
+	// Ideally, the file with all the class names in it should be updated with every build:
+		var src = xap.util.ObjectHierarchyAnalyzer._requestService.retrieve(srcDir+"/xap/util/allXapClassStrings.txt").responseText;
+		all_class_names = src.split("\n") ;
+		for( var i=0; i < all_class_names.length; ++i){
+			all_class_names[i] = all_class_names[i].replace(/\s/g,"") ;
+		}
+	}
+	
+	for(var i=0; i <  all_class_names.length; ++i){
+		var  className = all_class_names[i] ;
+		dependencies[className] = [] ;
+		// Build a file path from a class name:
+		var filePath = srcDir + className.replace(xap.util.ObjectHierarchyAnalyzer.allFullstopsRegexp, "/") + ".js";
+		// Get the source for the class:
+		var classSource = xap.util.ObjectHierarchyAnalyzer._requestService.retrieve(filePath).responseText ;
+		
+		var objMatches = classSource.match(xap.util.ObjectHierarchyAnalyzer.objectReferenceRegexp ) ;
+		
+		if( objMatches != null ){
+			dependencies[className] = xap.util.ArrayHelper.unique(objMatches).sort() ;
+		// Everything depends on itself, so remove that trivial dependency from the list:
+			xap.util.ArrayHelper.removeElement(dependencies[className], className) ;
+		}
+		
+	}
+
+	if(printP){
+		for(var className in dependencies){
+			document.writeln("<br>"+className+"::"+dependencies[className].join(",")) ;	
+		}
+	}
+
+	return dependencies ;
+
+}