def run(self, mode=None):
        view = self.window.active_view()

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.classpath = \
            HaxeComplete_inst().get_build(view).get_classpath(view)
        if self.classpath is None:
            return

        self.classes, self.packages = self.extract_modules(self.classpath)
        self.mode = mode

        idx = 0
        self.options = None
        if mode == 'module':
            self.options = self.classes
            cl = to_haxe_form(self.classpath, view.file_name(), True)
            idx = self.options.index(cl)
        elif mode == 'package':
            self.options = self.packages
            pk = to_haxe_form(
                self.classpath, os.path.dirname(view.file_name()))
            idx = self.options.index(pk)
        else:
            return

        self.window.show_quick_panel(self.options, self.on_select, 0, idx)
    def run(self, mode=None):
        view = self.window.active_view()

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.classpath = \
            HaxeComplete_inst().get_build(view).get_classpath(view)
        if self.classpath is None:
            return

        self.classes, self.packages = self.extract_modules(self.classpath)
        self.mode = mode

        idx = 0
        self.options = None
        if mode == 'module':
            self.options = self.classes
            cl = to_haxe_form(self.classpath, view.file_name(), True)
            if cl in self.options:
                idx = self.options.index(cl)
        elif mode == 'package':
            self.options = self.packages
            pk = to_haxe_form(
                self.classpath, os.path.dirname(view.file_name()))
            if pk in self.options:
                idx = self.options.index(pk)
        else:
            return

        self.window.show_quick_panel(self.options, self.on_select, 0, idx)
    def run(self):
        win = self.window
        view = win.active_view()

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.context = get_context(view)

        self.cmds = []
        for gen in HaxeRefactoring.modules:
            self.cmds.extend(gen.poll(self.context))

        items = []
        for cmd in self.cmds:
            items.append(cmd[0])

        win.show_quick_panel(items, self.on_select)
    def run(self):
        win = self.window
        view = win.active_view()

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.context = get_context(view)

        self.cmds = []
        for gen in HaxeRefactoring.modules:
            self.cmds.extend(gen.poll(self.context))

        items = []
        for cmd in self.cmds:
            items.append(cmd[0])

        win.show_quick_panel(items, self.on_select)
Exemplo n.º 5
0
    def run(self):
        if HaxeUsage.is_active:
            return

        win = self.window
        view = win.active_view()
        self.has_errors = False
        self.has_pos_errors = False
        self.view = view
        self.hx_files = None
        self.is_cancelled = False

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.context = get_context(view)
        word = self.context.word
        self.word = word

        if not word:
            return

        HaxeUsage.is_active = True
        self.type_map = HaxeOrganizeImports.get_type_map(self.view)
        self.usages = []
        self.src_wo_comments = remove_comments(self.context.src)
        self.package = parse_package(self.src_wo_comments)

        # print('HU: ---------------------------------------')
        # print('HU:', word.name)

        self.root_dir = get_root_dir(
            self.view.file_name(), self.package)
        self.result_base_dir = os.path.abspath(
            os.path.join(self.root_dir, os.pardir))
        # print('HU root:', self.root_dir)

        if is_type(word.name, self.type_map):
            self.find_type_usages()
        else:
            self.find_local_or_field_usages()
Exemplo n.º 6
0
    def run(self):
        if HaxeUsage.is_active:
            return

        win = self.window
        view = win.active_view()
        self.has_errors = False
        self.has_pos_errors = False
        self.view = view
        self.hx_files = None
        self.is_cancelled = False

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.context = get_context(view)
        word = self.context.word
        self.word = word

        if not word:
            return

        HaxeUsage.is_active = True
        self.type_map = HaxeOrganizeImports.get_type_map(self.view)
        self.usages = []
        self.src_wo_comments = remove_comments(self.context.src)
        self.package = parse_package(self.src_wo_comments)

        # print('HU: ---------------------------------------')
        # print('HU:', word.name)

        self.root_dir = get_root_dir(self.view.file_name(), self.package)
        self.result_base_dir = os.path.abspath(
            os.path.join(self.root_dir, os.pardir))
        # print('HU root:', self.root_dir)

        if is_type(word.name, self.type_map):
            self.find_type_usages()
        else:
            self.find_local_or_field_usages()
    def run(self, edit, cname=None, package=None):
        view = self.view

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        src = view.substr(sublime.Region(0, self.view.size()))

        if cname is not None:
            mo = re_type.search(src)
            view.replace(edit, sublime.Region(mo.start(2), mo.end(2)), cname)
            sublime.status_message('%s %s renamed to %s' %
                                   (mo.group(1), mo.group(2), cname))

        if package is not None:
            mo = re_package.search(src)
            if mo:
                view.replace(edit, sublime.Region(mo.start(0), mo.end(0)),
                             gen_package_decl(package))
            else:
                view.insert(edit, 0, gen_package_decl(package) + '\n')
            sublime.status_message('package renamed')
    def run(self, edit, cname=None, package=None):
        view = self.view

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        src = view.substr(sublime.Region(0, self.view.size()))

        if cname is not None:
            mo = re_type.search(src)
            view.replace(edit, sublime.Region(mo.start(2), mo.end(2)), cname)
            sublime.status_message(
                '%s %s renamed to %s' % (mo.group(1), mo.group(2), cname))

        if package is not None:
            mo = re_package.search(src)
            if mo:
                view.replace(
                    edit, sublime.Region(mo.start(0), mo.end(0)),
                    gen_package_decl(package))
            else:
                view.insert(edit, 0, gen_package_decl(package) + '\n')
            sublime.status_message('package renamed')