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.
* 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 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.
This patch makes MarkdownDecorator not include line breaks before and
after the `<pre>` and `<code>` tags that it adds to code blocks, since
this will be rendered as whitespace in the browser.
This patch fixes syntax highlighting for types and functions which names
begin with an underscore. Previously these entities would be treated as
plain text, but now they’re highlighted correctly as either types or
function calls.
This patch fixes syntax highlighting for when shorthand closure
arguments ($0, $1…) are interpolated into a string literal. The
fix is to no longer treat “$” as a delimiter, which should help
solve similar issues that might be encountered in the future as
well.
This patch makes Splash correctly highlight closure argument
shorthands (`$0`, `$1`, etc.), while also making the logic for
detecting a function call a bit simpler.