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] Remove TagsManager::AreTheSame/Language::FunctionFromPattern #3581

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 1 addition & 11 deletions CodeLite/Cxx/cpp_comment_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ wxString CppCommentCreator::FunctionComment()
for(size_t i = 0; i < tags.size(); i++)
comment << wxT(" * ") << m_keyPrefix << wxT("param ") << tags.at(i)->GetName() << wxT("\n");

if(m_tag->GetKind() == wxT("function")) {
clFunction f;
if(lang->FunctionFromPattern(m_tag, f)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always false, so dead code.

wxString type = _U(f.m_returnValue.m_type.c_str());
trimMe(type);
if(type != wxT("void")) { // void has no return value
comment << wxT(" * ") << m_keyPrefix << wxT("return \n");
}
}

} else {
if (m_tag->GetKind() != wxT("function")) {
Variable var;
lang->VariableFromPattern(m_tag->GetPattern(), m_tag->GetName(), var);
wxString type = _U(var.m_type.c_str());
Expand Down
7 changes: 0 additions & 7 deletions CodeLite/cl_calltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

struct tagCallTipInfo {
wxString sig;
wxString retValue;
std::vector<std::pair<int, int>> paramLen;
};

Expand Down Expand Up @@ -215,9 +214,6 @@ void clCallTip::FormatTagsToTips(const TagEntryPtrVector_t& tags, std::vector<cl

wxString raw_sig(t->GetSignature().Trim().Trim(false));

// evaluate the return value of the tag
cti.retValue = TagsManagerST::Get()->GetFunctionReturnValueFromPattern(t);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returned always wxEmptyString


bool hasDefaultValues = (raw_sig.Find(wxT("=")) != wxNOT_FOUND);

// the key for unique entries is the function prototype without the variables names and
Expand Down Expand Up @@ -274,9 +270,6 @@ void clCallTip::FormatTagsToTips(const TagEntryPtrVector_t& tags, std::vector<cl
// Rust & Php have "self" or other variant of it in the argument
// list, so lets filter it
tip.Trim().Trim(false);
if (iter->second.retValue.empty() == false) {
tip << " -> " << iter->second.retValue.Trim(false).Trim();
}

clTipInfo ti;
ti.paramLen = iter->second.paramLen;
Expand Down
121 changes: 0 additions & 121 deletions CodeLite/ctags_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,95 +395,6 @@ TagEntryPtr TagsManager::FunctionFromFileLine(const wxFileName& fileName, int li
return foo;
}

wxString TagsManager::FormatFunction(TagEntryPtr tag, size_t flags, const wxString& scope)
{
clFunction foo;
if(!GetLanguage()->FunctionFromPattern(tag, foo)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always false, so return always wxEmptyString

return wxEmptyString;
}

wxString body;
// add virtual keyword to declarations only && if the flags is set
if(foo.m_isVirtual && (flags & FunctionFormat_WithVirtual) && !(flags & FunctionFormat_Impl)) {
body << wxT("virtual\n");
}

if(tag->IsTemplateFunction()) {
// a template function, add the template definition
body << "template <";
CxxTemplateFunction helper(tag);
helper.ParseDefinitionList();
for(size_t i = 0; i < helper.GetList().GetCount(); ++i) {
body << " typename " << helper.GetList().Item(i) << ", \n";
}
if(body.EndsWith(", \n")) {
body.RemoveLast(3);
}
body << ">\n";
}

wxString retValue = tag->GetTypename();
if(retValue.IsEmpty() == false) {
body << retValue << wxT(" ");
}

if(flags & FunctionFormat_Impl) {
if(scope.IsEmpty()) {
if(tag->GetScope() != wxT("<global>")) {
body << tag->GetScope() << wxT("::");
}
} else {
body << scope << wxT("::");
}
}

// Build the flags required by the NormalizeFunctionSig() method
size_t tmpFlags(0);
if(flags & FunctionFormat_Impl) {
tmpFlags |= Normalize_Func_Name;
} else {
tmpFlags |= Normalize_Func_Name | Normalize_Func_Default_value;
}

if(flags & FunctionFormat_Arg_Per_Line)
tmpFlags |= Normalize_Func_Arg_Per_Line;

if(flags & FunctionFormat_Arg_Per_Line)
body << wxT("\n");

body << tag->GetName();
if(tag->GetFlags() & TagEntry::Tag_No_Signature_Format) {
body << tag->GetSignature();

} else {
body << NormalizeFunctionSig(tag->GetSignature(), tmpFlags);
}

if(foo.m_isConst) {
body << wxT(" const");
}

if(!foo.m_throws.empty()) {
body << wxT(" throw (") << wxString(foo.m_throws.c_str(), wxConvUTF8) << wxT(")");
}

if(flags & FunctionFormat_Impl) {
body << wxT("\n{\n}\n");
} else {
if(foo.m_isVirtual && (flags & FunctionFormat_WithOverride)) {
body << wxT(" override");
}
body << wxT(";\n");
}

// convert \t to spaces
body.Replace(wxT("\t"), wxT(" "));

// remove any extra spaces from the tip
while(body.Replace(wxT(" "), wxT(" "))) {}
return body;
}

void TagsManager::SetLanguage(Language* lang) { m_lang = lang; }

Language* TagsManager::GetLanguage()
Expand Down Expand Up @@ -656,36 +567,6 @@ void TagsManager::FilterNonNeededFilesForRetaging(wxArrayString& strFiles, ITags
}
}

wxString TagsManager::GetFunctionReturnValueFromPattern(TagEntryPtr tag)
{
// evaluate the return value of the tag
clFunction foo;
wxString return_value;
if(GetLanguage()->FunctionFromPattern(tag, foo)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always false, so return always wxEmptyString

if(foo.m_retrunValusConst.empty() == false) {
return_value << _U(foo.m_retrunValusConst.c_str()) << wxT(" ");
}

if(foo.m_returnValue.m_typeScope.empty() == false) {
return_value << _U(foo.m_returnValue.m_typeScope.c_str()) << wxT("::");
}

if(foo.m_returnValue.m_type.empty() == false) {
return_value << _U(foo.m_returnValue.m_type.c_str());
if(foo.m_returnValue.m_templateDecl.empty() == false) {
return_value << wxT("<") << _U(foo.m_returnValue.m_templateDecl.c_str()) << wxT(">");
}
return_value << _U(foo.m_returnValue.m_starAmp.c_str());
return_value << wxT(" ");
}

if(!foo.m_returnValue.m_rightSideConst.empty()) {
return_value << foo.m_returnValue.m_rightSideConst << " ";
}
}
return return_value;
}

void TagsManager::GetDereferenceOperator(const wxString& scope, std::vector<TagEntryPtr>& tags)
{
std::vector<std::pair<wxString, int>> derivationList;
Expand Down Expand Up @@ -799,8 +680,6 @@ wxString TagsManager::DoReplaceMacrosFromDatabase(const wxString& name)
return newName;
}

bool TagsManager::AreTheSame(const TagEntryPtrVector_t& v1, const TagEntryPtrVector_t& v2) const { return false; }

bool TagsManager::InsertFunctionDecl(const wxString& clsname, const wxString& functionDecl, wxString& sourceContent,
int visibility)
{
Expand Down
22 changes: 0 additions & 22 deletions CodeLite/ctags_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,6 @@ class WXDLLIMPEXP_CL TagsManager : public wxEvtHandler
*/
void GetTagsByPartialNames(const wxArrayString& partialNames, std::vector<TagEntryPtr>& tags);

/**
* @brief generate function body/impl based on a tag
* @param tag the input tag which represents the requested tag
* @param impl set to true if you need an implementation, false otherwise. Default is set to false
* @param scope real function scope to use
* @return the function impl/decl
*/
wxString FormatFunction(TagEntryPtr tag, size_t flags = FunctionFormat_WithVirtual,
const wxString& scope = wxEmptyString);

/**
* @brief return true if type & scope do exist in the symbols database
* @param typeName
Expand All @@ -321,25 +311,13 @@ class WXDLLIMPEXP_CL TagsManager : public wxEvtHandler
wxString NormalizeFunctionSig(const wxString& sig, size_t flags = Normalize_Func_Name,
std::vector<std::pair<int, int>>* paramLen = NULL);

/**
* @brief accept as input ctags pattern of a function and tries to evaluate the
* return value of the function
* @param pattern ctags pattern of the method
* @return return value of the method from the pattern of empty string
*/
wxString GetFunctionReturnValueFromPattern(TagEntryPtr tag);
/**
* @brief fileter a recently tagged files from the strFiles array
* @param strFiles
* @param db
*/
void FilterNonNeededFilesForRetaging(wxArrayString& strFiles, ITagsStoragePtr db);

/**
* @brief return true of v1 cotnains the same tags as v2
*/
bool AreTheSame(const TagEntryPtrVector_t& v1, const TagEntryPtrVector_t& v2) const;

/**
* @brief insert functionBody into clsname. This function will search for best location
* to place the function body. set visibility to 0 for 'pubilc' function, 1 for 'protected' and 2 for private
Expand Down
2 changes: 0 additions & 2 deletions CodeLite/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ bool Language::VariableFromPattern(const wxString& in, const wxString& name, Var
return false;
}

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

std::vector<TagEntryPtr> Language::GetLocalVariables(const wxString& in)
{
wxString pattern(in);
Expand Down
1 change: 0 additions & 1 deletion CodeLite/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class WXDLLIMPEXP_CL Language
std::vector<TagEntryPtr> GetLocalVariables(const wxString& in);

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

/**
* @brief insert functionBody into clsname. This function will search for best location
Expand Down
6 changes: 1 addition & 5 deletions LiteEditor/context_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include "findusagetab.h"
#include "frame.h"
#include "globals.h"
#include "implement_parent_virtual_functions.h"
#include "language.h"
#include "manager.h"
#include "movefuncimpldlg.h"
Expand Down Expand Up @@ -1232,10 +1231,7 @@ void ContextCpp::OnMoveImpl(wxCommandEvent& e)
CHECK_EXPECTED_RETURN(DoGetFunctionBody(curPos, blockStartPos, blockEndPos, content), true);

// create the functions body
wxString body = TagsManagerST::Get()->FormatFunction(tag, FunctionFormat_Impl);
// remove the empty content provided by this function
body = body.BeforeLast('{');
body = body.Trim().Trim(false);
wxString body = wxEmptyString;
body.Prepend("\n");
body << content << "\n";

Expand Down
3 changes: 1 addition & 2 deletions LiteEditor/implement_parent_virtual_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ wxString clFunctionImplDetails::GetImpl(ImplementParentVirtualFunctionsDialog* d

wxString impl;
tag->SetScope(dlg->m_scope);
impl << TagsManagerST::Get()->FormatFunction(tag, FunctionFormat_Impl) << wxT("\n");
impl << wxT("\n");
impl.Trim().Trim(false);
impl << "\n\n";

Expand Down Expand Up @@ -208,7 +208,6 @@ wxString clFunctionImplDetails::GetDecl(ImplementParentVirtualFunctionsDialog* d
if(IsAppendOverrideKeyword()) { format |= FunctionFormat_WithOverride; }

tag->SetScope(dlg->m_scope);
decl << TagsManagerST::Get()->FormatFunction(tag, format);
decl.Trim().Trim(false);
decl << "\n";
return decl;
Expand Down
4 changes: 0 additions & 4 deletions Plugin/symbol_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ void SymbolTree::BuildTree(const wxFileName& fileName, const TagEntryPtrVector_t
// Load the new tags from the database
db->SelectTagsByFile(fileName.GetFullPath(), newTags);

// Compare the new tags with the old ones
if(!forceBuild && TagsManagerST::Get()->AreTheSame(newTags, m_currentTags))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always false, so dead code.

return;

m_currentTags.clear();
m_currentTags.insert(m_currentTags.end(), newTags.begin(), newTags.end());

Expand Down
Loading