示例#1
0
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
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)]
示例#5
0
def make_template(s):
    s, bracketed = utilities.remove_bracketed(s)
    return Template(s), bracketed