Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
CC plugin interface redesign
oBFusCATed:
What do you want to store in this class? What functions will it has?
Alpha:
Instead of each CC plugin subscribing to editor events, I want this class to register the common ones that most (all) CC plugins would use. This class would then call the appropriate function from the appropriate CC plugin. For example: asking to rebuild the scope toolbar, asking for tooltips, asking for call tips, asking to launch/get data for the autocomple popup, asking for documentation on a symbol.
oBFusCATed:
Ok, then you'll need a manager :)
Another option is to define an interface class and to set the implementation in the Manager.
--- Code: ---struct cbCCManagerInterface
{
};
struct CCManager : cbCCManagerInterface {};
Manager::Get()->SetCCManager(new CCManager)
Manager::Get()->GetCCManager();
--- End code ---
p2rkw:
Last time I rarely use codeblocks, but some time ago I spend some time with CC source code, so I share my thoughts with you :)
Most modern IDEs collects and caches all token's data when it gets selected. Take a look at netbeans or eclipse: you selects token, and in next few moments
all matchig occurences are hightlighted. Rest of token data are probably cached, Why CB doesn't go this way? This may speed up token related operations such as autocomplete, go to definition/declaration, etc Also some kind of "find usages" are faster in those IDEs.
So here is my proposiotnion (I dont have to much time to write rich description, I hope you got the idea):
--- Code: ---struct TokenID;
struct TypeID;
struct TokenInfo{
std::string name;
TypeID typeID;
TypeID parentTypeID;
};
struct TypeInfo{
std::string name;
//std::vector<TypeID> childs, bases, etc...
};
struct CodeComplete{
// callback called when cursor position has been changed
virtual void onCursorPositionChange(int fileID, int cursorPosition);
// returns ID of token at currnet position
virtual TokenID getCurrnetTokenID();
// returns all useful informations about current token
virtual TokenInfo getTokenInfo();
// returns all useful informations about given token
virtual TokenInfo getTokenInfo(TokenID);
// returns all useful informations about given type (class, function, enum)
virtual TypeInfo getTypeInfo(TypeID);
// returs all occurrences of current token in open file
virtual std::vector<int> getOccurrences();
enum AccessBit{
abAll = 0,
abAccessible = 1,
abPrivate = 2,
abProtected = 4,
//etc
};
// returns IDs of members that have specified acces from current token
virtual std::vector<TokenID> getMembers(int accesBit);
int currentPosition;
int currentFileID;
TokenID currentTokenID;
};
--- End code ---
And possible autocomplete implementation:
--- Code: ---// object.mem|ber - '|' as always means caret position, "ber" is a rest of matching member name
TokenInfo ti = cc->getTokenInfo();
cc->setCurrentToken(ti.parentID);
std::vector<TokenID> members = cc->getMembers(abAccessible);
std::string autocomplete;
for(auto mem : members){
TokenInfo memInfo = cc->getTokenInfo(mem);
if(memInfo.name.startsWith(ti.name)) // ti.name == "mem" in this case
autocomplete += memInfo.fullName + "\n";
}
//send autocomplete string to scintilla here
cc->setCurrnetToken(ti.ID);
--- End code ---
Most imporntant thing is that CC doesnt touch UI code at all.
Alpha:
https://github.com/alpha0010/codeblocks_sf/tree/cc_interface
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version