aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-04-12 15:04:29 -0700
committerGitHub <noreply@github.com>2025-04-12 15:04:29 -0700
commit09c8cfe219481a8fc20c6711dc5c87451f5a5ef1 (patch)
treefbcb047197edca1ba96dbc174bb1de293aa07533 /clang/lib/Format/Format.cpp
parentbbc5d205d409bb22fe4ae8ad16ebaf1752e6b700 (diff)
downloadllvm-09c8cfe219481a8fc20c6711dc5c87451f5a5ef1.zip
llvm-09c8cfe219481a8fc20c6711dc5c87451f5a5ef1.tar.gz
llvm-09c8cfe219481a8fc20c6711dc5c87451f5a5ef1.tar.bz2
[clang-format][NFC] Add isJava() and isTextProto() in FormatStyle (#135466)
Also remove redundant name qualifiers format::, FormatStyle::, and LanguageKind::.
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b90bd82..3802766 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3591,13 +3591,12 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
return Replaces;
if (isLikelyXml(Code))
return Replaces;
- if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
- isMpegTS(Code)) {
- return Replaces;
- }
- if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
+ if (Style.isJavaScript()) {
+ if (isMpegTS(Code))
+ return Replaces;
return sortJavaScriptImports(Style, Code, Ranges, FileName);
- if (Style.Language == FormatStyle::LanguageKind::LK_Java)
+ }
+ if (Style.isJava())
return sortJavaImports(Style, Code, Ranges, FileName, Replaces);
if (Style.isCpp())
sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
@@ -3777,7 +3776,7 @@ reformat(const FormatStyle &Style, StringRef Code,
return {tooling::Replacements(), 0};
if (isLikelyXml(Code))
return {tooling::Replacements(), 0};
- if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
+ if (Expanded.isJavaScript() && isMpegTS(Code))
return {tooling::Replacements(), 0};
// JSON only needs the formatting passing.