本文整理汇总了C++中Symbol::asDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::asDeclaration方法的具体用法?C++ Symbol::asDeclaration怎么用?C++ Symbol::asDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::asDeclaration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectFieldNames
static QStringList collectFieldNames(ClassSpecifierAST *classAST, bool onlyTokensAndASTNodes)
{
QStringList fields;
Overview oo;
Class *clazz = classAST->symbol;
for (unsigned i = 0; i < clazz->memberCount(); ++i) {
Symbol *s = clazz->memberAt(i);
if (Declaration *decl = s->asDeclaration()) {
const QString declName = oo(decl->name());
const FullySpecifiedType ty = decl->type();
if (const PointerType *ptrTy = ty->asPointerType()) {
if (onlyTokensAndASTNodes) {
if (const NamedType *namedTy = ptrTy->elementType()->asNamedType()) {
if (oo(namedTy->name()).endsWith(QLatin1String("AST")))
fields.append(declName);
}
} else {
fields.append(declName);
}
} else if (ty.isUnsigned()) {
fields.append(declName);
}
}
}
return fields;
}
示例2: typedefsFromScopeUpToFunctionScope
/// Return all typedefs with given name from given scope up to function scope.
static QList<LookupItem> typedefsFromScopeUpToFunctionScope(const Name *name, Scope *scope)
{
QList<LookupItem> results;
if (!scope)
return results;
Scope *enclosingBlockScope = 0;
for (Block *block = scope->asBlock(); block;
block = enclosingBlockScope ? enclosingBlockScope->asBlock() : 0) {
const unsigned memberCount = block->memberCount();
for (unsigned i = 0; i < memberCount; ++i) {
Symbol *symbol = block->memberAt(i);
if (Declaration *declaration = symbol->asDeclaration()) {
if (isTypedefWithName(declaration, name)) {
LookupItem item;
item.setDeclaration(declaration);
item.setScope(block);
item.setType(declaration->type());
results.append(item);
}
}
}
enclosingBlockScope = block->enclosingScope();
}
return results;
}
示例3: noResult
QList<CppQuickFixOperation::Ptr> InsertQtPropertyMembers::match(const CppQuickFixState &state)
{
const QList<AST *> &path = state.path();
if (path.isEmpty())
return noResult();
AST * const ast = path.last();
QtPropertyDeclarationAST *qtPropertyDeclaration = ast->asQtPropertyDeclaration();
if (!qtPropertyDeclaration)
return noResult();
ClassSpecifierAST *klass = 0;
for (int i = path.size() - 2; i >= 0; --i) {
klass = path.at(i)->asClassSpecifier();
if (klass)
break;
}
if (!klass)
return noResult();
CppRefactoringChanges refactoring(state.snapshot());
const CppRefactoringFile &file = refactoring.file(state.document()->fileName());
const QString propertyName = file.textOf(qtPropertyDeclaration->property_name);
QString getterName;
QString setterName;
QString signalName;
int generateFlags = 0;
for (QtPropertyDeclarationItemListAST *it = qtPropertyDeclaration->property_declaration_item_list;
it; it = it->next) {
const QString tokenString = file.tokenAt(it->value->item_name_token).spell();
if (tokenString == QLatin1String("READ")) {
getterName = file.textOf(it->value->expression);
generateFlags |= GenerateGetter;
} else if (tokenString == QLatin1String("WRITE")) {
setterName = file.textOf(it->value->expression);
generateFlags |= GenerateSetter;
} else if (tokenString == QLatin1String("NOTIFY")) {
signalName = file.textOf(it->value->expression);
generateFlags |= GenerateSignal;
}
}
QString storageName = QString("m_%1").arg(propertyName);
generateFlags |= GenerateStorage;
Class *c = klass->symbol;
Overview overview;
for (unsigned i = 0; i < c->memberCount(); ++i) {
Symbol *member = c->memberAt(i);
FullySpecifiedType type = member->type();
if (member->asFunction() || (type.isValid() && type->asFunctionType())) {
const QString name = overview(member->name());
if (name == getterName) {
generateFlags &= ~GenerateGetter;
} else if (name == setterName) {
generateFlags &= ~GenerateSetter;
} else if (name == signalName) {
generateFlags &= ~GenerateSignal;
}
} else if (member->asDeclaration()) {
const QString name = overview(member->name());
if (name == storageName)
generateFlags &= ~GenerateStorage;
}
}
if (getterName.isEmpty() && setterName.isEmpty() && signalName.isEmpty())
return noResult();
return singleResult(new Operation(state, path.size() - 1, qtPropertyDeclaration, c,
generateFlags,
getterName, setterName, signalName, storageName));
}