Esempio n. 1
0
File: spots.py Progetto: boltjs/bolt
def spots(view):

    candidates = view.find_all('[a-zA-Z]+')
    inj = regions.injs(view)

    def spotter(region):
        return Spot(view.substr(region).strip(), region.begin(), region.end())

    def pred(region):
        text = view.substr(region)
        scope = view.scope_name(region.begin())
        ignored_scopes = filter(lambda x: scope.startswith('source.js ' + x), excluded_scopes())
        return len(ignored_scopes) == 0 and region.begin() > inj.end() and re.match('^[A-Z]', text)

    spot_regions = filter(pred, candidates)
    return map(spotter, spot_regions)
Esempio n. 2
0
def is_bolt_module(view):

    possible_starts = ['define\(', 'test\(']

    js = view.file_name() != None and view.file_name().endswith('.js')
    if js:

        dep_region = regions.deps(view)
        inj_region = regions.injs(view)

        def is_prefix(x):
            pos = view.find(x, 0)
            return pos != None and pos.begin() < dep_region.begin()

        if (dep_region != None and inj_region != None and dep_region.begin() < inj_region.begin()):
            defns = filter(is_prefix, possible_starts)
            if len(defns) == 0:
                return False
            else:
                return True

    return False
Esempio n. 3
0
File: write.py Progetto: boltjs/bolt
def _injs(view, edit, xs):
    region = regions.injs(view)
    view.replace(edit, region, _format_injs(xs))
Esempio n. 4
0
def injs(view):
    cursor = selection.point(view)
    return regions.injs(view).contains(cursor)
Esempio n. 5
0
def after_injs(view):
    cursor = selection.point(view)
    injs = regions.injs(view)
    return cursor > injs.end()
Esempio n. 6
0
File: text.py Progetto: boltjs/bolt
def injs(view):
    region = regions.injs(view)
    return _region(view, region)