summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJava.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Support formatting Java 8 interface default methods.Nico Weber2018-01-231-0/+1
| | | | llvm-svn: 323218
* clang-format/java: Unbreak genenrics formatting after r299952.Nico Weber2017-09-271-0/+5
| | | | | | | | | | | | | | https://reviews.llvm.org/rL299952 merged '>>>' tokens into a single JavaRightLogicalShift token. This broke formatting of generics nested more than two deep, e.g. Foo<Bar<Baz>>> because the '>>>' now weren't three '>' for parseAngle(). Luckily, just deleting JavaRightLogicalShift fixes things without breaking the test added in r299952, so do that. https://reviews.llvm.org/D38291 llvm-svn: 314325
* clang-format/java: Always put space after `assert` keyword.Nico Weber2017-09-251-0/+1
| | | | | | Previously, it was missing if the expression after the assert started with a (. llvm-svn: 314172
* [clang-format] Put '/**' and '*/' on own lines in multiline jsdocsKrasimir Georgiev2017-07-201-0/+9
| | | | | | | | | | | | Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D35683 llvm-svn: 308684
* clang-format: Do not binpack initialization listsFrancois Ferrand2017-06-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch tries to avoid binpacking when initializing lists/arrays, to allow things like: static int types[] = { registerType1(), registerType2(), registerType3(), }; std::map<int, std::string> x = { { 0, "foo fjakfjaklf kljj" }, { 1, "bar fjakfjaklf kljj" }, { 2, "stuff fjakfjaklf kljj" }, }; This is similar to how dictionnaries are formatted, and actually corresponds to the same conditions: when initializing a container (and not just 'calling' a constructor). Such formatting involves 2 things: * Line breaks around the content of the block. This can be forced by adding a comma or comment after the last element * Elements should not be binpacked This patch considers the block is an initializer list if it either ends with a comma, or follows an assignment, which seems to provide a sensible approximation. Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: malcolm.parsons, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34238 llvm-svn: 306868
* [clang-format] Recognize Java logical shift assignment operator Nico Weber2017-04-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | At present, clang-format mangles Java containing logical right shift operators ('>>>=' or '>>>'), splitting them in two, resulting in invalid code: public class Minimal { public void func(String args) { int i = 42; - i >>>= 1; + i >> >= 1; return i; } } This adds both forms of logical right shift to the FormatTokenLexer, so clang-format won't attempt to split them and insert bogus whitespace. https://reviews.llvm.org/D31652 Patch from Richard Bradfield <bradfier@fstab.me>! llvm-svn: 299952
* clang-format: [Java] Fix bug in enum formatting.Daniel Jasper2017-02-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Before: public enum VeryLongEnum { ENUM_WITH_MANY_PARAMETERS("aaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbb", "ccccccccccccccccccc") , SECOND_ENUM("a", "b", "c"); private VeryLongEnum(String a, String b, String c) {} } After: public enum VeryLongEnum { ENUM_WITH_MANY_PARAMETERS("aaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbb", "ccccccccccccccccccc") , SECOND_ENUM("a", "b", "c"); private VeryLongEnum(String a, String b, String c) {} } llvm-svn: 296499
* Make tooling::applyAllReplacements return llvm::Expected<string> instead of ↵Eric Liu2016-07-111-4/+4
| | | | | | | | | | | | | | | | empty string to indicate potential error. Summary: return llvm::Expected<> to carry error status and error information. This is the first step towards introducing "Error" into tooling::Replacements. Reviewers: djasper, klimek Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21601 llvm-svn: 275062
* clang-format: [Java] Remove unnecessary line break after complex annotationsDaniel Jasper2016-01-271-0/+3
| | | | | | | | | | | | | | | Before: @Annotation("Some" + " text") List<Integer> list; After: @Annotation("Some" + " text") List<Integer> list; llvm-svn: 258981
* clang-format: [JS] "operator" is not a keyword in Java/JavaScript.Daniel Jasper2015-12-221-0/+1
| | | | llvm-svn: 256245
* clang-format/java: Break after annotations on fields in Chromium style.Nico Weber2015-10-151-0/+4
| | | | | | | | | | | Chromium follows the Android style guide for Java code, and that doesn't make the distinction between fields and non-fields that the Google Java style guide makes: https://source.android.com/source/code-style.html#use-standard-java-annotations https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations llvm-svn: 250422
* Remove accidental superfluous newline added in r247750.Nico Weber2015-09-151-1/+0
| | | | llvm-svn: 247752
* clang-format: In Java, `assert` is followed by an expression.Nico Weber2015-09-151-0/+5
| | | | | | Before: assert a&& b; Now: assert a && b; llvm-svn: 247750
* clang-format: [Java/JS] Properly support instanceof and its precedence.Daniel Jasper2015-07-031-0/+2
| | | | llvm-svn: 241337
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-3/+3
| | | | llvm-svn: 239903
* clang-format: Indent relative to the ./-> and not the function name.Daniel Jasper2015-04-071-1/+1
| | | | | | | | | | | | | | | | | | Before: aaaaaaaaaaa // .aaaa( // bbbb) // This is different .. .aaaa( // cccc); // .. from this. After: aaaaaaaaaaa // .aaaa( // bbbb) // This is identical .. .aaaa( // cccc); // .. to this. llvm-svn: 234300
* clang-format: [Java] Support anonymous classes after = and return.Daniel Jasper2015-03-121-0/+13
| | | | | | | | | | | | | | | | | | | Before: A a = new A(){public String toString(){return "NotReallyA"; } } ; After: A a = return new A() { public String toString() { return "NotReallyA"; } }; This fixes llvm.org/PR22878. llvm-svn: 232042
* clang-format: [Java] Support try blocks with resources.Daniel Jasper2015-01-141-0/+11
| | | | | | | | | | | | | | | Before: try (SomeResource rs = someFunction()) { Something(); } After: try (SomeResource rs = someFunction()) { Something(); } llvm-svn: 225973
* clang-format: [Java] Prefer not to break in parameter annotations.Daniel Jasper2015-01-141-0/+6
| | | | | | | | | | | | | | Before: boolean someFunction(@Param(aaaaaaaaaaaaaaaa) String aaaaa, String bbbbbbbbbbbbbbb) {} After: boolean someFunction( @Param(aaaaaaaaaaaaaaaa) String aaaaa, String bbbbbbbbbbbbbbb) {} llvm-svn: 225971
* clang-format: [Java] Understand "import static".Daniel Jasper2015-01-141-0/+2
| | | | llvm-svn: 225965
* clang-format: [Java] Don't let annotations confuse return type analysis.Daniel Jasper2015-01-141-0/+4
| | | | | | | | | | | | | | Before: @Test ReturnType doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {} After: @Test ReturnType doSomething( String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {} llvm-svn: 225964
* clang-format: [Java] Don't line-wrap before annotations' l_parens.Daniel Jasper2015-01-141-0/+4
| | | | | | | | | | | | | | Before: @SomeAnnotation (aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa) int i; After: @SomeAnnotation( aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa) int i; llvm-svn: 225963
* clang-format: [Java] Don't get confused by leading annotations.Daniel Jasper2015-01-141-0/+3
| | | | | | | | | | | | | | Before: @Test(a) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa); After: @Test(a) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 225962
* clang-format: [Java] Detect `native` keyword.Nico Weber2015-01-131-0/+1
| | | | | | | | | | Before: public native<X> Foo foo(); After: public native <X> Foo foo(); llvm-svn: 225839
* clang-format: [Java] Support formatting qualified annotations.Nico Weber2015-01-091-0/+10
| | | | llvm-svn: 225559
* clang-format: [Java] Fix incorrect detection of cast.Daniel Jasper2015-01-051-0/+4
| | | | | | | | | | | | | | After: return (a instanceof List<?>) ? aaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaa) : aaaaaaaaaaaaaaaaaaaaaaa; After: return (a instanceof List<?>) ? aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa) : aaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 225161
* clang-format: [Java] Fix incorrect recognition of annonymous classes.Daniel Jasper2015-01-041-0/+5
| | | | | | | | | | | | | | | | Before: someFunction(new Runnable() { public void run() { System.out.println(42); } }); After: someFunction(new Runnable() { public void run() { System.out.println(42); } }); llvm-svn: 225142
* clang-format: Re-enable comment re-indentation for Java/JS.Daniel Jasper2015-01-041-0/+13
| | | | | | This was broken by r224120. llvm-svn: 225130
* Don't break string literals in Java and JavaScript.Alexander Kornienko2014-12-121-0/+7
| | | | | | | | The proper way to break string literals in these languages is by inserting a "+" between parts which we don't support yet. So we disable string literal breaking until then. llvm-svn: 224120
* clang-format: Indent correctly in conditional expressions after return.Daniel Jasper2014-12-081-0/+5
| | | | | | | | | | | | | | | | | | | This only applies when not aligning after the return itself (which is commonly done for C++. Before: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) // This is indented relative to aaaaaaaaaa. : b; After: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) : b; llvm-svn: 223694
* clang-format: [Java] Always break after annotations of multiline decls.Daniel Jasper2014-12-081-0/+4
| | | | | | | | | | | | | Before: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 223688
* clang-format: Fix expression parser not closing stuff at end of stmt.Daniel Jasper2014-12-031-0/+5
| | | | | | | | | | | | | | Uncovered by a Java test case: Before: public some.package.Type someFunction( // comment int parameter) {} After: public some.package.Type someFunction( // comment int parameter) {} llvm-svn: 223228
* clang-format: Add option to suppress operator alignment.Daniel Jasper2014-12-021-1/+1
| | | | | | | | | | | | | | | | With alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; Without alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; This fixes llvm.org/PR21666. llvm-svn: 223117
* clang-format: Don't use column layout with AlignAfterOpenBrackets.Daniel Jasper2014-11-271-0/+7
| | | | | | This fixes llvm.org/PR21676. llvm-svn: 222886
* clang-format: [Java] Don't line-wrap package declarations.Daniel Jasper2014-11-261-0/+5
| | | | | | This fixes llvm.org/PR21677. llvm-svn: 222843
* clang-format: Tweak -style=Chromium for Java files.Nico Weber2014-11-261-0/+15
| | | | | | | | | | | For Java, don't do any of the deviations from Google Style that Chromium style does for C++. Chromium's Java follows Android Java style [1], which is roughly Google Java style with an indent of 4 and a continuation indent of 8. 1: https://source.android.com/source/code-style.html llvm-svn: 222839
* clang-format: [Java] Improve formatting of throws declarations.Daniel Jasper2014-11-261-0/+2
| | | | | | | | | | | | Before: public void doSoooooooooo() throws LoooooooooongException, LooooooooooongException {} After: public void doSoooooooooo() throws LoooooooooongException, LooooooooooongException {} llvm-svn: 222829
* clang-format: [Java] Improve cast detection.Daniel Jasper2014-11-261-0/+4
| | | | | | | | | | Before: a[b >> 1] = (byte)(c() << 4); After: a[b >> 1] = (byte) (c() << 4); llvm-svn: 222827
* clang-format: [Java] Fix breaking after annotations.Daniel Jasper2014-11-261-0/+3
| | | | | | | | | | | | | Before: @Annotation1 // comment @Annotation2 class C {} After: @Annotation1 // comment @Annotation2 class C {} llvm-svn: 222825
* clang-format: Add SFS_Empty to only empty functions on a single line.Daniel Jasper2014-11-261-35/+23
| | | | | | | | Activated for and tested by Google's Java style. This fixes llvm.org/PR21667. llvm-svn: 222819
* clang-format: [Java] Support Foo.class;Daniel Jasper2014-11-261-0/+5
| | | | | | | | | | | | | Before: SomeClass. class.getName(); After: SomeClass.class.getName(); This fixes llvm.org/PR21665. llvm-svn: 222813
* clang-format: Refactoring.Daniel Jasper2014-11-251-0/+11
| | | | | | Re-apply r222638 and r222641 without variadic templates. llvm-svn: 222747
* Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 ↵Aaron Ballman2014-11-241-11/+0
| | | | | | does not support variadic templates. Also reverting r222641 because it was relying on 222638. llvm-svn: 222656
* clang-format: [Java] Treat 'instanceof' like other binary operators.Daniel Jasper2014-11-231-0/+11
| | | | | | This fixes llvm.org/PR21436. llvm-svn: 222641
* clang-format: [Java] Space before array initializers.Daniel Jasper2014-11-231-2/+9
| | | | | | | | | | Before: new int[]{1, 2, 3, 4}; After: new int[] {1, 2, 3, 4}; llvm-svn: 222640
* clang-format: Use nested block special case for all languages.Daniel Jasper2014-11-211-0/+23
| | | | | | | | | | | | | | | | | | | Previously this was only used for JavaScript. Before: functionCall({ int i; int j; }, aaaa, bbbb, cccc); After: functionCall({ int i; int j; }, aaaa, bbbb, cccc); llvm-svn: 222531
* clang-format: [Java] Support more Java keywords.Daniel Jasper2014-11-211-0/+2
| | | | | | | | | | | | | | | | | | Before: public final<X> Foo foo() { } public abstract<X> Foo foo(); After: public final <X> Foo foo() { } public abstract <X> Foo foo(); Patch by Harry Terkelsen. Thank you. llvm-svn: 222527
* clang-format: [Java] Basic lambda support.Daniel Jasper2014-11-211-0/+15
| | | | llvm-svn: 222524
OpenPOWER on IntegriCloud