-
Notifications
You must be signed in to change notification settings - Fork 113
Multiple Highlighter Support #273
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
Merged
thecoolwinter
merged 27 commits into
CodeEditApp:main
from
thecoolwinter:feat/multiple-highlighters
Nov 18, 2024
Merged
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
62c1731
Add Object Scaffolding, RangeStore, VisualRange Tests, Range Store Tests
thecoolwinter 6214f2d
I've Since Realized This Is Incorrect
thecoolwinter f313e7c
Finalize `StyledRangeStore` and Tests
thecoolwinter 1fa046c
Add Multi-Run Method, Fix Tests, Update Tests
thecoolwinter 0713d2c
Begin `StyledRangeContainer`
thecoolwinter f09822a
First Attempt At Overlapping Ranges
thecoolwinter 5c1a696
Finish `StyledRangeContainer`
thecoolwinter f01eeb0
Apply Styles, Update Init Params, Update Capture Representation
thecoolwinter 957b859
Add VisibleRangeProviderTests
thecoolwinter 8d3cf5a
Docs, Docs, Docs
thecoolwinter 3e21e21
Remove .swiftpm folder
thecoolwinter 88b928e
Lint Errors (darn whitespace)
thecoolwinter fec3ab1
Remove Swift 6 Fixes (will replace in future)
thecoolwinter f042b38
Fix Warnings
thecoolwinter 9102955
Fix Docs Typo
thecoolwinter 0b00fb9
Merge branch 'main' into feat/multiple-highlighters
thecoolwinter 053a7d4
Highlight Invalidation Fix
thecoolwinter aaef5f2
Merge branch 'feat/multiple-highlighters' of https://github.com/theco…
thecoolwinter 09e5cac
Rename CaptureModifiers -> CaptureModifier
thecoolwinter ba1dadb
Fix Compile Error
thecoolwinter 2271437
Update CaptureModifier.swift
thecoolwinter b7bd8fc
Add `insert` Method To Modifiers Set
thecoolwinter fc55634
Typo
thecoolwinter 327fc72
Code Style, Add Docs, Clean Tests
thecoolwinter 72c15c9
Merge branch 'feat/multiple-highlighters' of https://github.com/theco…
thecoolwinter 53605e4
Slight Doc Rewrite
thecoolwinter 4c0221e
Only Invalidate Cancellations
thecoolwinter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 0 additions & 101 deletions
101
.swiftpm/xcode/xcshareddata/xcschemes/CodeEditTextView.xcscheme
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
Sources/CodeEditSourceEditor/Enums/CaptureModifier.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // | ||
| // CaptureModifiers.swift | ||
| // CodeEditSourceEditor | ||
| // | ||
| // Created by Khan Winter on 10/24/24. | ||
| // | ||
|
|
||
| // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#semanticTokenModifiers | ||
|
|
||
| public enum CaptureModifier: Int8, CaseIterable, Sendable { | ||
| case declaration | ||
| case definition | ||
| case readonly | ||
| case `static` | ||
| case deprecated | ||
| case abstract | ||
| case async | ||
| case modification | ||
| case documentation | ||
| case defaultLibrary | ||
|
|
||
| public var stringValue: String { | ||
| switch self { | ||
| case .declaration: | ||
| return "declaration" | ||
| case .definition: | ||
| return "definition" | ||
| case .readonly: | ||
| return "readonly" | ||
| case .static: | ||
| return "static" | ||
| case .deprecated: | ||
| return "deprecated" | ||
| case .abstract: | ||
| return "abstract" | ||
| case .async: | ||
| return "async" | ||
| case .modification: | ||
| return "modification" | ||
| case .documentation: | ||
| return "documentation" | ||
| case .defaultLibrary: | ||
| return "defaultLibrary" | ||
| } | ||
| } | ||
|
|
||
| // swiftlint:disable:next cyclomatic_complexity | ||
| public static func fromString(_ string: String) -> CaptureModifier? { | ||
| switch string { | ||
| case "declaration": | ||
| return .declaration | ||
| case "definition": | ||
| return .definition | ||
| case "readonly": | ||
| return .readonly | ||
| case "static`": | ||
| return .static | ||
| case "deprecated": | ||
| return .deprecated | ||
| case "abstract": | ||
| return .abstract | ||
| case "async": | ||
| return .async | ||
| case "modification": | ||
| return .modification | ||
| case "documentation": | ||
| return .documentation | ||
| case "defaultLibrary": | ||
| return .defaultLibrary | ||
| default: | ||
| return nil | ||
| } | ||
| } | ||
| } | ||
|
|
||
| extension CaptureModifier: CustomDebugStringConvertible { | ||
| public var debugDescription: String { | ||
| switch self { | ||
| case .declaration: return "declaration" | ||
| case .definition: return "definition" | ||
| case .readonly: return "readonly" | ||
| case .static: return "static" | ||
| case .deprecated: return "deprecated" | ||
| case .abstract: return "abstract" | ||
| case .async: return "async" | ||
| case .modification: return "modification" | ||
| case .documentation: return "documentation" | ||
| case .defaultLibrary: return "defaultLibrary" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// A set of capture modifiers, efficiently represented by a single integer. | ||
| public struct CaptureModifierSet: OptionSet, Equatable, Hashable, Sendable { | ||
| public var rawValue: UInt | ||
|
|
||
| public init(rawValue: UInt) { | ||
| self.rawValue = rawValue | ||
| } | ||
|
|
||
| public static let declaration = CaptureModifierSet(rawValue: 1 << CaptureModifier.declaration.rawValue) | ||
| public static let definition = CaptureModifierSet(rawValue: 1 << CaptureModifier.definition.rawValue) | ||
| public static let readonly = CaptureModifierSet(rawValue: 1 << CaptureModifier.readonly.rawValue) | ||
| public static let `static` = CaptureModifierSet(rawValue: 1 << CaptureModifier.static.rawValue) | ||
| public static let deprecated = CaptureModifierSet(rawValue: 1 << CaptureModifier.deprecated.rawValue) | ||
| public static let abstract = CaptureModifierSet(rawValue: 1 << CaptureModifier.abstract.rawValue) | ||
| public static let async = CaptureModifierSet(rawValue: 1 << CaptureModifier.async.rawValue) | ||
| public static let modification = CaptureModifierSet(rawValue: 1 << CaptureModifier.modification.rawValue) | ||
| public static let documentation = CaptureModifierSet(rawValue: 1 << CaptureModifier.documentation.rawValue) | ||
| public static let defaultLibrary = CaptureModifierSet(rawValue: 1 << CaptureModifier.defaultLibrary.rawValue) | ||
|
|
||
| /// All values in the set. | ||
| public var values: [CaptureModifier] { | ||
| var rawValue = self.rawValue | ||
| var values: [Int8] = [] | ||
| while rawValue > 0 { | ||
| values.append(Int8(rawValue.trailingZeroBitCount)) | ||
| rawValue &= ~UInt(1 << rawValue.trailingZeroBitCount) | ||
thecoolwinter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return values.compactMap({ CaptureModifier(rawValue: $0) }) | ||
| } | ||
|
|
||
| public mutating func insert(_ value: CaptureModifier) { | ||
| rawValue &= 1 << value.rawValue | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.