You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
INPUTS
bindings
cmake
docs
examples
include
lib
ARCMigrate
AST
ASTMatchers
Analysis
Basic
CodeGen
CrossTU
Driver
Edit
Format
Frontend
FrontendTool
Headers
Index
CMakeLists.txt
CodegenNameGenerator.cpp
CommentToXML.cpp
IndexBody.cpp
IndexDecl.cpp
IndexSymbol.cpp
IndexTypeSourceInfo.cpp
IndexingAction.cpp
IndexingContext.cpp
IndexingContext.h
SimpleFormatContext.h
USRGeneration.cpp
Lex
Parse
Rewrite
Sema
Serialization
StaticAnalyzer
Tooling
CMakeLists.txt
runtime
tools
unittests
utils
www
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt
clang-tools-extra
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
76 lines
2.4 KiB
C
76 lines
2.4 KiB
C
![]() |
//===--- SimpleFormatContext.h ----------------------------------*- C++ -*-===//
|
||
|
//
|
||
|
// The LLVM Compiler Infrastructure
|
||
|
//
|
||
|
// This file is distributed under the University of Illinois Open Source
|
||
|
// License. See LICENSE.TXT for details.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
//
|
||
|
/// \file
|
||
|
///
|
||
|
/// \brief Defines a utility class for use of clang-format in libclang
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
|
||
|
#ifndef LLVM_CLANG_LIB_INDEX_SIMPLEFORMATCONTEXT_H
|
||
|
#define LLVM_CLANG_LIB_INDEX_SIMPLEFORMATCONTEXT_H
|
||
|
|
||
|
#include "clang/Basic/Diagnostic.h"
|
||
|
#include "clang/Basic/DiagnosticOptions.h"
|
||
|
#include "clang/Basic/FileManager.h"
|
||
|
#include "clang/Basic/LangOptions.h"
|
||
|
#include "clang/Basic/SourceManager.h"
|
||
|
#include "clang/Rewrite/Core/Rewriter.h"
|
||
|
#include "llvm/Support/FileSystem.h"
|
||
|
#include "llvm/Support/Path.h"
|
||
|
#include "llvm/Support/raw_ostream.h"
|
||
|
|
||
|
namespace clang {
|
||
|
namespace index {
|
||
|
|
||
|
/// \brief A small class to be used by libclang clients to format
|
||
|
/// a declaration string in memory. This object is instantiated once
|
||
|
/// and used each time a formatting is needed.
|
||
|
class SimpleFormatContext {
|
||
|
public:
|
||
|
SimpleFormatContext(LangOptions Options)
|
||
|
: DiagOpts(new DiagnosticOptions()),
|
||
|
Diagnostics(new DiagnosticsEngine(new DiagnosticIDs,
|
||
|
DiagOpts.get())),
|
||
|
InMemoryFileSystem(new vfs::InMemoryFileSystem),
|
||
|
Files(FileSystemOptions(), InMemoryFileSystem),
|
||
|
Sources(*Diagnostics, Files),
|
||
|
Rewrite(Sources, Options) {
|
||
|
Diagnostics->setClient(new IgnoringDiagConsumer, true);
|
||
|
}
|
||
|
|
||
|
FileID createInMemoryFile(StringRef Name, StringRef Content) {
|
||
|
InMemoryFileSystem->addFile(Name, 0,
|
||
|
llvm::MemoryBuffer::getMemBuffer(Content));
|
||
|
const FileEntry *Entry = Files.getFile(Name);
|
||
|
assert(Entry != nullptr);
|
||
|
return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
|
||
|
}
|
||
|
|
||
|
std::string getRewrittenText(FileID ID) {
|
||
|
std::string Result;
|
||
|
llvm::raw_string_ostream OS(Result);
|
||
|
Rewrite.getEditBuffer(ID).write(OS);
|
||
|
OS.flush();
|
||
|
return Result;
|
||
|
}
|
||
|
|
||
|
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
|
||
|
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
|
||
|
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
|
||
|
FileManager Files;
|
||
|
SourceManager Sources;
|
||
|
Rewriter Rewrite;
|
||
|
};
|
||
|
|
||
|
} // end namespace index
|
||
|
} // end namespace clang
|
||
|
|
||
|
#endif
|