From 80a1b4b2877e497e5452dd109aca2e5a3a25b16e Mon Sep 17 00:00:00 2001 From: Alexander Nittka Date: Wed, 9 May 2018 15:19:33 +0200 Subject: [PATCH 1/2] recompile only outdated when container is selected --- org.elysium.parent/org.elysium.ui/plugin.xml | 22 ++++++++++++++-- .../handlers/RecompileSelectedHandler.java | 25 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/org.elysium.parent/org.elysium.ui/plugin.xml b/org.elysium.parent/org.elysium.ui/plugin.xml index 8acb2af..156a7b9 100644 --- a/org.elysium.parent/org.elysium.ui/plugin.xml +++ b/org.elysium.parent/org.elysium.ui/plugin.xml @@ -83,7 +83,16 @@ - + + + + @@ -436,7 +445,16 @@ - + + + + + diff --git a/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java b/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java index d67bc5f..5c2ba86 100644 --- a/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java +++ b/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java @@ -1,7 +1,9 @@ package org.elysium.ui.compiler.handlers; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import javax.inject.Inject; @@ -25,14 +27,17 @@ import org.eclipse.util.ResourceUtils; import org.elysium.LilyPondConstants; import org.elysium.ui.compiler.LilyPondBuilder; +import org.elysium.ui.markers.MarkerTypes; public class RecompileSelectedHandler extends AbstractHandler { @Inject private Provider builder; + private boolean compileOutdatedOnly = false; @Override public Object execute(ExecutionEvent event) throws ExecutionException { + compileOutdatedOnly = Boolean.parseBoolean(event.getParameter("org.elysium.ui.commands.RecompileSelected.outdatedOnly")); Set files = new HashSet(); IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); ISelection selection = activePage.getSelection(); @@ -44,7 +49,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { containedFiles.add((IFile)element); } else if (element instanceof IContainer) { IContainer container = (IContainer)element; - containedFiles.addAll(ResourceUtils.getAllFiles(container)); + containedFiles.addAll(getFilesToCompileFromContainer(container)); } for (IFile file : containedFiles) { IFile source = getLilyPondSourceFile(file); @@ -64,6 +69,24 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return null; } + private List getFilesToCompileFromContainer(IContainer container){ + List allFiles=ResourceUtils.getAllFiles(container); + if(compileOutdatedOnly) { + List outdated=new ArrayList<>(); + for (IFile file : allFiles) { + try { + if(file.findMarkers(MarkerTypes.OUTDATED, false, IResource.DEPTH_ZERO).length>0) { + outdated.add(file); + } + } catch (CoreException e) { + //ignore and return all files + } + } + return outdated; + } + return allFiles; + } + private IFile getLilyPondSourceFile(IFile file) { if(file!=null) { if(LilyPondConstants.EXTENSION.equals(file.getFileExtension())) { From bef584d8e003484c41664b4100547cfab67e1aa3 Mon Sep 17 00:00:00 2001 From: Alexander Nittka Date: Sat, 26 May 2018 13:47:11 +0200 Subject: [PATCH 2/2] really compile only outdated --- .../compiler/handlers/RecompileSelectedHandler.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java b/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java index 5c2ba86..f162093 100644 --- a/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java +++ b/org.elysium.parent/org.elysium.ui/src/org/elysium/ui/compiler/handlers/RecompileSelectedHandler.java @@ -1,9 +1,7 @@ package org.elysium.ui.compiler.handlers; -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Set; import javax.inject.Inject; @@ -49,7 +47,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { containedFiles.add((IFile)element); } else if (element instanceof IContainer) { IContainer container = (IContainer)element; - containedFiles.addAll(getFilesToCompileFromContainer(container)); + containedFiles.addAll(ResourceUtils.getAllFiles(container)); } for (IFile file : containedFiles) { IFile source = getLilyPondSourceFile(file); @@ -65,14 +63,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException { files.add(source); } } - builder.get().compile(files); + builder.get().compile(filterFilesToCompile(files)); return null; } - private List getFilesToCompileFromContainer(IContainer container){ - List allFiles=ResourceUtils.getAllFiles(container); + private Set filterFilesToCompile(Set allFiles){ if(compileOutdatedOnly) { - List outdated=new ArrayList<>(); + Set outdated=new HashSet<>(); for (IFile file : allFiles) { try { if(file.findMarkers(MarkerTypes.OUTDATED, false, IResource.DEPTH_ZERO).length>0) {