2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
#include <cplusplus/Token.h>
|
|
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
2021-06-18 16:30:03 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTextDocument;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
namespace TextEditor { class AssistInterface; }
|
|
|
|
|
|
|
|
|
|
namespace ClangCodeModel {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class ClangCompletionContextAnalyzer
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-06-18 16:30:03 +02:00
|
|
|
ClangCompletionContextAnalyzer(QTextDocument *document, int position, bool isFunctionHint,
|
|
|
|
|
CPlusPlus::LanguageFeatures languageFeatures);
|
2015-05-08 15:48:17 +02:00
|
|
|
void analyze();
|
|
|
|
|
|
|
|
|
|
enum CompletionAction {
|
|
|
|
|
PassThroughToLibClang,
|
|
|
|
|
PassThroughToLibClangAfterLeftParen,
|
|
|
|
|
CompleteDoxygenKeyword,
|
|
|
|
|
CompleteIncludePath,
|
|
|
|
|
CompletePreprocessorDirective,
|
|
|
|
|
CompleteSignal,
|
2020-07-31 16:50:03 +02:00
|
|
|
CompleteSlot,
|
|
|
|
|
CompleteNone
|
2015-05-08 15:48:17 +02:00
|
|
|
};
|
|
|
|
|
CompletionAction completionAction() const { return m_completionAction; }
|
|
|
|
|
unsigned completionOperator() const { return m_completionOperator; }
|
|
|
|
|
int positionForProposal() const { return m_positionForProposal; }
|
|
|
|
|
int positionForClang() const { return m_positionForClang; }
|
2017-08-10 10:24:54 +02:00
|
|
|
int functionNameStart() const { return m_functionNameStart; }
|
2015-05-08 15:48:17 +02:00
|
|
|
int positionEndOfExpression() const { return m_positionEndOfExpression; }
|
2018-10-24 10:05:53 +02:00
|
|
|
bool addSnippets() const { return m_addSnippets; }
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
private:
|
2017-08-10 10:24:54 +02:00
|
|
|
int startOfFunctionCall(int endOfExpression) const;
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2017-08-10 10:24:54 +02:00
|
|
|
void setActionAndClangPosition(CompletionAction action,
|
|
|
|
|
int position,
|
|
|
|
|
int functionNameStart = -1);
|
2015-07-23 13:01:02 +02:00
|
|
|
void setAction(CompletionAction action);
|
|
|
|
|
|
|
|
|
|
bool handleNonFunctionCall(int position);
|
|
|
|
|
void handleCommaInFunctionCall();
|
|
|
|
|
void handleFunctionCall(int endOfOperator);
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-07-23 13:01:02 +02:00
|
|
|
private:
|
2021-06-18 16:30:03 +02:00
|
|
|
QTextDocument * const m_document;
|
|
|
|
|
const int m_position;
|
|
|
|
|
const bool m_isFunctionHint;
|
|
|
|
|
const CPlusPlus::LanguageFeatures m_languageFeatures;
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
// Results
|
|
|
|
|
CompletionAction m_completionAction = PassThroughToLibClang;
|
2015-07-23 13:01:02 +02:00
|
|
|
CPlusPlus::Kind m_completionOperator = CPlusPlus::T_EOF_SYMBOL;
|
2015-05-08 15:48:17 +02:00
|
|
|
int m_positionForProposal = -1;
|
|
|
|
|
int m_positionForClang = -1;
|
2017-08-10 10:24:54 +02:00
|
|
|
int m_functionNameStart = -1;
|
2015-05-08 15:48:17 +02:00
|
|
|
int m_positionEndOfExpression = -1;
|
2018-10-24 10:05:53 +02:00
|
|
|
bool m_addSnippets = false;
|
2015-05-08 15:48:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangCodeModel
|