def __init__(self, filename, ctx, kind=None):
     super().__init__(
         name=ctx.getChild(0, Parser.IdentifierContext).start.text,
         kind=kind,
         location=Location(
             filename,
             Range(start=Position(ctx.start.line, ctx.start.column),
                   end=Position(ctx.stop.line, ctx.stop.column))))
Beispiel #2
0
def definition(params):
    text_doc = server.workspace.get_document(params.textDocument.uri)
    antfile = get_antfile(text_doc)
    srclocations, range_ = antfile.goto(sb_position(params.position))

    definitions = [
        Location(loc.path, pygls_range(loc.range)) for loc in srclocations
    ]
    # If no definitions, return None
    return definitions or None
Beispiel #3
0
def jump_to_definition(ls, c: TextDocumentPositionParams) -> List[Location]:
    doc = ls.workspace.get_document(c.textDocument.uri)
    items = find_definition(doc.uri, doc.source, c.position.line + 1,
                            c.position.character)
    return [
        Location(
            path_to_uri(item.module_path),
            Range(
                Position(item.line - 1, item.column),
                Position(item.line - 1, item.column + len(item.name)),
            ),
        ) for item in items
    ]
Beispiel #4
0
def test_location():
    assert Location(uri="file:///document.txt", range=Range(Position(1, 2), Position(3, 4))) \
        == Location(uri="file:///document.txt", range=Range(Position(1, 2), Position(3, 4)))
    assert Location(uri="file:///document.txt", range=Range(Position(1, 2), Position(3, 4))) \
        != Location(uri="file:///another.txt", range=Range(Position(1, 2), Position(3, 4)))
    assert Location(uri="file:///document.txt", range=Range(Position(1, 2), Position(3, 4))) \
        != 'something else'
    assert "file:///document.txt:1:2-3:4" == repr(
        Location(uri="file:///document.txt",
                 range=Range(Position(1, 2), Position(3, 4))))
Beispiel #5
0
def lsp_location(name: Name) -> Location:
    """Get LSP location from Jedi definition."""
    return Location(uri=from_fs_path(name.module_path), range=lsp_range(name))
Beispiel #6
0
def _find_refs(ls: Server, uri: str, pos: Position):
    links = _find_links(ls, uri, pos, ls.wdl_refs)
    if links is not None:
        return [Location(link.abspath, _get_range(link)) for link in links]
Beispiel #7
0
def _find_def(ls: Server, uri: str, pos: Position):
    link = _find_links(ls, uri, pos, ls.wdl_defs)
    if link is not None:
        return Location(link.abspath, _get_range(link))