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
private static void addSimilarVariableProposals(ICompilationUnit cu, CompilationUnit astRoot, SimpleName node, Collection proposals) {
		IBinding[] varsInScope= (new ScopeAnalyzer(astRoot)).getDeclarationsInScope(node, ScopeAnalyzer.VARIABLES);
		if (varsInScope.length > 0) {
			
			String assignedName= null;
			ASTNode parent= node.getParent();
			if (parent.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
				assignedName= ((VariableDeclarationFragment) parent).getName().getIdentifier();
			}			
			
			ITypeBinding guessedType= ASTResolving.guessBindingForReference(node);
			if (astRoot.getAST().resolveWellKnownType("java.lang.Object") == guessedType) { 
				guessedType= null; 
			}
			
			String identifier= node.getIdentifier();
			for (int i= 0; i < varsInScope.length; i++) {
				IVariableBinding curr= (IVariableBinding) varsInScope[i];
				String currName= curr.getName();
				if (!currName.equals(assignedName)) {
					int relevance= 0;
					if (NameMatcher.isSimilarName(currName, identifier)) {
						relevance += 3; 
					}
					if (guessedType != null && TypeRules.canAssign(guessedType, curr.getType())) {
						relevance += 2;  						
					}
					if (relevance > 0) {
						String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changevariable.description", currName); 
						proposals.add(new ReplaceCorrectionProposal(label, cu, node.getStartPosition(), node.getLength(), currName, relevance));