summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/SortJavaScriptImports.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-05-09 21:35:52 +0000
committerEric Liu <ioeric@google.com>2018-05-09 21:35:52 +0000
commit2e538089fa3761a44cab65c640e93fb8b399f9a0 (patch)
treec451824c176061b166b2e92e814d95b201a3d1ef /clang/lib/Format/SortJavaScriptImports.cpp
parent1608ca6d644783f24e852448422d0f3a14ff4011 (diff)
downloadbcm5719-llvm-2e538089fa3761a44cab65c640e93fb8b399f9a0.tar.gz
bcm5719-llvm-2e538089fa3761a44cab65c640e93fb8b399f9a0.zip
Add SourceManagerForFile helper which sets up SourceManager and dependencies for a single file with code snippet
Summary: This can be used to create a virtual environment (incl. VFS, source manager) for code snippets. Reviewers: sammccall, klimek Reviewed By: sammccall Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D46176 llvm-svn: 331923
Diffstat (limited to 'clang/lib/Format/SortJavaScriptImports.cpp')
-rw-r--r--clang/lib/Format/SortJavaScriptImports.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp
index 0ca2c4433ca..e8df04c8bd4 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -445,10 +445,9 @@ tooling::Replacements sortJavaScriptImports(const FormatStyle &Style,
ArrayRef<tooling::Range> Ranges,
StringRef FileName) {
// FIXME: Cursor support.
- std::unique_ptr<Environment> Env =
- Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
- JavaScriptImportSorter Sorter(*Env, Style);
- return Sorter.process().first;
+ return JavaScriptImportSorter(Environment(Code, FileName, Ranges), Style)
+ .process()
+ .first;
}
} // end namespace format
OpenPOWER on IntegriCloud