def template(cls): head, args = utilities.remove_bracketed(inspect.cleandoc(cls.__doc__)) template = Template(head) template_def = locations.SymbolDefinition(locations.get_location(cls), cls.__name__, args) all_templates.add(template) template_definitions[template.id] = template_def return template
def set_aside(make_def): s, manipulate = manipulate_cursor_block() docstring, args = utilities.remove_bracketed(s) name, _ = add_def(docstring, vim.current.buffer, make_def, len(args)) manipulate("{}({})".format(name, ", ".join(args))) ensure_import("pydwimmer.terms", vim.current.buffer) ensure_import("pydwimmer.compiler", vim.current.buffer)
def get_definition(x): loc = get_location(x) name = x.__name__ try: args = inspect.getargspec(x)[0] except TypeError: _, args = utilities.remove_bracketed(x.__doc__) return SymbolDefinition(loc, name, args)
def get_autocompletions(n, base): line = vim.current.line row, col = vim.current.window.cursor line = line[:col] + base + line[col:] text, _ = manipulate_block(line, col) head, args = utilities.remove_bracketed(text) print(autocomplete.best_matches(head, n)) return [autocomplete_entry_for_template(template, args) for template in autocomplete.best_matches(head, n)]
def make_template(s): s, bracketed = utilities.remove_bracketed(s) return Template(s), bracketed