aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Format/Format.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Format/Format.h')
-rw-r--r--include/clang/Format/Format.h71
1 files changed, 56 insertions, 15 deletions
diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h
index 85dda948c11f..cb37b0c890c3 100644
--- a/include/clang/Format/Format.h
+++ b/include/clang/Format/Format.h
@@ -22,16 +22,18 @@
#include "llvm/Support/Regex.h"
#include <system_error>
+namespace llvm {
+namespace vfs {
+class FileSystem;
+}
+} // namespace llvm
+
namespace clang {
class Lexer;
class SourceManager;
class DiagnosticConsumer;
-namespace vfs {
-class FileSystem;
-}
-
namespace format {
enum class ParseError { Success = 0, Error, Unsuitable };
@@ -531,20 +533,17 @@ struct FormatStyle {
/// \code
/// try {
/// foo();
- /// } catch () {
+ /// }
+ /// catch () {
/// }
/// void foo() { bar(); }
- /// class foo
- /// {
+ /// class foo {
/// };
/// if (foo()) {
- /// } else {
/// }
- /// enum X : int
- /// {
- /// A,
- /// B
- /// };
+ /// else {
+ /// }
+ /// enum X : int { A, B };
/// \endcode
BS_Stroustrup,
/// Always break before braces.
@@ -1051,6 +1050,16 @@ struct FormatStyle {
/// For example: BOOST_FOREACH.
std::vector<std::string> ForEachMacros;
+ /// A vector of macros that should be interpreted as complete
+ /// statements.
+ ///
+ /// Typical macros are expressions, and require a semi-colon to be
+ /// added; sometimes this is not the case, and this allows to make
+ /// clang-format aware of such cases.
+ ///
+ /// For example: Q_UNUSED
+ std::vector<std::string> StatementMacros;
+
tooling::IncludeStyle IncludeStyle;
/// Indent case labels one level from the switch statement.
@@ -1120,6 +1129,37 @@ struct FormatStyle {
/// \endcode
bool IndentWrappedFunctionNames;
+ /// A vector of prefixes ordered by the desired groups for Java imports.
+ ///
+ /// Each group is seperated by a newline. Static imports will also follow the
+ /// same grouping convention above all non-static imports. One group's prefix
+ /// can be a subset of another - the longest prefix is always matched. Within
+ /// a group, the imports are ordered lexicographically.
+ ///
+ /// In the .clang-format configuration file, this can be configured like
+ /// in the following yaml example. This will result in imports being
+ /// formatted as in the Java example below.
+ /// \code{.yaml}
+ /// JavaImportGroups: ['com.example', 'com', 'org']
+ /// \endcode
+ ///
+ /// \code{.java}
+ /// import static com.example.function1;
+ ///
+ /// import static com.test.function2;
+ ///
+ /// import static org.example.function3;
+ ///
+ /// import com.example.ClassA;
+ /// import com.example.Test;
+ /// import com.example.a.ClassB;
+ ///
+ /// import com.test.ClassC;
+ ///
+ /// import org.example.ClassD;
+ /// \endcode
+ std::vector<std::string> JavaImportGroups;
+
/// Quotation styles for JavaScript strings. Does not affect template
/// strings.
enum JavaScriptQuoteStyle {
@@ -1724,6 +1764,7 @@ struct FormatStyle {
IndentPPDirectives == R.IndentPPDirectives &&
IndentWidth == R.IndentWidth && Language == R.Language &&
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
+ JavaImportGroups == R.JavaImportGroups &&
JavaScriptQuotes == R.JavaScriptQuotes &&
JavaScriptWrapImports == R.JavaScriptWrapImports &&
KeepEmptyLinesAtTheStartOfBlocks ==
@@ -1766,7 +1807,7 @@ struct FormatStyle {
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
Standard == R.Standard && TabWidth == R.TabWidth &&
- UseTab == R.UseTab;
+ StatementMacros == R.StatementMacros && UseTab == R.UseTab;
}
llvm::Optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
@@ -1999,7 +2040,7 @@ extern const char *DefaultFallbackStyle;
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
StringRef FallbackStyle,
StringRef Code = "",
- vfs::FileSystem *FS = nullptr);
+ llvm::vfs::FileSystem *FS = nullptr);
// Guesses the language from the ``FileName`` and ``Code`` to be formatted.
// Defaults to FormatStyle::LK_Cpp.