#
37a7f910 |
| 04-Jul-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] space between pseudo keywords and template literals.
Summary: Before: yield`foo`;
After: yield `foo`;
This reinstates commit 71d3b5cd91 / r307023 and fixes the logic by intr
clang-format: [JS] space between pseudo keywords and template literals.
Summary: Before: yield`foo`;
After: yield `foo`;
This reinstates commit 71d3b5cd91 / r307023 and fixes the logic by introducing an explicit table of JavaScript pseudo keywords.
Reviewers: djasper
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D34953
llvm-svn: 307087
show more ...
|
#
29e0a992 |
| 03-Jul-2017 |
Martin Probst <martin@probst.io> |
Revert "clang-format: [JS] space between pseudo keywords and template literals."
This reverts commit 71d3b5cd916106005ef23467e3f6c7fbca7bc499.
llvm-svn: 307034
|
#
bd1eb12d |
| 03-Jul-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] space between pseudo keywords and template literals.
Summary: Before: yield`foo`;
After: yield `foo`;
Reviewers: djasper
Subscribers: klimek
Differential Revision: htt
clang-format: [JS] space between pseudo keywords and template literals.
Summary: Before: yield`foo`;
After: yield `foo`;
Reviewers: djasper
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D34938
llvm-svn: 307023
show more ...
|
#
d96a052c |
| 07-Jun-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] recognize exported type definitions.
Summary: Support "export type T = {...};", in addition to just "type T = {...};".
Reviewers: klimek
Differential Revision: https://reviews.l
clang-format: [JS] recognize exported type definitions.
Summary: Support "export type T = {...};", in addition to just "type T = {...};".
Reviewers: klimek
Differential Revision: https://reviews.llvm.org/D33980
llvm-svn: 304904
show more ...
|
#
38423276 |
| 06-Jun-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] Correctly Indent Nested JavaScript Literals.
Nested literals are sometimes only indented by 2 spaces, instead of respecting the IndentWidth option. There are existing unit tests (
clang-format: [JS] Correctly Indent Nested JavaScript Literals.
Nested literals are sometimes only indented by 2 spaces, instead of respecting the IndentWidth option. There are existing unit tests (FormatTestJS.ArrayLiterals) that only pass because the style used to test them uses an IndentWidth of 2. This change removes the magic 2 and always uses the IndentWidth. I've added 6 tests. The first 4 of these tests fail before this change, while the last 2 already pass, but were added just to make sure it the change works with all types of braces.
Patch originally by Jared Neil, thanks!
Differential Revision: https://reviews.llvm.org/D33857
llvm-svn: 304791
show more ...
|
#
95ed8e79 |
| 31-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] improve calculateBraceType heuristic
Summary:
calculateBraceTypes decides for braced init for empty brace pairs ({}). In context of a function declaration, this incorrectly class
clang-format: [JS] improve calculateBraceType heuristic
Summary:
calculateBraceTypes decides for braced init for empty brace pairs ({}). In context of a function declaration, this incorrectly classifies empty function or method bodies as braced inits, leading to missing wraps:
class C { foo() {}[bar]() {} }
Where code should have wrapped after "}", before "[". This change adds another piece of contextual information in that braces following closing parentheses must always be the opening braces of function blocks. This fixes brace detection for methods immediately followed by brackets (computed property declarations), but also curlies.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D33714
llvm-svn: 304290
show more ...
|
#
b2f06eae |
| 29-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] fix indenting bound functions.
Summary: The previous fix to force build style wrapping if the previous token is a closing parenthesis broke a peculiar pattern where users parenthe
clang-format: [JS] fix indenting bound functions.
Summary: The previous fix to force build style wrapping if the previous token is a closing parenthesis broke a peculiar pattern where users parenthesize the function declaration in a bind call: fn((function() { ... }).bind(this));
This restores the previous behaviour by reverting that change, but narrowing the special case for unindenting closing parentheses to those followed by semicolons and opening braces, i.e. immediate calls and function declarations.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D33640
llvm-svn: 304135
show more ...
|
#
ab60acb6 |
| 22-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] avoid line breaks before unindented r_parens.
The change that enabled wrapping at the previous scope's indentation had unintended side-effects in that clang-format would prefer to
clang-format: [JS] avoid line breaks before unindented r_parens.
The change that enabled wrapping at the previous scope's indentation had unintended side-effects in that clang-format would prefer to wrap closing parentheses to the next line if it avoided a wrap on the next line (assuming very narrow lines):
fooObject .someCall(barbazbam) .then(bam);
Would get formatted as:
fooObject.someCall(barbazbam ).then(bam);
Because the ')' is now indented at the parent level (fooObject).
Normally formatting a builder pattern style call sequence like that is outlawed in clang-format anyway. However for JavaScript this is special cased to support trailing .bind calls.
This change disallows this special case when following a closing ')' to avoid the problem.
Included are some random comment fixes.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D33399
llvm-svn: 303557
show more ...
|
#
a050f41c |
| 18-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] for await, and fix a crash with for loops.
Summary: The syntax is actually `for await (const x of y)` (d'oh). This also fixes a crash for `for` tokens not followed by additional t
clang-format: [JS] for await, and fix a crash with for loops.
Summary: The syntax is actually `for await (const x of y)` (d'oh). This also fixes a crash for `for` tokens not followed by additional tokens.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D33329
llvm-svn: 303382
show more ...
|
#
bd49e321 |
| 15-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] for async loops.
Summary: JavaScript supports asynchronous loop iteration in async functions:
for async (const x of y) ...
Reviewers: djasper
Subscribers: klimek, cfe-commi
clang-format: [JS] for async loops.
Summary: JavaScript supports asynchronous loop iteration in async functions:
for async (const x of y) ...
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D33193
llvm-svn: 303106
show more ...
|
#
2c1cdae2 |
| 15-May-2017 |
Martin Probst <martin@probst.io> |
JavaScript allows parameter lists to include trailing commas:
myFunction(param1, param2,);
For symmetry with other parenthesized lists ([...], {...}), clang-format should wrap parenthesized lis
JavaScript allows parameter lists to include trailing commas:
myFunction(param1, param2,);
For symmetry with other parenthesized lists ([...], {...}), clang-format should wrap parenthesized lists one-per-line if they contain a trailing comma:
myFunction( param1, param2, );
This is particularly useful in function declarations or calls with many arguments, e.g. commonly in constructors.
Differential Revision: https://reviews.llvm.org/D33023
llvm-svn: 303049
show more ...
|
#
82b3d906 |
| 15-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] fix non-null assertion operator recognition.
Summary: `getIdentifierInfo()` includes all keywords, whereas non-null assertion operators should only be recognized after non-keyword
clang-format: [JS] fix non-null assertion operator recognition.
Summary: `getIdentifierInfo()` includes all keywords, whereas non-null assertion operators should only be recognized after non-keywords or pseudo keywords. Ideally this should list all tokens that clang-format recognizes as a keyword, but that are pseudo or no keywords in JS. For the time being, just recognize the specific bits users ran into (`namespace` in this case).
Reviewers: djasper
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D33182
llvm-svn: 303038
show more ...
|
#
79f9c5fe |
| 12-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] support non-null assertions after all identifiers.
Summary: Previously: x = namespace !;
Now: x = namespace!;
Reviewers: djasper
Subscribers: klimek
Differential Revis
clang-format: [JS] support non-null assertions after all identifiers.
Summary: Previously: x = namespace !;
Now: x = namespace!;
Reviewers: djasper
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D33113
llvm-svn: 302893
show more ...
|
#
b7fb267e |
| 10-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: refine calculating brace types.
Summary: For C++ code, opening parenthesis following a } indicate a braced init. For JavaScript and other languages, this is an invalid syntactical cons
clang-format: refine calculating brace types.
Summary: For C++ code, opening parenthesis following a } indicate a braced init. For JavaScript and other languages, this is an invalid syntactical construct, unless the closing parenthesis belongs to a function - in which situation its a BK_Block.
This fixes indenting IIFEs following top level functions:
function foo() {} (function() { codeHere(); }());
clang-format used to collapse these lines together.
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D33006
llvm-svn: 302658
show more ...
|
#
101ec894 |
| 09-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] Don't indent JavaScript IIFEs.
Because IIFEs[1] are often used like an anonymous namespace around large sections of JavaScript code, it's useful not to indent to them (which effec
clang-format: [JS] Don't indent JavaScript IIFEs.
Because IIFEs[1] are often used like an anonymous namespace around large sections of JavaScript code, it's useful not to indent to them (which effectively reduces the column limit by the indent amount needlessly).
It's also common for developers to wrap these around entire files or libraries. When adopting clang-format, changing the indent entire file can reduce the usefulness of the blame annotations.
Patch by danbeam, thanks!
Differential Revision: https://reviews.llvm.org/D32989
llvm-svn: 302580
show more ...
|
#
2083f31b |
| 09-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] keep triple slash directives intact.
Summary: TypeScript uses triple slash directives of the form: /// <reference path="..."/>
For various non-source instructions that should
clang-format: [JS] keep triple slash directives intact.
Summary: TypeScript uses triple slash directives of the form: /// <reference path="..."/>
For various non-source instructions that should not be wrapped.
Reference: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D32997
llvm-svn: 302523
show more ...
|
#
4ef0370e |
| 04-May-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] exponentiation operator
Summary: While its precedence should be higher than multiplicative, LLVM does not have a level for that, so for the time being just treat it as multiplicat
clang-format: [JS] exponentiation operator
Summary: While its precedence should be higher than multiplicative, LLVM does not have a level for that, so for the time being just treat it as multiplicative.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D32864
llvm-svn: 302156
show more ...
|
Revision tags: llvmorg-4.0.1-rc1 |
|
#
973ff79e |
| 27-Apr-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] parse async function declarations.
Summary: Previously, clang-format would accidentally parse an async function declaration as a function expression, and thus not insert an unwrap
clang-format: [JS] parse async function declarations.
Summary: Previously, clang-format would accidentally parse an async function declaration as a function expression, and thus not insert an unwrapped line for async functions, causing subsequent functions to run into the function:
async function f() { x(); } function g() { ...
With this change, async functions get parsed as top level function declarations and get their own unwrapped line context.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D32590
llvm-svn: 301538
show more ...
|
#
ad06391c |
| 26-Apr-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.
Summary: Java and JavaScript support annotations and decorators, respectively, that use a leading "@" token. clang-format currentl
clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.
Summary: Java and JavaScript support annotations and decorators, respectively, that use a leading "@" token. clang-format currently detects this as an Objective-C construct and applies special formatting, for example no whitespace around "=" operators. This change disables the distinction for Java and JavaScript, which leads to normal formatting of single line annotated and initialized properties.
Before: class X { @foo() bar=false; }
After: class X { @foo() bar = false; }
Reviewers: djasper, bkramer
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D32532
llvm-svn: 301399
show more ...
|
#
19c7de0a |
| 26-Apr-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] prevent wraps before class members.
Summary: In JavaScript/TypeScript, class member definitions that use modifiers can be subject to Automatic Semicolon Insertion (ASI). For examp
clang-format: [JS] prevent wraps before class members.
Summary: In JavaScript/TypeScript, class member definitions that use modifiers can be subject to Automatic Semicolon Insertion (ASI). For example, "class X { get \n foo }" defines a property called "get" and a property called "foo", both with no type annotation. This change prevents wrapping after the modifier keywords (visibility modifiers, static, get and set) to prevent accidental ASI.
Reviewers: djasper, bkramer
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D32531
llvm-svn: 301397
show more ...
|
#
bcda54b6 |
| 21-Apr-2017 |
Krasimir Georgiev <krasimir@google.com> |
[clang-format] Replace IncompleteFormat by a struct with Line
Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by
[clang-format] Replace IncompleteFormat by a struct with Line
Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by a struct that also contains a line number.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D32298
llvm-svn: 300985
show more ...
|
#
c4a3d081 |
| 05-Apr-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] fix whitespace around "of" operator.
Summary: Previously: import {of } from 'x'; of (null);
Now: import {of} from 'x'; of(null);
Reviewers: djasper
Subscribers:
clang-format: [JS] fix whitespace around "of" operator.
Summary: Previously: import {of } from 'x'; of (null);
Now: import {of} from 'x'; of(null);
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D31698
llvm-svn: 299533
show more ...
|
#
72b3357f |
| 31-Mar-2017 |
Daniel Jasper <djasper@google.com> |
clang-format: [JavaScript] Ignore QT keywords.
llvm-svn: 299204
|
#
b4cdb65e |
| 13-Mar-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] do not wrap @see tags.
Summary: @see is special among JSDoc tags in that it is commonly followed by URLs. The JSDoc spec suggests that users should wrap URLs in an additional {@li
clang-format: [JS] do not wrap @see tags.
Summary: @see is special among JSDoc tags in that it is commonly followed by URLs. The JSDoc spec suggests that users should wrap URLs in an additional {@link url...} tag (@see http://usejsdoc.org/tags-see.html), but this is very commonly violated, with @see being followed by a "naked" URL.
This change special cases all JSDoc lines that contain an @see not to be wrapped to account for that.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D30883
llvm-svn: 297607
show more ...
|
#
22b8d269 |
| 13-Mar-2017 |
Martin Probst <martin@probst.io> |
clang-format: [JS] allow breaking after non-null assertions.
Summary: Previously clang-format would not break after any !. However in TypeScript, ! can be used as a post fix operator for non-nullabi
clang-format: [JS] allow breaking after non-null assertions.
Summary: Previously clang-format would not break after any !. However in TypeScript, ! can be used as a post fix operator for non-nullability: x.foo()!.bar()!;
With this change, clang-format will wrap after the ! if it is likely a post-fix non null operator.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D30705
llvm-svn: 297606
show more ...
|