GP-5742 Cleanup preferred CommentType enum use. Changed SARIF data component comment JSON serialization from int to String.

This commit is contained in:
ghidra1 2025-06-06 17:58:07 -04:00
parent 4a65e9af3b
commit 8c441250f5
211 changed files with 4627 additions and 4860 deletions

View file

@ -52,7 +52,7 @@ public class DiffApplyMergeTest extends DiffApplyTestAdapter {
assertEquals(origDiffs.subtract(as), diffPlugin.getDiffHighlightSelection());
Listing listing = program.getListing();
CodeUnit cu = listing.getCodeUnitAt(addr("100415a"));
assertEquals("This is my function for testing diff", cu.getComment(CodeUnit.PLATE_COMMENT));
assertEquals("This is my function for testing diff", cu.getComment(CommentType.PLATE));
}
@Test
@ -68,7 +68,7 @@ public class DiffApplyMergeTest extends DiffApplyTestAdapter {
assertEquals(origDiffs, diffPlugin.getDiffHighlightSelection());
Listing listing = program.getListing();
CodeUnit cu = listing.getCodeUnitAt(addr("1002395"));
assertEquals("Pre: Program1\nPre: Program2", cu.getComment(CodeUnit.PRE_COMMENT));
assertEquals("Pre: Program1\nPre: Program2", cu.getComment(CommentType.PRE));
}
@Test
@ -84,7 +84,7 @@ public class DiffApplyMergeTest extends DiffApplyTestAdapter {
assertEquals(origDiffs, diffPlugin.getDiffHighlightSelection());
Listing listing = program.getListing();
CodeUnit cu = listing.getCodeUnitAt(addr("100238f"));
assertEquals("EOL: Program1\nEOL: Program2", cu.getComment(CodeUnit.EOL_COMMENT));
assertEquals("EOL: Program1\nEOL: Program2", cu.getComment(CommentType.EOL));
}
@Test
@ -101,7 +101,7 @@ public class DiffApplyMergeTest extends DiffApplyTestAdapter {
Listing listing = program.getListing();
CodeUnit cu = listing.getCodeUnitAt(addr("1002336"));
assertEquals("ONE: Repeatable comment.\nTWO: Repeatable comment.",
cu.getComment(CodeUnit.REPEATABLE_COMMENT));
cu.getComment(CommentType.REPEATABLE));
}
@Test
@ -117,7 +117,7 @@ public class DiffApplyMergeTest extends DiffApplyTestAdapter {
assertEquals(origDiffs, diffPlugin.getDiffHighlightSelection());
Listing listing = program.getListing();
CodeUnit cu = listing.getCodeUnitAt(addr("100239d"));
assertEquals("Post: Program1\nPost: Program2", cu.getComment(CodeUnit.POST_COMMENT));
assertEquals("Post: Program1\nPost: Program2", cu.getComment(CommentType.POST));
}
/**
@ -173,13 +173,8 @@ public class DiffApplyMergeTest extends DiffApplyTestAdapter {
setDiffSelection(as);
apply();
// Check the results. We should have both tags now in the target program
// (Program 1), so check the number of tags and make sure the names are
// correct.
Iterator<FunctionTag> iter = f1.getTags().iterator();
List<String> tagNames = new ArrayList<>();
while (iter.hasNext()) {
FunctionTag tag = iter.next();
for (FunctionTag tag : f1.getTags()) {
tagNames.add(tag.getName());
}
assertEquals(tagNames.size(), 2);

View file

@ -459,10 +459,10 @@ public class DiffTest extends DiffTestAdapter {
programBuilderDiffTest1.createMemory("d4", "0x400", 0x100);
programBuilderDiffTest2.createMemory("d2", "0x200", 0x100);
programBuilderDiffTest2.createComment("0x01008000", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x01008607", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x01008a99", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x0100a001", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x01008000", "My comment", CommentType.EOL);
programBuilderDiffTest2.createComment("0x01008607", "My comment", CommentType.EOL);
programBuilderDiffTest2.createComment("0x01008a99", "My comment", CommentType.EOL);
programBuilderDiffTest2.createComment("0x0100a001", "My comment", CommentType.EOL);
openDiff(diffTestP1, diffTestP2);
JTree tree = getProgramTree();
@ -528,10 +528,10 @@ public class DiffTest extends DiffTestAdapter {
programBuilderDiffTest1.createMemory("d4", "0x400", 0x100);
programBuilderDiffTest2.createMemory("d2", "0x200", 0x100);
programBuilderDiffTest2.createComment("0x01008000", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x01008607", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x01009943", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x0100a001", "My comment", CodeUnit.EOL_COMMENT);
programBuilderDiffTest2.createComment("0x01008000", "My comment", CommentType.EOL);
programBuilderDiffTest2.createComment("0x01008607", "My comment", CommentType.EOL);
programBuilderDiffTest2.createComment("0x01009943", "My comment", CommentType.EOL);
programBuilderDiffTest2.createComment("0x0100a001", "My comment", CommentType.EOL);
openDiff(diffTestP1, diffTestP2);
JTree tree = getProgramTree();

View file

@ -164,49 +164,49 @@ public class DiffTestAdapter extends AbstractGhidraHeadedIntegrationTest {
builder.createExternalReference("0x01001034", "yourLib.dll", "GetStuff", "0x77f42caa", 0);
// comments
builder.createComment("1002040", "Plate in P1.", CodeUnit.PLATE_COMMENT);
builder.createComment("1002040", "Pre in P1.", CodeUnit.PRE_COMMENT);
builder.createComment("1002040", "EOL in P1.", CodeUnit.EOL_COMMENT);
builder.createComment("1002040", "Repeatable in P1.", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002040", "Post in P1.", CodeUnit.POST_COMMENT);
builder.createComment("1002040", "Plate in P1.", CommentType.PLATE);
builder.createComment("1002040", "Pre in P1.", CommentType.PRE);
builder.createComment("1002040", "EOL in P1.", CommentType.EOL);
builder.createComment("1002040", "Repeatable in P1.", CommentType.REPEATABLE);
builder.createComment("1002040", "Post in P1.", CommentType.POST);
builder.createComment("1002304", "EOL comment", CodeUnit.EOL_COMMENT);
builder.createComment("1002306", "\"Pre Comment\"", CodeUnit.PRE_COMMENT);
builder.createComment("100230b", "Plate Comment", CodeUnit.PRE_COMMENT);
builder.createComment("100230b", "Post Comment", CodeUnit.PRE_COMMENT);
builder.createComment("100230d", "simple comment", CodeUnit.PRE_COMMENT);
builder.createComment("100230d", "simple comment", CodeUnit.EOL_COMMENT);
builder.createComment("100230d", "simple comment", CodeUnit.POST_COMMENT);
builder.createComment("100230d", "simple comment", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("100230d", "simple comment", CodeUnit.PLATE_COMMENT);
builder.createComment("1002304", "EOL comment", CommentType.EOL);
builder.createComment("1002306", "\"Pre Comment\"", CommentType.PRE);
builder.createComment("100230b", "Plate Comment", CommentType.PRE);
builder.createComment("100230b", "Post Comment", CommentType.PRE);
builder.createComment("100230d", "simple comment", CommentType.PRE);
builder.createComment("100230d", "simple comment", CommentType.EOL);
builder.createComment("100230d", "simple comment", CommentType.POST);
builder.createComment("100230d", "simple comment", CommentType.REPEATABLE);
builder.createComment("100230d", "simple comment", CommentType.PLATE);
builder.createComment("1002312", "\"My comment that the other comment is in.\"",
CodeUnit.PRE_COMMENT);
CommentType.PRE);
builder.createComment("1002312", "My comment that the other comment is in.",
CodeUnit.EOL_COMMENT);
CommentType.EOL);
builder.createComment("1002312", "My comment that the other comment is in.",
CodeUnit.POST_COMMENT);
CommentType.POST);
builder.createComment("1002312", "My comment that the other comment is in.",
CodeUnit.PLATE_COMMENT);
CommentType.PLATE);
builder.createComment("1002336", "ONE: Repeatable comment.", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002336", "ONE: Repeatable comment.", CommentType.REPEATABLE);
builder.createComment("1002346", "Easy as pie.", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002346", "Easy as pie.", CommentType.REPEATABLE);
builder.createComment("1002350", "Once upon a", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002350", "Once upon a", CommentType.REPEATABLE);
builder.createComment("100238f", "EOL: Program1", CodeUnit.EOL_COMMENT);
builder.createComment("100238f", "EOL: Program1", CommentType.EOL);
builder.createComment("1002395", "Pre: Program1", CodeUnit.PRE_COMMENT);
builder.createComment("1002395", "Pre: Program1", CommentType.PRE);
// builder.createComment("100239d", "Plate: Program1", CodeUnit.PLATE_COMMENT);
builder.createComment("100239d", "Post: Program1", CodeUnit.POST_COMMENT);
// builder.createComment("100239d", "Plate: Program1", CommentType.PLATE);
builder.createComment("100239d", "Post: Program1", CommentType.POST);
builder.createComment("10030d2", "FUNCTION", CodeUnit.PLATE_COMMENT);
builder.createComment("10030d2", "FUNCTION", CommentType.PLATE);
builder.createComment("100355f", "This is a function.", CodeUnit.PLATE_COMMENT);
builder.createComment("100355f", "This is a function.", CommentType.PLATE);
builder.createComment("100415a", "This is my function", CodeUnit.PLATE_COMMENT);
builder.createComment("100415a", "This is my function", CommentType.PLATE);
// functions
DataType dt = new ByteDataType();
@ -333,54 +333,50 @@ public class DiffTestAdapter extends AbstractGhidraHeadedIntegrationTest {
// comments
builder.createComment("100204c", "My multi-line plate\ncomment for program2.",
CodeUnit.PLATE_COMMENT);
CommentType.PLATE);
builder.createComment("100204c", "My multi-line pre\ncomment for program2.",
CodeUnit.PRE_COMMENT);
CommentType.PRE);
builder.createComment("100204c", "My multi-line EOL\ncomment for program2.",
CodeUnit.EOL_COMMENT);
CommentType.EOL);
builder.createComment("100204c", "My multi-line repeatable\ncomment for program2.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
builder.createComment("100204c", "My multi-line post\ncomment for program2.",
CodeUnit.POST_COMMENT);
CommentType.POST);
builder.createComment("100230d", "This is a simple comment for example.", CommentType.PRE);
builder.createComment("100230d", "This is a simple comment for example.", CommentType.EOL);
builder.createComment("100230d", "This is a simple comment for example.", CommentType.POST);
builder.createComment("100230d", "This is a simple comment for example.",
CodeUnit.PRE_COMMENT);
CommentType.REPEATABLE);
builder.createComment("100230d", "This is a simple comment for example.",
CodeUnit.EOL_COMMENT);
builder.createComment("100230d", "This is a simple comment for example.",
CodeUnit.POST_COMMENT);
builder.createComment("100230d", "This is a simple comment for example.",
CodeUnit.REPEATABLE_COMMENT);
builder.createComment("100230d", "This is a simple comment for example.",
CodeUnit.PLATE_COMMENT);
CommentType.PLATE);
builder.createComment("1002312", "My comment", CodeUnit.PRE_COMMENT);
builder.createComment("1002312", "My comment", CodeUnit.EOL_COMMENT);
builder.createComment("1002312", "My comment", CodeUnit.POST_COMMENT);
builder.createComment("1002312", "My comment", CodeUnit.PLATE_COMMENT);
builder.createComment("1002312", "My comment", CommentType.PRE);
builder.createComment("1002312", "My comment", CommentType.EOL);
builder.createComment("1002312", "My comment", CommentType.POST);
builder.createComment("1002312", "My comment", CommentType.PLATE);
builder.createComment("1002329", "Before the code unit", CodeUnit.PRE_COMMENT);
builder.createComment("1002329", "End of the line.", CodeUnit.EOL_COMMENT);
builder.createComment("1002329", "After the code unit", CodeUnit.POST_COMMENT);
builder.createComment("1002329", "PLATE", CodeUnit.PLATE_COMMENT);
builder.createComment("1002329", "Before the code unit", CommentType.PRE);
builder.createComment("1002329", "End of the line.", CommentType.EOL);
builder.createComment("1002329", "After the code unit", CommentType.POST);
builder.createComment("1002329", "PLATE", CommentType.PLATE);
builder.createComment("1002336", "TWO: Repeatable comment.", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002336", "TWO: Repeatable comment.", CommentType.REPEATABLE);
builder.createComment("1002346", "Easy", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002346", "Easy", CommentType.REPEATABLE);
builder.createComment("1002350", "Once upon a time...", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("1002350", "Once upon a time...", CommentType.REPEATABLE);
builder.createComment("100238f", "EOL: Program2", CodeUnit.EOL_COMMENT);
builder.createComment("100238f", "EOL: Program2", CommentType.EOL);
builder.createComment("1002395", "Pre: Program2", CodeUnit.PRE_COMMENT);
builder.createComment("1002395", "Pre: Program2", CommentType.PRE);
// builder.createComment("100239d", "Plate: Program2", CodeUnit.PLATE_COMMENT);
builder.createComment("100239d", "Post: Program2", CodeUnit.POST_COMMENT);
// builder.createComment("100239d", "Plate: Program2", CommentType.PLATE);
builder.createComment("100239d", "Post: Program2", CommentType.POST);
builder.createComment("1002a91", "FUNCTION", CodeUnit.PLATE_COMMENT);
builder.createComment("1002a91", "FUNCTION", CommentType.PLATE);
builder.createComment("100415a", "This is my function for testing diff",
CodeUnit.PLATE_COMMENT);
builder.createComment("100415a", "This is my function for testing diff", CommentType.PLATE);
// functions
DataType dt = new ByteDataType();