History log of /llvm-project/clang/unittests/Format/FormatTestJS.cpp (Results 1 – 25 of 353)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7
# 57c161a6 17-Dec-2024 Gedare Bloom <gedare@rtems.org>

[clang-format] Detect nesting in template strings (#119989)

The helper to check if a token is in a template string scans too far
backward. It should stop if a different scope is found.

Fixes #10

[clang-format] Detect nesting in template strings (#119989)

The helper to check if a token is in a template string scans too far
backward. It should stop if a different scope is found.

Fixes #107571

show more ...


Revision tags: llvmorg-19.1.6
# 8c681a92 15-Dec-2024 Owen Pan <owenpiano@gmail.com>

[clang-format][NFC] Add a TypeScript test case

See #108530.


Revision tags: llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1
# c9aa9d53 19-Sep-2024 Gedare Bloom <gedare@rtems.org>

[clang-format] Fix regression in BAS_AlwaysBreak for-await (#108634)

Fixes #108589.


Revision tags: llvmorg-19.1.0
# 04d71ea1 16-Sep-2024 kadir çetinkaya <kadircet@google.com>

[Format] Dont treat LBrace after extends/implements as initializer list (#108524)

This extends the fix in https://github.com/llvm/llvm-project/pull/106242
for other derived class types.


# 8168088f 12-Sep-2024 Owen Pan <owenpiano@gmail.com>

[clang-format] Fix regressions in BAS_AlwaysBreak (#107506)

Fixes #107401.
Fixes #107574.


Revision tags: llvmorg-19.1.0-rc4
# 77d63cfd 28-Aug-2024 Krasimir Georgiev <krasimir@google.com>

[clang-format] js handle anonymous classes (#106242)

Addresses a regression in JavaScript when formatting anonymous classes.

---------

Co-authored-by: Owen Pan <owenpiano@gmail.com>


Revision tags: llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7
# 1c58208d 21-May-2024 Owen Pan <owenpiano@gmail.com>

[clang-format][NFC] Remove redundnat llvm::, clang::, etc.


Revision tags: llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init
# d03beb94 22-Dec-2023 Ilya Biryukov <ibiryukov@google.com>

[clang-format] Do not break on JS fields like on goto labels (#76233)

This regressions was introduced in
70d7ea0cebcf363cd0ddcfb76375fb5fada87dd5.
The commit moved some code and correctly picked u

[clang-format] Do not break on JS fields like on goto labels (#76233)

This regressions was introduced in
70d7ea0cebcf363cd0ddcfb76375fb5fada87dd5.
The commit moved some code and correctly picked up an explicit check for
not running on Verilog.
However, the moved code also never ran for JavaScript and after the
commit we run it there and
this causes the wrong formatting of:

```js
export type Params = Config&{
columns: Column[];
};
```
into
```js
export type Params = Config&{
columns:
Column[];
};
```

show more ...


Revision tags: llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4
# 9299ace0 27-Oct-2023 Owen Pan <owenpiano@gmail.com>

[clang-format][NFC] Remove extraneous newlines in remaining unit tests


Revision tags: llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0
# ae90f689 15-Sep-2023 sstwcw <su3e8a96kzlver@posteo.net>

[clang-format] Disable string breaking in JS for now (#66372)

See the discussion

[here](https://github.com/llvm/llvm-project/pull/66168#issuecomment-1719038797).

The functionality is not matur

[clang-format] Disable string breaking in JS for now (#66372)

See the discussion

[here](https://github.com/llvm/llvm-project/pull/66168#issuecomment-1719038797).

The functionality is not mature enough.

show more ...


# cb479e7d 14-Sep-2023 sstwcw <su3e8a96kzlver@posteo.net>

[clang-format] More on unbreakable strings in TypeScript (#66321)

Now. string literals in lines beginning with `export type` will not be
broken.

The case was missed in 5db201fb75e6. I don't know T

[clang-format] More on unbreakable strings in TypeScript (#66321)

Now. string literals in lines beginning with `export type` will not be
broken.

The case was missed in 5db201fb75e6. I don't know TypeScript. And
merging GitHub pull requests seems to be a little too easy. So it got
committed before the reviewers had a chance to find edge cases.

show more ...


# 5db201fb 13-Sep-2023 sstwcw <134215812+sstwcw@users.noreply.github.com>

[clang-format] Stop breaking unbreakable strings in JS (#66168)

Dictionary literal keys and strings in TypeScript type declarations can
not be broken.

The problem was pointed out by @alexfh and

[clang-format] Stop breaking unbreakable strings in JS (#66168)

Dictionary literal keys and strings in TypeScript type declarations can
not be broken.

The problem was pointed out by @alexfh and @e-kud here:

https://reviews.llvm.org/D154093#4644512

show more ...


Revision tags: llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init
# ddc80637 29-Jun-2023 sstwcw <su3e8a96kzlver@posteo.net>

[clang-format] Break long string literals in C#, etc.

Now strings that are too long for one line in C#, Java, JavaScript, and
Verilog get broken into several lines. C# and JavaScript interpolated
s

[clang-format] Break long string literals in C#, etc.

Now strings that are too long for one line in C#, Java, JavaScript, and
Verilog get broken into several lines. C# and JavaScript interpolated
strings are not broken.

A new subclass BreakableStringLiteralUsingOperators is used to handle
the logic for adding plus signs and commas. The updateAfterBroken
method was added because now parentheses or braces may be required after
the parentheses or commas are added. In order to decide whether the
added plus sign should be unindented in the BreakableToken object, the
logic for it is taken out into a separate function
shouldUnindentNextOperator.

The logic for finding the continuation indentation when the option
AlignAfterOpenBracket is set to DontAlign is not implemented yet. So in
that case the new line may have the wrong indentation, and the parts may
have the wrong length if the string needs to be broken more than once
because finding where to break the string depends on where the string
starts.

The preambles for the C# and Java unit tests are changed to the newer
style in order to allow the 3-argument verifyFormat macro. Some cases
are changed from verifyFormat to verifyImcompleteFormat because those
use incomplete code and the new verifyFormat function checks that the
code is complete.

The line in the doc was changed to being indented by 4 spaces, that is,
the default continuation indentation. It has always been the case. It
was probably a mistake that the doc showed 2 spaces previously.

This commit was fist committed as 16ccba51072b. The tests caused
assertion failures. Then it was reverted in 547bce36132a.

Reviewed By: MyDeveloperDay

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

show more ...


# 547bce36 24-Aug-2023 David Spickett <david.spickett@linaro.org>

Revert "[clang-format] Break long string literals in C#, etc."

This reverts commit 16ccba51072bbc5ff4c66f91f939163dc91e5d96.

This is failing across Linaro's bots e.g.:
https://lab.llvm.org/buildbot

Revert "[clang-format] Break long string literals in C#, etc."

This reverts commit 16ccba51072bbc5ff4c66f91f939163dc91e5d96.

This is failing across Linaro's bots e.g.:
https://lab.llvm.org/buildbot/#/builders/188/builds/34393

show more ...


# 16ccba51 29-Jun-2023 sstwcw <su3e8a96kzlver@posteo.net>

[clang-format] Break long string literals in C#, etc.

Now strings that are too long for one line in C#, Java, JavaScript, and
Verilog get broken into several lines. C# and JavaScript interpolated
s

[clang-format] Break long string literals in C#, etc.

Now strings that are too long for one line in C#, Java, JavaScript, and
Verilog get broken into several lines. C# and JavaScript interpolated
strings are not broken.

A new subclass BreakableStringLiteralUsingOperators is used to handle
the logic for adding plus signs and commas. The updateAfterBroken
method was added because now parentheses or braces may be required after
the parentheses or commas are added. In order to decide whether the
added plus sign should be unindented in the BreakableToken object, the
logic for it is taken out into a separate function
shouldUnindentNextOperator.

The logic for finding the continuation indentation when the option
AlignAfterOpenBracket is set to DontAlign is not implemented yet. So in
that case the new line may have the wrong indentation, and the parts may
have the wrong length if the string needs to be broken more than once
because finding where to break the string depends on where the string
starts.

The preambles for the C# and Java unit tests are changed to the newer
style in order to allow the 3-argument verifyFormat macro. Some cases
are changed from verifyFormat to verifyImcompleteFormat because those
use incomplete code and the new verifyFormat function checks that the
code is complete.

The line in the doc was changed to being indented by 4 spaces, that is,
the default continuation indentation. It has always been the case. It
was probably a mistake that the doc showed 2 spaces previously.

Reviewed By: MyDeveloperDay

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

show more ...


# 20b4df1e 16-Jun-2023 Owen Pan <owenpiano@gmail.com>

[clang-format][NFC] Clean up unit tests

This patch adds a verifyNoChange macro to verify code that won't
change after being formatted. (The code will not be messed up before
being formatted.) It the

[clang-format][NFC] Clean up unit tests

This patch adds a verifyNoChange macro to verify code that won't
change after being formatted. (The code will not be messed up before
being formatted.) It then replaces EXPECT_EQ with verifyFormat
wherever applicable so that the code will be messed up before being
formatted. When the replacement fails the unit test, verifyFormat is
replaced with verifyNoChange.

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

show more ...


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4
# 34b422ba 10-May-2023 Jan Kuhle <jankuehle@google.com>

clang-format: [JS] support import/export type

Contributed by @jankuehle!

Users can choose to only import/export the type of the symbol (not value nor namespace) by adding a `type` keyword, e.g.:

`

clang-format: [JS] support import/export type

Contributed by @jankuehle!

Users can choose to only import/export the type of the symbol (not value nor namespace) by adding a `type` keyword, e.g.:

```
import type {x} from 'y';
import {type x} from 'y';
export type {x};
export {type x};
```

Previously, this was not handled and would:
- Terminate import sorting
- Remove the space before the curly bracket in `export type {`

With this change, both formatting and import sorting work as expected.

Reviewed By: MyDeveloperDay, krasimir

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

show more ...


Revision tags: llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3
# 801bd326 21-Feb-2023 Taymon A. Beal <taymon@google.com>

[clalng-format] Fix handling of TypeScript tuples with optional last member

These were previously incorrectly treated as syntax errors.

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


Revision tags: llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3
# 4b53c001 06-Oct-2022 Sam McCall <sam.mccall@gmail.com>

[Format] Drop speculative test added in previous patch, it hits asserts?


# 882a05af 06-Oct-2022 Sam McCall <sam.mccall@gmail.com>

[Format] Fix crash when hitting eof while lexing JS template string

Different loop termination conditions resulted in confusion of whether
*Offset was intended to be inside or outside the token.
Thi

[Format] Fix crash when hitting eof while lexing JS template string

Different loop termination conditions resulted in confusion of whether
*Offset was intended to be inside or outside the token.
This ultimately led to constructing an out-of-range SourceLocation.

Fix by making Offset consistently point *after* the token.

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

show more ...


Revision tags: working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1
# f6740fe4 30-Mar-2022 sstwcw <f0gukp2nk@protonmail.com>

[clang-format] Indent import statements in JavaScript.

[clang-format] Indent import statements in JavaScript.

Take for example this piece of code found at
<https://developer.mozilla.org/en-US/docs/

[clang-format] Indent import statements in JavaScript.

[clang-format] Indent import statements in JavaScript.

Take for example this piece of code found at
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import>.

```
for (const link of document.querySelectorAll("nav > a")) {
link.addEventListener("click", e => {
e.preventDefault();

import('/modules/my-module.js')
.then(module => {
module.loadPageInto(main);
})
.catch(err => {
main.textContent = err.message;
});
});
}
```

Previously the import line would be unindented, looking like this.

```
for (const link of document.querySelectorAll("nav > a")) {
link.addEventListener("click", e => {
e.preventDefault();

import('/modules/my-module.js')
.then(module => {
module.loadPageInto(main);
})
.catch(err => {
main.textContent = err.message;
});
});
}
```

Actually we were going to fix this along with fixing Verilog import
statements. But the patch got too big.

Reviewed By: MyDeveloperDay, curdeius

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

show more ...


Revision tags: llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3
# 4e88cb68 09-Mar-2022 Marek Kurdej <marek.kurdej+llvm.org@gmail.com>

[clang-format] Handle attributes before case label. Relanded.

Fixes https://github.com/llvm/llvm-project/issues/53110.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revisio

[clang-format] Handle attributes before case label. Relanded.

Fixes https://github.com/llvm/llvm-project/issues/53110.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

Relanding as the original patch provoked an infinite loop in JavaScript/TypeScript.
A reproducer test case was added and the issue fixed.

show more ...


# c24b3db4 14-Mar-2022 sstwcw <f0gukp2nk@protonmail.com>

[clang-format] Add option to align compound assignments like `+=`

Reviewed By: curdeius, HazardyKnusperkeks, MyDeveloperDay

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


Revision tags: llvmorg-14.0.0-rc2
# 071f870e 22-Feb-2022 Marek Kurdej <marek.kurdej+llvm.org@gmail.com>

[clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.

Fixes the issue raised post-review in D113319 (cf. https://reviews.llvm.org/D113319#3337485).

Reviewed By: krasimir

[clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.

Fixes the issue raised post-review in D113319 (cf. https://reviews.llvm.org/D113319#3337485).

Reviewed By: krasimir

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

show more ...


Revision tags: llvmorg-14.0.0-rc1, llvmorg-15-init
# f4d5195d 28-Jan-2022 Marek Kurdej <marek.kurdej+llvm.org@gmail.com>

[clang-format] Move irrelevant code from getRangeLength to getRemainingLength. NFC.


12345678910>>...15