2015-06-01 18:51:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:14 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:57:14 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-09-07 10:42:12 +02:00
|
|
|
#include "clangdocument.h"
|
|
|
|
|
#include "clangdocuments.h"
|
2016-09-08 15:49:54 +02:00
|
|
|
#include "clangdocumentprocessors.h"
|
|
|
|
|
#include "clangjobrequest.h"
|
2015-06-16 12:38:04 +02:00
|
|
|
#include "unsavedfiles.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2017-08-24 15:22:37 +02:00
|
|
|
#include <clangcodemodelserverinterface.h>
|
|
|
|
|
#include <ipcclientprovider.h>
|
2015-06-01 18:51:55 +02:00
|
|
|
#include <utf8string.h>
|
|
|
|
|
|
2016-05-31 16:07:09 +02:00
|
|
|
#include <QScopedPointer>
|
2015-08-26 16:47:38 +02:00
|
|
|
#include <QTimer>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
namespace ClangBackEnd {
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2018-01-10 14:54:45 +01:00
|
|
|
struct DocumentResetInfo {
|
|
|
|
|
Document documentToRemove;
|
|
|
|
|
FileContainer fileContainer;
|
|
|
|
|
};
|
|
|
|
|
using DocumentResetInfos = QVector<DocumentResetInfo>;
|
|
|
|
|
|
2017-08-24 15:22:37 +02:00
|
|
|
class ClangCodeModelServer : public ClangCodeModelServerInterface,
|
|
|
|
|
public IpcClientProvider<ClangCodeModelClientInterface>
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2016-06-29 16:49:56 +02:00
|
|
|
ClangCodeModelServer();
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
void end() override;
|
2018-05-31 15:21:53 +02:00
|
|
|
|
|
|
|
|
void documentsOpened(const DocumentsOpenedMessage &message) override;
|
|
|
|
|
void documentsChanged(const DocumentsChangedMessage &message) override;
|
|
|
|
|
void documentsClosed(const DocumentsClosedMessage &message) override;
|
|
|
|
|
void documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) override;
|
|
|
|
|
|
|
|
|
|
void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override;
|
|
|
|
|
void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override;
|
|
|
|
|
|
|
|
|
|
void requestCompletions(const RequestCompletionsMessage &message) override;
|
|
|
|
|
void requestAnnotations(const RequestAnnotationsMessage &message) override;
|
2017-06-09 12:19:09 +02:00
|
|
|
void requestReferences(const RequestReferencesMessage &message) override;
|
2017-07-27 10:58:05 +02:00
|
|
|
void requestFollowSymbol(const RequestFollowSymbolMessage &message) override;
|
2018-01-12 12:29:43 +01:00
|
|
|
void requestToolTip(const RequestToolTipMessage &message) override;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2016-09-08 15:49:54 +02:00
|
|
|
public: // for tests
|
2016-09-07 10:42:12 +02:00
|
|
|
const Documents &documentsForTestOnly() const;
|
2016-09-08 15:49:54 +02:00
|
|
|
QList<Jobs::RunningJob> runningJobsForTestsOnly();
|
|
|
|
|
int queueSizeForTestsOnly();
|
2016-05-31 16:07:09 +02:00
|
|
|
bool isTimerRunningForTestOnly() const;
|
2018-05-31 15:21:53 +02:00
|
|
|
void setUpdateAnnotationsTimeOutInMsForTestsOnly(int value);
|
2016-10-14 13:05:44 +02:00
|
|
|
void setUpdateVisibleButNotCurrentDocumentsTimeOutInMsForTestsOnly(int value);
|
2016-09-14 16:16:10 +02:00
|
|
|
DocumentProcessors &documentProcessors();
|
2015-10-13 15:56:41 +02:00
|
|
|
|
2015-10-13 12:54:22 +02:00
|
|
|
private:
|
2016-09-07 10:42:12 +02:00
|
|
|
void processInitialJobsForDocuments(const std::vector<Document> &documents);
|
2018-06-05 13:05:47 +02:00
|
|
|
void processJobsForVisibleDocuments();
|
|
|
|
|
void processJobsForCurrentDocument();
|
2016-10-14 13:05:44 +02:00
|
|
|
void processTimerForVisibleButNotCurrentDocuments();
|
2017-07-28 15:15:46 +02:00
|
|
|
void processSuspendResumeJobs(const std::vector<Document> &documents);
|
2016-10-14 13:05:44 +02:00
|
|
|
|
2018-01-10 14:54:45 +01:00
|
|
|
void categorizeFileContainers(const QVector<FileContainer> &fileContainers,
|
|
|
|
|
QVector<FileContainer> &toCreate,
|
|
|
|
|
DocumentResetInfos &toReset) const;
|
|
|
|
|
std::vector<Document> resetDocuments(const DocumentResetInfos &infos);
|
|
|
|
|
|
2017-05-04 11:49:31 +02:00
|
|
|
void addAndRunUpdateJobs(std::vector<Document> documents);
|
2016-10-14 13:05:44 +02:00
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
private:
|
|
|
|
|
UnsavedFiles unsavedFiles;
|
2016-09-07 10:42:12 +02:00
|
|
|
Documents documents;
|
2016-09-08 15:49:54 +02:00
|
|
|
|
|
|
|
|
QScopedPointer<DocumentProcessors> documentProcessors_; // Delayed initialization
|
2016-05-31 16:07:09 +02:00
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
QTimer updateAnnotationsTimer;
|
|
|
|
|
int updateAnnotationsTimeOutInMs = 1500;
|
2016-10-14 13:05:44 +02:00
|
|
|
|
|
|
|
|
QTimer updateVisibleButNotCurrentDocumentsTimer;
|
|
|
|
|
int updateVisibleButNotCurrentDocumentsTimeOutInMs = 2000;
|
2015-06-01 18:51:55 +02:00
|
|
|
};
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
} // namespace ClangBackEnd
|