From 3c42dba2dcd5c945fe34dbcc3aad94e750ef0b5b Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 18 Feb 2015 17:17:15 +0000 Subject: clang-format: [JS] support AtScript style annotations for JS. Based on Java annotation support and style. Patch by Martin Probst. llvm-svn: 229703 --- clang/lib/Format/TokenAnnotator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/TokenAnnotator.cpp') diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 8db48ff1ed5..40573429685 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -881,7 +881,9 @@ private: // Line.MightBeFunctionDecl can only be true after the parentheses of a // function declaration have been found. Current.Type = TT_TrailingAnnotation; - } else if (Style.Language == FormatStyle::LK_Java && Current.Previous) { + } else if ((Style.Language == FormatStyle::LK_Java || + Style.Language == FormatStyle::LK_JavaScript) && + Current.Previous) { if (Current.Previous->is(tok::at) && Current.isNot(Keywords.kw_interface)) { const FormatToken &AtToken = *Current.Previous; @@ -1920,6 +1922,10 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Left.NestingLevel == 0) return true; + if (Left.is(TT_LeadingJavaAnnotation) && + Right.isNot(TT_LeadingJavaAnnotation) && Right.isNot(tok::l_paren) && + Line.Last->is(tok::l_brace)) + return true; } else if (Style.Language == FormatStyle::LK_Java) { if (Left.is(TT_LeadingJavaAnnotation) && Right.isNot(TT_LeadingJavaAnnotation) && Right.isNot(tok::l_paren) && -- cgit v1.2.3