From 6a3913cd07858879bc9577ec52d6b21cabfc5ec7 Mon Sep 17 00:00:00 2001 From: Andrey Tarantsov Date: Tue, 23 Oct 2012 22:31:03 +0700 Subject: [PATCH] Report action.start, action.finish --- lib/plugins/compilation.iced | 5 ++++- lib/plugins/postproc.iced | 5 ++++- lib/plugins/refresh.iced | 5 +++++ lib/projects/analyzer.iced | 3 +++ lib/projects/project.iced | 10 ++++++++++ lib/session.iced | 4 ++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/plugins/compilation.iced b/lib/plugins/compilation.iced index 4aa9eee0f..33225f6e9 100644 --- a/lib/plugins/compilation.iced +++ b/lib/plugins/compilation.iced @@ -99,9 +99,12 @@ class CompilationStep '$(additional)': [] + action = { id: 'compile', message: "Compiling #{srcInfo.file}" } invocation = compiler.tool.createInvocation(info) - invocation.once 'finished', -> + @project.reportActionStart(action) + invocation.once 'finished', => + @project.reportActionFinish(action) callback(dstRelPath) invocation.run() diff --git a/lib/plugins/postproc.iced b/lib/plugins/postproc.iced index 389d8bbac..89289d601 100644 --- a/lib/plugins/postproc.iced +++ b/lib/plugins/postproc.iced @@ -69,6 +69,9 @@ class PostProcStep '$(projectDir)': @project.fullPath invocation = tool.createInvocation(info) - invocation.once 'finished', -> + action = { id: 'postproc', message: "Running #{@project.postprocCommand}" } + @project.reportActionStart(action) + invocation.once 'finished', => + @project.reportActionFinish(action) callback(null) invocation.run() diff --git a/lib/plugins/refresh.iced b/lib/plugins/refresh.iced index 3f7da3949..8edc7f118 100644 --- a/lib/plugins/refresh.iced +++ b/lib/plugins/refresh.iced @@ -40,11 +40,15 @@ class RefreshStep _perform: (request, done) -> debug "Executing browser refresh job: " + JSON.stringify(request) + return done(null) if request.paths.length == 0 + # json_object_set_new(arg, "path", json_string(request->path)); # json_object_set_new(arg, "originalPath", json_string(request->original_path ?: "")); # json_object_set_new(arg, "liveCSS", !project.disableLiveRefresh ? json_true() : json_false()); # json_object_set_new(arg, "enableOverride", project.enableRemoteServerWorkflow ? json_true() : json_false()); # _fullPageReloadDelay!! + action = { id: 'refresh', message: "Refreshing browser" } + @project.reportActionStart(action) for path in request.paths command = command: 'reload' @@ -57,5 +61,6 @@ class RefreshStep # message.overrideURL = @urlOverrideCoordinator.createOverrideURL(path) @session.sendBrowserCommand command + @project.reportActionFinish(action) done(null) diff --git a/lib/projects/analyzer.iced b/lib/projects/analyzer.iced index 3d92f0e88..29f65310a 100644 --- a/lib/projects/analyzer.iced +++ b/lib/projects/analyzer.iced @@ -69,6 +69,9 @@ class Analyzer return callback() debug "#{analyzer}: analyzing #{relpath}" + action = { id: 'analyze', message: "Analyzing #{Path.basename(relpath)}"} + @project.reportActionStart(action) await analyzer.update relpath, fullPath, defer() + @project.reportActionFinish(action) callback() diff --git a/lib/projects/project.iced b/lib/projects/project.iced index bcc82084b..2f56d2897 100644 --- a/lib/projects/project.iced +++ b/lib/projects/project.iced @@ -202,6 +202,16 @@ class Project extends R.Model return run + reportActionStart: (action) -> + if !action.id + throw new Error("Invalid argument: action.id is required") + @emit 'action.start', action + + reportActionFinish: (action) -> + if !action.id + throw new Error("Invalid argument: action.id is required") + @emit 'action.finish', action + patchSourceFile: (oldCompiled, newCompiled, callback) -> oldLines = oldCompiled.trim().split("\n") newLines = newCompiled.trim().split("\n") diff --git a/lib/session.iced b/lib/session.iced index 3796b942c..3158b466c 100644 --- a/lib/session.iced +++ b/lib/session.iced @@ -103,6 +103,10 @@ class Session extends EventEmitter _addProject: (project) -> project.on 'change', (path) => @emit 'command', command: 'reload', path: path + project.on 'action.start', (action) => + @emit 'action.start', project, action + project.on 'action.finish', (action) => + @emit 'action.finish', project, action project.on 'run.start', (run) => @emit 'run.start', project, run project.on 'run.finish', (run) =>