From 6bcca1763b364b36e74896ffd7008d9071d4e16f Mon Sep 17 00:00:00 2001 From: Alexander Blach Date: Tue, 19 Sep 2023 12:26:55 +0200 Subject: [PATCH 1/3] Recognize reserved words in variable and constant declaration If there was a variable declaration that was not followed by a type annotation and the next lined started a function declaration, the function declaration was not recognized. Fixed by including reserved-word-pop before matching the variable identifier. --- Swift.sublime-syntax | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Swift.sublime-syntax b/Swift.sublime-syntax index 2dedce8..a1dcaf7 100644 --- a/Swift.sublime-syntax +++ b/Swift.sublime-syntax @@ -1204,6 +1204,7 @@ contexts: - match: ':' scope: punctuation.separator.annotation.type-annotation.swift pop: 1 + - include: reserved-word-pop - match: '{{identifier}}' scope: meta.entity.name.let.swift variable.other.constant.swift # For value-binding @@ -1231,6 +1232,7 @@ contexts: - match: ':' scope: punctuation.separator.annotation.type-annotation.swift pop: 1 + - include: reserved-word-pop - match: '{{identifier}}' scope: meta.entity.name.var.swift variable.other.swift # For value-binding From 1b0edcb1b2590c900f8a054d53f71ebaf947c3b5 Mon Sep 17 00:00:00 2001 From: Alexander Blach Date: Tue, 19 Sep 2023 13:13:19 +0200 Subject: [PATCH 2/3] Change variable and constant declaration to match non-reserved identifiers --- Swift.sublime-syntax | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Swift.sublime-syntax b/Swift.sublime-syntax index a1dcaf7..670c297 100644 --- a/Swift.sublime-syntax +++ b/Swift.sublime-syntax @@ -1203,9 +1203,8 @@ contexts: pop: 1 - match: ':' scope: punctuation.separator.annotation.type-annotation.swift - pop: 1 - - include: reserved-word-pop - - match: '{{identifier}}' + pop: 1 + - match: '{{non_reserved_identifier}}' scope: meta.entity.name.let.swift variable.other.constant.swift # For value-binding - match: \(\s*({{identifier}}) @@ -1219,6 +1218,7 @@ contexts: - match: ({{identifier}}) captures: 1: meta.entity.name.let.swift variable.other.constant.swift + - include: reserved-word-pop - include: else-pop declaration-variable: @@ -1231,9 +1231,8 @@ contexts: pop: 1 - match: ':' scope: punctuation.separator.annotation.type-annotation.swift - pop: 1 - - include: reserved-word-pop - - match: '{{identifier}}' + pop: 1 + - match: '{{non_reserved_identifier}}' scope: meta.entity.name.var.swift variable.other.swift # For value-binding - match: \(\s*({{identifier}}) @@ -1247,6 +1246,7 @@ contexts: - match: ({{identifier}}) captures: 1: meta.entity.name.let.swift variable.other.constant.swift + - include: reserved-word-pop - include: else-pop declaration-typealias: From ae62b62d255ac2f37f184b8b02e1bb47d4d1089b Mon Sep 17 00:00:00 2001 From: Alexander Blach Date: Tue, 19 Sep 2023 13:18:47 +0200 Subject: [PATCH 3/3] Remove unnecessary whitespace --- Swift.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Swift.sublime-syntax b/Swift.sublime-syntax index 670c297..4d03189 100644 --- a/Swift.sublime-syntax +++ b/Swift.sublime-syntax @@ -1203,7 +1203,7 @@ contexts: pop: 1 - match: ':' scope: punctuation.separator.annotation.type-annotation.swift - pop: 1 + pop: 1 - match: '{{non_reserved_identifier}}' scope: meta.entity.name.let.swift variable.other.constant.swift # For value-binding @@ -1231,7 +1231,7 @@ contexts: pop: 1 - match: ':' scope: punctuation.separator.annotation.type-annotation.swift - pop: 1 + pop: 1 - match: '{{non_reserved_identifier}}' scope: meta.entity.name.var.swift variable.other.swift # For value-binding