Coeur: There is a Travis test failing on:

                class Time
                {
                    var minutes: Double
                    {
                        get
                        {
                            return (seconds / 60)
                        }
                        set
                        {
                            self.seconds = (newValue * 60)
                        }
                    }
                }

The reason may be that `'\n'` isn't the correct way to identify a newline token?

Coeur: If a newline can't be tokenized, an alternative may be to leave the state on `:` and `=`.
diff --git a/lizard_languages/swift.py b/lizard_languages/swift.py
index 8aea377..a7f4795 100644
--- a/lizard_languages/swift.py
+++ b/lizard_languages/swift.py
@@ -30,17 +30,24 @@ class SwiftStates(CodeStateMachine):  # pylint: disable=R0903
     def _state_global(self, token):
         if token == 'func':
             self._state = self._function_name
-        if token == 'init':
+        if token in ('init', 'subscript'):
             self._function_name(token)
-        if token in ('get', 'set', 'deinit'):
+        if token in ('get', 'set', 'willSet', 'didSet', 'deinit'):
             self.context.start_new_function(token)
             self._state = self._expect_function_impl
         if token == 'protocol':
             self._state = self._protocol
+        if token in ('let', 'var', 'case', ','):
+            self._state = self._expect_declaration_name
+
+    def _expect_declaration_name(self, token):
+        if token != '`':
+            self._state = self._state_global
 
     def _function_name(self, token):
-        self.context.start_new_function(token)
-        self._state = self._expect_function_dec
+        if token != '`':
+            self.context.start_new_function(token)
+            self._state = self._expect_function_dec
 
     def _expect_function_dec(self, token):
         if token == '(':

Incorrect behavior when a variable named `get` is used in Swift
I have the following Swift file, but lizard (master branch at b631dfd3561366539633a7279f755e237541f3bf) believes it is one single giant getter:

```
//  AFNetworkingWrapper.swift
//  Created by Antoine Cœur on 20/10/2016.
//  Copyright © 2016 EF Education. All rights reserved.

/*...*/

/// HTTP method definitions.
///
/// See https://tools.ietf.org/html/rfc7231#section-4.3
public enum HTTPMethod: String {
    case options = "OPTIONS"
    case get     = "GET"
    case head    = "HEAD"
    case post    = "POST"
    case put     = "PUT"
    case patch   = "PATCH"
    case delete  = "DELETE"
    case trace   = "TRACE"
    case connect = "CONNECT"
}

extension AFHTTPSessionManager {
    
    convenience init(baseURL url: URL?, requestEncoding: ParameterSerializer?, responseEncoding: ParameterSerializer? = nil) {
        self.init(baseURL: url)
        /*...*/
    }
    
    func foo(_ requestHeaders: [String:String]) {
        /*...*/
    }
    
    func bar(_ requestHeaders: [String:String]) {
        /*...*/
    }
    /*...*/
}
```

lizard output:
```
$ python lizard.py AFNetworkingWrapper.swift 
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
     106     29    714      0     118 get@29-146@/coeur/AFNetworkingWrapper.swift
1 file analyzed.
==============================================================
NLOC    Avg.NLOC  AvgCCN  Avg.token  function_cnt    file
--------------------------------------------------------------
    115     106.0    29.0      714.0         1     /coeur/AFNetworkingWrapper.swift

=========================================================================================
!!!! Warnings (cyclomatic_complexity > 15 or length > 1000 or parameter_count > 100) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
     106     29    714      0     118 get@29-146@/coeur/AFNetworkingWrapper.swift
==========================================================================================
Total nloc   Avg.NLOC  AvgCCN  Avg.token   Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
       115     106.0    29.0      714.0        1            1      1.00    1.00
```
diff --git a/test/test_languages/testSwift.py b/test/test_languages/testSwift.py
index 06bed37..0fec26e 100644
--- a/test/test_languages/testSwift.py
+++ b/test/test_languages/testSwift.py
@@ -93,18 +93,39 @@ class Test_parser_for_Swift(unittest.TestCase):
                 ''')
         self.assertEqual(0, len(result))
 
+#https://docs.swift.org/swift-book/LanguageGuide/Initialization.html
     def test_init(self):
         result = get_swift_function_list('''
             init() {}
                 ''')
         self.assertEqual("init", result[0].name)
 
+#https://docs.swift.org/swift-book/LanguageGuide/Deinitialization.html
     def test_deinit(self):
         result = get_swift_function_list('''
             deinit {}
                 ''')
         self.assertEqual("deinit", result[0].name)
 
+#https://docs.swift.org/swift-book/LanguageGuide/Subscripts.html
+    def test_subscript(self):
+        result = get_swift_function_list('''
+            override subscript(index: Int) -> Int {}
+                ''')
+        self.assertEqual("subscript", result[0].name)
+
+#https://stackoverflow.com/a/30593673
+    def test_labeled_subscript(self):
+        result = get_swift_function_list('''
+            extension Collection {
+                /// Returns the element at the specified index iff it is within bounds, otherwise nil.
+                subscript (safe index: Index) -> Iterator.Element? {
+                    return indices.contains(index) ? self[index] : nil
+                }
+            }
+                ''')
+        self.assertEqual("subscript", result[0].name)
+
     def test_getter_setter(self):
         result = get_swift_function_list('''
             class Time
@@ -125,6 +146,70 @@ class Test_parser_for_Swift(unittest.TestCase):
         self.assertEqual("get", result[0].name)
         self.assertEqual("set", result[1].name)
 
+#https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID259
+    def test_explicit_getter_setter(self):
+        result = get_swift_function_list('''
+            var center: Point {
+                get {
+                    let centerX = origin.x + (size.width / 2)
+                    let centerY = origin.y + (size.height / 2)
+                    return Point(x: centerX, y: centerY)
+                }
+                set(newCenter) {
+                    origin.x = newCenter.x - (size.width / 2)
+                    origin.y = newCenter.y - (size.height / 2)
+                }
+            }
+                ''')
+        self.assertEqual("get", result[0].name)
+        self.assertEqual("set", result[1].name)
+
+    def test_willset_didset(self):
+        result = get_swift_function_list('''
+            var cue = -1 {
+                willSet {
+                    if newValue != cue {
+                        tableView.reloadData()
+                    }
+                }
+                didSet {
+                    tableView.scrollToRow(at: IndexPath(row: cue, section: 0), at: .bottom, animated: true)
+                }
+            }
+                ''')
+        self.assertEqual("willSet", result[0].name)
+        self.assertEqual("didSet", result[1].name)
+
+#https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID262
+    def test_explicit_willset_didset(self):
+        result = get_swift_function_list('''
+            class StepCounter {
+                var totalSteps: Int = 0 {
+                    willSet(newTotalSteps) {
+                        print("About to set totalSteps to \(newTotalSteps)")
+                    }
+                    didSet {
+                        if totalSteps > oldValue  {
+                            print("Added \(totalSteps - oldValue) steps")
+                        }
+                    }
+                }
+            }
+                ''')
+        self.assertEqual("willSet", result[0].name)
+        self.assertEqual("didSet", result[1].name)
+
+    def test_keyword_declarations(self):
+        result = get_swift_function_list('''
+            enum Func {
+                static var `init`: Bool?, willSet: Bool?
+                static let `deinit` = 0, didSet = 0
+                case `func`; case get, set
+                func `default`() {}
+            }
+                ''')
+        self.assertEqual("default", result[0].name)
+
     def test_generic_function(self):
         result = get_swift_function_list('''
             func f<T>() {}

pip install -e .[sidecar]
parse_log_pytest
requirements.txt
pytest flake8 isort mypy
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
flake8==7.2.0
iniconfig==2.1.0
isort==6.0.1
-e git+https://github.com/terryyin/lizard.git@b631dfd3561366539633a7279f755e237541f3bf#egg=lizard
mccabe==0.7.0
mypy==1.15.0
mypy-extensions==1.0.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
tomli==2.2.1
typing_extensions==4.13.0

name: lizard
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - iniconfig==2.1.0
      - isort==6.0.1
      - mccabe==0.7.0
      - mypy==1.15.0
      - mypy-extensions==1.0.0
      - packaging==24.2
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - tomli==2.2.1
      - typing-extensions==4.13.0
prefix: /opt/conda/envs/lizard

test/test_languages/testSwift.py::Test_parser_for_Swift::test_explicit_willset_didset test/test_languages/testSwift.py::Test_parser_for_Swift::test_keyword_declarations test/test_languages/testSwift.py::Test_parser_for_Swift::test_labeled_subscript test/test_languages/testSwift.py::Test_parser_for_Swift::test_subscript test/test_languages/testSwift.py::Test_parser_for_Swift::test_willset_didset
test/test_languages/testSwift.py::Test_parser_for_Swift::test_coalescing_operator test/test_languages/testSwift.py::Test_parser_for_Swift::test_deinit test/test_languages/testSwift.py::Test_parser_for_Swift::test_empty test/test_languages/testSwift.py::Test_parser_for_Swift::test_explicit_getter_setter test/test_languages/testSwift.py::Test_parser_for_Swift::test_generic_function test/test_languages/testSwift.py::Test_parser_for_Swift::test_getter_setter test/test_languages/testSwift.py::Test_parser_for_Swift::test_init test/test_languages/testSwift.py::Test_parser_for_Swift::test_interface test/test_languages/testSwift.py::Test_parser_for_Swift::test_interface_followed_by_a_class test/test_languages/testSwift.py::Test_parser_for_Swift::test_interface_with_var test/test_languages/testSwift.py::Test_parser_for_Swift::test_no_function test/test_languages/testSwift.py::Test_parser_for_Swift::test_one_function test/test_languages/testSwift.py::Test_parser_for_Swift::test_one_function_with_complexity test/test_languages/testSwift.py::Test_parser_for_Swift::test_one_function_with_return_value test/test_languages/testSwift.py::Test_parser_for_Swift::test_one_with_parameter test/test_languages/testSwift.py::Test_parser_for_Swift::test_optional
lizard_languages/swift.py
lizard_languages/swift.py