diff --git a/String.txt b/String.txt new file mode 100644 index 0000000..93ceb63 --- /dev/null +++ b/String.txt @@ -0,0 +1,11 @@ +concat +equals +indexOf +lastIndexOf +length +replace +split +startsWith +substring +trim +valueOf \ No newline at end of file diff --git a/displayfunctions.py b/displayfunctions.py index 70b8765..c094e31 100644 --- a/displayfunctions.py +++ b/displayfunctions.py @@ -1,65 +1,122 @@ -import sublime -import sublime_plugin -import re +# import sublime +# import sublime_plugin +# import re +# import os -completions = [] +# completions = [] -class DisplayFunctionsCommand(sublime_plugin.TextCommand): +# class DisplayFunctionsCommand(sublime_plugin.TextCommand): + +# def run(self, edit): - def run(self, edit): +# sel = self.view.sel()[0] +# word = self.view.word(sel.end() - 1) +# string = self.view.substr(word).strip() - sel = self.view.sel()[0] - word = self.view.word(sel.end() - 1) - string = self.view.substr(word).strip() - regions = self.view.find_all('(? 0: - dir_len = this_file.rfind('\\') #(for Windows) +# if not methods: +# this_file = self.view.file_name() - this_dir = this_file[:(dir_len + 1)] # + 1 for the '/' - filename = this_dir + classname + ".java" +# dir_len = this_file.rfind('/') #(for OSX) - print filename +# if not dir_len > 0: +# dir_len = this_file.rfind('\\') #(for Windows) - with open(filename, 'r') as f: - read_data = f.read() - methods = re.findall("(\w+)\s*\(", read_data) #Regex taken from Java.tmLanguage (needs fix) +# this_dir = this_file[:(dir_len + 1)] # + 1 for the '/' +# filename = this_dir + classname + ".java" - methods = list(set(methods)) #to remove duplicates +# with open(filename, 'r') as f: +# read_data = f.read() +# methods = re.findall("(\w+)\s*\(", read_data) #Regex taken from Java.tmLanguage - print 'methods: ' - print methods +# methods = list(set(methods)) #to remove duplicates - del completions[:] +# del completions[:] - for m in methods: - completions.append(m + "()") +# for m in methods: +# m.strip('h') +# completions.append(m + "()") -class FillAutoComplete(sublime_plugin.EventListener): - def on_query_completions(self, view, prefix, locations): - return [(x, x) for x in completions] \ No newline at end of file +# class FillAutoComplete(sublime_plugin.EventListener): +# def on_query_completions(self, view, prefix, locations): +# return [(x, x) for x in completions] \ No newline at end of file diff --git a/displayfunctions2.py b/displayfunctions2.py new file mode 100644 index 0000000..11b97d3 --- /dev/null +++ b/displayfunctions2.py @@ -0,0 +1,121 @@ +import sublime +import sublime_plugin +import re +import os + +completions = [] + +class DisplayFunctionsCommand(sublime_plugin.TextCommand): + + # while previous word is a method + # go back && count ++ + + # now have root word + + # get type of root + #while less than count + # open up file + # get return type of next method + + #open up file and get methods... + # + + def run(self, edit): + + sel = self.view.sel()[0] + word = self.view.word(sel.end() - 1) + #string = self.view.substr(word).strip() + count = 0 + + prev_word = self.prev(word) + + print self.view.substr(prev_word) + + return + + while "meta.method" in self.view.scope_name(prev_word.begin()): + prev_word = self.prev(prev_word) + count = count + 1 + + root = prev_word + + return + + return_type = self.get_type(root) + + i = 0 + while i < count: + filename = self.make_filename(return_type) + with open(filename, 'r') as f: + read_data = f.read() + return_type = re.search('(\w+)\W+\w+$', read_data) + print return_type + + self.add_functions(return_type) + + def make_filename(self, classname): + this_file = self.view.file_name() + + dir_len = this_file.rfind('/') #(for OSX) + + if not dir_len > 0: + dir_len = this_file.rfind('\\') #(for Windows) + + this_dir = this_file[:(dir_len + 1)] # + 1 for the '/' + return this_dir + classname + ".java" + + def get_package_dir(self): + return os.path.join(sublime.packages_path(), "Display-Functions") + + def prev(self, word): + return self.view.word(word.begin() - 2) + + def next(self, word): + return self.view.word(word.end() + 2) + + def get_type(self, current_word): + string = self.view.substr(current_word) + regions = self.view.find_all('(?