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; }
Location* LocationManager::CreateLocation(const char* locationTypeName, const char* locationName, const csVector3 &pos, iSector* sector, float radius, float rot_angle, const csString &flags) { LocationType* locationType = FindLocation(locationTypeName); if(!locationType) { return NULL; } return CreateLocation(locationType, locationName, pos, sector, radius, rot_angle, flags); }
Location* LocationManager::CreateLocation(iDataConnection* db, LocationType* locationType, const char* locationName, const csVector3 &pos, iSector* sector, float radius, float rot_angle, const csString &flags) { Location* location = CreateLocation(locationType, locationName, pos, sector, radius, rot_angle, flags); if(!location->CreateUpdate(db)) { delete location; return NULL; } return location; }
bool clTernServer::PostFunctionTipRequest(IEditor* editor, int pos) { // 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(); // Write the modified buffer into a file // wxFileName tmpFileName = wxFileName::CreateTempFileName("tern"); // if(!FileUtils::WriteFileContent(tmpFileName, ctrl->GetText())) return false; // Prepare the request JSONRoot root(cJSON_Object); JSONElement query = JSONElement::createObject("query"); root.toElement().append(query); query.addProperty("type", wxString("type")); query.addProperty("file", wxString("#0")); query.append(CreateLocation(ctrl, pos)); // 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::kFunctionTip; // Create the worker thread and start the request m_workerThread = new clTernWorkerThread(this); m_workerThread->Start(); m_workerThread->Add(req); return true; }