package cucumber.eclipse.editor.editors;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;

import cucumber.eclipse.steps.integration.StepsChangedEvent;
import cucumber.eclipse.steps.jdt.StepDefinitions;

public class RecalculateStepsHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IEditorPart editorPart = HandlerUtil.getActiveEditorChecked(event);

		// Needs to be a gherkin editor for this to work, if not then simply do nothing.
		if (!(editorPart instanceof Editor)) {
			return null;
		}
		
        StepDefinitions defs = StepDefinitions.getInstance();
        defs.removeStepListeners();
        if (defs != null) {
            defs.notifyListeners(new StepsChangedEvent());
        }

		return null;
	}

}

@@ -835,45 +835,8 @@
 );%0D%0A
-        defs.removeStepListeners();%0D%0A
     

remove listener bug