예제 #1
0
def haskell_type(view, filename, module_name, line, column, cabal=None):
    result = None

    if hsdev.hsdev_enabled():
        # Convert from hsdev one-based locations to sublime zero-based positions
        def to_file_pos(r):
            return FilePosition(int(r['line']) - 1, int(r['column']) - 1)

        def to_region_type(r):
            return RegionType(r['type'], to_file_pos(r['region']['from']),
                              to_file_pos(r['region']['to']))

        ts = autocomplete.hsdev_client.ghcmod_type(filename,
                                                   line + 1,
                                                   column + 1,
                                                   ghc=get_ghc_opts(filename))
        if ts:
            return [to_region_type(r) for r in ts]
        return None
    column = sublime_column_to_ghc_column(view, line, column)
    line = line + 1
    if hdevtools_enabled():
        result = hdevtools_type(filename, line, column, cabal=cabal)
    if not result and module_name and ghcmod_enabled():
        result = ghcmod_type(filename, module_name, line, column)
    return parse_type_output(view, result) if result else None
예제 #2
0
def get_type(view, filename, module_name, line, column, cabal=None):
    result = None

    if get_setting_async('enable_hsdev'):
        # Convert from hsdev one-based locations to sublime zero-based positions
        ts = get_types(filename, cabal=cabal)
        pt = FilePosition(line, column).point(view)
        return sorted_types(view, ts, pt)
    column = sublime_column_to_ghc_column(view, line, column)
    line = line + 1
    if get_setting_async('enable_hdevtools'):
        result = hdevtools_type(filename, line, column, cabal=cabal)
    if not result and module_name and get_setting_async('enable_ghc_mod'):
        result = ghcmod_type(filename, module_name, line, column)
    return parse_type_output(view, result) if result else None
예제 #3
0
def get_type(view, filename, module_name, line, column, cabal = None):
    result = None

    if get_setting_async('enable_hsdev'):
        # Convert from hsdev one-based locations to sublime zero-based positions
        ts = get_types(filename, cabal = cabal)
        pt = FilePosition(line, column).point(view)
        return sorted_types(view, ts, pt)
    column = sublime_column_to_ghc_column(view, line, column)
    line = line + 1
    if get_setting_async('enable_hdevtools'):
        result = hdevtools_type(filename, line, column, cabal = cabal)
    if not result and module_name and get_setting_async('enable_ghc_mod'):
        result = ghcmod_type(filename, module_name, line, column)
    return parse_type_output(view, result) if result else None
예제 #4
0
def get_type(view, filename, module_name, line, column, cabal = None):
    result = None

    if get_setting_async('enable_hsdev'):
        # Convert from hsdev one-based locations to sublime zero-based positions
        ts = get_types(filename, cabal = cabal)
        pt = FilePosition(line, column).point(view)
        types = sorted(
            list(filter(lambda t: t.region(view).contains(pt), ts)),
            key = lambda t: t.region(view).size())
        return types
    column = sublime_column_to_ghc_column(view, line, column)
    line = line + 1
    if get_setting_async('enable_hdevtools'):
        result = hdevtools_type(filename, line, column, cabal = cabal)
    if not result and module_name and get_setting_async('enable_ghc_mod'):
        result = ghcmod_type(filename, module_name, line, column)
    return parse_type_output(view, result) if result else None
예제 #5
0
def haskell_type(view, filename, module_name, line, column, cabal = None):
    result = None

    if hsdev.hsdev_enabled():
        # Convert from hsdev one-based locations to sublime zero-based positions
        def to_file_pos(r):
            return FilePosition(int(r['line']) - 1, int(r['column']) - 1)
        def to_region_type(r):
            return RegionType(
                r['type'],
                to_file_pos(r['region']['from']),
                to_file_pos(r['region']['to']))
        ts = autocomplete.hsdev_client.ghcmod_type(filename, line + 1, column + 1, ghc = get_ghc_opts(filename))
        if ts:
            return [to_region_type(r) for r in ts]
        return None
    column = sublime_column_to_ghc_column(view, line, column)
    line = line + 1
    if hdevtools_enabled():
        result = hdevtools_type(filename, line, column, cabal = cabal)
    if not result and module_name and ghcmod_enabled():
        result = ghcmod_type(filename, module_name, line, column)
    return parse_type_output(view, result) if result else None