Skip to content

Commit 016f775

Browse files
committed
提交
1 parent ce61217 commit 016f775

File tree

8 files changed

+289
-22
lines changed

8 files changed

+289
-22
lines changed

3rd/uriparser/src/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#define PACKAGE_VERSION "0.9.5"
4545

46-
/* #undef HAVE_WPRINTF */
46+
#define HAVE_WPRINTF
4747
/* #undef HAVE_REALLOCARRAY */
4848

4949

CodeFormatServer/src/CodeFormatServer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ using namespace asio::ip;
1616

1717
int main(int argc, char** argv)
1818
{
19-
2019
if(argc > 1)
2120
{
2221
int port = std::stoi(argv[1]);
@@ -37,7 +36,5 @@ int main(int argc, char** argv)
3736
LanguageClient::GetInstance().Run();
3837
}
3938

40-
41-
4239
return 0;
4340
}

CodeFormatServer/src/LanguageClient.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ void LanguageClient::DiagnosticFile(std::string_view uri)
131131
diagnosis.severity = vscode::DiagnosticSeverity::Warning;
132132
}
133133

134-
135-
136-
137134
SendNotification("textDocument/publishDiagnostics", vscodeDiagnosis);
138135
}
139136

@@ -243,6 +240,8 @@ void LanguageClient::UpdateAllDiagnosis()
243240
void LanguageClient::SetRoot(std::string_view root)
244241
{
245242
_root = root;
243+
_defaultOptions->export_root = root;
244+
_defaultOptions->import_from.emplace_back(root);
246245
}
247246

248247
uint64_t LanguageClient::GetRequestId()

CodeFormatServer/src/LanguageService.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ std::shared_ptr<vscode::Serializable> LanguageService::OnRangeFormatting(
218218
return result;
219219
}
220220

221-
LuaFormatter formatter(parser, *options);
222-
formatter.BuildFormattedElement();
223-
224221
auto& edit = result->edits.emplace_back();
225222
LuaFormatRange formattedRange(static_cast<int>(param->range.start.line), static_cast<int>(param->range.end.line));
226223

224+
LuaFormatter formatter(parser, *options);
225+
formatter.BuildRangeFormattedElement(formattedRange);
226+
227227
edit.newText = formatter.GetRangeFormattedText(formattedRange);
228228
edit.range = vscode::Range(
229229
vscode::Position(formattedRange.StartLine, formattedRange.StartCharacter),
@@ -253,12 +253,12 @@ std::shared_ptr<vscode::Serializable> LanguageService::OnTypeFormatting(
253253
return result;
254254
}
255255

256-
LuaFormatter formatter(parser, *options);
257-
formatter.BuildFormattedElement();
258-
259256
auto& edit = result->edits.emplace_back();
260257
LuaFormatRange formattedRange(static_cast<int>(position.line) - 1, static_cast<int>(position.line) - 1);
261258

259+
LuaFormatter formatter(parser, *options);
260+
formatter.BuildRangeFormattedElement(formattedRange);
261+
262262
edit.newText = formatter.GetRangeFormattedText(formattedRange);
263263
edit.range = vscode::Range(
264264
vscode::Position(formattedRange.StartLine, formattedRange.StartCharacter),
@@ -310,21 +310,21 @@ std::shared_ptr<vscode::Serializable> LanguageService::OnExecuteCommand(
310310
return result;
311311
}
312312

313-
LuaFormatter formatter(parser, *options);
314-
formatter.BuildFormattedElement();
315313
auto it = applyParams->edit.changes.emplace(uri, std::vector<vscode::TextEdit>());
316314
auto& change = it.first->second;
317315

318316
auto& edit = change.emplace_back();
319317
LuaFormatRange formattedRange(static_cast<int>(range.start.line), static_cast<int>(range.end.line));
320318

319+
LuaFormatter formatter(parser, *options);
320+
formatter.BuildRangeFormattedElement(formattedRange);
321+
321322
edit.newText = formatter.GetRangeFormattedText(formattedRange);
322323
edit.range = vscode::Range(
323324
vscode::Position(formattedRange.StartLine, formattedRange.StartCharacter),
324325
vscode::Position(formattedRange.EndLine + 1, formattedRange.EndCharacter)
325326
);
326327

327-
328328
LanguageClient::GetInstance().SendRequest("workspace/applyEdit", applyParams);
329329
}
330330

CodeFormatServer/src/Service/ModuleService.cpp

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,68 @@
33

44
class UnResolveModuleFinder : public LuaAstVisitor
55
{
6+
public:
7+
class Scope
8+
{
9+
public:
10+
std::set<std::string, std::less<>> LocalVariableSet;
11+
};
12+
13+
UnResolveModuleFinder(std::vector<vscode::Diagnostic>& result, std::shared_ptr<LuaCodeStyleOptions> options)
14+
: _result(result),
15+
_options(options)
16+
{
17+
}
18+
19+
void Find()
20+
{
21+
22+
}
23+
624
protected:
7-
void VisitParamList(const std::shared_ptr<LuaAstNode>& node) override;
25+
void VisitParamList(const std::shared_ptr<LuaAstNode>& node) override
26+
{
27+
}
28+
29+
void VisitLocalFunctionStatement(const std::shared_ptr<LuaAstNode>& node) override
30+
{
31+
}
32+
33+
void VisitLocalStatement(const std::shared_ptr<LuaAstNode>& node) override
34+
{
35+
}
836

9-
void VisitLocalFunctionStatement(const std::shared_ptr<LuaAstNode>& node) override;
37+
void VisitExpression(const std::shared_ptr<LuaAstNode>& expression) override
38+
{
39+
if(expression->GetChildren().empty())
40+
switch (expression->GetType())
41+
{
42+
// case
1043

11-
void VisitLocalStatement(const std::shared_ptr<LuaAstNode>& node) override;
1244

13-
void VisitIdentify(const std::shared_ptr<LuaAstNode>& node) override;
1445

46+
}
47+
48+
}
49+
50+
private:
51+
std::vector<vscode::Diagnostic>& _result;
52+
std::shared_ptr<LuaCodeStyleOptions> _options;
1553
};
1654

55+
std::vector<vscode::Diagnostic> ModuleService::GetModuleDiagnostics(std::shared_ptr<LuaParser> parser,
56+
std::shared_ptr<LuaCodeStyleOptions> options)
57+
{
58+
std::vector<vscode::Diagnostic> result;
59+
UnResolveModuleFinder finder(result, options);
60+
auto ast = parser->GetAst();
1761

62+
ast->AcceptChildren(finder);
1863

64+
return result;
65+
}
1966

20-
std::vector<vscode::Diagnostic> ModuleService::GetModuleDiagnostics()
67+
std::vector<std::string> ModuleService::GetCompleteItems()
2168
{
69+
return {};
2270
}

0 commit comments

Comments
 (0)