Bug 51076 Quick fix misses and presents wrong name for target field class
Observe this example: public class Test { class Foo { void foo() { x = 4; } } void foo() { bar(new Runnable() { public void run() { x = 5; } }); } void bar(Runnable runner) { } } Quick-fix markers are activated for "x = 4" and "x = 5". For "x = 4", there is no suggestion to add a field to 'Test'. For "x = 5", there is a suggestion to add a field to ''. This should be 'Test'
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
if (cu.equals(targetCU)) {
					label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.description", sig); 
					image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE);
				} else {
					label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.other.description", new Object[] { sig, targetCU.getElementName() } ); 
					image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
				}
				proposals.add(new NewMethodCompletionProposal(label, targetCU, invocationNode, arguments, binding, 5, image));
				
				if (binding.isAnonymous() && cu.equals(targetCU) && sender == null && Bindings.findMethodInHierarchy(binding, methodName, null) == null) { 
					ASTNode anonymDecl= astRoot.findDeclaringNode(binding);
					if (anonymDecl != null) {
						binding= Bindings.getBindingOfParentType(anonymDecl.getParent());
						if (!binding.isAnonymous()) {
							String[] args= new String[] { sig, binding.getName() };
							label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.other.description", args); 
							image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PROTECTED);
							proposals.add(new NewMethodCompletionProposal(label, targetCU, invocationNode, arguments, binding, 5, image));
						}
					}
				}
			}
		}
		
		if (!isSuperInvocation) {
			ASTNode parent= invocationNode.getParent();
			while (parent instanceof Expression && parent.getNodeType() != ASTNode.CAST_EXPRESSION) {
				parent= parent.getParent();
			}