Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cleanup] code removal of some fixed parameters #3546

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CodeLite/Cxx/cpp_comment_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ wxString CppCommentCreator::FunctionComment()

// parse the function signature
Language* lang = LanguageST::Get();
const std::vector<TagEntryPtr> tags = lang->GetLocalVariables(m_tag->GetSignature(), true);
const std::vector<TagEntryPtr> tags = lang->GetLocalVariables(m_tag->GetSignature());

comment << wxT("$(FunctionPattern)\n");
for(size_t i = 0; i < tags.size(); i++)
Expand Down
67 changes: 0 additions & 67 deletions CodeLite/cl_typedef.h

This file was deleted.

20 changes: 1 addition & 19 deletions CodeLite/ctags_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "Cxx/cpp_comment_creator.h"
#include "StdToWX.h"
#include "cl_command_event.h"
#include "code_completion_api.h"
#include "codelite_events.h"
#include "database/tags_storage_sqlite3.h"
#include "event_notifier.h"
Expand Down Expand Up @@ -348,7 +347,7 @@ void TagsManager::SetCtagsOptions(const TagsOptionsData& options)
wxString TagsManager::GetScopeName(const wxString& scope)
{
Language* lang = GetLanguage();
return lang->GetScopeName(scope, NULL);
return lang->GetScopeName(scope);
}

void TagsManager::GetFiles(const wxString& partialName, std::vector<FileEntryPtr>& files)
Expand Down Expand Up @@ -774,23 +773,6 @@ bool TagsManager::IsBinaryFile(const wxString& filepath, const TagsOptionsData&
return true;
}

wxArrayString TagsManager::BreakToOuterScopes(const wxString& scope)
{
wxArrayString outerScopes;
wxArrayString scopes = wxStringTokenize(scope, wxT(":"), wxTOKEN_STRTOK);
for(size_t i = 1; i < scopes.GetCount(); i++) {
wxString newScope;
for(size_t j = 0; j < i; j++) {
newScope << scopes.Item(j) << wxT("::");
}
if(newScope.Len() >= 2) {
newScope.RemoveLast(2);
}
outerScopes.Add(newScope);
}
return outerScopes;
}

ITagsStoragePtr TagsManager::GetDatabase() { return m_db; }

wxString TagsManager::DoReplaceMacrosFromDatabase(const wxString& name)
Expand Down
1 change: 0 additions & 1 deletion CodeLite/ctags_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ class WXDLLIMPEXP_CL TagsManager : public wxEvtHandler
protected:
void DoFindByNameAndScope(const wxString& name, const wxString& scope, std::vector<TagEntryPtr>& tags);
wxString DoReplaceMacros(const wxString& name);
wxArrayString BreakToOuterScopes(const wxString& scope);
wxString DoReplaceMacrosFromDatabase(const wxString& name);
void GetScopesByScopeName(const wxString& scopeName, wxArrayString& scopes);
};
Expand Down
1 change: 0 additions & 1 deletion CodeLite/database/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "CompletionHelper.hpp"
#include "Cxx/CxxScannerTokens.h"
#include "Cxx/CxxTokenizer.h"
#include "code_completion_api.h"
#include "ctags_manager.h"
#include "language.h"
#include "macros.h"
Expand Down
103 changes: 3 additions & 100 deletions CodeLite/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Language::ParseTemplateInitList(const wxString& argListStr, wxArrayString&
typeName.Empty();
}

wxString Language::GetScopeName(const wxString& in, std::vector<wxString>* additionlNS)
wxString Language::GetScopeName(const wxString& in)
{
std::vector<std::string> moreNS;

Expand All @@ -157,36 +157,6 @@ wxString Language::GetScopeName(const wxString& in, std::vector<wxString>* addit
if(scope.IsEmpty()) {
scope = wxT("<global>");
}

if(additionlNS) {
for(size_t i = 0; i < moreNS.size(); i++) {
additionlNS->push_back(_U(moreNS.at(i).c_str()));
}

// In case we are found some 'using namesapce XXX;' statement
// we should scan the following scopes:
// XXX
// and also:
// XXX::CurrentScope (assuming that CurrentScope != <global>)
if(scope != wxT("<global>")) {
std::vector<wxString> tmpScopes;
for(size_t i = 0; i < additionlNS->size(); i++) {
tmpScopes.push_back(additionlNS->at(i));
tmpScopes.push_back(additionlNS->at(i) + wxT("::") + scope);
}
additionlNS->clear();
additionlNS->insert(additionlNS->begin(), tmpScopes.begin(), tmpScopes.end());
}

wxArrayString moreScopes = GetTagsManager()->BreakToOuterScopes(scope);
for(size_t i = 0; i < moreScopes.GetCount(); i++) {
if(moreScopes.Item(i) != scope &&
std::find(additionlNS->begin(), additionlNS->end(), moreScopes.Item(i)) == additionlNS->end()) {
additionlNS->push_back(moreScopes.Item(i));
}
}
}

return scope;
}

Expand Down Expand Up @@ -236,46 +206,19 @@ bool Language::VariableFromPattern(const wxString& in, const wxString& name, Var

bool Language::FunctionFromPattern(TagEntryPtr tag, clFunction& foo) { return false; }

std::vector<TagEntryPtr> Language::GetLocalVariables(const wxString& in, bool isFuncSignature, const wxString& name,
size_t flags)
std::vector<TagEntryPtr> Language::GetLocalVariables(const wxString& in)
{
wxString pattern(in);
pattern = pattern.Trim().Trim(false);

if(flags & ReplaceTokens) {
// Apply ctags replcements table on the current input string
pattern = ApplyCtagsReplacementTokens(in);
}

CxxVariableScanner scanner(pattern, eCxxStandard::kCxx11, GetTagsManager()->GetCtagsOptions().GetTokensWxMap(),
isFuncSignature);
true);
CxxVariable::Vec_t locals = scanner.GetVariables(false);

std::vector<TagEntryPtr> tags;
for(CxxVariable::Ptr_t local : locals) {
const wxString& tagName = local->GetName();

// if we have name, collect only tags that matches name
if(!name.IsEmpty()) {
// incase CaseSensitive is not required, make both string lower case
wxString tmpName(name);
wxString tmpTagName(tagName);
if(flags & IgnoreCaseSensitive) {
tmpName.MakeLower();
tmpTagName.MakeLower();
}

if((flags & PartialMatch) && !tmpTagName.StartsWith(tmpName))
continue;
// Don't suggest what we have typed so far
if((flags & PartialMatch) && tmpTagName == tmpName)
continue;
;
if((flags & ExactMatch) && tmpTagName != tmpName)
continue;
;
} // else no name is specified, collect all tags

TagEntryPtr tag(new TagEntry());
tag->SetName(tagName);
tag->SetKind(wxT("variable"));
Expand Down Expand Up @@ -409,46 +352,6 @@ Language* LanguageST::Get()
return gs_Language;
}

wxString Language::ApplyCtagsReplacementTokens(const wxString& in)
{
// First, get the replacement map
CLReplacementList replacements;
const wxStringTable_t& replacementMap = GetTagsManager()->GetCtagsOptions().GetTokensWxMap();
wxStringTable_t::const_iterator iter = replacementMap.begin();
for(; iter != replacementMap.end(); ++iter) {

if(iter->second.IsEmpty())
continue;

wxString pattern = iter->first;
wxString replace = iter->second;
pattern.Trim().Trim(false);
replace.Trim().Trim(false);
CLReplacement repl;
repl.construct(pattern.To8BitData().data(), replace.To8BitData().data());
if(repl.is_ok) {
replacements.push_back(repl);
}
}

if(replacements.empty())
return in;

// Now, apply the replacements
wxString outputStr;
wxArrayString lines = ::wxStringTokenize(in, wxT("\r\n"), wxTOKEN_STRTOK);
for(size_t i = 0; i < lines.GetCount(); i++) {
std::string outStr = lines.Item(i).mb_str(wxConvUTF8).data();
CLReplacementList::iterator iter = replacements.begin();
for(; iter != replacements.end(); iter++) {
::CLReplacePatternA(outStr, *iter, outStr);
}

outputStr << wxString(outStr.c_str(), wxConvUTF8) << wxT("\n");
}
return outputStr;
}

int Language::DoReadClassName(CppScanner& scanner, wxString& clsname) const
{
clsname.clear();
Expand Down
11 changes: 3 additions & 8 deletions CodeLite/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "Cxx/cpp_scanner.h"
#include "codelite_exports.h"
#include "database/entry.h"
#include "expression_result.h"
#include "function.h"
#include "macros.h"
#include "variable.h"
Expand Down Expand Up @@ -120,19 +119,15 @@ class WXDLLIMPEXP_CL Language
* @param in input string
* @return scope name or empty string
*/
wxString GetScopeName(const wxString& in, std::vector<wxString>* additionlNS);
wxString GetScopeName(const wxString& in);

/**
* Collect local variables from given scope text (in) and an optional symbol name
* Collect local variables from given scope text (in (a function signature))
* @param in scope to search for
* @param name optional name to look for (name can be partial).
* @return since we dont have full information about each token,
* all local variables returned are of type 'variable' with public access
*/
std::vector<TagEntryPtr> GetLocalVariables(const wxString& in, bool isFuncSignature,
const wxString& name = wxEmptyString, size_t flag = PartialMatch);

wxString ApplyCtagsReplacementTokens(const wxString& in);
std::vector<TagEntryPtr> GetLocalVariables(const wxString& in);

bool VariableFromPattern(const wxString& pattern, const wxString& name, Variable& var);
bool FunctionFromPattern(TagEntryPtr tag, clFunction& foo);
Expand Down
Loading
Loading