def run( self ) : log("run HaxeRestartServerCommand") view = sublime.active_window().active_view() project = hxproject.current_project(view) project.server.stop() project.start_server( view )
def run( self , edit ) : view = self.view log("run HaxeRunBuildCommand") project = hxproject.current_project(self.view) if len(project.builds) == 0: log("no builds available") project.extract_build_args(view, True); else: project.run_sublime_build( view )
def on_post_save(self, view): log("on_post_save") if view is not None and view.file_name() is not None: if view_tools.is_supported(view) or view.file_name().endswith(".erazor.html"): if (hxsettings.build_on_save()): project = hxproject.current_project(view) if len(project.builds) > 0: project.run_sublime_build( view ) else: project.extract_build_args(view, False) build = project.get_build(view) if (build != None): project.run_sublime_build( view )
def run( self , edit ) : log("run HaxeDisplayMacroCompletion") view = self.view project = hxproject.current_project(view) project.completion_context.set_manual_trigger(view, True) view.run_command( "auto_complete" , { "api_completions_only" : True, "disable_auto_insert" : True, "next_completion_if_showing" : True, 'auto_complete_commit_on_tab': True } )
def run( self , paths = [] , t = "class" ) : log("createtype") win = self.win view = win.active_view() project = hxproject.current_project(view) builds = project.builds #scopes = view.scope_name(view.sel()[0].end()).split() pack = []; if len(builds) == 0 and view != None and view.file_name() != None: print view.file_name() project.extract_build_args(view) builds = project.builds if len(paths) == 0 and view != None: fn = view.file_name() paths.append(fn) for path in paths : if os.path.isfile( path ) : path = os.path.dirname( path ) if self.classpath is None : self.classpath = path for b in builds : found = False for cp in b.classpaths : if path.startswith( cp ) : self.classpath = path[0:len(cp)] for p in path[len(cp):].split(os.sep) : if "." in p : break elif p : pack.append(p) found = True if found: break if found: break if found: break if self.classpath is None : if len(builds) > 0 : self.classpath = builds[0].classpaths[0] # so default text ends with . if len(pack) > 0 : pack.append("") sublime.status_message( "Current classpath : " + self.classpath ) win.show_input_panel("Enter "+t+" name : " , ".".join(pack) , lambda inp: self.on_done(inp, t) , self.on_change , self.on_cancel )
def run1 (self, use_display, inline_workaround = False): print "run HaxeFindDeclarationCommand" view = self.view file_name = view.file_name() if file_name == None: return project = hxproject.current_project(view) build = project.get_build(view).copy() build.args.append(("-D", "no-inline")) src = view_tools.get_content(view) file_name = os.path.basename(view.file_name()) using_line = "\nusing hxsublime.FindDeclaration;\n" pos = view.sel()[0].a word = view.word(pos) word_start = word.a word_end = word.b word_str = src[word_start:word_end] prev = src[word_start-1] field_access = False if prev == ".": field_access = True add = ".sublime_find_decl()" if use_display: add += ".|" start = src[0:word_start] end = src[word_end:] if inline_workaround: add_x = "sublime_find_decl" add_y = "" if use_display: add_y = ".|" new_src = start + add_x + "(" + word_str + ")" + add_y + end; else: new_src = start + word_str + add + end; package_decl = re.search(hxsrctools.package_line, new_src) if (package_decl == None): new_src = using_line + new_src else: new_src = new_src[0:package_decl.end(0)]+using_line+new_src[package_decl.end(0):len(new_src)] temp_path, temp_file = hxtemp.create_temp_path_and_file(build, view.file_name(), new_src) build.add_classpath(temp_path) build.add_classpath(plugin_path) if use_display: build.set_auto_completion(temp_file + "@0", False, False) server_mode = project.is_server_mode() out, err = build.run(project.haxe_exec(), project.haxe_env(), server_mode, view, project) hxtemp.remove_path(temp_path) file_pos = re.compile("\|\|\|\|\|([^|]+)\|\|\|\|\|", re.I) res = re.search(file_pos, out) if res != None: #we've got a proper response json_str = res.group(1) json_res = json.loads(json_str) self.handle_json_response(json_res, add, using_line, word_end, build, temp_path, temp_file, use_display, inline_workaround) else: if use_display: log("nothing found yet (2), try again without display (workaround)") self.run1(False) else: log("nothing found (3), cannot find declaration")
def run( self , edit ) : log("run HaxeSelectBuildCommand") view = self.view hxproject.current_project(self.view).select_build( view )
def run( self , edit ) : log("run HaxeSaveAllAndBuildCommand") view = self.view view.window().run_command("save_all") hxproject.current_project(self.view).run_sublime_build( view )
def on_query_completions(self, view, prefix, locations): log("on_query_completions triggered") project = hxproject.current_project(view) return auto_complete(project, view, prefix, locations)
def on_activated( self , view ) : if view is not None and view.file_name() is not None and view_tools.is_supported(view): project = hxproject.current_project(view)
def on_post_save( self , view ) : if view is not None and view.file_name() is not None and view_tools.is_hxml(view): project = hxproject.current_project(view) project.clear_build()
def on_load( self, view ) : if view is not None and view.file_name() is not None and view_tools.is_supported(view): if not hxproject.current_project(view).has_build(): hxproject.current_project(view).generate_build( view )