-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change representation of Placeholder annotations in StarLasu to disti…
…nguish between missing and failing transformations
- Loading branch information
1 parent
353a78f
commit 2df2e32
Showing
9 changed files
with
146 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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 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 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
42 changes: 42 additions & 0 deletions
42
core/src/main/kotlin/com/strumenta/kolasu/transformation/PlaceholderASTTransformation.kt
This file contains 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,42 @@ | ||
package com.strumenta.kolasu.transformation | ||
|
||
import com.strumenta.kolasu.model.Node | ||
import com.strumenta.kolasu.model.Origin | ||
import com.strumenta.kolasu.model.Position | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* This is used to indicate that a Node represents some form of placeholders to be used in transformation. | ||
*/ | ||
sealed class PlaceholderASTTransformation(val origin: Origin?, val message: String) : Origin { | ||
override val position: Position? | ||
get() = origin?.position | ||
override val sourceText: String? | ||
get() = origin?.sourceText | ||
} | ||
|
||
/** | ||
* This is used to indicate that we do not know how to transform a certain node. | ||
*/ | ||
class MissingASTTransformation( | ||
origin: Origin?, | ||
val transformationSource: Any?, | ||
val expectedType: KClass<out Node>? = null, | ||
message: String = "Translation of a node is not yet implemented: " + | ||
"${if (transformationSource is Node) transformationSource.simpleNodeType else transformationSource}" + | ||
if (expectedType != null) " into $expectedType" else "" | ||
) : | ||
PlaceholderASTTransformation(origin, message) { | ||
constructor(transformationSource: Node, expectedType: KClass<out Node>? = null) : this( | ||
transformationSource, | ||
transformationSource, | ||
expectedType | ||
) | ||
} | ||
|
||
/** | ||
* This is used to indicate that, while we had a transformation for a given node, that failed. | ||
* This is typically the case because the transformation covers only certain case and we encountered | ||
* one that was not covered. | ||
*/ | ||
class FailingASTTransformation(origin: Origin?, message: String) : PlaceholderASTTransformation(origin, message) |
This file contains 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 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
15 changes: 15 additions & 0 deletions
15
core/src/test/kotlin/com/strumenta/kolasu/ids/SourceIdProviderTest.kt
This file contains 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,15 @@ | ||
package com.strumenta.kolasu.ids | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class SourceIdProviderTest { | ||
|
||
@Test | ||
fun testRemoveCharactersInvalidInLionWebIDs() { | ||
assertEquals( | ||
"funny933--_12aaAAAAZz", | ||
"funny%à, è, é, ì, ò, ù =+933--_12aaAAAAZz".removeCharactersInvalidInLionWebIDs() | ||
) | ||
} | ||
} |
This file contains 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 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