FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
EmmyLuaCodeStyle/CodeFormatCLib/src/CodeFormatCLib.cpp at master · listout/EmmyLuaCodeStyle · GitHub
listout
EmmyLuaCodeStyle
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
EmmyLuaCodeStyle
/
CodeFormatCLib
/
src
/
CodeFormatCLib.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (61 loc) · 2.28 KB
Breadcrumbs
EmmyLuaCodeStyle
/
CodeFormatCLib
/
src
/
CodeFormatCLib.cpp
Copy path
File metadata and controls
69 lines (61 loc) · 2.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
include
"
CodeFormatCLib.h
"
#
include
"
CodeFormat.h
"
#
include
"
UtilTypes.h
"
extern
"
C
"
{
EMMY_API
char
*
ReformatLuaCode
(
const
char
*code,
const
char
*uri) {
CodeFormat &codeFormat =
CodeFormat::GetInstance
();
auto
result = codeFormat.
Reformat
(uri, code);
return
result;
}
EMMY_API
RangeFormatResult
RangeFormatLuaCode
(
const
char
*code,
const
char
*uri,
int
startLine,
int
startCol,
int
endLine,
int
endCol) {
CodeFormat &codeFormat =
CodeFormat::GetInstance
();
FormatRange range;
range.
StartLine
= startLine;
range.
StartCol
= startCol;
range.
EndLine
= endLine;
range.
EndCol
= endCol;
auto
result = codeFormat.
RangeFormat
(uri, range, code);
if
(result.
Type
== ResultType::Ok) {
return
result.
Data
;
}
else
{
return
RangeFormatResult{};
}
}
EMMY_API
void
FreeReformatResult
(
char
*ptr) {
delete[]
ptr;
}
EMMY_API
void
UpdateCodeStyle
(
const
char
*workspaceUri,
const
char
*configPath) {
CodeFormat &codeFormat =
CodeFormat::GetInstance
();
codeFormat.
UpdateCodeStyle
(workspaceUri, configPath);
}
EMMY_API
void
RemoveCodeStyle
(
const
char
*workspaceUri) {
CodeFormat &codeFormat =
CodeFormat::GetInstance
();
codeFormat.
RemoveCodeStyle
(workspaceUri);
}
EMMY_API
char
*
CheckCodeStyle
(
const
char
*code,
const
char
*uri) {
CodeFormat &codeFormat =
CodeFormat::GetInstance
();
auto
result = codeFormat.
Diagnostic
(uri, code);
if
(result.
Type
!= ResultType::Ok) {
return
nullptr
;
}
auto
diagnostic_results =
std::move
(result.
Data
);
std::string result_str;
auto
total_size =
0
;
for
(
auto
&diagnostic: diagnostic_results) {
total_size += diagnostic.
Message
.
size
();
}
result_str.
reserve
(total_size *
2
);
for
(
auto
&diagnostic: diagnostic_results) {
result_str.
append
(
std::to_string
(diagnostic.
Start
.
Line
)).
append
(
"
|
"
);
result_str.
append
(
std::to_string
(diagnostic.
Start
.
Col
)).
append
(
"
|
"
);
result_str.
append
(
std::to_string
(diagnostic.
End
.
Line
)).
append
(
"
|
"
);
result_str.
append
(
std::to_string
(diagnostic.
End
.
Col
)).
append
(
"
|
"
);
result_str.
append
(diagnostic.
Message
);
result_str.
append
(
"
\n
"
);
}
auto
ptr =
new
char
[result_str.
size
() +
1
];
std::copy
(result_str.
begin
(), result_str.
end
(), ptr);
ptr[result_str.
size
()] =
'
\0
'
;
return
ptr;
}
}
Back
|
FazBrowse Home
|
New Git URL