68
69
wxString clCallTip::TipAt(int at)
71
if ( m_tips.size() > 1 )
72
tip << _T("\n\001 ") << static_cast<int>(m_curr)+1 << _T(" of ") << static_cast<int>(m_tips.size()) << _T(" \002 ")
73
<< m_tips.at(at) << _T("\n");
75
tip << _T("\n") << m_tips.at( 0 ) << _T("\n");
72
if ( m_tips.size() > 1 ) {
73
tip << _T("\001 ") << static_cast<int>(m_curr)+1 << _T(" of ") << static_cast<int>(m_tips.size()) << _T(" \002 ") << m_tips.at(at).str ;
75
tip << m_tips.at( 0 ).str;
105
106
return TipAt(m_curr);
109
wxString clCallTip::All()
112
for (size_t i=0; i<m_tips.size(); i++) {
113
tip << m_tips.at(i).str << wxT("\n");
108
119
int clCallTip::Count() const
110
121
return (int)m_tips.size();
113
wxString clCallTip::All()
124
void clCallTip::Initialize(const std::vector<TagEntryPtr> &tips)
116
126
std::map<wxString, tagCallTipInfo> mymap;
117
for (size_t i=0; i< m_tips.size(); i++) {
127
for (size_t i=0; i< tips.size(); i++) {
118
128
tagCallTipInfo cti;
119
TagEntryPtr t = m_tips.at(i);
129
TagEntryPtr t = tips.at(i);
120
130
if (t->GetKind() == wxT("function") || t->GetKind() == wxT("prototype")) {
122
132
wxString raw_sig ( t->GetSignature().Trim().Trim(false) );
124
134
// evaluate the return value of the tag
126
if (LanguageST::Get()->FunctionFromPattern(t->GetPattern(), foo)) {
127
if (foo.m_retrunValusConst.empty() == false) {
128
cti.retValue << _U(foo.m_retrunValusConst.c_str()) << wxT(" ");
131
if (foo.m_returnValue.m_typeScope.empty() == false) {
132
cti.retValue << _U(foo.m_returnValue.m_typeScope.c_str()) << wxT("::");
135
if (foo.m_returnValue.m_type.empty() == false) {
136
cti.retValue << _U(foo.m_returnValue.m_type.c_str());
137
if (foo.m_returnValue.m_templateDecl.empty() == false) {
138
cti.retValue << wxT("<") << _U(foo.m_returnValue.m_templateDecl.c_str()) << wxT(">");
140
cti.retValue << _U(foo.m_returnValue.m_starAmp.c_str());
141
cti.retValue << wxT(" ");
135
cti.retValue = TagsManagerST::Get()->GetFunctionReturnValueFromPattern(t->GetPattern());
145
137
bool hasDefaultValues = (raw_sig.Find(wxT("=")) != wxNOT_FOUND);
146
wxString normalizedSig = TagsManagerST::Get()->NormalizeFunctionSig(raw_sig);
147
cti.sig = normalizedSig;
139
// the key for unique entries is the function prototype without the variables names and
140
// any default values
141
wxString key = TagsManagerST::Get()->NormalizeFunctionSig(raw_sig, 0);
143
// the signature that we want to keep is one with name & default values, so try and get the maximum out of the
144
// function signature
145
wxString full_signature = TagsManagerST::Get()->NormalizeFunctionSig(raw_sig, Normalize_Func_Name | Normalize_Func_Default_value, &cti.paramLen);
146
cti.sig = full_signature;
149
148
if (hasDefaultValues) {
150
//incase default values exist in this prototype,
151
//make it the tip instead of the existing one
153
mymap[normalizedSig] = cti;
149
// incase default values exist in this prototype,
150
// update/insert this signature
156
//make sure we dont add duplicates
157
if ( mymap.find(normalizedSig) == mymap.end() ) {
159
cti.sig = TagsManagerST::Get()->NormalizeFunctionSig(raw_sig, true);
160
mymap[normalizedSig] = cti;
154
// make sure we dont add duplicates
155
if ( mymap.find(key) == mymap.end() ) {
184
181
std::map<wxString, tagCallTipInfo>::iterator iter = mymap.begin();
185
for ( ; iter != mymap.end(); iter++ ) {
186
if( iter->second.retValue.empty() == false ) {
183
for (; iter != mymap.end(); iter++) {
185
if ( iter->second.retValue.empty() == false ) {
187
186
tip << iter->second.retValue.Trim(false).Trim() << wxT(" : ");
189
tip << iter->second.sig << wxT("\n");
191
tip = tip.BeforeLast(wxT('\n'));
188
tip << iter->second.sig;
190
ti.paramLen = iter->second.paramLen;
192
m_tips.push_back(ti);
196
void clCallTip::GetHighlightPos(int index, int& start, int& len)
200
if (m_curr >= 0 && m_curr < (int)m_tips.size()) {
201
clTipInfo ti = m_tips.at(m_curr);
202
int base = ti.str.Find(wxT("("));
204
if (m_tips.size() > 1) {
205
// multiple tooltips exists, make sure we calculate the up and down arrows
207
arrowsStr << _T("\001 ") << static_cast<int>(m_curr)+1 << _T(" of ") << static_cast<int>(m_tips.size()) << _T(" \002 ");
208
base += arrowsStr.Length();
212
if (base != wxNOT_FOUND && index < (int)ti.paramLen.size() && index >= 0) {
213
start = ti.paramLen.at(index).first + base;
214
len = ti.paramLen.at(index).second;