Commit 064201ff authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Mark the generated regions of text.

parent e4c0d293
......@@ -407,10 +407,13 @@ void LookupContext::expandClass(Scope *scope,
Name *baseClassName = baseClass->name();
const QList<Symbol *> baseClassCandidates = resolveClass(baseClassName,
classVisibleScopes);
#if 0
if (baseClassCandidates.isEmpty()) {
Overview overview;
qDebug() << "unresolved base class:" << overview.prettyName(baseClassName);
}
#endif
for (int j = 0; j < baseClassCandidates.size(); ++j) {
if (Class *baseClassSymbol = baseClassCandidates.at(j)->asClass())
......
......@@ -530,7 +530,8 @@ Preprocessor::Preprocessor(Client *client, Environment *env)
: client(client),
env(env),
_expand(env),
_result(0)
_result(0),
_markGeneratedTokens(false)
{
resetIfLevel ();
}
......@@ -603,12 +604,12 @@ Preprocessor::State Preprocessor::createStateFromSource(const QByteArray &source
return state;
}
void Preprocessor::processNewline()
void Preprocessor::processNewline(bool force)
{
if (env->currentLine == _dot->lineno)
if (! force && env->currentLine == _dot->lineno)
return;
if (env->currentLine > _dot->lineno) {
if (force || env->currentLine > _dot->lineno) {
_result->append("\n# ");
_result->append(QByteArray::number(_dot->lineno));
_result->append(' ');
......@@ -648,6 +649,50 @@ void Preprocessor::processSkippingBlocks(bool skippingBlocks,
}
}
bool Preprocessor::markGeneratedTokens(bool markGeneratedTokens,
TokenIterator dot)
{
bool previous = _markGeneratedTokens;
_markGeneratedTokens = markGeneratedTokens;
if (previous != _markGeneratedTokens) {
if (! dot)
dot = _dot;
if (_markGeneratedTokens)
_result->append("\n#pragma push(gen)");
else
_result->append("\n#pragma pop(gen)");
processNewline(/*force = */ true);
const char *begin = _source.constBegin();
const char *end = begin;
if (markGeneratedTokens)
end += dot->begin();
else
end += (dot - 1)->end();
const char *it = end - 1;
for (; it != begin - 1; --it) {
if (*it == '\n')
break;
}
++it;
for (; it != end; ++it) {
if (! std::isspace(*it))
_result->append(' ');
else
_result->append(*it);
}
}
return previous;
}
void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &source,
QByteArray *result)
{
......@@ -846,7 +891,9 @@ Macro *Preprocessor::processObjectLikeMacro(TokenIterator identifierToken,
return m;
}
const bool was = markGeneratedTokens(true, identifierToken);
_result->append(tmp);
(void) markGeneratedTokens(was);
return 0;
}
......@@ -859,7 +906,9 @@ void Preprocessor::expandBuiltinMacro(TokenIterator identifierToken,
client->startExpandingMacro(identifierToken->offset,
trivial, spell);
const bool was = markGeneratedTokens(true, identifierToken);
expand(spell, _result);
(void) markGeneratedTokens(was);
if (client)
client->stopExpandingMacro(_dot->offset, trivial);
......@@ -899,7 +948,9 @@ void Preprocessor::expandFunctionLikeMacro(TokenIterator identifierToken,
*m, text, actuals);
}
const bool was = markGeneratedTokens(true, identifierToken);
expand(beginOfText, endOfText, _result);
(void) markGeneratedTokens(was);
if (client)
client->stopExpandingMacro(_dot->offset, *m);
......
......@@ -97,6 +97,8 @@ private:
TokenIterator dot;
};
bool markGeneratedTokens(bool markGeneratedTokens, TokenIterator dot = 0);
void preprocess(const QByteArray &filename,
const QByteArray &source,
QByteArray *result);
......@@ -133,7 +135,7 @@ private:
void collectActualArguments(QVector<MacroArgumentReference> *actuals);
MacroArgumentReference collectOneActualArgument();
void processNewline();
void processNewline(bool force = false);
void processSkippingBlocks(bool skippingBlocks,
TokenIterator dot, TokenIterator lastToken);
......@@ -179,6 +181,7 @@ private:
TokenIterator _dot;
QByteArray *_result;
bool _markGeneratedTokens;
};
} // namespace CPlusPlus
......
......@@ -370,8 +370,7 @@ void CPPEditor::jumpToMethod(int)
return;
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory(true);
int line = symbol->line();
gotoLine(line);
openEditorAt(symbol);
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory();
setFocus();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment