Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
super.init(viewMode: .all)
}

public static func diagnostics(for tree: SyntaxProtocol) -> [Diagnostic] {
public static func diagnostics<SyntaxType: SyntaxProtocol>(
for tree: SyntaxType
) -> [Diagnostic] {
let diagProducer = ParseDiagnosticsGenerator()
diagProducer.walk(tree)
return diagProducer.diagnostics
Expand Down
18 changes: 10 additions & 8 deletions Tests/SwiftParserTest/RecoveryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,11 @@ public class RecoveryTests: XCTestCase {
var source = """
(first second third struct: Int)
"""
let (_, currentToken) = source.withUTF8 { buffer in
var parser = Parser(buffer)
return (parser.parseFunctionSignature(), parser.currentToken)
}
let (_, currentToken): (RawFunctionSignatureSyntax, Lexer.Lexeme) =
source.withUTF8 { buffer in
var parser = Parser(buffer)
return (parser.parseFunctionSignature(), parser.currentToken)
}

// The 'struct' keyword should be taken as an indicator that a new decl
// starts here, so `parseFunctionSignature` shouldn't eat it.
Expand Down Expand Up @@ -334,10 +335,11 @@ public class RecoveryTests: XCTestCase {
(first second third
: Int)
"""
let (_, currentToken) = source.withUTF8 { buffer in
var parser = Parser(buffer)
return (parser.parseFunctionSignature(), parser.currentToken)
}
let (_, currentToken): (RawFunctionSignatureSyntax, Lexer.Lexeme) =
source.withUTF8 { buffer in
var parser = Parser(buffer)
return (parser.parseFunctionSignature(), parser.currentToken)
}

XCTAssertEqual(currentToken.tokenKind, .colon)
}
Expand Down