forked from qt-creator/qt-creator
CppEditor: Use correct language features in Follow Symbol
Change-Id: If4adc4153341ac63bd5566a66ccf177ae4e536e1 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
88ee2bfb64
commit
69edf1e26d
@@ -129,17 +129,10 @@ int SimpleLexer::tokenAt(const Tokens &tokens, unsigned utf16charsOffset)
|
||||
Token SimpleLexer::tokenAt(const QString &text,
|
||||
unsigned utf16charsOffset,
|
||||
int state,
|
||||
bool qtMocRunEnabled)
|
||||
const LanguageFeatures &languageFeatures)
|
||||
{
|
||||
// FIXME: Check default values.
|
||||
LanguageFeatures features;
|
||||
features.qtMocRunEnabled = qtMocRunEnabled;
|
||||
features.qtEnabled = qtMocRunEnabled;
|
||||
features.qtKeywordsEnabled = qtMocRunEnabled;
|
||||
features.objCEnabled = qtMocRunEnabled;
|
||||
features.cxx11Enabled = qtMocRunEnabled;
|
||||
SimpleLexer tokenize;
|
||||
tokenize.setLanguageFeatures(features);
|
||||
tokenize.setLanguageFeatures(languageFeatures);
|
||||
const QVector<Token> tokens = tokenize(text, state);
|
||||
const int tokenIdx = tokenAt(tokens, utf16charsOffset);
|
||||
return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
static Token tokenAt(const QString &text,
|
||||
unsigned utf16charsOffset,
|
||||
int state,
|
||||
bool qtMocRunEnabled = false);
|
||||
const LanguageFeatures &languageFeatures);
|
||||
|
||||
static int tokenBefore(const Tokens &tokens, unsigned utf16charsOffset);
|
||||
|
||||
|
@@ -466,12 +466,9 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs
|
||||
int beginOfToken = 0;
|
||||
int endOfToken = 0;
|
||||
|
||||
LanguageFeatures features;
|
||||
features.qtEnabled = true;
|
||||
features.qtKeywordsEnabled = true;
|
||||
features.qtMocRunEnabled = true;
|
||||
features.objCEnabled = true;
|
||||
features.cxx11Enabled = true;
|
||||
const LanguageFeatures features = documentFromSemanticInfo
|
||||
? documentFromSemanticInfo->languageFeatures()
|
||||
: LanguageFeatures::defaultFeatures();
|
||||
|
||||
SimpleLexer tokenize;
|
||||
tokenize.setLanguageFeatures(features);
|
||||
@@ -564,7 +561,8 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs
|
||||
if (pos > 0 && !isValidIdentifierChar(ch))
|
||||
--pos; // positionInBlock points to a delimiter character.
|
||||
const Token tk = SimpleLexer::tokenAt(block.text(), pos,
|
||||
BackwardsScanner::previousBlockState(block), true);
|
||||
BackwardsScanner::previousBlockState(block),
|
||||
features);
|
||||
|
||||
beginOfToken = block.position() + tk.utf16charsBegin();
|
||||
endOfToken = block.position() + tk.utf16charsEnd();
|
||||
|
@@ -70,7 +70,8 @@ bool GlslCompleter::contextAllowsAutoParentheses(const QTextCursor &cursor,
|
||||
bool GlslCompleter::contextAllowsElectricCharacters(const QTextCursor &cursor) const
|
||||
{
|
||||
const Token tk = SimpleLexer::tokenAt(cursor.block().text(), cursor.positionInBlock(),
|
||||
BackwardsScanner::previousBlockState(cursor.block()));
|
||||
BackwardsScanner::previousBlockState(cursor.block()),
|
||||
LanguageFeatures::defaultFeatures());
|
||||
|
||||
// XXX Duplicated from CppEditor::isInComment to avoid tokenizing twice
|
||||
if (tk.isComment()) {
|
||||
@@ -99,7 +100,8 @@ bool GlslCompleter::contextAllowsElectricCharacters(const QTextCursor &cursor) c
|
||||
bool GlslCompleter::isInComment(const QTextCursor &cursor) const
|
||||
{
|
||||
const Token tk = SimpleLexer::tokenAt(cursor.block().text(), cursor.positionInBlock(),
|
||||
BackwardsScanner::previousBlockState(cursor.block()));
|
||||
BackwardsScanner::previousBlockState(cursor.block()),
|
||||
LanguageFeatures::defaultFeatures());
|
||||
|
||||
if (tk.isComment()) {
|
||||
const unsigned pos = cursor.selectionEnd() - cursor.block().position();
|
||||
|
Reference in New Issue
Block a user