Bug 40722 "add arguement to match" throws NPE [quick fix]
---------------Z.java----------------- public class Z extends X { public Z() { super(); //<-- use quickfix here } } class X { public X(int i) { } } ------------------------------------- if you use quick fix where mentioned above to add arguements you get NPE: java.lang.NullPointerException at org.eclipse.jdt.internal.ui.text.correction.AddArgumentCorrectionProposal.getRew rite(AddArgumentCorrectionProposal.java:53) at org.eclipse.jdt.internal.ui.text.correction.ASTRewriteCorrectionProposal.createC ompilationUnitChange(ASTRewriteCorrectionProposal.java:49) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getChange (CUCorrectionProposal.java:90) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getCompilationU nitChange(CUCorrectionProposal.java:291) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.apply (CUCorrectionProposal.java:202) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal (CompletionProposalPopup.java:328) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithM ask(CompletionProposalPopup.java:292) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey (CompletionProposalPopup.java:581) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey (ContentAssistant.java:599) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey (TextViewer.java:368) at org.eclipse.swt.custom.StyledTextListener.handleEvent (StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:872) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:665) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5208) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:4957) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:872) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1675) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1671) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:2993) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2872) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2713) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1338) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1876) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1680) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1663) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
}
		if (nDiffs == 2) { 
			int idx1= indexOfDiff[0];
			int idx2= indexOfDiff[1];
			boolean canSwap= TypeRules.canAssign(argTypes[idx1], paramTypes[idx2]) && TypeRules.canAssign(argTypes[idx2], paramTypes[idx1]);
			 if (canSwap) {
				Expression arg1= (Expression) arguments.get(idx1);
				Expression arg2= (Expression) arguments.get(idx2);
				
				ASTRewrite rewrite= new ASTRewrite(arg1.getParent());
				rewrite.markAsReplaced(arg1, rewrite.createCopy(arg2));
				rewrite.markAsReplaced(arg2, rewrite.createCopy(arg1));
				{
					String[] arg= new String[] { String.valueOf(idx1 + 1), String.valueOf(idx2 + 1) };
					String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swaparguments.description", arg); 
					Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
					ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image);
					proposal.ensureNoModifications();
					proposals.add(proposal);					
				}
				
				if (declaringType.isFromSource()) {
					ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType);
					if (targetCU != null) {
						ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length];
						for (int i= 0; i < nDiffs; i++) {
							changeDesc[idx1]= new SwapDescription(idx2);
						}
						ITypeBinding[] swappedTypes= new ITypeBinding[] { argTypes[idx1], paramTypes[idx2] };
						String[] args=  new String[] { getMethodSignature(methodBinding, !targetCU.equals(cu)), getTypeNames(swappedTypes) };