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

🐛 fix: incorrect PlantUMLScript when @unchecked Sendable present in S… #77

Merged
merged 1 commit into from
Nov 11, 2023
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 @@ -27,7 +27,13 @@
var index = 0

func addLinking(item: SyntaxStructure, parent: SyntaxStructure) {
let linkTo = parent.name?.removeAngleBracketsWithContent() ?? "___"
var linkTo = parent.name?.removeAngleBracketsWithContent() ?? "___"

Check warning on line 31 in Sources/SwiftPlantUMLFramework/Internal/PlantUMLContext.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
// escape names like "@unchecked Sendable" for PlantUML
if linkTo.starts(with: "@") {
linkTo = "\"\(linkTo)\""
}

Check warning on line 36 in Sources/SwiftPlantUMLFramework/Internal/PlantUMLContext.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
guard skipLinking(element: parent, basedOn: configuration.relationships.inheritance?.exclude) == false else { return }
let namedConnection = (uniqElementAndTypes[linkTo] != nil) ? "\(uniqElementAndTypes[linkTo] ?? "--ERROR--")" : "inherits"
var linkTypeKey = item.fullName! + "LinkType"
Expand Down
11 changes: 11 additions & 0 deletions Tests/SwiftPlantUMLFrameworkTests/PlantUMLContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ final class PlantUMLContextTests: XCTestCase {

XCTAssertEqual(context.connections.count, 0)
}

func testAddLinkingEscapeName() {
let superclass = SyntaxStructure(kind: .class, name: "@unchecked Sendable")
let subclass = SyntaxStructure(kind: .class, name: "Yoo")
let context = PlantUMLContext()

_ = context.uniqName(item: subclass, relationship: "inherits")
context.addLinking(item: subclass, parent: superclass)

XCTAssertEqual(context.connections.first!, #""@unchecked Sendable" <|-- Yoo : inherits"#)
}
}
Loading