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


C++ CppModelManager类代码示例

本文整理汇总了C++中CppModelManager的典型用法代码示例。如果您正苦于以下问题:C++ CppModelManager类的具体用法?C++ CppModelManager怎么用?C++ CppModelManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1:

BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &filePath)
{
    CppModelManager *cmmi = CppModelManager::instance();
    if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath))
        return cppEditorDocument->processor();
    return 0;
}
开发者ID:55171514,项目名称:qtcreator,代码行数:7,代码来源:baseeditordocumentprocessor.cpp

示例2: determineProjectPart

ProjectPart::Ptr BaseEditorDocumentParser::determineProjectPart(const QString &filePath,
                                                                const Configuration &config,
                                                                const State &state)
{
    if (config.manuallySetProjectPart)
        return config.manuallySetProjectPart;

    ProjectPart::Ptr projectPart = state.projectPart;

    CppModelManager *cmm = CppModelManager::instance();
    QList<ProjectPart::Ptr> projectParts = cmm->projectPart(filePath);
    if (projectParts.isEmpty()) {
        if (projectPart && config.stickToPreviousProjectPart)
            // File is not directly part of any project, but we got one before. We will re-use it,
            // because re-calculating this can be expensive when the dependency table is big.
            return projectPart;

        // Fall-back step 1: Get some parts through the dependency table:
        projectParts = cmm->projectPartFromDependencies(Utils::FileName::fromString(filePath));
        if (projectParts.isEmpty())
            // Fall-back step 2: Use fall-back part from the model manager:
            projectPart = cmm->fallbackProjectPart();
        else
            projectPart = projectParts.first();
    } else {
        if (!projectParts.contains(projectPart))
            // Apparently the project file changed, so update our project part.
            projectPart = projectParts.first();
    }

    return projectPart;
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:32,代码来源:baseeditordocumentparser.cpp

示例3: instance

/*!
 * \brief createSourceProcessor Create a new source processor, which will signal the
 * model manager when a document has been processed.
 *
 * Indexed file is truncated version of fully parsed document: copy of source
 * code and full AST will be dropped when indexing is done.
 *
 * \return a new source processor object, which the caller needs to delete when finished.
 */
CppSourceProcessor *CppModelManager::createSourceProcessor()
{
    CppModelManager *that = instance();
    return new CppSourceProcessor(that->snapshot(), [that](const Document::Ptr &doc) {
        that->emitDocumentUpdated(doc);
        doc->releaseSourceAndAST();
    });
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:17,代码来源:cppmodelmanager.cpp

示例4: get

BaseEditorDocumentParser::Ptr BaseEditorDocumentParser::get(const QString &filePath)
{
    CppModelManager *cmmi = CppModelManager::instance();
    if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) {
        if (BaseEditorDocumentProcessor *processor = cppEditorDocument->processor())
            return processor->parser();
    }
    return BaseEditorDocumentParser::Ptr();
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:9,代码来源:baseeditordocumentparser.cpp

示例5: cleanup

void ModelManagerTestHelper::cleanup()
{
    CppModelManager *mm = CppModelManager::instance();
    QList<ProjectInfo> pies = mm->projectInfos();
    foreach (const ProjectInfo &pie, pies)
        emit aboutToRemoveProject(pie.project().data());

    if (!pies.isEmpty())
        waitForFinishedGc();
}
开发者ID:UIKit0,项目名称:qt-creator,代码行数:10,代码来源:modelmanagertesthelper.cpp

示例6: instance

/*!
 * \brief createSourceProcessor Create a new source processor, which will signal the
 * model manager when a document has been processed.
 *
 * Indexed file is truncated version of fully parsed document: copy of source
 * code and full AST will be dropped when indexing is done.
 *
 * \return a new source processor object, which the caller needs to delete when finished.
 */
CppSourceProcessor *CppModelManager::createSourceProcessor()
{
    CppModelManager *that = instance();
    return new CppSourceProcessor(that->snapshot(), [that](const Document::Ptr &doc) {
        const Document::Ptr previousDocument = that->document(doc->fileName());
        const unsigned newRevision = previousDocument.isNull()
                ? 1U
                : previousDocument->revision() + 1;
        doc->setRevision(newRevision);
        that->emitDocumentUpdated(doc);
        doc->releaseSourceAndAST();
    });
}
开发者ID:retrobrain,项目名称:qt-creator,代码行数:22,代码来源:cppmodelmanager.cpp

示例7: parse

static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater)
{
    future.setProgressRange(0, 1);
    if (future.isCanceled()) {
        future.setProgressValue(1);
        return;
    }

    CppModelManager *cmm = qobject_cast<CppModelManager *>(CppModelManager::instance());
    updater->update(cmm->workingCopy());
    cmm->finishedRefreshingSourceFiles(QStringList(updater->fileInEditor()));

    future.setProgressValue(1);
}
开发者ID:ryzh945,项目名称:qt-creator,代码行数:14,代码来源:cpptoolseditorsupport.cpp

示例8: verifyClean

void ModelManagerTestHelper::verifyClean()
{
    CppModelManager *mm = CppModelManager::instance();
    assert(mm);

    QVERIFY(mm->projectInfos().isEmpty());
    QVERIFY(mm->includePaths().isEmpty());
    QVERIFY(mm->frameworkPaths().isEmpty());
    QVERIFY(mm->definedMacros().isEmpty());
    QVERIFY(mm->projectFiles().isEmpty());
    QVERIFY(mm->snapshot().isEmpty());
    QCOMPARE(mm->workingCopy().size(), 1);
    QVERIFY(mm->workingCopy().contains(mm->configurationFileName()));
}
开发者ID:Revulet,项目名称:qtcreator,代码行数:14,代码来源:modelmanagertesthelper.cpp

示例9: configuration

void BuiltinEditorDocumentParser::updateHelper(const WorkingCopy &theWorkingCopy)
{
    if (filePath().isEmpty())
        return;

    const Configuration baseConfig = configuration();
    const bool releaseSourceAndAST_ = releaseSourceAndAST();

    State baseState = state();
    ExtraState state = extraState();
    WorkingCopy workingCopy = theWorkingCopy;

    bool invalidateSnapshot = false, invalidateConfig = false, editorDefinesChanged_ = false;

    CppModelManager *modelManager = CppModelManager::instance();
    QByteArray configFile = modelManager->codeModelConfiguration();
    ProjectPartHeaderPaths headerPaths;
    QStringList precompiledHeaders;
    QString projectConfigFile;
    LanguageFeatures features = LanguageFeatures::defaultFeatures();

    baseState.projectPart = determineProjectPart(filePath(), baseConfig, baseState);

    if (state.forceSnapshotInvalidation) {
        invalidateSnapshot = true;
        state.forceSnapshotInvalidation = false;
    }

    if (const ProjectPart::Ptr part = baseState.projectPart) {
        configFile += part->toolchainDefines;
        configFile += overwrittenToolchainDefines(*part.data());
        configFile += part->projectDefines;
        headerPaths = part->headerPaths;
        projectConfigFile = part->projectConfigFile;
        if (baseConfig.usePrecompiledHeaders)
            precompiledHeaders = part->precompiledHeaders;
        features = part->languageFeatures;
    }

    if (configFile != state.configFile) {
        state.configFile = configFile;
        invalidateSnapshot = true;
        invalidateConfig = true;
    }

    if (baseConfig.editorDefines != baseState.editorDefines) {
        baseState.editorDefines = baseConfig.editorDefines;
        invalidateSnapshot = true;
        editorDefinesChanged_ = true;
    }

    if (headerPaths != state.headerPaths) {
        state.headerPaths = headerPaths;
        invalidateSnapshot = true;
    }

    if (projectConfigFile != state.projectConfigFile) {
        state.projectConfigFile = projectConfigFile;
        invalidateSnapshot = true;
    }

    if (precompiledHeaders != state.precompiledHeaders) {
        state.precompiledHeaders = precompiledHeaders;
        invalidateSnapshot = true;
    }

    unsigned rev = 0;
    if (Document::Ptr doc = state.snapshot.document(filePath()))
        rev = doc->revision();
    else
        invalidateSnapshot = true;

    Snapshot globalSnapshot = modelManager->snapshot();

    if (invalidateSnapshot) {
        state.snapshot = Snapshot();
    } else {
        // Remove changed files from the snapshot
        QSet<Utils::FileName> toRemove;
        foreach (const Document::Ptr &doc, state.snapshot) {
            const Utils::FileName fileName = Utils::FileName::fromString(doc->fileName());
            if (workingCopy.contains(fileName)) {
                if (workingCopy.get(fileName).second != doc->editorRevision())
                    addFileAndDependencies(&state.snapshot, &toRemove, fileName);
                continue;
            }
            Document::Ptr otherDoc = globalSnapshot.document(fileName);
            if (!otherDoc.isNull() && otherDoc->revision() != doc->revision())
                addFileAndDependencies(&state.snapshot, &toRemove, fileName);
        }

        if (!toRemove.isEmpty()) {
            invalidateSnapshot = true;
            foreach (const Utils::FileName &fileName, toRemove)
                state.snapshot.remove(fileName);
        }
    }
开发者ID:C-sjia,项目名称:qt-creator,代码行数:97,代码来源:builtineditordocumentparser.cpp

示例10: locker

void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
{
    QMutexLocker locker(&m_mutex);

    if (m_fileInEditor.isEmpty())
        return;

    bool invalidateSnapshot = false, invalidateConfig = false, editorDefinesChanged = false;

    CppModelManager *modelManager
        = dynamic_cast<CppModelManager *>(CppModelManagerInterface::instance());
    QByteArray configFile = modelManager->codeModelConfiguration();
    QStringList includePaths;
    QStringList frameworkPaths;
    QStringList precompiledHeaders;

    updateProjectPart();

    if (m_forceSnapshotInvalidation) {
        invalidateSnapshot = true;
        m_forceSnapshotInvalidation = false;
    }

    if (m_projectPart) {
        configFile += m_projectPart->toolchainDefines;
        configFile += m_projectPart->projectDefines;
        includePaths = m_projectPart->includePaths;
        frameworkPaths = m_projectPart->frameworkPaths;
        if (m_usePrecompiledHeaders)
            precompiledHeaders = m_projectPart->precompiledHeaders;
    }

    if (configFile != m_configFile) {
        m_configFile = configFile;
        invalidateSnapshot = true;
        invalidateConfig = true;
    }

    if (m_editorDefinesChangedSinceLastUpdate) {
        invalidateSnapshot = true;
        editorDefinesChanged = true;
        m_editorDefinesChangedSinceLastUpdate = false;
    }

    if (includePaths != m_includePaths) {
        m_includePaths = includePaths;
        invalidateSnapshot = true;
    }

    if (frameworkPaths != m_frameworkPaths) {
        m_frameworkPaths = frameworkPaths;
        invalidateSnapshot = true;
    }

    if (precompiledHeaders != m_precompiledHeaders) {
        m_precompiledHeaders = precompiledHeaders;
        invalidateSnapshot = true;
    }

    unsigned rev = 0;
    if (Document::Ptr doc = document())
        rev = doc->revision();
    else
        invalidateSnapshot = true;

    Snapshot globalSnapshot = modelManager->snapshot();

    if (invalidateSnapshot) {
        m_snapshot = Snapshot();
    } else {
        // Remove changed files from the snapshot
        QSet<QString> toRemove;
        foreach (const Document::Ptr &doc, m_snapshot) {
            QString fileName = doc->fileName();
            if (workingCopy.contains(fileName)) {
                if (workingCopy.get(fileName).second != doc->editorRevision())
                    addFileAndDependencies(&toRemove, fileName);
                continue;
            }
            Document::Ptr otherDoc = globalSnapshot.document(fileName);
            if (!otherDoc.isNull() && otherDoc->revision() != doc->revision())
                addFileAndDependencies(&toRemove, fileName);
        }

        if (!toRemove.isEmpty()) {
            invalidateSnapshot = true;
            foreach (const QString &fileName, toRemove)
                m_snapshot.remove(fileName);
        }
开发者ID:edwardZhang,项目名称:qt-creator,代码行数:89,代码来源:cppsnapshotupdater.cpp


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