Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate layout method #991

Merged
merged 2 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ android:
- tools
- platform-tools
- build-tools-28.0.3
- build-tools-29.0.2
- android-28
- android-29
- extra-google-google_play_services
- extra-android-m2repository
- extra-google-m2repository
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 4.0.0-beta4 (June 1, 2020)
Fixes:
- Synchronize ListUpdateCallback and PagedListModelCache functions (#987)
- 4.0.0.beta1 generating duplicate method layout(int) #988

# 4.0.0-beta3 (May 27, 2020)
- Sort functions in generated kotlin extension function files deterministically to prevent generated sources from changing
- Avoid generating bitset checks in models when not needed
Expand Down
14 changes: 1 addition & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
buildscript {

ext.KOTLIN_VERSION = "1.3.72"
ext.ANDROID_PLUGIN_VERSION = '3.6.3'
ext.ANDROID_PLUGIN_VERSION = '4.0.0'

repositories {
google()
Expand Down Expand Up @@ -37,22 +37,10 @@ allprojects {
subprojects { project ->
apply from: "$rootDir/blessedDeps.gradle"
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'checkstyle'
apply from: "${project.rootDir}/ktlint.gradle"

task checkstyle(type: Checkstyle) {
configFile rootProject.file('checkstyle.xml')
source 'src/main/java'
ignoreFailures false
showViolations true
include '**/*.java'

classpath = files()
}

afterEvaluate {
if (project.tasks.findByName('check')) {
check.dependsOn('checkstyle')
check.dependsOn('ktlint')
}
}
Expand Down
113 changes: 0 additions & 113 deletions checkstyle.xml

This file was deleted.

5 changes: 0 additions & 5 deletions epoxy-annotations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ mavenPublish {
sourceCompatibility = rootProject.JAVA_SOURCE_VERSION
targetCompatibility = rootProject.JAVA_TARGET_VERSION

checkstyle {
configFile rootProject.file('checkstyle.xml')
showViolations true
}

dependencies {
implementation rootProject.deps.androidAnnotations
// Allow us to use android support library annotations (@LayoutRes) in this project.
Expand Down
5 changes: 0 additions & 5 deletions epoxy-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,3 @@ dependencies {

testImplementation rootProject.deps.junit
}

checkstyle {
configFile rootProject.file('checkstyle.xml')
showViolations true
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Memoizer(
getTypeMirror(ClassNames.ANDROID_VIEW, elements, types)
}

private val methodsReturningClassType = mutableMapOf<Name, List<MethodInfo>>()
private val methodsReturningClassType = mutableMapOf<Name, Set<MethodInfo>>()

fun getMethodsReturningClassType(classType: TypeMirror): List<MethodInfo> =
fun getMethodsReturningClassType(classType: TypeMirror): Set<MethodInfo> =
synchronized(methodsReturningClassType) {
val classElement = types.asElement(classType) as TypeElement
methodsReturningClassType.getOrPut(classElement.qualifiedName) {
Expand All @@ -71,7 +71,7 @@ class Memoizer(
val superClassType = classElement.superclass
superClassType.ensureLoaded()
// Check for base Object class
if (superClassType.kind == TypeKind.NONE) return@getOrPut emptyList()
if (superClassType.kind == TypeKind.NONE) return@getOrPut emptySet()

val methodInfos: List<MethodInfo> =
classElement.enclosedElementsThreadSafe.mapNotNull { subElement ->
Expand Down Expand Up @@ -114,7 +114,10 @@ class Memoizer(
)
}

methodInfos + getMethodsReturningClassType(superClassType)
// Note: Adding super type methods second preserves any overloads in the base
// type that may have changes (ie, a new return type or annotation), since
// Set.plus only adds items that don't already exist.
methodInfos.toSet() + getMethodsReturningClassType(superClassType)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.airbnb.epoxy.processor

import com.squareup.javapoet.ParameterSpec
import com.squareup.javapoet.TypeName
import javax.lang.model.element.ExecutableElement
import javax.lang.model.element.Modifier

Expand All @@ -11,4 +12,28 @@ data class MethodInfo(
val varargs: Boolean,
val isEpoxyAttribute: Boolean,
val methodElement: ExecutableElement
)
) {
private val paramTypes: List<TypeName> get() = params.map { it.type }

// Use an equals/hashcode that matches method signature, but doesn't count non signature
// changes such as annotations, return type, or param names.
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as MethodInfo

if (name != other.name) return false
if (paramTypes != other.paramTypes) return false
if (varargs != other.varargs) return false

return true
}

override fun hashCode(): Int {
var result = name?.hashCode() ?: 0
result = 31 * result + paramTypes.hashCode()
result = 31 * result + varargs.hashCode()
return result
}
}
Loading