Commit fefd72b2 authored by Roberto Raggi's avatar Roberto Raggi

Introduced CPlusPlus::FindUsages.

parent 83a7e0f5
This diff is collapsed.
** This file is part of Qt Creator
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met:
** If you are unsure which license is appropriate for your use, please
** contact the sales department at
#include "LookupContext.h"
#include "CppDocument.h"
#include "CppBindings.h"
#include "Semantic.h"
#include <ASTVisitor.h>
#include <QtCore/QFutureInterface>
namespace CPlusPlus {
: line(0), col(0), len(0) {}
Usage(const QString &path, int line, const QString &lineText, int col, int len)
: path(path), line(line), lineText(lineText), col(col), len(len) {}
QString path;
int line;
QString lineText;
int col;
int len;
class CPLUSPLUS_EXPORT FindUsages: protected ASTVisitor
FindUsages(Document::Ptr doc, const Snapshot &snapshot, QFutureInterface<Usage> *future);
void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding);
QList<int> operator()(Symbol *symbol, Identifier *id, AST *ast);
using ASTVisitor::visit;
using ASTVisitor::endVisit;
QString matchingLine(const Token &tk) const;
void reportResult(unsigned tokenIndex, const QList<Symbol *> &candidates);
void reportResult(unsigned tokenIndex);
bool checkSymbol(Symbol *symbol) const;
bool checkCandidates(const QList<Symbol *> &candidates) const;
bool checkScope(Symbol *symbol, Symbol *otherSymbol) const;
void checkExpression(unsigned startToken, unsigned endToken);
LookupContext currentContext(AST *ast);
void ensureNameIsValid(NameAST *ast);
virtual bool visit(MemInitializerAST *ast);
virtual bool visit(PostfixExpressionAST *ast);
virtual void endVisit(PostfixExpressionAST *);
virtual bool visit(MemberAccessAST *ast);
virtual bool visit(QualifiedNameAST *ast);
virtual bool visit(EnumeratorAST *ast);
virtual bool visit(SimpleNameAST *ast);
virtual bool visit(DestructorNameAST *ast);
virtual bool visit(TemplateIdAST *ast);
virtual bool visit(ParameterDeclarationAST *ast);
virtual bool visit(ExpressionOrDeclarationStatementAST *ast);
virtual bool visit(FunctionDeclaratorAST *ast);
virtual bool visit(SimpleDeclarationAST *);
virtual void endVisit(SimpleDeclarationAST *);
QFutureInterface<Usage> *_future;
Identifier *_id;
Symbol *_declSymbol;
Document::Ptr _doc;
Snapshot _snapshot;
QByteArray _source;
Document::Ptr _exprDoc;
Semantic _sem;
NamespaceBindingPtr _globalNamespaceBinding;
QList<PostfixExpressionAST *> _postfixExpressionStack;
QList<QualifiedNameAST *> _qualifiedNameStack;
QList<int> _references;
LookupContext _previousContext;
int _inSimpleDeclaration;
} // end of namespace CPlusPlus
#endif // FINDUSAGES_H
......@@ -38,6 +38,7 @@ HEADERS += \
$$PWD/CppBindings.h \
$$PWD/ASTParent.h \
$$PWD/GenTemplateInstance.h \
$$PWD/FindUsages.h \
$$PWD/CheckUndefinedSymbols.h \
$$PWD/PreprocessorClient.h \
$$PWD/PreprocessorEnvironment.h \
......@@ -61,6 +62,7 @@ SOURCES += \
$$PWD/CppBindings.cpp \
$$PWD/ASTParent.cpp \
$$PWD/GenTemplateInstance.cpp \
$$PWD/FindUsages.cpp \
$$PWD/CheckUndefinedSymbols.cpp \
$$PWD/PreprocessorClient.cpp \
$$PWD/PreprocessorEnvironment.cpp \
This diff is collapsed.
......@@ -42,6 +42,10 @@ namespace Find {
struct SearchResultItem;
} // end of namespace Find
namespace CPlusPlus {
class Usage;
} // end of namespace CPlusPlus
namespace CppTools {
class CppModelManagerInterface;
......@@ -78,7 +82,7 @@ private:
QPointer<CppModelManagerInterface> _modelManager;
Find::SearchResultWindow *_resultWindow;
QFutureWatcher<Utils::FileSearchResult> m_watcher;
QFutureWatcher<CPlusPlus::Usage> m_watcher;
} // end of namespace Internal
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment