CppEditor: Pass CommentsSettings into DoxygenGenerator

... instead of forwarding each member separately.

Change-Id: I0639cc81716df70e8f286cb4b5f02554e1f56b95
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Christian Kandeler
2023-08-08 10:51:53 +02:00
parent 68c76e072d
commit 45f4ea6da5
3 changed files with 10 additions and 26 deletions

View File

@@ -340,8 +340,7 @@ static bool trySplitComment(TextEditor::TextEditorWidget *editorWidget,
DoxygenGenerator doxygen; DoxygenGenerator doxygen;
doxygen.setStyle(style); doxygen.setStyle(style);
doxygen.setAddLeadingAsterisks(settings.leadingAsterisks); doxygen.setSettings(settings);
doxygen.setGenerateBrief(settings.generateBrief);
// Move until we reach any possibly meaningful content. // Move until we reach any possibly meaningful content.
while (textDocument->characterAt(cursor.position()).isSpace() while (textDocument->characterAt(cursor.position()).isSpace()

View File

@@ -24,21 +24,6 @@ namespace CppEditor::Internal {
DoxygenGenerator::DoxygenGenerator() = default; DoxygenGenerator::DoxygenGenerator() = default;
void DoxygenGenerator::setStyle(DocumentationStyle style)
{
m_style = style;
}
void DoxygenGenerator::setGenerateBrief(bool get)
{
m_generateBrief = get;
}
void DoxygenGenerator::setAddLeadingAsterisks(bool add)
{
m_addLeadingAsterisks = add;
}
QString DoxygenGenerator::generate(QTextCursor cursor, QString DoxygenGenerator::generate(QTextCursor cursor,
const CPlusPlus::Snapshot &snapshot, const CPlusPlus::Snapshot &snapshot,
const Utils::FilePath &documentFilePath) const Utils::FilePath &documentFilePath)
@@ -139,7 +124,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
&& decltr->core_declarator->asDeclaratorId() && decltr->core_declarator->asDeclaratorId()
&& decltr->core_declarator->asDeclaratorId()->name) { && decltr->core_declarator->asDeclaratorId()->name) {
CoreDeclaratorAST *coreDecl = decltr->core_declarator; CoreDeclaratorAST *coreDecl = decltr->core_declarator;
if (m_generateBrief) if (m_settings.generateBrief)
writeBrief(&comment, m_printer.prettyName(coreDecl->asDeclaratorId()->name->name)); writeBrief(&comment, m_printer.prettyName(coreDecl->asDeclaratorId()->name->name));
else else
writeNewLine(&comment); writeNewLine(&comment);
@@ -177,7 +162,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
writeCommand(&comment, ReturnCommand); writeCommand(&comment, ReturnCommand);
} }
} }
} else if (spec && m_generateBrief) { } else if (spec && m_settings.generateBrief) {
bool briefWritten = false; bool briefWritten = false;
if (ClassSpecifierAST *classSpec = spec->asClassSpecifier()) { if (ClassSpecifierAST *classSpec = spec->asClassSpecifier()) {
if (classSpec->name) { if (classSpec->name) {
@@ -248,7 +233,7 @@ void DoxygenGenerator::writeContinuation(QString *comment) const
comment->append(offsetString() + "///"); comment->append(offsetString() + "///");
else if (m_style == CppStyleB) else if (m_style == CppStyleB)
comment->append(offsetString() + "//!"); comment->append(offsetString() + "//!");
else if (m_addLeadingAsterisks) else if (m_settings.leadingAsterisks)
comment->append(offsetString() + " *"); comment->append(offsetString() + " *");
else else
comment->append(offsetString() + " "); comment->append(offsetString() + " ");

View File

@@ -3,6 +3,8 @@
#pragma once #pragma once
#include <texteditor/commentssettings.h>
#include <cplusplus/Overview.h> #include <cplusplus/Overview.h>
QT_FORWARD_DECLARE_CLASS(QTextCursor) QT_FORWARD_DECLARE_CLASS(QTextCursor)
@@ -25,9 +27,8 @@ public:
CppStyleB ///< CppStyle comment variant B: //! CppStyleB ///< CppStyle comment variant B: //!
}; };
void setStyle(DocumentationStyle style); void setStyle(DocumentationStyle style) { m_style = style; }
void setGenerateBrief(bool gen); void setSettings(const TextEditor::CommentsSettings::Data &settings) { m_settings = settings; }
void setAddLeadingAsterisks(bool add);
QString generate(QTextCursor cursor, QString generate(QTextCursor cursor,
const CPlusPlus::Snapshot &snapshot, const CPlusPlus::Snapshot &snapshot,
@@ -58,11 +59,10 @@ private:
void assignCommentOffset(QTextCursor cursor); void assignCommentOffset(QTextCursor cursor);
QString offsetString() const; QString offsetString() const;
bool m_addLeadingAsterisks = true; TextEditor::CommentsSettings::Data m_settings;
bool m_generateBrief = true;
DocumentationStyle m_style = QtStyle;
CPlusPlus::Overview m_printer; CPlusPlus::Overview m_printer;
QString m_commentOffset; QString m_commentOffset;
DocumentationStyle m_style = QtStyle;
}; };
} // namespace CppEditor::Internal } // namespace CppEditor::Internal