Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support assume-filename option to find the configuration file when reading from stdin. #794

Merged
merged 1 commit into from
Aug 15, 2024
Merged
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
6 changes: 4 additions & 2 deletions Sources/swift-format/Frontend/Frontend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,19 @@ class Frontend {

/// Processes source content from standard input.
private func processStandardInput() {
let assumedUrl = lintFormatOptions.assumeFilename.map(URL.init(fileURLWithPath:))

guard let configuration = configuration(
fromPathOrString: lintFormatOptions.configuration,
orInferredFromSwiftFileAt: nil)
orInferredFromSwiftFileAt: assumedUrl)
else {
// Already diagnosed in the called method.
return
}

let fileToProcess = FileToProcess(
fileHandle: FileHandle.standardInput,
url: URL(fileURLWithPath: lintFormatOptions.assumeFilename ?? "<stdin>"),
url: assumedUrl ?? URL(fileURLWithPath: "<stdin>"),
configuration: configuration,
selection: Selection(offsetRanges: lintFormatOptions.offsets))
processFile(fileToProcess)
Expand Down