Fix some Java Lint naming errors
This is a pure naming change made by find/replace in bash.
The current binary resources system is transliterated from C++ code, and
changes often trigger Lint errors.
Long-term the naming and spacing should be updated to follow Java
conventions.
diff --git a/resources/src/main/java/org/robolectric/res/android/Chunk.java b/resources/src/main/java/org/robolectric/res/android/Chunk.java
index c16ae34..71e19e9 100644
--- a/resources/src/main/java/org/robolectric/res/android/Chunk.java
+++ b/resources/src/main/java/org/robolectric/res/android/Chunk.java
@@ -7,12 +7,12 @@
import java.nio.ByteBuffer;
import org.robolectric.res.android.ResourceTypes.ResChunk_header;
import org.robolectric.res.android.ResourceTypes.ResStringPool_header;
+import org.robolectric.res.android.ResourceTypes.ResTableStagedAliasEntry;
+import org.robolectric.res.android.ResourceTypes.ResTableStagedAliasHeader;
import org.robolectric.res.android.ResourceTypes.ResTable_header;
import org.robolectric.res.android.ResourceTypes.ResTable_lib_entry;
import org.robolectric.res.android.ResourceTypes.ResTable_lib_header;
import org.robolectric.res.android.ResourceTypes.ResTable_package;
-import org.robolectric.res.android.ResourceTypes.ResTable_staged_alias_entry;
-import org.robolectric.res.android.ResourceTypes.ResTable_staged_alias_header;
import org.robolectric.res.android.ResourceTypes.ResTable_type;
import org.robolectric.res.android.ResourceTypes.WithOffset;
@@ -121,17 +121,17 @@
}
}
- public ResTable_staged_alias_header asResTable_staged_alias_header() {
- if (header_size() >= ResTable_staged_alias_header.SIZEOF) {
- return new ResTable_staged_alias_header(device_chunk_.myBuf(), device_chunk_.myOffset());
+ public ResTableStagedAliasHeader asResTableStagedAliasHeader() {
+ if (header_size() >= ResTableStagedAliasHeader.SIZEOF) {
+ return new ResTableStagedAliasHeader(device_chunk_.myBuf(), device_chunk_.myOffset());
} else {
return null;
}
}
- public ResTable_staged_alias_entry asResTable_staged_alias_entry() {
- if (data_size() >= ResTable_staged_alias_entry.SIZEOF) {
- return new ResTable_staged_alias_entry(
+ public ResTableStagedAliasEntry asResTableStagedAliasEntry() {
+ if (data_size() >= ResTableStagedAliasEntry.SIZEOF) {
+ return new ResTableStagedAliasEntry(
device_chunk_.myBuf(), device_chunk_.myOffset() + header_size());
} else {
return null;
diff --git a/resources/src/main/java/org/robolectric/res/android/CppAssetManager2.java b/resources/src/main/java/org/robolectric/res/android/CppAssetManager2.java
index 71593cd..c65bfd1 100644
--- a/resources/src/main/java/org/robolectric/res/android/CppAssetManager2.java
+++ b/resources/src/main/java/org/robolectric/res/android/CppAssetManager2.java
@@ -350,7 +350,7 @@
// that compile against the framework.
for (ConfiguredPackage pkg : iter.packages_) {
for (Map.Entry<Integer, Integer> entry :
- pkg.loaded_package_.GetAliasResourceIdMap().entrySet()) {
+ pkg.loaded_package_.getAliasResourceIdMap().entrySet()) {
iter2.dynamic_ref_table.addAlias(entry.getKey(), entry.getValue());
}
}
diff --git a/resources/src/main/java/org/robolectric/res/android/DynamicRefTable.java b/resources/src/main/java/org/robolectric/res/android/DynamicRefTable.java
index 5d66236..0604116 100644
--- a/resources/src/main/java/org/robolectric/res/android/DynamicRefTable.java
+++ b/resources/src/main/java/org/robolectric/res/android/DynamicRefTable.java
@@ -102,11 +102,11 @@
int res = resId.get();
int packageId = Res_GETPACKAGE(res) + 1;
- Integer alias_id = mAliasId.get(res);
- if (alias_id != null) {
+ Integer aliasId = mAliasId.get(res);
+ if (aliasId != null) {
// Rewrite the resource id to its alias resource id. Since the alias resource id is a
// compile-time id, it still needs to be resolved further.
- res = alias_id;
+ res = aliasId;
}
if (packageId == SYS_PACKAGE_ID || (packageId == APP_PACKAGE_ID && !mAppAsLib)) {
diff --git a/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java b/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java
index 61f75a6..f682b9f 100644
--- a/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java
+++ b/resources/src/main/java/org/robolectric/res/android/LoadedArsc.java
@@ -29,6 +29,8 @@
import org.robolectric.res.android.Idmap.LoadedIdmap;
import org.robolectric.res.android.ResourceTypes.IdmapEntry_header;
import org.robolectric.res.android.ResourceTypes.ResStringPool_header;
+import org.robolectric.res.android.ResourceTypes.ResTableStagedAliasEntry;
+import org.robolectric.res.android.ResourceTypes.ResTableStagedAliasHeader;
import org.robolectric.res.android.ResourceTypes.ResTable_entry;
import org.robolectric.res.android.ResourceTypes.ResTable_header;
import org.robolectric.res.android.ResourceTypes.ResTable_lib_entry;
@@ -37,8 +39,6 @@
import org.robolectric.res.android.ResourceTypes.ResTable_map_entry;
import org.robolectric.res.android.ResourceTypes.ResTable_package;
import org.robolectric.res.android.ResourceTypes.ResTable_sparseTypeEntry;
-import org.robolectric.res.android.ResourceTypes.ResTable_staged_alias_entry;
-import org.robolectric.res.android.ResourceTypes.ResTable_staged_alias_header;
import org.robolectric.res.android.ResourceTypes.ResTable_type;
import org.robolectric.res.android.ResourceTypes.ResTable_typeSpec;
import org.robolectric.res.android.ResourceTypes.Res_value;
@@ -370,7 +370,7 @@
// };
final Map<Integer, TypeSpec> type_specs_ = new HashMap<>();
final List<DynamicPackageEntry> dynamic_package_map_ = new ArrayList<>();
- final Map<Integer, Integer> alias_id_map_ = new HashMap<>();
+ final Map<Integer, Integer> aliasIdMap = new HashMap<>();
ResTable_entry GetEntry(ResTable_type type_chunk,
short entry_index) {
@@ -729,30 +729,30 @@
// loaded_package.dynamic_package_map_.reserve(dtohl(lib.count));
- // ResTable_lib_entry entry_begin =
+ // ResTable_lib_entry entryBegin =
// reinterpret_cast<ResTable_lib_entry*>(child_chunk.data_ptr());
- ResTable_lib_entry entry_begin =
+ ResTable_lib_entry entryBegin =
child_chunk.asResTable_lib_entry();
- // ResTable_lib_entry entry_end = entry_begin + dtohl(lib.count);
- // for (auto entry_iter = entry_begin; entry_iter != entry_end; ++entry_iter) {
- for (ResTable_lib_entry entry_iter = entry_begin;
- entry_iter.myOffset() != entry_begin.myOffset() + dtohl(lib.count);
- entry_iter = new ResTable_lib_entry(entry_iter.myBuf(), entry_iter.myOffset() + ResTable_lib_entry.SIZEOF)) {
+ // ResTable_lib_entry entry_end = entryBegin + dtohl(lib.count);
+ // for (auto entryIter = entryBegin; entryIter != entry_end; ++entryIter) {
+ for (ResTable_lib_entry entryIter = entryBegin;
+ entryIter.myOffset() != entryBegin.myOffset() + dtohl(lib.count);
+ entryIter = new ResTable_lib_entry(entryIter.myBuf(), entryIter.myOffset() + ResTable_lib_entry.SIZEOF)) {
String package_name =
- Util.ReadUtf16StringFromDevice(entry_iter.packageName,
- entry_iter.packageName.length);
+ Util.ReadUtf16StringFromDevice(entryIter.packageName,
+ entryIter.packageName.length);
- if (dtohl(entry_iter.packageId) >= 255) {
+ if (dtohl(entryIter.packageId) >= 255) {
logError(String.format(
"Package ID %02x in RES_TABLE_LIBRARY_TYPE too large for package '%s'.",
- dtohl(entry_iter.packageId), package_name));
+ dtohl(entryIter.packageId), package_name));
return emptyBraces();
}
// loaded_package.dynamic_package_map_.emplace_back(std.move(package_name),
- // dtohl(entry_iter.packageId));
+ // dtohl(entryIter.packageId));
loaded_package.dynamic_package_map_.add(new DynamicPackageEntry(package_name,
- dtohl(entry_iter.packageId)));
+ dtohl(entryIter.packageId)));
}
} break;
@@ -767,52 +767,52 @@
break;
}
- ResTable_staged_alias_header lib_alias = child_chunk.asResTable_staged_alias_header();
- if (lib_alias == null) {
+ ResTableStagedAliasHeader libAlias = child_chunk.asResTableStagedAliasHeader();
+ if (libAlias == null) {
logError("RES_TABLE_STAGED_ALIAS_TYPE is too small.");
return emptyBraces();
}
- if ((child_chunk.data_size() / ResTable_staged_alias_entry.SIZEOF)
- < dtohl(lib_alias.count)) {
+ if ((child_chunk.data_size() / ResTableStagedAliasEntry.SIZEOF)
+ < dtohl(libAlias.count)) {
logError("RES_TABLE_STAGED_ALIAS_TYPE is too small to hold entries.");
return emptyBraces();
}
- // const auto entry_begin =
- // child_chunk.data_ptr().convert<ResTable_staged_alias_entry>();
- // const auto entry_end = entry_begin + dtohl(lib_alias.count);
- ResTable_staged_alias_entry entry_begin = child_chunk.asResTable_staged_alias_entry();
- int entry_end_offset =
- entry_begin.myOffset()
- + dtohl(lib_alias.count) * ResTable_staged_alias_entry.SIZEOF;
- // std::unordered_set<uint32_t> finalized_ids;
- // finalized_ids.reserve(entry_end - entry_begin);
- Set<Integer> finalized_ids = new HashSet<>();
- for (ResTable_staged_alias_entry entry_iter = entry_begin;
- entry_iter.myOffset() != entry_end_offset;
- entry_iter =
- new ResTable_staged_alias_entry(
- entry_iter.myBuf(),
- entry_iter.myOffset() + ResTable_staged_alias_entry.SIZEOF)) {
+ // const auto entryBegin =
+ // child_chunk.data_ptr().convert<ResTableStagedAliasEntry>();
+ // const auto entry_end = entryBegin + dtohl(libAlias.count);
+ ResTableStagedAliasEntry entryBegin = child_chunk.asResTableStagedAliasEntry();
+ int entryEndOffset =
+ entryBegin.myOffset()
+ + dtohl(libAlias.count) * ResTableStagedAliasEntry.SIZEOF;
+ // std::unordered_set<uint32_t> finalizedIds;
+ // finalizedIds.reserve(entry_end - entryBegin);
+ Set<Integer> finalizedIds = new HashSet<>();
+ for (ResTableStagedAliasEntry entryIter = entryBegin;
+ entryIter.myOffset() != entryEndOffset;
+ entryIter =
+ new ResTableStagedAliasEntry(
+ entryIter.myBuf(),
+ entryIter.myOffset() + ResTableStagedAliasEntry.SIZEOF)) {
- int finalized_id = dtohl(entry_iter.finalizedResId);
- // if (!finalized_ids.insert(finalized_id).second) {
- if (!finalized_ids.add(finalized_id)) {
+ int finalizedId = dtohl(entryIter.finalizedResId);
+ // if (!finalizedIds.insert(finalizedId).second) {
+ if (!finalizedIds.add(finalizedId)) {
logError(
String.format(
"Repeated finalized resource id '%08x' in staged aliases.",
- finalized_id));
+ finalizedId));
return emptyBraces();
}
- int staged_id = dtohl(entry_iter.stagedResId);
- // auto [_, success] = loaded_package->alias_id_map_.emplace(staged_id,
- // finalized_id);
- Integer previousValue = loaded_package.alias_id_map_.put(staged_id, finalized_id);
+ int stagedId = dtohl(entryIter.stagedResId);
+ // auto [_, success] = loaded_package->aliasIdMap.emplace(stagedId,
+ // finalizedId);
+ Integer previousValue = loaded_package.aliasIdMap.put(stagedId, finalizedId);
if (previousValue != null) {
logError(
String.format(
- "Repeated staged resource id '%08x' in staged aliases.", staged_id));
+ "Repeated staged resource id '%08x' in staged aliases.", stagedId));
return emptyBraces();
}
}
@@ -922,8 +922,8 @@
}
}
- Map<Integer, Integer> GetAliasResourceIdMap() {
- return alias_id_map_;
+ Map<Integer, Integer> getAliasResourceIdMap() {
+ return aliasIdMap;
}
private static LoadedPackage emptyBraces() {
diff --git a/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java b/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java
index a5375bb..83d8a1e 100644
--- a/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java
+++ b/resources/src/main/java/org/robolectric/res/android/ResourceTypes.java
@@ -1508,15 +1508,15 @@
* A map that allows rewriting staged (non-finalized) resource ids to their finalized
* counterparts.
*/
- static class ResTable_staged_alias_header extends WithOffset {
+ static class ResTableStagedAliasHeader extends WithOffset {
public static final int SIZEOF = ResChunk_header.SIZEOF + 4;
ResChunk_header header;
- // The number of ResTable_staged_alias_entry that follow this header.
+ // The number of ResTableStagedAliasEntry that follow this header.
int count;
- ResTable_staged_alias_header(ByteBuffer buf, int offset) {
+ ResTableStagedAliasHeader(ByteBuffer buf, int offset) {
super(buf, offset);
header = new ResChunk_header(buf, offset);
@@ -1525,7 +1525,7 @@
}
/** Maps the staged (non-finalized) resource id to its finalized resource id. */
- static class ResTable_staged_alias_entry extends WithOffset {
+ static class ResTableStagedAliasEntry extends WithOffset {
public static final int SIZEOF = 8;
// The compile-time staged resource id to rewrite.
@@ -1534,7 +1534,7 @@
// The compile-time finalized resource id to which the staged resource id should be rewritten.
int finalizedResId;
- ResTable_staged_alias_entry(ByteBuffer buf, int offset) {
+ ResTableStagedAliasEntry(ByteBuffer buf, int offset) {
super(buf, offset);
stagedResId = buf.getInt(offset);
diff --git a/resources/src/test/java/org/robolectric/res/android/LoadedArscTest.java b/resources/src/test/java/org/robolectric/res/android/LoadedArscTest.java
index 4e12890..73fedea 100644
--- a/resources/src/test/java/org/robolectric/res/android/LoadedArscTest.java
+++ b/resources/src/test/java/org/robolectric/res/android/LoadedArscTest.java
@@ -44,12 +44,12 @@
(short) RES_TABLE_STAGED_ALIAS_TYPE,
() -> {
// header
- buf.putInt(1); // ResTable_staged_alias_header.count
+ buf.putInt(1); // ResTableStagedAliasHeader.count
},
() -> {
// contents
- buf.putInt(stagedResId); // ResTable_staged_alias_entry.stagedResId
- buf.putInt(finalizedResId); // ResTable_staged_alias_entry.finalizedResId
+ buf.putInt(stagedResId); // ResTableStagedAliasEntry.stagedResId
+ buf.putInt(finalizedResId); // ResTableStagedAliasEntry.finalizedResId
});
});
final Chunk chunk = new Chunk(new ResChunk_header(buf, 0));
@@ -57,7 +57,7 @@
LoadedArsc.LoadedPackage.Load(
chunk, null /* loaded_idmap */, true /* system */, false /* load_as_shared_library */);
- final Map<Integer, Integer> aliasIdMap = loadedPackage.GetAliasResourceIdMap();
+ final Map<Integer, Integer> aliasIdMap = loadedPackage.getAliasResourceIdMap();
assertEquals(finalizedResId, (int) aliasIdMap.get(stagedResId));
}
}