void CSEdOpenedFiles::SetCompileFile(CSEdScriptEdit* cf) { if(compfile==cf) return; SetChange(); compfile = cf; CSEdOpenFilesListIt iter(GetOpenedFiles()); CSEdScriptEdit *se; while(!iter.End()) { se = iter->GetScriptEdit(); if(se) se->ShowCurCompFile(); iter++; } CompileForOB(); }
bool CodeRefactoring::Parse() { cbEditor* editor = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if (!editor) return false; const wxString targetText = GetSymbolUnderCursor(); if (targetText.IsEmpty()) return false; TokenIdxSet targetResult; const int endOfWord = editor->GetControl()->WordEndPosition(editor->GetControl()->GetCurrentPos(), true); m_NativeParser.MarkItemsByAI(targetResult, true, false, true, endOfWord); if (targetResult.empty()) { cbMessageBox(_("Symbol not found under cursor!"), _("Code Refactoring"), wxOK | wxICON_WARNING); return false; } // handle local variables bool isLocalVariable = false; TokenTree* tree = m_NativeParser.GetParser().GetTokenTree(); CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex) const Token* token = tree->at(*targetResult.begin()); if (token) { const Token* parent = tree->at(token->m_ParentIndex); if (parent && parent->m_TokenKind == tkFunction) isLocalVariable = true; } CC_LOCKER_TRACK_TT_MTX_UNLOCK(s_TokenTreeMutex) wxArrayString files; cbProject* project = m_NativeParser.GetProjectByEditor(editor); if (isLocalVariable || !project) files.Add(editor->GetFilename()); else { ScopeDialog scopeDlg(Manager::Get()->GetAppWindow(), _("Code Refactoring")); const int ret = scopeDlg.ShowModal(); if (ret == ScopeDialog::ID_OPEN_FILES) GetOpenedFiles(files); else if (ret == ScopeDialog::ID_PROJECT_FILES) GetAllProjectFiles(files, project); else return false; } if (files.IsEmpty()) return false; size_t count = SearchInFiles(files, targetText); if (count) count = VerifyResult(targetResult, targetText, isLocalVariable); return count != 0; }