32 Commits

Author SHA1 Message Date
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
3b546b7dd0
Correctly highlight enum cases called “some” (#100)
Was previously highlighted as a keyword.
2020-02-11 16:14:53 +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
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
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
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
John Sundell
5280f4abc7
Add support for the ‘convenience’ keyword (#76)
This patch makes Splash correctly highlight the ‘convenience’ keyword.
2019-07-21 13:44:11 +02:00
John Sundell
c582abf0a4
Add test verifying property wrapper compatibility (#73)
Splash was already capable of highlighting property wrappers, since
anything following an `@` symbol is treated as a keyword, but this
change adds a test that makes sure that it’ll keep working.
2019-06-18 13:37:57 +02:00
John Sundell
d978081933
Add support for Swift 5.1’s opaque return types (#71)
This change adds support for the Swift 5.1 `some` keyword, which is used
to declare opaque return types.
2019-06-09 12:33:00 +02:00
John Sundell
ec13df124a
Correctly highlight generic return types (#69)
This change makes Splash correctly highlight generics that are returned
from a function.
2019-05-13 11:25:16 +02:00
John Sundell
2b9e65e0d8
Fix highlighting for keywords used as generic function parameter labels (#65)
This patch fixes highlighting for parameter labels that also match a
keyword, when used within a generic function declaration.
2019-03-31 22:52:09 +02:00
John Sundell
2cdc99ce60
Correctly highlight generic parameters (#59)
This patch makes Splash highlight generics that appear as part of a
generic function’s parameter list in a correct way.
2019-03-16 12:41:53 +01:00
Marco Capano
60c06cc385 Adding support for rethrows keyword (#56) 2019-03-12 23:12:54 +01:00
Marco Capano
9a7fdefab4 Adding nonmutating support (#50) 2019-03-11 21:31:32 +01:00
John Sundell
8bc46cbeb0
Add SwiftLint (#49)
This change adds SwiftLint to the project. For now, the rules are tweaked
to match the current state of the code base — but will over time be changed
back to their defaults in several cases.

Some smaller changes (mostly related to code style) were applied to the
project to remove all warnings.
2019-03-11 14:52:46 +01:00
Marco Capano
892d6ae39c adding support for "dynamic" keyword (#48)
* adding support for "dynamic" keyword

* adding test for linux

* Fixing alignment issue
2019-03-11 13:57:33 +01:00
John Sundell
59161f2724 Support function argument pre-processors
This change adds support for three pre-processors that can appear in
function delcarations: `#file`, `#line` and `#function`. They’re not
highlighted as pre-processors, but rather as keywords, to match the
way Xcode treats them.
2019-03-09 13:12:23 +01:00
John Sundell
45ca85e299 Support the deinit keyword
This patch makes Splash correctly highlight the `deinit` keyword.
2019-03-08 21:57:56 +01:00
John Sundell
c85d8d9d4d Support highlighting of setters with an explicit access level
This change makes Splash correctly highlight property setters that have
an explicit access level defined — such as `private(set) var`.
2019-03-08 21:50:07 +01:00
John Sundell
f9ad32a0a6 Correctly highlight associated types
This patch makes Splash correctly highlight associated types within
protocol declarations. Like other declarations, typed declared using
the `associatedtype` keyword should not be highlighted.
2019-03-08 18:43:12 +01:00
John Sundell
7f2421cd99 Correctly highlight types conforming to multiple protocols
Previously, the last protocol would be treated as a function call (Splash
thought it was a call with trailing closure syntax, rather than the opening
of a type definition). This patch fixes that by verifying that the code
checking for constraints inside a generic type definition is in fact looking
at a generic, rather than something else.
2019-03-08 18:20:36 +01:00
John Sundell
ddd2bf9020 Don’t treat keywords used as function names as keywords
Swift enables the use of keywords as function names, and we want those
to be treated as plain text (like other function names) rather than as
keywords. Some keywords require escaping using back-ticks, and this
patch accounts for both of those variations.
2019-03-08 17:55:44 +01:00
John Sundell
5d075f7168 Add support for indirect enums
This patch makes Splash correctly highlight `indirect` enums. The keyword
was missing from the grammar definition.
2019-03-06 10:40:03 +01:00
Luffy
7a2f284e5d missed a component in the test declaration 2018-09-05 07:20:35 +05:30
Nikhil Muskur
70f49996fc
added the test case in allTests array 2018-09-05 07:06:01 +05:30
Nikhil Muskur
ea71fd7191
test added for the "inout" keyword 2018-09-05 06:58:51 +05:30
John Sundell
187effae29 DeclarationTests: Nitpicky code style fixes 2018-08-28 13:23:04 +02:00
wangchi
c1465b0a65 added “defer” as a keyword 2018-08-28 16:06:43 +08:00
John Sundell
ac9b512013 Don’t highlight keywords when used as a parameter label
Most keywords can be used as parameter labels, such as “for” or “in”, but
they shouldn’t be highlighted in that context.
2018-08-27 19:01:57 +02:00
John Sundell
1faa928214 Correctly highlight subscript declarations
This patch fixes syntax highlighting when declaring
a subscript:

```
struct MyStruct {
	subscript(key: Key) -> Value? {
		…
	}
}
```
2018-08-27 18:32:22 +02:00
John Sundell
8645db8de0 Initial commit 2018-08-24 18:42:07 +02:00