Commit 69edf1e2 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

CppEditor: Use correct language features in Follow Symbol



Change-Id: If4adc4153341ac63bd5566a66ccf177ae4e536e1
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 88ee2bfb
......@@ -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();
......
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