File tree Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 77 test :
88 strategy :
99 matrix :
10- os : [ubuntu-20.04 , macos-latest, windows-latest]
10+ os : [ubuntu-latest , macos-latest, windows-latest]
1111 runs-on : ${{ matrix.os }}
1212 steps :
1313 - name : Checkout
1414 uses : actions/checkout@v4
1515 with :
1616 fetch-depth : ' 0'
1717 - name : Install sbt
18- if : matrix.os == 'macos-latest'
19- run : brew install sbt
18+ uses : sbt/setup-sbt@v1
2019 - name : Install Swift
2120 uses : SwiftyLab/setup-swift@latest
2221 with :
2322 check-latest : true
2423 development : true
2524 swift-version : " 5.10"
2625 - name : Run Linux Build
27- if : matrix.os == 'ubuntu-20.04 '
26+ if : matrix.os == 'ubuntu-latest '
2827 run : |
2928 swift build
3029 mv ./.build/debug/SwiftAstGen SwiftAstGen-linux
Original file line number Diff line number Diff line change 1414 build :
1515 strategy :
1616 matrix :
17- os : [ubuntu-20.04 , macos-latest, windows-latest]
17+ os : [ubuntu-latest , macos-latest, windows-latest]
1818 runs-on : ${{ matrix.os }}
1919 steps :
2020 - name : Checkout
2828 development : true
2929 swift-version : " 5.10"
3030 - name : Run Linux Build
31- if : matrix.os == 'ubuntu-20.04 '
31+ if : matrix.os == 'ubuntu-latest '
3232 run : |
3333 swift build -c release --arch arm64 --arch x86_64 --static-swift-stdlib
3434 mv ./.build/release/SwiftAstGen SwiftAstGen-linux
Original file line number Diff line number Diff line change @@ -50,15 +50,21 @@ extension SyntaxProtocol {
5050
5151struct SyntaxParser {
5252
53+ static func encode( _ s: String ) -> String {
54+ let data = s. data ( using: . ascii, allowLossyConversion: true ) !
55+ return String ( data: data, encoding: . utf8) !
56+ }
57+
5358 static func parse(
5459 srcDir: URL ,
5560 fileUrl: URL ,
5661 relativeFilePath: String ,
5762 prettyPrint: Bool
5863 ) throws -> String {
5964 let code = try String ( contentsOf: fileUrl)
65+ let content = encode ( code)
6066 let opPrecedence = OperatorTable . standardOperators
61- let ast = Parser . parse ( source: code )
67+ let ast = Parser . parse ( source: content )
6268 let folded = try opPrecedence. foldAll ( ast)
6369
6470 let locationConverter = SourceLocationConverter ( fileName: fileUrl. path, tree: folded)
@@ -67,6 +73,7 @@ struct SyntaxParser {
6773 treeNode. projectFullPath = srcDir. standardized. resolvingSymlinksInPath ( ) . path
6874 treeNode. fullFilePath = fileUrl. standardized. resolvingSymlinksInPath ( ) . path
6975 treeNode. relativeFilePath = relativeFilePath
76+ treeNode. content = content
7077
7178 let encoder = JSONEncoder ( )
7279 if prettyPrint { encoder. outputFormatting = . prettyPrinted }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ final class TreeNode: Codable {
33 var projectFullPath : String ?
44 var relativeFilePath : String ?
55 var fullFilePath : String ?
6+ var content : String ?
67
78 var index : Int
89 var name : String
You can’t perform that action at this time.
0 commit comments