<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Colski</id>
	<title>Code::Blocks - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Colski"/>
	<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php/Special:Contributions/Colski"/>
	<updated>2026-05-02T15:15:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Code::Completion_Rewrite&amp;diff=5515</id>
		<title>Code::Completion Rewrite</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Code::Completion_Rewrite&amp;diff=5515"/>
		<updated>2008-05-12T16:15:17Z</updated>

		<summary type="html">&lt;p&gt;Colski: /* Hidden virtual functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you'll find some discussion on the Code::Completion rewrite, and some useful links to related materials online.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
The current Code::Completion plug-in has some flaws, and is currently development frozen.&lt;br /&gt;
The current plug-in lacks full support for:&lt;br /&gt;
# function and class templates&lt;br /&gt;
# default arguments in some cases&lt;br /&gt;
# some of the more complicated c++ mucky business&lt;br /&gt;
&lt;br /&gt;
== Current Effort ==&lt;br /&gt;
=== Structure ===&lt;br /&gt;
The current C::C is a monolithic library of features, which could be de-coupled and split up for use in multiple plugins, providing extra functionality and flexibility in the future.&lt;br /&gt;
Therefore, I propose the C::C be broken up into the following components:&lt;br /&gt;
&lt;br /&gt;
* Code::SymbolTable&lt;br /&gt;
** Provide a list of valid symbols in the workspace, along with relevant scope information&lt;br /&gt;
* Code::Completion&lt;br /&gt;
** Provide Auto-complete features&lt;br /&gt;
* Code::SymbolOutline&lt;br /&gt;
** Provide Symbol browser, find symbol, function jump features&lt;br /&gt;
* Code::Refactoring&lt;br /&gt;
** Provide code refactoring features&lt;br /&gt;
* Code::Documentation&lt;br /&gt;
** Provide automatic code generation features&lt;br /&gt;
&lt;br /&gt;
=== Code::Completion ===&lt;br /&gt;
==== Purpose Statement ====&lt;br /&gt;
The current Code::Completion plugin is outdated, and needs a complete rewrite.&lt;br /&gt;
The purpose of the Code::Completion plugin is thus:&lt;br /&gt;
&lt;br /&gt;
* Provide a list of likely symbols in the current scope as possible solutions to the current symbol.&lt;br /&gt;
* Provide function tooltips&lt;br /&gt;
** Parameter list&lt;br /&gt;
** Relevant documentation&lt;br /&gt;
* Provide variable tooltips&lt;br /&gt;
** type and modifiers&lt;br /&gt;
** scope&lt;br /&gt;
* Provide preprocessor tooltips&lt;br /&gt;
** replacement value of a macro&lt;br /&gt;
** parameter list when applicable&lt;br /&gt;
* Provide completion features for class constructors&lt;br /&gt;
* Provide completion features for initializer lists&lt;br /&gt;
&lt;br /&gt;
==== Process ====&lt;br /&gt;
* The user requests a completion of the current symbol.&lt;br /&gt;
** Call CC::EventSymbolHover&lt;br /&gt;
*** When the mouse hovers over a symbol after a timeout&lt;br /&gt;
** Call CC::EventSymbolTip&lt;br /&gt;
*** When the user types in any of the following: . :: -&amp;gt;&lt;br /&gt;
*** When the user presses the keystroke CTRL-SPACE&lt;br /&gt;
** Call CC::EventCallTip&lt;br /&gt;
*** When the user types in any of the following: ( ,&lt;br /&gt;
*** When the user presses the keystroke CTRL-SHIFT-SPACE&lt;br /&gt;
** Call CC::EventPreprocTip&lt;br /&gt;
*** When the user types in any of the following: &amp;lt; &amp;quot; when in preproc context (# at the start of the line)&lt;br /&gt;
* the C::C plugin determines the proper scope, when applicable (global, local, class)&lt;br /&gt;
* Compare the current symbol against the symbol table of proper scope.&lt;br /&gt;
* Provide a composite list to the user.&lt;br /&gt;
&lt;br /&gt;
=== Code::SymbolTable ===&lt;br /&gt;
There will be 3 symbol lists:&lt;br /&gt;
* global namespace&lt;br /&gt;
* local scope (2 options)&lt;br /&gt;
** the local scope can be generated by smartly parsing the current file on every request&lt;br /&gt;
** keep a running count, and add/remove symbols from the table as the file is edited&lt;br /&gt;
* class scope&lt;br /&gt;
&lt;br /&gt;
Here's a good link for further reading on the subject and the problems:&lt;br /&gt;
[http://en.wikipedia.org/wiki/C%2B%2B#Parsing_and_processing_C.2B.2B_source_code On Wikipedia]&lt;br /&gt;
&lt;br /&gt;
==== Data Proposal ====&lt;br /&gt;
&lt;br /&gt;
 class symbol&lt;br /&gt;
 {&lt;br /&gt;
     string name;              // name of the symbol&lt;br /&gt;
     int    id;                // Id of the symbol, should be unique in the workspace&lt;br /&gt;
     int    file_id;           // Id of file where the symbol has been declared&lt;br /&gt;
     int    filepos_begin;     // Position where declaration of the symbol starts&lt;br /&gt;
     int    filepos_end;       // Position where declaration of the symbol ends&lt;br /&gt;
     int    type;              // Type of the symbol: macro / class / typedef / variable / function&lt;br /&gt;
     flags  modifiers;         // Bitfield used to mark some extra properties of symbol&lt;br /&gt;
                               // like that it is static or inline&lt;br /&gt;
     int    value_type_id;     // Id of symbol which represents c++ type of current symbol&lt;br /&gt;
                               // (like type of variable or type of returned value from function)&lt;br /&gt;
     int    extra_type_id;     // Extra type used in some cases&lt;br /&gt;
     list   children;          // List of child elements of this symbol (members in class etc)&lt;br /&gt;
     list   extra_lists[3];    // See table below&lt;br /&gt;
     map    extra_values;      // int -&amp;gt; string map which can keep some extra data&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 class list_entry&lt;br /&gt;
 {&lt;br /&gt;
     int    symbol_id;         // ID of the symbol referenced&lt;br /&gt;
     int    storage_class;     // Storage class of the symbol (private/protected/public)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Explanation of symbol::extra_lists[]&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;3&amp;quot; cellspacing=&amp;quot;0&amp;quot; style=&amp;quot;border: 1px solid gray; border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background: #ececec; border: 1px solid gray;&amp;quot;&lt;br /&gt;
! type&lt;br /&gt;
! modifiers&lt;br /&gt;
! value_type_id&lt;br /&gt;
! extra_type&lt;br /&gt;
! children&lt;br /&gt;
! extra_lists[0]&lt;br /&gt;
! extra_lists[1]&lt;br /&gt;
! extra_lists[2]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| namespace&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| declarations in namespace&lt;br /&gt;
|&amp;quot;using&amp;quot; namespaces&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| class / struct / union&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| members of class&lt;br /&gt;
| base classes&lt;br /&gt;
| template args&lt;br /&gt;
| friends of class&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| variable&lt;br /&gt;
| extern, static, volatile, const&lt;br /&gt;
| type of variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| function&lt;br /&gt;
| static, inline, const ...&lt;br /&gt;
| returned value&lt;br /&gt;
|&lt;br /&gt;
| arguments&lt;br /&gt;
| template arguments&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| typedef&lt;br /&gt;
| pointer, array, reference, pointer_to_member&lt;br /&gt;
| base type&lt;br /&gt;
| type of class in pointer_to_member&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| enum&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| items in enum&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| enum item&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| id of enum&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| macro&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| macro parts&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| macro part&lt;br /&gt;
| arg_to_string, va_args&lt;br /&gt;
| number of arg or -1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Comments:&lt;br /&gt;
* Such representation would require some extra &amp;quot;hidden&amp;quot; symbols - for example when some complex type is returned from function, extra symbol of typedef representing proper value would be required.&lt;br /&gt;
* Also in case of templates, typeid's should be threated in special way - negative value could mean to use template argument instead of some real type. Base types (the POD ones) should have some predefined type ids.&lt;br /&gt;
&lt;br /&gt;
Questions:&lt;br /&gt;
* why are we storing filepos_end? Wouldn't it be much more useful to store declaration, definition info?&lt;br /&gt;
&lt;br /&gt;
== More complex cases of C::C usage ==&lt;br /&gt;
&lt;br /&gt;
Here we can put some more complex examples of c++ code where C::C may fail. Symbols that may be hard to find should be marked in bold&lt;br /&gt;
&lt;br /&gt;
=== Fetching type of operator call ===&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;string&amp;gt;&lt;br /&gt;
 using namespace std;&lt;br /&gt;
 &lt;br /&gt;
 int main(int,char**)&lt;br /&gt;
 {&lt;br /&gt;
     ( string(&amp;quot;first&amp;quot;) + &amp;quot;second&amp;quot; + &amp;quot;third&amp;quot; ) . '''c_str'''();&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Template classes ===&lt;br /&gt;
&lt;br /&gt;
 template&amp;lt;typename T&amp;gt; class Template&lt;br /&gt;
 {&lt;br /&gt;
 public:&lt;br /&gt;
     T&amp;amp; GetInstance() { return m_Instance; }&lt;br /&gt;
 private:&lt;br /&gt;
     T m_Instance;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Parameter&lt;br /&gt;
 {&lt;br /&gt;
 public:&lt;br /&gt;
     void PrintfText() { printf(&amp;quot;Text&amp;quot;); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main(int,char**)&lt;br /&gt;
 {&lt;br /&gt;
     Template&amp;lt;Parameter&amp;gt; Object;&lt;br /&gt;
     Object.GetInstance().'''PrintfText'''();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Automated deduction of template arguments from passed function arguments ===&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Class&lt;br /&gt;
 {&lt;br /&gt;
 	public:&lt;br /&gt;
 		void SomeFunction()  { printf(&amp;quot;SomeFunction\n&amp;quot;); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 template&amp;lt; class T &amp;gt; T&amp;amp; Function( T&amp;amp; arg )&lt;br /&gt;
 {&lt;br /&gt;
 	return arg;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main( int, char** )&lt;br /&gt;
 {&lt;br /&gt;
 	Class f;&lt;br /&gt;
 	Function(f).'''SomeFunction'''();&lt;br /&gt;
 	return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Template arguments for templates ===&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 template&amp;lt; template&amp;lt;class&amp;gt; class InternalTemplate, typename Type &amp;gt; class Test&lt;br /&gt;
 {&lt;br /&gt;
     public:&lt;br /&gt;
 &lt;br /&gt;
         InternalTemplate&amp;lt;Type&amp;gt; m_Member;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 template&amp;lt; class T &amp;gt; class TestInt&lt;br /&gt;
 {&lt;br /&gt;
     public:&lt;br /&gt;
 &lt;br /&gt;
         T m_IntMember;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Class&lt;br /&gt;
 {&lt;br /&gt;
     public:&lt;br /&gt;
 &lt;br /&gt;
         void Print() { printf(&amp;quot;Class::Print\n&amp;quot;); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main( int, char** )&lt;br /&gt;
 {&lt;br /&gt;
     Test&amp;lt;TestInt,Class&amp;gt; Object;&lt;br /&gt;
     Object.m_Member.'''m_IntMember'''.'''Print'''();&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Partial specializations ===&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 template&amp;lt; class T &amp;gt; class Template&lt;br /&gt;
 {&lt;br /&gt;
     public:&lt;br /&gt;
         void Print() { printf(&amp;quot;Generic specialization\n&amp;quot;); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 template&amp;lt;&amp;gt; class Template&amp;lt;float&amp;gt;&lt;br /&gt;
 {&lt;br /&gt;
     public:&lt;br /&gt;
         void PrintFloat() { printf(&amp;quot;Partial specialization\n&amp;quot;); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main(int,char**)&lt;br /&gt;
 {&lt;br /&gt;
     Template&amp;lt;int&amp;gt; TInt;&lt;br /&gt;
     TInt.'''Print'''();         // PrintFloat() should not be available here&lt;br /&gt;
 &lt;br /&gt;
     Template&amp;lt;float&amp;gt; TFloat;&lt;br /&gt;
     TFloat.'''PrintFloat'''();  // Print() should not be available here&lt;br /&gt;
 &lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Advanced template argument deduction ===&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 // Class encapsulating function without arguments&lt;br /&gt;
 class Caller0&lt;br /&gt;
 {&lt;br /&gt;
         void (* m_Func )( void );&lt;br /&gt;
 &lt;br /&gt;
     public:&lt;br /&gt;
 &lt;br /&gt;
         Caller0( void (* Func )( void ) ) : m_Func(Func) {}&lt;br /&gt;
 &lt;br /&gt;
         void Call0() { m_Func(); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 // Template for class encapsulating function with one argument&lt;br /&gt;
 template &amp;lt; class T &amp;gt; class Caller1&lt;br /&gt;
 {&lt;br /&gt;
         void (* m_Func )( T );&lt;br /&gt;
 &lt;br /&gt;
     public:&lt;br /&gt;
 &lt;br /&gt;
         Caller1( void (* Func )( T ) ) : m_Func(Func) {}&lt;br /&gt;
 &lt;br /&gt;
         void Call1() { m_Func( T() ); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 // Template for class encapsulating function with two arguments&lt;br /&gt;
 template &amp;lt; class T1, class T2 &amp;gt; class Caller2&lt;br /&gt;
 {&lt;br /&gt;
         void (* m_Func )( T1, T2 );&lt;br /&gt;
 &lt;br /&gt;
     public:&lt;br /&gt;
 &lt;br /&gt;
         Caller2( void (* Func )( T1, T2 ) ) : m_Func(Func) {}&lt;br /&gt;
 &lt;br /&gt;
         void Call2() { m_Func ( T1(), T2() ); }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 // This one will be used for functions without arguments&lt;br /&gt;
 Caller0 Invoke( void (* Func )( void ) )&lt;br /&gt;
 {&lt;br /&gt;
     return Caller0( Func );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // This one will be used for functions with one argument&lt;br /&gt;
 template &amp;lt; class T &amp;gt; Caller1&amp;lt;T&amp;gt; Invoke( void (* Func )( T ) )&lt;br /&gt;
 {&lt;br /&gt;
     return Caller1&amp;lt;T&amp;gt;( Func );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // This one will be used for functions with two arguments&lt;br /&gt;
 template &amp;lt; class T1, class T2 &amp;gt; Caller2&amp;lt;T1,T2&amp;gt; Invoke( void (* Func )( T1, T2 ) )&lt;br /&gt;
 {&lt;br /&gt;
     return Caller2&amp;lt;T1,T2&amp;gt; ( Func );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Function0(void)&lt;br /&gt;
 {&lt;br /&gt;
     printf(&amp;quot;Function0\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Function1(float)&lt;br /&gt;
 {&lt;br /&gt;
     printf(&amp;quot;Function1\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Function2(int)&lt;br /&gt;
 {&lt;br /&gt;
     printf(&amp;quot;Function2\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Function3(int,float)&lt;br /&gt;
 {&lt;br /&gt;
     printf(&amp;quot;Function3\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main(int,char**)&lt;br /&gt;
 {&lt;br /&gt;
     Invoke( Function0 ).'''Call0'''();&lt;br /&gt;
     Invoke( Function1 ).'''Call1'''();&lt;br /&gt;
     Invoke( Function2 ).'''Call1'''();&lt;br /&gt;
     Invoke( Function3 ).'''Call2'''();&lt;br /&gt;
 &lt;br /&gt;
     Invoke( &amp;amp;Function0 ).'''Call0'''();&lt;br /&gt;
     Invoke( &amp;amp;Function1 ).'''Call1'''();&lt;br /&gt;
     Invoke( &amp;amp;Function2 ).'''Call1'''();&lt;br /&gt;
     Invoke( &amp;amp;Function3 ).'''Call2'''();&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Hidden virtual functions ===&lt;br /&gt;
&lt;br /&gt;
 class Base&lt;br /&gt;
 {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void stam(int);&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Derived : Base&lt;br /&gt;
 {&lt;br /&gt;
 public:&lt;br /&gt;
     void stam(double, int);&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 main()&lt;br /&gt;
 {&lt;br /&gt;
     Base *pBase = new Base;&lt;br /&gt;
     pBase-&amp;gt;'''stam('''&lt;br /&gt;
             ^ Function tip should show stam(int)&lt;br /&gt;
     Derived * pDerived = new Derived;&lt;br /&gt;
     pDerived-&amp;gt;'''stam('''&lt;br /&gt;
                ^ Function tip should show stam(double, int)&lt;br /&gt;
                                           Base::stam(int)&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Macros hiding include files ===&lt;br /&gt;
in header.h&lt;br /&gt;
 int x;&lt;br /&gt;
in main.cpp&lt;br /&gt;
 #define myHeader &amp;quot;header.h&amp;quot;&lt;br /&gt;
 #include myHeader&lt;br /&gt;
 &lt;br /&gt;
 main()&lt;br /&gt;
 {&lt;br /&gt;
     int '''x''';&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Colski</name></author>
	</entry>
</feed>