void wxCrafterCBSettings::FromJSON(const JSONElement& json)
{
    m_wxcPath = json.namedObject(wxT("m_wxcPath")).toString(m_wxcPath);
    
    // Read the settings dialog size and pos
    wxPoint settingsDlgPt  ( wxDefaultPosition );
    wxSize  settingsDlgSize( wxDefaultSize     );
    
    if ( json.hasNamedObject(wxT("m_settingsDialogRect.size")) && json.hasNamedObject(wxT("m_settingsDialogRect.point")) ) {
        settingsDlgSize = json.namedObject(wxT("m_settingsDialogRect.size")).toSize();
        settingsDlgPt   = json.namedObject(wxT("m_settingsDialogRect.point")).toPoint();
        m_settingsDialogRect = wxRect(settingsDlgPt, settingsDlgSize);
    }
}
Example #2
0
void FindReplaceData::FromJSON(const JSONElement& json)
{
    m_findString = json.namedObject("m_findString").toArrayString();
    m_replaceString = json.namedObject("m_replaceString").toArrayString();
    m_flags = json.namedObject("m_flags").toSize_t(m_flags);

    if(json.hasNamedObject("m_lookIn")) {
        m_searchPaths = json.namedObject("m_lookIn").toArrayString();
    } else {
        m_searchPaths.Add(SEARCH_IN_WORKSPACE_FOLDER);
    }

    m_encoding = json.namedObject("m_encoding").toString(m_encoding);
    m_fileMask = json.namedObject("m_fileMask").toArrayString();
    m_selectedMask = json.namedObject("m_selectedMask").toString(m_selectedMask);

    long max_value = clConfig::Get().Read(kConfigMaxItemsInFindReplaceDialog, 15);

    TruncateArray(m_searchPaths, (size_t)max_value);
    TruncateArray(m_replaceString, (size_t)max_value);
    TruncateArray(m_findString, (size_t)max_value);

    if(m_fileMask.IsEmpty()) {
        m_fileMask.Add("*.c;*.cpp;*.cxx;*.cc;*.h;*.hpp;*.inc;*.mm;*.m;*.xrc");
        m_selectedMask = m_fileMask.Item(0);
    }
}
Example #3
0
void NodeJSSocket::ProcessInputBuffer()
{
    if(m_firstTimeConnected) {
        m_firstTimeConnected = false;
        // Apply breakpoints
        m_debugger->SetBreakpoints();
        // When an uncaught exception is thrown, break
        m_debugger->BreakOnException();
        m_inBuffer.Clear();
        // Let codelite know that we have control
        m_debugger->GotControl(true);
    } else {

        wxString buffer = GetResponse();
        while(!buffer.IsEmpty()) {
            JSONRoot root(buffer);
            JSONElement json = root.toElement();
            int reqSeq = json.namedObject("request_seq").toInt();
            if(reqSeq != wxNOT_FOUND) {
                std::map<size_t, NodeJSHandlerBase::Ptr_t>::iterator iter = m_handlers.find((size_t)reqSeq);
                if(iter != m_handlers.end()) {
                    NodeJSHandlerBase::Ptr_t handler = iter->second;
                    handler->Process(m_debugger, buffer);
                    m_handlers.erase(iter);
                }

                if(json.hasNamedObject("running") && !json.namedObject("running").toBool()) {
                    wxString responseCommand = json.namedObject("command").toString();
                    m_debugger->GotControl((m_noBacktraceCommands.count(responseCommand) == 0));
                } else {
                    m_debugger->SetCanInteract(false);
                }
            } else {

                // Notify the debugger that we got control
                if((json.namedObject("type").toString() == "event")) {
                    if(json.namedObject("event").toString() == "break") {
                        // breakpoint hit, notify we got control + request for backtrace
                        m_debugger->GotControl(true);
                    } else if(json.namedObject("event").toString() == "exception") {
                        
                        JSONElement body = json.namedObject("body");
                        NodeJSDebuggerException exc;
                        exc.message =  body.namedObject("exception").namedObject("text").toString();;
                        exc.line = body.namedObject("sourceLine").toInt();
                        exc.script = body.namedObject("script").namedObject("name").toString();
                        exc.column = body.namedObject("sourceColumn").toInt();
                        
                        // the vm execution stopped due to an exception
                        m_debugger->ExceptionThrown(exc);
                    }
                } else {
                    m_debugger->SetCanInteract(false);
                }
            }
            // Check to see if we got more reponses in the in-buffer
            buffer = GetResponse();
        }
    }
}
void LexerConf::FromJSON(const JSONElement& json)
{
    m_name = json.namedObject("Name").toString();
    m_lexerId = json.namedObject("Id").toInt();
    m_themeName = json.namedObject("Theme").toString();
    if(json.hasNamedObject("Flags")) {
        m_flags = json.namedObject("Flags").toSize_t();
    } else {
        SetIsActive(json.namedObject("IsActive").toBool());
        SetUseCustomTextSelectionFgColour(json.namedObject("UseCustomTextSelFgColour").toBool());
        SetStyleWithinPreProcessor(json.namedObject("StylingWithinPreProcessor").toBool());
    }
    SetKeyWords(json.namedObject("KeyWords0").toString(), 0);
    SetKeyWords(json.namedObject("KeyWords1").toString(), 1);
    SetKeyWords(json.namedObject("KeyWords2").toString(), 2);
    SetKeyWords(json.namedObject("KeyWords3").toString(), 3);
    SetKeyWords(json.namedObject("KeyWords4").toString(), 4);
    SetFileSpec(json.namedObject("Extensions").toString());

    m_properties.clear();
    JSONElement properties = json.namedObject("Properties");
    int arrSize = properties.arraySize();
    for(int i = 0; i < arrSize; ++i) {
        // Construct a style property
        StyleProperty p;
        p.FromJSON(properties.arrayItem(i));
        m_properties.insert(std::make_pair(p.GetId(), p));
    }
}
Example #5
0
void PHPWorkspace::FromJSON(const JSONElement& e)
{
    m_projects.clear();
    if(e.hasNamedObject("projects")) {
        PHPProject::Ptr_t firstProject;
        JSONElement projects = e.namedObject("projects");
        int count = projects.arraySize();
        for(int i = 0; i < count; ++i) {
            PHPProject::Ptr_t p(new PHPProject());
            wxString project_file = projects.arrayItem(i).toString();
            wxFileName fnProject(project_file);
            fnProject.MakeAbsolute(m_workspaceFile.GetPath());
            p->Load(fnProject);
            m_projects.insert(std::make_pair(p->GetName(), p));
            if(!firstProject) {
                firstProject = p;
            }
        }

        PHPProject::Ptr_t activeProject = GetActiveProject();
        if(!activeProject && firstProject) {
            // No active project found, mark the first project as active
            activeProject = firstProject;
            SetProjectActive(firstProject->GetName());
        }

        if(activeProject) {
            // Notify about active project been set
            clProjectSettingsEvent evt(wxEVT_ACTIVE_PROJECT_CHANGED);
            evt.SetProjectName(activeProject->GetName());
            evt.SetFileName(activeProject->GetFilename().GetFullPath());
            EventNotifier::Get()->AddPendingEvent(evt);
        }
    }
}
Example #6
0
bool clTernServer::ProcessDefinitionOutput(const wxString& output, clTernDefinition& loc)
{
    JSONRoot root(output);
    JSONElement json = root.toElement();

    if(json.hasNamedObject("file")) {
        wxFileName fn(json.namedObject("file").toString());
        if(!m_workingDirectory.IsEmpty()) {
            fn.MakeAbsolute(m_workingDirectory);
        }
        loc.file = fn.GetFullPath();
        loc.start = json.namedObject("start").toInt();
        loc.end = json.namedObject("end").toInt();
        return true;

    } else if(json.hasNamedObject("url")) {
        loc.url = json.namedObject("url").toString();
        return true;
    }
    return false;
}
void CompilationDatabase::ProcessCMakeCompilationDatabase(const wxFileName& compile_commands)
{
    JSONRoot root(compile_commands);
    JSONElement arr = root.toElement();

    try {

        wxString sql;
        sql = wxT("REPLACE INTO COMPILATION_TABLE (FILE_NAME, FILE_PATH, CWD, COMPILE_FLAGS) VALUES(?, ?, ?, ?)");
        wxSQLite3Statement st = m_db->PrepareStatement(sql);
        m_db->ExecuteUpdate("BEGIN");

        for(int i = 0; i < arr.arraySize(); ++i) {
            // Each object has 3 properties:
            // directory, command, file
            JSONElement element = arr.arrayItem(i);
            if(element.hasNamedObject("file") && element.hasNamedObject("directory") &&
               element.hasNamedObject("command")) {
                wxString cmd = element.namedObject("command").toString();
                wxString file = element.namedObject("file").toString();
                wxString path = wxFileName(file).GetPath();
                wxString cwd = element.namedObject("directory").toString();

                cwd = wxFileName(cwd, "").GetPath();
                file = wxFileName(file).GetFullPath();

                st.Bind(1, file);
                st.Bind(2, path);
                st.Bind(3, cwd);
                st.Bind(4, cmd);
                st.ExecuteUpdate();
            }
        }

        m_db->ExecuteUpdate("COMMIT");

    } catch(wxSQLite3Exception& e) {
        wxUnusedVar(e);
    }
}
void PHPConfigurationData::FromJSON(const JSONElement &json)
{
    m_includePaths = json.namedObject("m_includePaths").toArrayString();
    m_phpExe = json.namedObject("m_phpExe").toString("php");
    m_errorReporting = json.namedObject("m_errorReporting").toString("E_ALL & ~E_NOTICE");
    m_xdebugPort = json.namedObject("m_xdebugPort").toInt(9000);
    m_xdebugHost = json.namedObject("m_xdebugHost").toString("127.0.0.1");
    m_flags = json.namedObject("m_flags").toSize_t(m_flags);
    m_xdebugIdeKey = json.namedObject("m_xdebugIdeKey").toString("codeliteide");
    m_xdebugIdeKey.Trim().Trim(false);
    
    // xdebug IDE can not be an empty string, or else debugging in command line 
    // will not work
    if(m_xdebugIdeKey.IsEmpty()) {
        m_xdebugIdeKey = "codeliteide";
    }
    
    bool nodeExists = json.hasNamedObject("m_ccIncludePath");
    m_ccIncludePath = json.namedObject("m_ccIncludePath").toArrayString();
    
    if ( !nodeExists && m_ccIncludePath.IsEmpty() ) {
        m_ccIncludePath.Add( ::GetCCResourceDirectory() );
    }
}