Commit Graph

122 Commits

Author SHA1 Message Date
David Farler
c46c423da5 Revert "Fix ASan container-overflow in CodeFormatter"
This reverts commit 430c0abd2f.
2016-11-18 13:23:31 -08:00
David Farler
430c0abd2f Fix ASan container-overflow in CodeFormatter
I made an overzealous rebase earlier that caused a bad std::vector
iterator to be indirected.
2016-11-16 16:56:14 -08:00
David Farler
d6e2b58382 Preserve whitespace and comments during lexing as Trivia
Store leading a trailing "trivia" around a token, such as whitespace,
comments, doc comments, and escaping backticks. These are syntactically
important for preserving formatting when printing ASTs but don't
semantically affect the program.

Tokens take all trailing trivia up to, but not including, the next
newline. This is important to maintain checks that statements without
semicolon separators start on a new line, among other things.

Trivia are now data attached to the ends of tokens, not tokens
themselves.

Create a new Syntax sublibrary for upcoming immutable, persistent,
thread-safe ASTs, which will contain only the syntactic information
about source structure, as well as for generating new source code, and
structural editing. Proactively move swift::Token into there.

Since this patch is getting a bit large, a token fuzzer which checks
for round-trip equivlence with the workflow:

fuzzer => token stream => file1
  => Lexer => token stream => file 2 => diff(file1, file2)

Will arrive in a subsequent commit.

This patch does not change the grammar.
2016-11-15 16:11:57 -08:00
Daniel Duan
d0de084a79 [swift-format] add option to indent switch block
add a boolean option to indent switch's block:

```
// with -indent-switch-case
switch xyz {
  case .x:
    doSomething()
}
```

```
// without -indent-switch-case
switch xyz {
case .x:
  doSomething()
}
```
2016-11-03 19:48:41 -07:00
Xi Ge
e5d77911a2 [SourceKit] Indent property getters disregarding of empty bodies. rdar://28049927 (#5246)
[SourceKit] Indentation: when the indented line starts with open brace and the
line before starts with a leading declaration keywords, we never add
indentation level on the brace. rdar://28049927
2016-10-11 19:23:29 -07:00
Xi Ge
7cb5d9a8a2 [SourceKit] When function calls taking multiple closures, align the end of them. rdar://27473586 (#4787) 2016-09-14 19:13:50 -07:00
Xi Ge
365bb52a31 [SourceKit] Avoid adding indentation at the end of a CaptureListExpr. rdar://28193169 (#4749) 2016-09-13 13:33:34 -07:00
Xi Ge
5d07b4b068 [SourceKit][Format] Avoid indenting when multiple function call ends at the same line.
This fixes SR-603.
2016-07-25 17:57:57 -07:00
Daniel Martín
953076d9fc Fix coding style in Formatting.cpp (#3493) 2016-07-13 11:00:01 -07:00
Xi Ge
2ed177046e [SourceKit] Check location validity before getting the line number to fix a crash. rdar://26756189 (#3364) 2016-07-06 21:26:09 -07:00
Argyrios Kyrtzidis
49d786557c Fix bad merge, "#ifdef 0" -> "if 0" 2016-06-05 12:09:07 -07:00
Argyrios Kyrtzidis
20c5f53372 Merge pull request #2891 from practicalswift/remove-commented-out-code
[gardening] Remove commented out code.
2016-06-05 12:06:20 -07:00
practicalswift
2ef95264fc [gardening] Use the preferred form "#ifdef 0" instead of "/*". 2016-06-05 10:28:58 +02:00
practicalswift
d34114fec5 [gardening] Normalize formatting. Use "OS X" instead of "OSX". 2016-06-04 23:38:42 +02:00
practicalswift
57bccc8b06 [gardening] Fix inconsistent formatting. 2016-06-04 00:37:15 +02:00
Argyrios Kyrtzidis
d10220920b [IDE/format] Disable the sibling check for dictionary/array literal elements.
This ends up creating too much indentation in some common cases.
This effectively get us back to indentation behavior of Swift 2.2.

Addresses rdar://26290643.
2016-05-23 17:23:40 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Ben Langmuir
4d9c9f6098 Move SourceEntityWalker into libAST NFC
It fits right in among our other AST walkers and lets us use it lower in
the stack than libIDE.
2016-04-01 14:14:06 -07:00
Xi Ge
589d9a8a3e CodeFormat: Avoid indenting the close bracket of a closure if the closure is on the RHS of an assignment expression. rdar://24507930 2016-03-29 13:08:55 -07:00
practicalswift
ac87f428ea [gardening] Fix formatting of recently introduced headers. 2016-03-22 21:36:09 +01:00
John Regner
5b9fc3d832 [SourceKit] Add reformat function to libIDE
Move all the rest of the code formatters and helper classes out of the interface.
2016-03-18 21:37:00 -07:00
John Regner
e63678579b [SourceKit] Moved Formatting files into place in libIDE 2016-03-18 21:19:57 -07:00