Syntax Cleanup

This commit is contained in:
Konloch 2024-10-01 23:07:51 -06:00
parent c713a203ba
commit 938ee3f51b

AI 샘플 코드 생성 중입니다

Loading...
9 changed files with 136 additions and 110 deletions

View File

@ -62,7 +62,9 @@ public final class ASMResourceUtil
{
FieldInsnNode field = (FieldInsnNode) i;
if (field.owner.equals(originalParentName) && field.name.equals(originalFieldName) && field.desc.equals(originalFieldDesc))
if (field.owner.equals(originalParentName)
&& field.name.equals(originalFieldName)
&& field.desc.equals(originalFieldDesc))
{
if (newFieldParent != null)
field.owner = newFieldParent;
@ -90,12 +92,16 @@ public final class ASMResourceUtil
if (i instanceof MethodInsnNode)
{
MethodInsnNode mi = (MethodInsnNode) i;
if (mi.owner.equals(originalParentName) && mi.name.equals(originalMethodName) && mi.desc.equals(originalMethodDesc))
if (mi.owner.equals(originalParentName)
&& mi.name.equals(originalMethodName)
&& mi.desc.equals(originalMethodDesc))
{
if (newParent != null)
mi.owner = newParent;
if (newName != null)
mi.name = newName;
if (newDesc != null)
mi.desc = newDesc;
}
@ -108,14 +114,18 @@ public final class ASMResourceUtil
{
if (newName != null)
m.signature = m.signature.replace(originalMethodName, newName);
if (newParent != null)
m.signature = m.signature.replace(originalParentName, newParent);
}
if (m.name.equals(originalMethodName) && m.desc.equals(originalMethodDesc) && c.name.equals(originalParentName))
if (m.name.equals(originalMethodName)
&& m.desc.equals(originalMethodDesc)
&& c.name.equals(originalParentName))
{
if (newName != null)
m.name = newName;
if (newDesc != null)
m.desc = newDesc;
}

View File

@ -76,7 +76,8 @@ public class SearchableJTextArea extends JTextArea
addKeyListener(new PressKeyListener(keyEvent ->
{
if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
if ((keyEvent.getKeyCode() == KeyEvent.VK_F)
&& ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
searchInput.requestFocus();
GlobalHotKeys.keyPressed(keyEvent);

View File

@ -74,10 +74,12 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
addKeyListener(new PressKeyListener(keyEvent ->
{
if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
if ((keyEvent.getKeyCode() == KeyEvent.VK_F)
&& ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
this.textAreaSearchPanel.getSearchInput().requestFocusInWindow();
if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S)
&& ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
{
onCtrlS.run();
return;

View File

@ -44,9 +44,12 @@ public class GoToAction extends AbstractAction
container.fieldMembers.values().forEach(fields -> fields.forEach(field ->
{
if (field.line == line && field.columnStart - 1 <= column && field.columnEnd >= column)
if (field.line == line
&& field.columnStart - 1 <= column
&& field.columnEnd >= column)
{
Element root = textArea.getDocument().getDefaultRootElement();
// Open the class that is associated with the field's owner.
if (!field.owner.equals(container.getName()))
{
@ -353,6 +356,7 @@ public class GoToAction extends AbstractAction
Element root = panel.textArea.getDocument().getDefaultRootElement();
int startOffset = root.getElement(line - 1).getStartOffset() + (columnStart - 1);
panel.textArea.setCaretPosition(startOffset);
for (CaretListener caretListener : panel.textArea.getCaretListeners())
{
if (caretListener instanceof BytecodeViewPanelUpdater.MarkerCaretListener)

View File

@ -148,19 +148,12 @@ public class ValuesPanel extends javax.swing.JPanel
binaryLabel.setText("Binary");
binaryCheckBox0.addActionListener(this::binaryCheckBox0ActionPerformed);
binaryCheckBox1.addActionListener(this::binaryCheckBox1ActionPerformed);
binaryCheckBox2.addActionListener(this::binaryCheckBox2ActionPerformed);
binaryCheckBox3.addActionListener(this::binaryCheckBox3ActionPerformed);
binaryCheckBox4.addActionListener(this::binaryCheckBox4ActionPerformed);
binaryCheckBox5.addActionListener(this::binaryCheckBox5ActionPerformed);
binaryCheckBox6.addActionListener(this::binaryCheckBox6ActionPerformed);
binaryCheckBox7.addActionListener(this::binaryCheckBox7ActionPerformed);
byteLabel.setText("Byte");
@ -303,7 +296,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox0ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox0ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x80) > 0 != binaryCheckBox0.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x80) > 0 != binaryCheckBox0.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x80);
modifyValues(1);
@ -312,7 +306,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox1ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox1ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x40) > 0 != binaryCheckBox1.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x40) > 0 != binaryCheckBox1.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x40);
modifyValues(1);
@ -321,7 +316,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox2ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox2ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x20) > 0 != binaryCheckBox2.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x20) > 0 != binaryCheckBox2.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x20);
modifyValues(1);
@ -330,7 +326,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox3ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox3ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x10) > 0 != binaryCheckBox3.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x10) > 0 != binaryCheckBox3.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x10);
modifyValues(1);
@ -339,7 +336,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox4ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox4ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x8) > 0 != binaryCheckBox4.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x8) > 0 != binaryCheckBox4.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x8);
modifyValues(1);
@ -348,7 +346,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox5ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox5ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x4) > 0 != binaryCheckBox5.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x4) > 0 != binaryCheckBox5.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x4);
modifyValues(1);
@ -357,7 +356,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox6ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox6ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x2) > 0 != binaryCheckBox6.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x2) > 0 != binaryCheckBox6.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x2);
modifyValues(1);
@ -366,7 +366,8 @@ public class ValuesPanel extends javax.swing.JPanel
private void binaryCheckBox7ActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_binaryCheckBox7ActionPerformed
if (!valuesUpdater.isUpdateInProgress() && ((valuesCache[0] & 0x1) > 0 != binaryCheckBox7.isSelected()))
if (!valuesUpdater.isUpdateInProgress()
&& ((valuesCache[0] & 0x1) > 0 != binaryCheckBox7.isSelected()))
{
valuesCache[0] = (byte) (valuesCache[0] ^ 0x1);
modifyValues(1);
@ -383,16 +384,12 @@ public class ValuesPanel extends javax.swing.JPanel
if (isSigned())
{
if (intValue < Byte.MIN_VALUE || intValue > Byte.MAX_VALUE)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
}
else
{
if (intValue < 0 || intValue > UBYTE_MAX_VALUE)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
}
valuesCache[0] = (byte) intValue;
@ -416,16 +413,12 @@ public class ValuesPanel extends javax.swing.JPanel
if (isSigned())
{
if (intValue < SWORD_MIN_VALUE || intValue > SWORD_MAX_VALUE)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
}
else
{
if (intValue < 0 || intValue > UWORD_MAX_VALUE)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
}
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
@ -438,6 +431,7 @@ public class ValuesPanel extends javax.swing.JPanel
valuesCache[0] = (byte) ((intValue >> 8) & 0xff);
valuesCache[1] = (byte) (intValue & 0xff);
}
modifyValues(2);
updateValues();
}
@ -458,16 +452,12 @@ public class ValuesPanel extends javax.swing.JPanel
if (isSigned())
{
if (longValue < Integer.MIN_VALUE || longValue > Integer.MAX_VALUE)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
}
else
{
if (longValue < 0 || longValue > UINT_MAX_VALUE)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
}
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
@ -484,6 +474,7 @@ public class ValuesPanel extends javax.swing.JPanel
valuesCache[2] = (byte) ((longValue >> 8) & 0xff);
valuesCache[3] = (byte) (longValue & 0xff);
}
modifyValues(4);
updateValues();
}
@ -507,9 +498,7 @@ public class ValuesPanel extends javax.swing.JPanel
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder)
{
byteBuffer.order(byteOrder);
}
byteBuffer.putLong(longValue);
}
@ -517,9 +506,7 @@ public class ValuesPanel extends javax.swing.JPanel
{
BigInteger bigInteger = new BigInteger(longTextField.getText());
if (bigInteger.signum() == -1 || bigInteger.compareTo(ULONG_MAX_VALUE) > 0)
{
throw new NumberFormatException(VALUE_OUT_OF_RANGE);
}
if (byteOrder == ByteOrder.LITTLE_ENDIAN)
{
@ -561,10 +548,9 @@ public class ValuesPanel extends javax.swing.JPanel
float floatValue = Float.parseFloat(floatTextField.getText());
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder)
{
byteBuffer.order(byteOrder);
}
byteBuffer.putFloat(floatValue);
@ -588,10 +574,9 @@ public class ValuesPanel extends javax.swing.JPanel
double doubleValue = Double.parseDouble(doubleTextField.getText());
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder)
{
byteBuffer.order(byteOrder);
}
byteBuffer.putDouble(doubleValue);
@ -612,15 +597,12 @@ public class ValuesPanel extends javax.swing.JPanel
try
{
String characterText = characterTextField.getText();
if (characterText.length() == 0)
{
throw new InputMismatchException("Empty value not valid");
}
if (characterText.length() > 1)
{
throw new InputMismatchException("Only single character allowed");
}
byte[] bytes = characterText.getBytes(codeArea.getCharset());
System.arraycopy(bytes, 0, valuesCache, 0, bytes.length);
@ -642,16 +624,15 @@ public class ValuesPanel extends javax.swing.JPanel
try
{
String characterText = stringTextField.getText();
if (characterText.length() == 0)
{
throw new InputMismatchException("Empty value not valid");
}
byte[] bytes = characterText.getBytes(codeArea.getCharset());
if (bytes.length > CACHE_SIZE)
{
throw new InputMismatchException("String is too long");
}
System.arraycopy(bytes, 0, valuesCache, 0, bytes.length);
modifyValues(bytes.length);
@ -676,9 +657,11 @@ public class ValuesPanel extends javax.swing.JPanel
updateEditMode();
updateValues();
};
codeArea.addDataChangedListener(dataChangedListener);
caretMovedListener = (CodeAreaCaretPosition caretPosition) -> updateValues();
codeArea.addCaretMovedListener(caretMovedListener);
updateEditMode();
updateValues();
}
@ -692,6 +675,7 @@ public class ValuesPanel extends javax.swing.JPanel
public void updateEditMode()
{
boolean editable = isEditable();
binaryCheckBox0.setEnabled(editable);
binaryCheckBox1.setEnabled(editable);
binaryCheckBox2.setEnabled(editable);
@ -721,10 +705,9 @@ public class ValuesPanel extends javax.swing.JPanel
int availableData = dataSize - dataPosition >= CACHE_SIZE ? CACHE_SIZE : (int) (dataSize - dataPosition);
BinaryData contentData = Objects.requireNonNull(codeArea.getContentData());
contentData.copyToArray(dataPosition, valuesCache, 0, availableData);
if (availableData < CACHE_SIZE)
{
Arrays.fill(valuesCache, availableData, CACHE_SIZE, (byte) 0);
}
}
valuesUpdater.schedule();
@ -791,9 +774,8 @@ public class ValuesPanel extends javax.swing.JPanel
private synchronized void schedule()
{
if (updateInProgress)
{
updateTerminated = true;
}
if (!scheduleUpdate)
{
scheduleUpdate = true;
@ -816,15 +798,16 @@ public class ValuesPanel extends javax.swing.JPanel
if (valuesPanelField.ordinal() == 0)
{
long dataSize = codeArea.getDataSize();
clearFields = dataPosition >= dataSize;
byteOrder = littleEndianRadioButton.isSelected() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
byteOrder = getByteOrder();
signed = isSigned();
values = valuesCache;
if (clearFields)
{
values[0] = 0;
}
updateStarted();
}
@ -835,20 +818,15 @@ public class ValuesPanel extends javax.swing.JPanel
}
if (clearFields)
{
clearField(valuesPanelField);
}
else
{
updateField(valuesPanelField);
}
final ValuesPanelField[] panelFields = ValuesPanelField.values();
ValuesPanelField lastValue = panelFields[panelFields.length - 1];
if (valuesPanelField == lastValue)
{
stopUpdate();
}
else
{
SwingUtilities.invokeLater(() ->
@ -868,67 +846,77 @@ public class ValuesPanel extends javax.swing.JPanel
binaryCheckBox0.setSelected((values[0] & 0x80) > 0);
break;
}
case BINARY1:
{
binaryCheckBox1.setSelected((values[0] & 0x40) > 0);
break;
}
case BINARY2:
{
binaryCheckBox2.setSelected((values[0] & 0x20) > 0);
break;
}
case BINARY3:
{
binaryCheckBox3.setSelected((values[0] & 0x10) > 0);
break;
}
case BINARY4:
{
binaryCheckBox4.setSelected((values[0] & 0x8) > 0);
break;
}
case BINARY5:
{
binaryCheckBox5.setSelected((values[0] & 0x4) > 0);
break;
}
case BINARY6:
{
binaryCheckBox6.setSelected((values[0] & 0x2) > 0);
break;
}
case BINARY7:
{
binaryCheckBox7.setSelected((values[0] & 0x1) > 0);
break;
}
case BYTE:
{
byteTextField.setText(String.valueOf(signed ? values[0] : values[0] & 0xff));
break;
}
case WORD:
{
int wordValue = signed ? (byteOrder == ByteOrder.LITTLE_ENDIAN ? (values[0] & 0xff) | (values[1] << 8) : (values[1] & 0xff) | (values[0] << 8)) : (byteOrder == ByteOrder.LITTLE_ENDIAN ? (values[0] & 0xff) | ((values[1] & 0xff) << 8) : (values[1] & 0xff) | ((values[0] & 0xff) << 8));
wordTextField.setText(String.valueOf(wordValue));
break;
}
case INTEGER:
{
long intValue = signed ? (byteOrder == ByteOrder.LITTLE_ENDIAN ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | (values[3] << 24) : (values[3] & 0xffL) | ((values[2] & 0xffL) << 8) | ((values[1] & 0xffL) << 16) | (values[0] << 24)) : (byteOrder == ByteOrder.LITTLE_ENDIAN ? (values[0] & 0xffL) | ((values[1] & 0xffL) << 8) | ((values[2] & 0xffL) << 16) | ((values[3] & 0xffL) << 24) : (values[3] & 0xffL) | ((values[2] & 0xffL) << 8) | ((values[1] & 0xffL) << 16) | ((values[0] & 0xffL) << 24));
intTextField.setText(String.valueOf(intValue));
break;
}
case LONG:
{
if (signed)
{
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder)
{
byteBuffer.order(byteOrder);
}
longTextField.setText(String.valueOf(byteBuffer.getLong()));
}
@ -942,53 +930,54 @@ public class ValuesPanel extends javax.swing.JPanel
}
break;
}
case FLOAT:
{
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder)
{
byteBuffer.order(byteOrder);
}
floatTextField.setText(String.valueOf(byteBuffer.getFloat()));
break;
}
case DOUBLE:
{
byteBuffer.rewind();
if (byteBuffer.order() != byteOrder)
{
byteBuffer.order(byteOrder);
}
doubleTextField.setText(String.valueOf(byteBuffer.getDouble()));
break;
}
case CHARACTER:
{
String strValue = new String(values, codeArea.getCharset());
if (strValue.length() > 0)
{
characterTextField.setText(strValue.substring(0, 1));
}
else
{
characterTextField.setText("");
}
break;
}
case STRING:
{
String strValue = new String(values, codeArea.getCharset());
for (int i = 0; i < strValue.length(); i++)
{
char charAt = strValue.charAt(i);
if (charAt == '\r' || charAt == '\n' || charAt == 0)
{
strValue = strValue.substring(0, i);
break;
}
}
stringTextField.setText(strValue);
stringTextField.setCaretPosition(0);
break;
@ -1005,76 +994,91 @@ public class ValuesPanel extends javax.swing.JPanel
binaryCheckBox0.setSelected(false);
break;
}
case BINARY1:
{
binaryCheckBox1.setSelected(false);
break;
}
case BINARY2:
{
binaryCheckBox2.setSelected(false);
break;
}
case BINARY3:
{
binaryCheckBox3.setSelected(false);
break;
}
case BINARY4:
{
binaryCheckBox4.setSelected(false);
break;
}
case BINARY5:
{
binaryCheckBox5.setSelected(false);
break;
}
case BINARY6:
{
binaryCheckBox6.setSelected(false);
break;
}
case BINARY7:
{
binaryCheckBox7.setSelected(false);
break;
}
case BYTE:
{
byteTextField.setText("");
break;
}
case WORD:
{
wordTextField.setText("");
break;
}
case INTEGER:
{
intTextField.setText("");
break;
}
case LONG:
{
longTextField.setText("");
break;
}
case FLOAT:
{
floatTextField.setText("");
break;
}
case DOUBLE:
{
doubleTextField.setText("");
break;
}
case CHARACTER:
{
characterTextField.setText("");
break;
}
case STRING:
{
stringTextField.setText("");

View File

@ -57,12 +57,11 @@ public class ResourceTreeNode extends DefaultMutableTreeNode
private void recursiveSort(ResourceTreeNode node)
{
node.children.sort(nodeComparator);
for (TreeNode nextNode : (Iterable<TreeNode>) node.children)
{
if (nextNode.getChildCount() > 0)
{
recursiveSort((ResourceTreeNode) nextNode);
}
}
}
@ -76,13 +75,9 @@ public class ResourceTreeNode extends DefaultMutableTreeNode
private void addToMap(ResourceTreeNode newChild)
{
if (userObjectToChildMap != null)
{
userObjectToChildMap.put(newChild.getUserObject(), newChild);
}
else if (getChildCount() == CHILD_MAP_BUILD_THRESHOLD)
{
buildMap();
}
}
private void buildMap()
@ -112,9 +107,7 @@ public class ResourceTreeNode extends DefaultMutableTreeNode
public void remove(MutableTreeNode aChild)
{
if (userObjectToChildMap != null && aChild != null)
{
userObjectToChildMap.remove(((ResourceTreeNode) aChild).getUserObject());
}
super.remove(aChild);
}
@ -123,9 +116,7 @@ public class ResourceTreeNode extends DefaultMutableTreeNode
public void removeAllChildren()
{
if (userObjectToChildMap != null)
{
userObjectToChildMap.clear();
}
super.removeAllChildren();
}
@ -133,17 +124,14 @@ public class ResourceTreeNode extends DefaultMutableTreeNode
public ResourceTreeNode getChildByUserObject(Object userObject)
{
if (userObjectToChildMap != null)
{
return userObjectToChildMap.get(userObject);
}
for (int i = 0, childCount = getChildCount(); i < childCount; i++)
{
ResourceTreeNode child = (ResourceTreeNode) getChildAt(i);
if (child.getUserObject().equals(userObject))
{
return child;
}
}
return null;

View File

@ -82,17 +82,21 @@ public class FileViewer extends ResourceViewer
// (If none selected, try Pane2, Pane3, default to Procyon)
//check by file extension to display image
if (!onlyName.contains(":") && ResourceType.IMAGE_EXTENSION_MAP.containsKey(FilenameUtils.getExtension(onlyName)) && !hexViewerOnly)
if (!onlyName.contains(":")
&& ResourceType.IMAGE_EXTENSION_MAP.containsKey(FilenameUtils.getExtension(onlyName))
&& !hexViewerOnly)
{
canRefresh = true;
image = MiscUtils.loadImage(image, contents);
if (image == null)
{
HexViewer hex = new HexViewer(contents);
mainPanel.add(hex);
return;
}
originalImage = image;
mainPanel.add(new ImageJLabel(image), BorderLayout.CENTER);
@ -103,16 +107,10 @@ public class FileViewer extends ResourceViewer
int height = originalImage.getHeight();
int oldZoomSteps = zoomSteps;
if (notches < 0)
{
//zoom in
if (notches < 0) //zoom in
zoomSteps++;
}
else
{
//zoom out
else //zoom out
zoomSteps--;
}
try
{
@ -132,6 +130,7 @@ public class FileViewer extends ResourceViewer
});
return;
}
//hex viewer
else if (BytecodeViewer.viewer.forcePureAsciiAsText.isSelected() || hexViewerOnly)
{

View File

@ -247,19 +247,22 @@ public class BytecodeViewPanelUpdater implements Runnable
if (BytecodeViewer.viewer.synchronizedViewing.isSelected())
{
if (updateUpdaterTextArea.isShowing() && (updateUpdaterTextArea.hasFocus() || updateUpdaterTextArea.getMousePosition() != null))
if (updateUpdaterTextArea.isShowing()
&& (updateUpdaterTextArea.hasFocus() || updateUpdaterTextArea.getMousePosition() != null))
{
int caretLine = updateUpdaterTextArea.getCaretLineNumber();
int maxViewLine = ClassViewer.getMaxViewLine(updateUpdaterTextArea);
int activeViewLine = ClassViewer.getViewLine(updateUpdaterTextArea);
int activeLine = (activeViewLine == maxViewLine && caretLine > maxViewLine) ? caretLine : activeViewLine;
int activeLineDelta = -1;
MethodParser.Method activeMethod = null;
MethodParser activeMethods = viewer.methods.get(bytecodeViewPanel.panelIndex);
if (activeMethods != null)
{
int activeMethodLine = activeMethods.findActiveMethod(activeLine);
if (activeMethodLine != -1)
{
activeLineDelta = activeLine - activeMethodLine;
@ -299,10 +302,9 @@ public class BytecodeViewPanelUpdater implements Runnable
if (methodLine != -1)
{
int viewLine = ClassViewer.getViewLine(area);
if (activeLineDelta != viewLine - methodLine)
{
setLine = methodLine + activeLineDelta;
}
}
}
}
@ -312,9 +314,7 @@ public class BytecodeViewPanelUpdater implements Runnable
}
if (setLine >= 0)
{
ClassViewer.setViewLine(area, setLine);
}
}
}
}
@ -341,6 +341,7 @@ public class BytecodeViewPanelUpdater implements Runnable
{
String lineText = updateUpdaterTextArea.getLineText(i);
Matcher regexMatcher = MethodParser.REGEX.matcher(lineText);
if (regexMatcher.find())
{
String methodName = regexMatcher.group("name");
@ -370,9 +371,11 @@ public class BytecodeViewPanelUpdater implements Runnable
case 0:
area = viewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea;
break;
case 1:
area = viewer.bytecodeViewPanel2.updateThread.updateUpdaterTextArea;
break;
case 2:
area = viewer.bytecodeViewPanel3.updateThread.updateUpdaterTextArea;
break;
@ -507,6 +510,7 @@ public class BytecodeViewPanelUpdater implements Runnable
if (token == null)
{
token = textArea.modelToToken(textArea.getCaretPosition() - 1);
if (token == null)
{
highlighterEx.clearMarkOccurrencesHighlights();
@ -553,7 +557,8 @@ public class BytecodeViewPanelUpdater implements Runnable
errorStripe.refreshMarkers();
}
private void markField(RSyntaxTextArea textArea, ClassFileContainer classFileContainer, int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
private void markField(RSyntaxTextArea textArea, ClassFileContainer classFileContainer,
int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
{
classFileContainer.fieldMembers.values().forEach(fields -> fields.forEach(field ->
{
@ -562,6 +567,7 @@ public class BytecodeViewPanelUpdater implements Runnable
try
{
Element root = textArea.getDocument().getDefaultRootElement();
for (ClassFieldLocation location : classFileContainer.getFieldLocationsFor(finalToken.getLexeme()))
{
int startOffset = root.getElement(location.line - 1).getStartOffset() + (location.columnStart - 1);
@ -577,22 +583,27 @@ public class BytecodeViewPanelUpdater implements Runnable
}));
}
private void markMethod(RSyntaxTextArea textArea, ClassFileContainer classFileContainer, int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
private void markMethod(RSyntaxTextArea textArea, ClassFileContainer classFileContainer,
int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
{
classFileContainer.methodMembers.values().forEach(methods -> methods.forEach(method ->
{
String owner;
String parameters;
if (method.line == line && method.columnStart - 1 <= column && method.columnEnd >= column)
if (method.line == line && method.columnStart - 1 <= column
&& method.columnEnd >= column)
{
owner = method.owner;
parameters = method.methodParameterTypes;
Element root = textArea.getDocument().getDefaultRootElement();
for (ClassMethodLocation location : classFileContainer.getMethodLocationsFor(finalToken.getLexeme()))
{
try
{
if (Objects.equals(owner, location.owner) && Objects.equals(parameters, location.methodParameterTypes))
if (Objects.equals(owner, location.owner)
&& Objects.equals(parameters, location.methodParameterTypes))
{
int startOffset = root.getElement(location.line - 1).getStartOffset() + (location.columnStart - 1);
int endOffset = root.getElement(location.line - 1).getStartOffset() + (location.columnEnd - 1);
@ -618,7 +629,8 @@ public class BytecodeViewPanelUpdater implements Runnable
* @param finalToken the token
* @param highlighterEx the highlighter
*/
private void markMethodParameter(RSyntaxTextArea textArea, ClassFileContainer classFileContainer, int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
private void markMethodParameter(RSyntaxTextArea textArea, ClassFileContainer classFileContainer,
int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
{
classFileContainer.methodParameterMembers.values().forEach(parameters -> parameters.forEach(parameter ->
{
@ -629,6 +641,7 @@ public class BytecodeViewPanelUpdater implements Runnable
try
{
Element root = textArea.getDocument().getDefaultRootElement();
for (ClassParameterLocation location : classFileContainer.getParameterLocationsFor(finalToken.getLexeme()))
{
if (Objects.equals(method, location.method))
@ -657,17 +670,21 @@ public class BytecodeViewPanelUpdater implements Runnable
* @param finalToken the token
* @param highlighterEx the highlighter
*/
private void markMethodLocalVariable(RSyntaxTextArea textArea, ClassFileContainer classFileContainer, int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
private void markMethodLocalVariable(RSyntaxTextArea textArea, ClassFileContainer classFileContainer,
int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
{
classFileContainer.methodLocalMembers.values().forEach(localVariables -> localVariables.forEach(localVariable ->
{
String method;
if (localVariable.line == line && localVariable.columnStart - 1 <= column && localVariable.columnEnd >= column)
if (localVariable.line == line
&& localVariable.columnStart - 1 <= column
&& localVariable.columnEnd >= column)
{
method = localVariable.method;
try
{
Element root = textArea.getDocument().getDefaultRootElement();
for (ClassLocalVariableLocation location : classFileContainer.getLocalLocationsFor(finalToken.getLexeme()))
{
if (Objects.equals(method, location.method))
@ -686,7 +703,8 @@ public class BytecodeViewPanelUpdater implements Runnable
}));
}
private void markClasses(RSyntaxTextArea textArea, ClassFileContainer classFileContainer, int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
private void markClasses(RSyntaxTextArea textArea, ClassFileContainer classFileContainer,
int line, int column, Token finalToken, RSyntaxTextAreaHighlighterEx highlighterEx)
{
classFileContainer.classReferences.values().forEach(classes -> classes.forEach(clazz ->
{
@ -695,6 +713,7 @@ public class BytecodeViewPanelUpdater implements Runnable
try
{
Element root = textArea.getDocument().getDefaultRootElement();
for (ClassReferenceLocation location : classFileContainer.getClassReferenceLocationsFor(finalToken.getLexeme()))
{
int startOffset = root.getElement(location.line - 1).getStartOffset() + (location.columnStart - 1);

View File

@ -171,6 +171,7 @@ public class MethodParser
if (!methods.isEmpty())
{
Map.Entry<Integer, Method> low = methods.floorEntry(line);
if (low != null)
return low.getKey();
}
@ -183,9 +184,7 @@ public class MethodParser
if (!methods.isEmpty())
{
if (methods.size() == 1)
{
return methods.firstKey();
}
else
{
Map.Entry<Integer, Method> low = methods.floorEntry(line);