summaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTestJava.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* Java annotation declaration being handled correctlyHans Wennborg2018-10-191-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, Java annotation declarations (@interface AnnotationName) were being handled as ObjC interfaces. This caused the brace formatting to mess up, so that when you had a class with an interface defined in it, it would indent the final brace of the class. It used to format this class like so: class A { @interface B {} } But will now just skip the @interface and format it like so: class A { @interface B {} } Patch by Sam Maier! Differential Revision: https://reviews.llvm.org/D53434 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344789 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: Don't insert spaces in front of :: for Java 8 Method References.Nico Weber2018-10-051-0/+16
| | | | | | | | | | | | | | The existing code kept the space if it was there for identifiers, and it didn't handle `this`. After this patch, for Java `this` is handled in addition to identifiers, and existing space is always stripped between identifier and `::`. Also accept `::` in addition to `.` in front of `<` in `foo::<T>bar` generic calls. Differential Revision: https://reviews.llvm.org/D52842 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343872 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-3/+3
| | | | | | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Explicitly avoided changing the strings in the clang-format tests. Differential Revision: https://reviews.llvm.org/D44975 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332350 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang-format] In tests, expected code should be format-stableMark Zeren2018-04-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: Extend various verifyFormat helper functions to check that the expected text is "stable". This provides some protection against bugs where formatting results are ocilating between two forms, or continually change in some other way. Testing Done: * Ran unit tests. * Reproduced a known instability in preprocessor indentation which was caught by this new check. Reviewers: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42034 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329231 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: Support formatting Java 8 interface default methods.Nico Weber2018-01-231-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323218 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314325 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 (. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314172 91177308-0d34-0410-b5e6-96231b3b80d8
* [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308684 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306868 91177308-0d34-0410-b5e6-96231b3b80d8
* [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>! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299952 91177308-0d34-0410-b5e6-96231b3b80d8
* 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) {} } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296499 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275062 91177308-0d34-0410-b5e6-96231b3b80d8
* 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258981 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: [JS] "operator" is not a keyword in Java/JavaScript.Daniel Jasper2015-12-221-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256245 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250422 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove accidental superfluous newline added in r247750.Nico Weber2015-09-151-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247752 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: In Java, `assert` is followed by an expression.Nico Weber2015-09-151-0/+5
| | | | | | | | Before: assert a&& b; Now: assert a && b; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247750 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: [Java/JS] Properly support instanceof and its precedence.Daniel Jasper2015-07-031-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241337 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239903 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234300 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232042 91177308-0d34-0410-b5e6-96231b3b80d8
* 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(); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225973 91177308-0d34-0410-b5e6-96231b3b80d8
* 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) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225971 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: [Java] Understand "import static".Daniel Jasper2015-01-141-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225965 91177308-0d34-0410-b5e6-96231b3b80d8
* 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) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225964 91177308-0d34-0410-b5e6-96231b3b80d8
* 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225963 91177308-0d34-0410-b5e6-96231b3b80d8
* 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); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225962 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: [Java] Detect `native` keyword.Nico Weber2015-01-131-0/+1
| | | | | | | | | | | | Before: public native<X> Foo foo(); After: public native <X> Foo foo(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225839 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: [Java] Support formatting qualified annotations.Nico Weber2015-01-091-0/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225559 91177308-0d34-0410-b5e6-96231b3b80d8
* 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225161 91177308-0d34-0410-b5e6-96231b3b80d8
* 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); } }); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225142 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: Re-enable comment re-indentation for Java/JS.Daniel Jasper2015-01-041-0/+13
| | | | | | This was broken by r224120. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225130 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224120 91177308-0d34-0410-b5e6-96231b3b80d8
* 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223694 91177308-0d34-0410-b5e6-96231b3b80d8
* 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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223688 91177308-0d34-0410-b5e6-96231b3b80d8
* 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) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223228 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223117 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: Don't use column layout with AlignAfterOpenBrackets.Daniel Jasper2014-11-271-0/+7
| | | | | | This fixes llvm.org/PR21676. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222886 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: [Java] Don't line-wrap package declarations.Daniel Jasper2014-11-261-0/+5
| | | | | | This fixes llvm.org/PR21677. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222843 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222839 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222829 91177308-0d34-0410-b5e6-96231b3b80d8
* 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); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222827 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222825 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222819 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222813 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format: Refactoring.Daniel Jasper2014-11-251-0/+11
| | | | | | Re-apply r222638 and r222641 without variadic templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222747 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222656 91177308-0d34-0410-b5e6-96231b3b80d8