From 17154af4513051337d30e215ff3f00d108919914 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 13:28:27 -0400 Subject: [PATCH 01/51] Initial commit. --- edu.cuny.hunter.hybridize.eval/.classpath | 7 ++ edu.cuny.hunter.hybridize.eval/.project | 28 +++++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 9 +++ .../META-INF/MANIFEST.MF | 13 +++ .../build.properties | 7 ++ .../bundle.properties | 2 + .../icons/sample.png | Bin 0 -> 332 bytes .../icons/sample@2x.png | Bin 0 -> 526 bytes edu.cuny.hunter.hybridize.eval/plugin.xml | 74 ++++++++++++++++++ ...teHybridizeFunctionRefactoringHandler.java | 40 ++++++++++ ...ateHybridizeFunctionRefactoringPlugin.java | 25 ++++++ 12 files changed, 207 insertions(+) create mode 100644 edu.cuny.hunter.hybridize.eval/.classpath create mode 100644 edu.cuny.hunter.hybridize.eval/.project create mode 100644 edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.core.resources.prefs create mode 100644 edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs create mode 100644 edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF create mode 100644 edu.cuny.hunter.hybridize.eval/build.properties create mode 100644 edu.cuny.hunter.hybridize.eval/bundle.properties create mode 100644 edu.cuny.hunter.hybridize.eval/icons/sample.png create mode 100644 edu.cuny.hunter.hybridize.eval/icons/sample@2x.png create mode 100644 edu.cuny.hunter.hybridize.eval/plugin.xml create mode 100644 edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java create mode 100644 edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/ui/plugins/EvaluateHybridizeFunctionRefactoringPlugin.java diff --git a/edu.cuny.hunter.hybridize.eval/.classpath b/edu.cuny.hunter.hybridize.eval/.classpath new file mode 100644 index 000000000..e801ebfb4 --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edu.cuny.hunter.hybridize.eval/.project b/edu.cuny.hunter.hybridize.eval/.project new file mode 100644 index 000000000..65b6ffb7f --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/.project @@ -0,0 +1,28 @@ + + + edu.cuny.hunter.hybridize.eval + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.core.resources.prefs b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..c9545f06a --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF new file mode 100644 index 000000000..48efa977e --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Bundle-Name +Bundle-SymbolicName: edu.cuny.hunter.hybridize.eval;singleton:=true +Bundle-Vendor: %Bundle-Vendor +Bundle-Version: 1.0.0.qualifier +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime;bundle-version="3.26.0", + org.eclipse.core.resources;bundle-version="3.18.0", + org.python.pydev;bundle-version="[9.3.2,10.0.0)" +Automatic-Module-Name: edu.cuny.hunter.hybridize.eval +Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/edu.cuny.hunter.hybridize.eval/build.properties b/edu.cuny.hunter.hybridize.eval/build.properties new file mode 100644 index 000000000..cbc29804f --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + bundle.properties diff --git a/edu.cuny.hunter.hybridize.eval/bundle.properties b/edu.cuny.hunter.hybridize.eval/bundle.properties new file mode 100644 index 000000000..ee78c47a0 --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/bundle.properties @@ -0,0 +1,2 @@ +Bundle-Vendor = City University of New York (CUNY) Hunter College +Bundle-Name = Eclipse Hybridize Functions Refactoring Evaluation Plug-in diff --git a/edu.cuny.hunter.hybridize.eval/icons/sample.png b/edu.cuny.hunter.hybridize.eval/icons/sample.png new file mode 100644 index 0000000000000000000000000000000000000000..02c4b79e10986d56bda97051eb0da2e9119c97f5 GIT binary patch literal 332 zcmV-S0ki&zP)o}PQ;SW4Q?|D@o|!n4bZ+dmjHl(fFnOU>N3Hz|3`e^PLI_Tklq z9dEUPF8GjIQ2+RLZpDrNq~L=3C%1s!j|YcCWZ+aA5&{s6WBjJ7phjchl+7dD zK%??C5t{FV)M8Cck-?KSfC{eT(i|B$Wp$+QOcA_!0hFXcX&$6FDqzZKU<%z0%uwCY e0aKi5l4}7X=XWJ6VmxR70000{ZT)6VX-X|e!skhH1SmmK(Q+8xOk9EsoDx9;%V9VIujLL74J^=XMJoq9 z1|@9VK_4(VhK80y5@pbo6ckI-X8va_ZhIdO!f9Fi&L*dB`%g;@wBtO?KClDIJKpgF zIsXR&gB_67@QMe>IbYQF_DWvOz5n#UMXhhIg6u>s=Yd5ht>Yhtu@=)Y0h1l*%f Qr~m)}07*qoM6N<$f|JJHQ2+n{ literal 0 HcmV?d00001 diff --git a/edu.cuny.hunter.hybridize.eval/plugin.xml b/edu.cuny.hunter.hybridize.eval/plugin.xml new file mode 100644 index 000000000..09925d58d --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/plugin.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java new file mode 100644 index 000000000..c269538ed --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -0,0 +1,40 @@ +package edu.cuny.hunter.hybridize.eval.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; +import org.python.pydev.navigator.elements.PythonSourceFolder; + +public class EvaluateHybridizeFunctionRefactoringHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); + + for (Object obj : selection) { + IProject project = getProject(obj); + System.out.println(project.getName()); + } + + return null; + } + + private static IProject getProject(Object obj) { + if (obj instanceof PythonSourceFolder) { + PythonSourceFolder folder = (PythonSourceFolder) obj; + IResource actualObject = folder.getActualObject(); + return actualObject.getProject(); + } + + if (obj instanceof IProject) { + IProject project = (IProject) obj; + return project; + } + + throw new IllegalArgumentException("Unknown entity type: " + obj.getClass() + " for argument: " + obj + "."); + } +} diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/ui/plugins/EvaluateHybridizeFunctionRefactoringPlugin.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/ui/plugins/EvaluateHybridizeFunctionRefactoringPlugin.java new file mode 100644 index 000000000..3ae835933 --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/ui/plugins/EvaluateHybridizeFunctionRefactoringPlugin.java @@ -0,0 +1,25 @@ +package edu.cuny.hunter.hybridize.eval.ui.plugins; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +public class EvaluateHybridizeFunctionRefactoringPlugin extends Plugin { + + private static EvaluateHybridizeFunctionRefactoringPlugin plugin; + + public static Plugin getDefault() { + return plugin; + } + + @Override + public void start(BundleContext context) throws Exception { + plugin = this; + super.start(context); + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } +} From 45b24f362caab80ee33471138847250ae327fd47 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 14:03:20 -0400 Subject: [PATCH 02/51] Add job. --- ...aluateHybridizeFunctionRefactoringHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index c269538ed..71eb13b3e 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -5,6 +5,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; @@ -13,12 +14,14 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends AbstractHandler @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); - - for (Object obj : selection) { - IProject project = getProject(obj); - System.out.println(project.getName()); - } + Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { + IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); + + for (Object obj : selection) { + IProject project = getProject(obj); + System.out.println(project.getName()); + } + }).schedule(); return null; } From d1e1567e2f317861900a0232b639e97461053b95 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 14:28:07 -0400 Subject: [PATCH 03/51] Add Maven. --- edu.cuny.hunter.hybridize.eval/.classpath | 2 +- edu.cuny.hunter.hybridize.eval/.project | 6 ++++++ .../.settings/org.eclipse.m2e.core.prefs | 4 ++++ edu.cuny.hunter.hybridize.eval/build.properties | 2 +- edu.cuny.hunter.hybridize.eval/pom.xml | 13 +++++++++++++ pom.xml | 1 + 6 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.m2e.core.prefs create mode 100644 edu.cuny.hunter.hybridize.eval/pom.xml diff --git a/edu.cuny.hunter.hybridize.eval/.classpath b/edu.cuny.hunter.hybridize.eval/.classpath index e801ebfb4..1db08c6b4 100644 --- a/edu.cuny.hunter.hybridize.eval/.classpath +++ b/edu.cuny.hunter.hybridize.eval/.classpath @@ -3,5 +3,5 @@ - + diff --git a/edu.cuny.hunter.hybridize.eval/.project b/edu.cuny.hunter.hybridize.eval/.project index 65b6ffb7f..face1c615 100644 --- a/edu.cuny.hunter.hybridize.eval/.project +++ b/edu.cuny.hunter.hybridize.eval/.project @@ -20,8 +20,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.m2e.core.prefs b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/edu.cuny.hunter.hybridize.eval/build.properties b/edu.cuny.hunter.hybridize.eval/build.properties index cbc29804f..cdede84a7 100644 --- a/edu.cuny.hunter.hybridize.eval/build.properties +++ b/edu.cuny.hunter.hybridize.eval/build.properties @@ -1,5 +1,5 @@ source.. = src/ -output.. = bin/ +output.. = target/classes/ bin.includes = plugin.xml,\ META-INF/,\ .,\ diff --git a/edu.cuny.hunter.hybridize.eval/pom.xml b/edu.cuny.hunter.hybridize.eval/pom.xml new file mode 100644 index 000000000..c73ec8ec9 --- /dev/null +++ b/edu.cuny.hunter.hybridize.eval/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + edu.cuny.hunter.hybridize.eval + eclipse-plugin + Evaluate Hybridize Functions Refactoring + Evaluation plugin for the Hybridize Functions refactoring. + + edu.cuny.hunter.hybridize + edu.cuny.hunter.hybridize + 1.0.0-SNAPSHOT + .. + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 86d891423..ac34f6452 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ edu.cuny.hunter.hybridize.core edu.cuny.hunter.hybridize.ui + edu.cuny.hunter.hybridize.eval edu.cuny.hunter.hybridize.tests edu.cuny.hunter.hybridize.tests.report From 03ebc9570966ac9c3826a724e39cf2bf4827e264 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 14:28:52 -0400 Subject: [PATCH 04/51] Add newline. --- edu.cuny.hunter.hybridize.eval/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/pom.xml b/edu.cuny.hunter.hybridize.eval/pom.xml index c73ec8ec9..c62140ec1 100644 --- a/edu.cuny.hunter.hybridize.eval/pom.xml +++ b/edu.cuny.hunter.hybridize.eval/pom.xml @@ -10,4 +10,4 @@ 1.0.0-SNAPSHOT .. - \ No newline at end of file + From 003dd49a8fdf588f3f240ad62a8a42cee0b2438e Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 14:43:10 -0400 Subject: [PATCH 05/51] Add common refactoring. --- edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF | 3 ++- .../EvaluateHybridizeFunctionRefactoringHandler.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index 48efa977e..7f4cf847e 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -7,7 +7,8 @@ Bundle-Version: 1.0.0.qualifier Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", - org.python.pydev;bundle-version="[9.3.2,10.0.0)" + org.python.pydev;bundle-version="[9.3.2,10.0.0)", + edu.cuny.citytech.refactoring.common.eval;bundle-version="3.1.0" Automatic-Module-Name: edu.cuny.hunter.hybridize.eval Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 71eb13b3e..19c2f999e 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -1,6 +1,5 @@ package edu.cuny.hunter.hybridize.eval.handlers; -import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; @@ -10,7 +9,9 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; -public class EvaluateHybridizeFunctionRefactoringHandler extends AbstractHandler { +import edu.cuny.citytech.refactoring.common.eval.handlers.EvaluateRefactoringHandler; + +public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { From 0a8cf95c87a71680d3b7f17a455e0438ab15d8c2 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 14:44:29 -0400 Subject: [PATCH 06/51] Remove name from pom.xml. For consistency. --- edu.cuny.hunter.hybridize.eval/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/pom.xml b/edu.cuny.hunter.hybridize.eval/pom.xml index c62140ec1..ba7714057 100644 --- a/edu.cuny.hunter.hybridize.eval/pom.xml +++ b/edu.cuny.hunter.hybridize.eval/pom.xml @@ -2,7 +2,6 @@ 4.0.0 edu.cuny.hunter.hybridize.eval eclipse-plugin - Evaluate Hybridize Functions Refactoring Evaluation plugin for the Hybridize Functions refactoring. edu.cuny.hunter.hybridize From 6ec70048c19ed38e8b4a3bdb1fe9ac15b628db20 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 15:36:27 -0400 Subject: [PATCH 07/51] Only Python projects. --- .../META-INF/MANIFEST.MF | 1 + ...teHybridizeFunctionRefactoringHandler.java | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index 7f4cf847e..0efe36a46 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -4,6 +4,7 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: edu.cuny.hunter.hybridize.eval;singleton:=true Bundle-Vendor: %Bundle-Vendor Bundle-Version: 1.0.0.qualifier +Import-Package: org.python.pydev.plugin.nature Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 19c2f999e..a3b14a576 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -1,9 +1,16 @@ package edu.cuny.hunter.hybridize.eval.handlers; +import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; + +import java.util.LinkedHashSet; +import java.util.stream.Stream; + import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.handlers.HandlerUtil; @@ -16,17 +23,32 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { - IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); + IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); - for (Object obj : selection) { - IProject project = getProject(obj); - System.out.println(project.getName()); - } }).schedule(); return null; } + private IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException { + IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); + java.util.Set ret = new LinkedHashSet<>(); + + for (Object obj : selection) { + IProject project = getProject(obj); + + if (project != null) { + IProjectNature nature = project.getNature(PYTHON_NATURE_ID); + + if (nature != null) + // We have a Python project. + ret.add(project); + } + } + + return ret.toArray(IProject[]::new); + } + private static IProject getProject(Object obj) { if (obj instanceof PythonSourceFolder) { PythonSourceFolder folder = (PythonSourceFolder) obj; @@ -39,6 +61,6 @@ private static IProject getProject(Object obj) { return project; } - throw new IllegalArgumentException("Unknown entity type: " + obj.getClass() + " for argument: " + obj + "."); + return null; } } From 20490e5be38cd4419b8a55610b94c3da6ae52e94 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 17:48:37 -0400 Subject: [PATCH 08/51] Remove common refactoring. It's messing up the handler; I don't know why. --- edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF | 3 +-- .../EvaluateHybridizeFunctionRefactoringHandler.java | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index 0efe36a46..c0c5d3b78 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -8,8 +8,7 @@ Import-Package: org.python.pydev.plugin.nature Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", - org.python.pydev;bundle-version="[9.3.2,10.0.0)", - edu.cuny.citytech.refactoring.common.eval;bundle-version="3.1.0" + org.python.pydev;bundle-version="[9.3.2,10.0.0)" Automatic-Module-Name: edu.cuny.hunter.hybridize.eval Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index a3b14a576..8c6fd850d 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -5,6 +5,7 @@ import java.util.LinkedHashSet; import java.util.stream.Stream; +import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; @@ -16,9 +17,7 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; -import edu.cuny.citytech.refactoring.common.eval.handlers.EvaluateRefactoringHandler; - -public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { +public class EvaluateHybridizeFunctionRefactoringHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { From 29dce959dc5cffbdabb0c932dc847e03129208d2 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 27 Sep 2023 19:24:02 -0400 Subject: [PATCH 09/51] Fix build. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 8c6fd850d..cb770139d 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -3,7 +3,6 @@ import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; import java.util.LinkedHashSet; -import java.util.stream.Stream; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -29,7 +28,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return null; } - private IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException { + private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException { IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); java.util.Set ret = new LinkedHashSet<>(); From a097e363da6306ac4ddd68db3666f22908bf78bb Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 11:34:23 -0400 Subject: [PATCH 10/51] Add CSV printing. --- .../META-INF/MANIFEST.MF | 3 +- ...teHybridizeFunctionRefactoringHandler.java | 34 +++++++++++++++++++ hybridize.target | 12 ++++++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index c0c5d3b78..7e2d8247f 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: edu.cuny.hunter.hybridize.eval;singleton:=true Bundle-Vendor: %Bundle-Vendor Bundle-Version: 1.0.0.qualifier -Import-Package: org.python.pydev.plugin.nature +Import-Package: org.apache.commons.csv;version="1.10.0", + org.python.pydev.plugin.nature Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index cb770139d..2394cf501 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -2,8 +2,12 @@ import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; +import java.io.FileWriter; +import java.io.IOException; import java.util.LinkedHashSet; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVPrinter; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@ -11,6 +15,9 @@ import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.handlers.HandlerUtil; @@ -18,16 +25,43 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends AbstractHandler { + private static final String RESULTS_CSV_FILENAME = "results.csv"; + @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); + try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, new String[] { "subject", "time (s)" })) { + for (IProject project : pythonProjectsFromEvent) { + // subject. + resultsPrinter.print(project.getName()); + + // TODO: overall results time. + /* + resultsPrinter.print((resultsTimeCollector.getCollectedTime() + - processor.getExcludedTimeCollector().getCollectedTime()) / 1000.0); + */ + resultsPrinter.print(0); + + // end the record. + resultsPrinter.println(); + } + } catch (IOException e) { + IStatus status = Status.error("Encountered error with evaluation.", e); + throw new CoreException(status); + } finally { + SubMonitor.done(monitor); + } }).schedule(); return null; } + private static CSVPrinter createCSVPrinter(String fileName, String[] header) throws IOException { + return new CSVPrinter(new FileWriter(fileName, true), CSVFormat.EXCEL.builder().setHeader(header).build()); + } + private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException { IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); java.util.Set ret = new LinkedHashSet<>(); diff --git a/hybridize.target b/hybridize.target index 433cb659a..7d468bab5 100644 --- a/hybridize.target +++ b/hybridize.target @@ -43,6 +43,16 @@ + + + + org.apache.commons + commons-csv + 1.10.0 + jar + + + x86_64 @@ -53,4 +63,4 @@ -Declipse.p2.max.threads=10 -Doomph.update.url=https://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ -Dosgi.requiredJavaVersion=17 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms256m -Xmx2048m --add-modules=ALL-SYSTEM - + \ No newline at end of file From 6871a81bf89540b81f8ca817971a6d0b3530a43c Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 11:57:59 -0400 Subject: [PATCH 11/51] But back commons eval. The problem doesn't seem related. --- edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF | 6 +++--- ...EvaluateHybridizeFunctionRefactoringHandler.java | 11 +++-------- hybridize.target | 13 ------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index 7e2d8247f..0efe36a46 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -4,12 +4,12 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: edu.cuny.hunter.hybridize.eval;singleton:=true Bundle-Vendor: %Bundle-Vendor Bundle-Version: 1.0.0.qualifier -Import-Package: org.apache.commons.csv;version="1.10.0", - org.python.pydev.plugin.nature +Import-Package: org.python.pydev.plugin.nature Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", - org.python.pydev;bundle-version="[9.3.2,10.0.0)" + org.python.pydev;bundle-version="[9.3.2,10.0.0)", + edu.cuny.citytech.refactoring.common.eval;bundle-version="3.1.0" Automatic-Module-Name: edu.cuny.hunter.hybridize.eval Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 2394cf501..f5f719b87 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -2,13 +2,10 @@ import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; -import java.io.FileWriter; import java.io.IOException; import java.util.LinkedHashSet; -import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; -import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; @@ -23,7 +20,9 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; -public class EvaluateHybridizeFunctionRefactoringHandler extends AbstractHandler { +import edu.cuny.citytech.refactoring.common.eval.handlers.EvaluateRefactoringHandler; + +public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { private static final String RESULTS_CSV_FILENAME = "results.csv"; @@ -58,10 +57,6 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return null; } - private static CSVPrinter createCSVPrinter(String fileName, String[] header) throws IOException { - return new CSVPrinter(new FileWriter(fileName, true), CSVFormat.EXCEL.builder().setHeader(header).build()); - } - private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException { IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); java.util.Set ret = new LinkedHashSet<>(); diff --git a/hybridize.target b/hybridize.target index 7d468bab5..cf5afb4f6 100644 --- a/hybridize.target +++ b/hybridize.target @@ -37,22 +37,9 @@ github https://maven.pkg.github.com/ponder-lab/ML - - true - - - - - org.apache.commons - commons-csv - 1.10.0 - jar - - - x86_64 From aad2f1ec15a21dffd9beb7a01ba23297ef142e07 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 12:23:25 -0400 Subject: [PATCH 12/51] Use Common Eval 3.3.0. --- edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index 0efe36a46..c9b1e0987 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -9,7 +9,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", org.python.pydev;bundle-version="[9.3.2,10.0.0)", - edu.cuny.citytech.refactoring.common.eval;bundle-version="3.1.0" + edu.cuny.citytech.refactoring.common.eval;bundle-version="3.3.0" Automatic-Module-Name: edu.cuny.hunter.hybridize.eval Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin Bundle-RequiredExecutionEnvironment: JavaSE-11 From c1adcc17c21cae2bf3f4e08a14bbd8f1e3f6ee2d Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 12:29:10 -0400 Subject: [PATCH 13/51] Also use Common Eval 3.3.0 in the platform target definition. --- hybridize.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hybridize.target b/hybridize.target index cf5afb4f6..fae30f07c 100644 --- a/hybridize.target +++ b/hybridize.target @@ -18,7 +18,7 @@ - + From c31b63b16cc23f3b160aafac4d5a4c7367a907c6 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 12:42:13 -0400 Subject: [PATCH 14/51] Add source folder type to enabled list. --- edu.cuny.hunter.hybridize.eval/plugin.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/edu.cuny.hunter.hybridize.eval/plugin.xml b/edu.cuny.hunter.hybridize.eval/plugin.xml index 09925d58d..26d5ed746 100644 --- a/edu.cuny.hunter.hybridize.eval/plugin.xml +++ b/edu.cuny.hunter.hybridize.eval/plugin.xml @@ -25,6 +25,9 @@ + + From 48317d133126e69f05a9d9b7d70ad8657aaec764 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 12:44:22 -0400 Subject: [PATCH 15/51] Use our own command category. --- edu.cuny.hunter.hybridize.eval/plugin.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/plugin.xml b/edu.cuny.hunter.hybridize.eval/plugin.xml index 26d5ed746..9fa6f39dc 100644 --- a/edu.cuny.hunter.hybridize.eval/plugin.xml +++ b/edu.cuny.hunter.hybridize.eval/plugin.xml @@ -4,12 +4,17 @@ + + From bfc32b2ac2034c5a42d8da25e2f4ffd1cf635530 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 12:46:53 -0400 Subject: [PATCH 16/51] Inline local variable. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index f5f719b87..fbbf72a7e 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -12,7 +12,6 @@ import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; @@ -47,8 +46,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.println(); } } catch (IOException e) { - IStatus status = Status.error("Encountered error with evaluation.", e); - throw new CoreException(status); + throw new CoreException(Status.error("Encountered error with evaluation.", e)); } finally { SubMonitor.done(monitor); } From b6c1fc5a068afde038f16fe6e83eee9476ff08e9 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 13:59:56 -0400 Subject: [PATCH 17/51] Throw an exceptionw when there's no selection. --- ...teHybridizeFunctionRefactoringHandler.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index fbbf72a7e..ba139ed0a 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -15,7 +15,9 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.ISources; import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; @@ -28,9 +30,9 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { - IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); - try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, new String[] { "subject", "time (s)" })) { + IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); + for (IProject project : pythonProjectsFromEvent) { // subject. resultsPrinter.print(project.getName()); @@ -45,7 +47,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // end the record. resultsPrinter.println(); } - } catch (IOException e) { + } catch (IOException | ExecutionException e) { throw new CoreException(Status.error("Encountered error with evaluation.", e)); } finally { SubMonitor.done(monitor); @@ -55,8 +57,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return null; } - private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException { - IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); + private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException, ExecutionException { + IStructuredSelection selection = getCurrentStructuredSelectionChecked(event); java.util.Set ret = new LinkedHashSet<>(); for (Object obj : selection) { @@ -74,6 +76,25 @@ private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent even return ret.toArray(IProject[]::new); } + /** + * Return the current structured selection. + * + * @param event The execution event that contains the application context. + * @return The current IStructuredSelection.Will not return null. + * @throws ExecutionException If the current selection variable is not found. + */ + private static IStructuredSelection getCurrentStructuredSelectionChecked(ExecutionEvent event) throws ExecutionException { + ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); + + if (selection instanceof IStructuredSelection) + return (IStructuredSelection) selection; + + throw new ExecutionException("Incorrect type for " //$NON-NLS-1$ + + ISources.ACTIVE_CURRENT_SELECTION_NAME + " found while executing " //$NON-NLS-1$ + + event.getCommand().getId() + ", expected " + IStructuredSelection.class.getName() //$NON-NLS-1$ + + " found " + selection.getClass()); //$NON-NLS-1$ + } + private static IProject getProject(Object obj) { if (obj instanceof PythonSourceFolder) { PythonSourceFolder folder = (PythonSourceFolder) obj; From 65efb75e27ec1d6be49da0724360cb709082d5b9 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 14:02:27 -0400 Subject: [PATCH 18/51] Add time collector. --- .../META-INF/MANIFEST.MF | 3 ++- ...teHybridizeFunctionRefactoringHandler.java | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index c9b1e0987..e18c1d8f2 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", org.python.pydev;bundle-version="[9.3.2,10.0.0)", - edu.cuny.citytech.refactoring.common.eval;bundle-version="3.3.0" + edu.cuny.citytech.refactoring.common.eval;bundle-version="3.3.0", + edu.cuny.citytech.refactoring.common.core;bundle-version="3.3.0" Automatic-Module-Name: edu.cuny.hunter.hybridize.eval Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index ba139ed0a..44f288385 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -21,6 +21,7 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; +import edu.cuny.citytech.refactoring.common.core.TimeCollector; import edu.cuny.citytech.refactoring.common.eval.handlers.EvaluateRefactoringHandler; public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { @@ -37,12 +38,20 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // subject. resultsPrinter.print(project.getName()); - // TODO: overall results time. - /* - resultsPrinter.print((resultsTimeCollector.getCollectedTime() - - processor.getExcludedTimeCollector().getCollectedTime()) / 1000.0); - */ - resultsPrinter.print(0); + // set up analysis for single project. + TimeCollector resultsTimeCollector = new TimeCollector(); + + resultsTimeCollector.start(); + // TODO + resultsTimeCollector.stop(); + + // overall results time. + resultsPrinter.print( + // TODO: +// ( + resultsTimeCollector.getCollectedTime() +// - processor.getExcludedTimeCollector().getCollectedTime()) + / 1000.0); // end the record. resultsPrinter.println(); From 5e8c410b9afcd4266c396ce6dac106a8a244acd2 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 14:02:34 -0400 Subject: [PATCH 19/51] Minor cleanup. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 44f288385..168f9de56 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.LinkedHashSet; +import java.util.Set; import org.apache.commons.csv.CSVPrinter; import org.eclipse.core.commands.ExecutionEvent; @@ -67,8 +68,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { } private static IProject[] getSelectedPythonProjectsFromEvent(ExecutionEvent event) throws CoreException, ExecutionException { + Set ret = new LinkedHashSet<>(); IStructuredSelection selection = getCurrentStructuredSelectionChecked(event); - java.util.Set ret = new LinkedHashSet<>(); for (Object obj : selection) { IProject project = getProject(obj); From ea399cb7ca49605e63ce4b6ca27e5f0061f829b7 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 28 Sep 2023 14:36:06 -0400 Subject: [PATCH 20/51] Fix indentation. --- .../EvaluateHybridizeFunctionRefactoringHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 168f9de56..4c3d19c2c 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -48,10 +48,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // overall results time. resultsPrinter.print( - // TODO: -// ( + // TODO: + // ( resultsTimeCollector.getCollectedTime() -// - processor.getExcludedTimeCollector().getCollectedTime()) + // - processor.getExcludedTimeCollector().getCollectedTime()) / 1000.0); // end the record. From 1e84eee0ea67a0a612f5c8e88e95ca112afa9900 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 15:53:10 -0400 Subject: [PATCH 21/51] Progress. --- .../META-INF/MANIFEST.MF | 7 +- .../hunter/hybridize/core/utils/Util.java | 147 +++++++++++++++++- .../META-INF/MANIFEST.MF | 4 +- ...teHybridizeFunctionRefactoringHandler.java | 43 ++++- .../ui/handlers/HybridizeFunctionHandler.java | 78 +--------- .../hunter/hybridize/ui/handlers/Util.java | 71 --------- .../HybridizeFunctionRefactoringWizard.java | 3 +- 7 files changed, 204 insertions(+), 149 deletions(-) delete mode 100644 edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/Util.java diff --git a/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF index e4c5ef9df..10f6500bd 100644 --- a/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ltk.core.refactoring;bundle-version="3.12.200", org.python.pydev.ast;bundle-version="[9.3.2,10.0.0)", com.python.pydev.refactoring;bundle-version="[9.3.2,10.0.0)", com.python.pydev.analysis;bundle-version="[9.3.2,10.0.0)", - org.eclipse.core.resources;bundle-version="3.18.0" + org.eclipse.core.resources;bundle-version="3.18.0", + org.eclipse.core.runtime;bundle-version="3.26.0" Import-Package: com.ibm.wala.cast.ipa.callgraph, com.ibm.wala.cast.ir.ssa, com.ibm.wala.cast.loader, @@ -39,10 +40,14 @@ Import-Package: com.ibm.wala.cast.ipa.callgraph, com.ibm.wala.types, com.ibm.wala.util, com.ibm.wala.util.collections, + org.eclipse.core.commands, org.eclipse.core.runtime;version="3.7.0", org.eclipse.jface.text, org.python.pydev.ast.refactoring, org.python.pydev.core, + org.python.pydev.navigator, + org.python.pydev.navigator.elements, + org.python.pydev.outline, org.python.pydev.parser.jython.ast, org.python.pydev.shared_core.model Export-Package: edu.cuny.hunter.hybridize.core.analysis, diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java index 33f28ab4c..35dc8b7fd 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java @@ -1,18 +1,163 @@ package edu.cuny.hunter.hybridize.core.utils; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.core.runtime.Platform.getLog; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; import java.util.Set; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; import org.eclipse.ltk.core.refactoring.Refactoring; import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; import org.python.pydev.ast.refactoring.TooManyMatchesException; +import org.python.pydev.core.IPythonNature; +import org.python.pydev.navigator.PythonModelProvider; +import org.python.pydev.navigator.elements.PythonFile; +import org.python.pydev.navigator.elements.PythonNode; +import org.python.pydev.navigator.elements.PythonSourceFolder; +import org.python.pydev.outline.ParsedItem; +import org.python.pydev.parser.jython.SimpleNode; +import org.python.pydev.parser.jython.ast.FunctionDef; +import org.python.pydev.parser.visitors.scope.ASTEntryWithChildren; +import org.python.pydev.plugin.nature.PythonNature; import edu.cuny.hunter.hybridize.core.analysis.FunctionDefinition; +import edu.cuny.hunter.hybridize.core.analysis.FunctionExtractor; import edu.cuny.hunter.hybridize.core.refactorings.HybridizeFunctionRefactoringProcessor; public class Util { + private static final ILog LOG = getLog(Util.class); + + private static final PythonModelProvider provider = new PythonModelProvider(); + public static Refactoring createRefactoring(Set functionDefinitions) throws TooManyMatchesException { + return new ProcessorBasedRefactoring(new HybridizeFunctionRefactoringProcessor(functionDefinitions)); + } + + public static HybridizeFunctionRefactoringProcessor createHybridizeFunctionRefactoring(IProject[] projects, IProgressMonitor monitor) + throws ExecutionException, CoreException, IOException { + Set functionDefinitions = getFunctionDefinitions(Arrays.asList(projects)); HybridizeFunctionRefactoringProcessor processor = new HybridizeFunctionRefactoringProcessor(functionDefinitions); - return new ProcessorBasedRefactoring(processor); + return processor; + } + + public static Set getFunctionDefinitions(Iterable iterable) + throws ExecutionException, CoreException, IOException { + Set ret = new HashSet<>(); + + for (Object obj : iterable) { + Set nodeSet = getPythonNodes(obj); + + for (PythonNode node : nodeSet) + ret.addAll(process(node)); + } + + return ret; + } + + public static Set getPythonNodes(Object obj) { + Set ret = new HashSet<>(); + + if (obj instanceof PythonNode) { + PythonNode pythonNode = (PythonNode) obj; + ret.add(pythonNode); + } else { + Object[] children = provider.getChildren(obj); + for (Object child : children) + ret.addAll(getPythonNodes(child)); + } + return ret; + } + + public static Set process(PythonNode pythonNode) throws ExecutionException, CoreException, IOException { + Set ret = new HashSet<>(); + + String moduleName = getModuleName(pythonNode); + File file = getFile(pythonNode); + IDocument document = getDocument(pythonNode); + IPythonNature nature = Util.getPythonNature(pythonNode); + + ParsedItem entry = pythonNode.entry; + ASTEntryWithChildren ast = entry.getAstThis(); + SimpleNode simpleNode = ast.node; + + // extract function definitions. + FunctionExtractor functionExtractor = new FunctionExtractor(); + try { + simpleNode.accept(functionExtractor); + } catch (Exception e) { + LOG.error("Failed to start refactoring.", e); + throw new ExecutionException("Failed to start refactoring.", e); + } + + Collection definitions = functionExtractor.getDefinitions(); + + for (FunctionDef def : definitions) { + FunctionDefinition function = new FunctionDefinition(def, moduleName, file, document, nature); + ret.add(function); + } + + return ret; + } + + private static IFile getActualFile(PythonNode pythonNode) { + PythonFile pythonFile = pythonNode.getPythonFile(); + return pythonFile.getActualObject(); + } + + static IDocument getDocument(PythonNode pythonNode) throws CoreException, IOException { + IFile file = getActualFile(pythonNode); + + try (InputStream contentStream = file.getContents()) { + byte[] bytes = contentStream.readAllBytes(); + String content = new String(bytes, UTF_8); + return new Document(content); + } + } + + static File getFile(PythonNode pythonNode) { + IFile file = getActualFile(pythonNode); + URI uri = file.getRawLocationURI(); + return new File(uri); + } + + static String getFileName(PythonNode pythonNode) { + IFile file = getActualFile(pythonNode); + return file.getName(); + } + + static String getModuleName(PythonNode pythonNode) { + String fileName = getFileName(pythonNode); + int separatorPos = fileName.indexOf('.'); + return fileName.substring(0, separatorPos); + } + + static IPythonNature getPythonNature(PythonNode pythonNode) { + IProject project = getProject(pythonNode); + PythonNature pythonNature = PythonNature.getPythonNature(project); + return pythonNature; + } + + private static IProject getProject(PythonNode pythonNode) { + PythonFile pythonFile = pythonNode.getPythonFile(); + PythonSourceFolder sourceFolder = pythonFile.getSourceFolder(); + IResource resource = sourceFolder.getActualObject(); + IProject project = resource.getProject(); + return project; } } diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index e18c1d8f2..a557b5bd3 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.resources;bundle-version="3.18.0", org.python.pydev;bundle-version="[9.3.2,10.0.0)", edu.cuny.citytech.refactoring.common.eval;bundle-version="3.3.0", - edu.cuny.citytech.refactoring.common.core;bundle-version="3.3.0" + edu.cuny.citytech.refactoring.common.core;bundle-version="3.3.0", + edu.cuny.hunter.hybridize.core;bundle-version="1.0.0", + org.eclipse.ltk.core.refactoring Automatic-Module-Name: edu.cuny.hunter.hybridize.eval Bundle-Activator: edu.cuny.hunter.hybridize.eval.ui.plugins.EvaluateHybridizeFunctionRefactoringPlugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 4c3d19c2c..1a4972b53 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -1,9 +1,13 @@ package edu.cuny.hunter.hybridize.eval.handlers; +import static edu.cuny.hunter.hybridize.core.utils.Util.createHybridizeFunctionRefactoring; import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; import org.apache.commons.csv.CSVPrinter; @@ -18,12 +22,19 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; import org.eclipse.ui.ISources; import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; import edu.cuny.citytech.refactoring.common.core.TimeCollector; import edu.cuny.citytech.refactoring.common.eval.handlers.EvaluateRefactoringHandler; +import edu.cuny.hunter.hybridize.core.analysis.Function; +import edu.cuny.hunter.hybridize.core.analysis.PreconditionSuccess; +import edu.cuny.hunter.hybridize.core.analysis.Refactoring; +import edu.cuny.hunter.hybridize.core.analysis.Transformation; +import edu.cuny.hunter.hybridize.core.refactorings.HybridizeFunctionRefactoringProcessor; public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { @@ -32,9 +43,25 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { - try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, new String[] { "subject", "time (s)" })) { + List resultsHeader = new ArrayList<>(Arrays.asList("subject", "functions", "optimization available functions", + "optimizable functions", "failed preconditions")); + + for (Refactoring refactoring : Refactoring.values()) + resultsHeader.add(refactoring.toString()); + + for (PreconditionSuccess preconditionSuccess : PreconditionSuccess.values()) + resultsHeader.add(preconditionSuccess.toString()); + + for (Transformation transformation : Transformation.values()) + resultsHeader.add(transformation.toString()); + + resultsHeader.add("time (s)"); + + try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new))) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); + monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); + for (IProject project : pythonProjectsFromEvent) { // subject. resultsPrinter.print(project.getName()); @@ -43,9 +70,19 @@ public Object execute(ExecutionEvent event) throws ExecutionException { TimeCollector resultsTimeCollector = new TimeCollector(); resultsTimeCollector.start(); - // TODO + HybridizeFunctionRefactoringProcessor processor = createHybridizeFunctionRefactoring(new IProject[] { project }, + monitor); resultsTimeCollector.stop(); + // run the precondition checking. + resultsTimeCollector.start(); + RefactoringStatus status = new ProcessorBasedRefactoring(processor).checkAllConditions(monitor); + resultsTimeCollector.stop(); + + // functions. + Set functions = processor.getFunctions(); + resultsPrinter.print(functions.size()); + // overall results time. resultsPrinter.print( // TODO: @@ -56,6 +93,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // end the record. resultsPrinter.println(); + + monitor.worked(1); } } catch (IOException | ExecutionException e) { throw new CoreException(Status.error("Encountered error with evaluation.", e)); diff --git a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java index 7520bb0fd..ab34e3f22 100644 --- a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java +++ b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java @@ -1,15 +1,10 @@ package edu.cuny.hunter.hybridize.ui.handlers; -import static edu.cuny.hunter.hybridize.ui.handlers.Util.getDocument; -import static edu.cuny.hunter.hybridize.ui.handlers.Util.getFile; -import static edu.cuny.hunter.hybridize.ui.handlers.Util.getModuleName; +import static edu.cuny.hunter.hybridize.core.utils.Util.getFunctionDefinitions; import static org.eclipse.core.runtime.Platform.getLog; import static org.eclipse.ui.handlers.HandlerUtil.getActiveShellChecked; -import java.io.File; import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -19,22 +14,13 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILog; -import org.eclipse.jface.text.IDocument; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.ast.refactoring.TooManyMatchesException; -import org.python.pydev.core.IPythonNature; -import org.python.pydev.navigator.PythonModelProvider; -import org.python.pydev.navigator.elements.PythonNode; -import org.python.pydev.outline.ParsedItem; -import org.python.pydev.parser.jython.SimpleNode; -import org.python.pydev.parser.jython.ast.FunctionDef; -import org.python.pydev.parser.visitors.scope.ASTEntryWithChildren; import edu.cuny.hunter.hybridize.core.analysis.FunctionDefinition; -import edu.cuny.hunter.hybridize.core.analysis.FunctionExtractor; import edu.cuny.hunter.hybridize.core.utils.RefactoringAvailabilityTester; import edu.cuny.hunter.hybridize.ui.wizards.HybridizeFunctionRefactoringWizard; @@ -42,74 +28,22 @@ public class HybridizeFunctionHandler extends AbstractHandler { private static final ILog LOG = getLog(HybridizeFunctionHandler.class); - private static final PythonModelProvider provider = new PythonModelProvider(); - - private static Set getPythonNodes(Object obj) { - Set ret = new HashSet<>(); - - if (obj instanceof PythonNode) { - PythonNode pythonNode = (PythonNode) obj; - ret.add(pythonNode); - } else { - Object[] children = provider.getChildren(obj); - for (Object child : children) - ret.addAll(getPythonNodes(child)); - } - return ret; - } - - private static Set process(PythonNode pythonNode) throws ExecutionException, CoreException, IOException { - Set ret = new HashSet<>(); - - String moduleName = getModuleName(pythonNode); - File file = getFile(pythonNode); - IDocument document = getDocument(pythonNode); - IPythonNature nature = Util.getPythonNature(pythonNode); - - ParsedItem entry = pythonNode.entry; - ASTEntryWithChildren ast = entry.getAstThis(); - SimpleNode simpleNode = ast.node; - - // extract function definitions. - FunctionExtractor functionExtractor = new FunctionExtractor(); - try { - simpleNode.accept(functionExtractor); - } catch (Exception e) { - LOG.error("Failed to start refactoring.", e); - throw new ExecutionException("Failed to start refactoring.", e); - } - - Collection definitions = functionExtractor.getDefinitions(); - - for (FunctionDef def : definitions) { - FunctionDefinition function = new FunctionDefinition(def, moduleName, file, document, nature); - ret.add(function); - } - - return ret; - } - /** * Gather all functions from the user's selection. */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - Set functions = new HashSet<>(); + Set functions = null; ISelection currentSelection = HandlerUtil.getCurrentSelectionChecked(event); if (currentSelection instanceof IStructuredSelection) { List list = ((IStructuredSelection) currentSelection).toList(); if (list != null) - for (Object obj : list) { - Set nodeSet = getPythonNodes(obj); - - for (PythonNode node : nodeSet) - try { - functions.addAll(process(node)); - } catch (CoreException | IOException e) { - throw new ExecutionException("Unable to process python node:" + node + ".", e); - } + try { + functions = getFunctionDefinitions(list); + } catch (CoreException | IOException e) { + throw new ExecutionException("Unable to get functions from selections.", e); } } diff --git a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/Util.java b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/Util.java deleted file mode 100644 index 2d2cb4591..000000000 --- a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/Util.java +++ /dev/null @@ -1,71 +0,0 @@ -package edu.cuny.hunter.hybridize.ui.handlers; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.python.pydev.core.IPythonNature; -import org.python.pydev.navigator.elements.PythonFile; -import org.python.pydev.navigator.elements.PythonNode; -import org.python.pydev.navigator.elements.PythonSourceFolder; -import org.python.pydev.plugin.nature.PythonNature; - -public class Util { - private static IFile getActualFile(PythonNode pythonNode) { - PythonFile pythonFile = pythonNode.getPythonFile(); - return pythonFile.getActualObject(); - } - - static IDocument getDocument(PythonNode pythonNode) throws CoreException, IOException { - IFile file = getActualFile(pythonNode); - - try (InputStream contentStream = file.getContents()) { - byte[] bytes = contentStream.readAllBytes(); - String content = new String(bytes, UTF_8); - return new Document(content); - } - } - - static File getFile(PythonNode pythonNode) { - IFile file = getActualFile(pythonNode); - URI uri = file.getRawLocationURI(); - return new File(uri); - } - - static String getFileName(PythonNode pythonNode) { - IFile file = getActualFile(pythonNode); - return file.getName(); - } - - static String getModuleName(PythonNode pythonNode) { - String fileName = getFileName(pythonNode); - int separatorPos = fileName.indexOf('.'); - return fileName.substring(0, separatorPos); - } - - static IPythonNature getPythonNature(PythonNode pythonNode) { - IProject project = getProject(pythonNode); - PythonNature pythonNature = PythonNature.getPythonNature(project); - return pythonNature; - } - - private static IProject getProject(PythonNode pythonNode) { - PythonFile pythonFile = pythonNode.getPythonFile(); - PythonSourceFolder sourceFolder = pythonFile.getSourceFolder(); - IResource resource = sourceFolder.getActualObject(); - IProject project = resource.getProject(); - return project; - } - - private Util() { - } -} diff --git a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/wizards/HybridizeFunctionRefactoringWizard.java b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/wizards/HybridizeFunctionRefactoringWizard.java index f50790dc4..2bd937223 100644 --- a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/wizards/HybridizeFunctionRefactoringWizard.java +++ b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/wizards/HybridizeFunctionRefactoringWizard.java @@ -1,6 +1,7 @@ package edu.cuny.hunter.hybridize.ui.wizards; import static edu.cuny.hunter.hybridize.core.messages.Messages.Name; +import static edu.cuny.hunter.hybridize.core.utils.Util.createRefactoring; import java.util.Set; @@ -63,7 +64,7 @@ protected void setProcessor(RefactoringProcessor processor) { public static void startRefactoring(Set functionDefinitions, Shell shell) throws TooManyMatchesException { - Refactoring refactoring = edu.cuny.hunter.hybridize.core.utils.Util.createRefactoring(functionDefinitions); + Refactoring refactoring = createRefactoring(functionDefinitions); RefactoringWizard wizard = new HybridizeFunctionRefactoringWizard(refactoring); new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, From cf36e3d1410e586749da228b0c366440d232ade7 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:07:41 -0400 Subject: [PATCH 22/51] Remove unused monitor. --- .../src/edu/cuny/hunter/hybridize/core/utils/Util.java | 2 +- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java index 35dc8b7fd..080cd1ece 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java @@ -49,7 +49,7 @@ public static Refactoring createRefactoring(Set functionDefi return new ProcessorBasedRefactoring(new HybridizeFunctionRefactoringProcessor(functionDefinitions)); } - public static HybridizeFunctionRefactoringProcessor createHybridizeFunctionRefactoring(IProject[] projects, IProgressMonitor monitor) + public static HybridizeFunctionRefactoringProcessor createHybridizeFunctionRefactoring(IProject[] projects) throws ExecutionException, CoreException, IOException { Set functionDefinitions = getFunctionDefinitions(Arrays.asList(projects)); HybridizeFunctionRefactoringProcessor processor = new HybridizeFunctionRefactoringProcessor(functionDefinitions); diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 1a4972b53..06885f05b 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -70,8 +70,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { TimeCollector resultsTimeCollector = new TimeCollector(); resultsTimeCollector.start(); - HybridizeFunctionRefactoringProcessor processor = createHybridizeFunctionRefactoring(new IProject[] { project }, - monitor); + HybridizeFunctionRefactoringProcessor processor = createHybridizeFunctionRefactoring(new IProject[] { project }); resultsTimeCollector.stop(); // run the precondition checking. From ab6fe9932460308d5d76df1305f15393e6a6b134 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:07:57 -0400 Subject: [PATCH 23/51] Inline variable. --- .../src/edu/cuny/hunter/hybridize/core/utils/Util.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java index 080cd1ece..cc641f8bf 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java @@ -52,8 +52,7 @@ public static Refactoring createRefactoring(Set functionDefi public static HybridizeFunctionRefactoringProcessor createHybridizeFunctionRefactoring(IProject[] projects) throws ExecutionException, CoreException, IOException { Set functionDefinitions = getFunctionDefinitions(Arrays.asList(projects)); - HybridizeFunctionRefactoringProcessor processor = new HybridizeFunctionRefactoringProcessor(functionDefinitions); - return processor; + return new HybridizeFunctionRefactoringProcessor(functionDefinitions); } public static Set getFunctionDefinitions(Iterable iterable) From 78dcc94b386362106e8908d702e386afe9ef2902 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:08:27 -0400 Subject: [PATCH 24/51] Long unused variable. --- .../EvaluateHybridizeFunctionRefactoringHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 06885f05b..ae0c948a9 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -1,6 +1,7 @@ package edu.cuny.hunter.hybridize.eval.handlers; import static edu.cuny.hunter.hybridize.core.utils.Util.createHybridizeFunctionRefactoring; +import static org.eclipse.core.runtime.Platform.getLog; import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; import java.io.IOException; @@ -17,6 +18,7 @@ import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; @@ -38,6 +40,8 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { + private static final ILog LOG = getLog(EvaluateHybridizeFunctionRefactoringHandler.class); + private static final String RESULTS_CSV_FILENAME = "results.csv"; @Override @@ -78,6 +82,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { RefactoringStatus status = new ProcessorBasedRefactoring(processor).checkAllConditions(monitor); resultsTimeCollector.stop(); + LOG.info("Result of the precondition checking: " + status + "."); + // functions. Set functions = processor.getFunctions(); resultsPrinter.print(functions.size()); From 68a574049881ba9f481e0eb6f3b51daad2313d2c Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:28:33 -0400 Subject: [PATCH 25/51] Remove unused import. --- .../src/edu/cuny/hunter/hybridize/core/utils/Util.java | 1 - 1 file changed, 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java index cc641f8bf..1e333ea5d 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/utils/Util.java @@ -18,7 +18,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.ltk.core.refactoring.Refactoring; From ca1ef01a6157ccfcef5204958db259e89df36ec7 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:28:51 -0400 Subject: [PATCH 26/51] Count candidate streams. --- edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF | 1 + .../edu/cuny/hunter/hybridize/core/analysis/Function.java | 6 ++++++ edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF | 3 ++- .../EvaluateHybridizeFunctionRefactoringHandler.java | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF index 10f6500bd..602848304 100644 --- a/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.core/META-INF/MANIFEST.MF @@ -40,6 +40,7 @@ Import-Package: com.ibm.wala.cast.ipa.callgraph, com.ibm.wala.types, com.ibm.wala.util, com.ibm.wala.util.collections, + edu.cuny.hunter.hybridize.core.utils, org.eclipse.core.commands, org.eclipse.core.runtime;version="3.7.0", org.eclipse.jface.text, diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java index d65036f85..1d977f300 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java @@ -37,6 +37,8 @@ import edu.cuny.citytech.refactoring.common.core.RefactorableProgramEntity; +import edu.cuny.hunter.hybridize.core.utils.RefactoringAvailabilityTester; + /** * A representation of a Python function. * @@ -695,4 +697,8 @@ public RefactoringStatus getStatus() { public IProject getProject() { return this.getFunctionDefinition().getProject(); } + + public boolean isHybridizationAvailable() { + return RefactoringAvailabilityTester.isHybridizationAvailable(this.getFunctionDefinition().getFunctionDef()); + } } diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index a557b5bd3..f49cde39c 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: edu.cuny.hunter.hybridize.eval;singleton:=true Bundle-Vendor: %Bundle-Vendor Bundle-Version: 1.0.0.qualifier -Import-Package: org.python.pydev.plugin.nature +Import-Package: org.python.pydev.parser.jython.ast, + org.python.pydev.plugin.nature Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", org.eclipse.core.resources;bundle-version="3.18.0", diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index ae0c948a9..5fbfdf762 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -10,6 +10,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.csv.CSVPrinter; import org.eclipse.core.commands.ExecutionEvent; @@ -37,6 +38,7 @@ import edu.cuny.hunter.hybridize.core.analysis.Refactoring; import edu.cuny.hunter.hybridize.core.analysis.Transformation; import edu.cuny.hunter.hybridize.core.refactorings.HybridizeFunctionRefactoringProcessor; +import edu.cuny.hunter.hybridize.core.utils.RefactoringAvailabilityTester; public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { @@ -88,6 +90,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Set functions = processor.getFunctions(); resultsPrinter.print(functions.size()); + // optimization available functions. These are the "filtered" functions. + Set candidates = functions.stream().filter(f -> f.isHybridizationAvailable()).collect(Collectors.toSet()); + resultsPrinter.print(candidates.size()); // number. + // overall results time. resultsPrinter.print( // TODO: From 35f1bb073bd5a012105f9e82422e11f79b607974 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:38:50 -0400 Subject: [PATCH 27/51] Fix imports. --- .../src/edu/cuny/hunter/hybridize/core/analysis/Function.java | 1 - 1 file changed, 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java index 1d977f300..65d294e7b 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java @@ -36,7 +36,6 @@ import com.ibm.wala.util.collections.Pair; import edu.cuny.citytech.refactoring.common.core.RefactorableProgramEntity; - import edu.cuny.hunter.hybridize.core.utils.RefactoringAvailabilityTester; /** From d7618a0d6e504e8d9c82dec884126998542046d2 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 16:57:05 -0400 Subject: [PATCH 28/51] Fix build. --- ...teHybridizeFunctionRefactoringHandler.java | 1 - .../ui/handlers/HybridizeFunctionHandler.java | 40 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 5fbfdf762..f299017ad 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -38,7 +38,6 @@ import edu.cuny.hunter.hybridize.core.analysis.Refactoring; import edu.cuny.hunter.hybridize.core.analysis.Transformation; import edu.cuny.hunter.hybridize.core.refactorings.HybridizeFunctionRefactoringProcessor; -import edu.cuny.hunter.hybridize.core.utils.RefactoringAvailabilityTester; public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefactoringHandler { diff --git a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java index ab34e3f22..001e4dbec 100644 --- a/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java +++ b/edu.cuny.hunter.hybridize.ui/src/edu/cuny/hunter/hybridize/ui/handlers/HybridizeFunctionHandler.java @@ -33,33 +33,37 @@ public class HybridizeFunctionHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - Set functions = null; ISelection currentSelection = HandlerUtil.getCurrentSelectionChecked(event); if (currentSelection instanceof IStructuredSelection) { + Set functions = null; List list = ((IStructuredSelection) currentSelection).toList(); - if (list != null) - try { - functions = getFunctionDefinitions(list); - } catch (CoreException | IOException e) { - throw new ExecutionException("Unable to get functions from selections.", e); - } - } + try { + functions = getFunctionDefinitions(list); + } catch (CoreException | IOException e) { + throw new ExecutionException("Unable to get functions from selections.", e); + } - LOG.info("Found " + functions.size() + " function definition(s)."); + if (functions != null) { + LOG.info("Found " + functions.size() + " function definition(s)."); - Set availableFunctions = functions.stream() - .filter(f -> RefactoringAvailabilityTester.isHybridizationAvailable(f.getFunctionDef())).collect(Collectors.toSet()); - LOG.info("Found " + availableFunctions.size() + " available functions."); + Set availableFunctions = functions.stream() + .filter(f -> RefactoringAvailabilityTester.isHybridizationAvailable(f.getFunctionDef())) + .collect(Collectors.toSet()); + LOG.info("Found " + availableFunctions.size() + " available functions."); - Shell shell = getActiveShellChecked(event); + Shell shell = getActiveShellChecked(event); - try { - HybridizeFunctionRefactoringWizard.startRefactoring(availableFunctions, shell); - } catch (TooManyMatchesException e) { - throw new ExecutionException("Unable to start refactoring.", e); - } + try { + HybridizeFunctionRefactoringWizard.startRefactoring(availableFunctions, shell); + } catch (TooManyMatchesException e) { + throw new ExecutionException("Unable to start refactoring.", e); + } + } else + throw new ExecutionException("Unable to extract function definitions."); + } else + throw new ExecutionException("Can't extract selection: " + currentSelection + "."); return null; } From 91c1353af7e1bab2690ebbd5760031da492077c8 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 3 Oct 2023 17:13:12 -0400 Subject: [PATCH 29/51] Change log. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index f299017ad..ead768394 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -83,7 +83,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { RefactoringStatus status = new ProcessorBasedRefactoring(processor).checkAllConditions(monitor); resultsTimeCollector.stop(); - LOG.info("Result of the precondition checking: " + status + "."); + LOG.info("Precondition checking suceeded? " + status.isOK() + "."); // functions. Set functions = processor.getFunctions(); From a88044f78fbea63e955151c7a3b48d2a231f5d43 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 10:24:05 -0400 Subject: [PATCH 30/51] Enhance log statement. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index ead768394..ecc388810 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -83,7 +83,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { RefactoringStatus status = new ProcessorBasedRefactoring(processor).checkAllConditions(monitor); resultsTimeCollector.stop(); - LOG.info("Precondition checking suceeded? " + status.isOK() + "."); + LOG.info("Preconditions " + (status.isOK() ? "passed" : "failed") + "."); // functions. Set functions = processor.getFunctions(); From 0776424428c72c9c4e41c14ca3ae974cd74faaee Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 10:24:31 -0400 Subject: [PATCH 31/51] Fix path problem. --- .../ml/EclipsePythonProjectTensorAnalysisEngine.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/wala/ml/EclipsePythonProjectTensorAnalysisEngine.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/wala/ml/EclipsePythonProjectTensorAnalysisEngine.java index 06ba46158..89a4557c4 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/wala/ml/EclipsePythonProjectTensorAnalysisEngine.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/wala/ml/EclipsePythonProjectTensorAnalysisEngine.java @@ -50,7 +50,7 @@ public class EclipsePythonProjectTensorAnalysisEngine extends PythonTensorAnalys public EclipsePythonProjectTensorAnalysisEngine(IProject project) { this.project = project; - IPath projectPath = project.getFullPath(); + IPath projectPath = getPath(project); Module dirModule = new EclipseSourceDirectoryTreeModule(projectPath, null, ".py"); LOG.info("Creating engine from: " + dirModule); @@ -62,6 +62,15 @@ public EclipsePythonProjectTensorAnalysisEngine(IProject project) { } } + private static IPath getPath(IProject project) { + IPath path = project.getFullPath(); + + if (!path.toFile().exists()) + path = project.getLocation(); + + return path; + } + public IProject getProject() { return project; } From 15d3a9e60cab911ebc7704e6c28a513b1cd771c1 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 11:38:16 -0400 Subject: [PATCH 32/51] More fields. --- ...HybridizeFunctionRefactoringProcessor.java | 4 ++++ .../META-INF/MANIFEST.MF | 3 ++- ...teHybridizeFunctionRefactoringHandler.java | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/refactorings/HybridizeFunctionRefactoringProcessor.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/refactorings/HybridizeFunctionRefactoringProcessor.java index 659601050..95cab52ab 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/refactorings/HybridizeFunctionRefactoringProcessor.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/refactorings/HybridizeFunctionRefactoringProcessor.java @@ -278,6 +278,10 @@ public Set getFunctions() { return this.functions; } + public Set getOptimizableFunctions() { + return this.getFunctions().parallelStream().filter(f -> !f.getStatus().hasError()).collect(Collectors.toSet()); + } + @Override public String getIdentifier() { return HybridizeFunctionRefactoringDescriptor.REFACTORING_ID; diff --git a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF index f49cde39c..8410b2c0b 100644 --- a/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF +++ b/edu.cuny.hunter.hybridize.eval/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: edu.cuny.hunter.hybridize.eval;singleton:=true Bundle-Vendor: %Bundle-Vendor Bundle-Version: 1.0.0.qualifier -Import-Package: org.python.pydev.parser.jython.ast, +Import-Package: com.google.common.collect, + org.python.pydev.parser.jython.ast, org.python.pydev.plugin.nature Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime;bundle-version="3.26.0", diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index ecc388810..241de2a2f 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -26,11 +27,15 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry; import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; import org.eclipse.ui.ISources; import org.eclipse.ui.handlers.HandlerUtil; import org.python.pydev.navigator.elements.PythonSourceFolder; +import com.google.common.collect.Sets; +import com.google.common.collect.Sets.SetView; + import edu.cuny.citytech.refactoring.common.core.TimeCollector; import edu.cuny.citytech.refactoring.common.eval.handlers.EvaluateRefactoringHandler; import edu.cuny.hunter.hybridize.core.analysis.Function; @@ -93,6 +98,20 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Set candidates = functions.stream().filter(f -> f.isHybridizationAvailable()).collect(Collectors.toSet()); resultsPrinter.print(candidates.size()); // number. + // optimizable functions. + Set optimizableFunctions = processor.getOptimizableFunctions(); + resultsPrinter.print(optimizableFunctions.size()); // number. + + // failed functions. + SetView failures = Sets.difference(candidates, optimizableFunctions); + + // failed preconditions. + Collection errorEntries = failures.parallelStream().map(Function::getStatus) + .flatMap(s -> Arrays.stream(s.getEntries())).filter(RefactoringStatusEntry::isError) + .collect(Collectors.toSet()); + + resultsPrinter.print(errorEntries.size()); // number. + // overall results time. resultsPrinter.print( // TODO: From d07925b4e38fc8565cfca17837157ed4a26a27e1 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 12:05:10 -0400 Subject: [PATCH 33/51] Finish results.csv. For now. --- .../hunter/hybridize/core/analysis/Function.java | 12 ++++++++++++ ...luateHybridizeFunctionRefactoringHandler.java | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java index 65d294e7b..42531b163 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java @@ -700,4 +700,16 @@ public IProject getProject() { public boolean isHybridizationAvailable() { return RefactoringAvailabilityTester.isHybridizationAvailable(this.getFunctionDefinition().getFunctionDef()); } + + public Set getTransformations() { + return transformations; + } + + public PreconditionSuccess getPassingPrecondition() { + return passingPrecondition; + } + + public Refactoring getRefactoring() { + return refactoring; + } } diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 241de2a2f..dbecdfaff 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -10,6 +10,7 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -112,6 +113,21 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.print(errorEntries.size()); // number. + // Refactoring type counts. + for (Refactoring refactoring : Refactoring.values()) + resultsPrinter.print(functions.parallelStream().map(Function::getRefactoring) + .filter(r -> Objects.equals(r, refactoring)).count()); + + // Precondition success counts. + for (PreconditionSuccess preconditionSuccess : PreconditionSuccess.values()) + resultsPrinter.print(functions.parallelStream().map(Function::getPassingPrecondition) + .filter(pp -> Objects.equals(pp, preconditionSuccess)).count()); + + // Transformation counts. + for (Transformation transformation : Transformation.values()) + resultsPrinter.print(functions.parallelStream().map(Function::getTransformations).filter(Objects::nonNull) + .flatMap(as -> as.parallelStream()).filter(a -> Objects.equals(a, transformation)).count()); + // overall results time. resultsPrinter.print( // TODO: From b8d926d1238f81f5f47a4645dec5a7f07dfa4dfb Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 12:23:08 -0400 Subject: [PATCH 34/51] Add missing changes. Fixes buidl. --- .../edu/cuny/hunter/hybridize/core/analysis/Function.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java index 42531b163..cb39e6a51 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java @@ -287,22 +287,19 @@ public boolean getReduceRetracingParamExists() { /** * TODO: Populate. */ - @SuppressWarnings("unused") - private Set transformationSet; + private Set transformations; // private InstanceKey instanceKey; /** * TODO: Populate. */ - @SuppressWarnings("unused") private PreconditionSuccess passingPrecondition; /** * The refactoring that this {@link Function} qualifies for. There should be only one as the refactorings are mutually exclusive. TODO: * Populate. */ - @SuppressWarnings("unused") private Refactoring refactoring; private RefactoringStatus status = new RefactoringStatus(); From 2f88e70c6dcb3a1f6e34fa33f0308e3de88de65a Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 12:46:54 -0400 Subject: [PATCH 35/51] Perform refactoring change. --- ...ateHybridizeFunctionRefactoringHandler.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index dbecdfaff..327867cb8 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -22,11 +22,13 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry; import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; @@ -51,6 +53,8 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String RESULTS_CSV_FILENAME = "results.csv"; + private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.hybridize.eval.performChange"; + @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { @@ -85,8 +89,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsTimeCollector.stop(); // run the precondition checking. + ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor); resultsTimeCollector.start(); - RefactoringStatus status = new ProcessorBasedRefactoring(processor).checkAllConditions(monitor); + RefactoringStatus status = refactoring.checkAllConditions(monitor); resultsTimeCollector.stop(); LOG.info("Preconditions " + (status.isOK() ? "passed" : "failed") + "."); @@ -114,9 +119,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.print(errorEntries.size()); // number. // Refactoring type counts. - for (Refactoring refactoring : Refactoring.values()) + for (Refactoring refactoringKind : Refactoring.values()) resultsPrinter.print(functions.parallelStream().map(Function::getRefactoring) - .filter(r -> Objects.equals(r, refactoring)).count()); + .filter(r -> Objects.equals(r, refactoringKind)).count()); // Precondition success counts. for (PreconditionSuccess preconditionSuccess : PreconditionSuccess.values()) @@ -128,6 +133,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.print(functions.parallelStream().map(Function::getTransformations).filter(Objects::nonNull) .flatMap(as -> as.parallelStream()).filter(a -> Objects.equals(a, transformation)).count()); + if (Boolean.getBoolean(PERFORM_CHANGE_PROPERTY_KEY) && !status.hasFatalError()) { + resultsTimeCollector.start(); + Change change = refactoring.createChange(monitor.slice(IProgressMonitor.UNKNOWN)); + change.perform(monitor.slice(IProgressMonitor.UNKNOWN)); + resultsTimeCollector.stop(); + } + // overall results time. resultsPrinter.print( // TODO: From e1004ec6be69a6bc42b70b21b5cd7b375d89c463 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 16:23:06 -0400 Subject: [PATCH 36/51] More fields. --- ...teHybridizeFunctionRefactoringHandler.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 327867cb8..d538df1de 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -5,6 +5,7 @@ import static org.python.pydev.plugin.nature.PythonNature.PYTHON_NATURE_ID; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -53,6 +54,8 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String RESULTS_CSV_FILENAME = "results.csv"; + private static final String CANDIDATE_CSV_FILENAME = "candidate_functions.csv"; + private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.hybridize.eval.performChange"; @Override @@ -72,7 +75,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsHeader.add("time (s)"); - try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new))) { + try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); + CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, new String[] { "subject", "function", "module", + "relative path", "parameters", "tensor parameter", "hybrid" })) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); @@ -104,6 +109,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Set candidates = functions.stream().filter(f -> f.isHybridizationAvailable()).collect(Collectors.toSet()); resultsPrinter.print(candidates.size()); // number. + // candidate functions. + for (Function function : candidates) { + Path relativePath = project.getLocation().toFile().toPath().relativize(function.getContainingFile().toPath()); + + candidatePrinter.printRecord(project.getName(), function.getIdentifer(), function.getContainingModuleName(), + relativePath, function.getNumberOfParameters(), function.getLikelyHasTensorParameter(), + function.isHybrid()); + } + // optimizable functions. Set optimizableFunctions = processor.getOptimizableFunctions(); resultsPrinter.print(optimizableFunctions.size()); // number. @@ -118,17 +132,17 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.print(errorEntries.size()); // number. - // Refactoring type counts. + // refactoring type counts. for (Refactoring refactoringKind : Refactoring.values()) resultsPrinter.print(functions.parallelStream().map(Function::getRefactoring) .filter(r -> Objects.equals(r, refactoringKind)).count()); - // Precondition success counts. + // precondition success counts. for (PreconditionSuccess preconditionSuccess : PreconditionSuccess.values()) resultsPrinter.print(functions.parallelStream().map(Function::getPassingPrecondition) .filter(pp -> Objects.equals(pp, preconditionSuccess)).count()); - // Transformation counts. + // transformation counts. for (Transformation transformation : Transformation.values()) resultsPrinter.print(functions.parallelStream().map(Function::getTransformations).filter(Objects::nonNull) .flatMap(as -> as.parallelStream()).filter(a -> Objects.equals(a, transformation)).count()); From 950066616f24a70bcff01113247d295eaa9cbdfa Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 4 Oct 2023 16:36:55 -0400 Subject: [PATCH 37/51] More fields. --- .../EvaluateHybridizeFunctionRefactoringHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index d538df1de..868c18f97 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -76,8 +76,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsHeader.add("time (s)"); try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); - CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, new String[] { "subject", "function", "module", - "relative path", "parameters", "tensor parameter", "hybrid" })) { + CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, + new String[] { "subject", "function", "module", "relative path", "parameters", "tensor parameter", "hybrid", + "refactoring", "passingPrecondition", "status" })) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); @@ -112,10 +113,12 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // candidate functions. for (Function function : candidates) { Path relativePath = project.getLocation().toFile().toPath().relativize(function.getContainingFile().toPath()); + RefactoringStatus functionStatus = function.getStatus(); candidatePrinter.printRecord(project.getName(), function.getIdentifer(), function.getContainingModuleName(), - relativePath, function.getNumberOfParameters(), function.getLikelyHasTensorParameter(), - function.isHybrid()); + relativePath, function.getNumberOfParameters(), function.getLikelyHasTensorParameter(), function.isHybrid(), + function.getRefactoring(), function.getPassingPrecondition(), + functionStatus.isOK() ? 0 : functionStatus.getEntryWithHighestSeverity().getSeverity()); } // optimizable functions. From d041262e5e877bc18dbe6428a08d0585def07dd8 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 5 Oct 2023 17:34:43 -0400 Subject: [PATCH 38/51] Suppress indentation warnings. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 868c18f97..6177f5a7f 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -76,6 +76,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsHeader.add("time (s)"); try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); + @SuppressWarnings("indentation") CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, new String[] { "subject", "function", "module", "relative path", "parameters", "tensor parameter", "hybrid", "refactoring", "passingPrecondition", "status" })) { From 9e23c201e09e6c9dc10014958cb166c40aa0204c Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 10:02:20 -0400 Subject: [PATCH 39/51] Ignore unsupported token issue. For checkstyle. --- .../.settings/org.eclipse.jdt.core.prefs | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs index c9545f06a..faf8516df 100644 --- a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs +++ b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,112 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=11 From 098b30e264c0b23a13c4c6cb969321a4f2dc8c03 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 11:22:40 -0400 Subject: [PATCH 40/51] Use method to build function attribute columns. --- .../EvaluateHybridizeFunctionRefactoringHandler.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 6177f5a7f..e5a2abf7d 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -58,6 +58,13 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.hybridize.eval.performChange"; + private static String[] buildAttributeColumns(String... attributes) { + String[] primaryColumns = new String[] { "subject", "function", "module", "relative path" }; + List ret = new ArrayList<>(Arrays.asList(primaryColumns)); + ret.addAll(Arrays.asList(attributes)); + return ret.toArray(String[]::new); + } + @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { @@ -77,9 +84,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); @SuppressWarnings("indentation") - CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, - new String[] { "subject", "function", "module", "relative path", "parameters", "tensor parameter", "hybrid", - "refactoring", "passingPrecondition", "status" })) { + CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, buildAttributeColumns("parameters", + "tensor parameter", "hybrid", "refactoring", "passingPrecondition", "status"));) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); From 5f84696f1a7cc3e5553f0cce07bb85efbd68a0a7 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 11:23:14 -0400 Subject: [PATCH 41/51] Fix column name. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index e5a2abf7d..cbdc69e72 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -85,7 +85,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); @SuppressWarnings("indentation") CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, buildAttributeColumns("parameters", - "tensor parameter", "hybrid", "refactoring", "passingPrecondition", "status"));) { + "tensor parameter", "hybrid", "refactoring", "passing precondition", "status"));) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); From 8b23e6c08d04d34f3e61b5751497b25f13eae3c9 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 11:47:37 -0400 Subject: [PATCH 42/51] Change parameter and method name. --- .../EvaluateHybridizeFunctionRefactoringHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index cbdc69e72..a67956d06 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -58,10 +58,10 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.hybridize.eval.performChange"; - private static String[] buildAttributeColumns(String... attributes) { + private static String[] buildAttributeColumnNames(String... additionalColumnNames) { String[] primaryColumns = new String[] { "subject", "function", "module", "relative path" }; List ret = new ArrayList<>(Arrays.asList(primaryColumns)); - ret.addAll(Arrays.asList(attributes)); + ret.addAll(Arrays.asList(additionalColumnNames)); return ret.toArray(String[]::new); } @@ -84,7 +84,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); @SuppressWarnings("indentation") - CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, buildAttributeColumns("parameters", + CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, buildAttributeColumnNames("parameters", "tensor parameter", "hybrid", "refactoring", "passing precondition", "status"));) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); From 4d6658db8547bc13fac87d97cca530b917ed31de Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 11:51:56 -0400 Subject: [PATCH 43/51] Use method to build column values. --- ...teHybridizeFunctionRefactoringHandler.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index a67956d06..f3e1ecb3b 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -65,6 +65,16 @@ private static String[] buildAttributeColumnNames(String... additionalColumnName return ret.toArray(String[]::new); } + private static Object[] buildAttributeColumnValues(Function function, Object... additioanlColumnValues) { + IProject project = function.getProject(); + Path relativePath = project.getLocation().toFile().toPath().relativize(function.getContainingFile().toPath()); + String[] primaryColumns = new String[] { project.getName(), function.getIdentifer(), function.getContainingModuleName(), + relativePath.toString() }; + List ret = new ArrayList<>(Arrays.asList(primaryColumns)); + ret.addAll(Arrays.asList(additioanlColumnValues)); + return ret.toArray(Object[]::new); + } + @Override public Object execute(ExecutionEvent event) throws ExecutionException { Job.create("Evaluating Hybridize Functions refactoring...", monitor -> { @@ -119,13 +129,12 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // candidate functions. for (Function function : candidates) { - Path relativePath = project.getLocation().toFile().toPath().relativize(function.getContainingFile().toPath()); RefactoringStatus functionStatus = function.getStatus(); - candidatePrinter.printRecord(project.getName(), function.getIdentifer(), function.getContainingModuleName(), - relativePath, function.getNumberOfParameters(), function.getLikelyHasTensorParameter(), function.isHybrid(), - function.getRefactoring(), function.getPassingPrecondition(), - functionStatus.isOK() ? 0 : functionStatus.getEntryWithHighestSeverity().getSeverity()); + candidatePrinter.printRecord(buildAttributeColumnValues(function, function.getNumberOfParameters(), + function.getLikelyHasTensorParameter(), function.isHybrid(), function.getRefactoring(), + function.getPassingPrecondition(), + functionStatus.isOK() ? 0 : functionStatus.getEntryWithHighestSeverity().getSeverity())); } // optimizable functions. From 3e242066acd2588e3d84a0910e9821e0734b325e Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 12:05:19 -0400 Subject: [PATCH 44/51] Initialize transformation set. --- .../src/edu/cuny/hunter/hybridize/core/analysis/Function.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java index cb39e6a51..d0b9df303 100644 --- a/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java +++ b/edu.cuny.hunter.hybridize.core/src/edu/cuny/hunter/hybridize/core/analysis/Function.java @@ -3,6 +3,7 @@ import static org.eclipse.core.runtime.Platform.getLog; import java.io.File; +import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -287,7 +288,7 @@ public boolean getReduceRetracingParamExists() { /** * TODO: Populate. */ - private Set transformations; + private Set transformations = new HashSet<>(); // private InstanceKey instanceKey; From d5e83ba3cfe3bb56c692c16e0ce1e71fd6748145 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 12:07:31 -0400 Subject: [PATCH 45/51] Add transformations. --- ...EvaluateHybridizeFunctionRefactoringHandler.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index f3e1ecb3b..bf1d27cb4 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -56,6 +56,8 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String CANDIDATE_CSV_FILENAME = "candidate_functions.csv"; + private static final String TRANSFORMATIONS_CSV_FILENAME = "transformations.csv"; + private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.hybridize.eval.performChange"; private static String[] buildAttributeColumnNames(String... additionalColumnNames) { @@ -94,8 +96,11 @@ public Object execute(ExecutionEvent event) throws ExecutionException { try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); @SuppressWarnings("indentation") - CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, buildAttributeColumnNames("parameters", - "tensor parameter", "hybrid", "refactoring", "passing precondition", "status"));) { + CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, + buildAttributeColumnNames("parameters", "tensor parameter", "hybrid", "refactoring", "passing precondition", + "status")); + CSVPrinter transformationsPrinter = createCSVPrinter(TRANSFORMATIONS_CSV_FILENAME, + buildAttributeColumnNames("transformation"))) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); @@ -135,6 +140,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException { function.getLikelyHasTensorParameter(), function.isHybrid(), function.getRefactoring(), function.getPassingPrecondition(), functionStatus.isOK() ? 0 : functionStatus.getEntryWithHighestSeverity().getSeverity())); + + // transformations. + for (Transformation transformation : function.getTransformations()) + transformationsPrinter.printRecord(buildAttributeColumnValues(function, transformation)); } // optimizable functions. From 5f2312f6848a7bc769d64dbaca5b3bb53f75326d Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 12:07:57 -0400 Subject: [PATCH 46/51] Revert "Ignore unsupported token issue." This reverts commit 9e23c201e09e6c9dc10014958cb166c40aa0204c. --- .../.settings/org.eclipse.jdt.core.prefs | 103 ------------------ 1 file changed, 103 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs index faf8516df..c9545f06a 100644 --- a/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs +++ b/edu.cuny.hunter.hybridize.eval/.settings/org.eclipse.jdt.core.prefs @@ -1,112 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullable.secondary= -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.compliance=11 -org.eclipse.jdt.core.compiler.problem.APILeak=warning -org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled -org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=11 From 2887b135f6458b1d574379d891fa7cc935494df3 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 12:13:52 -0400 Subject: [PATCH 47/51] Remove warning suppression. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index bf1d27cb4..f27050669 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -95,7 +95,6 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsHeader.add("time (s)"); try (CSVPrinter resultsPrinter = createCSVPrinter(RESULTS_CSV_FILENAME, resultsHeader.toArray(String[]::new)); - @SuppressWarnings("indentation") CSVPrinter candidatePrinter = createCSVPrinter(CANDIDATE_CSV_FILENAME, buildAttributeColumnNames("parameters", "tensor parameter", "hybrid", "refactoring", "passing precondition", "status")); From 2ca7b9fa12521fc6469e82634063c532ce32b2a9 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 12:20:41 -0400 Subject: [PATCH 48/51] Simplify name. --- .../handlers/EvaluateHybridizeFunctionRefactoringHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index f27050669..e14bebefb 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -54,7 +54,7 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String RESULTS_CSV_FILENAME = "results.csv"; - private static final String CANDIDATE_CSV_FILENAME = "candidate_functions.csv"; + private static final String CANDIDATE_CSV_FILENAME = "candidates.csv"; private static final String TRANSFORMATIONS_CSV_FILENAME = "transformations.csv"; From 80a4bca63759b1f7b36bddbae81a70300f052042 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 13:55:06 -0400 Subject: [PATCH 49/51] More CSVs. --- ...teHybridizeFunctionRefactoringHandler.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index e14bebefb..9e99759bb 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -58,6 +58,12 @@ public class EvaluateHybridizeFunctionRefactoringHandler extends EvaluateRefacto private static final String TRANSFORMATIONS_CSV_FILENAME = "transformations.csv"; + private static final String OPTMIZABLE_CSV_FILENAME = "optimizable.csv"; + + private static final String NONOPTMIZABLE_CSV_FILENAME = "nonoptimizable.csv"; + + private static final String FAILED_PRECONDITIONS_CSV_FILENAME = "failed_preconditions.csv"; + private static final String PERFORM_CHANGE_PROPERTY_KEY = "edu.cuny.hunter.hybridize.eval.performChange"; private static String[] buildAttributeColumnNames(String... additionalColumnNames) { @@ -99,7 +105,11 @@ public Object execute(ExecutionEvent event) throws ExecutionException { buildAttributeColumnNames("parameters", "tensor parameter", "hybrid", "refactoring", "passing precondition", "status")); CSVPrinter transformationsPrinter = createCSVPrinter(TRANSFORMATIONS_CSV_FILENAME, - buildAttributeColumnNames("transformation"))) { + buildAttributeColumnNames("transformation")); + CSVPrinter optimizableFunctionPrinter = createCSVPrinter(OPTMIZABLE_CSV_FILENAME, buildAttributeColumnNames()); + CSVPrinter nonOptimizableFunctionPrinter = createCSVPrinter(NONOPTMIZABLE_CSV_FILENAME, buildAttributeColumnNames()); + CSVPrinter errorPrinter = createCSVPrinter(FAILED_PRECONDITIONS_CSV_FILENAME, + buildAttributeColumnNames("code", "message"));) { IProject[] pythonProjectsFromEvent = getSelectedPythonProjectsFromEvent(event); monitor.beginTask("Analyzing projects...", pythonProjectsFromEvent.length); @@ -149,9 +159,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException { Set optimizableFunctions = processor.getOptimizableFunctions(); resultsPrinter.print(optimizableFunctions.size()); // number. + for (Function function : optimizableFunctions) + optimizableFunctionPrinter.printRecord(buildAttributeColumnValues(function)); + // failed functions. SetView failures = Sets.difference(candidates, optimizableFunctions); + for (Function function : failures) + nonOptimizableFunctionPrinter.printRecord(buildAttributeColumnValues(function)); + // failed preconditions. Collection errorEntries = failures.parallelStream().map(Function::getStatus) .flatMap(s -> Arrays.stream(s.getEntries())).filter(RefactoringStatusEntry::isError) @@ -159,6 +175,21 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.print(errorEntries.size()); // number. + for (RefactoringStatusEntry entry : errorEntries) { + if (!entry.isFatalError()) { + Object correspondingElement = entry.getData(); + + if (!(correspondingElement instanceof Function)) + throw new IllegalStateException("The element: " + correspondingElement + + " corresponding to a failed precondition is not a Function. Instead, it is a: " + + correspondingElement.getClass()); + + Function failedFunction = (Function) correspondingElement; + + errorPrinter.printRecord(buildAttributeColumnValues(failedFunction, entry.getCode(), entry.getMessage())); + } + } + // refactoring type counts. for (Refactoring refactoringKind : Refactoring.values()) resultsPrinter.print(functions.parallelStream().map(Function::getRefactoring) @@ -174,6 +205,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { resultsPrinter.print(functions.parallelStream().map(Function::getTransformations).filter(Objects::nonNull) .flatMap(as -> as.parallelStream()).filter(a -> Objects.equals(a, transformation)).count()); + // actually perform the refactoring if there are no fatal errors. if (Boolean.getBoolean(PERFORM_CHANGE_PROPERTY_KEY) && !status.hasFatalError()) { resultsTimeCollector.start(); Change change = refactoring.createChange(monitor.slice(IProgressMonitor.UNKNOWN)); From 7df0afa9e5f0a6d7db8c768df503eb47acffea1e Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 14:21:47 -0400 Subject: [PATCH 50/51] Add excluded time collector. --- .../EvaluateHybridizeFunctionRefactoringHandler.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java index 9e99759bb..059d0fd8f 100644 --- a/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java +++ b/edu.cuny.hunter.hybridize.eval/src/edu/cuny/hunter/hybridize/eval/handlers/EvaluateHybridizeFunctionRefactoringHandler.java @@ -214,12 +214,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { } // overall results time. - resultsPrinter.print( - // TODO: - // ( - resultsTimeCollector.getCollectedTime() - // - processor.getExcludedTimeCollector().getCollectedTime()) - / 1000.0); + resultsPrinter.print((resultsTimeCollector.getCollectedTime() - processor.getExcludedTimeCollector().getCollectedTime()) / 1000.0); // end the record. resultsPrinter.println(); From 2282cc4813cb668c25ecf23add1a7c4186706c87 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 6 Oct 2023 14:31:03 -0400 Subject: [PATCH 51/51] Put back snapshot directive. --- hybridize.target | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hybridize.target b/hybridize.target index fae30f07c..9946c0f5c 100644 --- a/hybridize.target +++ b/hybridize.target @@ -37,6 +37,9 @@ github https://maven.pkg.github.com/ponder-lab/ML + + true + @@ -50,4 +53,4 @@ -Declipse.p2.max.threads=10 -Doomph.update.url=https://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ -Dosgi.requiredJavaVersion=17 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms256m -Xmx2048m --add-modules=ALL-SYSTEM - \ No newline at end of file +