forked from qt-creator/qt-creator
CppEditor: Detect changes in a function's exception specification
... so that the light bulb will pop up and let the user change the associated declaration or definition. Fixes: QTCREATORBUG-23895 Change-Id: I71032d81782b6d0bef929ecfa837eda2f5caec09 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -939,6 +939,30 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
|
||||
}
|
||||
}
|
||||
|
||||
// sync noexcept/throw()
|
||||
const QString exceptionSpecTarget = targetFunction->exceptionSpecification()
|
||||
? QString::fromUtf8(targetFunction->exceptionSpecification()->chars()) : QString();
|
||||
const QString exceptionSpecNew = newFunction->exceptionSpecification()
|
||||
? QString::fromUtf8(newFunction->exceptionSpecification()->chars()) : QString();
|
||||
if (exceptionSpecTarget != exceptionSpecNew) {
|
||||
if (!exceptionSpecTarget.isEmpty() && !exceptionSpecNew.isEmpty()) {
|
||||
changes.replace(targetFile->range(targetFunctionDeclarator->exception_specification),
|
||||
exceptionSpecNew);
|
||||
} else if (exceptionSpecTarget.isEmpty()) {
|
||||
int previousToken = targetFunctionDeclarator->ref_qualifier_token;
|
||||
if (!previousToken) {
|
||||
const SpecifierListAST *cvList = targetFunctionDeclarator->cv_qualifier_list;
|
||||
if (cvList && cvList->lastValue()->asSimpleSpecifier())
|
||||
previousToken = cvList->lastValue()->asSimpleSpecifier()->specifier_token;
|
||||
}
|
||||
if (!previousToken)
|
||||
previousToken = targetFunctionDeclarator->rparen_token;
|
||||
changes.insert(targetFile->endOf(previousToken), ' ' + exceptionSpecNew);
|
||||
} else if (!exceptionSpecTarget.isEmpty()) {
|
||||
changes.remove(targetFile->range(targetFunctionDeclarator->exception_specification));
|
||||
}
|
||||
}
|
||||
|
||||
if (targetOffset != -1) {
|
||||
// move all change operations to have the right start offset
|
||||
const int moveAmount = targetOffset - targetFile->startOf(targetDeclaration);
|
||||
|
Reference in New Issue
Block a user