Commit Graph

183 Commits

Author SHA1 Message Date
Shadowfacts c43e8a9a73 Fix crash on Linux 2024-11-30 23:25:16 -05:00
John Sundell 2e3f17c2d0
Correctly highlight the 'any' keyword when used within other type references (#130)
Treat it the same way as the `some` keyword.
2022-06-08 22:13:57 +02:00
John Sundell e92d451f82
Add support for the 'any' keyword (#129)
The newly added `any` keyword is now correctly highlighted.
2022-06-08 21:50:21 +02:00
Marcin Chojnacki c30a8277f7
Add `ImageIO` import allowing to build the tool using recent toolchain (#127)
Should resolve:
```
error: cannot find 'CGImageDestinationCreateWithURL' in scope
```
build errors.
2022-06-08 21:43:37 +02:00
John Sundell 7f4df436eb
Add support for Swift 5.5's concurrency features (#126)
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.
2021-06-14 13:03:57 +02:00
John Sundell 7f87f191b6
Update the project to Swift 5.4 (#125)
* 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
2021-06-14 10:33:59 +02:00
Flávio Caetano 4df8c3e76a
Add executables definition to Package.swift (#124) 2021-06-14 10:10:04 +02:00
Tyler 1005644d86
Remove reference to shuttered https://splash.rambo.codes (#122)
https://splash.rambo.codes seems to be gone; might as well remove it from the readme.
2020-12-17 17:16:22 +01:00
Peter Yaacoub 07c9cc05d1
Fix a small typo in README.md (#123) 2020-12-17 17:16:00 +01:00
John Sundell 43bd50bd04
A few minor syntax highlighting fixes (#121)
* 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
2020-11-14 19:20:35 +01:00
John Sundell 81de038955
Improve highlighting of comments when placed next to symbols (#120)
Especially for multi-line comments placed next to generic type lists.
2020-11-12 23:48:02 +01:00
John Sundell 8d83deb708
Never highlight keywords like “init” and “didSet” as function calls (#119) 2020-10-12 23:44:13 +02:00
John Sundell ee516ebf19
Fix highlighting for method calls named the same as a keyword (#118)
When those calls are made using trailing closure syntax.
2020-10-12 23:08:25 +02:00
John Sundell 8818825215
Fix highlighting for static properties/enum cases on generic types (#117)
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.
2020-10-12 22:27:00 +02:00
Marina f25dd8c9f1
Fix build product path to work on case sensitive and insensitive file systems (#116) 2020-08-31 12:41:34 +02:00
John Sundell d951a0906c
Improve syntax highlighting for property wrappers (#115)
This patch makes property wrappers highlight correctly when annotated
with explicit types.
2020-08-03 12:31:53 +02:00
John Sundell bda4fe71b6
Correctly highlight projected property wrapper values (#114)
Such as when passing a property wrapper using `self.$value`.
2020-06-28 13:41:09 +02:00
John Sundell 73a4cf178b
Correctly highlight comments that are preceded by a comma (#113)
Don’t merge “,” and “/“ pairs when handling delimiters.
2020-06-28 13:33:09 +02:00
John Sundell b2b8be4efa
Support nested property wrappers (#112)
This change makes Splash correctly highlight property wrappers that are
using nested types, for example `@My.PropertyWrapper`.
2020-06-11 21:23:06 +02:00
John Sundell ca9a1b7bff
Correctly highlight subclasses inheriting from a generic superclass (#108)
This change fixes syntax highlighting in situations when a subclass is
inheriting from a superclass that’s generic.
2020-05-25 01:18:22 +02:00
John Sundell 3e400c0874
Don’t highlight generic parameter types used in initializer declarations (#107)
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.
2020-05-25 00:54:25 +02:00
John Sundell 9798c4fd6b
Bump Swift version to 5.2 (#106)
* Bump Swift version to 5.2
* README: Update “Contributions and support” section
2020-05-25 00:50:44 +02:00
John Sundell ec37e1042c
Fix highlighting for comments that appear next to curly brackets (#105)
This change makes Splash correctly highlight comments that are placed
right next to either an opening or closing curly bracket.
2020-05-22 01:24:29 +02:00
John Sundell b6c489c980
Correctly highlight the “try” keyword when used within a function call (#104)
This change makes Splash highlight the `try` keyword when it appears
within a function’s argument list.
2020-05-22 01:14:37 +02:00
John Sundell 03ea9bdcbb
Don’t treat accessing properties within switch statements as calls (#103)
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.
2020-04-16 19:52:26 +02:00
John Sundell 8e96992997
Fix syntax highlighting for leading function calls within closures (#102)
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.
2020-04-16 19:29:01 +02:00
Marco Capano 26d4bbe7ca
Add option to specify a grammar for MarkdownDecorator (#101) 2020-04-16 19:28:37 +02:00
John Sundell 3b546b7dd0
Correctly highlight enum cases called “some” (#100)
Was previously highlighted as a keyword.
2020-02-11 16:14:53 +01:00
Tobias Due Munk 2d55b33529
Fix Swift 5.2 compiler crash (#99) 2020-02-07 15:09:18 +01:00
Artur Rymarz b501e834a8
Added Comment component test with a number (#90) 2020-01-29 11:36:20 +01:00
John Sundell eca0850b52
Fix regressions after keywords-in-optional binding change (#98)
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”.
2020-01-29 11:30:16 +01:00
John Sundell cac40caf68
Handle string literals that only have a new line (#97)
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).
2020-01-29 11:09:14 +01:00
John Sundell 812811ff69
Don’t highlight keyword names used in optional binding (#96)
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() { ... }
```
2020-01-29 11:04:14 +01:00
John Sundell bb8655e6d2
Support the ‘unowned’ keyword (#95)
This change makes Splash correctly highlight the `unowned` keyword
when used within closure capture lists.
2020-01-29 10:34:17 +01:00
Tobias Due Munk b7e9141e1b
Fix comments with punctuation just prior or after (#93)
This change makes Splash correctly handle connected multiline
comment delimiters; `/*` and `*/`, when those are either connected,
or directly placed next to punctuation.
2020-01-29 10:19:38 +01:00
John Sundell 97541c8835
Don’t highlight keywords used as parameters on a new line (#94)
This patch fixes a bug that would cause Splash to incorrectly highlight
parameter labels defined on a new line when those would match a keyword.
2020-01-29 00:37:08 +01:00
John Sundell 4da9bbd0bc
Add support for the “prefix” keyword (#91)
This patch makes Splash correctly highlight the `prefix` keyword, which
can only appear before `func`, so a special case was added for it (for now).
2019-12-30 23:39:54 +00:00
John Sundell 3de0275b52
HTML: Fully escape all required entities (#89)
Both when outputting HTML, and when highlighting code blocks within a
Markdown text, Splash now fully escapes all required character entities.
2019-11-23 23:59:16 +00:00
John Sundell 3a6c961de8
README: Remove Marathon installation instructions
Also remove the word "recent" when explaining how Splash is used
on Swift by Sundell, since it's now used for all articles.
2019-11-04 11:38:47 +01:00
John Sundell bc20ac969c
Support highlighting custom compiler directives (#88)
Add support for highlighting the `#warning` and `#error` directives.
2019-11-04 11:31:08 +01:00
John Sundell 66714d6867
Correctly highlight `nil` when passed as a function argument (#87)
This patch fixes syntax highlighting when `nil` is passed to a function
that doesn’t have any parameter labels, such as `handler(nil)`.
2019-11-04 11:26:15 +01:00
John Sundell 19df647082
Correctly highlight generic subscript type lists (#86)
This patch fixes highlighting for types that appear within a list of a
subscript’s generic types.
2019-09-05 14:17:48 +02:00
John Sundell 8ef48daff9
Fix highlighting for strings within interpolation (#85)
This patch fixes syntax highlighting for string literals that appear
within string interpolation. This patch only takes single words into
account.
2019-09-05 14:11:58 +02:00
John Sundell dddf418cea
Quick fix for single-expression raw string interpolation (#84)
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.
2019-09-05 11:59:28 +02:00
John Sundell d1dd1acda0
MarkdownDecorator: Enable CSS class prefix to be injected (#83)
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.
2019-09-05 11:54:56 +02:00
John Sundell 91adf9359f
Fix highlighting for comments starting with a delimiter (#82)
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.
2019-08-07 16:07:22 +02:00
John Sundell e03dac1dd6
Fix highlighting for comments ending with punctuation (#81)
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.
2019-08-07 15:51:16 +02:00
John Sundell 016aaa13f3
Add a test for indented function calls (#79)
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.
2019-08-07 15:45:29 +02:00
John Sundell dcf5951d10
Fix highlighting when delimiters appear next to string interpolation (#80)
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.
2019-08-07 15:45:15 +02:00
John Sundell 367b8408b1
Tweaks to how dot syntax is highlighted (#78)
- 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.
2019-08-06 15:50:23 +02:00