Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recompile only outdated when container is selected #184

Merged
merged 2 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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