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; }
bool clTernServer::PostFindDefinitionRequest(IEditor* editor) { // Sanity if(m_workerThread) return false; // another request is in progress if(m_port == wxNOT_FOUND) return false; // don't know tern's port ++m_recycleCount; wxStyledTextCtrl* ctrl = editor->GetCtrl(); // Prepare the request JSONRoot root(cJSON_Object); JSONElement query = JSONElement::createObject("query"); root.toElement().append(query); query.addProperty("type", wxString("definition")); query.addProperty("file", wxString("#0")); query.append(CreateLocation(ctrl)); // Creae the files array JSONElement files = CreateFilesArray(editor); root.toElement().append(files); clTernWorkerThread::Request* req = new clTernWorkerThread::Request; req->jsonRequest = root.toElement().FormatRawString(); req->filename = editor->GetFileName().GetFullPath(); req->type = clTernWorkerThread::kFindDefinition; // Create the worker thread and start the request m_workerThread = new clTernWorkerThread(this); m_workerThread->Start(); m_workerThread->Add(req); return true; }
bool clTernServer::PostResetCommand(bool forgetFiles) { // Sanity if(m_workerThread) return false; // another request is in progress if(m_port == wxNOT_FOUND) return false; // don't know tern's port ++m_recycleCount; // Prepare the request JSONRoot root(cJSON_Object); JSONElement query = JSONElement::createObject("query"); root.toElement().append(query); query.addProperty("type", wxString("reset")); if(forgetFiles) { query.addProperty("forgetFiles", true); } clTernWorkerThread::Request* req = new clTernWorkerThread::Request; req->jsonRequest = root.toElement().FormatRawString(); req->type = clTernWorkerThread::kReset; // Create the worker thread and start the request m_workerThread = new clTernWorkerThread(this); m_workerThread->Start(); m_workerThread->Add(req); return true; }
JSONElement AbbreviationJSONEntry::ToJSON() const { JSONElement ele = JSONElement::createObject(GetName()); ele.addProperty("entries", m_entries); ele.addProperty("autoInsert", m_autoInsert); return ele; }
JSONElement DiffConfig::ToJSON() const { JSONElement element = JSONElement::createObject(GetName()); element.addProperty("m_flags", m_flags); element.addProperty("m_viewFlags", m_viewFlags); return element; }
void PHPProject::ToJSON(JSONElement& pro) const { pro.addProperty("m_name", m_name); pro.addProperty("m_isActive", m_isActive); pro.addProperty("m_importFileSpec", m_importFileSpec); pro.addProperty("m_excludeFolders", m_excludeFolders); pro.append(m_settings.ToJSON()); }
JSONElement znConfigItem::ToJSON() const { JSONElement element = JSONElement::createObject(GetName()); element.addProperty("m_highlightColour", m_highlightColour); element.addProperty("m_enabled", m_enabled); element.addProperty("m_zoomFactor", m_zoomFactor); return element; }
JSONElement clDockerSettings::ToJSON() const { JSONElement json = JSONElement::createObject(GetName()); json.addProperty("docker", m_docker.GetFullPath()); json.addProperty("docker-compose", m_dockerCompose.GetFullPath()); json.addProperty("flags", m_flags); return json; }
JSONElement SSHWorkspaceSettings::ToJSON() const { JSONElement json = JSONElement::createObject(GetName()); json.addProperty("m_account", m_account); json.addProperty("m_remoteFolder", m_remoteFolder); json.addProperty("m_remoteUploadEnabled", m_remoteUploadEnabled); return json; }
JSONElement PluginInfo::ToJSON() const { JSONElement e = JSONElement::createObject(); e.addProperty("name", name); e.addProperty("author", author); e.addProperty("description", description); e.addProperty("version", version); return e; }
JSONElement LLDBSettings::ToJSON() const { JSONElement json = JSONElement::createObject(); json.addProperty("m_maxArrayElements", m_arrItems); json.addProperty("m_maxCallstackFrames", m_stackFrames); json.addProperty("m_flags", m_flags); json.addProperty("m_types", m_types); return json; }
JSONElement LLDBBacktrace::Entry::ToJSON() const { JSONElement json = JSONElement::createObject(); json.addProperty("id", id); json.addProperty("line", line); json.addProperty("filename", filename); json.addProperty("functionName", functionName); json.addProperty("address", address); return json; }
JSONElement GitEntry::ToJSON() const { JSONElement json = JSONElement::createObject(GetName()); json.addProperty("m_entries", m_entries); if(m_colourTrackedFile.IsOk()) { json.addProperty("m_colourTrackedFile", m_colourTrackedFile.GetAsString(wxC2S_HTML_SYNTAX)); } if(m_colourDiffFile.IsOk()) { json.addProperty("m_colourDiffFile", m_colourDiffFile.GetAsString(wxC2S_HTML_SYNTAX)); } json.addProperty("m_pathGIT", m_pathGIT); json.addProperty("m_pathGITK", m_pathGITK); json.addProperty("m_flags", m_flags); json.addProperty("m_gitDiffDlgSashPos", m_gitDiffDlgSashPos); json.addProperty("m_gitConsoleSashPos", m_gitConsoleSashPos); json.addProperty("m_gitCommitDlgHSashPos", m_gitCommitDlgHSashPos); json.addProperty("m_gitCommitDlgVSashPos", m_gitCommitDlgVSashPos); json.addProperty("m_recentCommits", m_recentCommits); // Add the git commands array JSONElement arrCommands = JSONElement::createArray("Commands"); json.append(arrCommands); GitCommandsEntriesMap_t::const_iterator iter = m_commandsMap.begin(); for(; iter != m_commandsMap.end(); ++iter) { iter->second.ToJSON(arrCommands); } return json; }
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; }
JSONElement DbConnectionInfo::ToJSON() const { JSONElement element = JSONElement::createObject(GetName()); element.addProperty("m_connectionName", m_connectionName ); element.addProperty("m_connectionType", m_connectionType ); element.addProperty("m_defaultDatabase", m_defaultDatabase); element.addProperty("m_password" , m_password ); element.addProperty("m_server" , m_server ); element.addProperty("m_port" , m_port ); element.addProperty("m_username" , m_username ); return element; }
void NodeJSDebugger::GetCurrentFrameSource(const wxString& filename, int line) { // Sanity if(!IsConnected()) return; // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "source"); // Write the command m_socket->WriteRequest(request, new NodeJSGetScriptHandler(filename, line)); }
void NodeJSDebugger::Callstack() { // Sanity if(!IsConnected()) return; // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "backtrace"); // Write the command m_socket->WriteRequest(request, new NodeJSCallstackHandler()); }
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 clTernServer::CreateLocation(wxStyledTextCtrl* ctrl, int pos) { if(pos == wxNOT_FOUND) { pos = ctrl->GetCurrentPos(); } int lineNo = ctrl->LineFromPosition(pos); JSONElement loc = JSONElement::createObject("end"); loc.addProperty("line", lineNo); // Pass the column int lineStartPos = ctrl->PositionFromLine(lineNo); pos = pos - lineStartPos; loc.addProperty("ch", pos); return loc; }
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& 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; }
void NodeJSDebugger::OnEvalExpression(clDebugEvent& event) { event.Skip(); // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "evaluate"); JSONElement args = JSONElement::createObject("arguments"); request.append(args); args.addProperty("expression", event.GetString()); // Write the command m_socket->WriteRequest(request, new NodeJSEvaluateExprHandler(event.GetString(), kNodeJSContextConsole)); }
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; }
JSONElement PHPConfigurationData::ToJSON() const { JSONElement e = JSONElement::createObject(GetName()); e.addProperty("m_includePaths", m_includePaths); e.addProperty("m_phpExe", m_phpExe); e.addProperty("m_errorReporting", m_errorReporting); e.addProperty("m_xdebugPort", m_xdebugPort); e.addProperty("m_xdebugHost", m_xdebugHost); e.addProperty("m_ccIncludePath", m_ccIncludePath); e.addProperty("m_flags", m_flags); e.addProperty("m_xdebugIdeKey", m_xdebugIdeKey); e.addProperty("m_findInFilesMask", m_findInFilesMask); e.addProperty("m_workspaceType", m_workspaceType); e.addProperty("m_settersGettersFlags", m_settersGettersFlags); return e; }
void NodeJSDebugger::SelectFrame(int frameId) { // Sanity if(!IsConnected()) return; // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "frame"); JSONElement args = JSONElement::createObject("arguments"); request.append(args); args.addProperty("number", frameId); // Write the command m_socket->WriteRequest(request, new NodeJSSelectFrameHandler()); }
void NodeJSDebugger::DeleteBreakpoint(const NodeJSBreakpoint& bp) { // Sanity if(!IsConnected()) return; if(!bp.IsApplied()) return; // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "clearbreakpoint"); JSONElement args = JSONElement::createObject("arguments"); request.append(args); args.addProperty("breakpoint", bp.GetNodeBpID()); // Write the command m_socket->WriteRequest(request, new NodeJSSetBreakpointHandler(bp)); }
void NodeJSDebugger::OnDebugStepOut(clDebugEvent& event) { event.Skip(); CHECK_RUNNING(); event.Skip(false); // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "continue"); JSONElement args = JSONElement::createObject("arguments"); request.append(args); args.addProperty("stepaction", "out"); args.addProperty("stepcount", 1); // how we tell nodejs to continue until next bp is hit? // Write the command m_socket->WriteRequest(request, new NodeJSContinueHandler()); }
void NodeJSDebugger::BreakOnException(bool b) { // Sanity if(!IsConnected()) return; // Build the request JSONElement request = JSONElement::createObject(); request.addProperty("type", "request"); request.addProperty("command", "setexceptionbreak"); JSONElement args = JSONElement::createObject("arguments"); request.append(args); args.addProperty("type", "uncaught"); args.addProperty("enabled", b); // Write the command m_socket->WriteRequest(request, NULL); }
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); }
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)); }