91 Commits

Author SHA1 Message Date
John Sundell
9fbdb92edb Add special case for XCTAssert family of functions
Normally, we don’t want Splash to contain too many special cases for
individual symbol names — but the `XCTAssert` family of functions are
so common that it warrants it. The problem is that Splash would currently
highlight those functions as types, since they are capitalized, which
has now been changed to function calls instead.
2019-03-08 19:14:18 +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
45740696d0 Correctly highlight Bools passed as unnamed function arguments
This patch fixes highlighting of `Bool` values passed as arguments that
don’t have an external parameter label.
2019-03-08 18:32: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
87437d7425 Don’t treat .init() as an enum
This change adds a special condition not to treat `.init()` as an enum
(or any other kind of dot access), just like we previously had for `self`.
2019-03-08 17:26:10 +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
John Sundell
0d1c781af1
Merge pull request #20 from MaciejGad/background_color
Add support for different background colors
2018-10-09 23:30:25 +02:00
John Sundell
183224503f
Theme: Nitpicky code style fix 2018-10-09 23:22:50 +02:00
John Sundell
59d45d39e3
Theme: Documentation fix for backgroundColor 2018-10-09 23:22:18 +02:00
John Sundell
cb3f05d3e2
Theme+Defaults: Nitpicky code style fixes 2018-10-09 23:21:35 +02:00
John Sundell
4c6f71c0de Support custom token types
This change makes it possible to implement custom token types, which is
really useful when building specialized grammars that use non-standard
token types.
2018-09-28 14:02:42 +02:00
John Sundell
98bfad4ea4 SwiftGrammar: Enable delimiters and syntax rules to be mutated
This enables easy creation of custom grammars that are based on the Swift one.
2018-09-28 13:52:51 +02:00
Maciej Gad
1c6998d5f5 add support for different background colors 2018-09-23 14:06:09 +02:00
John Sundell
b2c849e93e
SwiftGrammar: Add missing keyword separator
Lost in merge conflict resolution
2018-09-05 23:36:12 +02:00
John Sundell
2a049c2031
Merge branch 'master' into patch-1 2018-09-05 23:32:15 +02:00
Marco Capano
338e3b6ef9
Adding "while" keyword 2018-09-05 18:40:27 +02:00
Marco Capano
32764b0720
Add support for continue, fallthrough and repeat
This PR introduces new keywords in SwiftGrammar
2018-09-04 22:26:29 +02:00
Nikhil Muskur
b742c3cfa3
added "inout" as keyword 2018-09-04 16:30:42 +05:30
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
dc83f92228 Highlight ‘self’ as keyword when used to refer to a type
This patch fixes syntax highlighting when using `.self` to refer to a type.
2018-08-27 18:44:07 +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
a86694802e Highlight enums used as subscripting keys
This patch fixes highlighting when an enum is used as a dictionary key, like this:

```
let value = dictionary[.key]
```
2018-08-27 18:14:17 +02:00
John Sundell
c73767a0bc HTMLOutputFormat: Escape < and > characters
This patch makes `HTMLOutputFormat` correctly escape all < and > characters
that occur in source code. Otherwise, a web browser rendering the resulting
HTML will interpret those characters as tags.
2018-08-27 00:14:48 +02:00
John Sundell
be35cef1ea Correctly handle static methods called on a generic type
This patch fixes syntax highlighting for the following scenario:

```
Type<GenericType>.call()
```

Highlighting generic types is especially tricky, since we want them to
be highlighted when appearing at the call site, like above - but we don’t
want to highlight them when they are being declared. Hopefully with this
fix all/most edge cases are covered.
2018-08-27 00:10:08 +02:00
John Sundell
aea685e8b4 Color: Exclude internal extension on Linux 2018-08-26 22:57:02 +02:00
John Sundell
a68e461eb4 Replace custom Color struct with typealiases
Now that the decision not to support colors on Linux
has been made, we can replace the custom `Color` struct
with simple typealiases for `NSColor` and `UIColor`.

The same can’t be done for font, since we want to enable
loading of a font from a path, for SPM packages.
2018-08-26 22:49:39 +02:00
John Sundell
0155f41ceb Fix Sundell’s Colors theme colors
Seem to have been mixed up when moved to the new Defaults extension.
2018-08-26 14:15:47 +02:00
John Sundell
530cdad12f Disable Theme+Defaults on Linux 2018-08-26 00:59:22 +02:00
John Sundell
df73f6d066 Disable Color + Theme on Linux
They don’t really make sense, since there’s no way
to use them on Linux, without linking to some form
of Linux rendering framework.
2018-08-26 00:58:23 +02:00
John Sundell
1e532a6c4c Theme: Streamline cross-platform implementation
Now that we’re making Splash support iOS as well as
Mac + Linux, we need to create some nice abstractions
to make sure that we can share as much code as possible
between all platforms.

- Define Font.Loaded and Color.Renderable as platform-
specific typealiases for system fonts and colors.
- Don’t compile in non-Linux compatible code when building
for Linux.
- Make Font and Color handle all conversion themselves, so
that AttributedStringOutputFormat can be kept more clean.
2018-08-26 00:54:44 +02:00
Mihael Cholakov
dfd146dadb Removed whitespace 2018-08-25 23:37:24 +03:00
Mihael Cholakov
3952b91e3f Removed whitespace 2018-08-25 23:36:19 +03:00
Mihael Cholakov
128f0929d4 Moved Sundell theme to Defaults 2018-08-25 23:24:10 +03:00
Mihael Cholakov
d6a327c831 Adds additional premade themes 2018-08-25 23:22:54 +03:00
Mihael Cholakov
305d09e8ac Whitespace removal 2018-08-25 22:11:20 +03:00
Mihael Cholakov
def9e10f1a Shortened loadFont 2018-08-25 22:06:05 +03:00
Mihael Cholakov
5702cea843 Implements iOS support for AttributedStringOutputFormat 2018-08-25 21:49:30 +03:00
John Sundell
896a56b682 Correctly highlight properties after function calls
This patch fixes highlighting in the following scenarios:

```
call().property
call(argument).property
```
2018-08-25 12:56:34 +02:00
John Sundell
8645db8de0 Initial commit 2018-08-24 18:42:07 +02:00