JSONElement LLDBReply::ToJSON() const { JSONElement json = JSONElement::createObject(); json.addProperty("m_replyType", m_replyType); json.addProperty("m_stopResaon", m_interruptResaon); json.addProperty("m_line", m_line); json.addProperty("m_filename", m_filename); json.addProperty("m_lldbId", m_lldbId); json.addProperty("m_expression", m_expression); json.addProperty("m_debugSessionType", m_debugSessionType); json.addProperty("m_text", m_text); JSONElement bparr = JSONElement::createArray("m_breakpoints"); json.append(bparr); for(size_t i = 0; i < m_breakpoints.size(); ++i) { bparr.arrayAppend(m_breakpoints.at(i)->ToJSON()); } JSONElement localsArr = JSONElement::createArray("m_locals"); json.append(localsArr); for(size_t i = 0; i < m_variables.size(); ++i) { localsArr.arrayAppend(m_variables.at(i)->ToJSON()); } json.addProperty("m_backtrace", m_backtrace.ToJSON()); json.append(LLDBThread::ToJSON(m_threads, "m_threads")); return json; }
clKeyboardBindingConfig& clKeyboardBindingConfig::Save() { JSONRoot root(cJSON_Object); JSONElement mainObj = root.toElement(); JSONElement menuArr = JSONElement::createArray("menus"); mainObj.append(menuArr); for(MenuItemDataMap_t::iterator iter = m_bindings.begin(); iter != m_bindings.end(); ++iter) { JSONElement binding = JSONElement::createObject(); binding.addProperty("description", iter->second.action); binding.addProperty("accelerator", iter->second.accel); binding.addProperty("resourceID", iter->second.resourceID); binding.addProperty("parentMenu", iter->second.parentMenu); menuArr.arrayAppend(binding); } #if 0 JSONElement globalsArr = JSONElement::createArray("globals"); mainObj.append(globalsArr); for(MenuItemDataMap_t::iterator iter = m_globalBindings.begin(); iter != m_globalBindings.end(); ++iter) { JSONElement binding = JSONElement::createObject(); binding.addProperty("description", iter->second.action); binding.addProperty("accelerator", iter->second.accel); binding.addProperty("resourceID", iter->second.resourceID); binding.addProperty("parentMenu", iter->second.parentMenu); globalsArr.arrayAppend(binding); } #endif wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "keybindings.conf"); fn.AppendDir("config"); root.save(fn); return *this; }
wxString WebToolsConfig::GetTernProjectFile() const { JSONRoot root(cJSON_Object); JSONElement libs = JSONElement::createArray("libs"); root.toElement().append(libs); if(m_jsFlags & kJSLibraryBrowser) libs.arrayAppend("browser"); if(m_jsFlags & kJSLibraryChai) libs.arrayAppend("chai"); if(m_jsFlags & kJSLibraryEcma5) libs.arrayAppend("ecma5"); if(m_jsFlags & kJSLibraryEcma6) libs.arrayAppend("ecma6"); if(m_jsFlags & kJSLibraryJQuery) libs.arrayAppend("jquery"); if(m_jsFlags & kJSLibraryUnderscore) libs.arrayAppend("underscore"); JSONElement plugins = JSONElement::createObject("plugins"); root.toElement().append(plugins); if(m_jsFlags & kJSPluginNode) { JSONElement node = JSONElement::createObject("node"); plugins.append(node); } if(m_jsFlags & kJSPluginStrings) { JSONElement complete_strings = JSONElement::createObject("complete_strings"); plugins.append(complete_strings); } if(m_jsFlags & kJSPluginAngular) { JSONElement angular = JSONElement::createObject("angular"); plugins.append(angular); } return root.toElement().format(); }
JSONElement clTernServer::CreateFilesArray(IEditor* editor, bool forDelete) { const wxString fileContent = editor->GetCtrl()->GetText(); JSONElement files = JSONElement::createArray("files"); JSONElement file = JSONElement::createObject(); files.arrayAppend(file); wxString filename; if(!m_workingDirectory.IsEmpty()) { wxFileName fn(editor->GetFileName()); fn.MakeRelativeTo(m_workingDirectory); filename = fn.GetFullPath(); } else { filename = editor->GetFileName().GetFullName(); } if(forDelete) { file.addProperty("type", wxString("delete")); file.addProperty("name", filename); } else { file.addProperty("type", wxString("full")); file.addProperty("name", filename); file.addProperty("text", fileContent); } return files; }
JSONElement& JSONElement::addProperty(const wxString& name, const wxArrayString& arr) { JSONElement arrEle = JSONElement::createArray(name); for(size_t i = 0; i < arr.GetCount(); i++) { arrEle.arrayAppend(arr.Item(i)); } append(arrEle); return *this; }
void GitCommandsEntries::ToJSON(JSONElement& arr) const { JSONElement obj = JSONElement::createObject(); obj.addProperty("m_commandName", m_commandName); obj.addProperty("m_lastUsed", m_lastUsed); JSONElement commandsArr = JSONElement::createArray("m_commands"); obj.append(commandsArr); vGitLabelCommands_t::const_iterator iter = m_commands.begin(); for(; iter != m_commands.end(); ++iter) { JSONElement e = JSONElement::createObject(); e.addProperty("label", iter->label); e.addProperty("command", iter->command); commandsArr.arrayAppend(e); } arr.arrayAppend(obj); }
JSONElement PluginInfoArray::ToJSON() const { JSONElement el = JSONElement::createObject(GetName()); el.addProperty("disabledPlugins", m_disabledPlugins); JSONElement arr = JSONElement::createArray("installed-plugins"); PluginInfo::PluginMap_t::const_iterator iter = m_plugins.begin(); for( ; iter != m_plugins.end(); ++iter ) { arr.arrayAppend( iter->second.ToJSON() ); } el.append(arr); return el; }
JSONElement& JSONElement::addProperty(const wxString& name, const JSONElement::wxStringMap_t& stringMap) { if(!_json) return *this; JSONElement arr = JSONElement::createArray(name); JSONElement::wxStringMap_t::const_iterator iter = stringMap.begin(); for(; iter != stringMap.end(); ++iter) { JSONElement obj = JSONElement::createObject(); obj.addProperty("key", iter->first); obj.addProperty("value", iter->second); arr.arrayAppend(obj); } append(arr); return *this; }
JSONElement DbExplorerSettings::ToJSON() const { JSONElement element = JSONElement::createObject(GetName()); element.addProperty("m_recentFiles", m_recentFiles); element.addProperty("m_sqlHistory", m_sqlHistory); // add the connections array JSONElement arrConnections = JSONElement::createArray("connections"); element.append(arrConnections); DbConnectionInfoVec::const_iterator iter = m_connections.begin(); for(; iter != m_connections.end(); ++iter) { arrConnections.arrayAppend( iter->ToJSON() ); } return element; }
JSONElement PHPFolder::ToJSON() const { JSONElement json = JSONElement::createObject(""); json.addProperty("m_name", m_name); json.addProperty("m_files", m_files); JSONElement arr = JSONElement::createArray("children"); json.append(arr); PHPFolder::List_t::const_iterator iter = m_children.begin(); for(; iter != m_children.end(); ++iter) { arr.arrayAppend((*iter)->ToJSON()); } return json; }
JSONElement LLDBBreakpoint::ToJSON() const { JSONElement json = JSONElement::createObject(); json.addProperty("m_id", m_id); json.addProperty("m_type", m_type); json.addProperty("m_name", m_name); json.addProperty("m_filename", m_filename); json.addProperty("m_lineNumber", m_lineNumber); JSONElement arr = JSONElement::createArray("m_children"); json.append( arr ); for(size_t i=0; i<m_children.size(); ++i) { arr.arrayAppend( m_children.at(i)->ToJSON() ); } return json; }
void NodeJSDebugger::Lookup(const std::vector<int>& handles, eNodeJSContext context) { JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "lookup"); JSONElement args = JSONElement::createObject("arguments"); request.append(args); JSONElement arrHandles = JSONElement::createArray("handles"); args.append(arrHandles); for(size_t i = 0; i < handles.size(); ++i) { arrHandles.arrayAppend(JSONElement("", handles.at(i), cJSON_Number)); } // Write the command m_socket->WriteRequest(request, new NodeJSLookupHandler(context)); }
wxFileName CompilationDatabase::ConvertCodeLiteCompilationDatabaseToCMake(const wxFileName& compile_file) { wxFFile fp(compile_file.GetFullPath(), wxT("rb")); if( fp.IsOpened() ) { wxString content; fp.ReadAll(&content, wxConvUTF8); if( content.IsEmpty() ) return wxFileName(); JSONRoot root(cJSON_Array); JSONElement arr = root.toElement(); wxArrayString lines = ::wxStringTokenize(content, "\n\r", wxTOKEN_STRTOK); for(size_t i=0; i<lines.GetCount(); ++i) { wxArrayString parts = ::wxStringTokenize(lines.Item(i), wxT("|"), wxTOKEN_STRTOK); if( parts.GetCount() != 3 ) continue; wxString file_name = wxFileName(parts.Item(0).Trim().Trim(false)).GetFullPath(); wxString cwd = parts.Item(1).Trim().Trim(false); wxString cmp_flags = parts.Item(2).Trim().Trim(false); JSONElement element = JSONElement::createObject(); element.addProperty("directory", cwd); element.addProperty("command", cmp_flags); element.addProperty("file", file_name); arr.arrayAppend( element ); } wxFileName fn(compile_file.GetPath(), "compile_commands.json"); root.save( fn ); // Delete the old file { wxLogNull nl; fp.Close(); if ( compile_file.Exists() ) { ::wxRemoveFile( compile_file.GetFullPath() ); } } return fn; } return wxFileName(); }
void ColoursAndFontsManager::Save() { ColoursAndFontsManager::Map_t::const_iterator iter = m_lexersMap.begin(); JSONRoot root(cJSON_Array); JSONElement element = root.toElement(); for(; iter != m_lexersMap.end(); ++iter) { const ColoursAndFontsManager::Vec_t& lexers = iter->second; for(size_t i = 0; i < lexers.size(); ++i) { element.arrayAppend(lexers.at(i)->ToJSON()); } } wxFileName lexerFiles(clStandardPaths::Get().GetUserDataDir(), "lexers.json"); lexerFiles.AppendDir("lexers"); root.save(lexerFiles); SaveGlobalSettings(); clCommandEvent event(wxEVT_CMD_COLOURS_FONTS_UPDATED); EventNotifier::Get()->AddPendingEvent(event); }
JSONElement PHPWorkspace::ToJSON(JSONElement& e) const { JSONElement metadata = JSONElement::createObject("metadata"); e.append(metadata); metadata.addProperty("version", PHP_WORKSPACE_VERSION); metadata.addProperty("ide", PHP_WORKSPACE_IDE); metadata.addProperty("type", wxString("php")); // Store the list of files JSONElement projectsArr = JSONElement::createArray("projects"); e.append(projectsArr); PHPProject::Map_t::const_iterator iter = m_projects.begin(); for(; iter != m_projects.end(); ++iter) { wxFileName projectFile = iter->second->GetFilename(); projectFile.MakeRelativeTo(m_workspaceFile.GetPath()); projectsArr.arrayAppend(projectFile.GetFullPath(wxPATH_UNIX)); } return e; }
JSONElement LexerConf::ToJSON() const { JSONElement json = JSONElement::createObject(GetName()); json.addProperty("Name", GetName()); json.addProperty("Theme", GetThemeName()); json.addProperty("Flags", m_flags); json.addProperty("Id", GetLexerId()); json.addProperty("KeyWords0", GetKeyWords(0)); json.addProperty("KeyWords1", GetKeyWords(1)); json.addProperty("KeyWords2", GetKeyWords(2)); json.addProperty("KeyWords3", GetKeyWords(3)); json.addProperty("KeyWords4", GetKeyWords(4)); json.addProperty("Extensions", GetFileSpec()); JSONElement properties = JSONElement::createArray("Properties"); json.append(properties); StyleProperty::Map_t::const_iterator iter = m_properties.begin(); for(; iter != m_properties.end(); ++iter) { properties.arrayAppend(iter->second.ToJSON()); } return json; }