Skip to content

Instantly share code, notes, and snippets.

@dbarden
Forked from anonymous/sourcekitten
Last active January 25, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbarden/3727c106404b2015db765b86a8b5263a to your computer and use it in GitHub Desktop.
Save dbarden/3727c106404b2015db765b86a8b5263a to your computer and use it in GitHub Desktop.
protocol TestDelegate: class {
}
protocol TestProtocol {
weak var delegate: TestDelegate? { get }
}
class Test {
weak var delegate: TestDelegate
}
> swiftlint lint
Linting Swift files in current working directory
Linting 'atest.swift' (1/1)
/Users/barden/projects/DTI/swiftlint-test/atest.swift:10:8: warning: Weak Delegate Violation: Delegates should be weak to avoid reference cycles. (weak_delegate)
Done linting! Found 1 violation, 0 serious in 1 file.
{
  "key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
  "key.length" : 154,
  "key.offset" : 0,
  "key.substructure" : [
    {
      "key.accessibility" : "source.lang.swift.accessibility.internal",
      "key.bodylength" : 2,
      "key.bodyoffset" : 30,
      "key.elements" : [
        {
          "key.kind" : "source.lang.swift.structure.elem.typeref",
          "key.length" : 5,
          "key.offset" : 23
        }
      ],
      "key.inheritedtypes" : [
        {
          "key.name" : "class"
        }
      ],
      "key.kind" : "source.lang.swift.decl.protocol",
      "key.length" : 33,
      "key.name" : "TestDelegate",
      "key.namelength" : 12,
      "key.nameoffset" : 9,
      "key.offset" : 0,
      "key.runtime_name" : "_TtP8__main__12TestDelegate_"
    },
    {
      "key.accessibility" : "source.lang.swift.accessibility.internal",
      "key.bodylength" : 44,
      "key.bodyoffset" : 58,
      "key.kind" : "source.lang.swift.decl.protocol",
      "key.length" : 68,
      "key.name" : "TestProtocol",
      "key.namelength" : 12,
      "key.nameoffset" : 44,
      "key.offset" : 35,
      "key.runtime_name" : "_TtP8__main__12TestProtocol_",
      "key.substructure" : [
        {
          "key.accessibility" : "source.lang.swift.accessibility.internal",
          "key.attributes" : [
            {
              "key.attribute" : "source.decl.attribute.weak",
              "key.length" : 4,
              "key.offset" : 61
            }
          ],
          "key.bodylength" : 5,
          "key.bodyoffset" : 95,
          "key.kind" : "source.lang.swift.decl.var.instance",
          "key.length" : 35,
          "key.name" : "delegate",
          "key.namelength" : 8,
          "key.nameoffset" : 70,
          "key.offset" : 66,
          "key.typename" : "TestDelegate?"
        }
      ]
    },
    {
      "key.accessibility" : "source.lang.swift.accessibility.internal",
      "key.bodylength" : 35,
      "key.bodyoffset" : 117,
      "key.kind" : "source.lang.swift.decl.class",
      "key.length" : 48,
      "key.name" : "Test",
      "key.namelength" : 4,
      "key.nameoffset" : 111,
      "key.offset" : 105,
      "key.runtime_name" : "_TtC8__main__4Test",
      "key.substructure" : [
        {
          "key.accessibility" : "source.lang.swift.accessibility.internal",
          "key.attributes" : [
            {
              "key.attribute" : "source.decl.attribute.weak",
              "key.length" : 4,
              "key.offset" : 120
            }
          ],
          "key.kind" : "source.lang.swift.decl.var.instance",
          "key.length" : 26,
          "key.name" : "delegate",
          "key.namelength" : 8,
          "key.nameoffset" : 129,
          "key.offset" : 125,
          "key.setter_accessibility" : "source.lang.swift.accessibility.internal",
          "key.typename" : "TestDelegate"
        }
      ]
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment