-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathConfiguration+SwiftExtract.swift
More file actions
64 lines (59 loc) · 2.26 KB
/
Configuration+SwiftExtract.swift
File metadata and controls
64 lines (59 loc) · 2.26 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
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024-2026 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import SwiftExtract
import SwiftJavaConfigurationShared
/// Bridges swift-java's `Configuration` onto the language-neutral
/// `SwiftExtractConfiguration` surface consumed by `SwiftExtract`.
///
/// Most members are satisfied directly by `Configuration`'s own properties.
/// `Configuration` shares `AccessLevelMode` with the analyzer (both pull it in
/// from `SwiftExtractConfigurationShared`), so `swiftExtractAccessLevel` is a
/// straight passthrough. Only `swiftExtractLogLevel` needs a mapping from
/// swift-java's `LogLevel` onto the neutral `Logger.Level`.
extension Configuration: SwiftExtractConfiguration {
public var swiftExtractAccessLevel: AccessLevelMode {
effectiveMinimumInputAccessLevelMode
}
public var swiftExtractLogLevel: SwiftExtract.Logger.Level? {
guard let logLevel else { return nil }
switch logLevel {
case .trace: return .trace
case .debug: return .debug
case .info: return .info
case .notice: return .notice
case .warning: return .warning
case .error: return .error
case .critical: return .critical
}
}
// swift-java targets Java, which cannot express Swift operators or
// construct open generic types directly: leave both knobs off
public var extractsOperators: Bool { false }
public var extractsGenericTypeInitializers: Bool { false }
}
extension LogLevel {
/// Bridges from the analysis layer's neutral `Logger.Level` (used by the CLI's
/// `--log-level` option) onto swift-java's own `LogLevel`.
public init(_ level: SwiftExtract.Logger.Level) {
switch level {
case .trace: self = .trace
case .debug: self = .debug
case .info: self = .info
case .notice: self = .notice
case .warning: self = .warning
case .error: self = .error
case .critical: self = .critical
}
}
}