Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (27 sloc) 1.33 KB
import sublime
import sublime_plugin
import config
import auto_complete
import tree_builder
# Classes
class GoogClosureAutoCompleteCommand(sublime_plugin.EventListener):
def on_pre_save(self, view):
if config.db == None:
# TODO: Consider adding this to a queue to be reprocessed once the DB init is done.
config.log.debug("Database is not initialised so ignoring this save event.")
file = view.file_name()
if not(file in config.db["dependencies"]):
config.log.debug("File saved is not in the dependencies map, ignoring.")
namespaces_provided = config.db["dependencies"][file]
tree_builder.add_file_members_to_tree(namespaces_provided, file)
def on_query_completions(self, view, prefix, locations):
default_completions = [(item + "\tDefault", item) for sublist in [view.extract_completions(prefix)]
for item in sublist if len(item) > 3]
default_completions = list(set(default_completions))
line_region = view.line(sublime.Region(locations[0]))
line = str(view.substr(line_region))[:locations[0] - line_region.a]
completions = [(x, x) for x in auto_complete.get_completions(line)]
Jump to Line
Something went wrong with that request. Please try again.