2015-07-06 12:05:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-07-06 12:05:02 +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:40 +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-07-06 12:05:02 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +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-07-06 12:05:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "clangcompletionassistprovider.h"
|
|
|
|
|
|
|
|
|
|
#include "clangcompletionassistprocessor.h"
|
2015-10-13 15:56:41 +02:00
|
|
|
#include "clangeditordocumentprocessor.h"
|
2015-07-06 12:05:02 +02:00
|
|
|
#include "clangutils.h"
|
|
|
|
|
|
|
|
|
|
#include <cplusplus/Token.h>
|
|
|
|
|
#include <cpptools/cppcompletionassistprocessor.h>
|
2016-01-12 12:51:33 +01:00
|
|
|
#include <cpptools/projectpart.h>
|
2015-07-06 12:05:02 +02:00
|
|
|
|
|
|
|
|
#include <texteditor/codeassist/assistinterface.h>
|
|
|
|
|
#include <texteditor/codeassist/iassistprocessor.h>
|
|
|
|
|
#include <texteditor/codeassist/iassistprovider.h>
|
|
|
|
|
#include <texteditor/texteditor.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
namespace ClangCodeModel {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-09-25 15:10:48 +02:00
|
|
|
ClangCompletionAssistProvider::ClangCompletionAssistProvider(BackendCommunicator &communicator)
|
|
|
|
|
: m_communicator(communicator)
|
2015-07-06 12:05:02 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditor::IAssistProvider::RunType ClangCompletionAssistProvider::runType() const
|
|
|
|
|
{
|
|
|
|
|
return Asynchronous;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditor::IAssistProcessor *ClangCompletionAssistProvider::createProcessor() const
|
|
|
|
|
{
|
|
|
|
|
return new ClangCompletionAssistProcessor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditor::AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
|
|
|
|
|
const QString &filePath,
|
|
|
|
|
const TextEditor::TextEditorWidget *textEditorWidget,
|
|
|
|
|
const CPlusPlus::LanguageFeatures &/*languageFeatures*/,
|
|
|
|
|
int position,
|
|
|
|
|
TextEditor::AssistReason reason) const
|
|
|
|
|
{
|
2015-10-13 15:56:41 +02:00
|
|
|
const CppTools::ProjectPart::Ptr projectPart = Utils::projectPartForFileBasedOnProcessor(filePath);
|
|
|
|
|
if (projectPart) {
|
2017-09-25 15:10:48 +02:00
|
|
|
return new ClangCompletionAssistInterface(m_communicator,
|
2015-10-13 15:56:41 +02:00
|
|
|
textEditorWidget,
|
|
|
|
|
position,
|
|
|
|
|
filePath,
|
|
|
|
|
reason,
|
|
|
|
|
projectPart->headerPaths,
|
|
|
|
|
projectPart->languageFeatures);
|
|
|
|
|
}
|
2015-07-06 12:05:02 +02:00
|
|
|
|
2015-10-13 15:56:41 +02:00
|
|
|
return 0;
|
2015-07-06 12:05:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangCodeModel
|