Bug 38405

Summary: Problem with syntax highlighting of preprocessor directives
Product: [Tools] CDT Reporter: Victor Mozgin <victor.mozgin>
Component: cdt-coreAssignee: Alain Magloire <alain>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 Keywords: contributed
Version: 2.0   
Target Milestone: 1.2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch bjorn.freeman-benson: iplog+

Description Victor Mozgin CLA 2003-06-04 06:50:01 EDT
Syntax highlighting of preprocessor directives doesn't handle whitespaces 
around # sign (internal parser seems to work fine, though). And some people 
write conditional code like this:
 
#ifdef blabla
#    define A
#endif
 
or
 
#ifdef blabla
    #define A
#endif

In these examples, second #define is not highlighted in C/C++ editors.
Comment 1 Victor Mozgin CLA 2003-06-04 06:54:25 EDT
Created attachment 5053 [details]
Patch

   I've patched UI code to add a new rule for handling preprocessor directives,
PreprocessorRule class (extends WordRule). And here I noticed that
CppCodeScanner uses private class CWordRule, while CCodeScanner uses standard
WordRule. They seem to do exactly the same thing, but CWordRule additionally
checks for # sign to be the first character on the line.  As now preprocessor
directives are handled by PreprocessorRule class, CWordRule can be removed and
replaced with WordRule; also, there is no need for CWordDetector to pick up #
sign as a valid word start.
Comment 2 Alain Magloire CLA 2003-06-04 15:43:26 EDT
Patch applied.
status flip to Fixed