forked from qt-creator/qt-creator
Inital support for Q_D/Q_Q declarations.
This commit is contained in:
@@ -1462,6 +1462,10 @@ bool Preprocessor::isQtReservedWord(const QByteArray ¯oId) const
|
|||||||
return true;
|
return true;
|
||||||
else if (size == 6 && macroId.at(0) == 'Q' && macroId == "Q_SLOT")
|
else if (size == 6 && macroId.at(0) == 'Q' && macroId == "Q_SLOT")
|
||||||
return true;
|
return true;
|
||||||
|
else if (size == 3 && macroId.at(0) == 'Q' && macroId == "Q_D")
|
||||||
|
return true;
|
||||||
|
else if (size == 3 && macroId.at(0) == 'Q' && macroId == "Q_Q")
|
||||||
|
return true;
|
||||||
else if (size == 6 && macroId.at(0) == 'S' && macroId == "SIGNAL")
|
else if (size == 6 && macroId.at(0) == 'S' && macroId == "SIGNAL")
|
||||||
return true;
|
return true;
|
||||||
else if (size == 4 && macroId.at(0) == 'S' && macroId == "SLOT")
|
else if (size == 4 && macroId.at(0) == 'S' && macroId == "SLOT")
|
||||||
|
@@ -186,19 +186,20 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FindUses: protected ASTVisitor
|
class FindLocalUses: protected ASTVisitor
|
||||||
{
|
{
|
||||||
Scope *_functionScope;
|
Scope *_functionScope;
|
||||||
|
|
||||||
FindScope findScope;
|
FindScope findScope;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FindUses(TranslationUnit *translationUnit)
|
FindLocalUses(TranslationUnit *translationUnit)
|
||||||
: ASTVisitor(translationUnit)
|
: ASTVisitor(translationUnit), hasD(false), hasQ(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
// local and external uses.
|
// local and external uses.
|
||||||
SemanticInfo::LocalUseMap localUses;
|
SemanticInfo::LocalUseMap localUses;
|
||||||
|
bool hasD;
|
||||||
|
bool hasQ;
|
||||||
|
|
||||||
void operator()(FunctionDefinitionAST *ast)
|
void operator()(FunctionDefinitionAST *ast)
|
||||||
{
|
{
|
||||||
@@ -357,6 +358,16 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool visit(QtMemberDeclarationAST *ast)
|
||||||
|
{
|
||||||
|
if (tokenKind(ast->q_token) == T_Q_D)
|
||||||
|
hasD = true;
|
||||||
|
else
|
||||||
|
hasQ = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool visit(ExpressionOrDeclarationStatementAST *ast)
|
virtual bool visit(ExpressionOrDeclarationStatementAST *ast)
|
||||||
{
|
{
|
||||||
accept(ast->declaration);
|
accept(ast->declaration);
|
||||||
@@ -929,6 +940,7 @@ void CPPEditor::updateMethodBoxIndex()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses,
|
void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses,
|
||||||
|
const SemanticInfo &semanticInfo,
|
||||||
QList<QTextEdit::ExtraSelection> *selections)
|
QList<QTextEdit::ExtraSelection> *selections)
|
||||||
{
|
{
|
||||||
bool isUnused = false;
|
bool isUnused = false;
|
||||||
@@ -951,6 +963,14 @@ void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses,
|
|||||||
sel.cursor.setPosition(anchor);
|
sel.cursor.setPosition(anchor);
|
||||||
sel.cursor.setPosition(position, QTextCursor::KeepAnchor);
|
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);
|
selections->append(sel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1953,14 +1973,12 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uses.size() == 1) {
|
if (uses.size() == 1)
|
||||||
// it's an unused declaration
|
// it's an unused declaration
|
||||||
highlightUses(uses, &unusedSelections);
|
highlightUses(uses, semanticInfo, &unusedSelections);
|
||||||
} else if (good) {
|
|
||||||
QList<QTextEdit::ExtraSelection> selections;
|
else if (good && m_renameSelections.isEmpty())
|
||||||
highlightUses(uses, &selections);
|
highlightUses(uses, semanticInfo, &m_renameSelections);
|
||||||
m_renameSelections += selections;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setExtraSelections(UnusedSymbolSelection, unusedSelections);
|
setExtraSelections(UnusedSymbolSelection, unusedSelections);
|
||||||
@@ -2078,7 +2096,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
|
|||||||
FunctionDefinitionUnderCursor functionDefinitionUnderCursor(translationUnit);
|
FunctionDefinitionUnderCursor functionDefinitionUnderCursor(translationUnit);
|
||||||
FunctionDefinitionAST *currentFunctionDefinition = functionDefinitionUnderCursor(ast, source.line, source.column);
|
FunctionDefinitionAST *currentFunctionDefinition = functionDefinitionUnderCursor(ast, source.line, source.column);
|
||||||
|
|
||||||
FindUses useTable(translationUnit);
|
FindLocalUses useTable(translationUnit);
|
||||||
useTable(currentFunctionDefinition);
|
useTable(currentFunctionDefinition);
|
||||||
|
|
||||||
SemanticInfo semanticInfo;
|
SemanticInfo semanticInfo;
|
||||||
@@ -2086,6 +2104,8 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
|
|||||||
semanticInfo.snapshot = snapshot;
|
semanticInfo.snapshot = snapshot;
|
||||||
semanticInfo.doc = doc;
|
semanticInfo.doc = doc;
|
||||||
semanticInfo.localUses = useTable.localUses;
|
semanticInfo.localUses = useTable.localUses;
|
||||||
|
semanticInfo.hasQ = useTable.hasQ;
|
||||||
|
semanticInfo.hasD = useTable.hasD;
|
||||||
|
|
||||||
return semanticInfo;
|
return semanticInfo;
|
||||||
}
|
}
|
||||||
|
@@ -79,10 +79,12 @@ public:
|
|||||||
typedef QHashIterator<CPlusPlus::Symbol *, QList<Use> > LocalUseIterator;
|
typedef QHashIterator<CPlusPlus::Symbol *, QList<Use> > LocalUseIterator;
|
||||||
|
|
||||||
SemanticInfo()
|
SemanticInfo()
|
||||||
: revision(-1)
|
: revision(-1), hasQ(false), hasD(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
int revision;
|
int revision;
|
||||||
|
bool hasQ: 1;
|
||||||
|
bool hasD: 1;
|
||||||
CPlusPlus::Snapshot snapshot;
|
CPlusPlus::Snapshot snapshot;
|
||||||
CPlusPlus::Document::Ptr doc;
|
CPlusPlus::Document::Ptr doc;
|
||||||
LocalUseMap localUses;
|
LocalUseMap localUses;
|
||||||
@@ -253,6 +255,7 @@ private:
|
|||||||
SemanticHighlighter::Source currentSource(bool force = false);
|
SemanticHighlighter::Source currentSource(bool force = false);
|
||||||
|
|
||||||
void highlightUses(const QList<SemanticInfo::Use> &uses,
|
void highlightUses(const QList<SemanticInfo::Use> &uses,
|
||||||
|
const SemanticInfo &semanticInfo,
|
||||||
QList<QTextEdit::ExtraSelection> *selections);
|
QList<QTextEdit::ExtraSelection> *selections);
|
||||||
|
|
||||||
void createToolBar(CPPEditorEditable *editable);
|
void createToolBar(CPPEditorEditable *editable);
|
||||||
|
@@ -246,7 +246,21 @@ unsigned QtMethodAST::lastToken() const
|
|||||||
return method_token + 1;
|
return method_token + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned QtMemberDeclarationAST::firstToken() const
|
||||||
|
{
|
||||||
|
return q_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned QtMemberDeclarationAST::lastToken() const
|
||||||
|
{
|
||||||
|
if (rparen_token)
|
||||||
|
return rparen_token + 1;
|
||||||
|
else if (type_id)
|
||||||
|
return type_id->lastToken();
|
||||||
|
else if (lparen_token)
|
||||||
|
return lparen_token + 1;
|
||||||
|
return q_token + 1;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned BinaryExpressionAST::firstToken() const
|
unsigned BinaryExpressionAST::firstToken() const
|
||||||
{
|
{
|
||||||
|
@@ -246,6 +246,7 @@ public:
|
|||||||
virtual PostfixDeclaratorAST *asPostfixDeclarator() { return 0; }
|
virtual PostfixDeclaratorAST *asPostfixDeclarator() { return 0; }
|
||||||
virtual PostfixExpressionAST *asPostfixExpression() { return 0; }
|
virtual PostfixExpressionAST *asPostfixExpression() { return 0; }
|
||||||
virtual PtrOperatorAST *asPtrOperator() { return 0; }
|
virtual PtrOperatorAST *asPtrOperator() { return 0; }
|
||||||
|
virtual QtMemberDeclarationAST *asQtMemberDeclaration() { return 0; }
|
||||||
virtual QtMethodAST *asQtMethod() { return 0; }
|
virtual QtMethodAST *asQtMethod() { return 0; }
|
||||||
virtual QualifiedNameAST *asQualifiedName() { return 0; }
|
virtual QualifiedNameAST *asQualifiedName() { return 0; }
|
||||||
virtual ReferenceAST *asReference() { return 0; }
|
virtual ReferenceAST *asReference() { return 0; }
|
||||||
@@ -582,6 +583,25 @@ protected:
|
|||||||
virtual bool match0(AST *, ASTMatcher *);
|
virtual bool match0(AST *, ASTMatcher *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CPLUSPLUS_EXPORT QtMemberDeclarationAST: public StatementAST
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned q_token;
|
||||||
|
unsigned lparen_token;
|
||||||
|
ExpressionAST *type_id;
|
||||||
|
unsigned rparen_token;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual QtMemberDeclarationAST *asQtMemberDeclaration() { return this; }
|
||||||
|
|
||||||
|
virtual unsigned firstToken() const;
|
||||||
|
virtual unsigned lastToken() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void accept0(ASTVisitor *visitor);
|
||||||
|
virtual bool match0(AST *, ASTMatcher *);
|
||||||
|
};
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT BinaryExpressionAST: public ExpressionAST
|
class CPLUSPLUS_EXPORT BinaryExpressionAST: public ExpressionAST
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -128,6 +128,14 @@ bool QtMethodAST::match0(AST *pattern, ASTMatcher *matcher)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QtMemberDeclarationAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||||
|
{
|
||||||
|
if (QtMemberDeclarationAST *_other = pattern->asQtMemberDeclaration())
|
||||||
|
return matcher->match(this, _other);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool BinaryExpressionAST::match0(AST *pattern, ASTMatcher *matcher)
|
bool BinaryExpressionAST::match0(AST *pattern, ASTMatcher *matcher)
|
||||||
{
|
{
|
||||||
if (BinaryExpressionAST *_other = pattern->asBinaryExpression())
|
if (BinaryExpressionAST *_other = pattern->asBinaryExpression())
|
||||||
|
@@ -274,6 +274,25 @@ bool ASTMatcher::match(QtMethodAST *node, QtMethodAST *pattern)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ASTMatcher::match(QtMemberDeclarationAST *node, QtMemberDeclarationAST *pattern)
|
||||||
|
{
|
||||||
|
(void) node;
|
||||||
|
(void) pattern;
|
||||||
|
|
||||||
|
pattern->q_token = node->q_token;
|
||||||
|
|
||||||
|
pattern->lparen_token = node->lparen_token;
|
||||||
|
|
||||||
|
if (! pattern->type_id)
|
||||||
|
pattern->type_id = node->type_id;
|
||||||
|
else if (! AST::match(node->type_id, pattern->type_id, this))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
pattern->rparen_token = node->rparen_token;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ASTMatcher::match(BinaryExpressionAST *node, BinaryExpressionAST *pattern)
|
bool ASTMatcher::match(BinaryExpressionAST *node, BinaryExpressionAST *pattern)
|
||||||
{
|
{
|
||||||
(void) node;
|
(void) node;
|
||||||
|
@@ -135,6 +135,7 @@ public:
|
|||||||
virtual bool match(UsingDirectiveAST *node, UsingDirectiveAST *pattern);
|
virtual bool match(UsingDirectiveAST *node, UsingDirectiveAST *pattern);
|
||||||
virtual bool match(WhileStatementAST *node, WhileStatementAST *pattern);
|
virtual bool match(WhileStatementAST *node, WhileStatementAST *pattern);
|
||||||
virtual bool match(QtMethodAST *node, QtMethodAST *pattern);
|
virtual bool match(QtMethodAST *node, QtMethodAST *pattern);
|
||||||
|
virtual bool match(QtMemberDeclarationAST *node, QtMemberDeclarationAST *pattern);
|
||||||
virtual bool match(ObjCClassDeclarationAST *node, ObjCClassDeclarationAST *pattern);
|
virtual bool match(ObjCClassDeclarationAST *node, ObjCClassDeclarationAST *pattern);
|
||||||
virtual bool match(ObjCClassForwardDeclarationAST *node, ObjCClassForwardDeclarationAST *pattern);
|
virtual bool match(ObjCClassForwardDeclarationAST *node, ObjCClassForwardDeclarationAST *pattern);
|
||||||
virtual bool match(ObjCProtocolDeclarationAST *node, ObjCProtocolDeclarationAST *pattern);
|
virtual bool match(ObjCProtocolDeclarationAST *node, ObjCProtocolDeclarationAST *pattern);
|
||||||
|
@@ -131,6 +131,14 @@ void QtMethodAST::accept0(ASTVisitor *visitor)
|
|||||||
visitor->endVisit(this);
|
visitor->endVisit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtMemberDeclarationAST::accept0(ASTVisitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this)) {
|
||||||
|
accept(type_id, visitor);
|
||||||
|
}
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
void BinaryExpressionAST::accept0(ASTVisitor *visitor)
|
void BinaryExpressionAST::accept0(ASTVisitor *visitor)
|
||||||
{
|
{
|
||||||
if (visitor->visit(this)) {
|
if (visitor->visit(this)) {
|
||||||
|
@@ -198,6 +198,7 @@ public:
|
|||||||
virtual bool visit(UsingDirectiveAST *) { return true; }
|
virtual bool visit(UsingDirectiveAST *) { return true; }
|
||||||
virtual bool visit(WhileStatementAST *) { return true; }
|
virtual bool visit(WhileStatementAST *) { return true; }
|
||||||
virtual bool visit(QtMethodAST *) { return true; }
|
virtual bool visit(QtMethodAST *) { return true; }
|
||||||
|
virtual bool visit(QtMemberDeclarationAST *) { return true; }
|
||||||
|
|
||||||
// ObjC++
|
// ObjC++
|
||||||
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
|
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
|
||||||
@@ -323,6 +324,7 @@ public:
|
|||||||
virtual void endVisit(UsingDirectiveAST *) { }
|
virtual void endVisit(UsingDirectiveAST *) { }
|
||||||
virtual void endVisit(WhileStatementAST *) { }
|
virtual void endVisit(WhileStatementAST *) { }
|
||||||
virtual void endVisit(QtMethodAST *) { }
|
virtual void endVisit(QtMethodAST *) { }
|
||||||
|
virtual void endVisit(QtMemberDeclarationAST *) { }
|
||||||
|
|
||||||
// ObjC++
|
// ObjC++
|
||||||
virtual void endVisit(ObjCClassDeclarationAST *) { }
|
virtual void endVisit(ObjCClassDeclarationAST *) { }
|
||||||
|
@@ -162,6 +162,7 @@ class PostfixAST;
|
|||||||
class PostfixDeclaratorAST;
|
class PostfixDeclaratorAST;
|
||||||
class PostfixExpressionAST;
|
class PostfixExpressionAST;
|
||||||
class PtrOperatorAST;
|
class PtrOperatorAST;
|
||||||
|
class QtMemberDeclarationAST;
|
||||||
class QtMethodAST;
|
class QtMethodAST;
|
||||||
class QualifiedNameAST;
|
class QualifiedNameAST;
|
||||||
class ReferenceAST;
|
class ReferenceAST;
|
||||||
|
@@ -54,6 +54,9 @@
|
|||||||
#include "CoreTypes.h"
|
#include "CoreTypes.h"
|
||||||
#include "Control.h"
|
#include "Control.h"
|
||||||
#include "Symbols.h"
|
#include "Symbols.h"
|
||||||
|
#include "Names.h"
|
||||||
|
#include "Literals.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
@@ -307,4 +310,34 @@ bool CheckStatement::visit(WhileStatementAST *ast)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckStatement::visit(QtMemberDeclarationAST *ast)
|
||||||
|
{
|
||||||
|
Name *name = 0;
|
||||||
|
|
||||||
|
if (tokenKind(ast->q_token) == T_Q_D)
|
||||||
|
name = control()->nameId(control()->findOrInsertIdentifier("d"));
|
||||||
|
else
|
||||||
|
name = control()->nameId(control()->findOrInsertIdentifier("q"));
|
||||||
|
|
||||||
|
FullySpecifiedType declTy = semantic()->check(ast->type_id, _scope);
|
||||||
|
|
||||||
|
if (tokenKind(ast->q_token) == T_Q_D) {
|
||||||
|
if (NamedType *namedTy = declTy->asNamedType()) {
|
||||||
|
if (NameId *nameId = namedTy->name()->asNameId()) {
|
||||||
|
std::string privateClass;
|
||||||
|
privateClass += nameId->identifier()->chars();
|
||||||
|
privateClass += "Private";
|
||||||
|
|
||||||
|
Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(), privateClass.size()));
|
||||||
|
declTy.setType(control()->namedType(privName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Declaration *symbol = control()->newDeclaration(/*generated*/ 0, name);
|
||||||
|
symbol->setType(control()->pointerType(declTy));
|
||||||
|
|
||||||
|
_scope->enterSymbol(symbol);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@@ -88,6 +88,7 @@ protected:
|
|||||||
virtual bool visit(TryBlockStatementAST *ast);
|
virtual bool visit(TryBlockStatementAST *ast);
|
||||||
virtual bool visit(CatchClauseAST *ast);
|
virtual bool visit(CatchClauseAST *ast);
|
||||||
virtual bool visit(WhileStatementAST *ast);
|
virtual bool visit(WhileStatementAST *ast);
|
||||||
|
virtual bool visit(QtMemberDeclarationAST *ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StatementAST *_statement;
|
StatementAST *_statement;
|
||||||
|
@@ -65,7 +65,7 @@ static inline int classify2(const char *s, bool) {
|
|||||||
return T_IDENTIFIER;
|
return T_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int classify3(const char *s, bool) {
|
static inline int classify3(const char *s, bool q) {
|
||||||
if (s[0] == 'a') {
|
if (s[0] == 'a') {
|
||||||
if (s[1] == 's') {
|
if (s[1] == 's') {
|
||||||
if (s[2] == 'm') {
|
if (s[2] == 'm') {
|
||||||
@@ -101,6 +101,16 @@ static inline int classify3(const char *s, bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (q && s[0] == 'Q') {
|
||||||
|
if (s[1] == '_') {
|
||||||
|
if (s[2] == 'D') {
|
||||||
|
return T_Q_D;
|
||||||
|
}
|
||||||
|
else if (s[2] == 'Q') {
|
||||||
|
return T_Q_Q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return T_IDENTIFIER;
|
return T_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2104,6 +2104,16 @@ bool Parser::parseStatement(StatementAST *&node)
|
|||||||
if (objCEnabled())
|
if (objCEnabled())
|
||||||
return parseObjCSynchronizedStatement(node);
|
return parseObjCSynchronizedStatement(node);
|
||||||
|
|
||||||
|
case T_Q_D:
|
||||||
|
case T_Q_Q: {
|
||||||
|
QtMemberDeclarationAST *ast = new (_pool) QtMemberDeclarationAST;
|
||||||
|
ast->q_token = consumeToken();
|
||||||
|
match(T_LPAREN, &ast->lparen_token);
|
||||||
|
parseTypeId(ast->type_id);
|
||||||
|
match(T_RPAREN, &ast->rparen_token);
|
||||||
|
node = ast;
|
||||||
|
} return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (LA() == T_IDENTIFIER && LA(2) == T_COLON)
|
if (LA() == T_IDENTIFIER && LA(2) == T_COLON)
|
||||||
return parseLabeledStatement(node);
|
return parseLabeledStatement(node);
|
||||||
|
@@ -91,7 +91,7 @@ static const char *token_names[] = {
|
|||||||
("@protected"), ("@protocol"), ("@public"), ("@required"), ("@selector"),
|
("@protected"), ("@protocol"), ("@public"), ("@required"), ("@selector"),
|
||||||
("@synchronized"), ("@synthesize"), ("@throw"), ("@try"),
|
("@synchronized"), ("@synthesize"), ("@throw"), ("@try"),
|
||||||
|
|
||||||
("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), ("Q_FOREACH")
|
("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), ("Q_FOREACH"), ("Q_D"), ("Q_Q")
|
||||||
};
|
};
|
||||||
|
|
||||||
Token::Token() :
|
Token::Token() :
|
||||||
|
@@ -236,8 +236,10 @@ enum Kind {
|
|||||||
T_Q_SIGNALS,
|
T_Q_SIGNALS,
|
||||||
T_Q_SLOTS,
|
T_Q_SLOTS,
|
||||||
T_Q_FOREACH,
|
T_Q_FOREACH,
|
||||||
|
T_Q_D,
|
||||||
|
T_Q_Q,
|
||||||
|
|
||||||
T_LAST_KEYWORD = T_Q_FOREACH,
|
T_LAST_KEYWORD = T_Q_Q,
|
||||||
|
|
||||||
// aliases
|
// aliases
|
||||||
T_OR = T_PIPE_PIPE,
|
T_OR = T_PIPE_PIPE,
|
||||||
|
@@ -100,7 +100,7 @@ class FindASTNodes: protected ASTVisitor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindASTNodes(Document::Ptr doc, QTextDocument *document)
|
FindASTNodes(Document::Ptr doc, QTextDocument *document)
|
||||||
: ASTVisitor(doc->control()), document(document)
|
: ASTVisitor(doc->translationUnit()), document(document)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,8 +159,8 @@ class Accept0CG: protected ASTVisitor
|
|||||||
QTextStream *out;
|
QTextStream *out;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Accept0CG(const QDir &cplusplusDir, Control *control)
|
Accept0CG(const QDir &cplusplusDir, TranslationUnit *unit)
|
||||||
: ASTVisitor(control), _cplusplusDir(cplusplusDir), out(0)
|
: ASTVisitor(unit), _cplusplusDir(cplusplusDir), out(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void operator()(AST *ast)
|
void operator()(AST *ast)
|
||||||
@@ -296,8 +296,8 @@ class Match0CG: protected ASTVisitor
|
|||||||
QTextStream *out;
|
QTextStream *out;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Match0CG(const QDir &cplusplusDir, Control *control)
|
Match0CG(const QDir &cplusplusDir, TranslationUnit *unit)
|
||||||
: ASTVisitor(control), _cplusplusDir(cplusplusDir), out(0)
|
: ASTVisitor(unit), _cplusplusDir(cplusplusDir), out(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void operator()(AST *ast)
|
void operator()(AST *ast)
|
||||||
@@ -406,8 +406,8 @@ class MatcherCPPCG: protected ASTVisitor
|
|||||||
QTextStream *out;
|
QTextStream *out;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MatcherCPPCG(const QDir &cplusplusDir, Control *control)
|
MatcherCPPCG(const QDir &cplusplusDir, TranslationUnit *unit)
|
||||||
: ASTVisitor(control), _cplusplusDir(cplusplusDir), out(0)
|
: ASTVisitor(unit), _cplusplusDir(cplusplusDir), out(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void operator()(AST *ast)
|
void operator()(AST *ast)
|
||||||
@@ -560,7 +560,7 @@ class RemoveCastMethods: protected ASTVisitor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RemoveCastMethods(Document::Ptr doc, QTextDocument *document)
|
RemoveCastMethods(Document::Ptr doc, QTextDocument *document)
|
||||||
: ASTVisitor(doc->control()), document(document) {}
|
: ASTVisitor(doc->translationUnit()), document(document) {}
|
||||||
|
|
||||||
QList<QTextCursor> operator()(AST *ast)
|
QList<QTextCursor> operator()(AST *ast)
|
||||||
{
|
{
|
||||||
@@ -666,13 +666,13 @@ QStringList generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir)
|
|||||||
out << document.toPlainText();
|
out << document.toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
Accept0CG cg(cplusplusDir, AST_h_document->control());
|
Accept0CG cg(cplusplusDir, AST_h_document->translationUnit());
|
||||||
cg(AST_h_document->translationUnit()->ast());
|
cg(AST_h_document->translationUnit()->ast());
|
||||||
|
|
||||||
Match0CG cg2(cplusplusDir, AST_h_document->control());
|
Match0CG cg2(cplusplusDir, AST_h_document->translationUnit());
|
||||||
cg2(AST_h_document->translationUnit()->ast());
|
cg2(AST_h_document->translationUnit()->ast());
|
||||||
|
|
||||||
MatcherCPPCG cg3(cplusplusDir, AST_h_document->control());
|
MatcherCPPCG cg3(cplusplusDir, AST_h_document->translationUnit());
|
||||||
cg3(AST_h_document->translationUnit()->ast());
|
cg3(AST_h_document->translationUnit()->ast());
|
||||||
|
|
||||||
return astDerivedClasses;
|
return astDerivedClasses;
|
||||||
@@ -682,7 +682,7 @@ class FindASTForwards: protected ASTVisitor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindASTForwards(Document::Ptr doc, QTextDocument *document)
|
FindASTForwards(Document::Ptr doc, QTextDocument *document)
|
||||||
: ASTVisitor(doc->control()), document(document)
|
: ASTVisitor(doc->translationUnit()), document(document)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QList<QTextCursor> operator()(AST *ast)
|
QList<QTextCursor> operator()(AST *ast)
|
||||||
@@ -887,5 +887,5 @@ int main(int argc, char *argv[])
|
|||||||
astDerivedClasses.sort();
|
astDerivedClasses.sort();
|
||||||
generateASTFwd_h(snapshot, cplusplusDir, astDerivedClasses);
|
generateASTFwd_h(snapshot, cplusplusDir, astDerivedClasses);
|
||||||
|
|
||||||
generateASTPatternBuilder_h(cplusplusDir);
|
//generateASTPatternBuilder_h(cplusplusDir);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user