forked from NationalSecurityAgency/ghidra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'origin/GP-2090-dragonmacher-decompiler-brace-actions' (Closes NationalSecurityAgency#4264)
- Loading branch information
Showing
9 changed files
with
568 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ecompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/GoToNextBraceAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* ### | ||
* IP: GHIDRA | ||
* | ||
* 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:https://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. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package ghidra.app.plugin.core.decompile.actions; | ||
|
||
import java.awt.event.InputEvent; | ||
import java.awt.event.KeyEvent; | ||
|
||
import docking.action.KeyBindingData; | ||
import ghidra.app.decompiler.ClangSyntaxToken; | ||
import ghidra.app.decompiler.ClangToken; | ||
import ghidra.app.decompiler.component.DecompilerPanel; | ||
import ghidra.app.decompiler.component.DecompilerUtils; | ||
import ghidra.app.plugin.core.decompile.DecompilerActionContext; | ||
import ghidra.app.util.HelpTopics; | ||
import ghidra.util.HelpLocation; | ||
|
||
/** | ||
* Go to the next enclosing closing brace in the forward direction. | ||
*/ | ||
public class GoToNextBraceAction extends AbstractDecompilerAction { | ||
|
||
public GoToNextBraceAction() { | ||
super("Go To Next Brace"); | ||
|
||
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "GoToBrace")); | ||
setKeyBindingData( | ||
new KeyBindingData(KeyEvent.VK_CLOSE_BRACKET, InputEvent.SHIFT_DOWN_MASK)); | ||
} | ||
|
||
@Override | ||
protected boolean isEnabledForDecompilerContext(DecompilerActionContext context) { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void decompilerActionPerformed(DecompilerActionContext context) { | ||
|
||
ClangToken token = context.getTokenAtCursor(); | ||
ClangSyntaxToken brace = DecompilerUtils.getNextBrace(token, true); | ||
if (brace != null) { | ||
DecompilerPanel panel = context.getDecompilerPanel(); | ||
panel.goToToken(brace); | ||
} | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...piler/src/main/java/ghidra/app/plugin/core/decompile/actions/GoToPreviousBraceAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* ### | ||
* IP: GHIDRA | ||
* | ||
* 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:https://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. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package ghidra.app.plugin.core.decompile.actions; | ||
|
||
import java.awt.event.InputEvent; | ||
import java.awt.event.KeyEvent; | ||
|
||
import docking.action.KeyBindingData; | ||
import ghidra.app.decompiler.ClangSyntaxToken; | ||
import ghidra.app.decompiler.ClangToken; | ||
import ghidra.app.decompiler.component.DecompilerPanel; | ||
import ghidra.app.decompiler.component.DecompilerUtils; | ||
import ghidra.app.plugin.core.decompile.DecompilerActionContext; | ||
import ghidra.app.util.HelpTopics; | ||
import ghidra.util.HelpLocation; | ||
|
||
/** | ||
* Go to the previous enclosing opening brace in the backward direction. | ||
*/ | ||
public class GoToPreviousBraceAction extends AbstractDecompilerAction { | ||
|
||
public GoToPreviousBraceAction() { | ||
super("Go To Previous Brace"); | ||
|
||
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "GoToBrace")); | ||
setKeyBindingData(new KeyBindingData(KeyEvent.VK_OPEN_BRACKET, InputEvent.SHIFT_DOWN_MASK)); | ||
} | ||
|
||
@Override | ||
protected boolean isEnabledForDecompilerContext(DecompilerActionContext context) { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void decompilerActionPerformed(DecompilerActionContext context) { | ||
|
||
ClangToken token = context.getTokenAtCursor(); | ||
ClangSyntaxToken brace = DecompilerUtils.getNextBrace(token, false); | ||
if (brace != null) { | ||
DecompilerPanel panel = context.getDecompilerPanel(); | ||
panel.goToToken(brace); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.