highlight.js: (swift) does not recognize core Apple foundational libraries

I found this while writing this on Stack Overflow. I’m not sure what the root of the problem is, but I’m guessing it starts in the function signature. Here’s the code:

func configuredGridCell() -> UICollectionView.CellRegistration<UICollectionViewCell, Emoji> {
    return UICollectionView.CellRegistration<UICollectionViewCell, Emoji> { (cell, indexPath, emoji) in
        var content = UIListContentConfiguration.cell()
        content.text = emoji.text
        content.textProperties.font = .boldSystemFont(ofSize: 38)
        content.textProperties.alignment = .center
        content.directionalLayoutMargins = .zero
        cell.contentConfiguration = content
        var background = UIBackgroundConfiguration.listPlainCell()
        background.cornerRadius = 8
        background.strokeColor = .systemGray3
        background.strokeWidth = 1.0 / cell.traitCollection.displayScale
        cell.backgroundConfiguration = background
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (12 by maintainers)

Most upvoted comments

And if you happened to have the time: https://github.com/highlightjs/highlight.js/issues/2819 😃

@AustinConlon Want to take a pass at making a PR to pull over that rule from Objective-C, and balance the languages out?

Damn, my question was too broad. 😃 All all the class prefixes listed there valid for use in Swift code also? I think you’re saying the answer is yes?

I’m thinking we should add them to our Swift grammar so they can be highlighted and help out for auto-detecting, yes? Right now swift is highlighting them as “types” but they have no relevance score, so it doesn’t make it more likely that your code is Swift like it would if we added those API classes as an explicit list.