Bug 47838 Make refactoring menu selection sensitive in editor [refactoring]
M5 Currently all refactoring actions are enabled in the editor's context menu. Make them selection dependent. Check if code resolve might be enough (no need to create an AST).
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/SelectionConverter.java
return null;
		IJavaElement candidate= elements[0];
		if (elements.length > 1) {
			candidate= OpenActionUtil.selectJavaElement(elements, shell, title, message);
		}
		return candidate;
	}
	
	public static IJavaElement[] codeResolveHandled(JavaEditor editor, Shell shell, String title) {
		try {
			return codeResolve(editor);
		} catch (JavaModelException e) {
			ExceptionHandler.handle(e, shell, title, ActionMessages.getString("SelectionConverter.codeResolve_failed")); 
		}
		return null;
	}
	
	public static IJavaElement getElementAtOffset(JavaEditor editor) throws JavaModelException {
		return getElementAtOffset(getInput(editor), (ITextSelection)editor.getSelectionProvider().getSelection());
	}
	
	public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException {
		IJavaElement element= SelectionConverter.getElementAtOffset(editor);
		IType type= (IType)element.getAncestor(IJavaElement.TYPE);
		if (type == null) {
			ICompilationUnit unit= SelectionConverter.getInputAsCompilationUnit(editor);
			if (unit != null)
				type= unit.findPrimaryType();
		}
		return type;