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

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -64,7 +64,7 @@ public class ProgramProviderContext implements DataTypeProviderContext {
if (symbol != null && !symbol.isDynamic()) {
label = symbol.getName();
}
String comment = data.getComment(CodeUnit.EOL_COMMENT);
String comment = data.getComment(CommentType.EOL);
return new DataTypeComponentImpl(dt, null, length, 0, offset, label, comment);
}

View file

@ -20,8 +20,7 @@ import java.util.*;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.*;
import ghidra.program.model.symbol.*;
import ghidra.util.*;
@ -43,7 +42,7 @@ abstract class PseudoCodeUnit implements CodeUnit {
protected final static Reference[] emptyMemRefs = new Reference[0];
protected Map<Integer, String> comments = new HashMap<Integer, String>();
protected Map<CommentType, String> comments = new HashMap<CommentType, String>();
protected ReferenceManager refMgr;
@ -88,8 +87,7 @@ abstract class PseudoCodeUnit implements CodeUnit {
* @param memBuffer the memory buffer where bytes can be obtained for this code unit.
* @throws AddressOverflowException if code unit length causes wrap within space
*/
PseudoCodeUnit(Address addr, int length, MemBuffer memBuffer)
throws AddressOverflowException {
PseudoCodeUnit(Address addr, int length, MemBuffer memBuffer) throws AddressOverflowException {
this(addr, length, length, memBuffer);
}
@ -124,8 +122,8 @@ abstract class PseudoCodeUnit implements CodeUnit {
isValid = true;
}
catch (MemoryAccessException e) {
throw new RuntimeException("Not enough bytes in memory buffer to create code unit: " +
e.getMessage());
throw new RuntimeException(
"Not enough bytes in memory buffer to create code unit: " + e.getMessage());
}
}
@ -479,7 +477,7 @@ abstract class PseudoCodeUnit implements CodeUnit {
}
/**
* Get the code unit after this code unit.
* {@return the code unit after this code unit.}
*
* @throws ConcurrentModificationException
* if this object is no longer valid.
@ -491,10 +489,9 @@ abstract class PseudoCodeUnit implements CodeUnit {
}
/**
* Get the code unit before this code unit.
* {@return the code unit before this code unit.}
*
* @throws ConcurrentModificationException
* if this object is no longer valid.
* @throws ConcurrentModificationException if this object is no longer valid.
*/
public CodeUnit getPreviousCodeUnit() {
if (program == null)
@ -503,7 +500,7 @@ abstract class PseudoCodeUnit implements CodeUnit {
}
@Override
public String getComment(int commentType) {
public String getComment(CommentType commentType) {
return comments.get(commentType);
//throw new UnsupportedOperationException();
}
@ -521,7 +518,7 @@ abstract class PseudoCodeUnit implements CodeUnit {
* if this object is no longer valid.
*/
@Override
public String[] getCommentAsArray(int commentType) {
public String[] getCommentAsArray(CommentType commentType) {
String comment = comments.get(commentType);
if (comment == null)
return new String[0];
@ -544,7 +541,7 @@ abstract class PseudoCodeUnit implements CodeUnit {
* if this object is no longer valid.
*/
@Override
public void setCommentAsArray(int commentType, String comment[]) {
public void setCommentAsArray(CommentType commentType, String comment[]) {
setComment(commentType, comment[0]);
//throw new UnsupportedOperationException();
}
@ -562,34 +559,9 @@ abstract class PseudoCodeUnit implements CodeUnit {
* if this object is no longer valid.
*/
@Override
public void setComment(int commentType, String comment) {
public void setComment(CommentType commentType, String comment) {
comments.put(commentType, comment);
// String oldValue = comments.get(commentType);
comments.put(commentType, comment);
// int changeType;
// switch (commentType) {
// case CodeUnit.EOL_COMMENT:
// changeType = ChangeManager.DOCR_EOL_COMMENT_CHANGED;
// break;
// case CodeUnit.PLATE_COMMENT:
// changeType = ChangeManager.DOCR_PLATE_COMMENT_CHANGED;
// break;
// case CodeUnit.POST_COMMENT:
// changeType = ChangeManager.DOCR_POST_COMMENT_CHANGED;
// break;
// case CodeUnit.PRE_COMMENT:
// changeType = ChangeManager.DOCR_PRE_COMMENT_CHANGED;
// break;
// case CodeUnit.REPEATABLE_COMMENT:
// changeType = ChangeManager.DOCR_REPEATABLE_COMMENT_CHANGED;
// break;
// default:
// changeType = ChangeManager.DOCR_EOL_COMMENT_CHANGED;
// break;
// }
//
// program.setObjChanged(changeType, getMinAddress(), this, oldValue, comment);
//throw new UnsupportedOperationException();
}
/**
@ -768,8 +740,8 @@ abstract class PseudoCodeUnit implements CodeUnit {
ArrayList<Reference> list = new ArrayList<Reference>();
for (int i = 0; i < getNumOperands(); i++) {
Reference[] refs = getOperandReferences(i);
for (int j = 0; j < refs.length; j++) {
list.add(refs[j]);
for (Reference ref : refs) {
list.add(ref);
}
}
return list.toArray(emptyMemRefs);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -40,10 +40,9 @@ class PseudoDataComponent extends PseudoData {
private int[] path;
PseudoDataComponent(Program program, Address address, PseudoData parent,
DataTypeComponent component, MemBuffer memBuffer)
throws AddressOverflowException {
super(program, address, component.getDataType(), new WrappedMemBuffer(memBuffer,
component.getOffset()));
DataTypeComponent component, MemBuffer memBuffer) throws AddressOverflowException {
super(program, address, component.getDataType(),
new WrappedMemBuffer(memBuffer, component.getOffset()));
this.indexInParent = component.getOrdinal();
this.parent = parent;
this.component = component;
@ -170,9 +169,9 @@ class PseudoDataComponent extends PseudoData {
}
@Override
public synchronized String getComment(int commentType) {
public synchronized String getComment(CommentType commentType) {
String cmt = super.getComment(commentType);
if (cmt == null && commentType == CodeUnit.EOL_COMMENT && component != null) {
if (cmt == null && commentType == CommentType.EOL && component != null) {
cmt = component.getComment();
}
return cmt;

View file

@ -480,18 +480,19 @@ class ListingDB implements Listing {
}
@Override
public CommentHistory[] getCommentHistory(Address addr, int commentType) {
public CommentHistory[] getCommentHistory(Address addr, CommentType commentType) {
return codeMgr.getCommentHistory(addr, commentType);
}
@Override
public CodeUnitIterator getCommentCodeUnitIterator(int commentType, AddressSetView addrSet) {
public CodeUnitIterator getCommentCodeUnitIterator(CommentType commentType,
AddressSetView addrSet) {
return codeMgr.getCommentCodeUnitIterator(commentType, addrSet);
}
@Override
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView addrSet,
boolean forward) {
public AddressIterator getCommentAddressIterator(CommentType commentType,
AddressSetView addrSet, boolean forward) {
return codeMgr.getCommentAddressIterator(commentType, addrSet, forward);
}
@ -506,7 +507,7 @@ class ListingDB implements Listing {
}
@Override
public String getComment(int commentType, Address address) {
public String getComment(CommentType commentType, Address address) {
return codeMgr.getComment(commentType, address);
}
@ -516,7 +517,7 @@ class ListingDB implements Listing {
}
@Override
public void setComment(Address address, int commentType, String comment) {
public void setComment(Address address, CommentType commentType, String comment) {
codeMgr.setComment(address, commentType, comment);
}

View file

@ -138,8 +138,6 @@ public class CodeManager implements ErrorHandler, ManagerDB {
throws CancelledException, IOException {
try {
ReferenceManager refMgr = program.getReferenceManager();
LongPropertyMapDB oldFallFroms = new LongPropertyMapDB(dbHandle, OpenMode.UPGRADE, this,
null, addrMap, "FallFroms", monitor);
@ -940,7 +938,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
*
* @return the property map object associated to the property name
*/
public PropertyMap getPropertyMap(String propertyName) {
public PropertyMap<?> getPropertyMap(String propertyName) {
return propertyMapMgr.getPropertyMap(propertyName);
}
@ -1144,7 +1142,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
}
else {
// Possibly a user-defined property.
PropertyMapDB pm = (PropertyMapDB) propertyMapMgr.getPropertyMap(property);
PropertyMapDB<?> pm = (PropertyMapDB<?>) propertyMapMgr.getPropertyMap(property);
if (pm != null) {
try {
AddressKeyIterator iter = pm.getAddressKeyIterator(start, end, forward);
@ -1215,7 +1213,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
}
}
// Possibly a user-defined property.
PropertyMapDB pm = (PropertyMapDB) propertyMapMgr.getPropertyMap(property);
PropertyMapDB<?> pm = (PropertyMapDB<?>) propertyMapMgr.getPropertyMap(property);
if (pm != null) {
try {
AddressKeyIterator iter = pm.getAddressKeyIterator(addrSetView, forward);
@ -1234,7 +1232,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* @param set address set (null for all defined memory)
* @return code unit iterator
*/
public CodeUnitIterator getCommentCodeUnitIterator(int commentType, AddressSetView set) {
public CodeUnitIterator getCommentCodeUnitIterator(CommentType commentType,
AddressSetView set) {
CodeUnitIterator it = getCodeUnitIterator(CodeUnit.COMMENT_PROPERTY, set, true);
return new CommentTypeFilterIterator(it, commentType);
}
@ -1260,7 +1259,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* @param forward true to iterate in the direction of increasing addresses.
* @return address iterator
*/
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView set,
public AddressIterator getCommentAddressIterator(CommentType commentType, AddressSetView set,
boolean forward) {
if (set != null && set.isEmpty()) {
return AddressIterator.EMPTY_ITERATOR;
@ -3282,19 +3281,18 @@ public class CodeManager implements ErrorHandler, ManagerDB {
/**
* Get the comment for the given type at the specified address.
*
* @param commentType either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, PLATE_COMMENT, or
* REPEATABLE_COMMENT
* @param commentType {@link CommentType comment type}
* @param address the address of the comment.
* @return the comment string of the appropriate type or null if no comment of that type exists
* for this code unit
* @throws IllegalArgumentException if type is not one of the types of comments supported
*/
public String getComment(int commentType, Address address) {
public String getComment(CommentType commentType, Address address) {
try {
long addr = addrMap.getKey(address, false);
DBRecord commentRec = getCommentAdapter().getRecord(addr);
if (commentRec != null) {
return commentRec.getString(commentType);
return commentRec.getString(commentType.ordinal());
}
}
catch (IOException e) {
@ -3336,7 +3334,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* @param comment comment to set at the address
* @throws IllegalArgumentException if type is not one of the types of comments supported
*/
public void setComment(Address address, int commentType, String comment) {
public void setComment(Address address, CommentType commentType, String comment) {
CodeUnit cu = getCodeUnitAt(address);
if (cu != null) {
cu.setComment(commentType, comment);
@ -3345,18 +3343,19 @@ public class CodeManager implements ErrorHandler, ManagerDB {
lock.acquire();
try {
long addr = addrMap.getKey(address, true);
DBRecord commentRec = getCommentAdapter().getRecord(addr);
if (commentRec == null) {
if (comment == null) {
return;
}
commentRec = getCommentAdapter().createRecord(addr, commentType, comment);
commentRec = getCommentAdapter().createRecord(addr, commentType.ordinal(), comment);
sendNotification(address, commentType, null, comment);
return;
}
String oldValue = commentRec.getString(commentType);
commentRec.setString(commentType, comment);
String oldValue = commentRec.getString(commentType.ordinal());
commentRec.setString(commentType.ordinal(), comment);
sendNotification(address, commentType, oldValue, comment);
for (int i = 0; i < CommentsDBAdapter.COMMENT_COL_COUNT; i++) {
@ -3375,12 +3374,13 @@ public class CodeManager implements ErrorHandler, ManagerDB {
}
}
void sendNotification(Address address, int commentType, String oldValue, String newValue) {
void sendNotification(Address address, CommentType commentType, String oldValue,
String newValue) {
createCommentHistoryRecord(address, commentType, oldValue, newValue);
program.setChanged(new CommentChangeRecord(commentType, address, oldValue, newValue));
}
void createCommentHistoryRecord(Address address, int commentType, String oldComment,
void createCommentHistoryRecord(Address address, CommentType commentType, String oldComment,
String newComment) {
if (oldComment == null) {
oldComment = "";
@ -3395,8 +3395,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
long addr = addrMap.getKey(address, true);
try {
for (StringDiff diff : diffs) {
historyAdapter.createRecord(addr, (byte) commentType, diff.start, diff.end,
diff.text, date);
historyAdapter.createRecord(addr, (byte) commentType.ordinal(), diff.start,
diff.end, diff.text, date);
}
}
catch (IOException e) {
@ -3411,7 +3411,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* @param commentType comment type
* @return zero length array if no history exists
*/
public CommentHistory[] getCommentHistory(Address addr, int commentType) {
public CommentHistory[] getCommentHistory(Address addr, CommentType commentType) {
lock.acquire();
try {
@ -3456,12 +3456,13 @@ public class CodeManager implements ErrorHandler, ManagerDB {
}
// note: you must have the lock when calling this method
private List<DBRecord> getHistoryRecords(Address addr, int commentType) throws IOException {
private List<DBRecord> getHistoryRecords(Address addr, CommentType commentType)
throws IOException {
RecordIterator it = historyAdapter.getRecordsByAddress(addr);
List<DBRecord> list = new ArrayList<>();
while (it.hasNext()) {
DBRecord rec = it.next();
if (rec.getByteValue(CommentHistoryAdapter.HISTORY_TYPE_COL) == commentType) {
if (rec.getByteValue(CommentHistoryAdapter.HISTORY_TYPE_COL) == commentType.ordinal()) {
list.add(rec);
}
}
@ -3482,10 +3483,10 @@ public class CodeManager implements ErrorHandler, ManagerDB {
return records.subList(0, records.size());
}
private String getComment(Address addr, int commentType) throws IOException {
private String getComment(Address addr, CommentType commentType) throws IOException {
DBRecord record = commentAdapter.getRecord(addrMap.getKey(addr, false));
if (record != null) {
return record.getString(commentType);
return record.getString(commentType.ordinal());
}
return "";
}
@ -3525,16 +3526,16 @@ public class CodeManager implements ErrorHandler, ManagerDB {
RecordIterator iter = commentAdapter.getRecords(start, end, true);
while (iter.hasNext()) {
DBRecord rec = iter.next();
addCommentHistoryRecord(rec, CodeUnit.PRE_COMMENT);
addCommentHistoryRecord(rec, CodeUnit.POST_COMMENT);
addCommentHistoryRecord(rec, CodeUnit.EOL_COMMENT);
addCommentHistoryRecord(rec, CodeUnit.PLATE_COMMENT);
addCommentHistoryRecord(rec, CodeUnit.REPEATABLE_COMMENT);
addCommentHistoryRecord(rec, CommentType.PRE);
addCommentHistoryRecord(rec, CommentType.POST);
addCommentHistoryRecord(rec, CommentType.EOL);
addCommentHistoryRecord(rec, CommentType.PLATE);
addCommentHistoryRecord(rec, CommentType.REPEATABLE);
}
}
private void addCommentHistoryRecord(DBRecord commentRec, int commentType) {
String comment = commentRec.getString(commentType);
private void addCommentHistoryRecord(DBRecord commentRec, CommentType commentType) {
String comment = commentRec.getString(commentType.ordinal());
if (comment != null) {
createCommentHistoryRecord(addrMap.decodeAddress(commentRec.getKey()), commentType,
comment, "");

View file

@ -190,7 +190,10 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
}
@Override
public String getComment(int commentType) {
public String getComment(CommentType commentType) {
if (commentType == null) {
return null;
}
lock.acquire();
try {
checkIsValid();
@ -200,7 +203,7 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
if (commentRec == null) {
return null;
}
return commentRec.getString(commentType);
return commentRec.getString(commentType.ordinal());
}
finally {
lock.release();
@ -208,7 +211,7 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
}
@Override
public String[] getCommentAsArray(int commentType) {
public String[] getCommentAsArray(CommentType commentType) {
String comment = getComment(commentType);
return StringUtilities.toLines(comment);
}
@ -247,11 +250,7 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
SymbolTable st = codeMgr.getSymbolTable();
Symbol symbol = st.getPrimarySymbol(address);
if (symbol != null) {
try {
return symbol.getName();
}
catch (ConcurrentModificationException e) {
}
return symbol.getName();
}
return null;
}
@ -293,12 +292,8 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
PropertyMapManager upm = codeMgr.getPropertyMapManager();
ObjectPropertyMap<?> pm = upm.getObjectPropertyMap(name);
if (pm != null) {
try {
validate(lock);
return pm.get(address);
}
catch (ConcurrentModificationException e) {
}
validate(lock);
return pm.get(address);
}
return null;
}
@ -344,12 +339,8 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
PropertyMapManager upm = codeMgr.getPropertyMapManager();
StringPropertyMap pm = upm.getStringPropertyMap(name);
if (pm != null) {
try {
validate(lock);
return pm.getString(address);
}
catch (ConcurrentModificationException e) {
}
validate(lock);
return pm.getString(address);
}
return null;
}
@ -366,12 +357,8 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
PropertyMapManager upm = codeMgr.getPropertyMapManager();
VoidPropertyMap pm = upm.getVoidPropertyMap(name);
if (pm != null) {
try {
validate(lock);
return pm.hasProperty(address);
}
catch (ConcurrentModificationException e) {
}
validate(lock);
return pm.hasProperty(address);
}
return false;
}
@ -381,12 +368,8 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
PropertyMapManager upm = codeMgr.getPropertyMapManager();
PropertyMap<?> pm = upm.getPropertyMap(name);
if (pm != null) {
try {
validate(lock);
return pm.hasProperty(address);
}
catch (ConcurrentModificationException e) {
}
validate(lock);
return pm.hasProperty(address);
}
return false;
}
@ -433,12 +416,13 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
pm.remove(address);
}
catch (ConcurrentModificationException e) {
// ignore
}
}
}
@Override
public void setComment(int commentType, String comment) {
public void setComment(CommentType commentType, String comment) {
lock.acquire();
try {
checkDeleted();
@ -451,8 +435,8 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
return;
}
try {
commentRec =
codeMgr.getCommentAdapter().createRecord(addr, commentType, comment);
commentRec = codeMgr.getCommentAdapter()
.createRecord(addr, commentType.ordinal(), comment);
}
catch (IOException e) {
codeMgr.dbError(e);
@ -461,8 +445,8 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
return;
}
String oldValue = commentRec.getString(commentType);
commentRec.setString(commentType, comment);
String oldValue = commentRec.getString(commentType.ordinal());
commentRec.setString(commentType.ordinal(), comment);
codeMgr.sendNotification(address, commentType, oldValue, comment);
for (int i = 0; i < CommentsDBAdapter.COMMENT_COL_COUNT; i++) {
@ -485,7 +469,7 @@ abstract class CodeUnitDB extends DatabaseObject implements CodeUnit, ProcessorC
}
@Override
public void setCommentAsArray(int commentType, String[] comment) {
public void setCommentAsArray(CommentType commentType, String[] comment) {
setComment(commentType, StringUtils.join(comment, '\n'));
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,12 +15,11 @@
*/
package ghidra.program.database.code;
import java.util.Iterator;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressIterator;
import ghidra.program.model.listing.Listing;
import ghidra.program.model.listing.Program;
import java.util.Iterator;
import ghidra.program.model.listing.*;
/**
* Filters the given address iterator to only return addresses that have a comment of the given type
@ -28,7 +27,7 @@ import java.util.Iterator;
public class CommentTypeFilterAddressIterator implements AddressIterator {
private AddressIterator it;
private Listing listing;
private int commentType;
private CommentType commentType;
private Address nextAddr;
/**
@ -36,7 +35,8 @@ public class CommentTypeFilterAddressIterator implements AddressIterator {
* @param it an address iterator whose items are tested for the comment type.
* @param commentType the type of comment to search for.
*/
public CommentTypeFilterAddressIterator(Program program, AddressIterator it, int commentType) {
public CommentTypeFilterAddressIterator(Program program, AddressIterator it,
CommentType commentType) {
this.listing = program.getListing();
this.it = it;
this.commentType = commentType;

View file

@ -1,13 +1,12 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,17 +15,16 @@
*/
package ghidra.program.database.code;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CodeUnitIterator;
import java.util.Iterator;
import ghidra.program.model.listing.*;
/**
* Filters the given codeUnit iterator to only return codeUnits that have a comment of the given type
*/
public class CommentTypeFilterIterator implements CodeUnitIterator {
private CodeUnitIterator it;
private int commentType;
private CommentType commentType;
private CodeUnit nextCu;
/**
@ -34,7 +32,7 @@ public class CommentTypeFilterIterator implements CodeUnitIterator {
* @param it a codeunit iterator whose items are tested for the comment type.
* @param commentType the type of comment to search for.
*/
public CommentTypeFilterIterator(CodeUnitIterator it, int commentType) {
public CommentTypeFilterIterator(CodeUnitIterator it, CommentType commentType) {
this.it = it;
this.commentType = commentType;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,7 +23,7 @@ import ghidra.program.database.map.AddressKeyIterator;
import ghidra.program.database.map.AddressMap;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.VersionException;
import ghidra.util.task.TaskMonitor;
@ -39,11 +39,16 @@ abstract class CommentsDBAdapter {
static final Schema COMMENTS_SCHEMA;
static final int PRE_COMMENT_COL = CodeUnit.PRE_COMMENT;
static final int POST_COMMENT_COL = CodeUnit.POST_COMMENT;
static final int EOL_COMMENT_COL = CodeUnit.EOL_COMMENT;
static final int PLATE_COMMENT_COL = CodeUnit.PLATE_COMMENT;
static final int REPEATABLE_COMMENT_COL = CodeUnit.REPEATABLE_COMMENT;
//
// IMPORTANT: It is very important that the defined table columns and their sequence
// do not change and must match the ordinal ordering of CommentType enum values.
//
static final int EOL_COMMENT_COL = CommentType.EOL.ordinal();
static final int PRE_COMMENT_COL = CommentType.PRE.ordinal();
static final int POST_COMMENT_COL = CommentType.POST.ordinal();
static final int PLATE_COMMENT_COL = CommentType.PLATE.ordinal();
static final int REPEATABLE_COMMENT_COL = CommentType.REPEATABLE.ordinal();
static final int COMMENT_COL_COUNT = 5;
@ -51,9 +56,9 @@ abstract class CommentsDBAdapter {
static {
NAMES = new String[5];
NAMES[EOL_COMMENT_COL] = "EOL";
NAMES[PRE_COMMENT_COL] = "Pre";
NAMES[POST_COMMENT_COL] = "Post";
NAMES[EOL_COMMENT_COL] = "EOL";
NAMES[PLATE_COMMENT_COL] = "Plate";
NAMES[REPEATABLE_COMMENT_COL] = "Repeatable";
@ -62,17 +67,6 @@ abstract class CommentsDBAdapter {
StringField.INSTANCE, StringField.INSTANCE, StringField.INSTANCE }, NAMES);
}
// /** comment type for end of line */
// static final int EOL_COMMENT = 0;
// /** comment type that goes before a code unit */
// static final int PRE_COMMENT = 1;
// /** comment type that follows after a code unit */
// static final int POST_COMMENT = 2;
// /** plate comment type */
// static final int PLATE_COMMENT = 3;
// /** repeatable comment type */
// static final int REPEATABLE_COMMENT = 4;
static CommentsDBAdapter getAdapter(DBHandle dbHandle, OpenMode openMode, AddressMap addrMap,
TaskMonitor monitor) throws VersionException, CancelledException, IOException {
@ -105,6 +99,7 @@ abstract class CommentsDBAdapter {
return new CommentsDBAdapterV1(handle, addrMap.getOldAddressMap(), false);
}
catch (VersionException e) {
// ignore
}
return new CommentsDBAdapterV0(handle, addrMap);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,7 +21,6 @@ import db.*;
import ghidra.program.database.map.*;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.CodeUnit;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.VersionException;
import ghidra.util.task.TaskMonitor;
@ -32,27 +31,19 @@ import ghidra.util.task.TaskMonitor;
class CommentsDBAdapterV0 extends CommentsDBAdapter {
/** column for end of line comment */
private static final int EOL_COMMENT_COLUMN = 0;
private static final int V0_EOL_COMMENT_COLUMN = 0;
/** comment type that goes before a code unit */
private static final int PRE_COMMENT_COLUMN = 1;
private static final int V0_PRE_COMMENT_COLUMN = 1;
/** comment type that follows after a code unit */
private static final int POST_COMMENT_COLUMN = 2;
private static final int V0_POST_COMMENT_COLUMN = 2;
/** Property name for plate comment type */
private static final int PLATE_COMMENT_COLUMN = 3;
/** The number of comment fields in this version. */
/** Version 0 comment column names. */
private static final String[] V0_NAMES = new String[4];
static {
V0_NAMES[EOL_COMMENT_COLUMN] = "EOL";
V0_NAMES[PRE_COMMENT_COLUMN] = "Pre";
V0_NAMES[POST_COMMENT_COLUMN] = "Post";
V0_NAMES[PLATE_COMMENT_COLUMN] = "Plate";
}
private static final int V0_PLATE_COMMENT_COLUMN = 3;
/** Version 0 comment table schema. */
// private static final Schema V0_SCHEMA = new Schema(0, "Address",
// new Class[] {StringField.class, StringField.class,
// StringField.class, StringField.class},
// V0_NAMES);
// "EOL", "Pre", "Post", "Plate");
/** the comment table. */
private Table commentTable;
private AddressMap addrMap;
@ -62,8 +53,8 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
*
*/
@SuppressWarnings("unused")
public CommentsDBAdapterV0(DBHandle handle, AddressMap addrMap) throws IOException,
VersionException {
public CommentsDBAdapterV0(DBHandle handle, AddressMap addrMap)
throws IOException, VersionException {
this.addrMap = addrMap.getOldAddressMap();
commentTable = handle.getTable(COMMENTS_TABLE_NAME);
@ -75,49 +66,30 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
}
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#getRecord(long)
*/
@Override
public DBRecord getRecord(long addr) throws IOException {
return adaptRecord(commentTable.getRecord(addr));
return v0ConvertRecord(commentTable.getRecord(addr));
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#createRecord(long, int, java.lang.String)
*/
@Override
public DBRecord createRecord(long addr, int commentCol, String comment) throws IOException {
return null;
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#deleteRecord(long)
*/
@Override
public boolean deleteRecord(long addr) throws IOException {
return false;
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#deleteRecords(long, long)
*/
@Override
public boolean deleteRecords(Address start, Address end) throws IOException {
return false;
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#updateRecord(ghidra.framework.store.db.DBRecord)
*/
@Override
public void updateRecord(DBRecord commentRec) throws IOException {
}
/**
*
* @see ghidra.program.database.code.CommentsDBAdapter#getKeys(long, long, boolean)
*/
@Override
public AddressKeyIterator getKeys(Address start, Address end, boolean atStart)
throws IOException {
@ -127,9 +99,6 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
return new AddressKeyIterator(commentTable, addrMap, start, end, end, false);
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#getKeys(ghidra.program.model.address.AddressSetView, boolean)
*/
@Override
public AddressKeyIterator getKeys(AddressSetView set, boolean forward) throws IOException {
if (forward) {
@ -138,9 +107,6 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
return new AddressKeyIterator(commentTable, addrMap, set, set.getMaxAddress(), false);
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#getRecords(Address, Address, boolean)
*/
@Override
public RecordIterator getRecords(Address start, Address end, boolean atStart)
throws IOException {
@ -154,41 +120,26 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
return new RecordIteratorAdapter(it);
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#getRecords(Address)
*/
@Override
public RecordIterator getRecords(Address addr) throws IOException {
return new RecordIteratorAdapter(new AddressKeyRecordIterator(commentTable, addrMap, addr,
true));
return new RecordIteratorAdapter(
new AddressKeyRecordIterator(commentTable, addrMap, addr, true));
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#getRecords()
*/
@Override
public RecordIterator getRecords() throws IOException {
return new RecordIteratorAdapter(new AddressKeyRecordIterator(commentTable, addrMap));
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#putRecord(db.DBRecord)
*/
@Override
public void putRecord(DBRecord record) throws IOException {
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#getRecordCount()
*/
@Override
public int getRecordCount() throws IOException {
return commentTable.getRecordCount();
}
/**
* @see ghidra.program.database.code.CommentsDBAdapter#moveAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, long, ghidra.util.task.TaskMonitor)
*/
@Override
void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
throws CancelledException, IOException {
@ -200,29 +151,29 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
* @param recV0 the record matching the version 0 schema.
* @return a current comment record.
*/
private DBRecord adaptRecord(DBRecord recV0) {
private DBRecord v0ConvertRecord(DBRecord recV0) {
if (recV0 == null)
return null;
DBRecord record = COMMENTS_SCHEMA.createRecord(recV0.getKey());
String comment = recV0.getString(EOL_COMMENT_COLUMN);
String comment = recV0.getString(V0_EOL_COMMENT_COLUMN);
if (comment != null) {
record.setString(CodeUnit.EOL_COMMENT, comment);
record.setString(EOL_COMMENT_COL, comment);
}
comment = recV0.getString(PRE_COMMENT_COLUMN);
comment = recV0.getString(V0_PRE_COMMENT_COLUMN);
if (comment != null) {
record.setString(CodeUnit.PRE_COMMENT, comment);
record.setString(PRE_COMMENT_COL, comment);
}
comment = recV0.getString(POST_COMMENT_COLUMN);
comment = recV0.getString(V0_POST_COMMENT_COLUMN);
if (comment != null) {
record.setString(CodeUnit.POST_COMMENT, comment);
record.setString(POST_COMMENT_COL, comment);
}
comment = recV0.getString(PLATE_COMMENT_COLUMN);
comment = recV0.getString(V0_PLATE_COMMENT_COLUMN);
if (comment != null) {
record.setString(CodeUnit.PLATE_COMMENT, comment);
record.setString(PLATE_COMMENT_COL, comment);
}
return record;
@ -235,41 +186,31 @@ class CommentsDBAdapterV0 extends CommentsDBAdapter {
this.it = it;
}
/**
* @see ghidra.framework.store.db.RecordIterator#delete()
*/
@Override
public boolean delete() throws IOException {
return false;
}
/**
* @see ghidra.framework.store.db.RecordIterator#hasNext()
*/
@Override
public boolean hasNext() throws IOException {
return it.hasNext();
}
/**
* @see ghidra.framework.store.db.RecordIterator#hasPrevious()
*/
@Override
public boolean hasPrevious() throws IOException {
return it.hasPrevious();
}
/**
* @see ghidra.framework.store.db.RecordIterator#next()
*/
@Override
public DBRecord next() throws IOException {
DBRecord rec = it.next();
return adaptRecord(rec);
return v0ConvertRecord(rec);
}
/**
* @see ghidra.framework.store.db.RecordIterator#previous()
*/
@Override
public DBRecord previous() throws IOException {
DBRecord rec = it.previous();
return adaptRecord(rec);
return v0ConvertRecord(rec);
}
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,8 +20,7 @@ import ghidra.docking.settings.Settings;
import ghidra.program.database.DBObjectCache;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryAccessException;
/**
@ -234,11 +233,11 @@ class DataComponent extends DataDB {
}
@Override
public int getBytes(byte[] b, int offset) {
public int getBytes(byte[] b, int off) {
lock.acquire();
try {
checkIsValid();
return parent.getBytes(b, this.offset + offset);
return parent.getBytes(b, this.offset + off);
}
finally {
lock.release();
@ -274,9 +273,9 @@ class DataComponent extends DataDB {
}
@Override
public String getComment(int commentType) {
public String getComment(CommentType commentType) {
String cmt = super.getComment(commentType);
if (cmt == null && commentType == CodeUnit.EOL_COMMENT && component != null) {
if (cmt == null && commentType == CommentType.EOL && component != null) {
cmt = component.getComment();
}
return cmt;

View file

@ -25,6 +25,7 @@ import ghidra.program.database.data.ProgramDataTypeManager;
import ghidra.program.database.map.AddressMap;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Data;
import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryBlock;
@ -459,7 +460,7 @@ class DataDB extends CodeUnitDB implements Data {
}
@Override
public String getComment(int commentType) {
public String getComment(CommentType commentType) {
Data child = getComponentContaining(0);
if (child != null) {
// avoid caching issue by maintaining comment at lowest point in data path
@ -469,7 +470,7 @@ class DataDB extends CodeUnitDB implements Data {
}
@Override
public void setComment(int commentType, String comment) {
public void setComment(CommentType commentType, String comment) {
Data child = getComponentContaining(0);
if (child != null) {
// avoid caching issue by maintaining comment at lowest point in data path

View file

@ -262,7 +262,7 @@ public class FunctionDB extends DatabaseObject implements Function {
manager.lock.acquire();
try {
checkIsValid();
return manager.getCodeManager().getComment(CodeUnit.PLATE_COMMENT, getEntryPoint());
return manager.getCodeManager().getComment(CommentType.PLATE, getEntryPoint());
}
finally {
manager.lock.release();
@ -280,7 +280,7 @@ public class FunctionDB extends DatabaseObject implements Function {
try {
startUpdate();
checkDeleted();
manager.getCodeManager().setComment(getEntryPoint(), CodeUnit.PLATE_COMMENT, comment);
manager.getCodeManager().setComment(getEntryPoint(), CommentType.PLATE, comment);
}
finally {
endUpdate();
@ -293,8 +293,7 @@ public class FunctionDB extends DatabaseObject implements Function {
manager.lock.acquire();
try {
checkIsValid();
return manager.getCodeManager()
.getComment(CodeUnit.REPEATABLE_COMMENT, getEntryPoint());
return manager.getCodeManager().getComment(CommentType.REPEATABLE, getEntryPoint());
}
finally {
manager.lock.release();
@ -311,8 +310,7 @@ public class FunctionDB extends DatabaseObject implements Function {
manager.lock.acquire();
try {
checkDeleted();
manager.getCodeManager()
.setComment(getEntryPoint(), CodeUnit.REPEATABLE_COMMENT, comment);
manager.getCodeManager().setComment(getEntryPoint(), CommentType.REPEATABLE, comment);
}
finally {
manager.lock.release();

View file

@ -47,8 +47,8 @@ class OldFunctionDataDB {
private OldStackFrameDB frame;
private List<Parameter> regParams;
OldFunctionDataDB(OldFunctionManager functionManager, AddressMap addrMap, DBRecord functionRecord,
AddressSetView body) {
OldFunctionDataDB(OldFunctionManager functionManager, AddressMap addrMap,
DBRecord functionRecord, AddressSetView body) {
this.functionManager = functionManager;
this.addrMap = addrMap;
@ -83,8 +83,7 @@ class OldFunctionDataDB {
*/
public synchronized String getComment() {
CodeUnit cu = program.getCodeManager().getCodeUnitContaining(entryPoint);
return cu.getComment(CodeUnit.PLATE_COMMENT);
return cu.getComment(CommentType.PLATE);
}
/**
@ -254,17 +253,15 @@ class OldFunctionDataDB {
Parameter[] parms = new Parameter[regParams.size() + frame.getParameterCount()];
int ordinal = 0;
Iterator<Parameter> iter = regParams.iterator();
while (iter.hasNext()) {
Parameter rp = iter.next();
for (Parameter rp : regParams) {
parms[ordinal++] = rp;
}
try {
Variable[] stackParams = frame.getParameters();
for (int i = 0; i < stackParams.length; i++) {
parms[ordinal++] = new OldFunctionParameter(stackParams[i].getName(), ordinal,
stackParams[i].getDataType(), stackParams[i].getVariableStorage(), program,
for (Variable stackParam : stackParams) {
parms[ordinal++] = new OldFunctionParameter(stackParam.getName(), ordinal,
stackParam.getDataType(), stackParam.getVariableStorage(), program,
SourceType.USER_DEFINED);
}
}

View file

@ -38,43 +38,36 @@ public interface CodeUnit extends MemBuffer, PropertySet {
*/
public final static int MNEMONIC = -1;
public static final int NO_COMMENT = -1;
/**
* comment type for end of line
* @deprecated use {@link CommentType#EOL}
*/
@Deprecated
public static final int EOL_COMMENT = 0;
@Deprecated(forRemoval = true, since = "11.4")
public static final int EOL_COMMENT = 0; // CommentType.EOL.ordinal();
/**
* comment type that goes before a code unit
* @deprecated use {@link CommentType#PRE}
*/
@Deprecated
public static final int PRE_COMMENT = 1;
@Deprecated(forRemoval = true, since = "11.4")
public static final int PRE_COMMENT = 1; // CommentType.PRE.ordinal();
/**
* comment type that follows after a code unit
* @deprecated use {@link CommentType#POST}
*/
@Deprecated
public static final int POST_COMMENT = 2;
@Deprecated(forRemoval = true, since = "11.4")
public static final int POST_COMMENT = 2; // CommentType.POST.ordinal();
/**
* Property name for plate comment type
* @deprecated use {@link CommentType#POST}
*/
@Deprecated
public static final int PLATE_COMMENT = 3;
@Deprecated(forRemoval = true, since = "11.4")
public static final int PLATE_COMMENT = 3; // CommentType.PLATE.ordinal();
/**
* Property name for repeatable comment type
* @deprecated use {@link CommentType#REPEATABLE}
*/
@Deprecated
public static final int REPEATABLE_COMMENT = 4;
// /**
// * Property type for fall through property
// */
// public static final int FALL_THROUGH = 4;
@Deprecated(forRemoval = true, since = "11.4")
public static final int REPEATABLE_COMMENT = 4; // CommentType.REPEATABLE.ordinal();
/**
* Any comment property.
@ -104,36 +97,36 @@ public interface CodeUnit extends MemBuffer, PropertySet {
public String getAddressString(boolean showBlockName, boolean pad);
/**
* Get the label for this code unit.
* {@return the label for this code unit.}
*/
public String getLabel();
/**
* Get the Symbols for this code unit.
* {@return the Symbols for this code unit.}
* @throws ConcurrentModificationException if this object is no
* longer valid.
*/
public Symbol[] getSymbols();
/**
* Get the Primary Symbol for this code unit.
* {@return the Primary Symbol for this code unit.}
* @throws ConcurrentModificationException if this object is no
* longer valid.
*/
public Symbol getPrimarySymbol();
/**
* Get the starting address for this code unit.
* {@return the starting address for this code unit.}
*/
public Address getMinAddress();
/**
* Get the ending address for this code unit.
* {@return the ending address for this code unit.}
*/
public Address getMaxAddress();
/**
* Get the mnemonic for this code unit, e.g., MOV, JMP
* {@return the mnemonic for this code unit, e.g., MOV, JMP}
*/
public String getMnemonicString();
@ -148,19 +141,19 @@ public interface CodeUnit extends MemBuffer, PropertySet {
* three types of comments supported
* @deprecated use {@link #getComment(CommentType)} instead
*/
@Deprecated
public String getComment(int commentType);
@Deprecated(forRemoval = true, since = "11.4")
public default String getComment(int commentType) {
return getComment(CommentType.valueOf(commentType));
}
/**
* Get the comment for the given type
*
* @param type which type of comment to retrieve
* @param type {@link CommentType comment type}
* @return the comment string of the appropriate type or null if no comment of
* that type exists for this code unit
*/
public default String getComment(CommentType type) {
return getComment(type.ordinal());
}
public String getComment(CommentType type);
/**
* Get the comment for the given type and parse it into an array of strings
@ -175,21 +168,21 @@ public interface CodeUnit extends MemBuffer, PropertySet {
* three types of comments supported
* @deprecated use {@link #getCommentAsArray(CommentType)} instead
*/
@Deprecated
public String[] getCommentAsArray(int commentType);
@Deprecated(forRemoval = true, since = "11.4")
public default String[] getCommentAsArray(int commentType) {
return getCommentAsArray(CommentType.valueOf(commentType));
}
/**
* Get the comment for the given type and parse it into an array of strings
* such that each line is its own string.
*
* @param type the comment type to retrieve
* @param type {@link CommentType comment type}
* @return an array of strings where each item in the array is a line of text
* in the comment. If there is no comment of the requested type, an empty array
* is returned.
*/
public default String[] getCommentAsArray(CommentType type) {
return getCommentAsArray(type.ordinal());
}
public String[] getCommentAsArray(CommentType type);
/**
* Set the comment for the given comment type. Passing <code>null</code> clears the comment
@ -203,17 +196,17 @@ public interface CodeUnit extends MemBuffer, PropertySet {
* @deprecated use {@link #setComment(CommentType, String)} instead
*/
@Deprecated
public void setComment(int commentType, String comment);
public default void setComment(int commentType, String comment) {
setComment(CommentType.valueOf(commentType), comment);
}
/**
* Set the comment for the given comment type. Passing <code>null</code> clears the comment
*
* @param type of comment to set
* @param type {@link CommentType comment type}
* @param comment comment for code unit; null clears the comment
*/
public default void setComment(CommentType type, String comment) {
setComment(type.ordinal(), comment);
}
public void setComment(CommentType type, String comment);
/**
* Set the comment (with each line in its own string) for the given comment type
@ -224,12 +217,20 @@ public interface CodeUnit extends MemBuffer, PropertySet {
* @throws IllegalArgumentException if type is not one of the
* three types of comments supported
*/
public void setCommentAsArray(int commentType, String[] comment);
public default void setCommentAsArray(CommentType type, String[] comment) {
setCommentAsArray(type.ordinal(), comment);
public default void setCommentAsArray(int commentType, String[] comment) {
setCommentAsArray(CommentType.valueOf(commentType), comment);
}
/**
* Set the comment (with each line in its own string) for the given comment type
*
* @param type {@link CommentType comment type}
* @param comment an array of strings where each string is a single line of the comment.
* @throws IllegalArgumentException if type is not one of the
* three types of comments supported
*/
public void setCommentAsArray(CommentType type, String[] comment);
/**
* Get length of this code unit.
* NOTE: If an {@link Instruction#isLengthOverridden() instruction length-override} is
@ -258,7 +259,7 @@ public interface CodeUnit extends MemBuffer, PropertySet {
public void getBytesInCodeUnit(byte[] buffer, int bufferOffset) throws MemoryAccessException;
/**
* Returns true if address is contained in the range of this codeUnit
* {@return true if address is contained in the range of this codeUnit}
* @param testAddr the address to test.
*/
public boolean contains(Address testAddr);
@ -295,13 +296,13 @@ public interface CodeUnit extends MemBuffer, PropertySet {
public Reference[] getMnemonicReferences();
/**
* Get the references for the operand index.
* {@return the references for the operand index.}
* @param index operand index (0 is the first operand)
*/
public Reference[] getOperandReferences(int index);
/**
* Get the primary reference for the operand index.
* {@return the primary reference for the operand index.}
* @param index operand index (0 is the first operand)
*/
public Reference getPrimaryReference(int index);
@ -331,12 +332,12 @@ public interface CodeUnit extends MemBuffer, PropertySet {
public Reference[] getReferencesFrom();
/**
* Get an iterator over all references TO this code unit.
* {@return an iterator over all references TO this code unit.}
*/
public ReferenceIterator getReferenceIteratorTo();
/**
* Returns the program that generated this CodeUnit.
* {@return the program that generated this CodeUnit.}
*/
public Program getProgram();
@ -350,7 +351,7 @@ public interface CodeUnit extends MemBuffer, PropertySet {
/**
* Remove external reference (if any) at the given opIndex
* opIndex the index of the operand from which to remove any external reference.
* @param opIndex the index of the operand from which to remove any external reference.
*/
public void removeExternalReference(int opIndex);
@ -396,7 +397,7 @@ public interface CodeUnit extends MemBuffer, PropertySet {
RefType refType);
/**
* Get the number of operands for this code unit.
* {@return the number of operands for this code unit.}
*/
public int getNumOperands();

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -27,7 +27,7 @@ import ghidra.program.model.address.Address;
public class CommentHistory {
private Address addr;
private int commentType;
private CommentType commentType;
private Date modificationDate;
private String userName;
private String comments;
@ -40,7 +40,7 @@ public class CommentHistory {
* @param comments the list of comments.
* @param modificationDate the date the comment was changed.
*/
public CommentHistory(Address addr, int commentType, String userName, String comments,
public CommentHistory(Address addr, CommentType commentType, String userName, String comments,
Date modificationDate) {
this.addr = addr;
this.commentType = commentType;
@ -77,7 +77,7 @@ public class CommentHistory {
* Get the comment type
* @return the comment type
*/
public int getCommentType() {
public CommentType getCommentType() {
return commentType;
}

View file

@ -19,10 +19,38 @@ package ghidra.program.model.listing;
* Types of comments that be placed at an address or on a {@link CodeUnit}
*/
public enum CommentType {
//
// IMPORTANT: The ordinals of the defined comment types must be preserved since
// these values are used for comment storage. Any new comment types must be added
// to the bottom of the list.
//
EOL, // comments that appear at the end of the line
PRE, // comments that appear before the code unit
POST, // comments that appear after the code unit
PLATE, // comments that appear before the code unit with a decorated border
REPEATABLE // comments that appear at locations that refer to the address
// where this comment is defined
;
/**
* Get the comment type which corresponds to the specified ordinal value.
* <P>
* NOTE: This method is intended for conversion of old legacy commentType integer
* values to the enum type.
*
* @param commentType comment type value
* @return comment type enum which corresponds to specified ordinal
* @throws IllegalArgumentException if invalid comment type ordinal specified
*
*/
public static CommentType valueOf(int commentType) throws IllegalArgumentException {
try {
return CommentType.values()[commentType];
}
catch (ArrayIndexOutOfBoundsException e) {
throw new IllegalArgumentException("Invalid comment type: " + commentType, e);
}
}
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -130,22 +130,22 @@ public class DataStub implements Data {
}
@Override
public String getComment(int commentType) {
public String getComment(CommentType commentType) {
throw new UnsupportedOperationException();
}
@Override
public String[] getCommentAsArray(int commentType) {
public String[] getCommentAsArray(CommentType commentType) {
throw new UnsupportedOperationException();
}
@Override
public void setComment(int commentType, String comment) {
public void setComment(CommentType commentType, String comment) {
throw new UnsupportedOperationException();
}
@Override
public void setCommentAsArray(int commentType, String[] comment) {
public void setCommentAsArray(CommentType commentType, String[] comment) {
throw new UnsupportedOperationException();
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -127,22 +127,22 @@ public class InstructionStub implements Instruction {
}
@Override
public String getComment(int commentType) {
public String getComment(CommentType commentType) {
throw new UnsupportedOperationException();
}
@Override
public String[] getCommentAsArray(int commentType) {
public String[] getCommentAsArray(CommentType commentType) {
throw new UnsupportedOperationException();
}
@Override
public void setComment(int commentType, String comment) {
public void setComment(CommentType commentType, String comment) {
throw new UnsupportedOperationException();
}
@Override
public void setCommentAsArray(int commentType, String[] comment) {
public void setCommentAsArray(CommentType commentType, String[] comment) {
throw new UnsupportedOperationException();
}
@ -207,7 +207,8 @@ public class InstructionStub implements Instruction {
}
@Override
public void addOperandReference(int index, Address refAddr, RefType type, SourceType sourceType) {
public void addOperandReference(int index, Address refAddr, RefType type,
SourceType sourceType) {
throw new UnsupportedOperationException();
}

View file

@ -141,8 +141,13 @@ public interface Listing {
* @param addrSet address set
* @return a CodeUnitIterator that returns all code units from the indicated
* address set that have the specified comment type defined
* @deprecated use {@link #getCommentCodeUnitIterator(CommentType, AddressSetView)}
*/
public CodeUnitIterator getCommentCodeUnitIterator(int commentType, AddressSetView addrSet);
@Deprecated(forRemoval = true, since = "11.4")
public default CodeUnitIterator getCommentCodeUnitIterator(int commentType,
AddressSetView addrSet) {
return getCommentCodeUnitIterator(CommentType.valueOf(commentType), addrSet);
}
/**
* Get a forward code unit iterator over code units that have the specified
@ -153,10 +158,7 @@ public interface Listing {
* @return a CodeUnitIterator that returns all code units from the indicated
* address set that have the specified comment type defined
*/
public default CodeUnitIterator getCommentCodeUnitIterator(CommentType type,
AddressSetView addrSet) {
return getCommentCodeUnitIterator(type.ordinal(), addrSet);
}
public CodeUnitIterator getCommentCodeUnitIterator(CommentType type, AddressSetView addrSet);
/**
* Get a forward iterator over addresses that have the specified comment
@ -170,9 +172,11 @@ public interface Listing {
* address set that have the specified comment type defined
* @deprecated use {@link #getCommentAddressIterator(CommentType, AddressSetView, boolean)}
*/
@Deprecated
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView addrSet,
boolean forward);
@Deprecated(forRemoval = true, since = "11.4")
public default AddressIterator getCommentAddressIterator(int commentType,
AddressSetView addrSet, boolean forward) {
return getCommentAddressIterator(CommentType.valueOf(commentType), addrSet, forward);
}
/**
* Get a forward iterator over addresses that have the specified comment
@ -185,10 +189,8 @@ public interface Listing {
* @return an AddressIterator that returns all addresses from the indicated
* address set that have the specified comment type defined
*/
public default AddressIterator getCommentAddressIterator(CommentType type,
AddressSetView addrSet, boolean forward) {
return getCommentAddressIterator(type.ordinal(), addrSet, forward);
}
public AddressIterator getCommentAddressIterator(CommentType type, AddressSetView addrSet,
boolean forward);
/**
* Get a forward iterator over addresses that have any type of comment.
@ -213,15 +215,10 @@ public interface Listing {
* comments supported
* @deprecated use {@link #getComment(CommentType, Address)}
*/
@Deprecated
public String getComment(int commentType, Address address);
/**
* Get all the comments at the given address.
* @param address the address get comments
* @return a CodeUnitComments object that has all the comments at the address.
*/
public CodeUnitComments getAllComments(Address address);
@Deprecated(forRemoval = true, since = "11.4")
public default String getComment(int commentType, Address address) {
return getComment(CommentType.valueOf(commentType), address);
}
/**
* Get the comment for the given type at the specified address.
@ -231,9 +228,14 @@ public interface Listing {
* @return the comment string of the appropriate type or null if no comment
* of that type exists for this code unit
*/
public default String getComment(CommentType type, Address address) {
return getComment(type.ordinal(), address);
}
public String getComment(CommentType type, Address address);
/**
* Get all the comments at the given address.
* @param address the address get comments
* @return a CodeUnitComments object that has all the comments at the address.
*/
public CodeUnitComments getAllComments(Address address);
/**
* Set the comment for the given comment type at the specified address.
@ -246,8 +248,10 @@ public interface Listing {
* comments supported
* @deprecated use {@link #setComment(Address, CommentType, String)}
*/
@Deprecated
public void setComment(Address address, int commentType, String comment);
@Deprecated(forRemoval = true, since = "11.4")
public default void setComment(Address address, int commentType, String comment) {
setComment(address, CommentType.valueOf(commentType), comment);
}
/**
* Set the comment for the given comment type at the specified address.
@ -258,9 +262,7 @@ public interface Listing {
* @throws IllegalArgumentException if type is not one of the types of
* comments supported
*/
public default void setComment(Address address, CommentType type, String comment) {
setComment(address, type.ordinal(), comment);
}
public void setComment(Address address, CommentType type, String comment);
/**
* get a CodeUnit iterator that will iterate over the entire address space.
@ -655,7 +657,7 @@ public interface Listing {
* @param propertyName the property name
* @return PropertyMap the propertyMap object.
*/
public PropertyMap getPropertyMap(String propertyName);
public PropertyMap<?> getPropertyMap(String propertyName);
/**
* Creates a new Instruction object at the given address. The specified
@ -1048,8 +1050,21 @@ public interface Listing {
* @param addr address for comments
* @param commentType comment type defined in CodeUnit
* @return array of comment history records
* @deprecated use {@link #getCommentHistory(Address, CommentType)}
*/
public CommentHistory[] getCommentHistory(Address addr, int commentType);
@Deprecated(forRemoval = true, since = "11.4")
public default CommentHistory[] getCommentHistory(Address addr, int commentType) {
return getCommentHistory(addr, CommentType.valueOf(commentType));
}
/**
* Get the comment history for comments at the given address.
*
* @param addr address for comments
* @param type {@link CommentType comment type}
* @return array of comment history records
*/
public CommentHistory[] getCommentHistory(Address addr, CommentType type);
/**
* Returns the number of addresses where at least one comment type has been applied.

View file

@ -75,13 +75,14 @@ public class StubListing implements Listing {
}
@Override
public CodeUnitIterator getCommentCodeUnitIterator(int commentType, AddressSetView addrSet) {
public CodeUnitIterator getCommentCodeUnitIterator(CommentType commentType,
AddressSetView addrSet) {
throw new UnsupportedOperationException();
}
@Override
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView addrSet,
boolean forward) {
public AddressIterator getCommentAddressIterator(CommentType commentType,
AddressSetView addrSet, boolean forward) {
throw new UnsupportedOperationException();
}
@ -96,7 +97,7 @@ public class StubListing implements Listing {
}
@Override
public String getComment(int commentType, Address address) {
public String getComment(CommentType commentType, Address address) {
throw new UnsupportedOperationException();
}
@ -106,7 +107,7 @@ public class StubListing implements Listing {
}
@Override
public void setComment(Address address, int commentType, String comment) {
public void setComment(Address address, CommentType commentType, String comment) {
throw new UnsupportedOperationException();
}
@ -481,7 +482,7 @@ public class StubListing implements Listing {
}
@Override
public CommentHistory[] getCommentHistory(Address addr, int commentType) {
public CommentHistory[] getCommentHistory(Address addr, CommentType commentType) {
throw new UnsupportedOperationException();
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -17,8 +17,7 @@ package ghidra.program.util;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.*;
/**
* The <CODE>AutomaticCommentFieldLocation</CODE> class contains specific location information
@ -41,7 +40,7 @@ public class AutomaticCommentFieldLocation extends CommentFieldLocation {
*/
public AutomaticCommentFieldLocation(Program program, Address addr, int[] componentPath,
String[] comment, int row, int charOffset, int currentCommentRow) {
super(program, addr, componentPath, comment, CodeUnit.EOL_COMMENT, row, charOffset);
super(program, addr, componentPath, comment, CommentType.EOL, row, charOffset);
this.currentCommentRow = currentCommentRow;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -42,7 +42,7 @@ public class BlockStartLocation extends CommentFieldLocation {
public BlockStartLocation(Program program, Address addr, int[] componentPath, int row,
int charOffset, String[] comment, int commentRow) {
super(program, addr, componentPath, comment, CodeUnit.NO_COMMENT, row, charOffset);
super(program, addr, componentPath, comment, null, row, charOffset);
}
/**

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -17,6 +17,7 @@ package ghidra.program.util;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
/**
* Change record for comment changes
@ -24,16 +25,17 @@ import ghidra.program.model.listing.CodeUnit;
public class CommentChangeRecord extends ProgramChangeRecord {
// types defined in CodeUnit
private int commentType;
private CommentType commentType;
/**
* Constructor
* @param commentType the type of comment (as defined in {@link CodeUnit})
* @param commentType {@link CommentType comment type}
* @param address the address of the comment change
* @param oldValue the old comment (may be null for a new comment)
* @param newValue the new comment (may be null if the comment was deleted)
*/
public CommentChangeRecord(int commentType, Address address, String oldValue, String newValue) {
public CommentChangeRecord(CommentType commentType, Address address, String oldValue,
String newValue) {
super(ProgramEvent.COMMENT_CHANGED, address, address, null, oldValue, newValue);
this.commentType = commentType;
}
@ -42,7 +44,7 @@ public class CommentChangeRecord extends ProgramChangeRecord {
* Returns the comment type as defined in {@link CodeUnit}.
* @return the comment type
*/
public int getCommentType() {
public CommentType getCommentType() {
return commentType;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,7 +21,7 @@ import java.util.Arrays;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
/**
@ -31,7 +31,7 @@ import ghidra.program.model.listing.Program;
public class CommentFieldLocation extends CodeUnitLocation {
protected String[] comment;
protected int type;
protected CommentType type;
/**
* Construct a new CommentFieldLocation.
@ -41,16 +41,14 @@ public class CommentFieldLocation extends CodeUnitLocation {
* @param componentPath if not null, it is the array of indexes that point
* to a specific data type inside of another data type
* @param comment The array of strings that make up the comment
* @param type The type of this comment.
* Can be either CodeUnit.PRE_COMMENT, CodeUnit.POST_COMMENT,
* CodeUnit.PLATE_COMMENT, CodeUnit.EOL_COMMENT, or CodeUnit.REPEATABLE_COMMENT.
* @param type The type of this comment (null for no-comment type)
* @param row The index of the string that contains the exact location.
* @param charOffset The position within the string that specifies the exact location.
* @exception IllegalArgumentException
* Thrown if type is not one of the comment values given in <CODE>CodeUnit</CODE>
*/
public CommentFieldLocation(Program program, Address addr, int[] componentPath,
String[] comment, int type, int row, int charOffset) {
String[] comment, CommentType type, int row, int charOffset) {
super(program, addr, componentPath, row, 0, charOffset);
this.comment = comment;
@ -68,19 +66,6 @@ public class CommentFieldLocation extends CodeUnitLocation {
public CommentFieldLocation() {
}
/**
* Checks that the type is a valid comment type.
* @throws IllegalArgumentException if this doesn't have a valid comment type.
*/
protected void validateType() {
if (type != CodeUnit.PRE_COMMENT && type != CodeUnit.POST_COMMENT &&
type != CodeUnit.EOL_COMMENT && type != CodeUnit.REPEATABLE_COMMENT &&
type != CodeUnit.PLATE_COMMENT && type != CodeUnit.NO_COMMENT) {
throw new IllegalArgumentException(
"The comment type was " + type + ", but it must be from 0 to 4");
}
}
/**
* Returns the array of strings that make up the comment.
* @return the comment
@ -90,11 +75,9 @@ public class CommentFieldLocation extends CodeUnitLocation {
}
/**
* Returns the comment type. The type is either CodeUnit.EOL_COMMENT, CodeUnit.POST_COMMENT,
* CodeUnit.PLATE_COMMENT, CodeUnit.PRE_COMMENT, or CodeUnit.REPEATABLE_COMMENT.
* @return the comment type
* {@return the comment type or null if no-comment.}
*/
public int getCommentType() {
public CommentType getCommentType() {
return type;
}
@ -103,7 +86,8 @@ public class CommentFieldLocation extends CodeUnitLocation {
*/
@Override
public String toString() {
return super.toString() + ", Comment Type = " + type;
String str = type != null ? type.name() : "NO-COMMENT";
return super.toString() + ", Comment Type = " + str;
}
@Override
@ -111,7 +95,9 @@ public class CommentFieldLocation extends CodeUnitLocation {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Arrays.hashCode(comment);
result = prime * result + type;
if (type != null) {
result = prime * result + type.hashCode();
}
return result;
}
@ -140,14 +126,14 @@ public class CommentFieldLocation extends CodeUnitLocation {
public void saveState(SaveState obj) {
super.saveState(obj);
obj.putStrings("_COMMENT", comment);
obj.putInt("_TYPE", type);
obj.putInt("_TYPE", type != null ? type.ordinal() : -1);
}
@Override
public void restoreState(Program p, SaveState obj) {
super.restoreState(p, obj);
comment = obj.getStrings("_COMMENT", new String[0]);
type = obj.getInt("_TYPE", 0);
int commentType = obj.getInt("_TYPE", CommentType.EOL.ordinal());
type = commentType < 0 ? null : CommentType.valueOf(commentType);
}
}

View file

@ -16,6 +16,7 @@
package ghidra.program.util;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
public class CommentTypeUtils {
@ -27,32 +28,33 @@ public class CommentTypeUtils {
* @param defaultCommentType
* @return comment type
*/
public static int getCommentType(CodeUnit cu, ProgramLocation loc, int defaultCommentType) {
public static CommentType getCommentType(CodeUnit cu, ProgramLocation loc,
CommentType defaultCommentType) {
if (loc instanceof CommentFieldLocation) {
CommentFieldLocation cfLoc = (CommentFieldLocation) loc;
return cfLoc.getCommentType();
}
else if (loc instanceof PlateFieldLocation) {
return CodeUnit.PLATE_COMMENT;
return CommentType.PLATE;
}
else if (loc instanceof FunctionRepeatableCommentFieldLocation) {
return CodeUnit.REPEATABLE_COMMENT;
return CommentType.REPEATABLE;
}
else if (cu != null) {
if (cu.getComment(CodeUnit.PRE_COMMENT) != null) {
return CodeUnit.PRE_COMMENT;
if (cu.getComment(CommentType.PRE) != null) {
return CommentType.PRE;
}
if (cu.getComment(CodeUnit.POST_COMMENT) != null) {
return CodeUnit.POST_COMMENT;
if (cu.getComment(CommentType.POST) != null) {
return CommentType.POST;
}
if (cu.getComment(CodeUnit.EOL_COMMENT) != null) {
return CodeUnit.EOL_COMMENT;
if (cu.getComment(CommentType.EOL) != null) {
return CommentType.EOL;
}
if (cu.getComment(CodeUnit.PLATE_COMMENT) != null) {
return CodeUnit.PLATE_COMMENT;
if (cu.getComment(CommentType.PLATE) != null) {
return CommentType.PLATE;
}
if (cu.getComment(CodeUnit.REPEATABLE_COMMENT) != null) {
return CodeUnit.REPEATABLE_COMMENT;
if (cu.getComment(CommentType.REPEATABLE) != null) {
return CommentType.REPEATABLE;
}
}
return defaultCommentType;

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -17,7 +17,7 @@ package ghidra.program.util;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
/**
@ -41,7 +41,7 @@ public class EolCommentFieldLocation extends CommentFieldLocation {
*/
public EolCommentFieldLocation(Program program, Address addr, int[] componentPath,
String[] comment, int displayableCommentRow, int charOffset, int currentCommentRow) {
super(program, addr, componentPath, comment, CodeUnit.EOL_COMMENT, displayableCommentRow,
super(program, addr, componentPath, comment, CommentType.EOL, displayableCommentRow,
charOffset);
this.currentCommentRow = currentCommentRow;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,7 +18,6 @@
package ghidra.program.util;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program;
/**
@ -38,10 +37,9 @@ public class MemoryBlockStartFieldLocation extends CommentFieldLocation {
* @param comment the location comment
* @param commentRow the comment row
*/
public MemoryBlockStartFieldLocation(Program program, Address addr, int[] componentPath, int row,
int charOffset, String[] comment, int commentRow) {
super(program, addr, componentPath, comment, CodeUnit.NO_COMMENT, row, charOffset);
public MemoryBlockStartFieldLocation(Program program, Address addr, int[] componentPath,
int row, int charOffset, String[] comment, int commentRow) {
super(program, addr, componentPath, comment, null, row, charOffset);
}
/**

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,7 +19,7 @@ package ghidra.program.util;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
/**
@ -48,8 +48,7 @@ public class PlateFieldLocation extends CommentFieldLocation {
*/
public PlateFieldLocation(Program program, Address addr, int[] componentPath, int row,
int charOffset, String[] comment, int commentRow) {
super(program, addr, componentPath, comment, CodeUnit.PLATE_COMMENT, row, charOffset);
super(program, addr, componentPath, comment, CommentType.PLATE, row, charOffset);
this.commentRow = commentRow;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,7 +16,7 @@
package ghidra.program.util;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
/**
@ -37,7 +37,7 @@ public class PostCommentFieldLocation extends CommentFieldLocation {
*/
public PostCommentFieldLocation(Program program, Address addr, int[] componentPath,
String[] comment, int displayableCommentRow, int charOffset) {
super(program, addr, componentPath, comment, CodeUnit.POST_COMMENT, displayableCommentRow,
super(program, addr, componentPath, comment, CommentType.POST, displayableCommentRow,
charOffset);
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -17,7 +17,7 @@ package ghidra.program.util;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
/**
@ -45,7 +45,7 @@ public class RefRepeatCommentFieldLocation extends CommentFieldLocation {
public RefRepeatCommentFieldLocation(Program program, Address addr, int[] componentPath,
String[] comment, int row, int charOffset, int currentCommentRow,
Address refRepeatAddress) {
super(program, addr, componentPath, comment, CodeUnit.EOL_COMMENT, row, charOffset);
super(program, addr, componentPath, comment, CommentType.EOL, row, charOffset);
this.currentCommentRow = currentCommentRow;
this.refRepeatAddress = refRepeatAddress;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -17,7 +17,7 @@ package ghidra.program.util;
import ghidra.framework.options.SaveState;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
/**
@ -41,7 +41,7 @@ public class RepeatableCommentFieldLocation extends CommentFieldLocation {
*/
public RepeatableCommentFieldLocation(Program program, Address addr, int[] componentPath,
String[] comment, int row, int charOffset, int currentCommentRow) {
super(program, addr, componentPath, comment, CodeUnit.REPEATABLE_COMMENT, row, charOffset);
super(program, addr, componentPath, comment, CommentType.REPEATABLE, row, charOffset);
this.currentCommentRow = currentCommentRow;
}