@Override public void doRun( ITextSelection selection, Event event, UIInstrumentationBuilder instrumentation) { if (!ActionUtil.isEditable(fEditor)) { instrumentation.metric("Problem", "Editor not editable"); return; } CompilationUnit cu = SelectionConverter.getInputAsCompilationUnit(fEditor); instrumentation.record(cu); try { DartFunction function = DartModelUtil.findFunction(cu, selection.getOffset()); instrumentation.data("function", function.getSource()); boolean success = RefactoringExecutionStarter_OLD.startConvertGetterToMethodRefactoring( function, getShell()); if (success) { return; } instrumentation.metric( "Problem", "RefactoringExecutionStarter.startConvertGetterToMethodRefactoring False"); } catch (Throwable e) { instrumentation.record(e); } instrumentation.metric("Problem", "No valid selection, showing dialog"); MessageDialog.openInformation( getShell(), RefactoringMessages.ConvertGetterToMethodAction_dialog_title, RefactoringMessages.ConvertGetterToMethodAction_select); }
@Override public void doRun( IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) { try { Object element = selection.getFirstElement(); if (element instanceof DartFunction) { DartFunction function = (DartFunction) element; instrumentation.data("function", function.getSource()); if (!RefactoringAvailabilityTester.isConvertGetterToMethodAvailable(function)) { instrumentation.metric("Problem", "RefactoringAvailabilityTester Returned false"); } boolean success = RefactoringExecutionStarter_OLD.startConvertGetterToMethodRefactoring( function, getShell()); if (success) { return; } instrumentation.metric( "Problem", "RefactoringExecutionStarter.startConvertGetterToMethodRefactoring returned False"); } } catch (DartModelException e) { ExceptionHandler.handle( e, getShell(), RefactoringMessages.ConvertGetterToMethodAction_dialog_title, RefactoringMessages.InlineMethodAction_unexpected_exception); } }