Exemplo n.º 1
0
def alternate():
    mapping = {'.h': '.cpp', '.cpp': '.h'}
    if vimp.buf.extension in mapping:
        altfile = vimp.buf.stem + mapping[vimp.buf.extension]
        for f in package().locate_files(altfile):
            vimp.edit(f)
            return
        print 'Nothing found!'
    else:
        print 'No alternate for this extension'
Exemplo n.º 2
0
def alternate():
    mapping = {'.h': '.cpp', '.cpp': '.h'}
    if vimp.buf.extension in mapping:
        altfile = vimp.buf.stem + mapping[vimp.buf.extension]
        for f in package().locate_files(altfile):
            vimp.edit(f)
            return
        print 'Nothing found!'
    else:
        print 'No alternate for this extension'
Exemplo n.º 3
0
def alternate():
    mapping = {'.h': ('.cpp', '.cc'), '.cpp': ('.h',), '.cc': ('.h',)}
    if vimp.buf.extension in mapping:
        for altextension in mapping[vimp.buf.extension]:
            altfile = vimp.buf.stem + altextension
            for f in package().locate_files(altfile):
                vimp.edit(f)
                return
            print('No {} alternate found!'.format(altextension))
        else:
            print('Unknown extension!')
Exemplo n.º 4
0
def alternate():
    mapping = {".h": (".cpp", ".cc"), ".cpp": (".h",), ".cc": (".h",)}
    if vimp.buf.extension in mapping:
        for altextension in mapping[vimp.buf.extension]:
            altfile = vimp.buf.stem + altextension
            for f in package().locate_files(altfile):
                vimp.edit(f)
                return
            print("No {} alternate found!".format(altextension))
        else:
            print("Unknown extension!")
Exemplo n.º 5
0
def goto_file():
    import roslaunch.substitution_args
    tag = pxp.get_inner_tag(vim.current.buffer, vimp.buf.cursor)
    if 'file' in tag.attr:
        f = roslaunch.substitution_args.resolve_args(tag.attr['file'])
        vimp.edit(f)
        return
    find_expression = goto_rospack_find(vim.current.buffer, vimp.buf.cursor)
    if find_expression:
        f = roslaunch.substitution_args.resolve_args(find_expression)
        vimp.edit(f)
Exemplo n.º 6
0
def goto_file():
    import roslaunch.substitution_args
    tag = pxp.get_inner_tag(vim.current.buffer, vimp.buf.cursor)
    if 'file' in tag.attr:
        f = roslaunch.substitution_args.resolve_args(tag.attr['file'])
        vimp.edit(f)
        return
    for attr in tag.attr.values():
        if re.match(r'\$\(find \w+\)/.+', attr):
            f = roslaunch.substitution_args.resolve_args(attr)
            vimp.edit(f)
            return
Exemplo n.º 7
0
def alternate():
    mapping = {'.h': ('.cpp', '.cc'), '.cpp': ('.h', '.hpp'), '.cc': ('.h', ),
               '.hpp': ('.cpp', '.impl'), '.impl': ('.hpp', )}
    if vimp.buf.extension in mapping:
        for altextension in mapping[vimp.buf.extension]:
            altfile = vimp.buf.stem + altextension
            for f in package().locate_files(altfile):
                vimp.edit(f)
                return
            print('No {} alternate found!'.format(altextension))
        else:
            print('Unknown extension!')
Exemplo n.º 8
0
Arquivo: msg.py Projeto: nus/vim-ros
def goto_definition():
    text, group, start, end = vimp.syntax.get_entire_syntax_region()
    # We can go to the definition of only "complex" user-defined message types,
    # because build-in types have no definition. The only exception is the
    # "Header" type, which despite being a built-in is actually a "complex"
    # message type with a definition.
    if group == 'rosmsgBuiltInType' and text == 'Header':
        group, text = 'rosmsgType', 'std_msgs/Header'
    if group == 'rosmsgType':
        package_name, msg_type = text.split('/')
        for f in rosp.Package(package_name).locate_files(msg_type + '.msg'):
            vimp.edit(f)
    elif group == 'rosmsgBuiltInType':
        print '"{0}" is a built-in type and has no definition'.format(text)
    else:
        print 'Not a message type'
Exemplo n.º 9
0
def rosed(package_name, *file_names):
    try:
        pkg = rosp.Package(package_name)
    except rospkg.ResourceNotFound:
        print("Package {0} not found".format(package_name))
        return
    for fn in file_names:
        files = list(pkg.locate_files(fn))
        if len(files) == 0:
            print("File {0} not found".format(fn))
        elif len(files) == 1:
            vimp.edit(files[0])
        else:
            f = vimp.inputlist("You have chosen a non-unique filename, please " "pick one of the following:", files)
            if f is not None:
                vimp.edit(f)
Exemplo n.º 10
0
def goto_definition():
    text, group, start, end = vimp.syntax.get_entire_syntax_region()
    # We can go to the definition of only "complex" user-defined message types,
    # because build-in types have no definition. The only exception is the
    # "Header" type, which despite being a built-in is actually a "complex"
    # message type with a definition.
    if group == 'rosmsgBuiltInType' and text == 'Header':
        group, text = 'rosmsgType', 'std_msgs/Header'
    if group == 'rosmsgType':
        package_name, msg_type = text.split('/')
        for f in rosp.Package(package_name).locate_files(msg_type + '.msg'):
            vimp.edit(f)
    elif group == 'rosmsgBuiltInType':
        print('"{0}" is a built-in type and has no definition'.format(text))
    else:
        print('Not a message type')
Exemplo n.º 11
0
def rosed(package_name, *file_names):
    try:
        pkg = rosp.Package(package_name)
    except rospkg.ResourceNotFound:
        print('Package {0} not found'.format(package_name))
        return
    for fn in file_names:
        files = list(pkg.locate_files(fn))
        if len(files) == 0:
            print('File {0} not found'.format(fn))
        elif len(files) == 1:
            vimp.edit(files[0])
        else:
            f = vimp.inputlist('You have chosen a non-unique filename, please '
                               'pick one of the following:', files)
            if f is not None:
                vimp.edit(f)
Exemplo n.º 12
0
def goto_definition():
    text, group, start, end = vimp.syntax.get_entire_syntax_region()
    # We can go to the definition of only "complex" user-defined message types,
    # because build-in types have no definition. The only exception is the
    # "Header" type, which despite being a built-in is actually a "complex"
    # message type with a definition.
    if group == "rosmsgBuiltInType" and text == "Header":
        group, text = "rosmsgType", "std_msgs/Header"
    if group == "rosmsgType":
        # The type name may fully-qualified or relative to the package
        if "/" in text:
            package_name, msg_type = text.split("/")
        else:
            package_name, msg_type = vimp.var["b:ros_package_name"], text
        for f in rosp.Package(package_name).locate_files(msg_type + ".msg"):
            vimp.edit(f)
    elif group == "rosmsgBuiltInType":
        print('"{0}" is a built-in type and has no definition'.format(text))
    else:
        print("Not a message type")
Exemplo n.º 13
0
def goto_file():
    tag = pxp.get_inner_tag(vim.current.buffer, vimp.buf.cursor)
    if 'file' in tag.attr:
        import roslaunch.substitution_args
        f = roslaunch.substitution_args.resolve_args(tag.attr['file'])
        vimp.edit(f)
Exemplo n.º 14
0
def goto_file():
    tag = pxp.get_inner_tag(vim.current.buffer, vimp.buf.cursor)
    if 'filename' in tag.attr and tag.name != 'mesh':
        import roslaunch.substitution_args
        f = roslaunch.substitution_args.resolve_args(tag.attr['filename'])
        vimp.edit(f)