Skip over inter-section blank space when annotating

This commit is contained in:
Ben Gruver 2013-02-24 17:10:29 -08:00
parent df443569f2
commit 658dfb0880
2 changed files with 18 additions and 0 deletions

View File

@ -259,9 +259,11 @@ public abstract class DexBackedDexFile extends BaseDexBuffer implements DexFile
AnnotatedBytes annotatedBytes = new AnnotatedBytes(width);
HeaderItem.getAnnotator().annotateSection(annotatedBytes, this, 1);
annotatedBytes.skipTo(getStringIdItemOffset(0));
annotatedBytes.annotate(0, " ");
StringIdItem.getAnnotator().annotateSection(annotatedBytes, this, stringCount);
annotatedBytes.skipTo(getTypeIdItemOffset(0));
annotatedBytes.annotate(0, " ");
TypeIdItem.getAnnotator().annotateSection(annotatedBytes, this, typeCount);

View File

@ -61,6 +61,22 @@ public class AnnotatedBytes {
this.outputWidth = width;
}
/**
* Skips a portion of the binary output. This is equivalent to calling
* annotate(offset-cursor, "");
*
* @param offset The offset to skip to
*/
public void skipTo(int offset) {
if (offset < cursor) {
throw new IllegalArgumentException("skipTo can only skip forward");
}
int delta = offset - cursor;
if (delta != 0) {
annotate(delta, "");
}
}
/**
* Add an annotation of the given length at the current location.
*