Patch #3407 2013-01-15 21:24
p2rkw
CC: add nested enumerators to autocomplete list- Download
- 3407-CC_add_nested.patch (2.5 KB)
Index: src/plugins/codecompletion/nativeparser_base.cpp
===================================================================
--- src/plugins/codecompletion/nativeparser_base.cpp (wersja 8785)
+++ src/plugins/codecompletion/nativeparser_base.cpp (kopia robocza)
@@ -1318,7 +1318,11 @@
if (!token)
continue;
if ( !AddChildrenOfUnnamed(tree, token, result) )
+ {
result.insert(*it);
+ AddChildrenOfEnum(tree, token, result);
+ }
+
}
tree->RecalcInheritanceChain(parent);
@@ -1334,7 +1338,10 @@
if (!token)
continue;
if ( !AddChildrenOfUnnamed(tree, token, result) )
+ {
result.insert(*it2);
+ AddChildrenOfEnum(tree, token, result);
+ }
}
}
}
Index: src/plugins/codecompletion/nativeparser_base.h
===================================================================
--- src/plugins/codecompletion/nativeparser_base.h (wersja 8785)
+++ src/plugins/codecompletion/nativeparser_base.h (kopia robocza)
@@ -396,7 +396,8 @@
// for GenerateResultSet()
bool AddChildrenOfUnnamed(TokenTree* tree, const Token* parent, TokenIdxSet& result)
{
- if (parent->m_TokenKind == tkClass && parent->m_Name.StartsWith(g_UnnamedSymbol))
+ if (((parent->m_TokenKind & (tkClass | tkEnum)) != 0)
+ && parent->m_Name.StartsWith(g_UnnamedSymbol))
{
// add all its children
for (TokenIdxSet::const_iterator it = parent->m_Children.begin();
@@ -411,7 +412,25 @@
}
return false;
}
+
+ bool AddChildrenOfEnum(TokenTree* tree, const Token* parent, TokenIdxSet& result)
+ {
+ if (parent->m_TokenKind == tkEnum)
+ {
+ // add all its children
+ for (TokenIdxSet::const_iterator it = parent->m_Children.begin();
+ it != parent->m_Children.end(); ++it)
+ {
+ Token* tokenChild = tree->at(*it);
+ if (tokenChild)
+ result.insert(*it);
+ }
+ return true;
+ }
+ return false;
+ }
+
// for GenerateResultSet()
bool MatchText(const wxString& text, const wxString& target, bool caseSens, bool isPrefix)
{
History
p2rkw 2013-01-15 21:26
Test case:
struct B
{
enum Eb
{
ebAsd1, ebAsd2, ebAsd3,
};
enum{ unnamedEnumerator };
};
B::|
p2rkw 2013-01-15 21:50
Index: src/plugins/codecompletion/nativeparser_base.cpp =================================================================== --- src/plugins/codecompletion/nativeparser_base.cpp (wersja 8785) +++ src/plugins/codecompletion/nativeparser_base.cpp (kopia robocza) @@ -1318,7 +1318,11 @@ if (!token) continue; if ( !AddChildrenOfUnnamed(tree, token, result) ) + { result.insert(*it); + AddChildrenOfEnum(tree, token, result); + } + } tree->RecalcInheritanceChain(parent); @@ -1334,7 +1338,10 @@ if (!token) continue; if ( !AddChildrenOfUnnamed(tree, token, result) ) + { result.insert(*it2); + AddChildrenOfEnum(tree, token, result); + } } } } Index: src/plugins/codecompletion/nativeparser_base.h =================================================================== --- src/plugins/codecompletion/nativeparser_base.h (wersja 8785) +++ src/plugins/codecompletion/nativeparser_base.h (kopia robocza) @@ -396,7 +396,8 @@ // for GenerateResultSet() bool AddChildrenOfUnnamed(TokenTree* tree, const Token* parent, TokenIdxSet& result) { - if (parent->m_TokenKind == tkClass && parent->m_Name.StartsWith(g_UnnamedSymbol)) + if (((parent->m_TokenKind & (tkClass | tkEnum)) != 0) + && parent->m_Name.StartsWith(g_UnnamedSymbol)) { // add all its children for (TokenIdxSet::const_iterator it = parent->m_Children.begin(); @@ -411,7 +412,25 @@ } return false; } + + bool AddChildrenOfEnum(TokenTree* tree, const Token* parent, TokenIdxSet& result) + { + if (parent->m_TokenKind == tkEnum) + { + // add all its children + for (TokenIdxSet::const_iterator it = parent->m_Children.begin(); + it != parent->m_Children.end(); ++it) + { + Token* tokenChild = tree->at(*it); + if (tokenChild) + result.insert(*it); + } + return true; + } + return false; + } + // for GenerateResultSet() bool MatchText(const wxString& text, const wxString& target, bool caseSens, bool isPrefix) {
mortenmacfly 2013-01-21 15:46
tpetrov: As you stared to discuss it in the forums, I am assigning this to you temporarily so it doesn't get lost. Will give it a try, too and report back...
Assign to me if you feel nagged too much (hopefully not). :-)