Java Code Examples for ghidra.program.model.listing.CodeUnit#NO_COMMENT

The following examples show how to use ghidra.program.model.listing.CodeUnit#NO_COMMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DecompilerCommentsActionFactory.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected ProgramLocation getLocationForContext(
        ActionContext actionContext) {
    // only allow decompiler to have PRE, PLATE, and Generic Comment actions
    if ((actionContext instanceof DecompilerActionContext)
            && commentType != CodeUnit.PRE_COMMENT
            && commentType != CodeUnit.PLATE_COMMENT
            && commentType != CodeUnit.NO_COMMENT) {
        return null;
    }

    if ( !(actionContext instanceof ProgramLocationActionContext) ) {
        return null;
    }
    
    ProgramLocationActionContext context = (ProgramLocationActionContext) actionContext;
    return context.getLocation();
}
 
Example 2
Source File: CommentFieldLocation.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * 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");
	}
}
 
Example 3
Source File: CommentsPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private boolean hasComment(CodeUnit codeUnit, ProgramLocation loc) {
	if (codeUnit == null) {
		return false;
	}
	int commentType = CommentType.getCommentType(null, loc, CodeUnit.NO_COMMENT);
	return (commentType != CodeUnit.NO_COMMENT && codeUnit.getComment(commentType) != null);
}
 
Example 4
Source File: DecompilerCommentsActionFactory.java    From ghidra with Apache License 2.0 4 votes vote down vote up
DecompilerEditCommentsAction(CommentsDialog dialog, String name) {
    super(dialog, name, "Edit Comments", CodeUnit.NO_COMMENT);
    setPopupMenuData(new MenuData(EDIT_MENUPATH, "comments"));
    setKeyBindingData(new KeyBindingData(KeyEvent.VK_SEMICOLON, 0));
}
 
Example 5
Source File: BlockStartLocation.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
  * Create a new BlockStartLocation.
  * 
  * @param program the program of the location
  * @param addr address of block
  * @param componentPath object that uniquely identifies a module or fragment
  * by its hierarchy names; this parameter may be null
  *	@param row the component row
  * @param charOffset character position of the location
  * @param comment the block comments
  * @param commentRow the comment row
  */
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);
}
 
Example 6
Source File: MemoryBlockStartFieldLocation.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
  * Create a new BlockStartLocation.
  * 
  * @param program the program of the location
  * @param addr address of block
  * @param componentPath the component path
  * @param row component row
  * @param charOffset character position of the location
  * @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);
}