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/AbstractMethodCompletionProposal.java
newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
		}
		if (newTypeDecl != null) {
			ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
			
			MethodDeclaration newStub= getStub(rewrite, newTypeDecl);
			
			ChildListPropertyDescriptor property= fSenderBinding.isAnonymous() ? AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY : TypeDeclaration.BODY_DECLARATIONS_PROPERTY;
			List members= (List) newTypeDecl.getStructuralProperty(property);
			
			int insertIndex;
			if (isConstructor()) {
				insertIndex= findConstructorInsertIndex(members);
			} else if (!isInDifferentCU) {
				insertIndex= findMethodInsertIndex(members, fNode.getStartPosition());
			} else {
				insertIndex= members.size();
			}
			ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, property);
			listRewriter.insertAt(newStub, insertIndex, null);	
			
			return rewrite;
		}
		return null;
	}
		
	private MethodDeclaration getStub(ASTRewrite rewrite, ASTNode targetTypeDecl) throws CoreException {
		AST ast= targetTypeDecl.getAST();
		MethodDeclaration decl= ast.newMethodDeclaration();