Parcelable, Lint: Do not report "CREATOR field missing" warnings on our '@Parselize' Parcelables

This commit is contained in:
Yan Zhulanow
2017-07-31 16:23:43 +03:00
parent c1600c9841
commit 448fa8495a
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -14,5 +14,6 @@
<orderEntry type="library" name="guava" level="project" />
<orderEntry type="library" name="intellij-core" level="project" />
<orderEntry type="library" name="kotlin-runtime" level="project" />
<orderEntry type="module" module-name="android-extensions-runtime" />
</component>
</module>
@@ -33,6 +33,7 @@ import com.intellij.psi.PsiField;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.util.InheritanceUtil;
import kotlinx.android.parcel.Parcelize;
import org.jetbrains.uast.UAnonymousClass;
import org.jetbrains.uast.UClass;
@@ -94,6 +95,11 @@ public class ParcelDetector extends Detector implements Detector.UastScanner {
return;
}
// Do not report errors on our Android Extensions-improved Parcelables
if (declaration.findAnnotation(Parcelize.class.getName()) != null) {
return;
}
PsiField field = declaration.findFieldByName("CREATOR", false);
if (field == null) {
Location location = context.getUastNameLocation(declaration);