forked from qt-creator/qt-creator
Revert "Introduced a token cache for the C++ editor."
This reverts commit c2393df023.
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
#include <utils/faketooltip.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtGui/QAction>
|
||||
@@ -453,8 +454,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)
|
||||
{
|
||||
@@ -547,7 +547,7 @@ 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;
|
||||
@@ -555,7 +555,7 @@ static int startOfOperator(TokenCache *tokenCache,
|
||||
}
|
||||
|
||||
static CPlusPlus::TokenUnderCursor tokenUnderCursor;
|
||||
const SimpleToken tk = tokenUnderCursor(tokenCache, tc);
|
||||
const SimpleToken tk = tokenUnderCursor(tc);
|
||||
|
||||
if (completionKind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) {
|
||||
completionKind = T_EOF_SYMBOL;
|
||||
@@ -634,10 +634,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());
|
||||
@@ -685,8 +684,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);
|
||||
|
||||
@@ -727,7 +725,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) {
|
||||
@@ -802,13 +800,13 @@ int CppCodeCompletion::startCompletionInternal(TextEditor::BaseTextEditor *edit,
|
||||
}
|
||||
}
|
||||
|
||||
// if (debug)
|
||||
// qDebug() << "scope:" << scope->owner()->fileName() << scope->owner()->line() << scope->owner()->column();
|
||||
if (debug)
|
||||
qDebug() << "scope:" << scope->owner()->fileName() << scope->owner()->line() << scope->owner()->column();
|
||||
|
||||
QList<LookupItem> results = typeOfExpression(expression, scope, TypeOfExpression::Preprocess);
|
||||
|
||||
// if (debug)
|
||||
// qDebug() << "got:" << results.size() << "results";
|
||||
if (debug)
|
||||
qDebug() << "got:" << results.size() << "results";
|
||||
|
||||
if (results.isEmpty()) {
|
||||
if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) {
|
||||
@@ -830,8 +828,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
|
||||
@@ -1087,8 +1084,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
|
||||
@@ -1147,8 +1143,8 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults)
|
||||
{
|
||||
const LookupContext &context = typeOfExpression.context();
|
||||
|
||||
// if (debug)
|
||||
// qDebug() << Q_FUNC_INFO << __LINE__;
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << __LINE__;
|
||||
|
||||
if (baseResults.isEmpty())
|
||||
return false;
|
||||
@@ -1160,8 +1156,8 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults)
|
||||
if (ClassOrNamespace *binding = resolveExpression.baseExpression(baseResults,
|
||||
m_completionOperator,
|
||||
&replacedDotOperator)) {
|
||||
// if (debug)
|
||||
// qDebug() << "cool we got a binding for the base expression";
|
||||
if (debug)
|
||||
qDebug() << "cool we got a binding for the base expression";
|
||||
|
||||
if (replacedDotOperator && binding) {
|
||||
// Replace . with ->
|
||||
@@ -1177,10 +1173,10 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults)
|
||||
return ! m_completions.isEmpty();
|
||||
}
|
||||
|
||||
// if (debug) {
|
||||
// Overview oo;
|
||||
// qDebug() << "hmm, got:" << oo(baseResults.first().type());
|
||||
// }
|
||||
if (debug) {
|
||||
Overview oo;
|
||||
qDebug() << "hmm, got:" << oo(baseResults.first().type());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -962,9 +962,6 @@ bool CppModelManager::isCppEditor(Core::IEditor *editor) const
|
||||
return editor->context().contains(uid);
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
@@ -40,25 +40,16 @@
|
||||
|
||||
namespace CPlusPlus {
|
||||
class LookupContext;
|
||||
class TokenCache;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Project;
|
||||
}
|
||||
|
||||
namespace TextEditor {
|
||||
class ITextEditor;
|
||||
}
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class AbstractEditorSupport;
|
||||
|
||||
namespace Internal {
|
||||
class CppEditorSupport;
|
||||
}
|
||||
|
||||
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -139,8 +130,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);
|
||||
|
||||
|
||||
@@ -67,12 +67,8 @@ 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 {
|
||||
if (! _textEditor)
|
||||
return;
|
||||
}
|
||||
|
||||
connect(_textEditor, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
|
||||
connect(this, SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
|
||||
@@ -100,11 +96,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