[Qt-creator] Need help understanding some qt-creator source
Erik Verbruggen
erik.verbruggen at me.com
Tue Sep 10 16:28:42 CEST 2013
On Sep 10, 2013, at 14:57, Simon Schäfer <simonschaefer at posteo.de> wrote:
> Hello
>
> I try to understand some of the code of the creator, because I would
> like to remove it, it is the reason of a bug (QTCREATORBUG-8036, it
> still effects master) that annoys me. I can't figure out what it is used
> for. The code I am talking about is in pp-engine.cpp:
>
> bool Preprocessor::handleIdentifier(PPToken *tk)
>
> There the representations of some preprocessor macros are internally
> replaced by their meanings. For Example __LINE__ is replaced by the text
> "9". This leads to strange behaviour for highlighting and even
> re-factoring, because the editor determines the length of a token not by
> the space it uses in the view but by the length of its text. So for the
> above example the length is 1 instead of 8.
>
> The following example code can help you understand the Problem:
>
> <snip>
> #include <QCoreApplication> // line 1
>
> #include <QDebug>
>
> int main(int argc, char *argv[])
> {
> int abcd = 0;
>
> qDebug () << __LINE__ << abcd; // line 9
> qDebug () << __LINE__ << abcd; // line 10
> return 0;
> }
> <snap>
>
> If you click on abcd it will highlight a block of 4 chars within the
> first __LINE__ and another block of 4 in the second __LINE__ (moved one
> to the right). If you now use "Rename Symbol under cursor" and type
> abcde strange stuff happens.
>
> My basic question is why are those Preprocessor texts used instead of
> the displayed texts?
Um, because semantic highlighting uses information from the parser to find out that a piece of text is an identifier, and actually the identifier it needs to highlight? Or did I misunderstand the question?
-- Erik.
More information about the Qt-creator
mailing list