Skip to content

Commit

Permalink
unused minimal json library removed
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz committed Mar 16, 2024
1 parent f2b6022 commit d87af75
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 220 deletions.
16 changes: 1 addition & 15 deletions AUDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,8 @@ _Primary Source: https://mvnrepository.com/artifact/org.ow2.asm/asm_
* SHA-256: cda4de455fab48ff0bcb7c48b4639447d4de859a7afc30a094a986f0936beba2
* https://repo1.maven.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.jar

### Apache commons

_Primary Source: https://commons.apache.org/downloads/index.html_

* `./org.sf.feeling.decompiler.source.attach/lib/commons-compress.jar`
* Not included in ECD repository, downloaded automatically via Maven
* SHA-256: c267f17160e9ef662b4d78b7f29dca7c82b15c5cff2cb6a9865ef4ab3dd5b787
* Equal to https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.23.0/commons-compress-1.23.0.jar

### Fernflower
* `./org.sf.feeling.decompiler/lib/fernflower.jar`
* `./org.sf.feeling.decompiler.fernflower/lib/fernflower.jar`
* Not included in ECD repository, downloaded automatically via Maven
* SHA-256: 97b3579a221a3edf9651fca278257307441cb6dfdcfe1a1c6579f11002ff5d27
* Version from https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/java/java-decompiler-engine/232.10203.10/java-decompiler-engine-232.10203.10.jar
Expand All @@ -45,11 +36,6 @@ _Build Source: https://github.com/Vineflower/vineflower_
* version from: https://repo1.maven.org/maven2/org/vineflower/vineflower/1.9.3/vineflower-1.9.3.jar

### Minimal JSON
_Primary Source: https://github.com/ralfstx/minimal-json_

* `./org.sf.feeling.decompiler/lib/json.jar`
* SHA-256: e1d280900c78f18ae2e00c14e7410a77ba19cf084154b386532846aa6dc81721
* Version from http://central.maven.org/maven2/com/eclipsesource/minimal-json/minimal-json/0.9.4/minimal-json-0.9.4.jar

### CFR
_Project homepage: https://www.benf.org/other/cfr/_
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _If you have currently the "Eclipse" Class Decompiler installed, it is recommend

## How to build from source?

Requiremnent: JDK 11 or newer (make sure `JAVA_HOME` environment variable points to an appropriate JDK)
Requiremnent: JDK 17 (make sure `JAVA_HOME` environment variable points to an JDK 17)

If you want to test the latest features of this plugin, you have to build it from source. For this, proceed as following:

Expand Down
1 change: 0 additions & 1 deletion org.sf.feeling.decompiler/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/json.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.drgarbage.asm_5.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.drgarbage.asm.util_5.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/com.drgarbage.bytecodevisualizer.plugin_4.4.1.201408050542.jar"/>
Expand Down
6 changes: 2 additions & 4 deletions org.sf.feeling.decompiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Manifest-Version: 1.0
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/json.jar,
lib/com.drgarbage.asm_5.0.3.jar,
Bundle-ClassPath: lib/com.drgarbage.asm_5.0.3.jar,
lib/com.drgarbage.asm.util_5.0.3.jar,
lib/com.drgarbage.bytecodevisualizer.plugin_4.4.1.201408050542.jar,
lib/com.drgarbage.core.plugin_4.4.1.201408050542.jar,
Expand Down Expand Up @@ -37,8 +36,7 @@ Bundle-ManifestVersion: 2
Bundle-Activator: org.sf.feeling.decompiler.JavaDecompilerPlugin
Bundle-SymbolicName: org.sf.feeling.decompiler;singleton:=true
Eclipse-ExtensibleAPI: true
Export-Package: com.eclipsesource.json,
org.objectweb.asm,
Export-Package: org.objectweb.asm,
org.sf.feeling.decompiler,
org.sf.feeling.decompiler.actions,
org.sf.feeling.decompiler.editor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,12 @@
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.navigator.IExtensionStateConstants.Values;
import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
import org.eclipse.jdt.ui.text.IJavaColorConstants;
import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
Expand All @@ -54,15 +44,10 @@
import org.eclipse.ui.navigator.CommonNavigatorManager;
import org.eclipse.ui.navigator.IExtensionStateModel;
import org.eclipse.ui.navigator.INavigatorContentService;
import org.eclipse.ui.themes.ColorUtil;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.sf.feeling.decompiler.JavaDecompilerPlugin;
import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor;

import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonValue;

public class UIUtil {

public static void openBrowser(String url) {
Expand Down Expand Up @@ -408,142 +393,6 @@ public static boolean requestFromShowMatch() {
return false;
}

public static StyleRange getAdTextStyleRange(StyledText textWidget, int offset, int length) {
JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue(textTools, "fPreferenceStore"); //$NON-NLS-1$
String textColor = preferences.getString(IJavaColorConstants.JAVADOC_LINK);

StyleRange styleRange = null;
if (isDark(textWidget)) {
String darkStyleValue = JavaDecompilerPlugin.getDefault().getPreferenceStore().getString("darkStyle"); //$NON-NLS-1$
if (darkStyleValue != null && darkStyleValue.trim().length() > 0) {
styleRange = handleStyleValue(textWidget, offset, length, darkStyleValue, "text", textColor, false); //$NON-NLS-1$
}
} else {
String brightStyleValue = JavaDecompilerPlugin.getDefault().getPreferenceStore().getString("brightStyle"); //$NON-NLS-1$
if (brightStyleValue != null && brightStyleValue.trim().length() > 0) {
styleRange = handleStyleValue(textWidget, offset, length, brightStyleValue, "text", textColor, false); //$NON-NLS-1$
}

}

if (styleRange == null) {
styleRange = getDefaultCommonRange(textWidget, offset, length);
}
return styleRange;
}

private static StyleRange handleStyleValue(StyledText textWidget, int offset, int length, String brightStyleValue,
String property, String defaultColor, boolean isLink) {
JsonValue styleValue = null;
try {
styleValue = Json.parse(brightStyleValue);
} catch (Exception e) {
Logger.debug(e);
}

if (styleValue != null && styleValue.isObject()) {
JsonObject style = styleValue.asObject();
if (style.get(property) != null && style.get(property).isObject()) {
return getStyleRange(textWidget, offset, length, style.get(property).asObject(), defaultColor, isLink);
}
}

return null;
}

private static StyleRange getStyleRange(StyledText textWidget, int offset, int length, JsonObject style,
String defaultColor, boolean isLink) {
int contentLength = textWidget.getCharCount();
if (contentLength - offset < 0)
return null;
StyleRange range = new StyleRange(offset, offset + length < contentLength ? length : contentLength - offset,
defaultColor == null ? null
: JFaceResources.getResources().createColor(ColorUtil.getColorValue(defaultColor)),
null);
JsonValue fontStyleValue = style.get("fontStyle"); //$NON-NLS-1$
if (fontStyleValue != null && fontStyleValue.isNumber()) {
range.fontStyle = fontStyleValue.asInt();
}

JsonValue fontFamilyValue = style.get("fontFamily"); //$NON-NLS-1$
if (fontFamilyValue != null && fontFamilyValue.isString()) {
if (range.font == null) {
FontData fontData = textWidget.getFont().getFontData()[0];
fontData.setName(fontFamilyValue.asString());
Font font = new Font(textWidget.getDisplay(), fontData);
range.font = font;
} else {
FontData fontData = range.font.getFontData()[0];
fontData.setName(fontFamilyValue.asString());
}
}

JsonValue fontSizeValue = style.get("fontSize"); //$NON-NLS-1$
if (fontSizeValue != null && fontSizeValue.isNumber()) {
FontData textFontData = textWidget.getFont().getFontData()[0];
if (fontSizeValue.asInt() > textFontData.getHeight()) {
if (range.font == null) {
FontData fontData = textFontData;
fontData.setHeight(fontSizeValue.asInt());
Font font = new Font(textWidget.getDisplay(), fontData);
range.font = font;
} else {
FontData fontData = range.font.getFontData()[0];
fontData.setHeight(fontSizeValue.asInt());
}
}
}

if (isLink) {
range.underline = true;
range.underlineStyle = SWT.UNDERLINE_LINK;
}

JsonValue underlineValue = style.get("underline"); //$NON-NLS-1$
if (underlineValue != null && underlineValue.isBoolean()) {
range.underline = underlineValue.asBoolean();
if (range.underline) {
range.underlineStyle = SWT.UNDERLINE_LINK;
}
}

JsonValue underlineStyleValue = style.get("underlineStyle"); //$NON-NLS-1$
if (underlineStyleValue != null && underlineStyleValue.isNumber()) {
range.underlineStyle = underlineStyleValue.asInt();
}

JsonValue hideUnderlineValue = style.get("hideUnderline"); //$NON-NLS-1$
if (hideUnderlineValue != null && hideUnderlineValue.isBoolean()) {
if (hideUnderlineValue.asBoolean()) {
range.underlineColor = textWidget.getBackground();
}
}

JsonValue backgroundValue = style.get("background"); //$NON-NLS-1$
if (backgroundValue != null && backgroundValue.isString()) {
String backgroundString = backgroundValue.asString();
RGB rgb = ColorUtil.getColorValue(backgroundString);
if (rgb != null) {
range.background = new Color(textWidget.getDisplay(), rgb);
}
}

JsonValue foregroundValue = style.get("foreground"); //$NON-NLS-1$
if (foregroundValue != null && foregroundValue.isString()) {
String foregroundString = foregroundValue.asString();
RGB rgb = ColorUtil.getColorValue(foregroundString);
if (rgb != null) {
range.foreground = new Color(textWidget.getDisplay(), rgb);
if (range.underlineColor == null) {
range.underlineColor = range.foreground;
}
}
}

return range;
}

public static boolean isDark(Control textWidget) {
if (textWidget != null && !textWidget.isDisposed()) {
Color color = textWidget.getBackground();
Expand All @@ -555,54 +404,6 @@ public static boolean isDark(Control textWidget) {
return false;
}

public static StyleRange getAdLinkStyleRange(StyledText textWidget, int offset, int length) {
JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue(textTools, "fPreferenceStore"); //$NON-NLS-1$
String linkColor = preferences.getString(IJavaColorConstants.JAVADOC_DEFAULT);

StyleRange styleRange = null;
if (isDark(textWidget)) {
String darkStyleValue = JavaDecompilerPlugin.getDefault().getPreferenceStore().getString("darkStyle"); //$NON-NLS-1$
if (darkStyleValue != null && darkStyleValue.trim().length() > 0) {
styleRange = handleStyleValue(textWidget, offset, length, darkStyleValue, "link", linkColor, true); //$NON-NLS-1$
}
} else {
String brightStyleValue = JavaDecompilerPlugin.getDefault().getPreferenceStore().getString("brightStyle"); //$NON-NLS-1$
if (brightStyleValue != null && brightStyleValue.trim().length() > 0) {
styleRange = handleStyleValue(textWidget, offset, length, brightStyleValue, "link", linkColor, true); //$NON-NLS-1$
}
}

if (styleRange == null) {
styleRange = getDefaultLinkRange(textWidget, offset, length);
}
return styleRange;
}

private static StyleRange getDefaultLinkRange(StyledText textWidget, int offset, int length) {
JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue(textTools, "fPreferenceStore"); //$NON-NLS-1$
String linkColor = preferences.getString(IJavaColorConstants.JAVADOC_LINK);

StyleRange range = new StyleRange(offset, length,
JFaceResources.getResources().createColor(ColorUtil.getColorValue(linkColor)), null);
range.font = textWidget.getFont();
range.underline = true;
range.underlineStyle = SWT.UNDERLINE_LINK;
return range;
}

private static StyleRange getDefaultCommonRange(StyledText textWidget, int offset, int length) {
JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue(textTools, "fPreferenceStore"); //$NON-NLS-1$
String commentColor = preferences.getString(IJavaColorConstants.JAVADOC_DEFAULT);

StyleRange range = new StyleRange(offset, length,
new Color(textWidget.getDisplay(), ColorUtil.getColorValue(commentColor)), null);
range.font = textWidget.getFont();
return range;
}

public static boolean requestFromLinkToSelection() {
StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
for (int i = 0; i < stacks.length && i < 10; i++) {
Expand Down

0 comments on commit d87af75

Please sign in to comment.