-
Notifications
You must be signed in to change notification settings - Fork 226
/
ObjCDeclarationKind.swift
83 lines (80 loc) · 3.39 KB
/
ObjCDeclarationKind.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#if !os(Linux)
#if SWIFT_PACKAGE
import Clang_C
#endif
/**
Objective-C declaration kinds.
More or less equivalent to `SwiftDeclarationKind`, but with made up values because there's no such
thing as SourceKit for Objective-C.
*/
public enum ObjCDeclarationKind: String {
/// `category`.
case category = "sourcekitten.source.lang.objc.decl.category"
/// `class`.
case `class` = "sourcekitten.source.lang.objc.decl.class"
/// `constant`.
case constant = "sourcekitten.source.lang.objc.decl.constant"
/// `enum`.
case `enum` = "sourcekitten.source.lang.objc.decl.enum"
/// `enumcase`.
case enumcase = "sourcekitten.source.lang.objc.decl.enumcase"
/// `initializer`.
case initializer = "sourcekitten.source.lang.objc.decl.initializer"
/// `method.class`.
case methodClass = "sourcekitten.source.lang.objc.decl.method.class"
/// `method.instance`.
case methodInstance = "sourcekitten.source.lang.objc.decl.method.instance"
/// `property`.
case property = "sourcekitten.source.lang.objc.decl.property"
/// `protocol`.
case `protocol` = "sourcekitten.source.lang.objc.decl.protocol"
/// `typedef`.
case typedef = "sourcekitten.source.lang.objc.decl.typedef"
/// `function`.
case function = "sourcekitten.source.lang.objc.decl.function"
/// `mark`.
case mark = "sourcekitten.source.lang.objc.mark"
/// `struct`
case `struct` = "sourcekitten.source.lang.objc.decl.struct"
/// `union`
case `union` = "sourcekitten.source.lang.objc.decl.union"
/// `field`
case field = "sourcekitten.source.lang.objc.decl.field"
/// `ivar`
case ivar = "sourcekitten.source.lang.objc.decl.ivar"
/// `ModuleImport`
case moduleImport = "sourcekitten.source.lang.objc.module.import"
/// `UnexposedDecl`
case unexposedDecl = "sourcekitten.source.lang.objc.decl.unexposed"
/// `static_assert`
case staticAssert = "sourcekitten.source.lang.objc.decl.static_assert"
// swiftlint:disable:next cyclomatic_complexity
public init(_ cursorKind: CXCursorKind) {
switch cursorKind {
case CXCursor_ObjCCategoryDecl: self = .category
case CXCursor_ObjCInterfaceDecl: self = .class
case CXCursor_EnumDecl: self = .enum
case CXCursor_EnumConstantDecl: self = .enumcase
case CXCursor_ObjCClassMethodDecl: self = .methodClass
case CXCursor_ObjCInstanceMethodDecl: self = .methodInstance
case CXCursor_ObjCPropertyDecl: self = .property
case CXCursor_ObjCProtocolDecl: self = .protocol
case CXCursor_TypedefDecl: self = .typedef
case CXCursor_VarDecl: self = .constant
case CXCursor_FunctionDecl: self = .function
case CXCursor_StructDecl: self = .struct
case CXCursor_UnionDecl: self = .union
case CXCursor_FieldDecl: self = .field
case CXCursor_ObjCIvarDecl: self = .ivar
case CXCursor_ModuleImportDecl: self = .moduleImport
case CXCursor_UnexposedDecl: self = .unexposedDecl
case CXCursor_ObjCImplementationDecl: self = .class
case CXCursor_ObjCCategoryImplDecl: self = .category
case CXCursor_ObjCDynamicDecl: self = .unexposedDecl
case CXCursor_ObjCSynthesizeDecl: self = .unexposedDecl
case CXCursor_StaticAssert: self = .staticAssert
default: fatalError("Unsupported CXCursorKind: \(clang_getCursorKindSpelling(cursorKind))")
}
}
}
#endif