Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature Improvements]: Tabs indetation selector added
- Loading branch information
Showing
16 changed files
with
140 additions
and
19 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
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/robohorse/robopojogenerator/delegates/IndentationDelegate.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,11 @@ | ||
package com.robohorse.robopojogenerator.delegates | ||
|
||
import com.robohorse.robopojogenerator.generator.consts.templates.ClassTemplate | ||
|
||
class IndentationDelegate { | ||
|
||
fun updateFileBody(body: String) = | ||
body.replace(ClassTemplate.TAB, "$SPACE$SPACE$SPACE$SPACE") | ||
} | ||
|
||
private const val SPACE = " " |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/com/robohorse/robopojogenerator/delegates/PreWriterDelegate.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,16 @@ | ||
package com.robohorse.robopojogenerator.delegates | ||
|
||
import com.robohorse.robopojogenerator.models.GenerationModel | ||
|
||
class PreWriterDelegate( | ||
private val indentationDelegate: IndentationDelegate | ||
) { | ||
|
||
fun updateFileBody( | ||
generationModel: GenerationModel, body: String | ||
) = if (!generationModel.useTabsIndentation) { | ||
indentationDelegate.updateFileBody(body) | ||
} else { | ||
body | ||
} | ||
} |
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
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
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
16 changes: 16 additions & 0 deletions
16
src/test/kotlin/com/robohorse/robopojogenerator/delegates/IndentationDelegateTest.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,16 @@ | ||
package com.robohorse.robopojogenerator.delegates | ||
|
||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
class IndentationDelegateTest { | ||
private val indentationDelegate = IndentationDelegate() | ||
|
||
@Test | ||
fun check_body_update() { | ||
assertEquals(RESULT, indentationDelegate.updateFileBody(SOURCE)) | ||
} | ||
} | ||
|
||
private const val SOURCE = "class MyClass{\t}" | ||
private const val RESULT = "class MyClass{ }" |
39 changes: 39 additions & 0 deletions
39
src/test/kotlin/com/robohorse/robopojogenerator/delegates/PreWriterDelegateTest.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,39 @@ | ||
package com.robohorse.robopojogenerator.delegates | ||
|
||
import com.robohorse.robopojogenerator.models.GenerationModel | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.InjectMockKs | ||
import io.mockk.impl.annotations.RelaxedMockK | ||
import io.mockk.junit5.MockKExtension | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import kotlin.test.assertEquals | ||
|
||
@ExtendWith(MockKExtension::class) | ||
class PreWriterDelegateTest { | ||
@RelaxedMockK | ||
lateinit var indentationDelegate: IndentationDelegate | ||
|
||
@RelaxedMockK | ||
lateinit var generationModel: GenerationModel | ||
|
||
@InjectMockKs | ||
lateinit var preWriterDelegate: PreWriterDelegate | ||
|
||
@Test | ||
fun checkIndentationApply() { | ||
every { generationModel.useTabsIndentation }.returns(false) | ||
every { indentationDelegate.updateFileBody(SOURCE) }.returns(RESULT) | ||
assertEquals(RESULT, preWriterDelegate.updateFileBody(generationModel, SOURCE)) | ||
} | ||
|
||
@Test | ||
fun checkIndentationSkip() { | ||
every { generationModel.useTabsIndentation }.returns(true) | ||
every { indentationDelegate.updateFileBody(SOURCE) }.returns(RESULT) | ||
assertEquals(SOURCE, preWriterDelegate.updateFileBody(generationModel, SOURCE)) | ||
} | ||
} | ||
|
||
private const val SOURCE = "class MyClass{\t}" | ||
private const val RESULT = "class MyClass{ }" |
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