Skip to content

Commit cd61fb7

Browse files
committed
清理警告
1 parent f6fc581 commit cd61fb7

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

CodeService/src/Format/Analyzer/SpaceAnalyzer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,23 @@ void SpaceAnalyzer::SpaceRight(LuaSyntaxNode &n, const LuaSyntaxTree &t, std::si
314314
_rightSpaces[token.GetIndex()] = space;
315315
}
316316

317-
std::optional<std::size_t> SpaceAnalyzer::GetRightSpace(LuaSyntaxNode &n) const {
317+
SpaceAnalyzer::OptionalInt SpaceAnalyzer::GetRightSpace(LuaSyntaxNode &n) const {
318318
if (_ignoreSpace.count(n.GetIndex())) {
319-
return {};
319+
return OptionalInt();
320320
}
321321

322322
auto it = _rightSpaces.find(n.GetIndex());
323323
if (it == _rightSpaces.end()) {
324-
return {};
324+
return OptionalInt();
325325
}
326-
return it->second;
326+
return OptionalInt(it->second);
327327
}
328328

329329
std::size_t
330330
SpaceAnalyzer::ProcessSpace(const LuaSyntaxTree &t, LuaSyntaxNode &left, LuaSyntaxNode &right) {
331331
auto rightSpaceOfLeftToken = GetRightSpace(left);
332-
if (rightSpaceOfLeftToken.has_value()) {
333-
return rightSpaceOfLeftToken.value();
332+
if (rightSpaceOfLeftToken.HasValue) {
333+
return rightSpaceOfLeftToken.Value;
334334
}
335335
if (!right.IsNull(t)) {
336336
return t.GetStartOffset(right.GetIndex()) - t.GetEndOffset(left.GetIndex()) - 1;

CodeService/src/RangeFormat/RangeFormatBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "LuaParser/Lexer/LuaTokenTypeDetail.h"
33

44
RangeFormatBuilder::RangeFormatBuilder(LuaStyle &style, FormatRange &range)
5-
: FormatBuilder(style), _range(range), _validRange(false) {
5+
: FormatBuilder(style), _validRange(false), _range(range) {
66

77
}
88

include/CodeService/Format/Analyzer/SpaceAnalyzer.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include <optional>
43
#include <unordered_set>
54
#include <unordered_map>
65
#include "CodeService/Format/Analyzer/FormatAnalyzer.h"
@@ -9,6 +8,16 @@ class SpaceAnalyzer : public FormatAnalyzer {
98
public:
109
DECLARE_FORMAT_ANALYZER(SpaceAnalyzer)
1110

11+
// workaround for mac 10.13
12+
struct OptionalInt {
13+
OptionalInt() : HasValue(false), Value(0) {}
14+
15+
explicit OptionalInt(std::size_t value) : HasValue(true), Value(value) {}
16+
17+
bool HasValue;
18+
std::size_t Value;
19+
};
20+
1221
SpaceAnalyzer();
1322

1423
void Analyze(FormatState &f, const LuaSyntaxTree &t) override;
@@ -26,9 +35,7 @@ class SpaceAnalyzer : public FormatAnalyzer {
2635
void SpaceIgnore(LuaSyntaxNode &n, const LuaSyntaxTree &t);
2736

2837
private:
29-
// std::optional<std::size_t> GetLeftSpace(LuaSyntaxNode &n) const;
30-
31-
std::optional<std::size_t> GetRightSpace(LuaSyntaxNode &n) const;
38+
OptionalInt GetRightSpace(LuaSyntaxNode &n) const;
3239

3340
std::size_t ProcessSpace(const LuaSyntaxTree &t, LuaSyntaxNode &left, LuaSyntaxNode &right);
3441

0 commit comments

Comments
 (0)