Source

pycode / sourceindex / parser.py

Diff from to

sourceindex/parser.py

 			
 
 
-def parse_rope(filename):
+def parse(filename):
 	prj = project.NoProject()
 	pyc = pycore.PyCore(prj)
 	#resource = resources.File(prj, filename)
 	kind = scope.get_kind()
 	pyobj = scope.pyobject
 	if kind == "Function":
+		parent = scope.parent
+		if parent.get_kind() != "Module":
+			parent_scope = parent.pyobject.get_name()
+		else:
+			parent_scope = ""
 		fname = pyobj.get_name()
 		line = pyobj.get_ast().lineno
-		yield "func", fname, line
+		yield "func", parent_scope, fname, line
 		for param in scope.pyobject.get_parameters().keys():
-			yield "arg", param, line
+			yield "arg", "", param, line
 	elif kind == "Class":
+		parent = scope.parent
+		if parent.get_kind() != "Module":
+			parent_scope = parent.pyobject.get_name()
+		else:
+			parent_scope = ""
 		cname = pyobj.get_name()
 		line = pyobj.get_ast().lineno
-		yield "class", cname, line
+		yield "class", parent_scope, cname, line
 	elif kind == "Module":
-		print "*", scope.get_defined_names()
 		for name, var in scope.get_defined_names().items():
 			pyobject = getattr(var, "pyobject", None)
 			if pyobject:
-				yield "global", name, getattr(pyobject, "get_ast", None)
+				ast = getattr(pyobject, "get_ast", None)
+				if ast:
+					yield "global", "", name, ast().lineno
 	for child in scope.get_scopes():
 		for item in parse_scope(child):
 			yield item
 
 
-	
-parse = parse_rope
+
 
 
 if __name__ == "__main__":