forked from qt-creator/qt-creator
Renamed CheckUndefinedSymbols.
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "cppcheckundefinedsymbols.h"
|
#include "cppchecksymbols.h"
|
||||||
#include <cplusplus/Overview.h>
|
#include <cplusplus/Overview.h>
|
||||||
|
|
||||||
#include <Names.h>
|
#include <Names.h>
|
||||||
@@ -255,13 +255,13 @@ protected:
|
|||||||
|
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
CheckUndefinedSymbols::Future CheckUndefinedSymbols::go(Document::Ptr doc, const LookupContext &context)
|
CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &context)
|
||||||
{
|
{
|
||||||
Q_ASSERT(doc);
|
Q_ASSERT(doc);
|
||||||
return (new CheckUndefinedSymbols(doc, context))->start();
|
return (new CheckSymbols(doc, context))->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckUndefinedSymbols::CheckUndefinedSymbols(Document::Ptr doc, const LookupContext &context)
|
CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context)
|
||||||
: ASTVisitor(doc->translationUnit()), _doc(doc), _context(context)
|
: ASTVisitor(doc->translationUnit()), _doc(doc), _context(context)
|
||||||
{
|
{
|
||||||
_fileName = doc->fileName();
|
_fileName = doc->fileName();
|
||||||
@@ -270,10 +270,10 @@ CheckUndefinedSymbols::CheckUndefinedSymbols(Document::Ptr doc, const LookupCont
|
|||||||
_scopes = collectTypes.scopes();
|
_scopes = collectTypes.scopes();
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckUndefinedSymbols::~CheckUndefinedSymbols()
|
CheckSymbols::~CheckSymbols()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void CheckUndefinedSymbols::run()
|
void CheckSymbols::run()
|
||||||
{
|
{
|
||||||
if (! isCanceled())
|
if (! isCanceled())
|
||||||
runFunctor();
|
runFunctor();
|
||||||
@@ -281,7 +281,7 @@ void CheckUndefinedSymbols::run()
|
|||||||
reportFinished();
|
reportFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::runFunctor()
|
void CheckSymbols::runFunctor()
|
||||||
{
|
{
|
||||||
_diagnosticMessages.clear();
|
_diagnosticMessages.clear();
|
||||||
|
|
||||||
@@ -291,14 +291,14 @@ void CheckUndefinedSymbols::runFunctor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::warning(unsigned line, unsigned column, const QString &text, unsigned length)
|
bool CheckSymbols::warning(unsigned line, unsigned column, const QString &text, unsigned length)
|
||||||
{
|
{
|
||||||
Document::DiagnosticMessage m(Document::DiagnosticMessage::Warning, _fileName, line, column, text, length);
|
Document::DiagnosticMessage m(Document::DiagnosticMessage::Warning, _fileName, line, column, text, length);
|
||||||
_diagnosticMessages.append(m);
|
_diagnosticMessages.append(m);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::warning(AST *ast, const QString &text)
|
bool CheckSymbols::warning(AST *ast, const QString &text)
|
||||||
{
|
{
|
||||||
const Token &firstToken = tokenAt(ast->firstToken());
|
const Token &firstToken = tokenAt(ast->firstToken());
|
||||||
const Token &lastToken = tokenAt(ast->lastToken() - 1);
|
const Token &lastToken = tokenAt(ast->lastToken() - 1);
|
||||||
@@ -311,7 +311,7 @@ bool CheckUndefinedSymbols::warning(AST *ast, const QString &text)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::preVisit(AST *)
|
bool CheckSymbols::preVisit(AST *)
|
||||||
{
|
{
|
||||||
if (isCanceled())
|
if (isCanceled())
|
||||||
return false;
|
return false;
|
||||||
@@ -319,7 +319,7 @@ bool CheckUndefinedSymbols::preVisit(AST *)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(NamespaceAST *ast)
|
bool CheckSymbols::visit(NamespaceAST *ast)
|
||||||
{
|
{
|
||||||
if (ast->identifier_token) {
|
if (ast->identifier_token) {
|
||||||
const Token &tok = tokenAt(ast->identifier_token);
|
const Token &tok = tokenAt(ast->identifier_token);
|
||||||
@@ -334,22 +334,22 @@ bool CheckUndefinedSymbols::visit(NamespaceAST *ast)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(UsingDirectiveAST *)
|
bool CheckSymbols::visit(UsingDirectiveAST *)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(SimpleDeclarationAST *)
|
bool CheckSymbols::visit(SimpleDeclarationAST *)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(NamedTypeSpecifierAST *)
|
bool CheckSymbols::visit(NamedTypeSpecifierAST *)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::checkNamespace(NameAST *name)
|
void CheckSymbols::checkNamespace(NameAST *name)
|
||||||
{
|
{
|
||||||
if (! name)
|
if (! name)
|
||||||
return;
|
return;
|
||||||
@@ -369,7 +369,7 @@ void CheckUndefinedSymbols::checkNamespace(NameAST *name)
|
|||||||
warning(line, column, QCoreApplication::translate("CheckUndefinedSymbols", "Expected a namespace-name"), length);
|
warning(line, column, QCoreApplication::translate("CheckUndefinedSymbols", "Expected a namespace-name"), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::checkName(NameAST *ast)
|
void CheckSymbols::checkName(NameAST *ast)
|
||||||
{
|
{
|
||||||
if (ast && ast->name) {
|
if (ast && ast->name) {
|
||||||
if (const Identifier *ident = ast->name->identifier()) {
|
if (const Identifier *ident = ast->name->identifier()) {
|
||||||
@@ -383,25 +383,25 @@ void CheckUndefinedSymbols::checkName(NameAST *ast)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(SimpleNameAST *ast)
|
bool CheckSymbols::visit(SimpleNameAST *ast)
|
||||||
{
|
{
|
||||||
checkName(ast);
|
checkName(ast);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(TemplateIdAST *ast)
|
bool CheckSymbols::visit(TemplateIdAST *ast)
|
||||||
{
|
{
|
||||||
checkName(ast);
|
checkName(ast);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(DestructorNameAST *ast)
|
bool CheckSymbols::visit(DestructorNameAST *ast)
|
||||||
{
|
{
|
||||||
checkName(ast);
|
checkName(ast);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast)
|
bool CheckSymbols::visit(QualifiedNameAST *ast)
|
||||||
{
|
{
|
||||||
if (ast->name) {
|
if (ast->name) {
|
||||||
Scope *scope = findScope(ast);
|
Scope *scope = findScope(ast);
|
||||||
@@ -439,7 +439,7 @@ bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(TypenameTypeParameterAST *ast)
|
bool CheckSymbols::visit(TypenameTypeParameterAST *ast)
|
||||||
{
|
{
|
||||||
if (ast->name && ast->name->name) {
|
if (ast->name && ast->name->name) {
|
||||||
if (const Identifier *templId = ast->name->name->identifier()) {
|
if (const Identifier *templId = ast->name->name->identifier()) {
|
||||||
@@ -454,24 +454,24 @@ bool CheckUndefinedSymbols::visit(TypenameTypeParameterAST *ast)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(TemplateTypeParameterAST *ast)
|
bool CheckSymbols::visit(TemplateTypeParameterAST *ast)
|
||||||
{
|
{
|
||||||
checkName(ast->name);
|
checkName(ast->name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(TemplateDeclarationAST *ast)
|
bool CheckSymbols::visit(TemplateDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
_templateDeclarationStack.append(ast);
|
_templateDeclarationStack.append(ast);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::endVisit(TemplateDeclarationAST *)
|
void CheckSymbols::endVisit(TemplateDeclarationAST *)
|
||||||
{
|
{
|
||||||
_templateDeclarationStack.takeFirst();
|
_templateDeclarationStack.takeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::addTypeUsage(const Use &use)
|
void CheckSymbols::addTypeUsage(const Use &use)
|
||||||
{
|
{
|
||||||
_typeUsages.append(use);
|
_typeUsages.append(use);
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ void CheckUndefinedSymbols::addTypeUsage(const Use &use)
|
|||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::addTypeUsage(ClassOrNamespace *b, NameAST *ast)
|
void CheckSymbols::addTypeUsage(ClassOrNamespace *b, NameAST *ast)
|
||||||
{
|
{
|
||||||
if (! b)
|
if (! b)
|
||||||
return;
|
return;
|
||||||
@@ -500,7 +500,7 @@ void CheckUndefinedSymbols::addTypeUsage(ClassOrNamespace *b, NameAST *ast)
|
|||||||
//qDebug() << "added use" << oo(ast->name) << line << column << length;
|
//qDebug() << "added use" << oo(ast->name) << line << column << length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::addTypeUsage(const QList<Symbol *> &candidates, NameAST *ast)
|
void CheckSymbols::addTypeUsage(const QList<Symbol *> &candidates, NameAST *ast)
|
||||||
{
|
{
|
||||||
unsigned startToken = ast->firstToken();
|
unsigned startToken = ast->firstToken();
|
||||||
if (DestructorNameAST *dtor = ast->asDestructorName())
|
if (DestructorNameAST *dtor = ast->asDestructorName())
|
||||||
@@ -530,7 +530,7 @@ void CheckUndefinedSymbols::addTypeUsage(const QList<Symbol *> &candidates, Name
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned CheckUndefinedSymbols::startOfTemplateDeclaration(TemplateDeclarationAST *ast) const
|
unsigned CheckSymbols::startOfTemplateDeclaration(TemplateDeclarationAST *ast) const
|
||||||
{
|
{
|
||||||
if (ast->declaration) {
|
if (ast->declaration) {
|
||||||
if (TemplateDeclarationAST *templ = ast->declaration->asTemplateDeclaration())
|
if (TemplateDeclarationAST *templ = ast->declaration->asTemplateDeclaration())
|
||||||
@@ -542,7 +542,7 @@ unsigned CheckUndefinedSymbols::startOfTemplateDeclaration(TemplateDeclarationAS
|
|||||||
return ast->firstToken();
|
return ast->firstToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
Scope *CheckUndefinedSymbols::findScope(AST *ast) const
|
Scope *CheckSymbols::findScope(AST *ast) const
|
||||||
{
|
{
|
||||||
Scope *scope = 0;
|
Scope *scope = 0;
|
||||||
|
|
||||||
@@ -561,7 +561,7 @@ Scope *CheckUndefinedSymbols::findScope(AST *ast) const
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckUndefinedSymbols::flush()
|
void CheckSymbols::flush()
|
||||||
{
|
{
|
||||||
if (_typeUsages.isEmpty())
|
if (_typeUsages.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef CPLUSPLUS_CHECKUNDEFINEDSYMBOLS_H
|
#ifndef CPLUSPLUS_CHECKSYMBOLS_H
|
||||||
#define CPLUSPLUS_CHECKUNDEFINEDSYMBOLS_H
|
#define CPLUSPLUS_CHECKSYMBOLS_H
|
||||||
|
|
||||||
#include "cppsemanticinfo.h"
|
#include "cppsemanticinfo.h"
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@
|
|||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
class CheckUndefinedSymbols:
|
class CheckSymbols:
|
||||||
protected ASTVisitor,
|
protected ASTVisitor,
|
||||||
public QtConcurrent::RunFunctionTaskBase<CppEditor::Internal::SemanticInfo::Use>
|
public QtConcurrent::RunFunctionTaskBase<CppEditor::Internal::SemanticInfo::Use>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~CheckUndefinedSymbols();
|
virtual ~CheckSymbols();
|
||||||
|
|
||||||
typedef CppEditor::Internal::SemanticInfo::Use Use;
|
typedef CppEditor::Internal::SemanticInfo::Use Use;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ protected:
|
|||||||
using ASTVisitor::visit;
|
using ASTVisitor::visit;
|
||||||
using ASTVisitor::endVisit;
|
using ASTVisitor::endVisit;
|
||||||
|
|
||||||
CheckUndefinedSymbols(Document::Ptr doc, const LookupContext &context);
|
CheckSymbols(Document::Ptr doc, const LookupContext &context);
|
||||||
|
|
||||||
bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0);
|
bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0);
|
||||||
bool warning(AST *ast, const QString &text);
|
bool warning(AST *ast, const QString &text);
|
||||||
@@ -123,4 +123,4 @@ private:
|
|||||||
|
|
||||||
} // end of namespace CPlusPlus
|
} // end of namespace CPlusPlus
|
||||||
|
|
||||||
#endif // CPLUSPLUS_CHECKUNDEFINEDSYMBOLS_H
|
#endif // CPLUSPLUS_CHECKSYMBOLS_H
|
||||||
@@ -31,10 +31,8 @@
|
|||||||
#include "cppeditorconstants.h"
|
#include "cppeditorconstants.h"
|
||||||
#include "cppplugin.h"
|
#include "cppplugin.h"
|
||||||
#include "cpphighlighter.h"
|
#include "cpphighlighter.h"
|
||||||
#include "cppcheckundefinedsymbols.h"
|
#include "cppchecksymbols.h"
|
||||||
|
|
||||||
#include "cppquickfix.h"
|
#include "cppquickfix.h"
|
||||||
#include <cpptools/cpptoolsplugin.h>
|
|
||||||
|
|
||||||
#include <AST.h>
|
#include <AST.h>
|
||||||
#include <Control.h>
|
#include <Control.h>
|
||||||
@@ -57,6 +55,7 @@
|
|||||||
#include <cplusplus/BackwardsScanner.h>
|
#include <cplusplus/BackwardsScanner.h>
|
||||||
#include <cplusplus/FastPreprocessor.h>
|
#include <cplusplus/FastPreprocessor.h>
|
||||||
|
|
||||||
|
#include <cpptools/cpptoolsplugin.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <cpptools/cpptoolsconstants.h>
|
#include <cpptools/cpptoolsconstants.h>
|
||||||
#include <cpptools/cppcodeformatter.h>
|
#include <cpptools/cppcodeformatter.h>
|
||||||
@@ -1128,7 +1127,7 @@ void CPPEditor::highlightTypeUsages(int from, int to)
|
|||||||
if (m_nextHighlightBlockNumber >= doc->blockCount())
|
if (m_nextHighlightBlockNumber >= doc->blockCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMap<int, QVector<SemanticInfo::Use> > chunks = CheckUndefinedSymbols::chunks(m_highlighter, from, to);
|
QMap<int, QVector<SemanticInfo::Use> > chunks = CheckSymbols::chunks(m_highlighter, from, to);
|
||||||
Q_ASSERT(!chunks.isEmpty());
|
Q_ASSERT(!chunks.isEmpty());
|
||||||
QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber);
|
QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber);
|
||||||
|
|
||||||
@@ -1977,7 +1976,7 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
|||||||
|
|
||||||
if (semanticInfo.doc) {
|
if (semanticInfo.doc) {
|
||||||
LookupContext context(semanticInfo.doc, semanticInfo.snapshot);
|
LookupContext context(semanticInfo.doc, semanticInfo.snapshot);
|
||||||
CheckUndefinedSymbols::Future f = CheckUndefinedSymbols::go(semanticInfo.doc, context);
|
CheckSymbols::Future f = CheckSymbols::go(semanticInfo.doc, context);
|
||||||
m_highlighter = f;
|
m_highlighter = f;
|
||||||
m_highlightRevision = semanticInfo.revision;
|
m_highlightRevision = semanticInfo.revision;
|
||||||
m_nextHighlightBlockNumber = 0;
|
m_nextHighlightBlockNumber = 0;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ HEADERS += cppplugin.h \
|
|||||||
cppclasswizard.h \
|
cppclasswizard.h \
|
||||||
cppquickfix.h \
|
cppquickfix.h \
|
||||||
cpprefactoringchanges.h \
|
cpprefactoringchanges.h \
|
||||||
cppcheckundefinedsymbols.h \
|
cppchecksymbols.h \
|
||||||
cppsemanticinfo.h \
|
cppsemanticinfo.h \
|
||||||
cppoutline.h \
|
cppoutline.h \
|
||||||
cppdeclfromdef.h
|
cppdeclfromdef.h
|
||||||
@@ -30,7 +30,7 @@ SOURCES += cppplugin.cpp \
|
|||||||
cppclasswizard.cpp \
|
cppclasswizard.cpp \
|
||||||
cppquickfix.cpp \
|
cppquickfix.cpp \
|
||||||
cpprefactoringchanges.cpp \
|
cpprefactoringchanges.cpp \
|
||||||
cppcheckundefinedsymbols.cpp \
|
cppchecksymbols.cpp \
|
||||||
cppsemanticinfo.cpp \
|
cppsemanticinfo.cpp \
|
||||||
cppoutline.cpp \
|
cppoutline.cpp \
|
||||||
cppdeclfromdef.cpp
|
cppdeclfromdef.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user