Skip to content

Commit

Permalink
Merge pull request #23 from SchwarzIT/bugfix/code-generation-long-lines
Browse files Browse the repository at this point in the history
Fix Entity code generation for long lines
  • Loading branch information
marco-wolf-ergon authored Aug 21, 2020
2 parents a540dfa + 4e1e97e commit d5b4048
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ class CblFieldHolder(field: Field, allWrappers: List<String>) : CblBaseFieldHold

if (useMDocChanges) {
getter.addCode(CodeBlock.builder().beginControlFlow("if(mDocChanges.containsKey(%N))", constantName)
.addStatement("return %T.fromMap(mDocChanges.get(%N) as %T)", subEntityTypeName, constantName, castType)
.addStatement("return·%T.fromMap(mDocChanges.get(%N) as %T)", subEntityTypeName, constantName, castType)
.endControlFlow().build())
}
getter.addCode(CodeBlock.builder()
.beginControlFlow("if(mDoc.containsKey(%N))", constantName)
.addStatement("return %T.fromMap(mDoc.get(%N) as %T)", subEntityTypeName, constantName, castType)
.addStatement("return·%T.fromMap(mDoc.get(%N) as %T)", subEntityTypeName, constantName, castType)
.endControlFlow().build())

getter.addStatement("return null")
Expand Down
11 changes: 9 additions & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
buildTypes {
release {
Expand Down Expand Up @@ -62,10 +66,13 @@ dependencies {
})
implementation 'com.android.support:appcompat-v7:28.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation project(path: ':couchbase-entity-api')
implementation project(path: ':couchbase-entity-connector')
kapt project(path: ':couchbase-entity')
compileOnly project(path: ':couchbase-entity')
implementation 'com.couchbase.lite:couchbase-lite-android:2.1.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

// Test dependencies
testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kaufland.com.demo.entity

import com.couchbase.lite.Blob
import kaufland.com.coachbasebinderapi.*
import kaufland.com.coachbasebinderapi.query.Queries
import kaufland.com.coachbasebinderapi.query.Query

@Entity(database = "mydb_db")
@MapWrapper
@Fields(
Field(name = "type", type = String::class, defaultValue = "something", readonly = true),
Field(name = "name", type = String::class)
)
open class JustSomeClassWithAVeryLongName
14 changes: 14 additions & 0 deletions demo/src/main/java/kaufland/com/demo/entity/TestClass.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kaufland.com.demo.entity

import com.couchbase.lite.Blob
import kaufland.com.coachbasebinderapi.*
import kaufland.com.coachbasebinderapi.query.Queries
import kaufland.com.coachbasebinderapi.query.Query

@Entity(database = "mydb_db")
@MapWrapper
@Fields(
Field(name = "type", type = String::class, defaultValue = "something", readonly = true),
Field(name = "just_some_class_with_a_very_long_name", type = JustSomeClassWithAVeryLongName::class, list = true)
)
open class TestClass

0 comments on commit d5b4048

Please sign in to comment.