Commit 9f94a8b3 authored by Nikolai Kosjar's avatar Nikolai Kosjar

C++: Slim down SemanticInfo

Remove SemanticInfo::hasD and SemanticInfo::hasQ. They were used in
CPPEditorWidget::highlightUses() but became superfluous by filtering out
invalid Uses.

Change-Id: I08f46e55cf42fbc6088fbcb03e30822421df57d6
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent c6291db9
......@@ -1006,8 +1006,7 @@ void CPPEditorWidget::updateOutlineIndex()
}
void CPPEditorWidget::highlightUses(const QList<SemanticInfo::Use> &uses,
const SemanticInfo &semanticInfo,
QList<QTextEdit::ExtraSelection> *selections)
QList<QTextEdit::ExtraSelection> *selections)
{
bool isUnused = false;
......@@ -1031,14 +1030,6 @@ void CPPEditorWidget::highlightUses(const QList<SemanticInfo::Use> &uses,
sel.cursor.setPosition(anchor);
sel.cursor.setPosition(position, QTextCursor::KeepAnchor);
if (isUnused) {
if (semanticInfo.hasQ && sel.cursor.selectedText() == QLatin1String("q"))
continue; // skip q
else if (semanticInfo.hasD && sel.cursor.selectedText() == QLatin1String("d"))
continue; // skip d
}
selections->append(sel);
}
}
......@@ -1965,10 +1956,10 @@ void CPPEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
if (uses.size() == 1) {
if (!CppTools::isOwnershipRAIIType(it.key(), context)) {
// it's an unused declaration
highlightUses(uses, semanticInfo, &unusedSelections);
highlightUses(uses, &unusedSelections);
}
} else if (good && m_renameSelections.isEmpty()) {
highlightUses(uses, semanticInfo, &m_renameSelections);
highlightUses(uses, &m_renameSelections);
}
}
......@@ -2228,8 +2219,6 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
const LocalSymbols useTable(semanticInfo.doc, currentFunctionDefinition);
semanticInfo.revision = source.revision;
semanticInfo.localUses = useTable.uses;
semanticInfo.hasQ = useTable.hasQ;
semanticInfo.hasD = useTable.hasD;
}
return semanticInfo;
......
......@@ -262,7 +262,6 @@ private:
SemanticHighlighter::Source currentSource(bool force = false);
void highlightUses(const QList<TextEditor::SemanticHighlighter::Result> &uses,
const CppTools::SemanticInfo &semanticInfo,
QList<QTextEdit::ExtraSelection> *selections);
void createToolBar(CPPEditor *editable);
......
......@@ -51,13 +51,11 @@ class FindLocalSymbols: protected ASTVisitor
public:
FindLocalSymbols(Document::Ptr doc)
: ASTVisitor(doc->translationUnit()), _doc(doc), hasD(false), hasQ(false)
: ASTVisitor(doc->translationUnit()), _doc(doc)
{ }
// local and external uses.
SemanticInfo::LocalUseMap localUses;
bool hasD;
bool hasQ;
void operator()(DeclarationAST *ast)
{
......@@ -169,16 +167,6 @@ protected:
return true;
}
virtual bool visit(QtMemberDeclarationAST *ast)
{
if (tokenKind(ast->q_token) == T_Q_D)
hasD = true;
else
hasQ = true;
return true;
}
virtual bool visit(FunctionDefinitionAST *ast)
{
if (ast->symbol)
......@@ -313,7 +301,5 @@ LocalSymbols::LocalSymbols(CPlusPlus::Document::Ptr doc, CPlusPlus::DeclarationA
{
FindLocalSymbols findLocalSymbols(doc);
findLocalSymbols(ast);
hasD = findLocalSymbols.hasD;
hasQ = findLocalSymbols.hasQ;
uses = findLocalSymbols.localUses;
}
......@@ -45,8 +45,6 @@ class CPPTOOLS_EXPORT LocalSymbols
public:
LocalSymbols(CPlusPlus::Document::Ptr doc, CPlusPlus::DeclarationAST *ast);
bool hasD;
bool hasQ;
SemanticInfo::LocalUseMap uses;
};
......
......@@ -32,6 +32,6 @@
using namespace CppTools;
SemanticInfo::SemanticInfo()
: revision(0), hasQ(false), hasD(false), forced(false)
: revision(0), forced(false)
{
}
......@@ -62,8 +62,6 @@ public:
SemanticInfo();
unsigned revision;
bool hasQ: 1;
bool hasD: 1;
bool forced: 1;
CPlusPlus::Snapshot snapshot;
CPlusPlus::Document::Ptr doc;
......
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