Skip to content

Commit

Permalink
rename StyleNode.Text -> StyleNode.TextStyledNode
Browse files Browse the repository at this point in the history
  • Loading branch information
lytefast committed Nov 3, 2020
1 parent 76a2830 commit 99f6b20
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ open class CodeNode<RC>(
pre: String, name: String,
codeStyleProviders: CodeStyleProviders<RC>
) : Node.Parent<RC>(
StyleNode.Text(pre, codeStyleProviders.keywordStyleProvider),
StyleNode.Text(name, codeStyleProviders.typesStyleProvider)
StyleNode.TextStyledNode(pre, codeStyleProviders.keywordStyleProvider),
StyleNode.TextStyledNode(name, codeStyleProviders.typesStyleProvider)
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object CodeRules {
): ParseSpec<R, S> {
val content = matcher.group(group).orEmpty()
val node = stylesProvider
?.let { StyleNode.Text(content, it) }
?.let { StyleNode.TextStyledNode(content, it) }
?: TextNode(content)
return ParseSpec.createTerminal(node, state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ object Kotlin {
pre: String, generic: String?, signature: String, params: String,
codeStyleProviders: CodeStyleProviders<RC>
) : Node.Parent<RC>(
StyleNode.Text(pre, codeStyleProviders.keywordStyleProvider),
generic?.let { StyleNode.Text(it, codeStyleProviders.genericsStyleProvider) },
StyleNode.Text(signature, codeStyleProviders.identifierStyleProvider),
StyleNode.Text(params, codeStyleProviders.paramsStyleProvider),
StyleNode.TextStyledNode(pre, codeStyleProviders.keywordStyleProvider),
generic?.let { StyleNode.TextStyledNode(it, codeStyleProviders.genericsStyleProvider) },
StyleNode.TextStyledNode(signature, codeStyleProviders.identifierStyleProvider),
StyleNode.TextStyledNode(params, codeStyleProviders.paramsStyleProvider),
) {
companion object {

Expand Down Expand Up @@ -74,8 +74,8 @@ object Kotlin {
definition: String, name: String,
codeStyleProviders: CodeStyleProviders<RC>
) : Node.Parent<RC>(
StyleNode.Text(definition, codeStyleProviders.keywordStyleProvider),
StyleNode.Text(name, codeStyleProviders.identifierStyleProvider),
StyleNode.TextStyledNode(definition, codeStyleProviders.keywordStyleProvider),
StyleNode.TextStyledNode(name, codeStyleProviders.identifierStyleProvider),
) {
companion object {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ open class StyleNode<RC, T>(val styles: List<T>) : Node.Parent<RC>() {
*
* @see TextNode
*/
class Text<RC>(content: String, val stylesProvider: SpanProvider<RC>) : TextNode<RC>(content) {
class TextStyledNode<RC>(content: String, val stylesProvider: SpanProvider<RC>) : TextNode<RC>(content) {
override fun render(builder: SpannableStringBuilder, renderContext: RC) {
val startIndex = builder.length
super.render(builder, renderContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"// Inlined",
"// Line comment",
"/// Doc")
Expand All @@ -57,7 +57,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"# Inlined",
"# Line comment")
}
Expand All @@ -73,7 +73,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
""""maybe"""",
""""lyte"""",
""""hello
Expand All @@ -91,7 +91,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
""""maybe"""",
""""lyte"""",
""""hello
Expand All @@ -111,7 +111,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"0", "12", "123", "456"
)
}
Expand All @@ -126,7 +126,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"@Route",
"def", " get",
"pass"
Expand All @@ -144,7 +144,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"#[derive(HelperAttr)]\n",
"struct", " Struct",
// "#[helper]" // Not supported
Expand Down Expand Up @@ -176,7 +176,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"mod", " test",
"use", "Arc",
"pub", "struct", " Event",
Expand Down Expand Up @@ -206,7 +206,7 @@ class CodeRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"from", "import", "as",
"def", " hello_world", "self",
"try",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class KotlinRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"""
/** Multiline
Comment
Expand All @@ -63,7 +63,7 @@ class KotlinRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
""""hello"""",
""""world"""")
}
Expand All @@ -81,7 +81,7 @@ class KotlinRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"\"\"",
"""
${'"'}
Expand All @@ -102,7 +102,7 @@ class KotlinRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"@Test",
"@Nullable",
)
Expand Down Expand Up @@ -137,7 +137,7 @@ class KotlinRulesTest {
```
""".trimIndent(), TestState())

ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"""
/*
private override fun <T> test(x:T) {
Expand Down Expand Up @@ -174,7 +174,7 @@ class KotlinRulesTest {
}
```
""".trimIndent(), TestState())
ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"package", "import",
"while", "true", "123", "break",
"if", "false",
Expand All @@ -191,7 +191,7 @@ class KotlinRulesTest {
add(123,456)
```
""".trimIndent(), TestState())
ast.assertNodeContents<StyleNode.Text<*>>(
ast.assertNodeContents<StyleNode.TextStyledNode<*>>(
"0", "12", "123", "456"
)
}
Expand Down
Empty file.

0 comments on commit 99f6b20

Please sign in to comment.