mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-07-18 21:14:34 -04:00
chore: Run clang-format over the codebase (#82)
This commit is a result of the following commands: clang-format-19 --style=file -i $(git ls-files | fgrep .cpp) clang-format-19 --style=file -i $(git ls-files | fgrep .hpp)
This commit is contained in:
committed by
GitHub
parent
102bb114a1
commit
61196cae90
@ -30,17 +30,12 @@ ChangesManager &ChangesManager::instance()
|
||||
|
||||
ChangesManager::ChangesManager()
|
||||
: QObject(nullptr)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
ChangesManager::~ChangesManager()
|
||||
{
|
||||
}
|
||||
ChangesManager::~ChangesManager() {}
|
||||
|
||||
void ChangesManager::addChange(TextEditor::TextDocument *document,
|
||||
int position,
|
||||
int charsRemoved,
|
||||
int charsAdded)
|
||||
void ChangesManager::addChange(
|
||||
TextEditor::TextDocument *document, int position, int charsRemoved, int charsAdded)
|
||||
{
|
||||
auto &documentQueue = m_documentChanges[document];
|
||||
|
||||
@ -51,9 +46,10 @@ void ChangesManager::addChange(TextEditor::TextDocument *document,
|
||||
|
||||
ChangeInfo change{fileName, lineNumber, lineContent};
|
||||
|
||||
auto it = std::find_if(documentQueue.begin(),
|
||||
documentQueue.end(),
|
||||
[lineNumber](const ChangeInfo &c) { return c.lineNumber == lineNumber; });
|
||||
auto it
|
||||
= std::find_if(documentQueue.begin(), documentQueue.end(), [lineNumber](const ChangeInfo &c) {
|
||||
return c.lineNumber == lineNumber;
|
||||
});
|
||||
|
||||
if (it != documentQueue.end()) {
|
||||
it->lineContent = lineContent;
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
namespace QodeAssist::Context {
|
||||
|
||||
@ -41,10 +41,8 @@ public:
|
||||
|
||||
static ChangesManager &instance();
|
||||
|
||||
void addChange(TextEditor::TextDocument *document,
|
||||
int position,
|
||||
int charsRemoved,
|
||||
int charsAdded);
|
||||
void addChange(
|
||||
TextEditor::TextDocument *document, int position, int charsRemoved, int charsAdded);
|
||||
QString getRecentChangesContext(const TextEditor::TextDocument *currentDocument) const;
|
||||
|
||||
private:
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
#include "DocumentContextReader.hpp"
|
||||
|
||||
#include <languageserverprotocol/lsptypes.h>
|
||||
#include <QFileInfo>
|
||||
#include <QTextBlock>
|
||||
#include <languageserverprotocol/lsptypes.h>
|
||||
|
||||
#include "CodeCompletionSettings.hpp"
|
||||
|
||||
@ -41,9 +41,8 @@ const QRegularExpression &getNameRegex()
|
||||
|
||||
const QRegularExpression &getCommentRegex()
|
||||
{
|
||||
static const QRegularExpression
|
||||
commentRegex(R"((/\*[\s\S]*?\*/|//.*$|#.*$|//{2,}[\s\S]*?//{2,}))",
|
||||
QRegularExpression::MultilineOption);
|
||||
static const QRegularExpression commentRegex(
|
||||
R"((/\*[\s\S]*?\*/|//.*$|#.*$|//{2,}[\s\S]*?//{2,}))", QRegularExpression::MultilineOption);
|
||||
return commentRegex;
|
||||
}
|
||||
|
||||
@ -80,9 +79,8 @@ QString DocumentContextReader::getLineText(int lineNumber, int cursorPosition) c
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DocumentContextReader::getContextBefore(int lineNumber,
|
||||
int cursorPosition,
|
||||
int linesCount) const
|
||||
QString DocumentContextReader::getContextBefore(
|
||||
int lineNumber, int cursorPosition, int linesCount) const
|
||||
{
|
||||
int effectiveStartLine;
|
||||
if (m_copyrightInfo.found) {
|
||||
@ -94,9 +92,8 @@ QString DocumentContextReader::getContextBefore(int lineNumber,
|
||||
return getContextBetween(effectiveStartLine, lineNumber, cursorPosition);
|
||||
}
|
||||
|
||||
QString DocumentContextReader::getContextAfter(int lineNumber,
|
||||
int cursorPosition,
|
||||
int linesCount) const
|
||||
QString DocumentContextReader::getContextAfter(
|
||||
int lineNumber, int cursorPosition, int linesCount) const
|
||||
{
|
||||
int endLine = qMin(m_document->blockCount() - 1, lineNumber + linesCount);
|
||||
return getContextBetween(lineNumber + 1, endLine, cursorPosition);
|
||||
@ -179,9 +176,7 @@ CopyrightInfo DocumentContextReader::findCopyright()
|
||||
return result;
|
||||
}
|
||||
|
||||
QString DocumentContextReader::getContextBetween(int startLine,
|
||||
int endLine,
|
||||
int cursorPosition) const
|
||||
QString DocumentContextReader::getContextBetween(int startLine, int endLine, int cursorPosition) const
|
||||
{
|
||||
QString context;
|
||||
for (int i = startLine; i <= endLine; ++i) {
|
||||
@ -240,8 +235,9 @@ QString DocumentContextReader::getContextAfter(int lineNumber, int cursorPositio
|
||||
if (Settings::codeCompletionSettings().readFullFile()) {
|
||||
return readWholeFileAfter(lineNumber, cursorPosition);
|
||||
} else {
|
||||
int endLine = qMin(m_document->blockCount() - 1,
|
||||
lineNumber + Settings::codeCompletionSettings().readStringsAfterCursor());
|
||||
int endLine = qMin(
|
||||
m_document->blockCount() - 1,
|
||||
lineNumber + Settings::codeCompletionSettings().readStringsAfterCursor());
|
||||
return getContextBetween(lineNumber + 1, endLine, -1);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace QodeAssist::Context {
|
||||
|
||||
int TokenUtils::estimateTokens(const QString& text)
|
||||
int TokenUtils::estimateTokens(const QString &text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
return 0;
|
||||
@ -31,7 +31,7 @@ int TokenUtils::estimateTokens(const QString& text)
|
||||
return text.length() / 4;
|
||||
}
|
||||
|
||||
int TokenUtils::estimateFileTokens(const Context::ContentFile& file)
|
||||
int TokenUtils::estimateFileTokens(const Context::ContentFile &file)
|
||||
{
|
||||
int total = 0;
|
||||
|
||||
@ -42,13 +42,13 @@ int TokenUtils::estimateFileTokens(const Context::ContentFile& file)
|
||||
return total;
|
||||
}
|
||||
|
||||
int TokenUtils::estimateFilesTokens(const QList<Context::ContentFile>& files)
|
||||
int TokenUtils::estimateFilesTokens(const QList<Context::ContentFile> &files)
|
||||
{
|
||||
int total = 0;
|
||||
for (const auto& file : files) {
|
||||
for (const auto &file : files) {
|
||||
total += estimateFileTokens(file);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace QodeAssist::Context
|
||||
|
@ -19,18 +19,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include "ContentFile.hpp"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
namespace QodeAssist::Context {
|
||||
|
||||
class TokenUtils
|
||||
{
|
||||
public:
|
||||
static int estimateTokens(const QString& text);
|
||||
static int estimateFileTokens(const Context::ContentFile& file);
|
||||
static int estimateFilesTokens(const QList<Context::ContentFile>& files);
|
||||
static int estimateTokens(const QString &text);
|
||||
static int estimateFileTokens(const Context::ContentFile &file);
|
||||
static int estimateFilesTokens(const QList<Context::ContentFile> &files);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace QodeAssist::Context
|
||||
|
Reference in New Issue
Block a user