Exemple #1
0
def run(view, handler):

    valid = lookup_file_type.is_bolt_module(view)
    if not valid:
        open_file = view.file_name() if view.file_name() != None else "-- no view"
        print "View is not a bolt module: " + open_file
        handler.cancel()
    else:
        read_view = ui_read.all(view)
        spots = read_spots.spots(view)
        plasmas = core_read.plasmas(read_view.ptext)

        def update_ui(highlights, module_wrong):
            def run():
                regions = write_highlight.regions(view, highlights)
                module_region = [ui_regions.module_name(view)] if module_wrong else []
                flag_info = zip(flags(), [regions.incorrect, regions.missing, regions.unused, module_region])

                def highlight_flag(x):
                    if len(x[1]) > 0:
                        write_highlight.highlight(view, x[1], x[0]),
                    else:
                        write_highlight.remove_highlight(view, x[0])

                map(highlight_flag, flag_info)

            sublime.set_timeout(run, 0)

        thread = GeneralThread(_highlighter(read_view, spots, plasmas, update_ui), handler.success, handler.failure)
        sublime.set_timeout(thread.start, 0)
        handler.init(thread)
Exemple #2
0
def optimise(view, edit):
    read_view = ui_read.all(view)
    spots = read_spots.spots(view)
    plasmas = core_read.plasmas(read_view.ptext)

    unused = analyse.unused(plasmas, spots)
    optimised = plist.remove_all(plasmas, unused)
    ui_write.plasmas(view, edit, plist.sort(optimised))