mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/patch' into
GP-0-dragonmacher-patch-merge
This commit is contained in:
commit
0ad5aa6710
2 changed files with 24 additions and 25 deletions
|
@ -90,6 +90,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private Set<String> ignoredMiddleMouseTokens = Set.of("{", "}", ";");
|
||||||
private ActiveMiddleMouse activeMiddleMouse;
|
private ActiveMiddleMouse activeMiddleMouse;
|
||||||
private int middleMouseHighlightButton;
|
private int middleMouseHighlightButton;
|
||||||
private Color middleMouseHighlightColor;
|
private Color middleMouseHighlightColor;
|
||||||
|
@ -264,11 +265,10 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
||||||
}
|
}
|
||||||
|
|
||||||
// exclude tokens that users do not want to highlight
|
// exclude tokens that users do not want to highlight
|
||||||
if (token instanceof ClangOpToken) {
|
if (shouldIgnoreOpToken(token)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (shouldIgnoreSyntaxTokenHighlight(token)) {
|
||||||
if (token instanceof ClangSyntaxToken syntaxToken && !isNamespace(syntaxToken)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,26 +277,24 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
||||||
activeMiddleMouse = newMiddleMouse;
|
activeMiddleMouse = newMiddleMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNamespace(ClangSyntaxToken token) {
|
private boolean shouldIgnoreOpToken(ClangToken token) {
|
||||||
|
if (!(token instanceof ClangOpToken)) {
|
||||||
String text = token.getText();
|
|
||||||
if (text.length() <= 1) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if we have a '::' token trailing this token
|
// users would like to be able to highlight return statements
|
||||||
ClangLine line = token.getLineParent();
|
String text = token.toString();
|
||||||
int index = line.indexOfToken(token);
|
return !text.equals("return");
|
||||||
for (int i = index + 1; i < line.getNumTokens(); i++) {
|
}
|
||||||
ClangToken nextToken = line.getToken(i);
|
|
||||||
String nextText = nextToken.getText();
|
|
||||||
if (nextText.isBlank()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nextText.equals("::");
|
private boolean shouldIgnoreSyntaxTokenHighlight(ClangToken token) {
|
||||||
|
|
||||||
|
if (!(token instanceof ClangSyntaxToken syntaxToken)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
String string = syntaxToken.toString();
|
||||||
|
return ignoredMiddleMouseTokens.contains(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addHighlighterHighlights(ClangDecompilerHighlighter highlighter,
|
void addHighlighterHighlights(ClangDecompilerHighlighter highlighter,
|
||||||
|
@ -771,7 +769,6 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
||||||
|
|
||||||
int clickCount = ev.getClickCount();
|
int clickCount = ev.getClickCount();
|
||||||
int buttonState = ev.getButton();
|
int buttonState = ev.getButton();
|
||||||
|
|
||||||
if (buttonState == MouseEvent.BUTTON1) {
|
if (buttonState == MouseEvent.BUTTON1) {
|
||||||
if (DockingUtils.isControlModifier(ev) && clickCount == 2) {
|
if (DockingUtils.isControlModifier(ev) && clickCount == 2) {
|
||||||
tryToGoto(location, field, ev, true);
|
tryToGoto(location, field, ev, true);
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class ToolUtils {
|
||||||
File[] toolFiles = USER_TOOLS_DIR.listFiles(filter);
|
File[] toolFiles = USER_TOOLS_DIR.listFiles(filter);
|
||||||
if (toolFiles != null) {
|
if (toolFiles != null) {
|
||||||
for (File toolFile : toolFiles) {
|
for (File toolFile : toolFiles) {
|
||||||
ToolTemplate template = ToolUtils.readToolTemplate(toolFile);
|
ToolTemplate template = readToolTemplate(toolFile);
|
||||||
if (template != null) {
|
if (template != null) {
|
||||||
map.put(template.getName(), template);
|
map.put(template.getName(), template);
|
||||||
}
|
}
|
||||||
|
@ -202,9 +202,9 @@ public class ToolUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renameToolTemplate(ToolTemplate toolTemplate, String newName) {
|
public static void renameToolTemplate(ToolTemplate toolTemplate, String newName) {
|
||||||
ToolUtils.deleteTool(toolTemplate);
|
deleteTool(toolTemplate);
|
||||||
toolTemplate.setName(newName);
|
toolTemplate.setName(newName);
|
||||||
ToolUtils.writeToolTemplate(toolTemplate);
|
writeToolTemplate(toolTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean writeToolTemplate(ToolTemplate template) {
|
public static boolean writeToolTemplate(ToolTemplate template) {
|
||||||
|
@ -232,6 +232,8 @@ public class ToolUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ToolTemplate readToolTemplate(File toolFile) {
|
public static ToolTemplate readToolTemplate(File toolFile) {
|
||||||
|
|
||||||
|
LOGGER.trace("Loading tool file {}", toolFile);
|
||||||
GhidraToolTemplate toolTemplate = null;
|
GhidraToolTemplate toolTemplate = null;
|
||||||
try (FileInputStream is = new FileInputStream(toolFile)) {
|
try (FileInputStream is = new FileInputStream(toolFile)) {
|
||||||
|
|
||||||
|
@ -331,7 +333,7 @@ public class ToolUtils {
|
||||||
public static String getUniqueToolName(ToolTemplate template) {
|
public static String getUniqueToolName(ToolTemplate template) {
|
||||||
String name = template.getName();
|
String name = template.getName();
|
||||||
int n = 1;
|
int n = 1;
|
||||||
while (ToolUtils.getToolFile(name).exists()) {
|
while (getToolFile(name).exists()) {
|
||||||
name = name + "_" + n++;
|
name = name + "_" + n++;
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue