@@ -40,6 +40,9 @@ def find_type_of_variable(self, data, variable):
4040 # Variable not defined in this class...
4141 return None
4242
43+ def get_cmd (self ):
44+ return "java -classpath .:/Users/quarnster/android/android-sdk-mac_86/platforms/android-14/android.jar SublimeJava"
45+
4346 def find_absolute_of_type (self , data , type ):
4447 match = re .search ("class %s" % type , data )
4548 if not match is None :
@@ -52,26 +55,35 @@ def find_absolute_of_type(self, data, type):
5255 match = re .search (regex , data )
5356 if not match is None :
5457 return "%s.%s" % (match .group (1 ), type )
55- return type
5658
57- def run_java (self , cmd ):
59+ # Couldn't find the absolute name of this class so try to
60+ # see if it's in one of the packages imported as
61+ # "import package.*;", or in java.lang
62+ #
63+ packages = re .findall ("[ \t ]*import[ \t ]+(.*)\.\*;" , data )
64+ packages .append ("java.lang" )
65+ output = self .run_java ("%s -findclass %s" % (self .get_cmd (), type ), "\n " .join (packages ))
66+ return output .strip ()
67+
68+ def run_java (self , cmd , stdin = None ):
5869 scriptdir = os .path .dirname (os .path .abspath (__file__ ))
5970 proc = subprocess .Popen (
6071 cmd ,
6172 cwd = scriptdir ,
6273 shell = True ,
63- stdout = subprocess .PIPE
74+ stdout = subprocess .PIPE ,
75+ stdin = subprocess .PIPE
6476 )
65- stdout , stderr = proc .communicate ()
77+ stdout , stderr = proc .communicate (stdin )
6678 return stdout
6779
6880 def complete_class (self , absolute_classname , prefix ):
69- stdout = self .run_java ("java -classpath .:/Users/quarnster/android/android-sdk-mac_86/platforms/android-14/android.jar SublimeJava - complete %s %s" % (absolute_classname , prefix ))
81+ stdout = self .run_java ("%s - complete %s %s" % (self . get_cmd (), absolute_classname , prefix ))
7082 ret = [tuple (line .split (";" )) for line in stdout .split ("\n " )[:- 1 ]]
7183 return sorted (ret , key = lambda a : a [0 ])
7284
7385 def get_return_type (self , absolute_classname , prefix ):
74- stdout = self .run_java ("java -classpath .:/Users/quarnster/android/android-sdk-mac_86/platforms/android-14/android.jar SublimeJava - returntype %s %s" % (absolute_classname , prefix ))
86+ stdout = self .run_java ("%s - returntype %s %s" % (self . get_cmd (), absolute_classname , prefix ))
7587 return stdout .strip ()
7688
7789 def on_query_completions (self , view , prefix , locations ):
@@ -93,6 +105,7 @@ def on_query_completions(self, view, prefix, locations):
93105 t = self .find_type_of_variable (data , var )
94106 print "type is %s" % t
95107 t = self .find_absolute_of_type (data , t )
108+
96109 print "absolute is %s" % (t )
97110
98111 idx = before .find ("." )
0 commit comments