コード例 #1
0
ファイル: rpc.py プロジェクト: rocknrollMarc/Sublime-Text-2
 def unparse(self):
     return [[
         key(":type"),
         sym("field"),
         key(":object-id"), self.object_id,
         key(":field"), self.field
     ]]
コード例 #2
0
ファイル: rpc.py プロジェクト: rocknrollMarc/Sublime-Text-2
def _mk_req(func, *args, **kwargs):
    if kwargs: raise Exception("kwargs are not supported by the RPC proxy")
    req = []

    def translate_name(name):
        if name.startswith("_"): name = name[1:]
        name = name.replace("_", "-")
        return name

    req.append(sym("swank:" + translate_name(func.__name__)))
    (spec_args, spec_varargs, spec_keywords,
     spec_defaults) = inspect.getargspec(func)
    if spec_varargs: raise Exception("varargs in signature of " + str(func))
    if spec_keywords: raise Exception("keywords in signature of " + str(func))
    if len(spec_args) != len(args):
        if len(args) < len(spec_args) and len(args) + len(
                spec_defaults) >= len(spec_args):
            # everything's fine. we can use default values for parameters to provide arguments to the call
            args += spec_defaults[len(spec_defaults) - len(spec_args) +
                                  len(args):]
        else:
            preamble = "argc mismatch in signature of " + str(func) + ": "
            expected = "expected " + str(
                len(spec_args)) + " args " + str(spec_args) + ", "
            actual = "actual " + str(
                len(args)) + " args " + str(args) + " with types " + str(
                    map(lambda a: type(a), args))
            raise Exception(preamble + expected + actual)
    for arg in args[1:]:  # strip off self
        if hasattr(arg, "unparse"): argreq = arg.unparse()
        else: argreq = [arg]
        req.extend(argreq)
    return req
コード例 #3
0
ファイル: rpc.py プロジェクト: adilakhter/ensime-sublime
def _mk_req(func, *args, **kwargs):
    if kwargs: raise Exception("kwargs are not supported by the RPC proxy")
    req = []

    def translate_name(name):
        if name.startswith("_"): name = name[1:]
        name = name.replace("_", "-")
        return name

    req.append(sym("swank:" + translate_name(func.__name__)))
    (spec_args, spec_varargs, spec_keywords, spec_defaults) = inspect.getargspec(func)
    if spec_varargs: raise Exception("varargs in signature of " + str(func))
    if spec_keywords: raise Exception("keywords in signature of " + str(func))
    if len(spec_args) != len(args):
        if len(args) < len(spec_args) and len(args) + len(spec_defaults) >= len(spec_args):
            # everything is fine. we can use default values for parameters to provide arguments to the call
            args += spec_defaults[len(spec_defaults) - len(spec_args) + len(args):]
        else:
            preamble = "argc mismatch in signature of " + str(func) + ": "
            expected = "expected " + str(len(spec_args)) + " args " + str(spec_args) + ", "
            actual = "actual " + str(len(args)) + " args " + str(args) + " with types " + str(
                map(lambda a: type(a), args))
            raise Exception(preamble + expected + actual)
    for arg in args[1:]:  # strip off self
        if hasattr(arg, "unparse"):
            argreq = arg.unparse()
        else:
            argreq = [arg]
        req.extend(argreq)
    return req
コード例 #4
0
ファイル: rpc.py プロジェクト: rocknrollMarc/Sublime-Text-2
 def unparse(self):
     return [[
         key(":type"),
         sym("element"),
         key(":object-id"), self.object_id,
         key(":index"), self.index
     ]]
コード例 #5
0
def _mk_req(func, *args, **kwargs):
    if kwargs: raise Exception("kwargs are not supported for " + str(func))
    req = []

    def translate_name(name):
        if name.startswith("_"): name = name[1:]
        name = name.replace("_", "-")
        return name

    req.append(sym("swank:" + translate_name(func.__name__)))
    (spec_args, spec_varargs, spec_keywords,
     spec_defaults) = inspect.getargspec(func)
    if len(spec_args) != len(args):
        preamble = "argc mismatch in signature of " + str(func) + ": "
        expected = "expected " + str(
            len(spec_args)) + " args " + str(spec_args) + ", "
        actual = "actual " + str(
            len(args)) + " args " + str(args) + " with types " + str(
                map(lambda a: type(a), args))
        raise Exception(preamble + expected + actual)
    if spec_varargs: raise Exception("varargs in signature of " + str(func))
    if spec_keywords: raise Exception("keywords in signature of " + str(func))
    if spec_defaults: raise Exception("defaults in signature of " + str(func))
    req.extend(args[1:])  # strip off self
    return req
コード例 #6
0
    def run(self, encoding="utf-8", env={}, start=False, quiet=True, kill=False, show_output=True):
        print "Running: " + self.__class__.__name__
        self.show_output = show_output
        if not hasattr(self, "settings"):
            self.settings = sublime.load_settings("Ensime.sublime-settings")

        server_dir = self.settings.get("ensime_server_path", self.default_ensime_install_path())
        server_path = server_dir if server_dir.startswith("/") else os.path.join(sublime.packages_path(), server_dir)

        if kill:
            ensime_environment.ensime_env.client().sync_req([sym("swank:shutdown-server")])
            ensime_environment.ensime_env.client().disconnect()
            if self.proc:
                self.proc.kill()
                self.proc = None
                self.append_data(None, "[Cancelled]")
            return
        else:
            if self.is_started():
                self.show_output_window(show_output)
                if start and not self.quiet:
                    print "Ensime server is already running!"
                return

        if not hasattr(self, "output_view"):
            self.output_view = self.window.get_output_panel("ensime_server")

        self.quiet = quiet

        self.proc = None
        if not self.quiet:
            print "Starting Ensime Server."

        if show_output:
            self.show_output_window(show_output)

        # Change to the working dir, rather than spawning the process with it,
        # so that emitted working dir relative path names make sense
        if self.ensime_project_root() and self.ensime_project_root() != "":
            os.chdir(self.ensime_project_root())

        err_type = OSError
        if os.name == "nt":
            err_type = WindowsError

        try:
            self.show_output = show_output
            if start:
                cl = EnsimeClient(ensime_environment.ensime_env.settings, self.window, self.ensime_project_root())
                sublime.set_timeout(functools.partial(ensime_environment.ensime_env.set_client, cl), 0)
                vw = self.window.active_view()
                self.proc = AsyncProcess(
                    [server_path + "/" + self.ensime_command(), self.ensime_project_root() + "/.ensime_port"],
                    self,
                    server_path,
                )
        except err_type as e:
            print str(e)
            self.append_data(None, str(e) + "\n")
コード例 #7
0
ファイル: rpc.py プロジェクト: rocknrollMarc/Sublime-Text-2
 def unparse(self):
     return [[
         key(":type"),
         sym("slot"),
         key(":thread-id"), self.thread_id,
         key(":frame"), self.frame,
         key(":offset"), self.offset
     ]]
コード例 #8
0
ファイル: rpc.py プロジェクト: corelon/sublime-ensime
def _mk_req(func, *args, **kwargs):
  if kwargs: raise Exception("kwargs are not supported for " + str(func))
  req = []
  def translate_name(name):
    if name.startswith("_"): name = name[1:]
    name = name.replace("_", "-")
    return name
  req.append(sym("swank:" + translate_name(func.__name__)))
  (spec_args, spec_varargs, spec_keywords, spec_defaults) = inspect.getargspec(func)
  if len(spec_args) != len(args):
    preamble = "argc mismatch in signature of " + str(func) + ": "
    expected = "expected " + str(len(spec_args)) + " args " + str(spec_args) + ", "
    actual = "actual " + str(len(args)) + " args " + str(args) + " with types " + str(map(lambda a: type(a), args))
    raise Exception(preamble + expected + actual)
  if spec_varargs: raise Exception("varargs in signature of " + str(func))
  if spec_keywords: raise Exception("keywords in signature of " + str(func))
  if spec_defaults: raise Exception("defaults in signature of " + str(func))
  req.extend(args[1:]) # strip off self
  return req
コード例 #9
0
ファイル: project.py プロジェクト: aemoncannon/clime
 def receive_syntax_checker_output(self, req, clang_output):
     for line in clang_output:
         m = self.RE_ITEM.match(line)
         if m:
             print line
             sys.stdout.flush()
             filename = m.group(1)
             line = int(m.group(2))
             col = int(m.group(3))
             item_type = m.group(4)
             msg = m.group(5)
             util.send_sexp(
                 req,
                 [key(":notes"), 
                  [key(":notes"),
                   [[key(":file"), filename,
                     key(":line"), line,
                     key(":col"), col,
                     key(":beg"), False,
                     key(":end"), False,
                     key(":severity"), sym(self.SEVERITY_MAP[item_type]),
                     key(":msg"), msg
                     ]]]])
コード例 #10
0
 def format_source(self, file_path, on_complete):
   self.req([sym("swank:format-source"),[file_path]], on_complete)
コード例 #11
0
 def type_check_all(self, on_complete):
   self.req([sym("swank:typecheck-all")], on_complete)
コード例 #12
0
 def perform_organize(self, previous_id, msg_id, on_complete):
     self.req([
         sym("swank:exec-refactor"),
         int(previous_id),
         sym("organizeImports")
     ], on_complete, int(msg_id))
コード例 #13
0
 def __initialize_project(self, conf, subproj_name, on_complete):
   conf = conf + [key(":root-dir"), self.project_root]
   conf = conf + [key(":active-subproject"), subproj_name]
   self.req([sym("swank:init-project"), conf], on_complete)
コード例 #14
0
 def complete_member(self, file_path, position):
   return self.sync_req([sym("swank:completions"), file_path, position, 0])
コード例 #15
0
 def handshake(self, on_complete):
     self.req([sym("swank:connection-info")], on_complete)
コード例 #16
0
 def type_check_all(self, on_complete):
     self.req([sym("swank:typecheck-all")], on_complete)
コード例 #17
0
 def perform_organize(self, previous_id, msg_id, on_complete):
   self.req([sym("swank:exec-refactor"),
             int(previous_id), 
             sym("organizeImports")], 
            on_complete, int(msg_id))
コード例 #18
0
 def type_check_file(self, file_path, on_complete):
     self.req([sym("swank:typecheck-file"), file_path], on_complete)
コード例 #19
0
ファイル: rpc.py プロジェクト: adilakhter/ensime-sublime
 def unparse(self):
     return [[key(":type"), sym("reference"), key(":object-id"), self.object_id]]
コード例 #20
0
    def run(self,
            encoding="utf-8",
            env={},
            start=False,
            quiet=True,
            kill=False,
            show_output=True):
        print "Running: " + self.__class__.__name__
        self.show_output = show_output
        if not hasattr(self, 'settings'):
            self.settings = sublime.load_settings("Ensime.sublime-settings")

        server_dir = self.settings.get("ensime_server_path",
                                       self.default_ensime_install_path())
        server_path = server_dir if server_dir.startswith(
            "/") else os.path.join(sublime.packages_path(), server_dir)

        if kill:
            ensime_environment.ensime_env.client().sync_req(
                [sym("swank:shutdown-server")])
            ensime_environment.ensime_env.client().disconnect()
            if self.proc:
                self.proc.kill()
                self.proc = None
                self.append_data(None, "[Cancelled]")
            return
        else:
            if self.is_started():
                self.show_output_window(show_output)
                if start and not self.quiet:
                    print "Ensime server is already running!"
                return

        if not hasattr(self, 'output_view'):
            self.output_view = self.window.get_output_panel("ensime_server")

        self.quiet = quiet

        self.proc = None
        if not self.quiet:
            print "Starting Ensime Server."

        if show_output:
            self.show_output_window(show_output)

        # Change to the working dir, rather than spawning the process with it,
        # so that emitted working dir relative path names make sense
        if self.ensime_project_root() and self.ensime_project_root() != "":
            os.chdir(self.ensime_project_root())

        err_type = OSError
        if os.name == "nt":
            err_type = WindowsError

        try:
            self.show_output = show_output
            if start:
                cl = EnsimeClient(ensime_environment.ensime_env.settings,
                                  self.window, self.ensime_project_root())
                sublime.set_timeout(
                    functools.partial(ensime_environment.ensime_env.set_client,
                                      cl), 0)
                vw = self.window.active_view()
                self.proc = AsyncProcess([
                    server_path + '/' + self.ensime_command(),
                    self.ensime_project_root() + "/.ensime_port"
                ], self, server_path)
        except err_type as e:
            print str(e)
            self.append_data(None, str(e) + '\n')
コード例 #21
0
 def complete_member(self, file_path, position):
     return self.sync_req(
         [sym("swank:completions"), file_path, position, 0])
コード例 #22
0
 def inspect_type_at_point(self, file_path, position, on_complete):
     self.req([sym("swank:type-at-point"), file_path,
               int(position)], on_complete)
コード例 #23
0
 def type_check_file(self, file_path, on_complete):
   self.req([sym("swank:typecheck-file"), file_path], on_complete)
コード例 #24
0
 def format_source(self, file_path, on_complete):
     self.req([sym("swank:format-source"), [file_path]], on_complete)
コード例 #25
0
 def organize_imports(self, file_path, on_complete):
   self.req([sym("swank:exec-refactor"),
             self.next_procedure_id(),
             sym("organizeImports"), 
             [sym("file"),file_path], 
             True], on_complete)
コード例 #26
0
ファイル: rpc.py プロジェクト: adilakhter/ensime-sublime
 def unparse(self):
     return [
         [key(":type"), sym("slot"), key(":thread-id"), self.thread_id, key(":frame"), self.frame, key(":offset"),
          self.offset]]
コード例 #27
0
 def inspect_type_at_point(self, file_path, position, on_complete):
   self.req([sym("swank:type-at-point"),
             file_path,
             int(position)], 
            on_complete)
コード例 #28
0
 def __initialize_project(self, conf, subproj_name, on_complete):
     conf = conf + [key(":root-dir"), self.project_root]
     conf = conf + [key(":active-subproject"), subproj_name]
     self.req([sym("swank:init-project"), conf], on_complete)
コード例 #29
0
ファイル: rpc.py プロジェクト: rocknrollMarc/Sublime-Text-2
 def unparse(self):
     return [[
         key(":type"),
         sym("reference"),
         key(":object-id"), self.object_id
     ]]
コード例 #30
0
 def handshake(self, on_complete): 
   self.req([sym("swank:connection-info")], on_complete)
コード例 #31
0
ファイル: rpc.py プロジェクト: adilakhter/ensime-sublime
 def unparse(self):
     return [[key(":type"), sym("element"), key(":object-id"), self.object_id, key(":index"), self.index]]
コード例 #32
0
 def organize_imports(self, file_path, on_complete):
     self.req([
         sym("swank:exec-refactor"),
         self.next_procedure_id(),
         sym("organizeImports"), [sym("file"), file_path], True
     ], on_complete)
コード例 #33
0
ファイル: rpc.py プロジェクト: adilakhter/ensime-sublime
 def unparse(self):
     return [[key(":type"), sym("field"), key(":object-id"), self.object_id, key(":field"), self.field]]
コード例 #34
0
 def complete_member(self, file_path, position, max_results=0,case_sense=False,reload=False):
   return self.sync_req([sym("swank:completions"), file_path, position, max_results, case_sense, reload])