File: NodeJSGetScriptHandler.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (40 lines) | stat: -rw-r--r-- 1,363 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "NodeJSGetScriptHandler.h"
#include "fileutils.h"
#include <wx/filename.h>
#include "json_node.h"
#include "cl_standard_paths.h"
#include "cl_command_event.h"
#include "event_notifier.h"
#include "NodeJSEvents.h"
#include "NodeJSDebugger.h"
#include "file_logger.h"

NodeJSGetScriptHandler::NodeJSGetScriptHandler(const wxString& filename, int line)
    : m_filename(filename)
    , m_line(line)
{
}

NodeJSGetScriptHandler::~NodeJSGetScriptHandler()
{
}

void NodeJSGetScriptHandler::Process(NodeJSDebugger* debugger, const wxString& output)
{
    JSONRoot root(output);
    wxString sourceFile = root.toElement().namedObject("body").namedObject("source").toString();
    if(!sourceFile.IsEmpty()) {
        wxFileName fn(clStandardPaths::Get().GetUserDataDir(), m_filename);
        fn.AppendDir("webtools");
        fn.AppendDir("tmp");
        fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
        if(FileUtils::WriteFileContent(fn, sourceFile)) {
            CL_DEBUG("Calling marking line for %s:%d", fn.GetFullPath(), m_line);
            debugger->AddTempFile(fn.GetFullPath());
            clDebugEvent eventHighlight(wxEVT_NODEJS_DEBUGGER_MARK_LINE);
            eventHighlight.SetLineNumber(m_line);
            eventHighlight.SetFileName(fn.GetFullPath());
            EventNotifier::Get()->AddPendingEvent(eventHighlight);
        }
    }
}