@@ -16,8 +16,8 @@ Formatter *Formatter::fromJson(const QJsonObject &obj) {
1616
1717 f->name = m.value (" name" ).toString ();
1818 f->binary = m.value (" binary" ).toString ();
19- f->stdin = m.value (" stdin" , false ).toBool ();
20- f->stdout = m.value (" stdout" , false ).toBool ();
19+ f->processStdin = m.value (" stdin" , false ).toBool ();
20+ f->processStdout = m.value (" stdout" , false ).toBool ();
2121 f->requiresFilepath = m.value (" requires_filepath" , false ).toBool ();
2222 f->tempfile = m.value (" tempfile" , false ).toBool ();
2323 f->extensions = m.value (" exts" ).toStringList ();
@@ -48,14 +48,14 @@ bool FormatterRegistry::loadFromFile(const QString &jsonFile) {
4848 auto arr = doc.array ();
4949 m_indenters.clear ();
5050 m_extIndex.clear ();
51- for (const auto &v : arr) {
51+ for (auto &v : std::as_const ( arr) ) {
5252 if (!v.isObject ()) {
5353 continue ;
5454 }
5555
5656 auto t = Formatter::fromJson (v.toObject ());
5757 m_indenters.append (t);
58- for (auto const &ext : t->extensions ) {
58+ for (auto &ext : std::as_const ( t->extensions ) ) {
5959 m_extIndex.insert (ext.toLower (), t);
6060 }
6161 }
@@ -67,7 +67,8 @@ const Formatter *FormatterRegistry::getForFile(const QString &filePath) const {
6767 auto info = QFileInfo (filePath);
6868 auto ext = info.suffix ().toLower ();
6969 if (!m_extIndex.contains (ext)) {
70- qDebug () << " FormatterRegistry: no indenter found for suffix" << ext << " of" << filePath << " m_extIndex keys:" << m_extIndex.keys ();
70+ qDebug () << " FormatterRegistry: no indenter found for suffix" << ext << " of" << filePath
71+ << " m_extIndex keys:" << m_extIndex.keys ();
7172 return nullptr ;
7273 }
7374 auto lll = m_extIndex[ext];
@@ -120,6 +121,7 @@ void CodeFormatPlugin::on_client_merged(qmdiHost *host) {
120121 w->connect (w, &QFileSystemWatcher::fileChanged, this , [this ]() {
121122 auto dataDir = QStandardPaths::writableLocation (QStandardPaths::AppConfigLocation);
122123 auto fullFileName = dataDir + QDir::separator () + " indenters.json" ;
124+ fullFileName = QDir::toNativeSeparators (fullFileName);
123125
124126 qDebug () << " Reloading" << fullFileName;
125127 userRegistry.clear ();
@@ -168,7 +170,7 @@ QFuture<CommandArgs> CodeFormatPlugin::handleCommandAsync(const QString &command
168170 for (auto &p : patterns) {
169171 p = p.trimmed ();
170172 }
171- for (const auto &pattern : patterns) {
173+ for (const auto &pattern : std::as_const ( patterns) ) {
172174 auto regex = QRegularExpression (QRegularExpression::wildcardToRegularExpression (pattern),
173175 QRegularExpression::CaseInsensitiveOption);
174176 if (regex.match (baseName).hasMatch ()) {
@@ -211,7 +213,7 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
211213 result[GlobalArguments::ExitCode] = 0 ;
212214
213215 args.reserve (indenter->args .size ());
214- for (auto arg : indenter->args ) {
216+ for (const auto & arg : indenter->args ) {
215217 QString a = arg;
216218 args.append (a.replace (" $filepath" , fileName));
217219 }
@@ -237,7 +239,7 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
237239 result[GlobalArguments::ErrorMessage] = tr (" Failed running %1" ).arg (fullCommand);
238240 return result;
239241 }
240- if (indenter->stdin ) {
242+ if (indenter->processStdin ) {
241243 proc.write (input.toUtf8 ());
242244 proc.closeWriteChannel ();
243245 }
@@ -249,15 +251,15 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
249251 }
250252
251253 if (proc.exitCode () != 0 ) {
252- auto stderr = proc.readAllStandardError ();
254+ auto processStderr = proc.readAllStandardError ();
253255 qDebug () << " CodeFormatPlugin:" << indenter->binary << " code:" << proc.exitCode ();
254- qDebug () << " CodeFormatPlugin stderr:" << stderr ;
256+ qDebug () << " CodeFormatPlugin stderr:" << processStderr ;
255257 result[GlobalArguments::ExitCode] = proc.exitCode ();
256- result[GlobalArguments::ErrorMessage] = stderr ;
258+ result[GlobalArguments::ErrorMessage] = processStderr ;
257259 return result;
258260 }
259261
260- if (indenter->stdout ) {
262+ if (indenter->processStdout ) {
261263 auto out = proc.readAllStandardOutput ();
262264 if (!out.isEmpty ()) {
263265 result[GlobalArguments::Content] = QString::fromUtf8 (out);
@@ -266,7 +268,7 @@ QFuture<CommandArgs> CodeFormatPlugin::runFormat(const QString &fileName, const
266268 qDebug () << " CodeFormatPlugin: stdout is empty for" << indenter->binary ;
267269 }
268270 }
269- if (!indenter->stdout && indenter->tempfile ) {
271+ if (!indenter->processStdout && indenter->tempfile ) {
270272 auto file = QFile (fileName);
271273 if (file.open (QIODevice::ReadOnly)) {
272274 result[GlobalArguments::Content] = QString::fromUtf8 (file.readAll ());
0 commit comments