forked from qt-creator/qt-creator
ClangCodeModel: Add some clangd completion logging
Change-Id: I35dea3ad2815683181eb5dfbe1ea7d985037f55c Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -94,6 +94,8 @@ static Q_LOGGING_CATEGORY(clangdLogServer, "qtc.clangcodemodel.clangd.server", Q
|
|||||||
static Q_LOGGING_CATEGORY(clangdLogAst, "qtc.clangcodemodel.clangd.ast", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(clangdLogAst, "qtc.clangcodemodel.clangd.ast", QtWarningMsg);
|
||||||
static Q_LOGGING_CATEGORY(clangdLogHighlight, "qtc.clangcodemodel.clangd.highlight", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(clangdLogHighlight, "qtc.clangcodemodel.clangd.highlight", QtWarningMsg);
|
||||||
static Q_LOGGING_CATEGORY(clangdLogTiming, "qtc.clangcodemodel.clangd.timing", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(clangdLogTiming, "qtc.clangcodemodel.clangd.timing", QtWarningMsg);
|
||||||
|
static Q_LOGGING_CATEGORY(clangdLogCompletion, "qtc.clangcodemodel.clangd.completion",
|
||||||
|
QtWarningMsg);
|
||||||
static QString indexingToken() { return "backgroundIndexProgress"; }
|
static QString indexingToken() { return "backgroundIndexProgress"; }
|
||||||
|
|
||||||
static QStringView subViewLen(const QString &s, qsizetype start, qsizetype length)
|
static QStringView subViewLen(const QString &s, qsizetype start, qsizetype length)
|
||||||
@@ -2582,19 +2584,26 @@ ClangdClient::ClangdCompletionAssistProvider::ClangdCompletionAssistProvider(Cla
|
|||||||
IAssistProcessor *ClangdClient::ClangdCompletionAssistProvider::createProcessor(
|
IAssistProcessor *ClangdClient::ClangdCompletionAssistProvider::createProcessor(
|
||||||
const AssistInterface *interface) const
|
const AssistInterface *interface) const
|
||||||
{
|
{
|
||||||
|
qCDebug(clangdLogCompletion) << "completion processor requested for" << interface->filePath();
|
||||||
|
qCDebug(clangdLogCompletion) << "text before cursor is"
|
||||||
|
<< interface->textAt(interface->position(), -10);
|
||||||
|
qCDebug(clangdLogCompletion) << "text after cursor is"
|
||||||
|
<< interface->textAt(interface->position(), 10);
|
||||||
ClangCompletionContextAnalyzer contextAnalyzer(interface->textDocument(),
|
ClangCompletionContextAnalyzer contextAnalyzer(interface->textDocument(),
|
||||||
interface->position(), false, {});
|
interface->position(), false, {});
|
||||||
contextAnalyzer.analyze();
|
contextAnalyzer.analyze();
|
||||||
switch (contextAnalyzer.completionAction()) {
|
switch (contextAnalyzer.completionAction()) {
|
||||||
case ClangCompletionContextAnalyzer::PassThroughToLibClangAfterLeftParen:
|
case ClangCompletionContextAnalyzer::PassThroughToLibClangAfterLeftParen:
|
||||||
qCDebug(clangdLog) << "completion changed to function hint";
|
qCDebug(clangdLogCompletion) << "creating function hint processor";
|
||||||
return new ClangdFunctionHintProcessor(m_client);
|
return new ClangdFunctionHintProcessor(m_client);
|
||||||
case ClangCompletionContextAnalyzer::CompleteDoxygenKeyword:
|
case ClangCompletionContextAnalyzer::CompleteDoxygenKeyword:
|
||||||
|
qCDebug(clangdLogCompletion) << "creating doxygen processor";
|
||||||
return new CustomAssistProcessor(m_client,
|
return new CustomAssistProcessor(m_client,
|
||||||
contextAnalyzer.positionForProposal(),
|
contextAnalyzer.positionForProposal(),
|
||||||
contextAnalyzer.completionOperator(),
|
contextAnalyzer.completionOperator(),
|
||||||
CustomAssistMode::Doxygen);
|
CustomAssistMode::Doxygen);
|
||||||
case ClangCompletionContextAnalyzer::CompletePreprocessorDirective:
|
case ClangCompletionContextAnalyzer::CompletePreprocessorDirective:
|
||||||
|
qCDebug(clangdLogCompletion) << "creating macro processor";
|
||||||
return new CustomAssistProcessor(m_client,
|
return new CustomAssistProcessor(m_client,
|
||||||
contextAnalyzer.positionForProposal(),
|
contextAnalyzer.positionForProposal(),
|
||||||
contextAnalyzer.completionOperator(),
|
contextAnalyzer.completionOperator(),
|
||||||
@@ -2605,6 +2614,8 @@ IAssistProcessor *ClangdClient::ClangdCompletionAssistProvider::createProcessor(
|
|||||||
const QString snippetsGroup = contextAnalyzer.addSnippets() && !isInCommentOrString(interface)
|
const QString snippetsGroup = contextAnalyzer.addSnippets() && !isInCommentOrString(interface)
|
||||||
? CppEditor::Constants::CPP_SNIPPETS_GROUP_ID
|
? CppEditor::Constants::CPP_SNIPPETS_GROUP_ID
|
||||||
: QString();
|
: QString();
|
||||||
|
qCDebug(clangdLogCompletion) << "creating proper completion processor"
|
||||||
|
<< (snippetsGroup.isEmpty() ? "without" : "with") << "snippets";
|
||||||
return new ClangdCompletionAssistProcessor(m_client, snippetsGroup);
|
return new ClangdCompletionAssistProcessor(m_client, snippetsGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2625,6 +2636,7 @@ bool ClangdClient::ClangdCompletionAssistProvider::isActivationCharSequence(cons
|
|||||||
// contexts, such as '(', '<' or '/'.
|
// contexts, such as '(', '<' or '/'.
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case T_DOT: case T_COLON_COLON: case T_ARROW: case T_DOT_STAR: case T_ARROW_STAR: case T_POUND:
|
case T_DOT: case T_COLON_COLON: case T_ARROW: case T_DOT_STAR: case T_ARROW_STAR: case T_POUND:
|
||||||
|
qCDebug(clangdLogCompletion) << "detected" << sequence << "as activation char sequence";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user