This patch adds syntax highlighting support for the new concurrency keywords
introduced in Swift 5.5 - `actor`, `async`, and `await`. It also includes supporting
changes to make sure that usages of these new features/keywords are highlighted
correctly, and to protect against regressions within existing Splash-highlighted code.
* Update the project to Swift 5.4
- Splash now uses the Swift 5.4 toolchain.
- Since Swift 5.4 now enables automatic test discovery on all supported
platforms, all of the infrastructure that was previously used to maintain
Linux unit testing compatibility has now been removed.
* Remove LinuxMain.swift
* Correctly highlight nil when used within a ternary operation
* Correctly highlight comments placed next to array types or literals
* Correctly highlight underscores used to ignore function parameters
* Correctly highlight projected property wrapper values
This patch makes Splash correctly render enum cases and static properties
that are defined on a generic type when those symbols are references along
with their enclosing type.
This change makes Splash stop highlighting generic types that are attached
to an initializer declaration, and instead now only highlights their
constraints, just like within other kinds of generic type lists.
This patch fixes syntax highlighting for when a property is being switched
on, which previously would be treated as a function call with trailing
closure syntax.
This patch fixes syntax highlighting when a function call appears as the
first expression within a closure that accepts arguments or capture lists
using the ‘in’ keyword.
This patch fixes two regressions caused by the recently introduced change
to not highlight keywords used as symbol names when binding optionals:
1. When a weak reference to `self` is unwrapped using a `guard` statement.
2. When a property declaration is placed after a comment ending with “var”.
Since such new lines are grouped with their trailing marker, and start
with an escaping backslash, they would previously be ignored (since they
were incorrectly treated as string interpolation or escaped markers).
This patch makes Splash no longer highlight variables with the same
name as a keyword when used in optional binding, for example:
```
if let override = makeOverride() { ... }
```
This change makes Splash correctly handle connected multiline
comment delimiters; `/*` and `*/`, when those are either connected,
or directly placed next to punctuation.
Raw string interpolation has proven to be a bit trickier to
implement, since we don’t want to treat `#` as a delimiter
(since it’s used in so many other ways in Swift, for example
for `#if`, `#available`, etc.).
This patch contains a “quick fix” for supporting interpolated
raw strings that contain a single expression per interpolation.
A proper fix should be developed as soon as possible, but this
unblocks using Splash to highlight most raw string interpolated
code samples, for now.
This change makes it possible to inject a custom CSS class
prefix into `MarkdownDecorator`, which will in turn be
passed to its underlying HTML-based syntax highlighter.
This patch fixes syntax highlighting for any comments that begin with
a delimiter, which would previously prevent the comment’s leading token
from being parsed correctly. The fix is to prevent slashes to be merged
with any other delimiter, except for other slashes and asterisks.
This patch fixes highlighting of any type declarations that follow
a comment which was ended with a punctuation character. The fix is
to only look at previous tokens on the same line when determining
whether a given token is a keyword.
This change adds a test that verifies that indented function calls
are correctly highlighted. This was fixed as part of the previous
change to make static methods highlight correctly, but this test
will ensure we don’t see any regressions for this particular use case.
This patch makes Splash correctly highlight strings in which a value
is interpolated next to a delimiter character. The fix is to enable
each `Grammar` implementation to decide whether two tokens should be
*merged*, which in turn enables `SwiftGrammar` to veto that string
interpolation delimiters should be merged with their predecesor.
- Don’t highlight what *could* be a static method call using
the `dotAccess` style, only highlight tokens that are either
value-less enum cases or static properties.
- The exception to the above rule is within `switch` statements,
in which even call-like tokens are assumed to be enum cases.
- Highlight calls to `.init()` as keywords, for consistency
with other `init` usages.