Is it good idea to store token implementation start/end lines in array or better hold this information in tokens tree? Multiple impl. start/end lines used only for namespaces.
Sorry, I'm not quite understand your idea. Currently, a Token structure is something like:
class Token : public BlockAllocated<Token, 10000>
{
friend class TokensTree;
public:
Token();
Token(const wxString& name, unsigned int file, unsigned int line);
~Token();
void AddChild(int child);
void RemoveChild(int child);
wxString GetNamespace() const;
bool InheritsFrom(int idx) const;
wxString DisplayName() const;
wxString GetTokenKindString() const;
wxString GetTokenScopeString() const;
wxString GetFilename() const;
wxString GetImplFilename() const;
inline unsigned long GetTicket() const { return m_Ticket; }
bool MatchesFiles(const TokenFilesSet& files);
bool SerializeIn(wxInputStream* f);
bool SerializeOut(wxOutputStream* f);
int GetSelf() { return m_Self; } // current index in the tree
wxString GetParentName();
Token* GetParentToken();
TokensTree* GetTree() { return m_pTree; }
wxString m_Type; // this is the return value (if any): e.g. const wxString&
wxString m_ActualType; // this is what the parser believes is the actual return value: e.g. wxString
wxString m_Name;
wxString m_Args;
wxString m_StrippedArgs;
wxString m_AncestorsString; // all ancestors comma-separated list
wxString m_TemplateArgument;
unsigned int m_FileIdx;
unsigned int m_Line;
unsigned int m_ImplFileIdx;
unsigned int m_ImplLine; // where the token was met
unsigned int m_ImplLineStart; // if token is impl, opening brace line
unsigned int m_ImplLineEnd; // if token is impl, closing brace line
TokenScope m_Scope;
TokenKind m_TokenKind;
bool m_IsOperator;
bool m_IsLocal; // found in a local file?
bool m_IsTemp; // if true, the tree deletes it in FreeTemporaries()
bool m_IsConst; // the member method is const (yes/no)
int m_ParentIndex;
TokenIdxSet m_Children;
TokenIdxSet m_Ancestors;
TokenIdxSet m_DirectAncestors;
TokenIdxSet m_Descendants;
wxArrayString m_Aliases; // used for namespace aliases
void* m_pUserData; // custom user-data (the classbrowser expects it to be a pointer to a cbProject)
protected:
TokensTree* m_pTree;
int m_Self; // current index in the tree
unsigned long m_Ticket;
static unsigned long GetTokenTicket();
};
So, You means that the same Tokens(used form, especially they used have different imp start line and end line) can be merged to one Token?
Great, works well.
Thanks!
----------------------
Oh, I found a bug: can not find the global functions.
#include <iostream>
using namespace std;
class A
{
public:
void func1() {}
void func2() {}
void func3() {}
};
class B
{
public:
void func1() {}
void func2() {}
void func3() {}
};
class C
{
public:
void func1() {}
void func2() {}
void func3() {}
};
// can not jump to here
void func1() {}
void func2() {}
void func3() {}
int main()
{
cout << "Hello world!" << endl;
return 0;
}
I change xrc's size, like:
<?xml version="1.0" ?>
<resource>
<object class="wxToolBarAddOn" name="codecompletion_toolbar">
<object class="wxChoice" name="chcCodeCompletionScope">
<content/>
<size>220,-1</size>
</object>
<object class="wxChoice" name="chcCodeCompletionFunction">
<content/>
<size>690,-1</size>
</object>
</object>
</resource>
[attachment deleted by admin]
If I put the top of the global functions, then all functions are normal!
#include <iostream>
using namespace std;
// can not jump to here
void func1() {}
void func2() {}
void func3() {}
class A
{
public:
void func1() {}
void func2() {}
void func3() {}
};
class B
{
public:
void func1() {}
void func2() {}
void func3() {}
};
class C
{
public:
void func1() {}
void func2() {}
void func3() {}
};
int main()
{
cout << "Hello world!" << endl;
return 0;
}
And if change to:
class A
{
public:
void func1() {}
void func2() {}
void func3() {}
};
// can not jump to here
void func1() {}
void func2() {}
void func3() {}
Now, it's unwork.
WOW! i see, this is indeed parser problem!
If change global function's name to :
// can not jump to here
void gfunc1() {}
void gfunc2() {}
void gfunc3() {}
then, that's work well now.
Following patch formally fixes this bug, Loaden.
Index: token.cpp
===================================================================
--- token.cpp (revision 6178)
+++ token.cpp (working copy)
@@ -521,9 +521,7 @@
if (!curToken)
continue;
- if ( ( (parent < 0)
- || (curToken->m_ParentIndex == parent) )
- && (curToken->m_TokenKind & kindMask) )
+ if ((curToken->m_ParentIndex == parent) && (curToken->m_TokenKind & kindMask))
{
return result;
}
But it makes another questions. Can this patch raise another bugs? :) And why we should return first found token if searched token parent is -1 (Global namespace) ?