当前位置: 首页>>代码示例>>C++>>正文


C++ Symbol::asDeclaration方法代码示例

本文整理汇总了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;
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例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;
 }
开发者ID:C-sjia,项目名称:qt-creator,代码行数:26,代码来源:ResolveExpression.cpp

示例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));
}
开发者ID:NoobSaibot,项目名称:qtcreator-minimap,代码行数:74,代码来源:cppinsertqtpropertymembers.cpp


注:本文中的Symbol::asDeclaration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。