Java Code Examples for ghidra.program.model.listing.CodeUnit#PRE_COMMENT
The following examples show how to use
ghidra.program.model.listing.CodeUnit#PRE_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 |
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: CommentWindowPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private int getCommentType(int type) { if (type == ChangeManager.DOCR_PRE_COMMENT_CHANGED) { return CodeUnit.PRE_COMMENT; } if (type == ChangeManager.DOCR_POST_COMMENT_CHANGED) { return CodeUnit.POST_COMMENT; } if (type == ChangeManager.DOCR_EOL_COMMENT_CHANGED) { return CodeUnit.EOL_COMMENT; } if (type == ChangeManager.DOCR_PLATE_COMMENT_CHANGED) { return CodeUnit.PLATE_COMMENT; } if ((type == ChangeManager.DOCR_REPEATABLE_COMMENT_CHANGED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_ADDED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_REMOVED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_CREATED) || (type == ChangeManager.DOCR_REPEATABLE_COMMENT_DELETED)) { return CodeUnit.REPEATABLE_COMMENT; } return -1; }
Example 3
Source File: CommentsDialog.java From ghidra with Apache License 2.0 | 6 votes |
void setCommentType(int type) { switch (type) { case CodeUnit.EOL_COMMENT: tab.setSelectedIndex(0); break; case CodeUnit.PRE_COMMENT: tab.setSelectedIndex(1); break; case CodeUnit.POST_COMMENT: tab.setSelectedIndex(2); break; case CodeUnit.PLATE_COMMENT: tab.setSelectedIndex(3); break; case CodeUnit.REPEATABLE_COMMENT: tab.setSelectedIndex(4); break; } }
Example 4
Source File: CommentHistoryDialog.java From ghidra with Apache License 2.0 | 6 votes |
private JPanel buildMainPanel() { JPanel mainPanel = new JPanel(new BorderLayout()); tabbedPane = new JTabbedPane(); mainPanel.add(tabbedPane); eolPanel = new CommentHistoryPanel(CodeUnit.EOL_COMMENT); prePanel = new CommentHistoryPanel(CodeUnit.PRE_COMMENT); postPanel = new CommentHistoryPanel(CodeUnit.POST_COMMENT); platePanel = new CommentHistoryPanel(CodeUnit.PLATE_COMMENT); repeatablePanel = new CommentHistoryPanel(CodeUnit.REPEATABLE_COMMENT); JScrollPane sp = new JScrollPane(eolPanel); JViewport vp = sp.getViewport(); Dimension d = vp.getPreferredSize(); sp.getViewport().setPreferredSize(new Dimension(500, d.height*7)); tabbedPane.addTab(" EOL Comment ",sp); tabbedPane.addTab(" Pre Comment ",new JScrollPane(prePanel)); tabbedPane.addTab(" Post Comment ",new JScrollPane(postPanel)); tabbedPane.addTab(" Plate Comment ",new JScrollPane(platePanel)); tabbedPane.addTab(" Repeatable Comment ", new JScrollPane(repeatablePanel)); tabbedPane.addChangeListener(this); return mainPanel; }
Example 5
Source File: CommentMerger.java From ghidra with Apache License 2.0 | 6 votes |
private int getCodeUnitCommentType(int programMergeCommentType) { switch (programMergeCommentType) { case ProgramMergeFilter.PLATE_COMMENTS: return CodeUnit.PLATE_COMMENT; case ProgramMergeFilter.PRE_COMMENTS: return CodeUnit.PRE_COMMENT; case ProgramMergeFilter.EOL_COMMENTS: return CodeUnit.EOL_COMMENT; case ProgramMergeFilter.REPEATABLE_COMMENTS: return CodeUnit.REPEATABLE_COMMENT; case ProgramMergeFilter.POST_COMMENTS: return CodeUnit.POST_COMMENT; default: return -1; } }
Example 6
Source File: CommentFieldLocation.java From ghidra with Apache License 2.0 | 5 votes |
/** * 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 7
Source File: CommentType.java From ghidra with Apache License 2.0 | 5 votes |
/** * Get the comment type from the current location. If the cursor * is not over a comment, then just return EOL as the default. * @param cu * @param loc * @param defaultCommentType * @return comment type */ public static int getCommentType(CodeUnit cu, ProgramLocation loc, int defaultCommentType) { if (loc instanceof CommentFieldLocation) { CommentFieldLocation cfLoc = (CommentFieldLocation) loc; return cfLoc.getCommentType(); } else if (loc instanceof PlateFieldLocation) { return CodeUnit.PLATE_COMMENT; } else if (loc instanceof FunctionRepeatableCommentFieldLocation) { return CodeUnit.REPEATABLE_COMMENT; } else if (cu != null) { if (cu.getComment(CodeUnit.PRE_COMMENT) != null) { return CodeUnit.PRE_COMMENT; } if (cu.getComment(CodeUnit.POST_COMMENT) != null) { return CodeUnit.POST_COMMENT; } if (cu.getComment(CodeUnit.EOL_COMMENT) != null) { return CodeUnit.EOL_COMMENT; } if (cu.getComment(CodeUnit.PLATE_COMMENT) != null) { return CodeUnit.PLATE_COMMENT; } if (cu.getComment(CodeUnit.REPEATABLE_COMMENT) != null) { return CodeUnit.REPEATABLE_COMMENT; } } return defaultCommentType; }
Example 8
Source File: DecompilerCommentsActionFactory.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected int getEditCommentType(ActionContext context) { if (context instanceof DecompilerActionContext) { DecompilerActionContext decompContext = (DecompilerActionContext) context; Address addr = decompContext.getAddress(); if (addr.equals(decompContext.getFunctionEntryPoint())) { return CodeUnit.PLATE_COMMENT; } return CodeUnit.PRE_COMMENT; } CodeUnit cu = getCodeUnit(context); return CommentType.getCommentType(cu, getLocationForContext(context), CodeUnit.NO_COMMENT); }
Example 9
Source File: CommentHistoryDialog.java From ghidra with Apache License 2.0 | 5 votes |
private CommentHistoryPanel getHistoryPanel(int commentType) { switch(commentType) { case CodeUnit.EOL_COMMENT: return eolPanel; case CodeUnit.PRE_COMMENT: return prePanel; case CodeUnit.POST_COMMENT: return postPanel; case CodeUnit.PLATE_COMMENT: return platePanel; case CodeUnit.REPEATABLE_COMMENT: return repeatablePanel; } return null; }
Example 10
Source File: PreCommentMarkupType.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected ProgramLocation getLocation(VTAssociation association, Address address, boolean isSource) { if (address == null || address == Address.NO_ADDRESS) { return null; } Program program = isSource ? getSourceProgram(association) : getDestinationProgram(association); return new CommentFieldLocation(program, address, null, null, CodeUnit.PRE_COMMENT, 0, 0); }
Example 11
Source File: CommentsPlugin.java From ghidra with Apache License 2.0 | 4 votes |
private void updatePopupPath(DockingAction action, String actionString, ProgramLocation loc) { String endString = ""; if (action == historyAction) { endString = "..."; } if (loc instanceof FunctionRepeatableCommentFieldLocation) { action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Repeatable Comment" + endString }); return; } if (loc instanceof PlateFieldLocation) { action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Plate Comment" + endString }); return; } CommentFieldLocation cfLoc = (CommentFieldLocation) loc; int type = cfLoc.getCommentType(); switch (type) { case CodeUnit.PRE_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Pre-Comment" + endString }); break; case CodeUnit.POST_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Post-Comment" + endString }); break; case CodeUnit.EOL_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " EOL Comment" + endString }); break; case CodeUnit.REPEATABLE_COMMENT: action.getPopupMenuData().setMenuPath( new String[] { "Comments", actionString + " Repeatable Comment" + endString }); break; } }
Example 12
Source File: PreCommentMarkupType.java From ghidra with Apache License 2.0 | 4 votes |
@Override protected int getCodeUnitCommentType() { return CodeUnit.PRE_COMMENT; }