-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix invalid property usage for const properties and seperate constant…
…s from normal properties (#61) * Split the file constant into an own spec structure to reduce complexity * Add test class for the FileConstWriter * Integrate FileConstantSpec to replace the PropertySpec usage * Add test for the new structure * Improve property tests * Update file const write * Improve property writing * Add emitFileConst method * Update ALLOWED_CONST_MODIFIERS content * Improve allowed modifiers check * Replace check with require * Update validation checks and dedicated method for a property as constant * Mark type as nullable * Deprecate ConstClassName * Update type check * Improve property tests * Update content from the ALLOWED_CLASS_CONST_MODIFIERS constant * Update to the new spec structure for constant values * Update method call to write the constants * Rename constant writer * Update constant property access in the test cases * Remove old place for the constant spec structure * Change name of the constant property objects * Fix failing tests
- Loading branch information
1 parent
3cd44d9
commit 7d2b865
Showing
22 changed files
with
591 additions
and
72 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
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
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/net/theevilreaper/dartpoet/code/writer/ConstantPropertyWriter.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,30 @@ | ||
package net.theevilreaper.dartpoet.code.writer | ||
|
||
import net.theevilreaper.dartpoet.DartModifier.* | ||
import net.theevilreaper.dartpoet.code.CodeWriter | ||
import net.theevilreaper.dartpoet.property.consts.ConstantPropertySpec | ||
import net.theevilreaper.dartpoet.util.SEMICOLON | ||
import net.theevilreaper.dartpoet.util.SPACE | ||
|
||
internal class ConstantPropertyWriter { | ||
|
||
fun emit(spec: ConstantPropertySpec, codeWriter: CodeWriter) { | ||
val modifiersAsString = spec.modifiers.joinToString(separator = SPACE, postfix = SPACE) { it.identifier } | ||
|
||
codeWriter.emit(modifiersAsString) | ||
|
||
if (spec.typeName != null) { | ||
codeWriter.emitCode("%T·", spec.typeName) | ||
} | ||
|
||
if (spec.isPrivat) { | ||
codeWriter.emit(PRIVATE.identifier) | ||
} | ||
|
||
codeWriter.emitCode("%L", spec.name) | ||
|
||
codeWriter.emit("·=·") | ||
codeWriter.emitCode(spec.initializer.build(), isConstantContext = true) | ||
codeWriter.emit(SEMICOLON) | ||
} | ||
} |
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
Oops, something went wrong.