forked from qt-creator/qt-creator
ClangFormat: Replace checks widget with editor
The existing approach utilizing the widget poses maintenance challenges, primarily due to the dynamic nature of clang-format settings across versions. The widget necessitates regeneration for each new version, and compatibility issues arise when users have different clang-format versions on their devices. The updated solution adopts an Editor integrated with a yaml language server, offering the ability to highlight and provide code completion for the .clang-format file. This resolves the widget regeneration issue and ensures compatibility with various clang-format versions. - Replaced the checks widget with an editor - Introduced a line for yaml language server schema in .clang-format files to enable autocompletion. ToDo: Enhance schema accessibility without relying on this line. - Added Ctrl+Space shortcut for autocompletion - Added Ctrl+S shortcut for saving - Eliminated outdated logic related to the checks widget - Fixed copying and removal of clang-format settings Change-Id: I2e3fbf19abe2f4df031f6ba5faffd47e07274346 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -539,6 +539,7 @@ public:
|
||||
|
||||
clang::format::FormatStyle customSettingsStyle(const FilePath &fileName) const;
|
||||
ICodeStylePreferences *m_overriddenPreferences = nullptr;
|
||||
clang::format::FormatStyle m_overriddenStyle = clang::format::getNoStyle();
|
||||
};
|
||||
|
||||
ClangFormatBaseIndenter::ClangFormatBaseIndenter(QTextDocument *doc)
|
||||
@@ -870,6 +871,9 @@ const clang::format::FormatStyle &ClangFormatBaseIndenterPrivate::styleForFile()
|
||||
{
|
||||
static const milliseconds cacheTimeout = getCacheTimeout();
|
||||
|
||||
if (!(m_overriddenStyle == clang::format::getNoStyle()))
|
||||
return m_overriddenStyle;
|
||||
|
||||
QDateTime time = QDateTime::currentDateTime();
|
||||
if (m_cachedStyle.expirationTime > time && !(m_cachedStyle.style == clang::format::getNoStyle()))
|
||||
return m_cachedStyle.style;
|
||||
@@ -907,4 +911,9 @@ void ClangFormatBaseIndenter::setOverriddenPreferences(ICodeStylePreferences *pr
|
||||
d->m_overriddenPreferences = preferences;
|
||||
}
|
||||
|
||||
void ClangFormatBaseIndenter::setOverriddenStyle(const clang::format::FormatStyle &style)
|
||||
{
|
||||
d->m_overriddenStyle = style;
|
||||
}
|
||||
|
||||
} // namespace ClangFormat
|
||||
|
||||
Reference in New Issue
Block a user