forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/2.8'
Conflicts: qtcreator.pri qtcreator.qbs src/libs/extensionsystem/pluginmanager.cpp src/plugins/coreplugin/documentmanager.cpp src/plugins/fakevim/fakevimhandler.cpp Change-Id: Ibc2adc40bad6f10df94c50d66e78dc3f4bcb84c0
This commit is contained in:
@@ -464,6 +464,57 @@ void Document::setGlobalNamespace(Namespace *globalNamespace)
|
||||
_globalNamespace = globalNamespace;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Extract the function name including scope at the given position.
|
||||
*
|
||||
* Note that a function (scope) starts at the name of that function, not at the return type. The
|
||||
* implication is that this method will return an empty string when the line/column is on the
|
||||
* return type.
|
||||
*
|
||||
* \param line the line number, starting with line 1
|
||||
* \param column the column number, starting with column 1
|
||||
*/
|
||||
QString Document::functionAt(int line, int column) const
|
||||
{
|
||||
if (line < 1 || column < 1)
|
||||
return QString();
|
||||
|
||||
CPlusPlus::Symbol *symbol = lastVisibleSymbolAt(line, column);
|
||||
if (!symbol)
|
||||
return QString();
|
||||
|
||||
// Find the enclosing function scope (which might be several levels up, or we might be standing
|
||||
// on it)
|
||||
Scope *scope;
|
||||
if (symbol->isScope())
|
||||
scope = symbol->asScope();
|
||||
else
|
||||
scope = symbol->enclosingScope();
|
||||
|
||||
while (scope && !scope->isFunction() )
|
||||
scope = scope->enclosingScope();
|
||||
|
||||
if (!scope)
|
||||
return QString();
|
||||
|
||||
// We found the function scope, extract its name.
|
||||
const Overview o;
|
||||
QString rc = o.prettyName(scope->name());
|
||||
|
||||
// Prepend namespace "Foo::Foo::foo()" up to empty root namespace
|
||||
for (const Symbol *owner = scope->enclosingNamespace();
|
||||
owner; owner = owner->enclosingNamespace()) {
|
||||
const QString name = o.prettyName(owner->name());
|
||||
if (name.isEmpty()) {
|
||||
break;
|
||||
} else {
|
||||
rc.prepend(QLatin1String("::"));
|
||||
rc.prepend(name);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Scope *Document::scopeAt(unsigned line, unsigned column)
|
||||
{
|
||||
FindScopeAt findScopeAt(_translationUnit, line, column);
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
QList<Macro> definedMacros() const
|
||||
{ return _definedMacros; }
|
||||
|
||||
QString functionAt(int line, int column) const;
|
||||
Symbol *lastVisibleSymbolAt(unsigned line, unsigned column = 0) const;
|
||||
Scope *scopeAt(unsigned line, unsigned column = 0);
|
||||
|
||||
|
||||
@@ -1332,19 +1332,6 @@ void Preprocessor::synchronizeOutputLines(const PPToken &tk, bool forceLine)
|
||||
adjustForCommentOrStringNewlines(&m_env->currentLine, tk);
|
||||
}
|
||||
|
||||
void Preprocessor::removeTrailingOutputLines()
|
||||
{
|
||||
QByteArray &buffer = currentOutputBuffer();
|
||||
int i = buffer.size() - 1;
|
||||
while (i >= 0 && buffer.at(i) == '\n')
|
||||
--i;
|
||||
const int mightChop = buffer.size() - i - 1;
|
||||
if (mightChop > 1) {
|
||||
// Keep one new line at end.
|
||||
buffer.chop(mightChop - 1);
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t Preprocessor::computeDistance(const Preprocessor::PPToken &tk, bool forceTillLine)
|
||||
{
|
||||
// Find previous non-space character or line begin.
|
||||
@@ -1450,8 +1437,6 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
|
||||
|
||||
} while (tk.isNot(T_EOF_SYMBOL));
|
||||
|
||||
removeTrailingOutputLines();
|
||||
|
||||
if (includeGuardMacroName) {
|
||||
if (m_state.m_includeGuardState == State::IncludeGuardState_AfterDefine
|
||||
|| m_state.m_includeGuardState == State::IncludeGuardState_AfterEndif)
|
||||
@@ -1915,8 +1900,6 @@ void Preprocessor::handleEndIfDirective(PPToken *tk, const PPToken £Token)
|
||||
|
||||
void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk)
|
||||
{
|
||||
static const QByteArray qCreatorRun("Q_CREATOR_RUN");
|
||||
|
||||
lex(tk); // consume "ifdef" token
|
||||
if (tk->is(T_IDENTIFIER)) {
|
||||
if (checkUndefined && m_state.m_ifLevel == 0)
|
||||
@@ -1937,8 +1920,6 @@ void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk)
|
||||
}
|
||||
} else if (m_env->isBuiltinMacro(macroName)) {
|
||||
value = true;
|
||||
} else if (macroName == qCreatorRun) {
|
||||
value = true;
|
||||
}
|
||||
|
||||
if (checkUndefined)
|
||||
|
||||
@@ -237,7 +237,6 @@ private:
|
||||
void maybeStartOutputLine();
|
||||
void generateOutputLineMarker(unsigned lineno);
|
||||
void synchronizeOutputLines(const PPToken &tk, bool forceLine = false);
|
||||
void removeTrailingOutputLines();
|
||||
|
||||
void enforceSpacing(const PPToken &tk, bool forceSpacing = false);
|
||||
static std::size_t computeDistance(const PPToken &tk, bool forceTillLine = false);
|
||||
|
||||
Reference in New Issue
Block a user