Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: scarphin on February 27, 2012, 12:29:39 pm

Title: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 27, 2012, 12:29:39 pm
I've recently discovered what 'user keyword' in syntax highlighting is used for. From what understand it highlights the entries in 'keywords' sets but it doesn't highlight the 3rd set and the sets after the 3rd. Is there a specific reason for this? There is the option 'keyword sets to additionally include' under the code completion settings, does that got anything to do with highlighting?

I can't get code completion work with function arguments like the 'param1, param2' in the code below, anything wrong by my side?
Code
void func1(int param1, int param2)
{
... // Can't get code completion work with param1, param2 here!
}
I can't get it work with the standard library also. Like say cout for example, it doesn't kick in after the dot when I type 'cout.' . I'm guessing it doesn't parse the header (i.e. <iostream>) files. How can I manage that?
Thnx...

OS: Win7
CB: Feb 11 nightly svn 7790
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: MortenMacFly on February 27, 2012, 12:54:47 pm
I can't get code completion work with function arguments like the 'param1, param2' in the code below, anything wrong by my side?
Code
void func1(int param1, int param2)
{
... // Can't get code completion work with param1, param2 here!
}
I can't get it work with the standard library also.
Works fine here. CC Settings? Steps to reproduce (including creation of project / code)? Did you enable "Debug SmartSense", what do you see?
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 27, 2012, 01:22:19 pm
Deleted the 'default.conf' file, launched CB, created a new 'console project', tested with the code below and still doesn't work. Attached a screen image for the CC settings, they should be the defaults. How do I 'Debug SmartSense' btw?

Code
#include <iostream>

using namespace std;

void testFunction(int, int);

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}


void testFunction(int param1, int param2)
{
    int testVar;

    testVar=param1;
}

[attachment deleted by admin]
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: MortenMacFly on February 27, 2012, 05:04:23 pm
Attached a screen image for the CC settings, they should be the defaults. How do I 'Debug SmartSense' btw?
The C/C++ parser settings are missing. Any please, use an image resource webpage like imageshack, as our forum webspace is limited.

To debug smart sense, see here:
http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#Debug_Smart_Sense_log_output
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 27, 2012, 05:30:04 pm
Sorry linked them below. I still think these settings should be the defaults. I'm going to try 'debug smartsense' with my settings though.

CC settings:
(http://i779.photobucket.com/albums/yy72/scarphin/CCsettings.jpg)

C/C++ Parser settings:
(http://i779.photobucket.com/albums/yy72/scarphin/CPPparser.jpg)

C/C++ Parser settings adv:
(http://i779.photobucket.com/albums/yy72/scarphin/CPPparserAdv.jpg)
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 27, 2012, 06:02:11 pm
Here is the 'debug log' output when I type 'value' in the code below. I'm using the setting 4 letters for CC to launch.
Code
void displayBits(unsigned value)
{
int i;
const int SHIFT= 8* sizeof(unsigned)- 1;
unsigned int mask= (1<< SHIFT);

value        // CC doesn't kick in after I type the 'u' character nor the 'e'!

cout<< setw(10)<< value<< " = ";

for(i=0; i<=SHIFT; i++) {
cout<< (value& mask? '1': '0');
mask>>=1;

if(i% 8== 7)
cout<< ' ';
}// for

cout<< endl;
}// displayBits

Debug Log:
Code
Initialize EditColourSet .....
Initialize EditColourSet: done.
Loading toolbar...
Abbreviations: loaded
AStylePlugin: loaded
Autosave: loaded
AutoVersioning: loaded
BrowseTracker: loaded
BYOGames: loaded
CB_Koders: loaded
Cccc: loaded
ClassWizard: loaded
CodeCompletion: loaded
CodeSnippets: loaded
CodeStat: loaded
Compiler: loaded
copystrings: loaded
CppCheck: loaded
Cscope: loaded
Debugger: loaded
FilesExtensionHandler: loaded
DevPakUpdater: loaded
DoxyBlocks: loaded
cbDragScroll: loaded
EditorTweaks: loaded
EnvVars: loaded
Exporter: loaded
FileManager: loaded
HeaderFixup: loaded
HelpPlugin: loaded
HexEditor: loaded
IncrementalSearch: loaded
cbKeyBinder: loaded
lib_finder: loaded
MouseSap: loaded
NassiShneidermanPlugin: loaded
OpenFilesList: loaded
Profiler: loaded
ProjectsImporter: loaded
RegExTestbed: loaded
ReopenEditor: loaded
ScriptedWizard: loaded
SpellChecker: loaded
SymTab: loaded
ThreadSearch: loaded
ToDoList: loaded
ToolsPlus: loaded
wxSmith: loaded
wxSmithMime: loaded
wxSmithAui: loaded
wxSmithContribItems: loaded
WindowsXPLookNFeel: loaded
Abbreviations plugin activated
Source code formatter (AStyle) plugin activated
Autosave plugin activated
AutoVersioning plugin activated
BrowseTracker plugin activated
BYO Games plugin activated
Koders query plugin activated
Cccc plugin activated
Class wizard plugin activated
Code completion plugin activated
Code snippets plugin activated
Code statistics plugin activated
Added compiler "GNU GCC Compiler"
Updating class browser...
Class browser updated.
Added compiler "Microsoft Visual C++ Toolkit 2003"
Added compiler "Microsoft Visual C++ 2005/2008"
Added compiler "Microsoft Visual C++ 2010"
Added compiler "Borland C++ Compiler (5.5, 5.82)"
Added compiler "Digital Mars Compiler"
Added compiler "OpenWatcom (W32) Compiler"
Added compiler "GNU GCC Compiler for MSP430"
Added compiler "Cygwin GCC"
Added compiler "LCC Compiler"
Added compiler "Intel C/C++ Compiler"
Added compiler "SDCC Compiler"
Added compiler "Tiny C Compiler"
Added compiler "GDC D Compiler"
Added compiler "LLVM D Compiler"
Added compiler "Digital Mars D Compiler"
Added compiler "GNU Fortran Compiler"
Added compiler "G95 Fortran Compiler"
Added compiler "GNU ARM GCC Compiler"
Added compiler "GNU AVR GCC Compiler"
Added compiler "GNU GCC Compiler for PowerPC"
Added compiler "GNU GCC Compiler for TriCore"
Added compiler "TDM GCC Compiler"
Compiler plugin activated
Copy Strings to clipboard plugin activated
CppCheck plugin activated
Cscope plugin activated
Debugger plugin activated
Files extension handler plugin activated
DevPak updater/installer plugin activated
DragScroll plugin activated
Editor Tweaks plugin: Building menu
Editor Tweaks plugin: making the menu 14
EditorTweaks plugin activated
Environment variables plugin activated
Source Exporter plugin activated
FileManager plugin activated
Header Fixup plugin activated
Help plugin plugin activated
HexEditor plugin activated
IncrementalSearch plugin activated
Keyboard shortcuts plugin activated
Library finder plugin activated
MouseSap plugin activated
NassiShneidermanPlugin plugin activated
Open files list plugin activated
Code profiler plugin activated
Foreign projects importer plugin activated
Regular expressions testbed plugin activated
ReopenEditor plugin activated
Project wizard added for 'Empty project'
Project wizard added for 'Fortran application'
Project wizard added for 'Fortran library'
Project wizard added for 'Fortran DLL'
Project wizard added for 'Console application'
Project wizard added for 'D application'
Project wizard added for 'Direct/X project'
Project wizard added for 'Dynamic Link Library'
Project wizard added for 'Kernel Mode Driver'
Project wizard added for 'FLTK project'
Project wizard added for 'GLFW project'
Project wizard added for 'GLUT project'
Project wizard added for 'GTK+ project'
Project wizard added for 'Irrlicht project'
Project wizard added for 'Lightfeather project'
Project wizard added for 'Matlab project'
Project wizard added for 'OpenGL project'
Project wizard added for 'Ogre project'
Project wizard added for 'Code::Blocks plugin'
Project wizard added for 'QT4 project'
Project wizard added for 'SDL project'
Project wizard added for 'SFML project'
Project wizard added for 'SmartWin project'
Project wizard added for 'Static library'
Project wizard added for 'STL port application'
Project wizard added for 'Shared library'
Project wizard added for 'Win32 GUI project'
Project wizard added for 'wxWidgets project'
Build-target wizard added for 'Console'
Build-target wizard added for 'Static library'
Build-target wizard added for 'Dynamic Link Library'
Build-target wizard added for 'wxWidgets'
Project wizard added for 'ARM Project'
Project wizard added for 'AVR Project'
Project wizard added for 'TriCore Project'
Project wizard added for 'PowerPC Project'
Project wizard added for 'MCS51 Project'
File(s) wizard added for 'Empty file'
File(s) wizard added for 'C/C++ source'
File(s) wizard added for 'C/C++ header'
File(s) wizard added for 'Fortran source'
Scripted wizard plugin activated
SpellChecker plugin activated
Symbol Table Plugin plugin activated
ThreadSearch plugin activated
Todo List plugin activated
ToolsPlus plugin activated
wxSmith - MIME plugin plugin activated
wxSmith - Aui plugin activated
wxSmith - Contrib Items plugin activated
Windows XP Look'n'Feel plugin activated
Initializing plugins...
Loading project file...
Parsing project file...
Loading target Debug
Loading target Release
Loading project files...
3 files loaded
Done loading project in 3ms
Project's base path: D:\coding\projects\exCpp\
Project's common toplevel path: D:\coding\projects\exCpp\
Text seems to be pure ASCII!
We use user specified encoding: Windows Western European (CP 1252) (ID: 33)
Final encoding detected: Windows Western European (CP 1252) (ID: 33)
Editor Open
project data set for D:\coding\projects\exCpp\src\main.cpp
Text seems to be pure ASCII!
We use user specified encoding: Windows Western European (CP 1252) (ID: 33)
Final encoding detected: Windows Western European (CP 1252) (ID: 33)
Editor Open
project data set for D:\coding\projects\exCpp\src\class.cpp
Text seems to be pure ASCII!
We use user specified encoding: Windows Western European (CP 1252) (ID: 33)
Final encoding detected: Windows Western European (CP 1252) (ID: 33)
Editor Open
project data set for D:\coding\projects\exCpp\src\class.h
Top Editor: D:\coding\projects\exCpp\src\main.cpp
Caching GCC dir: C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include\c++
Caching GCC dir: C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include\c++\mingw32
Caching GCC dir: C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include\c++\backward
Caching GCC dir: C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include
Caching GCC dir: C:\GNU\MinGW\include
Caching GCC dir: C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include-fixed
Passing list of files to batch-parser.
Header to parse with priority: 'C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include\c++\cstddef'
Header to parse with priority: 'C:\GNU\MinGW\include\w32api.h'
Header to parse with priority: 'C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include\c++\iostream'
Header to parse with priority: 'C:\GNU\MinGW\lib\gcc\mingw32\4.6.1\include\c++\iomanip'
Add 4 priority parsing file(s) for project 'exCpp'...
Added 3 file(s) for project 'exCpp' to batch-parser...
Create new parser for project 'exCpp'
Updating class browser...
Class browser updated.
Starting batch parsing for project 'exCpp'...
Project 'exCpp' parsing stage done!
Project 'exCpp' parsing stage done (100 total parsed files, 4412 tokens in 0 minute(s), 0.488 seconds).
Updating class browser...
Class browser updated.
Re-parsed 1 files.
Starting re-parsing for project 'exCpp'...
Project 'exCpp' parsing stage done (100 total parsed files, 4412 tokens in 0 minute(s), 0.014 seconds).
Updating class browser...
Class browser updated.
MarkItemsByAI_1()
ParseUsingNamespace() Parse file scope for "using namespace"
ParseFunctionArguments() Parse function arguments
FindCurrentFunctionStart() Looking for tokens in 'D:\coding\projects\exCpp\src\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() Current function: 'void displayBits(unsigned)' (at line 53)
FindCurrentFunctionStart() Namespace='', proc='displayBits' (returning 786)
GenerateResultSet() search 'displayBits', parent='Global namespace (id:0, type:(null)), isPrefix=0'
ParseFunctionArguments() + Function match: displayBits
ParseFunctionArguments() Parsing arguments: "unsigned;"
ParseLocalBlock() Parse local block
FindCurrentFunctionStart() Looking for tokens in 'D:\coding\projects\exCpp\src\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() Current function: 'void displayBits(unsigned)' (at line 53)
FindCurrentFunctionStart() Namespace='', proc='displayBits' (returning 786)
ParseLocalBlock() Block:

int i;
const int SHIFT= 8* sizeof(unsigned)- 1;
unsigned int mask= (1<< SHIFT);

valu
ParseLocalBlock() Local tokens:
 + int displayBits::i Parent = displayBits
 + const int displayBits::SHIFT Parent = displayBits
 + unsigned int displayBits::mask Parent = displayBits
AI() =========================================================
AI() Doing AI for ' valu':
FindCurrentFunctionStart() Looking for tokens in 'D:\coding\projects\exCpp\src\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() Current function: 'void displayBits(unsigned)' (at line 53)
FindCurrentFunctionStart() Namespace='', proc='displayBits' (returning 786)
GenerateResultSet() search 'displayBits', parent='Global namespace (id:0, type:(null)), isPrefix=0'
AI() Adding search namespace: Global namespace
BreakUpComponents() Breaking up ' valu'
BreakUpComponents() Found component: 'valu' (SearchText)
BreakUpComponents() Adding component: 'valu'.
ResolveExpression() search scope is 2 result.
search scope: -1
search scope: 3129
ResolveExpression() Looping 0 result.
AI() AI leave, returned 0 results
0 results
Generating tokens list...
Last AI search was global: adding theme keywords in list
No items found.
MarkItemsByAI_1()
ParseUsingNamespace() Parse file scope for "using namespace"
ParseFunctionArguments() Parse function arguments
FindCurrentFunctionStart() Looking for tokens in 'D:\coding\projects\exCpp\src\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() Current function: 'void displayBits(unsigned)' (at line 53)
FindCurrentFunctionStart() Namespace='', proc='displayBits' (returning 786)
GenerateResultSet() search 'displayBits', parent='Global namespace (id:0, type:(null)), isPrefix=0'
ParseFunctionArguments() + Function match: displayBits
ParseFunctionArguments() Parsing arguments: "unsigned;"
ParseLocalBlock() Parse local block
FindCurrentFunctionStart() Looking for tokens in 'D:\coding\projects\exCpp\src\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() Current function: 'void displayBits(unsigned)' (at line 53)
FindCurrentFunctionStart() Namespace='', proc='displayBits' (returning 786)
ParseLocalBlock() Block:

int i;
const int SHIFT= 8* sizeof(unsigned)- 1;
unsigned int mask= (1<< SHIFT);

value
ParseLocalBlock() Local tokens:
 + unsigned int displayBits::mask Parent = displayBits
 + const int displayBits::SHIFT Parent = displayBits
 + int displayBits::i Parent = displayBits
AI() =========================================================
AI() Doing AI for ' value':
FindCurrentFunctionStart() Looking for tokens in 'D:\coding\projects\exCpp\src\main.cpp'
FindCurrentFunctionStart() Found 2 results
FindCurrentFunctionStart() Current function: 'void displayBits(unsigned)' (at line 53)
FindCurrentFunctionStart() Namespace='', proc='displayBits' (returning 786)
GenerateResultSet() search 'displayBits', parent='Global namespace (id:0, type:(null)), isPrefix=0'
AI() Adding search namespace: Global namespace
BreakUpComponents() Breaking up ' value'
BreakUpComponents() Found component: 'value' (SearchText)
BreakUpComponents() Adding component: 'value'.
ResolveExpression() search scope is 2 result.
search scope: -1
search scope: 3129
ResolveExpression() Looping 0 result.
AI() AI leave, returned 0 results
0 results
Generating tokens list...
Last AI search was global: adding theme keywords in list
No items found.
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 28, 2012, 06:30:31 pm
So can anyone at least tell me what am I looking for in that log?
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: MortenMacFly on February 28, 2012, 10:13:07 pm
So can anyone at least tell me what am I looking for in that log?
Give me some time, I am rather busy atm...
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 29, 2012, 09:35:27 am
Ok sorry, I thought I was abandoned. ;) I've made some more tests btw.

I installed the latest nightly on a brand new laptop with Win 7. I can say 'parenthesis mismatch' and 'function arguments' problems still occur on a brand new default installation. I found why I can't get code completion work on function arguments btw. If I type the argument name in the 'function declaration' it works, if I use empty argument names in the declaration it doesn't. Even if the argument names in the declaration and in the definition mismatch, CC works on only the ones defined in function declaration. All 3 test cases below:
Code
#include <iostream>

using namespace std;

void testFunction(int* , int =0);

int main()
{
int *ptrToInt;

testFunction(ptrToInt);

    return 0;
}

void testFunction(int* iPtr, int param2)
{
iPtr; // CC doesn't work here!

cout<< "Test";
}

Code
#include <iostream>

using namespace std;

void testFunction(int* iPtr, int param=0);

int main()
{
int *ptrToInt;

testFunction(ptrToInt);

    return 0;
}

void testFunction(int* iPtr, int param)
{
iPtr; // CC works when argument names declared!

cout<< "Test";
}

Code
#include <iostream>

using namespace std;

void testFunction(int* somePtr, int otherName=0);

int main()
{
int *ptrToInt;

testFunction(ptrToInt);

    return 0;
}

void testFunction(int* iPtr, int param)
{
iPtr; // CC doesn't work with 'iPtr'!
somePtr; // But it works with 'somePtr'!

cout<< "Test";
}
I don't think that's intended, is it? Also is there a way to make the help popup work with function definitions not the declarations?
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: ollydbg on February 29, 2012, 02:45:44 pm
@scarphin (http://forums.codeblocks.org/index.php?action=profile;u=16520), you test case is quite good. thanks.
 I can confirm this bug, so I put it on my todo list. (I'm currently a bit busy :))

The major part is the argument handling, we have some code to strip the function declaration. E.g.
Code
int fff( int a, float b); //This is a declaration

int fff( int c, float d)  //function implementation
{
}
Those two should match. but I'm not sure how it handle the declaration which the parameter identifier is missing like
Code
int fff( int, float);

Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: scarphin on February 29, 2012, 04:00:34 pm
Code
int fff( int a, float b); //This is a declaration

int fff( int c, float d)  //function implementation
{
}
Those two should match.
Yup, they should match for sure but afaik compiler discards the argument names defined in function declarations without any 'match' checking and only cares about the ones defined in function definitions. So the code below is a valid code and can be compiled without any error. Regarding this fact I can't think of any case that argument names in function declarations must have priority.
Code
#include <iostream>

using namespace std;

void testFunction(int* somePtr, int otherName=0); // Declaration.

int main()
{
int *ptrToInt;

testFunction(ptrToInt);

    return 0;
}

void testFunction(int* iPtr, int param) // Definition.
{
iPtr=NULL; // 'iPtr' is the designated name for the 1st argument instead of 'somePtr'!

cout<< "Test";
}

I can't believe that bug lasted that long without being spotted. Or is it a known bug? I guess majority of the CB users define argument names in declarations. ;/
Title: Re: Issues with Syntax Highlighting ans Code Completion
Post by: ollydbg on March 01, 2013, 04:05:18 am
FYI:
Quote
Revision: 8889
Author: ollydbg
Date: 2013-3-1 11:04:22
Message:
*CC: commit patch #3408 to fix bug #18559 (CC doesn't work on function arguments), thanks p2rkw. See some discussion in http://forums.codeblocks.org/index.php/topic,16024.msg108174.html#msg108174.
-------------------------------
M : /trunk/src/plugins/codecompletion/parser/parserthread.cpp