Skip to content

Commit

Permalink
Merge pull request #184 from nittka/recompileOutdated
Browse files Browse the repository at this point in the history
recompile only outdated when container is selected
  • Loading branch information
thSoft authored May 30, 2018
2 parents f793342 + bef584d commit 9c78d0d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
22 changes: 20 additions & 2 deletions org.elysium.parent/org.elysium.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@
<extension point="org.eclipse.ui.commands">
<command id="org.elysium.ui.commands.RecompileEdited" name="Recompile Edited" categoryId="org.elysium.ui.commandCategories.LilyPond"/>
<command id="org.elysium.ui.commands.RecompileViewed" name="Recompile Viewed" categoryId="org.elysium.ui.commandCategories.LilyPond"/>
<command id="org.elysium.ui.commands.RecompileSelected" name="Recompile" categoryId="org.elysium.ui.commandCategories.LilyPond"/>
<command
categoryId="org.elysium.ui.commandCategories.LilyPond"
id="org.elysium.ui.commands.RecompileSelected"
name="Recompile">
<commandParameter
id="org.elysium.ui.commands.RecompileSelected.outdatedOnly"
name="name"
optional="true">
</commandParameter>
</command>
<command id="org.elysium.ui.commands.SyntaxUpdateSelected" name="Update Syntax" categoryId="org.elysium.ui.commandCategories.LilyPond"/>
</extension>
<extension point="org.eclipse.ui.handlers">
Expand Down Expand Up @@ -436,7 +445,16 @@
<equals value="org.elysium.ui.perspectives.LilyPond"/>
</with>
</visibleWhen>
<command commandId="org.elysium.ui.commands.RecompileSelected"/>
<command commandId="org.elysium.ui.commands.RecompileSelected" label="Recompile All"/>
<command
commandId="org.elysium.ui.commands.RecompileSelected"
icon="icons/outdated/Marker.png"
label="Recompile Outdated">
<parameter
name="org.elysium.ui.commands.RecompileSelected.outdatedOnly"
value="true">
</parameter>
</command>
<command commandId="org.elysium.ui.commands.SyntaxUpdateSelected"/>
</menu>
</menuContribution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,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<LilyPondBuilder> 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<IFile> files = new HashSet<IFile>();
IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
ISelection selection = activePage.getSelection();
Expand Down Expand Up @@ -60,10 +63,27 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
files.add(source);
}
}
builder.get().compile(files);
builder.get().compile(filterFilesToCompile(files));
return null;
}

private Set<IFile> filterFilesToCompile(Set<IFile> allFiles){
if(compileOutdatedOnly) {
Set<IFile> outdated=new HashSet<>();
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())) {
Expand Down

0 comments on commit 9c78d0d

Please sign in to comment.