History log of /llvm-project/clang/unittests/Format/FormatTestJS.cpp (Results 76 – 100 of 353)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 7e0f25b2 25-Nov-2017 Martin Probst <martin@probst.io>

clang-format: [JS] disable ASI on decorators.

Summary:
Automatic Semicolon Insertion in clang-format tries to guess if a line
wrap should insert an implicit semicolong. The previous heuristic would

clang-format: [JS] disable ASI on decorators.

Summary:
Automatic Semicolon Insertion in clang-format tries to guess if a line
wrap should insert an implicit semicolong. The previous heuristic would
not trigger ASI if a token was immediately preceded by an `@` sign:

function foo(@Bar // <-- does not trigger due to preceding @
baz) {}

However decorators can have arbitrary parameters:

function foo(@Bar(param, param, param) // <-- precending @ missed
baz) {}

While it would be possible to precisely find the matching `@`, just
conversatively disabling ASI for the entire line is simpler, while also
not regressing ASI substatially.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D40410

llvm-svn: 318973

show more ...


# ce2bd4df 24-Nov-2017 Martin Probst <martin@probst.io>

clang-format: [JS] do not break in ArrayType[].

Summary:
Wrapping between the type name and the array type indicator creates
invalid syntax in TypeScript.

Before:
const xIsALongIdent:
Y

clang-format: [JS] do not break in ArrayType[].

Summary:
Wrapping between the type name and the array type indicator creates
invalid syntax in TypeScript.

Before:
const xIsALongIdent:
YJustBarelyFitsLinex
[]; // illegal syntax.

After:
const xIsALongIdent:
YJustBarelyFitsLinex[];

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40436

llvm-svn: 318959

show more ...


# a5968aad 24-Nov-2017 Martin Probst <martin@probst.io>

clang-format: [JS] do not wrap before yield.

Summary: The same rules apply as for `return`.

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40431

llvm-svn

clang-format: [JS] do not wrap before yield.

Summary: The same rules apply as for `return`.

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40431

llvm-svn: 318958

show more ...


# a2555114 24-Nov-2017 Martin Probst <martin@probst.io>

clang-format: [JS] space between ! assert and in.

Summary:
Before:
x = y!in z;
After:
x = y! in z;

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D

clang-format: [JS] space between ! assert and in.

Summary:
Before:
x = y!in z;
After:
x = y! in z;

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40433

llvm-svn: 318957

show more ...


# 70cec59e 24-Nov-2017 Martin Probst <martin@probst.io>

clang-format: [JS] handle destructuring `of`.

Summary:
Previously, clang-format would drop a space character between `of` and
then following (non-identifier) token if the preceding token was part of

clang-format: [JS] handle destructuring `of`.

Summary:
Previously, clang-format would drop a space character between `of` and
then following (non-identifier) token if the preceding token was part of
a destructuring assignment (`}` or `]`).

Before:
for (const [a, b] of[]) {}

After:
for (const [a, b] of []) {}

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40411

llvm-svn: 318942

show more ...


# a004b3f5 17-Nov-2017 Martin Probst <martin@probst.io>

clang-format: remove trailing lines in lamdas and arrow functions.

Summary:
clang-format already removes empty lines at the beginning & end of
blocks:

int x() {

foo(); // lines before a

clang-format: remove trailing lines in lamdas and arrow functions.

Summary:
clang-format already removes empty lines at the beginning & end of
blocks:

int x() {

foo(); // lines before and after will be removed.

}

However because lamdas and arrow functions are parsed as expressions,
the existing logic to remove empty lines in UnwrappedLineFormatter
doesn't handle them.

This change special cases arrow functions in ContinuationIndenter to
remove empty lines:

x = []() {

foo(); // lines before and after will now be removed.

};

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D40178

llvm-svn: 318537

show more ...


# 35599fdf 16-Oct-2017 Krasimir Georgiev <krasimir@google.com>

[clang-format] Break non-trailing comments, try 2

Summary:
This patch enables `BreakableToken` to manage the formatting of non-trailing
block comments. It is a refinement of https://reviews.llvm.org

[clang-format] Break non-trailing comments, try 2

Summary:
This patch enables `BreakableToken` to manage the formatting of non-trailing
block comments. It is a refinement of https://reviews.llvm.org/D37007.
We discovered that the optimizer outsmarts us on cases where breaking the comment
costs considerably less than breaking after the comment. This patch addresses
this by ensuring that a newline is inserted between a block comment and the next
token.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D37695

llvm-svn: 315893

show more ...


# 103a7b5b 11-Sep-2017 Martin Probst <martin@probst.io>

clang-format: [JS] wrap and indent `goog.setTestOnly` calls.

Summary:
While `goog.setTestOnly` usually appears in the imports section of a file, it is
not actually an import, and also usually doesn'

clang-format: [JS] wrap and indent `goog.setTestOnly` calls.

Summary:
While `goog.setTestOnly` usually appears in the imports section of a file, it is
not actually an import, and also usually doesn't take long parameters (nor
namespaces as a parameter, it's a description/message that should be wrapped).

This fixes a regression where a `goog.setTestOnly` call nested in a function was
not wrapped.

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D37685

llvm-svn: 312918

show more ...


# c10d97f9 29-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] simplify template string wrapping.

Summary:
Previously, clang-format would try to wrap template string substitutions
by indenting relative to the openening `${`. This helped with

clang-format: [JS] simplify template string wrapping.

Summary:
Previously, clang-format would try to wrap template string substitutions
by indenting relative to the openening `${`. This helped with
indenting structured strings, such as strings containing HTML, as the
substitutions would be aligned according to the structure of the string.

However it turns out that the overwhelming majority of template string +
substitution usages are for substitutions into non-structured strings,
e.g. URLs or just plain messages. For these situations, clang-format
would often produce very ugly indents, in particular for strings
containing no line breaks:

return `<a href='http://google3/${file}?l=${row}'>${file}</a>(${
row
},${
col
}): `;

This change makes clang-format indent template string substitutions as
if they were string concatenation operations. It wraps +4 on overlong
lines and keeps all operands on the same line:

return `<a href='http://google3/${file}?l=${row}'>${file}</a>(${
row},${col}): `;

While this breaks some lexical continuity between the `${` and `row}`
here, the overall effects are still a huge improvement, and users can
still manually break the string using `+` if desired.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D37142

llvm-svn: 311988

show more ...


# 325ff7c5 14-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] wrap optional properties in type aliases.

Summary:
clang-format wraps object literal keys in an object literal if they are
marked as `TT_SelectorName`s and/or the colon is marked

clang-format: [JS] wrap optional properties in type aliases.

Summary:
clang-format wraps object literal keys in an object literal if they are
marked as `TT_SelectorName`s and/or the colon is marked as
`TT_DictLiteral`. Previously, clang-format would accidentally work
because colons in type aliases were marked as `TT_DictLiteral`. r310367
fixed this to assing `TT_JsTypeColon`, which broke wrapping in certain
situations. However the root cause was that clang-format incorrectly
didn't skip questionmarks when detecting selector name.

This change fixes both locations to (1) assign `TT_SelectorName` and (2)
treat `TT_JsTypeColon` like `TT_DictLiteral`.

Previously:

type X = {
a: string, b?: string,
};

Now:

type X = {
a: string,
b?: string,
};

Reviewers: djasper, sammccall

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D36684

llvm-svn: 310852

show more ...


# 83e0220b 14-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] do not insert whitespace in call positions.

Summary:
In JavaScript, may keywords can be used in method names and thus call sites:

foo.delete();
foo.instanceof();

clang-f

clang-format: [JS] do not insert whitespace in call positions.

Summary:
In JavaScript, may keywords can be used in method names and thus call sites:

foo.delete();
foo.instanceof();

clang-format would previously insert whitespace after the `instanceof`. This
change generically skips inserting whitespace between a keyword and a
parenthesis if preceded by a dot, i.e. in a callsite.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36142

llvm-svn: 310851

show more ...


# 0a19d433 09-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] detect ASI after closing parens.

Summary: A closing parenthesis followed by a declaration or statement should always terminate the current statement.

Reviewers: djasper

Subscrib

clang-format: [JS] detect ASI after closing parens.

Summary: A closing parenthesis followed by a declaration or statement should always terminate the current statement.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36491

llvm-svn: 310482

show more ...


# 3b86534a 09-Aug-2017 Krasimir Georgiev <krasimir@google.com>

[clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

Summary:
This handles a case where the trailing '*/' of a multiline jsdoc eding in a
comment pragma wouldn't be put

[clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

Summary:
This handles a case where the trailing '*/' of a multiline jsdoc eding in a
comment pragma wouldn't be put on a new line.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D36359

llvm-svn: 310458

show more ...


# 0fb46bb2 08-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] fix union type spacing in object & array types.

Summary:
Previously, clang-format would insert whitespace in union types nested in object
and array types, as it wouldn't recognize

clang-format: [JS] fix union type spacing in object & array types.

Summary:
Previously, clang-format would insert whitespace in union types nested in object
and array types, as it wouldn't recognize those as a type operator:

const x: {foo: number | null};
const x: [number | null];

While this is correct for actual binary operators, clang-format should not
insert whitespace into union and intersection types to mark those:

const x: {foo: number|null};
const x: [number|null];

This change propagates that the context is not an expression by inspecting
the preceding token and marking as non-expression if it was a type colon.

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D36136

llvm-svn: 310367

show more ...


# 64d31ede 08-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] handle single lines comments ending in `\\`.

Summary:
Previously, clang-format would consider the following code line to be part of
the comment and incorrectly format the rest of

clang-format: [JS] handle single lines comments ending in `\\`.

Summary:
Previously, clang-format would consider the following code line to be part of
the comment and incorrectly format the rest of the file.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36159

llvm-svn: 310365

show more ...


# f785fd94 04-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] support fields with case/switch/default labels.

Summary:
`case:` and `default:` would normally parse as labels for a `switch` block.
However in TypeScript, they can be used in fie

clang-format: [JS] support fields with case/switch/default labels.

Summary:
`case:` and `default:` would normally parse as labels for a `switch` block.
However in TypeScript, they can be used in field declarations, e.g.:

interface I {
case: string;
}

This change special cases parsing them in declaration lines to avoid wrapping
them.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36148

llvm-svn: 310070

show more ...


# 9926abb9 01-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] no whitespace between typeof operator and l_paren.

llvm-svn: 309713


# cde9815d 01-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] prefer wrapping chains over empty literals.

Summary:
E.g. don't wrap like this:

(foo.bar.baz).and.bam(Blah.of({
}))

But rather:

(foo.bar.baz)
.and.bam(Blah.

clang-format: [JS] prefer wrapping chains over empty literals.

Summary:
E.g. don't wrap like this:

(foo.bar.baz).and.bam(Blah.of({
}))

But rather:

(foo.bar.baz)
.and.bam(Blah.of({}))

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36139

llvm-svn: 309712

show more ...


# 22e00f09 01-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] whitespace between keywords and parenthesized expressions.

Summary: `throw (...)` should have a whitespace following it, as do await and void.

Reviewers: djasper

Subscribers: kl

clang-format: [JS] whitespace between keywords and parenthesized expressions.

Summary: `throw (...)` should have a whitespace following it, as do await and void.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36146

llvm-svn: 309710

show more ...


# ec36326d 01-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] handle union types in arrow functions.

Summary: clang-format would previously fail to detect that an arrow functions parameter block is not an expression, and thus insert whitespa

clang-format: [JS] handle union types in arrow functions.

Summary: clang-format would previously fail to detect that an arrow functions parameter block is not an expression, and thus insert whitespace around the `|` and `&` type operators in it.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36147

llvm-svn: 309707

show more ...


# db51cc57 01-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] consistenly format enums.

Summary: Previously, const enums would get formatted differently because the modifier was not recognized.

Reviewers: djasper

Subscribers: klimek, cfe-c

clang-format: [JS] consistenly format enums.

Summary: Previously, const enums would get formatted differently because the modifier was not recognized.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36144

llvm-svn: 309703

show more ...


# cb870c57 01-Aug-2017 Martin Probst <martin@probst.io>

clang-format: [JS] handle object types in extends positions.

Summary:
clang-format would previously drop the whitespace after `extends` in code such as:

class Foo extends {} {}

Where the first

clang-format: [JS] handle object types in extends positions.

Summary:
clang-format would previously drop the whitespace after `extends` in code such as:

class Foo extends {} {}

Where the first set of curly braces is an inline object literal type.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36131

llvm-svn: 309695

show more ...


# 22d7e6b0 20-Jul-2017 Krasimir Georgiev <krasimir@google.com>

[clang-format] Put '/**' and '*/' on own lines in multiline jsdocs

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D35683

[clang-format] Put '/**' and '*/' on own lines in multiline jsdocs

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D35683

llvm-svn: 308684

show more ...


# 93008f01 18-Jul-2017 Martin Probst <martin@probst.io>

clang-format: [JS] Correctly format JavaScript imports with long module paths

Currently the `UnwrappedLineParser` fails to correctly unwrap JavaScript
imports where the module path is not on the sam

clang-format: [JS] Correctly format JavaScript imports with long module paths

Currently the `UnwrappedLineParser` fails to correctly unwrap JavaScript
imports where the module path is not on the same line as the `from` keyword.
For example:

import {A} from
'some/path/longer/than/column/limit/module.js';```

This causes issues when in the middle a list of imports because the formatter
thinks it has reached the end of the imports, and therefore will not sort any
imports lower in the list.

The formatter will, however, split the `from` keyword and the module path if
the path exceeds the column limit, which triggers the issue the next time the
file is formatted.

Patch originally by Jared Neil - thanks!

Differential Revision: https://reviews.llvm.org/D34920

llvm-svn: 308306

show more ...


# a81dd0b6 07-Jul-2017 Martin Probst <martin@probst.io>

clang-format: [JS] do not wrap after "readonly".

Summary:
Breaks after "readonly" trigger automatic semicolon insertion in field
declarations.

Reviewers: krasimir, djasper

Subscribers: klimek

Dif

clang-format: [JS] do not wrap after "readonly".

Summary:
Breaks after "readonly" trigger automatic semicolon insertion in field
declarations.

Reviewers: krasimir, djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D35112

llvm-svn: 307394

show more ...


12345678910>>...15