Bug 79806 "Create field" QuickFix in Enum constructor throws "Node does not have this property"
I20041130-0800: "Create field" QuickFix in Enum constructor throws "Node does not have this property". package p; enum A { ONE(1); public A(int num) { fNum= num; // Ctrl+1 here } } Error Nov 30, 2004 20:07:01.837 Node does not have this property java.lang.RuntimeException: Node does not have this property at org.eclipse.jdt.core.dom.ASTNode.internalGetChildListProperty(ASTNode.java:1667) at org.eclipse.jdt.core.dom.EnumDeclaration.internalGetChildListProperty(EnumDeclaration.java:204) at org.eclipse.jdt.core.dom.ASTNode.getStructuralProperty(ASTNode.java:1514) at org.eclipse.jdt.internal.ui.text.correction.NewVariableCompletionProposal.doAddField(NewVariableCompletionProposal.java:320) at org.eclipse.jdt.internal.ui.text.correction.NewVariableCompletionProposal.getRewrite(NewVariableCompletionProposal.java:65) at org.eclipse.jdt.internal.ui.text.correction.ASTRewriteCorrectionProposal.addEdits(ASTRewriteCorrectionProposal.java:61) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.initializeTextChange(CUCorrectionProposal.java:135) at org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal.getAdditionalProposalInfo(CUCorrectionProposal.java:181) at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:221) at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:761) at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:751) at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:173) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2780) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2451) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1579) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:282) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:710) at org.eclipse.core.launcher.Main.main(Main.java:694)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AssignToVariableAssistProposal.java
addLinkedPosition(rewrite.track(newDeclFrag.getName()), false, KEY_NAME);
		addLinkedPosition(rewrite.track(newDecl.getType()), false, KEY_TYPE);
		addLinkedPosition(rewrite.track(accessName), true, KEY_NAME);
		setEndPosition(rewrite.track(selectionNode));
		
		return rewrite;		
	}
	private Type evaluateType(AST ast) throws CoreException {
		ITypeBinding[] proposals= ASTResolving.getRelaxingTypes(ast, fTypeBinding);
		for (int i= 0; i < proposals.length; i++) {
			addLinkedPositionProposal(KEY_TYPE, proposals[i]);
		}
		return getImportRewrite().addImport(fTypeBinding, ast);
	}
	
	private String[] suggestLocalVariableNames(ITypeBinding binding, Expression expression) {
		ArrayList res= new ArrayList();
		
		IJavaProject project= getCompilationUnit().getJavaProject();
		ITypeBinding base= binding.isArray() ? binding.getElementType() : binding;
		IPackageBinding packBinding= base.getPackage();
		String packName= packBinding != null ? packBinding.getName() : ""; 
		
		String[] excludedNames= getUsedVariableNames();
		
		String name= ASTResolving.getBaseNameFromExpression(project, expression);
		if (name != null) {
			String[] argname= StubUtility.getLocalNameSuggestions(project, name, 0, excludedNames); 
			for (int i= 0; i < argname.length; i++) {