Bug 7337 NPE when pasting a member (that got deleted)
1) create a class with members a and b 2) copy a in the packages view (while show members is enabled) 3) delete a in the packages view 4) paste in the packages view ->NPE 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.codemanipulation.MemberEdit.connect(M emberEdit.java:96) at org.eclipse.jdt.internal.corext.codemanipulation.TextBufferEditor.add TextEdit(TextBufferEditor.java:86) at org.eclipse.jdt.internal.ui.reorg.PasteSourceReferencesAction.paste(P asteSourceReferencesAction.java:155) at org.eclipse.jdt.internal.ui.reorg.PasteSourceReferencesAction.perform (PasteSourceReferencesAction.java:139) at org.eclipse.jdt.internal.ui.reorg.PasteSourceReferencesAction$1.run(P asteSourceReferencesAction.java:126) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56) at org.eclipse.jdt.internal.ui.reorg.PasteSourceReferencesAction.run(Pas teSourceReferencesAction.java:123) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(Act ionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handle Event(ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handle Event(ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled C ode)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled C ode)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compil ed Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compile d Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:758) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoa der.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52) java.lang.NullPointerException
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/reorg/PasteSourceReferencesAction.java
return false;
		}
		return true;
	}
	
	private static int getElementType(ISourceReference ref){
		return ((IJavaElement)ref).getElementType();
	}
	
	private static boolean canPasteAfterImportContainerOrDeclaration(int type){
		if (type == IJavaElement.IMPORT_CONTAINER)
			return true;
		if (type == IJavaElement.IMPORT_DECLARATION)	
			return true;
		if (type == IJavaElement.TYPE)		
			return true;	
		return false;
	}
	private static boolean canPasteAfterMember(TypedSource[] elems){
		return areAllMembers(elems);
	}
	
	private static boolean canPasteIn(ISourceReference ref, TypedSource[] elements){
		if (ref instanceof IImportContainer)
			return canPasteInImportContainer(elements);	
		if (ref instanceof IType)
			return canPasteInType(elements);
		if (ref instanceof ICompilationUnit)
			return canPasteInCompilationUnit(elements);