Refactoring CodeHighlightingInstance

Milian Wolff mail at milianw.de
Fri Dec 10 20:10:37 UTC 2010


Hey David,

I need to do some changes to CodeHighlightingInstance, as it is not good for 
languages such as PHP:

a) I want rainbow colors for global variables, since you can write scripts 
(and often do) that don't use functions.

b) I don't want rainbow colorization for functions / classes / ... whatever 
inside functions. Yes that's possible in PHP, don't blame me :)

c) I want alias declarations to use the same color everywhere.

I have multiple ideas on how to solve that:

somewhat working but imo hackish and dirty version:

a) overload highlightDeclaration and highlightUse and do some black magic that 
essentially copies the "rainbow colorize local declarations" part for 
namespace and top context variable declarations.

b) check isFunctionDeclaration in KDevplatform for the local declarations and 
don't apply rainbow colors in that case

c) check for alias declarations in KDevplatform for the local declarations 
(and also in my black magic code above) and use the color in 
m_functionColorsForDeclarations[aliasedDeclaration->context] if it exists.

or alternatively: try to refactor the whole class to make such cases simpler 
to overload and configure on a per language basis. I've yet to find out how 
though, the simplest would of course be something like

virtual bool useRainbowColor(Declaration* dec) const;

and call that for every use and declaration in *all* contexts... I'm not sure 
how much of a difference this would make speedwise, I think I'll try it out.

Ideas?

Bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20101210/4124d135/attachment.sig>


More information about the KDevelop-devel mailing list