-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for Kotlin 2.2.0 #155
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
base: main
Are you sure you want to change the base?
Changes from all commits
a98aef8
c3fa9ed
9b6f906
1705188
b777918
540f5cd
f40a67b
fada584
8c24234
6333ba3
eed9c2a
d5e03b2
a235723
a5c7c3a
c6a798a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,7 +47,7 @@ class CorpusParseAndWriteWithExtrasTest(private val unit: Corpus.Unit) { | |||||||
| } | ||||||||
| } catch (e: Parser.ParseError) { | ||||||||
| if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e | ||||||||
|
||||||||
| if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e | |
| if (!unit.canSkip || unit.errorMessages.isEmpty()) throw e | |
| // TODO: Re-enable the assertion below when partial parsing is supported. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,7 @@ | ||||||
| package ktast.ast | ||||||
|
|
||||||
| private val stringMultiDollarPrefixRegex = Regex("^\\$+") | ||||||
|
|
||||||
| /** | ||||||
| * Common interface for all the AST nodes. | ||||||
| */ | ||||||
|
|
@@ -724,7 +726,7 @@ sealed interface Node { | |||||
| */ | ||||||
| data class FunctionType( | ||||||
| override val modifiers: List<Modifier>, | ||||||
| val contextReceiver: ContextReceiver?, | ||||||
| val contextReceiver: Modifier.ContextReceiver?, | ||||||
| val receiverType: Type?, | ||||||
| val lPar: Keyword.LPar, | ||||||
| val parameters: List<FunctionTypeParameter>, | ||||||
|
|
@@ -746,6 +748,14 @@ sealed interface Node { | |||||
| override val supplement: NodeSupplement = NodeSupplement(), | ||||||
| ) : Node | ||||||
| } | ||||||
|
|
||||||
| data class IntersectionType( | ||||||
| override val modifiers: List<Modifier>, | ||||||
| val leftType: Type, | ||||||
| val rightType: Type, | ||||||
| override val supplement: NodeSupplement = NodeSupplement(), | ||||||
| ) : Type { | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -1195,14 +1205,26 @@ sealed interface Node { | |||||
| /** | ||||||
| * AST node that represents a string literal expression. The node corresponds to KtStringTemplateExpression. | ||||||
| * | ||||||
| * @property prefix prefix of the string literal. Typically, it is single double quote `"`, but can be triple quotes `"""` for raw strings. In case of multi-dollar string, it can be `$$"` or similar. | ||||||
| * @property entries list of string entries. | ||||||
| * @property raw `true` if this is raw string surrounded by `"""`, `false` if this is regular string surrounded by `"`. | ||||||
| */ | ||||||
| data class StringLiteralExpression( | ||||||
| val prefix: String, | ||||||
| val entries: List<StringEntry>, | ||||||
| val raw: Boolean, | ||||||
| override val supplement: NodeSupplement = NodeSupplement(), | ||||||
| ) : Expression { | ||||||
| /** | ||||||
| * Suffix of the string literal, which is the prefix without any multi-dollar prefix. For example, if the prefix is `$$"`, the suffix will be `"`. | ||||||
| */ | ||||||
| val suffix: String | ||||||
| get() = prefix.replace(stringMultiDollarPrefixRegex, "") | ||||||
|
|
||||||
| /** | ||||||
| * Returns `true` if this is a raw string literal, i.e. it starts and ends with triple quotes `"""`. Otherwise, returns `false`. | ||||||
| */ | ||||||
| val raw: Boolean | ||||||
| get() = prefix.endsWith("\"\"\"") | ||||||
|
|
||||||
| /** | ||||||
| * Common interface for string entries. The node corresponds to KtStringTemplateEntry. | ||||||
| */ | ||||||
|
|
@@ -1237,19 +1259,31 @@ sealed interface Node { | |||||
| /** | ||||||
| * AST node that represents a template string entry with expression. The node corresponds to KtStringTemplateEntryWithExpression. | ||||||
| * | ||||||
| * @property prefix prefix of the template string entry. Typically, it is `$` for short template strings, or `${` for long template strings. In case of multi-dollar template strings, it can be `$$`, `$${`, etc. | ||||||
| * @property expression template expression of this entry. | ||||||
| * @property short `true` if this is short template string entry, e.g. `$x`, `false` if this is long template string entry, e.g. `${x}`. When this is `true`, [expression] must be [NameExpression]. | ||||||
| */ | ||||||
| data class TemplateStringEntry( | ||||||
| val prefix: String, | ||||||
| val expression: Expression, | ||||||
| val short: Boolean, | ||||||
| override val supplement: NodeSupplement = NodeSupplement(), | ||||||
| ) : StringEntry { | ||||||
| init { | ||||||
| require(!short || expression is NameExpression || expression is ThisExpression) { | ||||||
|
||||||
| require(!short || expression is NameExpression || expression is ThisExpression) { | |
| require(!prefix.endsWith("{") || expression is NameExpression || expression is ThisExpression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion is commented out, which may indicate incomplete work or temporary debugging. Consider either removing this code entirely or adding a TODO comment explaining why it's disabled and when it should be re-enabled.