ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot()); while (selectedNode instanceof QualifiedName) { selectedNode= ((QualifiedName) selectedNode).getQualifier();
IFix fix= CodeStyleFix.createFix(context.getASTRoot(), problem, true, false); if (fix != null) { Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new CodeStyleMultiFix(true, false), 5, image); proposal.setCommandId(ADD_FIELD_QUALIFICATION_ID); proposals.add(proposal);
	public static void addUnqualifiedFieldAccessProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {		ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());		while (selectedNode instanceof QualifiedName) {			selectedNode= ((QualifiedName) selectedNode).getQualifier();		}		if (!(selectedNode instanceof SimpleName)) {			return;		}		SimpleName name = (SimpleName) selectedNode;		IBinding binding= name.resolveBinding();		if (binding.getKind() != IBinding.VARIABLE) {			return;		}		ASTRewrite rewrite= ASTRewrite.create(name.getAST());		ImportRewrite imports= new ImportRewrite(context.getCompilationUnit());		ITypeBinding declaringClass= ((IVariableBinding) binding).getDeclaringClass();		String qualifier;		if (Modifier.isStatic(binding.getModifiers())) {			qualifier= imports.addImport(declaringClass);		} else {			ITypeBinding parentType= Bindings.getBindingOfParentType(name);			ITypeBinding currType= parentType;			while (currType != null && !Bindings.isSuperType(declaringClass, currType)) {				currType= currType.getDeclaringClass();			}			if (currType != parentType) {				String outer= imports.addImport(currType);				qualifier= outer + ".this"; //$NON-NLS-1$			} else {				qualifier= "this"; //$NON-NLS-1$			}		}		String replacement= qualifier + '.' + name.getIdentifier();		rewrite.replace(name, rewrite.createStringPlaceholder(replacement, ASTNode.SIMPLE_NAME), null);		String label= Messages.format(CorrectionMessages.LocalCorrectionsSubProcessor_unqualifiedfieldaccess_description, qualifier);		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);		ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image); 		proposal.setImportRewrite(imports);		proposal.setCommandId(ADD_FIELD_QUALIFICATION_ID);		proposals.add(proposal);	}