forked from qt-creator/qt-creator
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:
@@ -340,8 +340,7 @@ static bool trySplitComment(TextEditor::TextEditorWidget *editorWidget,
|
||||
|
||||
DoxygenGenerator doxygen;
|
||||
doxygen.setStyle(style);
|
||||
doxygen.setAddLeadingAsterisks(settings.leadingAsterisks);
|
||||
doxygen.setGenerateBrief(settings.generateBrief);
|
||||
doxygen.setSettings(settings);
|
||||
|
||||
// Move until we reach any possibly meaningful content.
|
||||
while (textDocument->characterAt(cursor.position()).isSpace()
|
||||
|
||||
@@ -24,21 +24,6 @@ namespace CppEditor::Internal {
|
||||
|
||||
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,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const Utils::FilePath &documentFilePath)
|
||||
@@ -139,7 +124,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
|
||||
&& decltr->core_declarator->asDeclaratorId()
|
||||
&& decltr->core_declarator->asDeclaratorId()->name) {
|
||||
CoreDeclaratorAST *coreDecl = decltr->core_declarator;
|
||||
if (m_generateBrief)
|
||||
if (m_settings.generateBrief)
|
||||
writeBrief(&comment, m_printer.prettyName(coreDecl->asDeclaratorId()->name->name));
|
||||
else
|
||||
writeNewLine(&comment);
|
||||
@@ -177,7 +162,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
|
||||
writeCommand(&comment, ReturnCommand);
|
||||
}
|
||||
}
|
||||
} else if (spec && m_generateBrief) {
|
||||
} else if (spec && m_settings.generateBrief) {
|
||||
bool briefWritten = false;
|
||||
if (ClassSpecifierAST *classSpec = spec->asClassSpecifier()) {
|
||||
if (classSpec->name) {
|
||||
@@ -248,7 +233,7 @@ void DoxygenGenerator::writeContinuation(QString *comment) const
|
||||
comment->append(offsetString() + "///");
|
||||
else if (m_style == CppStyleB)
|
||||
comment->append(offsetString() + "//!");
|
||||
else if (m_addLeadingAsterisks)
|
||||
else if (m_settings.leadingAsterisks)
|
||||
comment->append(offsetString() + " *");
|
||||
else
|
||||
comment->append(offsetString() + " ");
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <texteditor/commentssettings.h>
|
||||
|
||||
#include <cplusplus/Overview.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTextCursor)
|
||||
@@ -25,9 +27,8 @@ public:
|
||||
CppStyleB ///< CppStyle comment variant B: //!
|
||||
};
|
||||
|
||||
void setStyle(DocumentationStyle style);
|
||||
void setGenerateBrief(bool gen);
|
||||
void setAddLeadingAsterisks(bool add);
|
||||
void setStyle(DocumentationStyle style) { m_style = style; }
|
||||
void setSettings(const TextEditor::CommentsSettings::Data &settings) { m_settings = settings; }
|
||||
|
||||
QString generate(QTextCursor cursor,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
@@ -58,11 +59,10 @@ private:
|
||||
void assignCommentOffset(QTextCursor cursor);
|
||||
QString offsetString() const;
|
||||
|
||||
bool m_addLeadingAsterisks = true;
|
||||
bool m_generateBrief = true;
|
||||
DocumentationStyle m_style = QtStyle;
|
||||
TextEditor::CommentsSettings::Data m_settings;
|
||||
CPlusPlus::Overview m_printer;
|
||||
QString m_commentOffset;
|
||||
DocumentationStyle m_style = QtStyle;
|
||||
};
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
|
||||
Reference in New Issue
Block a user