-
Notifications
You must be signed in to change notification settings - Fork 47
format all swift sources, enable format checks #109
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ extension String { | |
|
||
return "\(f.uppercased())\(String(dropFirst()))" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,8 @@ | |
|
||
import Foundation | ||
import JavaTypes | ||
import SwiftSyntax | ||
import OrderedCollections | ||
import SwiftSyntax | ||
|
||
/// Any imported (Swift) declaration | ||
protocol ImportedDecl { | ||
|
@@ -36,7 +36,10 @@ public struct ImportedNominalType: ImportedDecl { | |
public var methods: [ImportedFunc] = [] | ||
public var variables: [ImportedVariable] = [] | ||
|
||
public init(swiftTypeName: String, javaType: JavaType, swiftMangledName: String? = nil, kind: NominalTypeKind) { | ||
public init( | ||
swiftTypeName: String, javaType: JavaType, swiftMangledName: String? = nil, | ||
kind: NominalTypeKind | ||
) { | ||
self.swiftTypeName = swiftTypeName | ||
self.javaType = javaType | ||
self.swiftMangledName = swiftMangledName | ||
|
@@ -56,7 +59,7 @@ public struct ImportedNominalType: ImportedDecl { | |
/// The Java class name without the package. | ||
public var javaClassName: String { | ||
switch javaType { | ||
case .class(package: _, name: let name): name | ||
case .class(package: _, let name): name | ||
default: javaType.description | ||
} | ||
} | ||
|
@@ -250,7 +253,7 @@ public struct ImportedVariable: ImportedDecl, CustomStringConvertible { | |
public var identifier: String | ||
|
||
/// Which accessors are we able to expose. | ||
/// | ||
/// | ||
/// Usually this will be all the accessors the variable declares, | ||
/// however if the getter is async or throwing we may not be able to import it | ||
/// (yet), and therefore would skip it from the supported set. | ||
|
@@ -285,13 +288,14 @@ public struct ImportedVariable: ImportedDecl, CustomStringConvertible { | |
|
||
switch kind { | ||
case .set: | ||
let newValueParam: FunctionParameterSyntax = "_ newValue: \(self.returnType.cCompatibleSwiftType)" | ||
let newValueParam: FunctionParameterSyntax = | ||
"_ newValue: \(self.returnType.cCompatibleSwiftType)" | ||
var funcDecl = ImportedFunc( | ||
parentName: self.parentName, | ||
identifier: self.identifier, | ||
returnType: TranslatedType.void, | ||
parameters: [.init(param: newValueParam, type: self.returnType)]) | ||
funcDecl.swiftMangledName = self.swiftMangledName + "s" // form mangled name of the getter by adding the suffix | ||
funcDecl.swiftMangledName = self.swiftMangledName + "s" // form mangled name of the getter by adding the suffix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. weird decision by swift-format here... |
||
return funcDecl | ||
|
||
case .get: | ||
|
@@ -300,21 +304,24 @@ public struct ImportedVariable: ImportedDecl, CustomStringConvertible { | |
identifier: self.identifier, | ||
returnType: self.returnType, | ||
parameters: []) | ||
funcDecl.swiftMangledName = self.swiftMangledName + "g" // form mangled name of the getter by adding the suffix | ||
funcDecl.swiftMangledName = self.swiftMangledName + "g" // form mangled name of the getter by adding the suffix | ||
return funcDecl | ||
} | ||
} | ||
|
||
public func effectiveAccessorParameters(_ kind: VariableAccessorKind, selfVariant: SelfParameterVariant?) -> [ImportedParam] { | ||
public func effectiveAccessorParameters( | ||
_ kind: VariableAccessorKind, selfVariant: SelfParameterVariant? | ||
) -> [ImportedParam] { | ||
var params: [ImportedParam] = [] | ||
|
||
if kind == .set { | ||
let newValueParam: FunctionParameterSyntax = "_ newValue: \(raw: self.returnType.swiftTypeName)" | ||
let newValueParam: FunctionParameterSyntax = | ||
"_ newValue: \(raw: self.returnType.swiftTypeName)" | ||
params.append( | ||
ImportedParam( | ||
param: newValueParam, | ||
type: self.returnType) | ||
) | ||
) | ||
} | ||
|
||
if let parentName { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c'mon, seriously swift-format? 🤪
(pretty sure that'll break some things since we checked the () -> () string 😅 )