History log of /external/robolectric-shadows/robolectric/src/test/java/org/robolectric/lib3/R.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
04435496a32c21967f07cfa0621e3cc5f166f41d 23-Jan-2017 Jonathan Gerrish <jonathan@indiekid.rg> Assign resource IDs eagerly when the resources are written into the table, either by using the R values written in previously or by generating them where they are missing instead of generating them on a query. This had the sideeffect of erroneously generating resource ids where the resources didn't exist making debugging harder and a subtle source of bugs.

Correct hand rolled R files to use attribute suffices that correspond to real attr values.

Switch resource tests to use latest version of android resources rather than min version.
/external/robolectric-shadows/robolectric/src/test/java/org/robolectric/lib3/R.java
6a7bdc7a1b1fbe38142995bde5f05023b8ab86ad 29-Dec-2016 Jonathan Gerrish <jonathan@indiekid.rg> Refactor Robolectric resource handling to move from a hierarchy of ResourceLoaders + ResourceIndexes that provided a virtualized view of resource merging to separate the concerns into a single flat ResourceTable per package with the merging functionality externalized to a ResourceMerger. This models the resource table in the same way that Android does with its arsc tables. Externalizing the loading + id to name mapping this way simplifies the path forward to loading pre-merged resources for build systems that support this, or even loading resources from arsc files directly.

Here is a description of follow up refactor I recommend: Since Android deals with resource ids rather than names for all of its APIs (other than Resources.getIdentifier(String type, String name, String package) it seems logical to refactor ResourceTable to look up via resId rather than ResName, which would also enable us to address the remaining style look up corner case bug (Styles build from the app at compiletime have a ResName but we're not able to look that ID up from the runtime frameworks ResourceTable) see rollback" https://github.com/robolectric/robolectric/pull/2756/files. In this model we would move to having resources keyed by int resId in the ResourceTable rather than ResName which should reduce the number of id to name to id lookups we are currently doing. We could consider some optimizations like using a SparseArray of ints rather than a Map of Integer object references if we deemed it worthwhile. This would remove the need for ResourceIndex entirely as this logic would be handled entirely by the resource id / remapping generation introduced in this change for existing Maven like builds. For builds that already provide resource merging and final R value generation or even just reading the arsc file directly none of this would even required.

Tighten up the resource loading / merging to forbid duplicate resource name to id mappings which was a cause of subtle bugs.
Inline existing usages of ResourceParser class (which was not a ResourceParser) so the class name can be reused.
ResourcePath no longer has a package name since package name is a single package name for the application rather than related to resource directories which should be considered as simple overlays.
Remove MergedResourceIndex + OverlayResourceIndex as ResourceIndex is now merged at construction time (see ResourceMerger)
Remove OverlayResourceLoader as ResourceLoader (now ResourceTable) is merged at construction time
PackageResourceIndex is a single flat ResourceIndex for a given package (String name + int package identifier, PP from PPTTEEEE) of which two exist in standard Android apps 0x01 / "android" +0x7F / "com.someapplication". On Android it is possible to load shared resources from another APK but Robolectric hasn't supported this as yet. PackageResourceIndex is now far more strict forbidding resources with mixed PP identifiers or duplicate name / id mappings (Uses a BiMap to enforce this)
Remove PackageResourceLoader + RoutingResourceLoader since there is now a single flat ResourceTable
Remove now unused makeImmutable() + mergeLibraryStyle() methods from ResBunch + ResBundle
ResourceExtractor has been replaced with by PackageResourceIndex and now just populates the PackageResourceIndex from the R classes.
Create new class ResourceIdGenerator which will generate resource identifiers for a given type. In Android AAPT assigns a type identifer, TT in PPTTEEEE on an as-seen basis, starting at 0x00, that is a particular type identifier is not stable across builds and the same is true with the entry identifier, EEEE in PPTTEEEE starting at 0x0000. This class keeps track of the next free entry identifier for each type, and the next free type identifier.
Expand ResourceIds utility class to provide other useful methods to extract package, type and entry identifiers from a complete resource id.
Create new class ResourceMerger which now performs the merging logic since we now have flat resource tables.
Create new class ResourceParser which performs the functionality of loading resources from XML files into a flat ResourceTable.
Unused class ResourceRemapper is now used and has been re-written to behave in the same way as AAPT. It allows final classes if requested, this would only be the final top level application R class and if so will use the ID values already asigned in this class. For all other calls final R files are forbidden as these would be library R files and as such should not have final fields lest the values be inline by the compiler. ResourceRemapper uses the ResourceIdGenerator to provide unique TT + EEEE identifers for each new encountered type and entry.
XResourceLoader becomes ResourceTable a single flat resource table for all resources in a package (currently only "android" or "com.myapp")
Create RoutingResourceIndex, simply routes to the correct ResourceIndex based on either the integer package identifer or String name.
Re-write all hand crafted R files to have the correct format PPTTEEEE and be in the application package space (0x7F) - also include resource clashes to simulate AAPT not having regenerated the final R values.
/external/robolectric-shadows/robolectric/src/test/java/org/robolectric/lib3/R.java
7cb2faa35d4f3f158989b7bb72124996d22b9abb 26-Aug-2014 Fr Jeremy Krieg <fr.jeremy@stnectarios.org.au> Imported rap into the robolectric respository as submodule robolectric-processor.
Refactored to move core into robolectric submodule and robolectric-annotations as common, with robolectric-parent as the parent POM for all submodules.
/external/robolectric-shadows/robolectric/src/test/java/org/robolectric/lib3/R.java