Skip to content

Commit c5fdd01

Browse files
committed
[refactor] Refactor directories
1 parent a4c5acc commit c5fdd01

7 files changed

+10
-43
lines changed

.clang-tidy

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2-
Checks: '*,\
2+
Checks: |
3+
*,
34
-llvmlibc-implementation-in-namespace,
45
-llvmlibc-restrict-system-libc-headers,
56
-llvmlibc-callee-namespace,
67
-llvmlibc-restrict-system-libc-headers,
78
-fuchsia-trailing-return,
89
-misc-no-recursion,
9-
-altera-unroll-loops'
10+
-altera-unroll-loops
1011
WarningsAsErrors: '*'
1112
HeaderFilterRegex: ".*"
1213
FormatStyle: .clang-format

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
configure:
22
CXX=/usr/bin/clang++ cmake -S . -B build
33

4-
compile: configure
4+
compile:
55
cmake --build build
66
cp build/compile_commands.json compile_commands.json
77

8-
test: compile
8+
test:
99
(cd build; ctest)
1010

11-
run: compile
11+
run:
1212
(./build/repl-sql-autocomplete)
1313

1414
clean:
File renamed without changes.
File renamed without changes.

src/repl.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,13 @@ auto complete(const std::string& text, int& length) -> Completions {
4242
| std::ranges::to<std::vector>();
4343
}
4444

45-
auto hint(const std::string& text, int& length, Color& color) -> Hints {
46-
color = Color::BLUE;
47-
return candidates(text.substr(text.size() - length));
48-
}
49-
5045
} // namespace
5146

5247
REPL::REPL() {
5348
constexpr auto MaxHintRows = 4;
5449
constexpr auto MaxHistorySize = 32;
5550

5651
replxx.set_completion_callback(complete);
57-
replxx.set_hint_callback(hint);
5852
replxx.set_max_hint_rows(MaxHintRows);
5953
replxx.set_max_history_size(MaxHistorySize);
6054
}
@@ -74,4 +68,4 @@ auto REPL::out() -> std::ostream& {
7468
return std::cout;
7569
}
7670

77-
} // namespace repl
71+
} // namespace repl

src/repl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ class REPL {
1717
replxx::Replxx replxx;
1818
};
1919

20-
} // namespace repl
20+
} // namespace repl

src/suggest.cpp

+2-30
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "suggest.hpp"
22
#include "sql.hpp"
33

4-
#include "antlr-c3/CodeCompletionCore.hpp"
4+
#include "antlr/c3/CodeCompletionCore.hpp"
55

66
#include <cassert>
77
#include <cstddef>
@@ -26,14 +26,6 @@ auto Suggest(const std::string& prefix) -> std::vector<std::string> {
2626
}
2727

2828
size_t caretTokenIndex = pipeline.tokens->size() - 2;
29-
{
30-
std::cerr << "tokens: " << std::endl;
31-
for (std::size_t i = 0; i < pipeline.tokens->size(); ++i) {
32-
std::cerr << " " << i << ": " << pipeline.tokens->get(i)->toString()
33-
<< std::endl;
34-
}
35-
std::cerr << "caretTokenIndex:" << caretTokenIndex << std::endl;
36-
}
3729

3830
antlr4::ParserRuleContext* context = nullptr;
3931
size_t timeoutMS = 200;
@@ -42,27 +34,7 @@ auto Suggest(const std::string& prefix) -> std::vector<std::string> {
4234
= engine.collectCandidates(caretTokenIndex, context, timeoutMS, cancel);
4335
assert(!candidates.cancelled);
4436

45-
std::vector<std::string> result;
46-
for (const auto& [token, following] : candidates.tokens) {
47-
const auto& vocabulary = pipeline.lexer->getVocabulary();
48-
std::cerr << "token: " << vocabulary.getDisplayName(token) << ""
49-
<< std::endl;
50-
for (const auto next : following) {
51-
std::cerr << " next -> symbolic: '" << vocabulary.getSymbolicName(next) << "'"
52-
<< ", literal: '" << vocabulary.getLiteralName(next) << "'"
53-
<< std::endl;
54-
}
55-
}
56-
for (const auto& [index, candidate] : candidates.rules) {
57-
for (const auto& rule : candidate.ruleList) {
58-
const auto& parser = *pipeline.parser;
59-
std::cerr << "index: " << index //
60-
<< ", startTokenIndex: " << candidate.startTokenIndex //
61-
<< ", rule: " << parser.getRuleNames()[rule] //
62-
<< std::endl;
63-
}
64-
}
65-
return result;
37+
return {};
6638
}
6739

6840
} // namespace repl

0 commit comments

Comments
 (0)