forked from qt-creator/qt-creator
Removed the TokenCache.
This commit is contained in:
@@ -452,8 +452,7 @@ QIcon CppCodeCompletion::iconForSymbol(Symbol *symbol) const
|
||||
/*
|
||||
Searches backwards for an access operator.
|
||||
*/
|
||||
static int startOfOperator(TokenCache *tokenCache,
|
||||
TextEditor::ITextEditable *editor,
|
||||
static int startOfOperator(TextEditor::ITextEditable *editor,
|
||||
int pos, unsigned *kind,
|
||||
bool wantFunctionCall)
|
||||
{
|
||||
@@ -546,14 +545,19 @@ static int startOfOperator(TokenCache *tokenCache,
|
||||
}
|
||||
|
||||
if (completionKind == T_COMMA) {
|
||||
ExpressionUnderCursor expressionUnderCursor(tokenCache);
|
||||
ExpressionUnderCursor expressionUnderCursor;
|
||||
if (expressionUnderCursor.startOfFunctionCall(tc) == -1) {
|
||||
completionKind = T_EOF_SYMBOL;
|
||||
start = pos;
|
||||
}
|
||||
}
|
||||
|
||||
const SimpleToken tk = tokenCache->tokenUnderCursor(tc);
|
||||
SimpleLexer tokenize;
|
||||
tokenize.setQtMocRunEnabled(true);
|
||||
tokenize.setSkipComments(false);
|
||||
const QList<SimpleToken> &tokens = tokenize(tc.block().text());
|
||||
const int tokenIdx = SimpleLexer::tokenAt(tokens, tc.positionInBlock());
|
||||
const SimpleToken &tk = (tokenIdx == -1) ? SimpleToken() : tokens.at(tokenIdx);
|
||||
|
||||
if (completionKind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) {
|
||||
completionKind = T_EOF_SYMBOL;
|
||||
@@ -573,7 +577,6 @@ static int startOfOperator(TokenCache *tokenCache,
|
||||
start = pos;
|
||||
}
|
||||
else if (completionKind == T_LPAREN) {
|
||||
const QList<SimpleToken> &tokens = tokenCache->tokensForBlock(tc.block());
|
||||
int i = 0;
|
||||
for (; i < tokens.size(); ++i) {
|
||||
const SimpleToken &token = tokens.at(i);
|
||||
@@ -595,11 +598,12 @@ static int startOfOperator(TokenCache *tokenCache,
|
||||
// Check for include preprocessor directive
|
||||
else if (completionKind == T_STRING_LITERAL || completionKind == T_ANGLE_STRING_LITERAL || completionKind == T_SLASH) {
|
||||
bool include = false;
|
||||
const QList<SimpleToken> &tokens = tokenCache->tokensForBlock(tc.block());
|
||||
if (tokens.size() >= 3) {
|
||||
if (tokens.at(0).is(T_POUND) && tokens.at(1).is(T_IDENTIFIER) && (tokens.at(2).is(T_STRING_LITERAL) ||
|
||||
tokens.at(2).is(T_ANGLE_STRING_LITERAL))) {
|
||||
QString directive = tokenCache->text(tc.block(), 1);
|
||||
const SimpleToken &directiveToken = tokens.at(1);
|
||||
QString directive = tc.block().text().mid(directiveToken.position(),
|
||||
directiveToken.length());
|
||||
if (directive == QLatin1String("include") ||
|
||||
directive == QLatin1String("include_next") ||
|
||||
directive == QLatin1String("import")) {
|
||||
@@ -632,10 +636,9 @@ int CppCodeCompletion::startPosition() const
|
||||
bool CppCodeCompletion::triggersCompletion(TextEditor::ITextEditable *editor)
|
||||
{
|
||||
const int pos = editor->position();
|
||||
TokenCache *tokenCache = m_manager->tokenCache(editor);
|
||||
unsigned token = T_EOF_SYMBOL;
|
||||
|
||||
if (startOfOperator(tokenCache, editor, pos, &token, /*want function call=*/ true) != pos) {
|
||||
if (startOfOperator(editor, pos, &token, /*want function call=*/ true) != pos) {
|
||||
if (token == T_POUND) {
|
||||
if (TextEditor::BaseTextEditor *edit = qobject_cast<TextEditor::BaseTextEditor *>(editor->widget())) {
|
||||
QTextCursor tc(edit->document());
|
||||
@@ -683,8 +686,7 @@ int CppCodeCompletion::startCompletionHelper(TextEditor::ITextEditable *editor)
|
||||
while (editor->characterAt(endOfOperator - 1).isSpace())
|
||||
--endOfOperator;
|
||||
|
||||
TokenCache *tokenCache = m_manager->tokenCache(editor);
|
||||
int endOfExpression = startOfOperator(tokenCache, editor, endOfOperator,
|
||||
int endOfExpression = startOfOperator(editor, endOfOperator,
|
||||
&m_completionOperator,
|
||||
/*want function call =*/ true);
|
||||
|
||||
@@ -725,7 +727,7 @@ int CppCodeCompletion::startCompletionHelper(TextEditor::ITextEditable *editor)
|
||||
return m_startPosition;
|
||||
}
|
||||
|
||||
ExpressionUnderCursor expressionUnderCursor(m_manager->tokenCache(editor));
|
||||
ExpressionUnderCursor expressionUnderCursor;
|
||||
QTextCursor tc(edit->document());
|
||||
|
||||
if (m_completionOperator == T_COMMA) {
|
||||
@@ -822,8 +824,7 @@ int CppCodeCompletion::startCompletionInternal(TextEditor::BaseTextEditor *edit,
|
||||
QTextCursor tc(edit->document());
|
||||
tc.setPosition(index);
|
||||
|
||||
TokenCache *tokenCache = m_manager->tokenCache(edit->editableInterface());
|
||||
ExpressionUnderCursor expressionUnderCursor(tokenCache);
|
||||
ExpressionUnderCursor expressionUnderCursor;
|
||||
const QString baseExpression = expressionUnderCursor(tc);
|
||||
|
||||
// Resolve the type of this expression
|
||||
@@ -1079,8 +1080,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r
|
||||
|
||||
QTextCursor tc(edit->document());
|
||||
tc.setPosition(endOfExpression);
|
||||
TokenCache *tokenCache = m_manager->tokenCache(m_editor);
|
||||
BackwardsScanner bs(tokenCache, tc);
|
||||
BackwardsScanner bs(tc);
|
||||
const int startToken = bs.startToken();
|
||||
const int lineStartToken = bs.startOfLine(startToken);
|
||||
// make sure the required tokens are actually available
|
||||
|
||||
@@ -959,11 +959,6 @@ bool CppModelManager::isCppEditor(Core::IEditor *editor) const
|
||||
return editor->context().contains(ProjectExplorer::Constants::LANG_CXX);
|
||||
}
|
||||
|
||||
TokenCache *CppModelManager::tokenCache(TextEditor::ITextEditor *editor) const
|
||||
{
|
||||
return editorSupport(editor)->tokenCache();
|
||||
}
|
||||
|
||||
void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
|
||||
{
|
||||
emit documentUpdated(doc);
|
||||
|
||||
@@ -108,8 +108,6 @@ public:
|
||||
CppEditorSupport *editorSupport(TextEditor::ITextEditor *editor) const
|
||||
{ return m_editorSupport.value(editor); }
|
||||
|
||||
virtual CPlusPlus::TokenCache *tokenCache(TextEditor::ITextEditor *editor) const;
|
||||
|
||||
void emitDocumentUpdated(CPlusPlus::Document::Ptr doc);
|
||||
|
||||
void stopEditorSelectionsUpdate()
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace Core {
|
||||
|
||||
namespace CPlusPlus {
|
||||
class LookupContext;
|
||||
class TokenCache;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -145,8 +144,6 @@ public:
|
||||
|
||||
virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0;
|
||||
|
||||
virtual CPlusPlus::TokenCache *tokenCache(TextEditor::ITextEditor *editor) const = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void documentUpdated(CPlusPlus::Document::Ptr doc);
|
||||
|
||||
|
||||
@@ -68,16 +68,11 @@ void CppEditorSupport::setTextEditor(TextEditor::ITextEditor *textEditor)
|
||||
_textEditor = textEditor;
|
||||
|
||||
if (_textEditor) {
|
||||
if (TextEditor::BaseTextEditor *ed = qobject_cast<TextEditor::BaseTextEditor *>(_textEditor->widget()))
|
||||
_tokenCache.setDocument(ed->document());
|
||||
} else {
|
||||
return;
|
||||
connect(_textEditor, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
|
||||
connect(this, SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
|
||||
|
||||
updateDocument();
|
||||
}
|
||||
|
||||
connect(_textEditor, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
|
||||
connect(this, SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
|
||||
|
||||
updateDocument();
|
||||
}
|
||||
|
||||
QString CppEditorSupport::contents()
|
||||
@@ -100,11 +95,6 @@ unsigned CppEditorSupport::editorRevision() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
TokenCache *CppEditorSupport::tokenCache()
|
||||
{
|
||||
return &_tokenCache;
|
||||
}
|
||||
|
||||
int CppEditorSupport::updateDocumentInterval() const
|
||||
{ return _updateDocumentInterval; }
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QTextCursor>
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cplusplus/TokenCache.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTimer;
|
||||
@@ -73,8 +72,6 @@ public:
|
||||
QString contents();
|
||||
unsigned editorRevision() const;
|
||||
|
||||
CPlusPlus::TokenCache *tokenCache();
|
||||
|
||||
Q_SIGNALS:
|
||||
void contentsChanged();
|
||||
|
||||
@@ -92,7 +89,6 @@ private:
|
||||
QFuture<void> _documentParser;
|
||||
QString _cachedContents;
|
||||
unsigned _revision;
|
||||
CPlusPlus::TokenCache _tokenCache;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user