2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 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
|
|
|
|
2015-07-23 13:01:02 +02:00
|
|
|
#include <cplusplus/Token.h>
|
|
|
|
|
|
|
|
|
|
#include <QTextCursor>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTextDocument;
|
|
|
|
|
QT_END_NAMESPACE
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
namespace ClangCodeModel {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-07-23 13:01:02 +02:00
|
|
|
class ActivationSequenceContextProcessor
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-07-23 13:01:02 +02:00
|
|
|
public:
|
2021-06-18 16:30:03 +02:00
|
|
|
ActivationSequenceContextProcessor(QTextDocument *document, int position,
|
|
|
|
|
CPlusPlus::LanguageFeatures languageFeatures);
|
2015-07-23 13:01:02 +02:00
|
|
|
|
|
|
|
|
CPlusPlus::Kind completionKind() const;
|
2015-07-23 16:06:48 +02:00
|
|
|
int startOfNamePosition() const; // e.g. points to 'b' in "foo.bar<CURSOR>"
|
|
|
|
|
int operatorStartPosition() const; // e.g. points to '.' for "foo.bar<CURSOR>"
|
2015-07-23 13:01:02 +02:00
|
|
|
|
|
|
|
|
const QTextCursor &textCursor_forTestOnly() const;
|
|
|
|
|
|
2017-10-17 12:48:07 +02:00
|
|
|
enum class NameCategory { Function, NonFunction };
|
2021-06-18 16:30:03 +02:00
|
|
|
static int findStartOfName(const QTextDocument *document,
|
2017-10-17 12:48:07 +02:00
|
|
|
int startPosition,
|
|
|
|
|
NameCategory category = NameCategory::NonFunction);
|
2021-06-18 16:30:03 +02:00
|
|
|
static int skipPrecedingWhitespace(const QTextDocument *document,
|
2015-07-24 15:35:20 +02:00
|
|
|
int startPosition);
|
|
|
|
|
|
2015-07-23 13:01:02 +02:00
|
|
|
protected:
|
|
|
|
|
void process();
|
2015-07-23 16:06:48 +02:00
|
|
|
void goBackToStartOfName();
|
2015-07-23 13:01:02 +02:00
|
|
|
void processActivationSequence();
|
|
|
|
|
void processStringLiteral();
|
|
|
|
|
void processComma();
|
|
|
|
|
void generateTokens();
|
|
|
|
|
void processDoxygenComment();
|
|
|
|
|
void processComment();
|
|
|
|
|
void processInclude();
|
|
|
|
|
void processSlashOutsideOfAString();
|
2018-08-20 13:15:13 +02:00
|
|
|
void processLeftParenOrBrace();
|
2015-07-23 13:01:02 +02:00
|
|
|
void processPreprocessorInclude();
|
2015-07-23 16:06:48 +02:00
|
|
|
void resetPositionsForEOFCompletionKind();
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-07-23 13:01:02 +02:00
|
|
|
bool isCompletionKindStringLiteralOrSlash() const;
|
|
|
|
|
bool isProbablyPreprocessorIncludeDirective() const;
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-07-23 13:01:02 +02:00
|
|
|
private:
|
|
|
|
|
QVector<CPlusPlus::Token> m_tokens;
|
|
|
|
|
QTextCursor m_textCursor;
|
|
|
|
|
CPlusPlus::Token m_token;
|
2021-06-18 16:30:03 +02:00
|
|
|
QTextDocument * const m_document;
|
|
|
|
|
const CPlusPlus::LanguageFeatures m_languageFeatures;
|
2015-07-23 13:01:02 +02:00
|
|
|
int m_tokenIndex;
|
2015-07-23 16:06:48 +02:00
|
|
|
const int m_positionInDocument;
|
|
|
|
|
int m_startOfNamePosition;
|
|
|
|
|
int m_operatorStartPosition;
|
2015-07-23 13:01:02 +02:00
|
|
|
CPlusPlus::Kind m_completionKind;
|
2015-05-08 15:48:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangCodeModel
|