implement smart class generation

if the file exists, we only change the class declaration, app id, and
the parent::__construct call.