Bug 77871 [GlobalActions] (Re)Build Project should track resources itself
bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java
for (int k = 0; k < editors.length; k++) {
                    IEditorPart editor = editors[k];
                    IEditorInput input = editor.getEditorInput();
                    if (input instanceof IFileEditorInput) {
                        IFile inputFile = ((IFileEditorInput) input).getFile();
                        if (projects.contains(inputFile.getProject())) {
                            page.saveEditor(editor, false);
                        }
                    }
                }
            }
        }
    }
    /* (non-Javadoc)
     * Method declared on WorkspaceAction.
     */
    boolean shouldPerformResourcePruning() {
        return true;
    }
    /**
     * The <code>BuildAction</code> implementation of this
     * <code>SelectionListenerAction</code> method ensures that this action is
     * enabled only if all of the selected resources have buildable projects.
     */
    protected boolean updateSelection(IStructuredSelection s) {
        projectsToBuild = null;
        return !ResourcesPlugin.getWorkspace().isAutoBuilding()
                && super.updateSelection(s) && getProjectsToBuild().size() > 0;
    }
}