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


C++ TagEntryPtr::IsStruct方法代码示例

本文整理汇总了C++中TagEntryPtr::IsStruct方法的典型用法代码示例。如果您正苦于以下问题:C++ TagEntryPtr::IsStruct方法的具体用法?C++ TagEntryPtr::IsStruct怎么用?C++ TagEntryPtr::IsStruct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TagEntryPtr的用法示例。


在下文中一共展示了TagEntryPtr::IsStruct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoResolveWord

bool RefactoringEngine::DoResolveWord(TextStatesPtr states, const wxFileName& fn, int pos, int line, const wxString &word, RefactorSource *rs)
{
    std::vector<TagEntryPtr> tags;

    // try to process the current expression
    wxString expr = GetExpression(pos, states);

    // sanity
    if(states->text.length() < (size_t)pos + 1)
        return false;

    // get the scope
    // Optimize the text for large files
    wxString text(states->text.substr(0, pos + 1));

    // we simply collect declarations & implementations

    //try implemetation first
    bool found(false);
    TagsManagerST::Get()->FindImplDecl(fn, line, expr, word, text, tags, true, true);
    if (tags.empty() == false) {
        // try to see if we got a function and not class/struct

        for (size_t i=0; i<tags.size(); i++) {
            TagEntryPtr tag = tags.at(i);
            // find first non class/struct tag
            if (tag->GetKind() != wxT("class") && tag->GetKind() != wxT("struct")) {

                // if there is no match, add it anyways
                if (!found) {
                    rs->isClass = (tag->GetKind() == wxT("class") ||tag->GetKind() == wxT("struct"));
                    rs->name = tag->GetName();
                    rs->scope = tag->GetScope();
                    found = true;
                } else if (rs->scope == wxT("<global>") && rs->isClass == false) {
                    // give predecense to <global> variables
                    rs->isClass = (tag->GetKind() == wxT("class") ||tag->GetKind() == wxT("struct"));
                    rs->name = tag->GetName();
                    rs->scope = tag->GetScope();
                    found = true;
                }
                found = true;
            }
        }

        // if no match was found, keep the first result but keep searching
        if ( !found ) {

            TagEntryPtr tag = tags.at(0);
            rs->scope   = tag->GetScope();
            rs->name    = tag->GetName();
            rs->isClass = tag->IsClass() || tag->IsStruct();
            found = true;

        } else {
            return true;

        }
    }

    // Ok, the "implementation" search did not yield definite results, try declaration
    tags.clear();
    TagsManagerST::Get()->FindImplDecl(fn, line, expr, word, text, tags, false, true);
    if (tags.empty() == false) {
        // try to see if we got a function and not class/struct
        for (size_t i=0; i<tags.size(); i++) {
            TagEntryPtr tag = tags.at(i);
            // find first non class/struct tag
            if (tag->GetKind() != wxT("class") && tag->GetKind() != wxT("struct")) {
                rs->name = tag->GetName();
                rs->scope = tag->GetScope();
                return true;
            }
        }

        // if no match was found, keep the first result but keep searching
        if ( !found ) {
            TagEntryPtr tag = tags.at(0);
            rs->scope    = tag->GetScope();
            rs->name     = tag->GetName();
            rs->isClass  = tag->IsClass() || tag->IsStruct();
        }
        return true;
    }

    // if we got so far, CC failed to parse the expression
    return false;
}
开发者ID:AndrianDTR,项目名称:codelite,代码行数:88,代码来源:refactorengine.cpp


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