grab / grab-bazel-common

Common rules and macros for Grab's Android projects built with Bazel.
https://grab.github.io/grazel
Apache License 2.0
39 stars 15 forks source link

List of custom type not imported in generated binding #61

Closed pswaminathan closed 1 year ago

pswaminathan commented 2 years ago

Repro here. I see in bazel-out/android-armeabi-v7a-fastbuild/bin/app/_javac/app_lib-kotlin/app_lib-kotlin-java_tmp/com/example/databinding/lib/databinding (note the lack of imports):

package com.example.databinding.lib.databinding;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.Bindable;
import androidx.databinding.ViewDataBinding;
import java.lang.Object;

public abstract class ActivityMainBinding extends ViewDataBinding {
  @Bindable
  protected int mItem;

  @Bindable
  protected Object mItemContext;

  @Bindable
  protected List<MyModel> mMyObjects;

  @Bindable
  protected int mPosition;

  @Bindable
  protected int mVisibility;

  protected ActivityMainBinding(Object _bindingComponent, View _root, int _localFieldCount) {
    super(_bindingComponent, _root, _localFieldCount);
  }

  @NonNull
  public static ActivityMainBinding bind(View view) {
    throw new RuntimeException("Stub!");
  }

  @NonNull
  public static ActivityMainBinding bind(View view, Object component) {
    throw new RuntimeException("Stub!");
  }

  @Nullable
  public int getItem() {
    throw new RuntimeException("Stub!");
  }

  @Nullable
  public Object getItemContext() {
    throw new RuntimeException("Stub!");
  }

  @Nullable
  public List<MyModel> getMyObjects() {
    throw new RuntimeException("Stub!");
  }

  @Nullable
  public int getPosition() {
    throw new RuntimeException("Stub!");
  }

  @Nullable
  public int getVisibility() {
    throw new RuntimeException("Stub!");
  }

  @NonNull
  public static ActivityMainBinding inflate(LayoutInflater inflater) {
    throw new RuntimeException("Stub!");
  }

  @NonNull
  public static ActivityMainBinding inflate(LayoutInflater inflater, ViewGroup root,
      boolean attachToRoot) {
    throw new RuntimeException("Stub!");
  }

  @NonNull
  public static ActivityMainBinding inflate(LayoutInflater inflater, ViewGroup root,
      boolean attachToRoot, Object component) {
    throw new RuntimeException("Stub!");
  }

  public abstract void setItem(int var1);

  public abstract void setItemContext(Object var1);

  public abstract void setMyObjects(List<MyModel> var1);

  public abstract void setPosition(int var1);

  public abstract void setVisibility(int var1);
}
pswaminathan commented 2 years ago

I added a line to dump all the bindings, and I'm seeing:

INFO: From DatabindingStubs @//app:app_lib-stubs:
[...Binding(rawName=myObjects, typeName=List<MyModel>, name=myObjects, bindingType=com.grab.databinding.stub.binding.parser.BindingType$Variable@34f654c)]
...

That is, it's showing type as List<MyModel>, not java.util.List<com.example.otherpkg.MyModel>. This looks like it might have something to do with this discussion