forked from yonaskolb/XcodeGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreakpointGenerator.swift
More file actions
126 lines (118 loc) · 4.61 KB
/
BreakpointGenerator.swift
File metadata and controls
126 lines (118 loc) · 4.61 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import Foundation
import ProjectSpec
import XcodeProj
public class BreakpointGenerator {
let project: Project
public init(project: Project) {
self.project = project
}
func generateBreakpointList() throws -> XCBreakpointList? {
let breakpoints = project.breakpoints
guard !breakpoints.isEmpty else {
return nil
}
return XCBreakpointList(type: "4", version: "2.0", breakpoints: try breakpoints.map({ try generateBreakpointProxy($0) }))
}
private func generateBreakpointProxy(_ breakpoint: Breakpoint) throws -> XCBreakpointList.BreakpointProxy {
let breakpointExtensionID: BreakpointExtensionID
var filePath: String?
var line: String?
var column: String?
var scope: String?
var stopOnStyle: String?
var symbol: String?
var module: String?
switch breakpoint.type {
case let .file(path, lineNumber, columnNumber):
breakpointExtensionID = .file
filePath = path
line = String(lineNumber)
column = columnNumber.map(String.init)
case let .exception(exception):
breakpointExtensionID = .exception
scope = exception.scope.rawValue
stopOnStyle = exception.stopOnStyle.rawValue
case .swiftError:
breakpointExtensionID = .swiftError
case .openGLError:
breakpointExtensionID = .openGLError
case let .symbolic(symbolName, moduleName):
breakpointExtensionID = .symbolic
symbol = symbolName
module = moduleName
case .ideConstraintError:
breakpointExtensionID = .ideConstraintError
case .ideTestFailure:
breakpointExtensionID = .ideTestFailure
case .runtimeIssue:
breakpointExtensionID = .runtimeIssue
}
let xcbreakpoint = XCBreakpointList.BreakpointProxy.BreakpointContent(
enabled: breakpoint.enabled,
ignoreCount: String(breakpoint.ignoreCount),
continueAfterRunningActions: breakpoint.continueAfterRunningActions,
filePath: filePath,
startingColumn: column,
endingColumn: column,
startingLine: line,
endingLine: line,
symbol: symbol,
module: module,
scope: scope,
stopOnStyle: stopOnStyle,
condition: breakpoint.condition,
actions: try breakpoint.actions.map { try generateBreakpointActionProxy($0) }
)
return XCBreakpointList.BreakpointProxy(
breakpointExtensionID: breakpointExtensionID,
breakpointContent: xcbreakpoint
)
}
private func generateBreakpointActionProxy(_ breakpointAction: Breakpoint.Action) throws -> XCBreakpointList.BreakpointProxy.BreakpointContent.BreakpointActionProxy {
let actionExtensionID: BreakpointActionExtensionID
var consoleCommand: String?
var message: String?
var conveyanceType: String?
var command: String?
var arguments: String?
var waitUntilDone: Bool?
var script: String?
var soundName: String?
switch breakpointAction {
case let .debuggerCommand(command):
actionExtensionID = .debuggerCommand
consoleCommand = command
case let .log(log):
actionExtensionID = .log
message = log.message
conveyanceType = log.conveyanceType.rawValue
case let .shellCommand(commandPath, commandArguments, waitUntilCommandDone):
actionExtensionID = .shellCommand
command = commandPath
arguments = commandArguments
waitUntilDone = waitUntilCommandDone
case .graphicsTrace:
actionExtensionID = .graphicsTrace
case let .appleScript(appleScript):
actionExtensionID = .appleScript
script = appleScript
case let .sound(sound):
actionExtensionID = .sound
soundName = sound.rawValue
}
let xcaction = XCBreakpointList.BreakpointProxy.BreakpointContent.BreakpointActionProxy.ActionContent(
consoleCommand: consoleCommand,
message: message,
conveyanceType: conveyanceType,
command: command,
arguments: arguments,
waitUntilDone: waitUntilDone,
script: script,
soundName: soundName
)
return XCBreakpointList.BreakpointProxy.BreakpointContent.BreakpointActionProxy(
actionExtensionID: actionExtensionID,
actionContent: xcaction
)
}
}