diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2019-05-06 08:39:17 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2019-05-06 08:39:17 +0000 |
| commit | 949d69f5cf1bd25fc4c727d38a3e27a6c36f680e (patch) | |
| tree | 1e99414c31afab01cbdd2c33395c8ee568a5ac75 /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | b5d3430d3df9d1d7241d908df7859a71db981a71 (diff) | |
| download | bcm5719-llvm-949d69f5cf1bd25fc4c727d38a3e27a6c36f680e.tar.gz bcm5719-llvm-949d69f5cf1bd25fc4c727d38a3e27a6c36f680e.zip | |
[clangd] Always call getFormatStyleForFile().
This means "format" will no longer return an error if the -fallback-style flag
is invalid, it will log and use LLVM style. This doesn't really matter.
Also document the dependence on global variables. (This patch is a
compromise - it's probably not worth actually avoiding the globals).
llvm-svn: 360020
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index de6083f132f..374ffc0b2f7 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -496,20 +496,16 @@ llvm::Expected<tooling::Replacements> ClangdServer::formatCode(llvm::StringRef Code, PathRef File, llvm::ArrayRef<tooling::Range> Ranges) { // Call clang-format. - auto FS = FSProvider.getFileSystem(); - auto Style = format::getStyle(format::DefaultFormatStyle, File, - format::DefaultFallbackStyle, Code, FS.get()); - if (!Style) - return Style.takeError(); - + format::FormatStyle Style = + getFormatStyleForFile(File, Code, FSProvider.getFileSystem().get()); tooling::Replacements IncludeReplaces = - format::sortIncludes(*Style, Code, Ranges, File); + format::sortIncludes(Style, Code, Ranges, File); auto Changed = tooling::applyAllReplacements(Code, IncludeReplaces); if (!Changed) return Changed.takeError(); return IncludeReplaces.merge(format::reformat( - Style.get(), *Changed, + Style, *Changed, tooling::calculateRangesAfterReplacements(IncludeReplaces, Ranges), File)); } |

