And what's your problem exactly ? You don't know how to create a list of all variables available in the current scope of the cursor ? This doesn't surprise me, you'll need to write a kind of C++ grammar parser for that
Suppose that user writes
#include <iostream>
#include <iostream>
To copy to clipboard, switch view to plain text mode
After the file is saved, a good IDE should now parse the included file and extract all available classes, symbols and methods (if its not done already). Writing such editor is not trivial task, for example, imagine an user writing an implementation of a method. Depending on the cursor position, you'll need to provide different lists of available variables:
void MyClass::method(){
int x, y;
//pos1 - all symbols from global scope, MyClass scope, and variables x,y
{
#ifdef SYMBOL_1
int scopedVar;
// pos2 - all symbols from pos1 and scopedVar, but only if SYMBOL_1 is defined !
...
#else
...
#endif
}
}
void MyClass::method(){
int x, y;
//pos1 - all symbols from global scope, MyClass scope, and variables x,y
{
#ifdef SYMBOL_1
int scopedVar;
// pos2 - all symbols from pos1 and scopedVar, but only if SYMBOL_1 is defined !
...
#else
...
#endif
}
}
To copy to clipboard, switch view to plain text mode
Ok, but what was your question anyway ?
Bookmarks