Daniel Jasper
043ac05010
clang-format: [Java/JS] Properly support instanceof and its precedence.
...
llvm-svn: 241337
2015-07-03 10:12:53 +00:00
Alexander Kornienko
ab9db51042
Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
...
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko
3d9d929e42
Fixed/added namespace ending comments using clang-tidy. NFC
...
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
2015-06-22 09:47:44 +00:00
Daniel Jasper
e6fcf7d372
clang-format: clang-format (NFC)
...
llvm-svn: 239903
2015-06-17 13:08:06 +00:00
Daniel Jasper
9dedc775d7
clang-format: Indent relative to the ./-> and not the function name.
...
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
2015-04-07 06:41:24 +00:00
Daniel Jasper
6acf513099
clang-format: [Java] Support anonymous classes after = and return.
...
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
2015-03-12 14:44:29 +00:00
Daniel Jasper
e189d46512
clang-format: [Java] Support try blocks with resources.
...
Before:
try
(SomeResource rs = someFunction()) {
Something();
}
After:
try (SomeResource rs = someFunction()) {
Something();
}
llvm-svn: 225973
2015-01-14 10:48:41 +00:00
Daniel Jasper
190fbda6de
clang-format: [Java] Prefer not to break in parameter annotations.
...
Before:
boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
String aaaaa,
String bbbbbbbbbbbbbbb) {}
After:
boolean someFunction(
@Param(aaaaaaaaaaaaaaaa) String aaaaa,
String bbbbbbbbbbbbbbb) {}
llvm-svn: 225971
2015-01-14 10:36:31 +00:00
Daniel Jasper
16dbe0bc44
clang-format: [Java] Understand "import static".
...
llvm-svn: 225965
2015-01-14 10:02:49 +00:00
Daniel Jasper
404658aede
clang-format: [Java] Don't let annotations confuse return type analysis.
...
Before:
@Test
ReturnType
doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}
After:
@Test
ReturnType doSomething(
String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}
llvm-svn: 225964
2015-01-14 10:00:20 +00:00
Daniel Jasper
3e1bd1407b
clang-format: [Java] Don't line-wrap before annotations' l_parens.
...
Before:
@SomeAnnotation
(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)
int i;
After:
@SomeAnnotation(
aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)
int i;
llvm-svn: 225963
2015-01-14 09:51:32 +00:00
Daniel Jasper
a831c58e53
clang-format: [Java] Don't get confused by leading annotations.
...
Before:
@Test(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaa);
After:
@Test(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 225962
2015-01-14 09:47:57 +00:00
Nico Weber
ed50166b6b
clang-format: [Java] Detect `native` keyword.
...
Before:
public native<X> Foo foo();
After:
public native <X> Foo foo();
llvm-svn: 225839
2015-01-13 22:32:50 +00:00
Nico Weber
beb03938e9
clang-format: [Java] Support formatting qualified annotations.
...
llvm-svn: 225559
2015-01-09 23:25:06 +00:00
Daniel Jasper
77ef2be2e4
clang-format: [Java] Fix incorrect detection of cast.
...
After:
return (a instanceof List<?>) ? aaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaa)
: aaaaaaaaaaaaaaaaaaaaaaa;
After:
return (a instanceof List<?>)
? aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)
: aaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 225161
2015-01-05 10:33:39 +00:00
Daniel Jasper
5f1fa85e5b
clang-format: [Java] Fix incorrect recognition of annonymous classes.
...
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
2015-01-04 20:40:51 +00:00
Daniel Jasper
428f0b1430
clang-format: Re-enable comment re-indentation for Java/JS.
...
This was broken by r224120.
llvm-svn: 225130
2015-01-04 09:11:17 +00:00
Alexander Kornienko
ff2437fe84
Don't break string literals in Java and JavaScript.
...
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
2014-12-12 13:03:22 +00:00
Daniel Jasper
a536df4b28
clang-format: Indent correctly in conditional expressions after return.
...
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
2014-12-08 21:28:31 +00:00
Daniel Jasper
211e1329cc
clang-format: [Java] Always break after annotations of multiline decls.
...
Before:
@Mock DataLoader loooooooooooooooooooooooader =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After:
@Mock
DataLoader loooooooooooooooooooooooader =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 223688
2014-12-08 20:08:04 +00:00
Daniel Jasper
8379107afe
clang-format: Fix expression parser not closing stuff at end of stmt.
...
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
2014-12-03 13:20:49 +00:00
Daniel Jasper
3219e43c94
clang-format: Add option to suppress operator alignment.
...
With alignment:
int aaaaaa = aa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
* cccccccccccccccccccccccccccccccc;
Without alignment:
int aaaaaa = aa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
* cccccccccccccccccccccccccccccccc;
This fixes llvm.org/PR21666.
llvm-svn: 223117
2014-12-02 13:24:51 +00:00
Daniel Jasper
13404dad0d
clang-format: Don't use column layout with AlignAfterOpenBrackets.
...
This fixes llvm.org/PR21676.
llvm-svn: 222886
2014-11-27 14:40:48 +00:00
Daniel Jasper
9b9e07608d
clang-format: [Java] Don't line-wrap package declarations.
...
This fixes llvm.org/PR21677.
llvm-svn: 222843
2014-11-26 18:03:42 +00:00
Nico Weber
450425c980
clang-format: Tweak -style=Chromium for Java files.
...
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
2014-11-26 16:43:18 +00:00
Daniel Jasper
375815d24b
clang-format: [Java] Improve formatting of throws declarations.
...
Before:
public void doSoooooooooo() throws LoooooooooongException,
LooooooooooongException {}
After:
public void doSoooooooooo()
throws LoooooooooongException, LooooooooooongException {}
llvm-svn: 222829
2014-11-26 12:31:19 +00:00
Daniel Jasper
4f56b0bb88
clang-format: [Java] Improve cast detection.
...
Before:
a[b >> 1] = (byte)(c() << 4);
After:
a[b >> 1] = (byte) (c() << 4);
llvm-svn: 222827
2014-11-26 12:23:10 +00:00
Daniel Jasper
07013a42d2
clang-format: [Java] Fix breaking after annotations.
...
Before:
@Annotation1 // comment
@Annotation2 class C {}
After:
@Annotation1 // comment
@Annotation2
class C {}
llvm-svn: 222825
2014-11-26 11:20:43 +00:00
Daniel Jasper
9e709351c5
clang-format: Add SFS_Empty to only empty functions on a single line.
...
Activated for and tested by Google's Java style.
This fixes llvm.org/PR21667.
llvm-svn: 222819
2014-11-26 10:43:58 +00:00
Daniel Jasper
e5d74867aa
clang-format: [Java] Support Foo.class;
...
Before:
SomeClass.
class.getName();
After:
SomeClass.class.getName();
This fixes llvm.org/PR21665.
llvm-svn: 222813
2014-11-26 08:17:08 +00:00
Daniel Jasper
a98b7b01be
clang-format: Refactoring.
...
Re-apply r222638 and r222641 without variadic templates.
llvm-svn: 222747
2014-11-25 10:05:17 +00:00
Aaron Ballman
484ee9b404
Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 does not support variadic templates. Also reverting r222641 because it was relying on 222638.
...
llvm-svn: 222656
2014-11-24 15:42:34 +00:00
Daniel Jasper
325e486f9b
clang-format: [Java] Treat 'instanceof' like other binary operators.
...
This fixes llvm.org/PR21436.
llvm-svn: 222641
2014-11-23 21:34:25 +00:00
Daniel Jasper
a0143fab5e
clang-format: [Java] Space before array initializers.
...
Before:
new int[]{1, 2, 3, 4};
After:
new int[] {1, 2, 3, 4};
llvm-svn: 222640
2014-11-23 20:54:37 +00:00
Daniel Jasper
4b444495ed
clang-format: Use nested block special case for all languages.
...
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
2014-11-21 13:38:53 +00:00
Daniel Jasper
82c9275344
clang-format: [Java] Support more Java keywords.
...
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
2014-11-21 12:19:07 +00:00
Daniel Jasper
8354ea84dd
clang-format: [Java] Basic lambda support.
...
llvm-svn: 222524
2014-11-21 12:14:12 +00:00
Daniel Jasper
6cab6784b9
clang-format: [Java] Don't align after "return".
...
Doesn't seem to be common practice in Java.
Before:
return aaaaaaaaaaaaaaaaaaa
&& bbbbbbbbbbbbbbbbbbb
&& ccccccccccccccccccc;
After:
return aaaaaaaaaaaaaaaaaaa
&& bbbbbbbbbbbbbbbbbbb
&& ccccccccccccccccccc;
Patch by Harry Terkelsen.
llvm-svn: 222424
2014-11-20 09:54:49 +00:00
Daniel Jasper
caf8685958
clang-format: [Java] Don't force break before generic type method.
...
Before:
Foo.bar()
.<X>
baz();
After:
Foo.bar()
.<X>baz();
Patch by Harry Terkelsen.
llvm-svn: 222423
2014-11-20 09:48:11 +00:00
Daniel Jasper
ccb68b487e
clang-format: [Java] Accept generic types in enum declaration
...
Before:
enum Foo implements Bar<X, Y> {
ABC {
...
}
, CDE {
...
};
}
After:
enum Foo implements Bar<X, Y> {
ABC {
...
},
CDE {
...
};
}
Patch by Harry Terkelsen.
llvm-svn: 222394
2014-11-19 22:38:18 +00:00
Daniel Jasper
fe2cf6673a
clang-format: [Java] Ignore C++-specific keywords
...
Before:
public void union
(Object o);
public void struct
(Object o);
public void delete (Object o);
After:
public void union(Object o);
public void struct(Object o);
public void delete(Object o);
Patch by Harry Terkelsen, thank you!
llvm-svn: 222357
2014-11-19 14:11:11 +00:00
Daniel Jasper
3aa9a6a126
clang-format: Add option to disable alignment after opening brackets
...
Before:
SomeFunction(parameter,
parameter);
After:
SomeFunction(parameter,
parameter);
Patch by Harry Terkelsen, thank you!
llvm-svn: 222284
2014-11-18 23:55:27 +00:00
Daniel Jasper
6761b42b90
clang-format: Fix space between generic type parameter and square
...
bracket
Before:
public Foo<X, Y> [] foos;
After:
public Foo<X, Y>[] foos;
Patch by Harry Terkelsen. Thank you!
llvm-svn: 222283
2014-11-18 23:48:01 +00:00
Daniel Jasper
4bfa736f1b
clang-format: [Java] Further improve generics formatting.
...
llvm-svn: 222011
2014-11-14 17:30:15 +00:00
Daniel Jasper
734d52b58b
clang-format: [Java] Fix line break behavior of class declarations.
...
Change breaking preferences:
1. Break before "extends"
2. Break before "implements"
3. Break within the implements list.
llvm-svn: 221981
2014-11-14 10:15:56 +00:00
Daniel Jasper
09f6abe8d8
clang-format: [Java] Improve generic return type formatting.
...
Before:
public<R> ArrayList<R> get() {
After:
public <R> ArrayList<R> get() {
llvm-svn: 221979
2014-11-14 09:05:32 +00:00
Daniel Jasper
30a2406e65
clang-format: [Java] No altnerative operator names in Java.
...
Before:
someObject.and ();
After:
someObject.and();
llvm-svn: 221978
2014-11-14 09:02:28 +00:00
Daniel Jasper
61d81973c1
clang-format: [Java] Improve formatting of generics.
...
Before:
Function < F, ? extends T > function;
After:
Function<F, ? extends T> function;
llvm-svn: 221976
2014-11-14 08:22:46 +00:00
Daniel Jasper
6be0f55d44
clang-format: [Java] Support Java enums.
...
In Java, enums can contain a class body and enum constants can have
arguments as well as class bodies. Support most of that.
llvm-svn: 221895
2014-11-13 15:56:28 +00:00
Nico Weber
a644d7f39c
clang-format: [Java] Never treat @interface as annotation.
...
'@' followed by any keyword can't be an annotation, but @interface is currently
the only combination of '@' and a keyword that's allowed, so limit it to this
case. `@interface Foo` without a leading `public` was misformatted prior to
this patch.
llvm-svn: 221607
2014-11-10 16:30:02 +00:00