Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
kdevelop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Daniel Mensinger
kdevelop
Commits
966d5f32
Unverified
Commit
966d5f32
authored
Oct 04, 2019
by
Daniel Mensinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clangFormat: Sort includes
parent
17313206
Pipeline
#10685
passed with stage
in 49 minutes and 9 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
plugins/clangformat/cf_plugin.cpp
plugins/clangformat/cf_plugin.cpp
+14
-2
No files found.
plugins/clangformat/cf_plugin.cpp
View file @
966d5f32
...
...
@@ -189,19 +189,31 @@ QString ClangFormatPlugin::formatSourceWithStyle(SourceFormatterStyle style, con
return
text
;
}
// LLVM uses string REFERENCES ==> always keep the original string around on the stack
string
filename
=
url
.
fileName
().
toStdString
();
if
(
filename
.
empty
())
{
filename
=
"<stdin>"
;
}
tooling
::
Range
codeRange
(
left
.
size
(),
center
.
size
());
auto
replacements
=
format
::
reformat
(
cfStyle
,
code
,
{
codeRange
},
filename
);
// Includes have to be sorted seperately (not sure why but thats waht clang-format does)
auto
replacements
=
format
::
sortIncludes
(
cfStyle
,
code
,
{
codeRange
},
filename
);
auto
result
=
tooling
::
applyAllReplacements
(
code
,
replacements
);
if
(
!
result
)
{
return
text
;
}
code
=
*
result
;
auto
newRanges
=
tooling
::
calculateRangesAfterReplacements
(
replacements
,
{
codeRange
});
// Do the main clang-format
replacements
=
format
::
reformat
(
cfStyle
,
code
,
newRanges
,
filename
);
result
=
tooling
::
applyAllReplacements
(
code
,
replacements
);
if
(
!
result
)
{
return
text
;
}
return
KDevelop
::
extractFormattedTextFromContext
(
QString
::
fromStdString
(
*
result
),
text
,
leftContext
,
rightContext
,
cfStyle
.
TabWidth
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment