Loading api/current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -53464,11 +53464,6 @@ package android.view.inputmethod { package android.view.inspector { public class GeneratedInspectionCompanionProvider implements android.view.inspector.InspectionCompanionProvider { ctor public GeneratedInspectionCompanionProvider(); method @Nullable public <T> android.view.inspector.InspectionCompanion<T> provide(@NonNull Class<T>); } public interface InspectionCompanion<T> { method @Nullable public default String getNodeName(); method public void mapProperties(@NonNull android.view.inspector.PropertyMapper); Loading Loading @@ -53549,6 +53544,11 @@ package android.view.inspector { ctor public PropertyReader.PropertyTypeMismatchException(int, @NonNull String, @NonNull String); } public class StaticInspectionCompanionProvider implements android.view.inspector.InspectionCompanionProvider { ctor public StaticInspectionCompanionProvider(); method @Nullable public <T> android.view.inspector.InspectionCompanion<T> provide(@NonNull Class<T>); } public final class WindowInspector { method @NonNull public static java.util.List<android.view.View> getGlobalWindowViews(); } core/java/android/view/inspector/GeneratedInspectionCompanionProvider.java→core/java/android/view/inspector/StaticInspectionCompanionProvider.java +10 −5 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ import android.annotation.NonNull; import android.annotation.Nullable; /** * An inspection companion provider that loads pre-generated inspection companions * An inspection companion provider that finds companions as inner classes or generated code. * * @see android.processor.view.inspector.PlatformInspectableProcessor */ public class GeneratedInspectionCompanionProvider implements InspectionCompanionProvider { public class StaticInspectionCompanionProvider implements InspectionCompanionProvider { /** * The suffix used for the generated class * The suffix used for the generated classes and inner classes */ private static final String COMPANION_SUFFIX = "$$InspectionCompanion"; private static final String COMPANION_SUFFIX = "$InspectionCompanion"; @Override @Nullable Loading @@ -39,7 +39,12 @@ public class GeneratedInspectionCompanionProvider implements InspectionCompanion try { final Class<InspectionCompanion<T>> companionClass = (Class<InspectionCompanion<T>>) cls.getClassLoader().loadClass(companionName); if (InspectionCompanion.class.isAssignableFrom(companionClass)) { return companionClass.newInstance(); } else { return null; } } catch (ClassNotFoundException e) { return null; } catch (IllegalAccessException e) { Loading tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectionCompanionGenerator.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public final class InspectionCompanionGenerator { /** * The suffix of the generated class name after the class's binary name. */ private static final String GENERATED_CLASS_SUFFIX = "$$InspectionCompanion"; private static final String GENERATED_CLASS_SUFFIX = "$InspectionCompanion"; /** * The null resource ID, copied to avoid a host dependency on platform code. Loading tools/processors/view_inspector/src/java/android/processor/view/inspector/PlatformInspectableProcessor.java +27 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.ElementFilter; /** Loading Loading @@ -127,12 +128,37 @@ public final class PlatformInspectableProcessor extends AbstractProcessor { final InspectableClassModel model = modelMap.computeIfAbsent( classElement.get().getQualifiedName().toString(), k -> new InspectableClassModel(ClassName.get(classElement.get()))); k -> { if (hasNestedInspectionCompanion(classElement.get())) { fail( String.format( "Class %s already has an inspection companion.", classElement.get().getQualifiedName().toString()), element); } return new InspectableClassModel(ClassName.get(classElement.get())); }); processor.process(element, model); } } /** * Determine if a class has a nested class named {@code InspectionCompanion}. * * @param typeElement A type element representing the class to check * @return f the class contains a class named {@code InspectionCompanion} */ private static boolean hasNestedInspectionCompanion(TypeElement typeElement) { for (TypeElement nestedClass : ElementFilter.typesIn(typeElement.getEnclosedElements())) { if (nestedClass.getSimpleName().toString().equals("InspectionCompanion")) { return true; } } return false; } /** * Get the nearest enclosing class if there is one. * Loading tools/processors/view_inspector/test/resources/android/processor/view/inspector/InspectionCompanionGeneratorTest/FieldProperty.java.txt +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import java.lang.Override; * Generated by {@link android.processor.view.inspector.InspectionCompanionGenerator} * on behalf of {@link android.processor.view.inspector.InspectionCompanionGeneratorTest}. */ public final class TestNode$$InspectionCompanion implements InspectionCompanion<TestNode> { public final class TestNode$InspectionCompanion implements InspectionCompanion<TestNode> { /** * Set by {@link #mapProperties(PropertyMapper)} once properties have been mapped. */ Loading Loading
api/current.txt +5 −5 Original line number Diff line number Diff line Loading @@ -53464,11 +53464,6 @@ package android.view.inputmethod { package android.view.inspector { public class GeneratedInspectionCompanionProvider implements android.view.inspector.InspectionCompanionProvider { ctor public GeneratedInspectionCompanionProvider(); method @Nullable public <T> android.view.inspector.InspectionCompanion<T> provide(@NonNull Class<T>); } public interface InspectionCompanion<T> { method @Nullable public default String getNodeName(); method public void mapProperties(@NonNull android.view.inspector.PropertyMapper); Loading Loading @@ -53549,6 +53544,11 @@ package android.view.inspector { ctor public PropertyReader.PropertyTypeMismatchException(int, @NonNull String, @NonNull String); } public class StaticInspectionCompanionProvider implements android.view.inspector.InspectionCompanionProvider { ctor public StaticInspectionCompanionProvider(); method @Nullable public <T> android.view.inspector.InspectionCompanion<T> provide(@NonNull Class<T>); } public final class WindowInspector { method @NonNull public static java.util.List<android.view.View> getGlobalWindowViews(); }
core/java/android/view/inspector/GeneratedInspectionCompanionProvider.java→core/java/android/view/inspector/StaticInspectionCompanionProvider.java +10 −5 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ import android.annotation.NonNull; import android.annotation.Nullable; /** * An inspection companion provider that loads pre-generated inspection companions * An inspection companion provider that finds companions as inner classes or generated code. * * @see android.processor.view.inspector.PlatformInspectableProcessor */ public class GeneratedInspectionCompanionProvider implements InspectionCompanionProvider { public class StaticInspectionCompanionProvider implements InspectionCompanionProvider { /** * The suffix used for the generated class * The suffix used for the generated classes and inner classes */ private static final String COMPANION_SUFFIX = "$$InspectionCompanion"; private static final String COMPANION_SUFFIX = "$InspectionCompanion"; @Override @Nullable Loading @@ -39,7 +39,12 @@ public class GeneratedInspectionCompanionProvider implements InspectionCompanion try { final Class<InspectionCompanion<T>> companionClass = (Class<InspectionCompanion<T>>) cls.getClassLoader().loadClass(companionName); if (InspectionCompanion.class.isAssignableFrom(companionClass)) { return companionClass.newInstance(); } else { return null; } } catch (ClassNotFoundException e) { return null; } catch (IllegalAccessException e) { Loading
tools/processors/view_inspector/src/java/android/processor/view/inspector/InspectionCompanionGenerator.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public final class InspectionCompanionGenerator { /** * The suffix of the generated class name after the class's binary name. */ private static final String GENERATED_CLASS_SUFFIX = "$$InspectionCompanion"; private static final String GENERATED_CLASS_SUFFIX = "$InspectionCompanion"; /** * The null resource ID, copied to avoid a host dependency on platform code. Loading
tools/processors/view_inspector/src/java/android/processor/view/inspector/PlatformInspectableProcessor.java +27 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.ElementFilter; /** Loading Loading @@ -127,12 +128,37 @@ public final class PlatformInspectableProcessor extends AbstractProcessor { final InspectableClassModel model = modelMap.computeIfAbsent( classElement.get().getQualifiedName().toString(), k -> new InspectableClassModel(ClassName.get(classElement.get()))); k -> { if (hasNestedInspectionCompanion(classElement.get())) { fail( String.format( "Class %s already has an inspection companion.", classElement.get().getQualifiedName().toString()), element); } return new InspectableClassModel(ClassName.get(classElement.get())); }); processor.process(element, model); } } /** * Determine if a class has a nested class named {@code InspectionCompanion}. * * @param typeElement A type element representing the class to check * @return f the class contains a class named {@code InspectionCompanion} */ private static boolean hasNestedInspectionCompanion(TypeElement typeElement) { for (TypeElement nestedClass : ElementFilter.typesIn(typeElement.getEnclosedElements())) { if (nestedClass.getSimpleName().toString().equals("InspectionCompanion")) { return true; } } return false; } /** * Get the nearest enclosing class if there is one. * Loading
tools/processors/view_inspector/test/resources/android/processor/view/inspector/InspectionCompanionGeneratorTest/FieldProperty.java.txt +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import java.lang.Override; * Generated by {@link android.processor.view.inspector.InspectionCompanionGenerator} * on behalf of {@link android.processor.view.inspector.InspectionCompanionGeneratorTest}. */ public final class TestNode$$InspectionCompanion implements InspectionCompanion<TestNode> { public final class TestNode$InspectionCompanion implements InspectionCompanion<TestNode> { /** * Set by {@link #mapProperties(PropertyMapper)} once properties have been mapped. */ Loading