Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Sources/SwiftExtract/SwiftAnalyzer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ extension SwiftAnalyzer {
)
}

package func add(filePath: String, text: String) {
public func add(filePath: String, text: String) {
log.debug("Adding: \(filePath)")
let sourceFileSyntax = Parser.parse(source: text)
self.inputs.append(SwiftInputFile(syntax: sourceFileSyntax, path: filePath))
Expand All @@ -150,7 +150,7 @@ extension SwiftAnalyzer {
/// the analyzer's natively-registered ones. Without the hook, those
/// specializations are registered too late and any constrained extension
/// (`extension Box where T == ConcreteT { … }`) is silently dropped.
package func analyze(
public func analyze(
beforeProcessingDeferredExtensions hook: (SwiftAnalyzer) throws -> Void = { _ in }
) throws {
prepareForTranslation()
Expand Down Expand Up @@ -283,6 +283,15 @@ extension SwiftAnalyzer {
return analyzer.result
}

/// Resolve a type reference found outside of a declaration signature
/// (e.g. inside an attribute argument such as `@JavaExport(as: Foo.self)`)
/// against the analyzed module's symbol tables. Only valid after
/// `analyze()` has run.
public func resolveType(_ syntax: TypeSyntax) throws -> SwiftType {
precondition(lookupContext != nil, "resolveType may only be called after analyze()")
return try SwiftType(syntax, lookupContext: lookupContext)
}

package func prepareForTranslation() {
let symbolTable = SwiftSymbolTable.setup(
moduleName: self.swiftModuleName,
Expand Down
Loading