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(swift) correctly highlight generics and conformances in type definitions #3937

Merged
merged 15 commits into from
Dec 24, 2023

Conversation

bradleymackey
Copy link
Contributor

@bradleymackey bradleymackey commented Dec 10, 2023

Fixes highlighting of type definitions, especially when the given type is generic.

Changes

  • Fix entire type definition being highlighted as title.class, only the newly defined type should be highlighted as this. Inheritance and protocol conformances should be indicated with the title.class.inherited class instead, as this is better modelled by this inheritance class.
  • Support generic signatures for type declarations
  • Add more test cases for type declarations

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change -51 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.17 KB -1 B
es/highlight.min.js 8.17 KB 8.17 KB -1 B
es/languages/swift.min.js 3.54 KB 3.52 KB -24 B
highlight.min.js 8.21 KB 8.21 KB -1 B
languages/swift.min.js 3.55 KB 3.52 KB -24 B

@joshgoebel
Copy link
Member

I know it's not exactly the same thing, but might title.class.inherited be better than type?

@bradleymackey
Copy link
Contributor Author

@joshgoebel I agree, this better models the semantics here. Please see latest changes.

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

2 files changed

Total change +20 B

View Changes
file base pr diff
es/languages/swift.min.js 3.54 KB 3.55 KB +10 B
languages/swift.min.js 3.55 KB 3.56 KB +10 B

1 similar comment
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

2 files changed

Total change +20 B

View Changes
file base pr diff
es/languages/swift.min.js 3.54 KB 3.55 KB +10 B
languages/swift.min.js 3.55 KB 3.56 KB +10 B

src/languages/swift.js Outdated Show resolved Hide resolved
src/languages/swift.js Outdated Show resolved Hide resolved
src/languages/swift.js Outdated Show resolved Hide resolved
Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just a few thoughts.

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change -14 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.17 KB -1 B
es/highlight.min.js 8.18 KB 8.17 KB -1 B
es/languages/swift.min.js 3.54 KB 3.54 KB -5 B
highlight.min.js 8.21 KB 8.21 KB -1 B
languages/swift.min.js 3.55 KB 3.54 KB -6 B

src/languages/swift.js Outdated Show resolved Hide resolved
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

4 files changed

Total change -11 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.18 KB +1 B
es/highlight.min.js 8.17 KB 8.18 KB +1 B
es/languages/swift.min.js 3.54 KB 3.54 KB -6 B
languages/swift.min.js 3.55 KB 3.54 KB -7 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change -11 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.18 KB +1 B
es/highlight.min.js 8.17 KB 8.18 KB +1 B
es/languages/swift.min.js 3.54 KB 3.54 KB -7 B
highlight.min.js 8.21 KB 8.21 KB +1 B
languages/swift.min.js 3.55 KB 3.54 KB -7 B

@joshgoebel joshgoebel force-pushed the fix/swift/generic-sigs branch from 369e606 to e3336f3 Compare December 24, 2023 23:13
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change -21 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.17 KB -2 B
es/highlight.min.js 8.17 KB 8.17 KB -2 B
es/languages/swift.min.js 3.54 KB 3.54 KB -7 B
highlight.min.js 8.21 KB 8.2 KB -3 B
languages/swift.min.js 3.55 KB 3.54 KB -7 B

@joshgoebel joshgoebel merged commit 518a820 into highlightjs:main Dec 24, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants