Skip to content

Commit

Permalink
Added arguments scope completions, closes #37
Browse files Browse the repository at this point in the history
- also prepare for v0.14.0
  • Loading branch information
jcberquist committed Aug 18, 2016
1 parent d830f20 commit 17cc1aa
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"0.12.1": "messages/0.12.1.txt",
"0.12.2": "messages/0.12.2.txt",
"0.12.3": "messages/0.12.3.txt",
"0.13.0": "messages/0.13.0.txt"
"0.13.0": "messages/0.13.0.txt",
"0.14.0": "messages/0.14.0.txt"
}
11 changes: 11 additions & 0 deletions messages/0.14.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CFML v0.14.0 Changelog:

- after typing `arguments.` in a function body you will now be offered
available function arguments as completions
https://github.com/jcberquist/sublimetext-cfml/issues/37

- CFScript formatting bug fixes
https://github.com/jcberquist/sublimetext-cfml/issues/40

- Tag completions were updated to match latest cfdocs.org tag data
https://github.com/jcberquist/sublimetext-cfml/pull/41
10 changes: 10 additions & 0 deletions src/in_file_completions/in_file_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ def get_dot_completions(view, prefix, position, info):
completions = [make_completion(completion, info["file_path"]) for completion in completions["functions"]]
return CompletionList(completions, 1, True)

if len(info["dot_context"]) == 1 and symbol.name == "arguments":
current_function_body = utils.get_current_function_body(view, position, component_method=False)
if current_function_body:
function = utils.get_function(view, current_function_body.begin() - 1)
meta = metadata.get_string_metadata(view.substr(function[2]) + "{}")
if "functions" in meta and function[0] in meta["functions"]:
args = meta["functions"][function[0]].meta["arguments"]
completions = [(arg["name"] + "\targuments", arg["name"]) for arg in args]
return CompletionList(completions, 1, True)

if symbol.name == "super" and info["project_name"]:
extends = get_extends(view)
if extends:
Expand Down
3 changes: 3 additions & 0 deletions src/in_file_completions/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def get_view_metadata(view):
extended_meta["property_file_map"].update({prop_key: file_path for prop_key in base_meta["properties"]})
return extended_meta

def get_string_metadata(file_string):
return parse_cfc_file_string(file_string)

def get_minimal_file_string(view):
min_string = ""

Expand Down
8 changes: 7 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ def get_function_call(view, pt, support=False):
return view.substr(function_name_region).lower(), function_name_region, function_args_region
return None

def get_current_function_body(view, pt, component_method=True):
selector = "meta.function.body.cfml"
if component_method:
selector = "source.cfml.script meta.class.body.cfml " + selector
return get_scope_region_containing_point(view, pt, selector)

def get_verified_path(root_path, rel_path):
"""
Given a valid root path and an unverified relative path out from that root
Expand All @@ -289,4 +295,4 @@ def get_verified_path(root_path, rel_path):
return rel_path, False
verified_path_elements.append(dir_map[elem.lower()])

return "/".join(verified_path_elements), True
return "/".join(verified_path_elements), True

0 comments on commit 17cc1aa

Please sign in to comment.