feat(SublimeText2.WebPackages): cache packages

This commit is contained in:
Iristyle
2013-04-04 08:54:25 -04:00
parent 590d7a44f9
commit 1e6f643a1b
1026 changed files with 79077 additions and 0 deletions

View File

@@ -0,0 +1,236 @@
import sublime, sublime_plugin
import re
import os
import threading
import coffee_utils
from coffee_utils import debug
from copy import copy
COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY = "coffee_autocomplete"
COFFEESCRIPT_AUTOCOMPLETE_STATUS_MESSAGE = "Coffee: Autocompleting \"%s\"..."
final_completions = []
status = {"working": False}
# TODO:
# - Type hinting using comments containing square brackets [Type] on same line or previous line
# - Codo docs searching for function parameter types
# - Better symbol parsing. Assignment lookups should consider the entire set of operands.
# X Consider all super classes (support extends)
# - Consider another feature: Override/implement methods
# - Full assignment traceback (that = this, a = b = c, knows what c is)
# - Check contents of currently open views
# - Built in types
class CoffeeAutocomplete(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
completions = copy(final_completions)
working = status["working"]
# If there is a word selection and we're looking at a coffee file...
if not completions and coffee_utils.is_coffee_syntax(view) and not working:
status["working"] = True
current_location = locations[0]
# Get the window
self.window = sublime.active_window()
# http://www.sublimetext.com/forum/viewtopic.php?f=6&t=9076
settings = sublime.load_settings(coffee_utils.SETTINGS_FILE_NAME)
built_in_types_settings = sublime.load_settings(coffee_utils.BUILT_IN_TYPES_SETTINGS_FILE_NAME)
built_in_types = built_in_types_settings.get(coffee_utils.BUILT_IN_TYPES_SETTINGS_KEY)
if not built_in_types:
built_in_types = []
custom_types_settings = sublime.load_settings(coffee_utils.CUSTOM_TYPES_SETTINGS_FILE_NAME)
custom_types = custom_types_settings.get(coffee_utils.CUSTOM_TYPES_SETTINGS_KEY)
if not custom_types:
custom_types = []
built_in_types.extend(custom_types)
# Pull the excluded dirs from preferences
excluded_dirs = settings.get(coffee_utils.PREFERENCES_COFFEE_EXCLUDED_DIRS)
if not excluded_dirs:
excluded_dirs = []
restricted_to_dirs = settings.get(coffee_utils.PREFERENCES_COFFEE_RESTRICTED_TO_PATHS)
if not restricted_to_dirs:
restricted_to_dirs = []
# List of all project folders
project_folder_list = self.window.folders()
if restricted_to_dirs:
specific_project_folders = []
for next_restricted_dir in restricted_to_dirs:
for next_project_folder in project_folder_list:
next_specific_folder = os.path.normpath(os.path.join(next_project_folder, next_restricted_dir))
specific_project_folders.append(next_specific_folder)
project_folder_list = specific_project_folders
function_return_types = settings.get(coffee_utils.FUNCTION_RETURN_TYPES_SETTINGS_KEY)
if not function_return_types:
function_return_types = []
this_aliases = settings.get(coffee_utils.PREFERENCES_THIS_ALIASES)
if not this_aliases:
this_aliases = []
member_exclusion_regexes = settings.get(coffee_utils.PREFERENCES_MEMBER_EXCLUSION_REGEXES)
if not member_exclusion_regexes:
member_exclusion_regexes = []
# Lines for the current file in view
current_file_lines = coffee_utils.get_view_content_lines(view)
# TODO: Smarter previous word selection
preceding_symbol = coffee_utils.get_preceding_symbol(view, prefix, locations)
immediately_preceding_symbol = coffee_utils.get_preceding_symbol(view, "", locations)
preceding_function_call = coffee_utils.get_preceding_function_call(view).strip()
# Determine preceding token, if any (if a period was typed).
token = coffee_utils.get_preceding_token(view).strip()
# TODO: Smarter region location
symbol_region = sublime.Region(locations[0] - len(prefix), locations[0] - len(prefix))
if (preceding_function_call or token or coffee_utils.THIS_SUGAR_SYMBOL == preceding_symbol) and coffee_utils.is_autocomplete_trigger(immediately_preceding_symbol):
self.window.active_view().run_command('hide_auto_complete')
thread = CoffeeAutocompleteThread(project_folder_list, excluded_dirs, this_aliases, current_file_lines, preceding_symbol, prefix, preceding_function_call, function_return_types, token, symbol_region, built_in_types, member_exclusion_regexes)
thread.start()
self.check_operation(thread, final_completions, current_location, token, status)
else:
status["working"] = False
elif completions:
self.clear_completions(final_completions)
return completions
def check_operation(self, thread, final_completions, current_location, token, status, previous_progress_indicator_tuple=None):
if not thread.is_alive():
if thread.completions:
final_completions.extend(thread.completions)
# Hide the default auto-complete and show ours
self.window.active_view().run_command('hide_auto_complete')
sublime.set_timeout(lambda: self.window.active_view().run_command('auto_complete'), 1)
self.window.active_view().erase_status(COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY)
status["working"] = False
else:
token = thread.token
# Create the command's goto definition text, including the selected word. For the status bar.
status_text = COFFEESCRIPT_AUTOCOMPLETE_STATUS_MESSAGE % token
# Get a tuple containing the progress text, progress position, and progress direction.
# This is used to animate a progress indicator in the status bar.
current_progress_indicator_tuple = coffee_utils.get_progress_indicator_tuple(previous_progress_indicator_tuple)
# Get the progress text
progress_indicator_status_text = current_progress_indicator_tuple[0]
# Set the status bar text so the user knows what's going on
self.window.active_view().set_status(COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY, status_text + " " + progress_indicator_status_text)
# Check again momentarily to see if the operation has completed.
sublime.set_timeout(lambda: self.check_operation(thread, final_completions, current_location, token, status, current_progress_indicator_tuple), 100)
def clear_completions(self, final_completions):
debug("Clearing completions...")
while len(final_completions) > 0:
final_completions.pop()
class CoffeeAutocompleteThread(threading.Thread):
def __init__(self, project_folder_list, excluded_dirs, this_aliases, current_file_lines, preceding_symbol, prefix, preceding_function_call, function_return_types, token, symbol_region, built_in_types, member_exclusion_regexes):
self.project_folder_list = project_folder_list
self.excluded_dirs = excluded_dirs
self.this_aliases = this_aliases
self.current_file_lines = current_file_lines
self.preceding_symbol = preceding_symbol
self.prefix = prefix
self.preceding_function_call = preceding_function_call
self.function_return_types = function_return_types
self.token = token
self.symbol_region = symbol_region
self.built_in_types = built_in_types
self.member_exclusion_regexes = member_exclusion_regexes
# None if no completions found, or an array of the completion tuples
self.completions = None
threading.Thread.__init__(self)
def run(self):
project_folder_list = self.project_folder_list
excluded_dirs = self.excluded_dirs
this_aliases = self.this_aliases
current_file_lines = self.current_file_lines
preceding_symbol = self.preceding_symbol
prefix = self.prefix
preceding_function_call = self.preceding_function_call
function_return_types = self.function_return_types
token = self.token
symbol_region = self.symbol_region
built_in_types = self.built_in_types
member_exclusion_regexes = self.member_exclusion_regexes
selected_word = token[token.rfind(".") + 1:]
completions = []
# First see if it is a special function return definition, like $ for $("#selector")
if preceding_function_call:
for next_return_type in function_return_types:
function_names = next_return_type[coffee_utils.FUNCTION_RETURN_TYPE_FUNCTION_NAMES_KEY]
if preceding_function_call in function_names:
return_type = next_return_type[coffee_utils.FUNCTION_RETURN_TYPE_TYPE_NAME_KEY]
completions = coffee_utils.get_completions_for_class(return_type, False, None, prefix, None, built_in_types, member_exclusion_regexes, False)
if not completions:
# Prepare to search globally if we need to...
# Coffeescript filename regex
coffeescript_filename_regex = coffee_utils.COFFEE_FILENAME_REGEX
# All coffeescript file paths
all_coffee_file_paths = coffee_utils.get_files_in(project_folder_list, coffeescript_filename_regex, excluded_dirs)
# If @ typed, process as "this."
if preceding_symbol == coffee_utils.THIS_SUGAR_SYMBOL:
# Process as "this."
this_type = coffee_utils.get_this_type(current_file_lines, symbol_region)
if this_type:
completions = coffee_utils.get_completions_for_class(this_type, False, current_file_lines, prefix, all_coffee_file_paths, built_in_types, member_exclusion_regexes, True)
pass
elif preceding_symbol == coffee_utils.PERIOD_OPERATOR:
# If "this" or a substitute for it, process as "this."
if selected_word == coffee_utils.THIS_KEYWORD or selected_word in this_aliases:
# Process as "this."
this_type = coffee_utils.get_this_type(current_file_lines, symbol_region)
if this_type:
completions = coffee_utils.get_completions_for_class(this_type, False, current_file_lines, prefix, all_coffee_file_paths, built_in_types, member_exclusion_regexes, True)
else:
# If TitleCase, assume a class, and that we want static properties and functions.
if coffee_utils.is_capitalized(selected_word):
# Assume it is either in the current view or in a coffee file somewhere
completions = coffee_utils.get_completions_for_class(selected_word, True, current_file_lines, prefix, all_coffee_file_paths, built_in_types, member_exclusion_regexes, False)
if not completions:
# Now we search globally...
completions = coffee_utils.get_completions_for_class(selected_word, True, None, prefix, all_coffee_file_paths, built_in_types, member_exclusion_regexes, False)
# If nothing yet, assume a variable.
if not completions:
variable_type = coffee_utils.get_variable_type(current_file_lines, token, symbol_region, all_coffee_file_paths, built_in_types, [])
if variable_type:
# Assume it is either in the current view or in a coffee file somewhere
completions = coffee_utils.get_completions_for_class(variable_type, False, current_file_lines, prefix, all_coffee_file_paths, built_in_types, member_exclusion_regexes, False)
if not completions:
# Now we search globally for a class... Maybe they're making a static call on something lowercase? Bad design, but check anyways.
completions = coffee_utils.get_completions_for_class(selected_word, True, None, prefix, all_coffee_file_paths, built_in_types, member_exclusion_regexes, False)
if completions:
self.completions = completions

View File

@@ -0,0 +1,337 @@
{
"coffee_autocomplete_plus_built_in_types":
[
{
"name": "Array",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods":
[
{"name":"isArray", "args": [{"name": "obj"}]}
],
"instance_properties":
[
{"name": "length"}
],
"instance_methods":
[
{"name":"concat", "args": [{"name": "vals…"}]},
{"name":"every", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}]},
{"name":"every", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}, {"name": "thisArg"}]},
{"name":"filter", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}]},
{"name":"filter", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}, {"name": "thisArg"}]},
{"name":"forEach", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}]},
{"name":"forEach", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}, {"name": "thisArg"}]},
{"name":"indexOf", "args": [{"name": "val"}]},
{"name":"indexOf", "args": [{"name": "val"}, {"name": "start"}]},
{"name":"join", "args": []},
{"name":"join", "args": [{"name": "separator"}]},
{"name":"lastIndexOf", "args": [{"name": "val"}]},
{"name":"lastIndexOf", "args": [{"name": "val"}, {"name": "start"}]},
{"name":"map", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}]},
{"name":"map", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}, {"name": "thisArg"}]},
{"name":"pop", "args": []},
{"name":"push", "args": [{"name": "vals…"}]},
{"name":"reduce", "args": [{"name": "cb()", "insertion": "(prevVal, curVal, index, arr) ->"}]},
{"name":"reduce", "args": [{"name": "cb()", "insertion": "(prevVal, curVal, index, arr) ->"}, {"name": "initVal"}]},
{"name":"reduceRight", "args": [{"name": "cb()", "insertion": "(prevVal, curVal, index, arr) ->"}]},
{"name":"reduceRight", "args": [{"name": "cb()", "insertion": "(prevVal, curVal, index, arr) ->"}, {"name": "initVal"}]},
{"name":"reverse", "args": []},
{"name":"shift", "args": []},
{"name":"slice", "args": [{"name": "start"}]},
{"name":"slice", "args": [{"name": "start"}, {"name": "end"}]},
{"name":"some", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}]},
{"name":"some", "args": [{"name": "cb()", "insertion": "(val, index, arr) ->"}, {"name": "thisArg"}]},
{"name":"sort", "args": []},
{"name":"sort", "args": [{"name": "compare()", "insertion": "(a, b) ->"}]},
{"name":"splice", "args": [{"name": "start"}, {"name": "del"}]},
{"name":"splice", "args": [{"name": "start"}, {"name": "del"}, {"name": "vals…"}]},
{"name":"unshift", "args": [{"name": "vals…"}]}
]
},
{
"name": "Boolean",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods": [],
"instance_properties": [],
"instance_methods": []
},
{
"name": "Date",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods":
[
{"name":"now", "args": []},
{"name":"parse", "args": [{"name": "dateStr"}]},
{"name":"UTC", "args": [{"name": "year"}, {"name": "month"}]},
{"name":"UTC", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}]},
{"name":"UTC", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}, {"name": "hrs"}]},
{"name":"UTC", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}, {"name": "hrs"}, {"name": "min"}]},
{"name":"UTC", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}, {"name": "hrs"}, {"name": "min"}, {"name": "sec"}]},
{"name":"UTC", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}, {"name": "hrs"}, {"name": "min"}, {"name": "sec"}, {"name": "ms"}]}
],
"instance_properties": [],
"instance_methods":
[
{"name":"getDate", "args": []},
{"name":"getDay", "args": []},
{"name":"getFullYear", "args": []},
{"name":"getHours", "args": []},
{"name":"getMilliseconds", "args": []},
{"name":"getMinutes", "args": []},
{"name":"getMonth", "args": []},
{"name":"getSeconds", "args": []},
{"name":"getTime", "args": []},
{"name":"getTimezoneOffset", "args": []},
{"name":"getUTCDate", "args": []},
{"name":"getUTCDay", "args": []},
{"name":"getUTCFullYear", "args": []},
{"name":"getUTCHours", "args": []},
{"name":"getUTCMilliseconds", "args": []},
{"name":"getUTCMinutes", "args": []},
{"name":"getUTCMonth", "args": []},
{"name":"getUTCSeconds", "args": []},
{"name":"setDate", "args": [{"name": "day"}]},
{"name":"setFullYear", "args": [{"name": "year"}]},
{"name":"setFullYear", "args": [{"name": "year"}, {"name": "month"}]},
{"name":"setFullYear", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}]},
{"name":"setHours", "args": [{"name": "hrs"}]},
{"name":"setHours", "args": [{"name": "hrs"}, {"name": "min"}]},
{"name":"setHours", "args": [{"name": "hrs"}, {"name": "min"}, {"name": "sec"}]},
{"name":"setHours", "args": [{"name": "hrs"}, {"name": "min"}, {"name": "sec"}, {"name": "ms"}]},
{"name":"setMilliseconds", "args": [{"name": "ms"}]},
{"name":"setMinutes", "args": [{"name": "min"}]},
{"name":"setMinutes", "args": [{"name": "min"}, {"name": "sec"}]},
{"name":"setMinutes", "args": [{"name": "min"}, {"name": "sec"}, {"name": "ms"}]},
{"name":"setMonth", "args": [{"name": "month"}]},
{"name":"setMonth", "args": [{"name": "month"}, {"name": "day"}]},
{"name":"setSeconds", "args": [{"name": "sec"}]},
{"name":"setSeconds", "args": [{"name": "sec"}, {"name": "ms"}]},
{"name":"setTime", "args": [{"name": "timeVal"}]},
{"name":"setUTCDate", "args": [{"name": "day"}]},
{"name":"setUTCFullYear", "args": [{"name": "year"}]},
{"name":"setUTCFullYear", "args": [{"name": "year"}, {"name": "month"}]},
{"name":"setUTCFullYear", "args": [{"name": "year"}, {"name": "month"}, {"name": "day"}]},
{"name":"setUTCHours", "args": [{"name": "hrs"}]},
{"name":"setUTCHours", "args": [{"name": "hrs"}, {"name": "min"}]},
{"name":"setUTCHours", "args": [{"name": "hrs"}, {"name": "min"}, {"name": "sec"}]},
{"name":"setUTCHours", "args": [{"name": "hrs"}, {"name": "min"}, {"name": "sec"}, {"name": "ms"}]},
{"name":"setUTCMilliseconds", "args": [{"name": "ms"}]},
{"name":"setUTCMinutes", "args": [{"name": "min"}]},
{"name":"setUTCMinutes", "args": [{"name": "min"}, {"name": "sec"}]},
{"name":"setUTCMinutes", "args": [{"name": "min"}, {"name": "sec"}, {"name": "ms"}]},
{"name":"setUTCMonth", "args": [{"name": "month"}]},
{"name":"setUTCMonth", "args": [{"name": "month"}, {"name": "day"}]},
{"name":"setUTCSeconds", "args": [{"name": "sec"}]},
{"name":"setUTCSeconds", "args": [{"name": "sec"}, {"name": "ms"}]},
{"name":"toDateString", "args": []},
{"name":"toISOString", "args": []},
{"name":"toJSON", "args": []},
{"name":"toLocaleDateString", "args": []},
{"name":"toLocaleString", "args": []},
{"name":"toLocaleTimeString", "args": []},
{"name":"toTimeString", "args": []},
{"name":"toUTCString", "args": []}
]
},
{
"name": "Function",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods": [],
"instance_properties":
[
{"name": "length"},
{"name": "prototype"}
],
"instance_methods":
[
{"name":"apply", "args": [{"name": "thisArg"}]},
{"name":"apply", "args": [{"name": "thisArg"}, {"name": "args…"}]},
{"name":"bind", "args": [{"name": "obj"}]},
{"name":"bind", "args": [{"name": "obj"}, {"name": "args…"}]},
{"name":"call", "args": [{"name": "thisArg"}]},
{"name":"call", "args": [{"name": "thisArg"}, {"name": "args…"}]}
]
},
{
"name": "Number",
"enabled": true,
"constructors": [],
"static_properties":
[
{"name": "MAX_VALUE"},
{"name": "MIN_VALUE"},
{"name": "NaN"},
{"name": "NEGATIVE_INFINITY"},
{"name": "POSITIVE_INFINITY"}
],
"static_methods": [],
"instance_properties": [],
"instance_methods":
[
{"name":"toExponential", "args": []},
{"name":"toExponential", "args": [{"name": "digits"}]},
{"name":"toFixed", "args": []},
{"name":"toFixed", "args": [{"name": "digits"}]},
{"name":"toPrecision", "args": []},
{"name":"toPrecision", "args": [{"name": "precision"}]},
{"name":"toString", "args": []},
{"name":"toString", "args": [{"name": "radix"}]}
]
},
{
"name": "Object",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods":
[
{"name":"create", "args": [{"name": "proto"}]},
{"name":"create", "args": [{"name": "proto"}, {"name": "propsObj"}]},
{"name":"defineProperties", "args": [{"name": "obj"}, {"name": "descs"}]},
{"name":"defineProperty", "args": [{"name": "obj"}, {"name": "prop"}, {"name": "desc"}]},
{"name":"freeze", "args": [{"name": "obj"}]},
{"name":"getOwnPropertyDescriptor", "args": [{"name": "obj"}, {"name": "prop"}]},
{"name":"getOwnPropertyNames", "args": [{"name": "obj"}]},
{"name":"getPrototypeOf", "args": [{"name": "obj"}]},
{"name":"isExtensible", "args": [{"name": "obj"}]},
{"name":"isFrozen", "args": [{"name": "obj"}]},
{"name":"isSealed", "args": [{"name": "obj"}]},
{"name":"keys", "args": [{"name": "obj"}]},
{"name":"preventExtensions", "args": [{"name": "obj"}]},
{"name":"seal", "args": [{"name": "obj"}]}
],
"instance_properties": [{"name": "constructor"}],
"instance_methods":
[
{"name":"hasOwnProperty", "args": [{"name": "prop"}]},
{"name":"isPrototypeOf", "args": [{"name": "obj"}]},
{"name":"propertyIsEnumerable", "args": [{"name": "prop"}]},
{"name":"toLocaleString", "args": []},
{"name":"toString", "args": []},
{"name":"valueOf", "args": []}
]
},
{
"name": "RegExp",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods": [],
"instance_properties": [
{"name": "global"},
{"name": "ignoreCase"},
{"name": "lastIndex"},
{"name": "multiline"},
{"name": "source"}
],
"instance_methods": [
{"name":"exec", "args": [{"name": "str"}]},
{"name":"test", "args": [{"name": "str"}]}
]
},
{
"name": "String",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods":
[
{"name":"fromCharCode", "args": [{"name": "codes…"}]}
],
"instance_properties": [{"name": "length"}],
"instance_methods":
[
{"name":"charAt", "args": [{"name": "index"}]},
{"name":"charCodeAt", "args": [{"name": "index"}]},
{"name":"concat", "args": [{"name": "strs…"}]},
{"name":"indexOf", "args": [{"name": "substr"}]},
{"name":"indexOf", "args": [{"name": "substr"}, {"name": "start"}]},
{"name":"lastIndexOf", "args": [{"name": "substr"}]},
{"name":"lastIndexOf", "args": [{"name": "substr"}, {"name": "start"}]},
{"name":"localeCompare", "args": [{"name": "target"}]},
{"name":"match", "args": [{"name": "regexp"}]},
{"name":"replace", "args": [{"name": "substr"}, {"name": "repl"}]},
{"name":"replace", "args": [{"name": "substr"}, {"name": "repl()", "insertion": "(match, submatches…, pos, str) ->"}]},
{"name":"replace", "args": [{"name": "regexp"}, {"name": "repl"}]},
{"name":"replace", "args": [{"name": "regexp"}, {"name": "repl()", "insertion": "(match, submatches…, pos, str) ->"}]},
{"name":"search", "args": [{"name": "regexp"}]},
{"name":"slice", "args": [{"name": "start"}]},
{"name":"slice", "args": [{"name": "start"}, {"name": "end"}]},
{"name":"split", "args": []},
{"name":"split", "args": [{"name": "separator"}]},
{"name":"split", "args": [{"name": "separator"}, {"name": "limit"}]},
{"name":"substring", "args": [{"name": "from"}]},
{"name":"substring", "args": [{"name": "from"}, {"name": "to"}]},
{"name":"toLocaleLowerCase", "args": []},
{"name":"toLocaleUpperCase", "args": []},
{"name":"toLowerCase", "args": []},
{"name":"toUpperCase", "args": []},
{"name":"trim", "args": []}
]
},
{
"name": "JSON",
"enabled": true,
"constructors": [],
"static_properties": [],
"static_methods":
[
{"name":"parse", "args": [{"name": "str"}]},
{"name":"parse", "args": [{"name": "str"}, {"name": "reviver()", "insertion": "(prop, val) ->"}]},
{"name":"stringify", "args": [{"name": "val"}]},
{"name":"stringify", "args": [{"name": "val"}, {"name": "filterArr"}]},
{"name":"stringify", "args": [{"name": "val"}, {"name": "filterArr"}, {"name": "indent"}]},
{"name":"stringify", "args": [{"name": "val"}, {"name": "filter()", "insertion": "(prop, val) ->"}]},
{"name":"stringify", "args": [{"name": "val"}, {"name": "filter()", "insertion": "(prop, val) ->"}, {"name": "indent"}]}
],
"instance_properties": [],
"instance_methods": []
},
{
"name": "Math",
"enabled": true,
"constructors": [],
"static_properties": [
{"name": "E"},
{"name": "LN10"},
{"name": "LN2"},
{"name": "LOG10E"},
{"name": "LOG2E"},
{"name": "PI"},
{"name": "SQRT1_2"},
{"name": "SQRT2"}
],
"static_methods":
[
{"name":"abs", "args": [{"name": "x"}]},
{"name":"acos", "args": [{"name": "x"}]},
{"name":"asin", "args": [{"name": "x"}]},
{"name":"atan", "args": [{"name": "x"}]},
{"name":"atan2", "args": [{"name": "y"}, {"name": "x"}]},
{"name":"ceil", "args": [{"name": "x"}]},
{"name":"cos", "args": [{"name": "x"}]},
{"name":"exp", "args": [{"name": "x"}]},
{"name":"floor", "args": [{"name": "x"}]},
{"name":"log", "args": [{"name": "x"}]},
{"name":"max", "args": [{"name": "vals…"}]},
{"name":"min", "args": [{"name": "vals…"}]},
{"name":"pow", "args": [{"name": "x"}, {"name": "y"}]},
{"name":"random", "args": []},
{"name":"round", "args": [{"name": "x"}]},
{"name":"sin", "args": [{"name": "x"}]},
{"name":"sqrt", "args": [{"name": "x"}]},
{"name":"tan", "args": [{"name": "x"}]}
],
"instance_properties": [],
"instance_methods": []
}
]
}

View File

@@ -0,0 +1,428 @@
{
"coffee_autocomplete_plus_custom_types":
[
// {
// "name": "MyType",
// "constructors": [{"args": []}],
// "static_properties": [{"name": "CONSTANT_ONE"}, {"name": "CONSTANT_TWO"}],
// "static_methods":
// [
// {"name":"myStaticMethod", "args": [{"name": "arg1"}, {"name": "arg2"}]},
// {"name":"myStaticMethodTwo", "args": []}
// ],
// "instance_properties": [{"name": "thingOne"}, {"name": "thingTwo"}, {"name": "thingThree"}],
// "instance_methods":
// [
// {"name":"doStuff", "args": [{"name": "numTimes"}]},
// {"name":"doMoreStuff", "args": [{"name": "numTimes"}, {"name": "extraAmount"}]}
// ]
// },
{
"name": "$",
"enabled": true,
"constructors": [{"args": []}],
"static_properties":
[
{"name":"boxModel"},
{"name":"browser"},
{"name":"cssHooks"},
{"name":"fx.interval"},
{"name":"fx.off"},
{"name":"support"}
],
"static_methods":
[
{"name":"ajax", "args": [{"name": "url"}]},
{"name":"ajax", "args": [{"name": "url"}, {"name": "settings"}]},
{"name":"ajax", "args": []},
{"name":"ajax", "args": [{"name": "settings"}]},
{"name":"ajaxPrefilter", "args": [{"name": "handler(options, originalOptions, jqXHR)"}]},
{"name":"ajaxPrefilter", "args": [{"name": "dataTypes"}, {"name": "handler(options, originalOptions, jqXHR)"}]},
{"name":"ajaxSetup", "args": [{"name": "options"}]},
{"name":"ajaxTransport", "args": [{"name": "handler(options, originalOptions, jqXHR)"}]},
{"name":"ajaxTransport", "args": [{"name": "dataType"}, {"name": "handler(options, originalOptions, jqXHR)"}]},
{"name":"Callbacks", "args": [{"name": "flags"}]},
{"name":"contains", "args": [{"name": "container"}, {"name": "contained"}]},
{"name":"data", "args": [{"name": "element"}]},
{"name":"data", "args": [{"name": "element"}, {"name": "key"}]},
{"name":"data", "args": [{"name": "element"}, {"name": "key"}, {"name": "value"}]},
{"name":"Deferred", "args": []},
{"name":"Deferred", "args": [{"name": "[beforeStart]"}]},
{"name":"dequeue", "args": [{"name": "element"}]},
{"name":"dequeue", "args": [{"name": "element"}, {"name": "queueName"}]},
{"name":"each", "args": [{"name": "collection"}]},
{"name":"each", "args": [{"name": "collection"}, {"name": "callback(indexInArray, valueOfElement)"}]},
{"name":"error", "args": [{"name": "message"}]},
{"name":"extend", "args": [{"name": "target"}, {"name": "object1"}]},
{"name":"extend", "args": [{"name": "target"}, {"name": "object1"}, {"name": "obj2 .. objN"}]},
{"name":"extend", "args": [{"name": "deep"}, {"name": "target"}, {"name": "obj1 .. objN"}]},
{"name":"get", "args": [{"name": "url"}]},
{"name":"get", "args": [{"name": "url"}, {"name": "data"}]},
{"name":"get", "args": [{"name": "url"}, {"name": "data"}, {"name": "success(data, textStatus, jqXHR)"}]},
{"name":"get", "args": [{"name": "url"}, {"name": "data"}, {"name": "success(data, textStatus, jqXHR)"}, {"name": "dataType"}]},
{"name":"getJSON", "args": [{"name": "url"}]},
{"name":"getJSON", "args": [{"name": "url"}, {"name": "data"}]},
{"name":"getJSON", "args": [{"name": "url"}, {"name": "data"}, {"name": "success(data, textStatus, jqXHR)"}]},
{"name":"getScript", "args": [{"name": "url"}]},
{"name":"getScript", "args": [{"name": "url"}, {"name": "success(script, textStatus, jqXHR)"}]},
{"name":"globalEval", "args": [{"name": "code"}]},
{"name":"grep", "args": [{"name": "array"}, {"name": "function(elementOfArray, indexInArray)"}]},
{"name":"grep", "args": [{"name": "array"}, {"name": "function(elementOfArray, indexInArray)"}, {"name": "invert"}]},
{"name":"hasData", "args": [{"name": "element"}]},
{"name":"holdReady", "args": [{"name": "hold"}]},
{"name":"inArray", "args": [{"name": "valueE"}, {"name": "array"}]},
{"name":"inArray", "args": [{"name": "valueE"}, {"name": "array"}, {"name": "fromIndex"}]},
{"name":"isArray", "args": [{"name": "obj"}]},
{"name":"isEmptyObject", "args": [{"name": "object"}]},
{"name":"isFunction", "args": [{"name": "obj"}]},
{"name":"isNumeric", "args": [{"name": "value"}]},
{"name":"isPlainObject", "args": [{"name": "object"}]},
{"name":"isWindow", "args": [{"name": "obj"}]},
{"name":"isXMLDoc", "args": [{"name": "node"}]},
{"name":"makeArray", "args": [{"name": "obj"}]},
{"name":"map", "args": [{"name": "array"}, {"name": "callback(elementOfArray, indexInArray)"}]},
{"name":"map", "args": [{"name": "arrayOrObject"}, {"name": "callback(value, indexOrKey)"}]},
{"name":"merge", "args": [{"name": "first"}, {"name": "second"}]},
{"name":"noConflict", "args": []},
{"name":"noConflict", "args": [{"name": "removeAll"}]},
{"name":"noop", "args": []},
{"name":"now", "args": []},
{"name":"param", "args": [{"name": "obj"}]},
{"name":"param", "args": [{"name": "obj"}, {"name": "traditional"}]},
{"name":"parseHTML", "args": [{"name": "data"}]},
{"name":"parseHTML", "args": [{"name": "data"}, {"name": "context"}]},
{"name":"parseHTML", "args": [{"name": "data"}, {"name": "context"}, {"name": "keepScripts"}]},
{"name":"parseJSON", "args": [{"name": "json"}]},
{"name":"parseXML", "args": [{"name": "data"}]},
{"name":"post", "args": [{"name": "url"}]},
{"name":"post", "args": [{"name": "url"}, {"name": "data"}]},
{"name":"post", "args": [{"name": "url"}, {"name": "data"}, {"name": "success(data, textStatus, jqXHR)"}]},
{"name":"post", "args": [{"name": "url"}, {"name": "data"}, {"name": "success(data, textStatus, jqXHR)"}, {"name": "dataType"}]},
{"name":"proxy", "args": [{"name": "function"}, {"name": "context"}]},
{"name":"proxy", "args": [{"name": "context"}, {"name": "name"}]},
{"name":"proxy", "args": [{"name": "function"}, {"name": "context"}]},
{"name":"proxy", "args": [{"name": "function"}, {"name": "context"}, {"name": "additionalArguments"}]},
{"name":"proxy", "args": [{"name": "context"}, {"name": "name"}]},
{"name":"proxy", "args": [{"name": "context"}, {"name": "name"}, {"name": "additionalArguments"}]},
{"name":"queue", "args": [{"name": "element"}]},
{"name":"queue", "args": [{"name": "element"}, {"name": "queueName"}]},
{"name":"queue", "args": [{"name": "element"}, {"name": "queueName"}, {"name": "newQueue"}]},
{"name":"queue", "args": [{"name": "element"}, {"name": "queueName"}, {"name": "callback()"}]},
{"name":"removeData", "args": [{"name": "element"}]},
{"name":"removeData", "args": [{"name": "element"}, {"name": "name"}]},
{"name":"sub", "args": []},
{"name":"trim", "args": [{"name": "str"}]},
{"name":"type", "args": [{"name": "obj"}]},
{"name":"unique", "args": [{"name": "array"}]},
{"name":"when", "args": [{"name": "deferreds"}]}
],
"instance_properties":
[
{"name":"context"},
{"name":"jquery"},
{"name":"length"},
{"name":"selector"}
],
"instance_methods":
[
{"name":"add", "args": [{"name": "selector"}]},
{"name":"add", "args": [{"name": "elements"}]},
{"name":"add", "args": [{"name": "html"}]},
{"name":"add", "args": [{"name": "jQueryObject"}]},
{"name":"add", "args": [{"name": "selector"}, {"name": "context"}]},
{"name":"addBack", "args": []},
{"name":"addBack", "args": [{"name": "selector"}]},
{"name":"addClass", "args": [{"name": "className"}]},
{"name":"addClass", "args": [{"name": "function(index, currentClass)"}]},
{"name":"after", "args": [{"name": "content"}]},
{"name":"after", "args": [{"name": "content"}, {"name": "additionalContent"}]},
{"name":"after", "args": [{"name": "function(index)"}]},
{"name":"ajaxComplete", "args": [{"name": "handler(event, XMLHttpRequest, ajaxOptions)"}]},
{"name":"ajaxError", "args": [{"name": "handler(event, jqXHR, ajaxSettings, thrownError)"}]},
{"name":"ajaxSend", "args": [{"name": "handler(event, jqXHR, ajaxOptions)"}]},
{"name":"ajaxStart", "args": [{"name": "handler()"}]},
{"name":"ajaxStop", "args": [{"name": "handler()", "insertion": "->"}]},
{"name":"ajaxSuccess", "args": [{"name": "handler(event, XMLHttpRequest, ajaxOptions)"}]},
{"name":"andSelf", "args": []},
{"name":"animate", "args": [{"name": "properties"}, {"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"animate", "args": [{"name": "properties"}, {"name": "options"}]},
{"name":"append", "args": [{"name": "content"}]},
{"name":"append", "args": [{"name": "content"}, {"name": "additionalContent"}]},
{"name":"append", "args": [{"name": "function(index, html)"}]},
{"name":"appendTo", "args": [{"name": "target"}]},
{"name":"attr", "args": [{"name": "attributeName"}]},
{"name":"attr", "args": [{"name": "attributeName"}, {"name": "value"}]},
{"name":"attr", "args": [{"name": "attributes"}]},
{"name":"attr", "args": [{"name": "attributeName"}, {"name": "function(index, attr)"}]},
{"name":"before", "args": [{"name": "content"}]},
{"name":"before", "args": [{"name": "content"}, {"name": "additionalContent"}]},
{"name":"bind", "args": [{"name": "eventType"}, {"name": "[eventData]"}, {"name": "[handler(eventObject)]"}]},
{"name":"bind", "args": [{"name": "eventType"}, {"name": "[eventData]"}, {"name": "preventBubble"}]},
{"name":"bind", "args": [{"name": "events"}]},
{"name":"blur", "args": []},
{"name":"blur", "args": [{"name": "handler(eventObject)"}]},
{"name":"blur", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"change", "args": [{"name": "handler(eventObject)"}]},
{"name":"change", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"change", "args": []},
{"name":"children", "args": [{"name": "[selector]"}]},
{"name":"clearQueue", "args": [{"name": "[queueName]"}]},
{"name":"click", "args": [{"name": "handler(eventObject)"}]},
{"name":"click", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"click", "args": []},
{"name":"clone", "args": [{"name": "withDataAndEvents"}]},
{"name":"clone", "args": [{"name": "withDataAndEvents"}, {"name": "[deepWithDataAndEvents] "}]},
{"name":"closest", "args": [{"name": "selector"}, {"name": "[context]"}]},
{"name":"closest", "args": [{"name": "jQueryObject"}]},
{"name":"closest", "args": [{"name": "element"}]},
{"name":"contents", "args": []},
{"name":"css", "args": [{"name": "propertyName"}]},
{"name":"css", "args": [{"name": "propertyNames"}]},
{"name":"css", "args": [{"name": "propertyName"}, {"name": "value"}]},
{"name":"css", "args": [{"name": "propertyName"}, {"name": "function(index, value)"}]},
{"name":"css", "args": [{"name": "properties"}]},
{"name":"data", "args": [{"name": "key"}, {"name": "value"}]},
{"name":"data", "args": [{"name": "obj"}]},
{"name":"data", "args": [{"name": "key"}]},
{"name":"data", "args": []},
{"name":"dblclick", "args": [{"name": "handler(eventObject)"}]},
{"name":"dblclick", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"dblclick", "args": []},
{"name":"delay", "args": [{"name": "duration"}, {"name": "[queueName]"}]},
{"name":"delegate", "args": [{"name": "selector"}, {"name": "eventType"}, {"name": "handler(eventObject)"}]},
{"name":"delegate", "args": [{"name": "selector"}, {"name": "eventType"}, {"name": "eventData"}, {"name": "handler(eventObject)"}]},
{"name":"delegate", "args": [{"name": "selector"}, {"name": "events"}]},
{"name":"dequeue", "args": [{"name": "[queueName]"}]},
{"name":"detach", "args": [{"name": "[selector]"}]},
{"name":"die", "args": []},
{"name":"die", "args": [{"name": "eventType"}, {"name": "[handler]"}]},
{"name":"die", "args": [{"name": "events"}]},
{"name":"each", "args": [{"name": "function(index, Element)"}]},
{"name":"empty", "args": []},
{"name":"end", "args": []},
{"name":"eq", "args": [{"name": "index"}]},
{"name":"eq", "args": [{"name": "-index"}]},
{"name":"error", "args": [{"name": "handler(eventObject)"}]},
{"name":"error", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"fadeIn", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"fadeIn", "args": [{"name": "options"}]},
{"name":"fadeIn", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"fadeOut", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"fadeOut", "args": [{"name": "options"}]},
{"name":"fadeOut", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"fadeTo", "args": [{"name": "duration"}, {"name": "opacity"}, {"name": "[complete]"}]},
{"name":"fadeTo", "args": [{"name": "duration"}, {"name": "opacity"}, {"name": "[easing]"}, {"name": "[complete()]"}]},
{"name":"fadeToggle", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"fadeToggle", "args": [{"name": "options"}]},
{"name":"filter", "args": [{"name": "selector"}]},
{"name":"filter", "args": [{"name": "function(index)"}]},
{"name":"filter", "args": [{"name": "element"}]},
{"name":"filter", "args": [{"name": "jQueryObject"}]},
{"name":"find", "args": [{"name": "selector"}]},
{"name":"find", "args": [{"name": "jQueryObject"}]},
{"name":"find", "args": [{"name": "element"}]},
{"name":"finish", "args": [{"name": "[queue]"}]},
{"name":"first", "args": []},
{"name":"focus", "args": [{"name": "handler(eventObject)"}]},
{"name":"focus", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"focus", "args": []},
{"name":"focusin", "args": [{"name": "handler(eventObject)"}]},
{"name":"focusin", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"focusout", "args": [{"name": "handler(eventObject)"}]},
{"name":"focusout", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"get", "args": [{"name": "[index]"}]},
{"name":"has", "args": [{"name": "selector"}]},
{"name":"has", "args": [{"name": "contained"}]},
{"name":"hasClass", "args": [{"name": "className"}]},
{"name":"height", "args": []},
{"name":"height", "args": [{"name": "value"}]},
{"name":"height", "args": [{"name": "function(index, height)"}]},
{"name":"hide", "args": []},
{"name":"hide", "args": [{"name": "[duration_default_400]"}, {"name": "[complete]"}]},
{"name":"hide", "args": [{"name": "options"}]},
{"name":"hide", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"hover", "args": [{"name": "handlerIn(eventObject)"}, {"name": "handlerOut(eventObject)"}]},
{"name":"html", "args": []},
{"name":"html", "args": [{"name": "htmlString"}]},
{"name":"html", "args": [{"name": "function(index, oldhtml)"}]},
{"name":"index", "args": []},
{"name":"index", "args": [{"name": "selector"}]},
{"name":"index", "args": [{"name": "element"}]},
{"name":"innerHeight", "args": []},
{"name":"innerWidth", "args": []},
{"name":"insertAfter", "args": [{"name": "target"}]},
{"name":"insertBefore", "args": [{"name": "target"}]},
{"name":"is", "args": [{"name": "selector"}]},
{"name":"is", "args": [{"name": "function(index)"}]},
{"name":"is", "args": [{"name": "jQueryObject"}]},
{"name":"is", "args": [{"name": "element"}]},
{"name":"keydown", "args": []},
{"name":"keydown", "args": [{"name": "handler(eventObject)"}]},
{"name":"keydown", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"keypress", "args": []},
{"name":"keypress", "args": [{"name": "handler(eventObject)"}]},
{"name":"keypress", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"keyup", "args": []},
{"name":"keyup", "args": [{"name": "handler(eventObject)"}]},
{"name":"keyup", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"last", "args": []},
{"name":"live", "args": [{"name": "events"}, {"name": "handler(eventObject)"}]},
{"name":"live", "args": [{"name": "events"}, {"name": "data"}, {"name": "handler(eventObject)"}]},
{"name":"live", "args": [{"name": "events"}]},
{"name":"load", "args": [{"name": "url"}, {"name": "[data]"}, {"name": "[complete(responseText, textStatus, XMLHttpRequest)]"}]},
{"name":"load", "args": [{"name": "handler(eventObject)"}]},
{"name":"load", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"map", "args": [{"name": "callback(index, domElement)"}]},
{"name":"mousedown", "args": []},
{"name":"mousedown", "args": [{"name": "handler(eventObject)"}]},
{"name":"mousedown", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"mouseenter", "args": []},
{"name":"mouseenter", "args": [{"name": "handler(eventObject)"}]},
{"name":"mouseenter", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"mouseleave", "args": []},
{"name":"mouseleave", "args": [{"name": "handler(eventObject)"}]},
{"name":"mouseleave", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"mousemove", "args": []},
{"name":"mousemove", "args": [{"name": "handler(eventObject)"}]},
{"name":"mousemove", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"mouseout", "args": []},
{"name":"mouseout", "args": [{"name": "handler(eventObject)"}]},
{"name":"mouseout", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"mouseover", "args": []},
{"name":"mouseover", "args": [{"name": "handler(eventObject)"}]},
{"name":"mouseover", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"mouseup", "args": []},
{"name":"mouseup", "args": [{"name": "handler(eventObject)"}]},
{"name":"mouseup", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"next", "args": [{"name": "[selector]"}]},
{"name":"nextAll", "args": [{"name": "[selector]"}]},
{"name":"nextUntil", "args": [{"name": "[selector]"}, {"name": "[filter]"}]},
{"name":"nextUntil", "args": [{"name": "[element]"}, {"name": "[filter]"}]},
{"name":"not", "args": [{"name": "selector"}]},
{"name":"not", "args": [{"name": "elements"}]},
{"name":"not", "args": [{"name": "function(index)"}]},
{"name":"not", "args": [{"name": "jQueryObject"}]},
{"name":"off", "args": [{"name": "events"}, {"name": "[selector]"}, {"name": "handler(eventObject)"}]},
{"name":"off", "args": [{"name": "events"}, {"name": "[selector]"}]},
{"name":"offset", "args": []},
{"name":"offset", "args": [{"name": "coordinates"}]},
{"name":"offset", "args": [{"name": "function(index, coords)"}]},
{"name":"offsetParent", "args": []},
{"name":"on", "args": [{"name": "events"}, {"name": "[selector]"}, {"name": "[data]"}, {"name": "handler(eventObject)"}]},
{"name":"on", "args": [{"name": "events"}, {"name": "[selector]"}, {"name": "[data]"}]},
{"name":"one", "args": [{"name": "events"}, {"name": "[data]"}, {"name": "handler(eventObject)"}]},
{"name":"one", "args": [{"name": "events"}, {"name": "[selector]"}, {"name": "[data]"}, {"name": "handler(eventObject)"}]},
{"name":"one", "args": [{"name": "events"}, {"name": "[selector]"}, {"name": "[data]"}]},
{"name":"outerHeight", "args": [{"name": "[includeMargin]"}]},
{"name":"outerWidth", "args": [{"name": "[includeMargin]"}]},
{"name":"parent", "args": [{"name": "[selector]"}]},
{"name":"parents", "args": [{"name": "[selector]"}]},
{"name":"parentsUntil", "args": [{"name": "[selector]"}, {"name": "[filter]"}]},
{"name":"parentsUntil", "args": [{"name": "[element]"}, {"name": "[filter]"}]},
{"name":"position", "args": []},
{"name":"prepend", "args": [{"name": "content"}, {"name": "[additionalContent]"}]},
{"name":"prepend", "args": [{"name": "function(index, html)"}]},
{"name":"prependTo", "args": [{"name": "target"}]},
{"name":"prev", "args": [{"name": "[selector]"}]},
{"name":"prevAll", "args": [{"name": "[selector]"}]},
{"name":"prevUntil", "args": [{"name": "[selector]"}, {"name": "[filter]"}]},
{"name":"prevUntil", "args": [{"name": "[element]"}, {"name": "[filter]"}]},
{"name":"promise", "args": [{"name": "[type_default_fx]"}, {"name": "[target]"}]},
{"name":"prop", "args": [{"name": "propertyName"}]},
{"name":"prop", "args": [{"name": "propertyName"}, {"name": "value"}]},
{"name":"prop", "args": [{"name": "properties"}]},
{"name":"prop", "args": [{"name": "propertyName"}, {"name": "function(index, oldPropertyValue)"}]},
{"name":"pushStack", "args": [{"name": "elements"}]},
{"name":"pushStack", "args": [{"name": "elements"}, {"name": "name"}, {"name": "arguments"}]},
{"name":"queue", "args": [{"name": "[queueName]"}]},
{"name":"queue", "args": [{"name": "[queueName]"}, {"name": "newQueue"}]},
{"name":"queue", "args": [{"name": "[queueName]"}, {"name": "callback(next)"}]},
{"name":"ready", "args": [{"name": "handler"}]},
{"name":"remove", "args": [{"name": "[selector]"}]},
{"name":"removeAttr", "args": [{"name": "attributeName"}]},
{"name":"removeClass", "args": [{"name": "[className]"}]},
{"name":"removeClass", "args": [{"name": "function(index, class)"}]},
{"name":"removeData", "args": [{"name": "[name]"}]},
{"name":"removeData", "args": [{"name": "[list]"}]},
{"name":"removeProp", "args": [{"name": "propertyName"}]},
{"name":"replaceAll", "args": [{"name": "target"}]},
{"name":"replaceWith", "args": [{"name": "newContent"}]},
{"name":"replaceWith", "args": [{"name": "function"}]},
{"name":"resize", "args": [{"name": "handler(eventObject)"}]},
{"name":"resize", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"resize", "args": []},
{"name":"scroll", "args": [{"name": "handler(eventObject)"}]},
{"name":"scroll", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"scroll", "args": []},
{"name":"scrollLeft", "args": [{"name": "value"}]},
{"name":"scrollLeft", "args": []},
{"name":"scrollTop", "args": [{"name": "value"}]},
{"name":"scrollTop", "args": []},
{"name":"select", "args": [{"name": "handler(eventObject)"}]},
{"name":"select", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"select", "args": []},
{"name":"serialize", "args": []},
{"name":"serializeArray", "args": []},
{"name":"show", "args": []},
{"name":"show", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"show", "args": [{"name": "options"}]},
{"name":"show", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"siblings", "args": [{"name": "[selector]"}]},
{"name":"size", "args": []},
{"name":"slice", "args": [{"name": "start"}, {"name": "[end]"}]},
{"name":"slideDown", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"slideDown", "args": [{"name": "options"}]},
{"name":"slideDown", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"slideToggle", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"slideToggle", "args": [{"name": "options"}]},
{"name":"slideToggle", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"slideUp", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"slideUp", "args": [{"name": "options"}]},
{"name":"slideUp", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"stop", "args": [{"name": "[clearQueue]"}, {"name": "[jumpToEnd]"}]},
{"name":"stop", "args": [{"name": "[queue]"}, {"name": "[clearQueue]"}, {"name": "[jumpToEnd]"}]},
{"name":"submit", "args": [{"name": "handler(eventObject)"}]},
{"name":"submit", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"submit", "args": []},
{"name":"text", "args": []},
{"name":"text", "args": [{"name": "textString"}]},
{"name":"text", "args": [{"name": "function(index, text)"}]},
{"name":"toArray", "args": []},
{"name":"toggle", "args": [{"name": "[duration_default_400]"}, {"name": "[complete()]"}]},
{"name":"toggle", "args": [{"name": "options"}]},
{"name":"toggle", "args": [{"name": "[duration_default_400]"}, {"name": "[easing_default_swing]"}, {"name": "[complete()]"}]},
{"name":"toggle", "args": [{"name": "showOrHide"}]},
{"name":"toggle", "args": [{"name": "evenHandler(eventObject)"}, {"name": "oddHandler(eventObject)"}, {"name": "handler(eventObject)"}]},
{"name":"toggleClass", "args": [{"name": "className"}]},
{"name":"toggleClass", "args": [{"name": "className"}, {"name": "switch"}]},
{"name":"toggleClass", "args": [{"name": "[switch]"}]},
{"name":"toggleClass", "args": [{"name": "function(index, class, switch)"}, {"name": "[switch]"}]},
{"name":"trigger", "args": [{"name": "eventType"}, {"name": "[extraParameters]"}]},
{"name":"trigger", "args": [{"name": "event"}]},
{"name":"triggerHandler", "args": [{"name": "eventType"}, {"name": "[extraParameters]"}]},
{"name":"unbind", "args": [{"name": "[eventType]"}, {"name": "[handler(eventObject)]"}]},
{"name":"unbind", "args": [{"name": "eventType"}, {"name": "false"}]},
{"name":"unbind", "args": [{"name": "event"}]},
{"name":"undelegate", "args": []},
{"name":"undelegate", "args": [{"name": "selector"}, {"name": "eventType"}]},
{"name":"undelegate", "args": [{"name": "selector"}, {"name": "eventType"}, {"name": "handler(eventObject)"}]},
{"name":"undelegate", "args": [{"name": "selector"}, {"name": "events"}]},
{"name":"undelegate", "args": [{"name": "namespace"}]},
{"name":"unload", "args": [{"name": "handler(eventObject)"}]},
{"name":"unload", "args": [{"name": "[eventData]"}, {"name": "handler(eventObject)"}]},
{"name":"unwrap", "args": []},
{"name":"val", "args": []},
{"name":"val", "args": [{"name": "value"}]},
{"name":"val", "args": [{"name": "function(index, value)"}]},
{"name":"width", "args": []},
{"name":"width", "args": [{"name": "value"}]},
{"name":"width", "args": [{"name": "function(index, width)"}]},
{"name":"wrap", "args": [{"name": "wrappingElement"}]},
{"name":"wrap", "args": [{"name": "function(index)"}]},
{"name":"wrapAll", "args": [{"name": "wrappingElement"}]},
{"name":"wrapInner", "args": [{"name": "wrappingElement"}]},
{"name":"wrapInner", "args": [{"name": "function(index)"}]}
]
}
]
}

View File

@@ -0,0 +1,107 @@
{"scope": "source.coffee -comment",
"completions": [
// keywords
{"trigger": "break"},
{"trigger": "continue"},
{"trigger": "delete"},
{"trigger": "extends"},
{"trigger": "finally"},
{"trigger": "instanceof"},
{"trigger": "return"},
{"trigger": "super"},
{"trigger": "throw"},
{"trigger": "typeof"},
{"trigger": "until"},
{"trigger": "while"},
// classes
{"trigger": "Array"},
{"trigger": "Boolean"},
{"trigger": "Date"},
{"trigger": "Error"},
{"trigger": "Function"},
{"trigger": "JSON"},
{"trigger": "Math"},
{"trigger": "Number"},
{"trigger": "Object"},
{"trigger": "RegExp"},
{"trigger": "String"},
// globals
{"trigger": "Infinity"},
{"trigger": "NaN"},
{"trigger": "undefined"},
{"trigger": "● decodeURI(encURI)", "contents": "decodeURI(${1:encURI})"},
{"trigger": "● decodeURIComponent(encURI)", "contents": "decodeURIComponent(${1:encURI})"},
{"trigger": "● encodeURI(URI)", "contents": "encodeURI(${1:URI})"},
{"trigger": "● encodeURIComponent(str)", "contents": "encodeURIComponent(${1:str})"},
{"trigger": "● eval(str)", "contents": "eval(${1:str})"},
{"trigger": "● isFinite(x)", "contents": "isFinite(${1:x})"},
{"trigger": "● isNaN(val)", "contents": "isNaN(${1:val})"},
{"trigger": "● parseFloat(str)", "contents": "parseFloat(${1:str})"},
{"trigger": "● parseInt(str)", "contents": "parseInt(${1:str})"},
{"trigger": "● parseInt(str, radix)", "contents": "parseInt(${1:str}, ${2:radix})"}
/*
// too short
{"trigger": "and"},
{"trigger": "by"},
{"trigger": "do"},
{"trigger": "else"},
{"trigger": "false"},
{"trigger": "for"},
{"trigger": "if"},
{"trigger": "in"},
{"trigger": "is"},
{"trigger": "isnt"},
{"trigger": "loop"},
{"trigger": "new"},
{"trigger": "no"},
{"trigger": "not"},
{"trigger": "null"},
{"trigger": "of"},
{"trigger": "off"},
{"trigger": "on"},
{"trigger": "or"},
{"trigger": "then"},
{"trigger": "this"},
{"trigger": "true"},
{"trigger": "try"},
{"trigger": "when"},
{"trigger": "yes"},
// snippets
{"trigger": "catch"},
{"trigger": "class"},
{"trigger": "switch"},
{"trigger": "unless"},
// rare
{"trigger": "debugger"},
{"trigger": "EvalError"},
{"trigger": "RangeError"},
{"trigger": "ReferenceError"},
{"trigger": "SyntaxError"},
{"trigger": "TypeError"},
{"trigger": "URIError"},
{"trigger": "configurable: "},
{"trigger": "enumerable: "},
{"trigger": "value: "},
{"trigger": "writable: "},
{"trigger": "get: ()", "contents": "get: ->"},
{"trigger": "set: (val)", "contents": "set: (val) ->"}
*/
]
}

View File

@@ -0,0 +1,50 @@
{
// These dirs will not be searched when looking for .coffee files.
// These should be dir names only. No relative paths.
"coffee_autocomplete_plus_excluded_dirs":
[
".svn",
".git",
"CVS",
"lib",
"node_modules",
"pub",
"public",
"vendor",
"doc",
"docs",
"build",
"builds",
"bin"
],
// List of strings. These paths will be appended to your project's root and searched.
// Leave empty to search all directories in your project's root directory.
"coffee_autocomplete_plus_restricted_to_paths": [],
// Map function names to types.
"coffee_autocomplete_plus_function_return_types":
[
{
"function_names": ["$", "jQuery"],
"type_name": "$"
}
],
// Regular expression of members to exclude from autocomplete.
// This is useful for properties/methods that are regarded "private" and start
// with an underscore. E.g. _privateVariable
"coffee_autocomplete_plus_member_exclusion_regexes":
[
"^_" // Starts with underscore
],
// OBSOLETE
// Aliases for "this", like "that" and "self".
// CA+ assignment detection is now able to detect that = this assignments.
"coffee_autocomplete_plus_this_aliases": ["that", "self"],
// The triggers for autocompletion
"auto_complete_triggers":
[
{"characters": ".@", "selector": "source.coffee, source.litcoffee, source.coffee.md"}
]
}

View File

@@ -0,0 +1,250 @@
import sublime, sublime_plugin
import re
import os
import threading
import coffee_utils
from coffee_utils import debug
COMMAND_NAME = 'coffee_goto_definition'
STATUS_MESSAGE_DEFINITION_FOUND = "Coffee: Definition for \"%s\" found."
STATUS_MESSAGE_NO_DEFINITION_FOUND = "Coffee: No definition for \"%s\" found."
STATUS_MESSAGE_COFFEE_GOTO_DEFINITION = "Coffee: Goto Definition of \"%s\""
# SEARCH ORDER:
# Current file class (TitleCaps only)
# Current file function
# Current file assignment
# Global TitleCaps.coffee class
# Global search for class (TitleCaps only)
# Global search for function
# TODO:
# X Add config for "this" aliases (DONE)
# - Codo docs searching for function parameter types
# X Goto definition knows about function parameters and for loop variables
# - Smarter operand parsing. E.g. Given: this.test = "test", when goto "test", look for "this.test = ", not "test ="
# - Check contents of currently open views
# - Menu integration
class CoffeeGotoDefinitionCommand(sublime_plugin.TextCommand):
def run(self, edit):
# Get the window
self.window = sublime.active_window()
# The current view
view = self.view
# Lines for currently viewed file
current_file_lines = coffee_utils.get_view_content_lines(view)
# Get currently selected word
coffee_utils.select_current_word(view)
selected_word = coffee_utils.get_selected_word(view)
selected_region = self.view.sel()[0]
# http://www.sublimetext.com/forum/viewtopic.php?f=6&t=9076
settings = sublime.load_settings(coffee_utils.SETTINGS_FILE_NAME)
# Pull the excluded dirs from preferences
excluded_dirs = settings.get(coffee_utils.PREFERENCES_COFFEE_EXCLUDED_DIRS)
if not excluded_dirs:
excluded_dirs = []
restricted_to_dirs = settings.get(coffee_utils.PREFERENCES_COFFEE_RESTRICTED_TO_PATHS)
if not restricted_to_dirs:
restricted_to_dirs = []
# List of all project folders
project_folder_list = self.window.folders()
if restricted_to_dirs:
specific_project_folders = []
for next_restricted_dir in restricted_to_dirs:
for next_project_folder in project_folder_list:
next_specific_folder = os.path.normpath(os.path.join(next_project_folder, next_restricted_dir))
specific_project_folders.append(next_specific_folder)
project_folder_list = specific_project_folders
# If there is a word selection and we're looking at a coffee file...
if len(selected_word) > 0 and coffee_utils.is_coffee_syntax(view):
thread = CoffeeGotoDefinitionThread(project_folder_list, current_file_lines, selected_word, excluded_dirs, selected_region)
thread.start()
self.check_operation(thread)
def check_operation(self, thread, previous_progress_indicator_tuple=None):
selected_word = thread.selected_word
if not thread.is_alive():
# Flatten any selection ranges
if len(self.view.sel()) > 0:
region = self.view.sel()[0]
debug(region)
end_point = region.end()
region_to_select = sublime.Region(end_point, end_point)
coffee_utils.select_region_in_view(self.view, region_to_select)
matched_location_tuple = thread.matched_location_tuple
if matched_location_tuple:
# debug("Match found!")
file_to_open = matched_location_tuple[0]
row = matched_location_tuple[1] + 1
column = matched_location_tuple[2] + 1
match = matched_location_tuple[3]
row_start_index = matched_location_tuple[4]
# If there is a file to open...
if file_to_open:
# Open the file in the editor
coffee_utils.open_file_at_position(self.window, file_to_open, row, column)
# Otherwise, assume we found the match in the current view
else:
match_end = row_start_index + match.start() + len(match.group())
region_to_select = sublime.Region(match_end, match_end)
coffee_utils.select_region_in_view(self.view, region_to_select)
self.view.show(region_to_select)
self.window.active_view().set_status(COMMAND_NAME, STATUS_MESSAGE_DEFINITION_FOUND % selected_word)
else:
self.window.active_view().set_status(COMMAND_NAME, STATUS_MESSAGE_NO_DEFINITION_FOUND % selected_word)
else:
# Create the command's goto definition text, including the selected word. For the status bar.
goto_definition_status_text = STATUS_MESSAGE_COFFEE_GOTO_DEFINITION % selected_word
# Get a tuple containing the progress text, progress position, and progress direction.
# This is used to animate a progress indicator in the status bar.
current_progress_indicator_tuple = coffee_utils.get_progress_indicator_tuple(previous_progress_indicator_tuple)
# Get the progress text
progress_indicator_status_text = current_progress_indicator_tuple[0]
# Set the status bar text so the user knows what's going on
self.window.active_view().set_status(COMMAND_NAME, goto_definition_status_text + " " + progress_indicator_status_text)
# Check again momentarily to see if the operation has completed.
sublime.set_timeout(lambda: self.check_operation(thread, current_progress_indicator_tuple), 100)
class CoffeeGotoDefinitionThread(threading.Thread):
def __init__(self, project_folder_list, current_file_lines, selected_word, excluded_dirs, selected_region):
self.project_folder_list = project_folder_list
self.current_file_lines = current_file_lines
self.selected_word = selected_word
self.excluded_dirs = excluded_dirs
self.selected_region = selected_region
# None if no match was found, or a tuple containing the filename, row, column and match
self.matched_location_tuple = None
threading.Thread.__init__(self)
def run(self):
project_folder_list = self.project_folder_list
current_file_lines = self.current_file_lines
selected_word = self.selected_word
excluded_dirs = self.excluded_dirs
selected_region = self.selected_region
# This will be assigned whem a match is made
matched_location_tuple = None
# The regular expression used to search for the selected class
class_regex = coffee_utils.CLASS_REGEX % re.escape(selected_word)
# The regex used to search for the selected function
function_regex = coffee_utils.FUNCTION_REGEX % re.escape(selected_word)
# The regex used to search for the selected variable assignment
assignment_regex = coffee_utils.ASSIGNMENT_REGEX % re.escape(selected_word)
# The regex used to search for the selected variable as a parameter in a method
param_regex = coffee_utils.PARAM_REGEX.format(name=re.escape(selected_word))
# The regex used to search for the selected variable as a for loop var
for_loop_regex = coffee_utils.FOR_LOOP_REGEX % re.escape(selected_word)
debug(("Selected: \"%s\"" % selected_word))
# ------ CURRENT FILE: CLASS (TitleCaps ONLY) ------------
if not matched_location_tuple:
# If so, we assume it is a class.
debug("Checking for local class %s..." % selected_word)
class_location_search_tuple = coffee_utils.find_location_of_regex_in_files(class_regex, current_file_lines, [])
if class_location_search_tuple:
matched_location_tuple = class_location_search_tuple
# ------ GLOBAL SEARCH: CLASS ----------------------------
if not matched_location_tuple:
# Coffeescript filename regex
coffeescript_filename_regex = coffee_utils.COFFEE_FILENAME_REGEX
# All coffeescript file paths
all_coffee_file_paths = coffee_utils.get_files_in(project_folder_list, coffeescript_filename_regex, excluded_dirs)
debug("Checking globally for class %s..." % selected_word)
# Assume it is a file called selected_word.coffee
exact_file_name_regex = "^" + re.escape(selected_word) + coffee_utils.COFFEE_EXTENSION_WITH_DOT + "$"
exact_name_file_paths = coffee_utils.get_files_in(project_folder_list, exact_file_name_regex, excluded_dirs)
exact_location_search_tuple = coffee_utils.find_location_of_regex_in_files(class_regex, None, exact_name_file_paths)
if exact_location_search_tuple:
matched_location_tuple = exact_location_search_tuple
else:
global_class_location_search_tuple = coffee_utils.find_location_of_regex_in_files(class_regex, None, all_coffee_file_paths)
if global_class_location_search_tuple:
matched_location_tuple = global_class_location_search_tuple
# ------ CURRENT FILE: FUNCTION --------------------------
if not matched_location_tuple:
debug("Checking for local function %s..." % selected_word)
local_function_location_search_tuple = coffee_utils.find_location_of_regex_in_files(function_regex, current_file_lines, [])
if local_function_location_search_tuple:
matched_location_tuple = local_function_location_search_tuple
# ------ CURRENT FILE: ASSIGNMENT ------------------------
if not matched_location_tuple:
debug("Checking for local assignment of %s..." % selected_word)
backwards_match_tuple = coffee_utils.search_backwards_for(current_file_lines, assignment_regex, selected_region)
if backwards_match_tuple:
filename_tuple = tuple([None])
matched_location_tuple = filename_tuple + backwards_match_tuple
else:
# Nothing found. Now let's look backwards for a method parameter
param_match_tuple = coffee_utils.search_backwards_for(current_file_lines, param_regex, selected_region)
if param_match_tuple:
filename_tuple = tuple([None])
matched_location_tuple = filename_tuple + param_match_tuple
else:
for_loop_match_tuple = coffee_utils.search_backwards_for(current_file_lines, for_loop_regex, selected_region)
if for_loop_match_tuple:
filename_tuple = tuple([None])
matched_location_tuple = filename_tuple + for_loop_match_tuple
# Otherwise, forwards search for it. It could be defined in the constructor.
else:
forwards_match_tuple = coffee_utils.find_location_of_regex_in_files(assignment_regex, current_file_lines, [])
if forwards_match_tuple:
matched_location_tuple = forwards_match_tuple
# ------ GLOBAL SEARCH: FUNCTION -------------------------
if not matched_location_tuple:
# Coffeescript filename regex
coffeescript_filename_regex = coffee_utils.COFFEE_FILENAME_REGEX
# All coffeescript file paths
all_coffee_file_paths = coffee_utils.get_files_in(project_folder_list, coffeescript_filename_regex, excluded_dirs)
debug("Checking globally for function %s..." % selected_word)
global_function_location_search_tuple = coffee_utils.find_location_of_regex_in_files(function_regex, None, all_coffee_file_paths)
if global_function_location_search_tuple:
matched_location_tuple = global_function_location_search_tuple
# ------ DOT OPERATION LOOKUP (TBD) ----------------------
# TODO: Pull out dot operator object, determine its assignment type, find class, goto method/property.
# Also, determine where to put this lookup.
# ------ SUPER METHOD LOOKUP (TBD) -----------------------
# TODO: If selected_word is "super", assume a function and then attempt to find
# extending class and open it to the function the cursor is within.
# ------ STORE MATCH RESULTS -----------------------------
# If not None, then we found something that matched the search!
if matched_location_tuple:
self.matched_location_tuple = matched_location_tuple

View File

@@ -0,0 +1,5 @@
[
{
"keys": ["ctrl+alt+d"], "command": "coffee_goto_definition"
}
]

View File

@@ -0,0 +1,8 @@
[
{
"button": "button1", "count": 1, "modifiers": ["ctrl", "alt"],
"press_command": "drag_select",
"command": "coffee_goto_definition",
"press_args": {"by": "words"}
}
]

View File

@@ -0,0 +1,5 @@
[
{
"keys": ["ctrl+alt+d"], "command": "coffee_goto_definition"
}
]

View File

@@ -0,0 +1,8 @@
[
{
"button": "button1", "count": 1, "modifiers": ["ctrl", "alt"],
"press_command": "drag_select",
"command": "coffee_goto_definition",
"press_args": {"by": "words"}
}
]

View File

@@ -0,0 +1,5 @@
[
{
"keys": ["ctrl+alt+d"], "command": "coffee_goto_definition"
}
]

View File

@@ -0,0 +1,8 @@
[
{
"button": "button1", "count": 1, "modifiers": ["ctrl", "alt"],
"press_command": "drag_select",
"command": "coffee_goto_definition",
"press_args": {"by": "words"}
}
]

View File

@@ -0,0 +1,3 @@
[
{"caption": "Coffee: Goto Definition", "command": "coffee_goto_definition"}
]

View File

@@ -0,0 +1,160 @@
[
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "CoffeeComplete Plus",
"children":
[
{ // README
"command": "open_file",
"args": {"file": "${packages}/CoffeeComplete Plus (Autocompletion)/README.md"},
"caption": "README"
},
{ "caption": "-" },
{ // Settings - Default
"command": "open_file",
"args": {"file": "${packages}/CoffeeComplete Plus (Autocompletion)/CoffeeComplete Plus.sublime-settings"},
"caption": "Settings Default"
},
{ // Settings User
"command": "open_file",
"args": {"file": "${packages}/User/CoffeeComplete Plus.sublime-settings"},
"caption": "Settings User"
},
{ "caption": "-" },
{ // Key Bindings Default (OSX)
"command": "open_file",
"args": {
"file": "${packages}/CoffeeComplete Plus (Autocompletion)/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings Default"
},
{ // Key Bindings Default (Linux)
"command": "open_file",
"args": {
"file": "${packages}/CoffeeComplete Plus (Autocompletion)/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings Default"
},
{ // Key Bindings Default (Windows)
"command": "open_file",
"args": {
"file": "${packages}/CoffeeComplete Plus (Autocompletion)/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings Default"
},
{ // Key Bindings User (OSX)
"command": "open_file",
"args": {
"file": "${packages}/User/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings User"
},
{ // Key Bindings User (Linux)
"command": "open_file",
"args": {
"file": "${packages}/User/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings User"
},
{ // Key Bindings User (Windows)
"command": "open_file",
"args": {
"file": "${packages}/User/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings User"
},
{ "caption": "-" },
{ // Mouse Bindings Default (OSX)
"command": "open_file",
"args": {
"file": "${packages}/CoffeeComplete Plus (Autocompletion)/Default (OSX).sublime-mousemap",
"platform": "OSX"
},
"caption": "Mouse Bindings Default"
},
{ // Mouse Bindings Default (Linux)
"command": "open_file",
"args": {
"file": "${packages}/CoffeeComplete Plus (Autocompletion)/Default (Linux).sublime-mousemap",
"platform": "Linux"
},
"caption": "Mouse Bindings Default"
},
{ // Mouse Bindings Default (Windows)
"command": "open_file",
"args": {
"file": "${packages}/CoffeeComplete Plus (Autocompletion)/Default (Windows).sublime-mousemap",
"platform": "Windows"
},
"caption": "Mouse Bindings Default"
},
{ // Mouse Bindings User (OSX)
"command": "open_file",
"args": {
"file": "${packages}/User/Default (OSX).sublime-mousemap",
"platform": "OSX"
},
"caption": "Mouse Bindings User"
},
{ // Mouse Bindings User (Linux)
"command": "open_file",
"args": {
"file": "${packages}/User/Default (Linux).sublime-mousemap",
"platform": "Linux"
},
"caption": "Mouse Bindings User"
},
{ // Mouse Bindings User (Windows)
"command": "open_file",
"args": {
"file": "${packages}/User/Default (Windows).sublime-mousemap",
"platform": "Windows"
},
"caption": "Mouse Bindings User"
},
{ "caption": "-" },
{ // Custom Types Default
"command": "open_file",
"args": {"file": "${packages}/CoffeeComplete Plus (Autocompletion)/CoffeeComplete Plus Custom Types.sublime-settings"},
"caption": "Custom Types Default"
},
{ // Custom Types User
"command": "open_file",
"args": {"file": "${packages}/User/CoffeeComplete Plus Custom Types.sublime-settings"},
"caption": "Custom Types User"
},
{ "caption": "-" },
{ // Built-In Types Default
"command": "open_file",
"args": {"file": "${packages}/CoffeeComplete Plus (Autocompletion)/CoffeeComplete Plus Built-In Types.sublime-settings"},
"caption": "Built-In Types Default"
},
{ // Built-In Types User
"command": "open_file",
"args": {"file": "${packages}/User/CoffeeComplete Plus Built-In Types.sublime-settings"},
"caption": "Built-In Types User"
}
]
}
]
}
]
}
]

View File

@@ -0,0 +1,424 @@
CoffeeComplete Plus
===================
CoffeeComplete Plus (CC+) is a [Sublime Text 2](http://www.sublimetext.com/2) plugin that scans your CoffeeScript files on demand and makes autocomplete suggestions for you.
In addition, this plugin adds the "Coffee: Goto Definition" command, which will look up the class, function or variable definition of the selected token.
Do you miss the old days? When, at the control-tap of a spacebar, your IDE joyfully came running to you, list in hand, asking, "what would you like, sir?" And that list actually made sense? And suggested items you were interested in? I missed those days, so I decided to do something about it. I learned about [Sublime Text 2](http://www.sublimetext.com/2). Best decision of my life. Then, I learned how to make plugins. My first order of business was to make this plugin—and now it's available for you to use.
Autocompletions. Zooming to definitions.
Let start coding again like the old days. With *style*.
Installation
------------
### Package Control
It is recommended that you use [Sublime Package Control](http://wbond.net/sublime_packages/package_control) to install CoffeeComplete Plus. If you have Package Control installed, use the Package Control: Install Package command and search for CoffeeComplete Plus. Ouila. Start coding easier.
### Manual Installation
In order to manually install CoffeeComplete Plus, clone the repository into your Sublime Text 2 `Packages` directory, which can be located by navigating to Preferences -> Browse Packages. Name the directory `CoffeeComplete Plus (Autocompletion)`.
For your convenience:
```
git clone https://github.com/justinmahar/SublimeCSAutocompletePlus.git "CoffeeComplete Plus (Autocompletion)"
```
Usage
-----
### Autocomplete
Autocomplete can be triggered in coffee files by typing the dot `.` operator or the `@` symbol (which is shorthand for `this`). You can also press `ctrl+space` to trigger autocompletions manually. The plugin will then try to figure out what you're doing and propose a list of suggestions.
Example usage: Inside a class, you type `this.`. A list of the available methods and properties is presented.
### Goto Definition
Looking for where a class, function or variable was defined? Look no further.
Place your cursor on any word and press `ctrl+alt+d` in Windows/Linux, and `ctrl+alt+d` in OS X, to goto the definition of the selected class, function or variable. Life's good.
Alternatively, use `ctrl+alt` + `left click` in Windows/Linux, and `ctrl+alt` + `left click` in OS X.
Features
--------
### Autocomplete
Autocomplete will make suggestions when you trigger autocomplete after a dot operator. It starts with the current view, then branches out to other coffee files. Because of this, most lookups are blazingly fast. You can configure CC+ to exclude certain directories and to only look in others. This will further increase speed as less searching will be needed.
Autocomplete suggestions alphabetically show properties first, as indicated by a ○ symbol before each property name, followed by alphabetically sorted methods, as indicated by a ● symbol before each method name. Inherited properties and methods will be preceded by a Ⱶ symbol. This creates a nice visual breakdown of what you can do at any given time, and where things are coming from. Badass.
For example:
○ property1
○ propertyTwo
○ someOtherProperty
● methodOne()
● methodTwo(arg1, arg2)
● theLastMethod(arg1, arg2, arg3)
Ⱶ○ inheritedProperty1
Ⱶ○ inheritedPropertyTwo
Ⱶ● inheritedMethod1()
Ⱶ● inheritedMethod2(arg1, arg2)
Here are the main features. In the examples, `[autocomplete]` represents the user action of triggering autocomplete, which is typically `ctrl+space`.
* Suggests instance properties and methods when operating on an instance.
myLamp = new LavaLamp()
# Suggests all instance properties and methods of LavaLamp.
myLamp.[autocomplete]
* Suggests static properties and methods when operating on a class.
# Suggests all static properties and methods of LavaLamp.
LavaLamp.[autocomplete]
* Supports "this" keyword and any defined aliases.
class LavaLamp
heatUp: ->
console.log "Heating up!"
coolDown: ->
console.log "Cooling down!"
moveBlobs: ->
# Suggests heatUp() and coolDown() methods
this.[autocomplete]
* Any variable assigned to `this` in the constructor will be considered an instance property.
class LavaLamp
constructor: (@color, size) ->
this.size = size
moveBlobs: ->
# Suggests color, size and moveBlobs()
this.[autocomplete]
* Suggests super class properties and functions. This applies to both instance and static suggestions.
# In the following example, we have a LavaLamp that extends Appliance.
# Each class has static and non-static properties and methods.
# Given the context, CC+ will suggest either static or non-static,
# and will walk up the class hierarchy.
class Appliance
# Static
@WARRANTY_YEARS = 10
@calculateWarrantyExpiration: (currentYear) ->
console.log "Expires: ", currentYear + Appliance.WARRANTY_YEARS
# Non-static
constructor: ->
this.isSwitchedOn = False
toggle: ->
this.isSwitchedOn = !this.isSwitchedOn
class LavaLamp extends Appliance
# Static
@BEST_COLOR = "Red"
@isLampAwesome: (lamp) ->
if lamp.color == LavaLamp.BEST_COLOR
console.log "Definitely"
else
console.log "Probably"
# Non-static
constructor: (@color, size) ->
this.size = size
moveBlobs: ->
# Suggests color, isSwitchedOn, size, moveBlobs(), toggle()
this.[autocomplete]
# Suggests WARRANTY_YEARS and calculateWarrantyExpiration(), which are static.
Appliance.[autocomplete]
# Suggests BEST_COLOR, WARRANTY_YEARS, calculateWarrantyExpiration(), and isLampAwesome()
# These are all static properties from the complete class heirarchy.
LavaLamp.[autocomplete]
* After autocompleting a method, tab stops for parameters are provided (if applicable).
* Expects that you don't suck at naming things. Will assume a class is UpperCamelCase and everything else is lowerCamelCase. It still works either way; it will just be faster if things are named properly.
* For every 1 million autocompletions, a beautiful masseuse appears and gives you a massage. You must be tired after all that coding.
### Support For Built-in Types
CC+ now supports autocompletion for the following built-in types:
* Array
* Boolean
* Date
* Function
* Number
* Object
* RegExp
* String
* JSON
This makes life that much easier.
In addition, autocomplete suggests inherited properties and methods from Object.
### Custom Types
If you find yourself using a third-party library often and would like to have autocompletions for that library, you can create custom type. This is essentially a collection of autocomplete suggestions. CC+ supports jQuery out of the box, but you can always add others. If you do add a custom type and would like to share it, please issue a pull request and I will add it to the plugin. If your library is used as function, like jQuery, you can map that function's return value to a type. See the configuration section for how to do this.
### Type Hinting
Document your code and you shall be rewarded in many ways. One of these way is autocompletion. Another of these ways is a warm, fuzzy feeling all over.
CC+ can detect types using hints you provide it in comments. You can even add method headers with hints for parameters.
* Variable assignment type hints
- When you assign a variable, you can add a type hint that CC+ will use to look up the class autocompletions for you. This type must be in square brackets, and in a single-line `#` comment on either the same line or the previous line, in the form `[TYPENAME]`. Other text can surround the type hint.
```
# The [String] to add type hinting for
myString = someObject.getSomething()
# Now, CC+ knows that it's a String
myString.[autocomplete]
# Alternate way to add type hinting
otherString = someObject.getSomethingElse() # It's a [String], son.
```
* Parameter type hints
- If you use [Codo](https://github.com/netzpirat/codo), or are in the habit of documenting your classes, you can add type hints for your method parameters as well. These hints must be in a single-line `#` comment above the method signature. The hint can either be in the form `[TYPENAME] parameterName` or `parameterName [TYPENAME]`. Other text can surround the type hint.
```
# [Animal] critter
# [Boolean] animalEscapes
feedAlligator: (critter, animalEscapes) ->
if animalEscapes
# CC+ knows that it's an Animal. Will he escape? Autocomplete and choose his destiny!
critter.[autocomplete]
```
* Method return type hints
- If a variable is assigned to the return value of a method, type hinting can collected from that method. The method must have a single-line `#` comment on a previous line with the hint `@return [TYPE]`. This is a bonus convenience. Remember, you can always use the regular assignment type hinting mentioned above when assigning variables!
```
class Alligator
# @return [Animal]
getLastMeal: ->
this.lastMeal
rememberGoodTimes: ->
critter = this.getLastMeal()
# CC+ will detect your return type hint and display suggestions for type Animal
console.log "I remember the time I ate a critter named " + critter.[autocomplete]
```
### Data-Hiding With Private Member Exclusion
CoffeeScript doesn't provide an explicit way to hide properties and methods of a class. [According to Jeremy Ashkenas](https://groups.google.com/forum/#!topic/coffeescript/jgG7DhvyzzM), creator of coffeescript:
> The norm in JavaScript is that hiding stuff is not that big of a deal, and you prefix private properties of an object with an underscore, as a convention.
So, it's left up to you.
Using an underscore is all well and fine until your autocomplete list is all cluttered up with things you're not supposed to see.
CC+ to the rescue. You can define regular expressions to exclude any members of your choosing. By default, members starting with an underscore are not shown when working outside of a class (i.e., not using `this.`). See the configuration section for how to add/remove exclusions.
### Goto Definition
Goto Definition is useful for finding where a class, function, or variable was defined or declared. Again, searching is performed from the current view and branches out to other files if nothing is found. With this, you can quickly jump between classes and zoom to functions—even ones defined in other files—with ease.
* Supports classes, functions and variable assignment.
* Searches backwards from selected token for assignment, then forwards.
* Considers variables declared in for loops.
* Considers method parameters.
* Tries to find something rather than nothing.
* Includes both mouse and keyboard shortcuts for convenience. Code your way.
### General
* Asynchronous and fast lookups. That means no UI freezing while waiting for completions or Goto Definiton. Hate that.
* You can configure directories to be be excluded from global .coffee search. **(recommended)**
* You can configure the tool to only search in specific locations. **(recommended)**
Default Key Bindings
--------------------
### Windows/Linux:
Autocomplete: `ctrl+space` (after a dot operator)
Goto Definition: `ctrl+alt+d` or `ctrl+alt`+`left click`
### Mac OS X:
Autocomplete: `ctrl+space` (after a dot operator)
Goto Definition: `ctrl+alt+d` or `ctrl+alt`+`left click`
Key bindings can be changed by navigating to Preferences -> Package Settings -> CoffeeComplete Plus -> Key Bindings. It is not recommended that you change the Default settings as they will be overwritten by plugin updates. Instead, make your changes in User settings, which will override the Default settings.
Configuration
-------------
CoffeeComplete Plus has the following configurable settings:
### General Settings
In `CoffeeComplete Plus.sublime-settings`:
#### Excluded Directories
* `coffee_autocomplete_plus_excluded_dirs` — Excluded directories.
- Directories to exclude from searching for CoffeeScript classes, functions and variables. All directories in your project are searched except for the ones that match the names listed in this setting. **This is recommended.** Some excluded directories have already been specified in settings.
- Expected value: Array of directory names.
- Example:
```
"coffee_autocomplete_plus_excluded_dirs" : [".git", "SVN", "pub", "docs"]
```
#### Path Restrictions
* `coffee_autocomplete_plus_restricted_to_paths` — Restrict searching to these directories.
- Paths to restrict the search to. If one or more path is specified, searching will be restricted to `PATH_TO_PROJECT/your/defined/path`. For example, you specify `src/coffee`. Now, only `PROJECT_PATH/src/coffee` will be scanned. **This is recommended.** If `[]`, no restrictions are applied.
- Expected value: Array of paths relative to your project directory.
- Example:
```
"coffee_autocomplete_plus_restricted_to_paths" : ["src/coffee", "lib/src/coffee"]
```
#### Member Exclusion Patterns For Data Hiding
* `coffee_autocomplete_plus_member_exclusion_regexes` — Regular expressions for members excluded from autocomplete suggestions.
- CoffeeScript doesn't provide a mechanism for making members `private` in the traditional sense. Conventionally, private members are prefixed with an underscore `_`. This configuration setting allows you to define regular expressions for members you would like to exclude. By default, members beginning with an underscore are excluded.
- Expected value: Array of Python regular expression strings.
- Example:
```
"coffee_autocomplete_plus_member_exclusion_regexes": ["^_"] // Excludes members prefixed with underscore
```
#### Customizing Autocomplete Trigger
* `auto_complete_triggers` — Characters that trigger the autocomplete menu.
- Sublime allows for context-specific triggers for the autocompletion menus. This allows the menu to show as soon as `.` or `@` are pressed, which are enabled by default. To customize these, use the following in settings and make the desired changes:
```
"auto_complete_triggers":
[
{"characters": ".@", "selector": "source.coffee"}
]
```
#### Aliases For `this`
* `coffee_autocomplete_plus_this_aliases` — Aliases for `this` keyword
- Due to lexical scoping you sometimes need to assign an alias for `this`, such as `that` or `self`. Keep in mind, you can use a fat arrow `=>` to have CoffeeScript do this for you under the hood. Regardless, this config setting allows you to add or remove aliases that cause autocomplete to behave just like using `this` would. No futher searching—`this` will be assumed.
- Expected value: Array of alias strings.
- Example:
```
"coffee_autocomplete_plus_this_aliases" : ["that", "self"]
```
#### Mapped Function Return Types
* `coffee_autocomplete_plus_function_return_types` — Mappings for the return types of special functions, like jQuery.
- You may want to make calls directly off of the returned values of special functions. For example, when using jQuery, you might type `$(selector).` and want some autocomplete suggestions. If you have a custom type defined, you can map the returns of function names, like `$` and `jQuery`, to that custom type. See the next config section for defining custom types.
- Expected value: Array of objects. Each object has a `function_names` property that maps to an array of string names, and a `type_name` property that maps to the string name of the type the functions return.
- Example:
```
"coffee_autocomplete_plus_function_return_types":
[
{
"function_names": ["$", "jQuery"],
"type_name": "$"
}
]
```
### Custom Types
In `CoffeeComplete Plus Custom Types.sublime-settings`:
* `coffee_autocomplete_plus_custom_types` -- Custom types, allowing libraries like jQuery.
- If you would like to define custom types, put them here. Autocomplete will then make the defined suggestions for you. By default, a type for jQuery is defined.
- Method arguments have a `name` property, and an option `insertion`, which will be the text that is actually inserted. For example, this is useful for inserting `->` syntax for callbacks.
- Use the `enabled` property to enable or disable a custom type.
- Use the following example as a starting point:
```
{
"name": "MyType",
"enabled": true,
"constructors": [{"args": []}],
"static_properties": [{"name": "CONSTANT_ONE"}, {"name": "CONSTANT_TWO"}],
"static_methods":
[
{"name":"myStaticMethod", "args": [{"name": "arg1"}, {"name": "arg2"}]},
{"name":"myStaticMethodTwo", "args": []}
],
"instance_properties": [{"name": "thingOne"}, {"name": "thingTwo"}, {"name": "thingThree"}],
"instance_methods":
[
{"name":"doStuffWithCallback", "args": [{"name": "numTimes"}, {"name": "callback()", "insertion": "->"}]},
{"name":"doMoreStuff", "args": [{"name": "numTimes"}, {"name": "extraAmount"}]}
]
}
```
### Built-In Types
In `CoffeeComplete Plus Built-In Types.sublime-settings`:
* `coffee_autocomplete_plus_built_in_types` -- Built-in types, like Object, Array, and String.
- These are JavaScript's build-in types. These specs were gleaned from the [Mozilla MDN](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects).
- Any of the built-in types can be disabled, if you'd like. Change the `enabled` property to `false`.
To configure these settings, open Preferences -> Package Settings -> CoffeeComplete Plus. It is not recommended that you change the Default settings as they will be overwritten by plugin updates. Instead, make your changes in User settings, which will override the Default settings.
Limitations and Plans
---------------------
> "Conceal a flaw, and the world will imagine the worst." — Marcus Aurelius, 16th Emperor of the Roman Empire
Autocomplete is smart, but not Mensa smart. Under the hood, we're using regular expressions and lots of scanning. I coded this rather quickly, and it's my first plugin, so there may be (read: probably are) bugs. Please let me know if there are. As I build out functionality, I will try to fix its limitations.
For now, here is the list of TBDs:
* Clean up code. Make modular/reusable. First priority.
* Constructor support
- Add constructors to built-in types
* Additional built-in types (Error, etc)
* Optional parameter detection
- Square brackets indicate optional params.
- Example: `methodName(var1, optionalVar2="hey, I'm optional")` will autocomplete to `classInstance.methodName(var1, [optionalVar2])`
* Fix issues
* Goto Definition knows types of objects methods are called on. Right now, it makes a guess.
* Support for built-in types when getting the return type for a method.
Far too many times I've installed a plugin only to be disappointed because it fell short of my expectations. If you feel this way, please let me know how I can make this plugin better for you and I will do my best.
Happy coding!
-Justin
License
-------
CoffeeComplete Plus is licensed under the MIT license.
Copyright (c) 2013 Justin Mahar <justin.m.mahar@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,3 @@
{
"install": "README.md"
}

View File

@@ -0,0 +1 @@
{"url": "https://github.com/justinmahar/SublimeCSAutocompletePlus", "version": "2013.03.20.10.00.10", "description": "CoffeeScript autocompletions and more!"}