spartanrefactoring / main Goto Github PK
View Code? Open in Web Editor NEWEclipse plugin that performs automatic refactoring of Java source code, making it shorter, more idiomatic and more readable
Home Page: https://www.spartan.org.il
Eclipse plugin that performs automatic refactoring of Java source code, making it shorter, more idiomatic and more readable
Home Page: https://www.spartan.org.il
Need to check spartanizations apply on the junit project, in regard of:
// ar matrica simetrine, ar teigiamai aprezta? switch (checkMatrix(A)) { case -1: { System.out.println("Duomenų matrica nėra simetrinė."); System.exit(0); } case -2: { System.out.println("Duomenų matrica nėra teigiamai aprėžta."); System.exit(0); } case 0: { System.out.println("Duomenų matrica teigiamai aprėžta ir simetrinė."); break; } }
Add configurable preferences
Add a key binding to the action "Spartanize this file"
Add to trimmerTest
A few comments made by Yossi:
Change parameter names in constructors to the names of the corresponding private fields (this.variable = variable)
And viewing for these.
There's currently only one functional spartanization (called Trimmer). Refactor the code by removing the old, unused classes extending spartanization, and move Trimmer to the spartanization package
Add wring and add configuration option.
Add an option to perform a full spartanization of the code that is highlighted (and spartanizations that include the highlighted code)
Convert a.equals("a") to "a".equals(a);
Also, for equalsIgnoreCase
Maven packaging and Travis build failing due to changes in pom file(s): SpartanRefactoring/pom.xml missing definition of parent pom, and spartan-refactoring/pom.xml contains Java1.8 declaration. I tried inserting missing definitions to pom or reverting to last version of pom.xml, but it did not work
Although the default value for the plug-in is "true", the plug-in does not automatically start working for new projects, requiring to turn it off and on again
E.g.,
switch (x) {
asdfasdf:
break;
}
return
to
switch (x) {
asdfasdf:
return;
}
Eliminate all JavaDoc errors
return a ? b //
c ? d //
e;
I am experiencing some errors that during the build of the application, namely after running "Run as application" with the latest udpate (commit 38acb5c).
The error is the following.
Errors running builder 'Spartanization Checker' on project 'mina-parent'.
Could not initialize class il.org.spartan.refactoring.spartanizations.Spartanizations.
The program throws the following Exception (taken from the console):
!MESSAGE Errors running builder 'Spartanization Checker' on project 'mina-benchmarks-common'.
!STACK 0
java.lang.ExceptionInInitializerError
at il.org.spartan.refactoring.builder.Builder.addMarkers(Builder.java:57)
at il.org.spartan.refactoring.builder.Builder.addMarkers(Builder.java:72)
at il.org.spartan.refactoring.builder.Builder.lambda$1(Builder.java:110)
at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:119)
at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:83)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:129)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:93)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:51)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:116)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:104)
at il.org.spartan.refactoring.builder.Builder.fullBuild(Builder.java:109)
at il.org.spartan.refactoring.builder.Builder.build(Builder.java:90)
at il.org.spartan.refactoring.builder.Builder.build(Builder.java:102)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.NullPointerException
at il.org.spartan.refactoring.spartanizations.Spartanizations$1.(Spartanizations.java:67)
at il.org.spartan.refactoring.spartanizations.Spartanizations.(Spartanizations.java:64)
... 34 more
When trying to enable the Spartanization suggestions (by toggling on the corresponding item on the project's menu) it throws the following Exception
java.lang.NoClassDefFoundError: il/org/spartan/Utils
at il.org.spartan.refactoring.handlers.ToggleSpartanizationHandler.enableNature(ToggleSpartanizationHandler.java:36)
at il.org.spartan.refactoring.handlers.ToggleSpartanizationHandler.toggleNature(ToggleSpartanizationHandler.java:57)
at il.org.spartan.refactoring.handlers.ToggleSpartanizationHandler.execute(ToggleSpartanizationHandler.java:44)
at il.org.spartan.refactoring.handlers.ToggleSpartanizationHandler.execute(ToggleSpartanizationHandler.java:64)
at il.org.spartan.refactoring.handlers.ToggleSpartanizationHandler.execute(ToggleSpartanizationHandler.java:1)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:799)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:675)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:659)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:592)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1329)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: java.lang.ClassNotFoundException: il.org.spartan.Utils cannot be found by il.org.spartan.refactoring_2.5.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 50 more
It did not happen before.
If I reset to the commit 30a65bd it works fine - I choose this commit because I remember that it was working fine since then.
Configurations:
On my laptop:
Eclipse Mars.2 Release (4.5.2)
JDK version "1.8.0_91"
Ubuntu 14.04
On the workstation
Eclipse Neon 4.6.0
JDK version "1.8.0_91"
Ubuntu Mate 16.04
Since plug-ins can't have inter-project dependencies (meaning that they depend on other projects in the workspace), convert those dependencies into Maven dependencies once the CLI and Spartan projects are deployed to Maven Central
We should consider adding auto-formatting (ctrl + shift + f in eclipse) to apply spartanization - there are some inaccuracies while taking care of comments and overall spartanizating, so easily arranging the code using builtin formatting will resolve all the problem + future issues.
Apparently there is no binding in TrimmerTest, although setting binding resolution to true. Needed for new, binding using wrings.
Whenever a user right-clicks a spartanization suggestion, display a "Spartanize" action to do it. Also, make sure the "Spartanization" submenu does not appear in that context
I don't think this simplification is correct:
switch (totalNegation) {
default:
break;
case 0:
return null;
case 1:
if (negationLevel(es.get(0)) == 1)
return null;
}
I am using Eclipse Mars 2 and have Lombok installed as a java agent. I installed Spartan Refactoring from the Eclipse Marketplace.
The project I am working on is a Maven multi-module.
On starting Eclipse the following error is displayed:
Errors occurred during the build.
Errors running builder 'Spartanization Checker' on project 'camel-microservices'.
Invalid string literal : >@Data<
Errors running builder 'Spartanization Checker' on project 'first-steps'.
Invalid string literal : >@Data<
As I use Lombok just about everywhere I had to uninstall the plugin
We discussed this in the past, however nothing was done.
Nowadays, the plugin converts an if statement with multiples cases into a very long ternary chain, for example:
if(exp1)
stmt1;
else if(exp2)
stmt2;
else if(exp3)
stmt3;
else
stmt4;
Becomes:
exp1 ? stmt1 : exp2 ? stmt2 : exp3 ? stmt3 : stmt4;
I believe this isn't readable and makes understanding the code much harder. I believe we should limit this to at most 2 chained if-else statements (exp1 ? stmt1 : exp2 ? stmt2 : stmt3
)
Complete the top two fields in the preferences, for controlling how the plugin behaves on startup and whether to apply the plugin automatically to new projects
Instead of doing a single step, make the "Spartanize this file" apply all changes to the file until no changes were left
Add the chosen tests from the AutoRefactor project into our tests set
I tried installing the source following the instructions, and it simply did no matter how many times I tried, and in which fresh install I used, and permuting the order. Nothing worked. I suspect the problem lies with the fact that the package depends on itself. One of the Build commands.
Daniel, can you please check what's going on? Can you try the instructions with a fresh install?
Create a preference that allows users to enable or disable binding resolution when building the AST, and add wrings the ability to query the preferences whether bindings are resolved or not
Starting building stable spartanization. This issue contains all relevant material about the subject:
Known issues need to be solved:
Issues answered:
int x;double y;x=0;y=0;
) - disabled the option for NumberLiteral assignments (cannot be resolved without binding resolution)Also new tests for stabilization, see TrimmerTest
Fixes in original code:
Notice:
Similarly to changing return variable name to $, change the name a parameter
to a function with a single generic parameter to ¢
Should not apply to constructors or to setters.
also
x.size() != 0 ===> !x.isEmpty()
Note: this requires binding information
Add spartanization to this effect
Allow users to mark either methods or classes with a @NoSpartanization annotation, telling the plugin to skip these completely
In all cases that a variable is annotated with @suppersswarnings("Unused")
change, if possible variable name to __ (double underscore).
This applies to parameters
local variables,
but not fields.
Do NOT invoke eclipse rename.
Instead of list
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.