C++: Accept language features in BackwardsScanner et al

Change-Id: Id97ca27fa909979573efca12dc0cd14b28eacd17
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-02-26 09:14:38 +02:00
committed by Orgad Shaneh
parent 1a37605f91
commit d63624afe0
15 changed files with 48 additions and 47 deletions

View File

@@ -286,6 +286,9 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos,
if (function)
function->clear();
const QString fileName = editorWidget->textDocument()->filePath().toString();
const Snapshot snapshot = CppModelManager::instance()->snapshot();
const Document::Ptr document = snapshot.document(fileName);
QTextCursor tc = editorWidget->textCursor();
QString expr = tc.selectedText();
if (expr.isEmpty()) {
@@ -295,21 +298,18 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos,
tc.movePosition(QTextCursor::EndOfWord);
// Fetch the expression's code.
ExpressionUnderCursor expressionUnderCursor;
ExpressionUnderCursor expressionUnderCursor(document ? document->languageFeatures()
: LanguageFeatures::defaultFeatures());
expr = expressionUnderCursor(tc);
}
*column = tc.positionInBlock();
*line = tc.blockNumber() + 1;
if (!expr.isEmpty()) {
QString fileName = editorWidget->textDocument()->filePath().toString();
const Snapshot snapshot = CppModelManager::instance()->snapshot();
if (const Document::Ptr document = snapshot.document(fileName)) {
QString func = document->functionAt(*line, *column, scopeFromLine, scopeToLine);
if (function)
*function = func;
}
if (!expr.isEmpty() && document) {
QString func = document->functionAt(*line, *column, scopeFromLine, scopeToLine);
if (function)
*function = func;
}
return expr;