String[] args= problem.getProblemArguments(); if (selectedNode instanceof QualifiedName && args.length == 2) { String field= args[1]; QualifiedName qualified= (QualifiedName) selectedNode; while (!field.equals(qualified.getName().getIdentifier()) && qualified.getQualifier() instanceof QualifiedName) { qualified= (QualifiedName) qualified.getQualifier(); } selectedNode= qualified; problem= new ProblemLocation(qualified.getStartPosition(), qualified.getLength(), problem.getProblemId(), args, problem.isError()); }
	public static void addCorrectAccessToStaticProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {		ICompilationUnit cu= context.getCompilationUnit();		CompilationUnit astRoot= context.getASTRoot();		ASTNode selectedNode= problem.getCoveringNode(astRoot);		if (selectedNode == null) {			return;		}		// fix for 32022		String[] args= problem.getProblemArguments();		if (selectedNode instanceof QualifiedName && args.length == 2) {			String field= args[1];			QualifiedName qualified= (QualifiedName) selectedNode;			while (!field.equals(qualified.getName().getIdentifier()) && qualified.getQualifier() instanceof QualifiedName) {				qualified= (QualifiedName) qualified.getQualifier();			}			selectedNode= qualified;			problem= new ProblemLocation(qualified.getStartPosition(), qualified.getLength(), problem.getProblemId(), args, problem.isError());		}		Expression qualifier= null;		IBinding accessBinding= null;        if (selectedNode instanceof QualifiedName) {        	QualifiedName name= (QualifiedName) selectedNode;        	qualifier= name.getQualifier();        	accessBinding= name.resolveBinding();        } else if (selectedNode instanceof SimpleName) {        	ASTNode parent= selectedNode.getParent();        	if (parent instanceof FieldAccess) {        		FieldAccess fieldAccess= (FieldAccess) parent;        		qualifier= fieldAccess.getExpression();        		accessBinding= fieldAccess.getName().resolveBinding();        	}        } else if (selectedNode instanceof MethodInvocation) {        	MethodInvocation methodInvocation= (MethodInvocation) selectedNode;        	qualifier= methodInvocation.getExpression();        	accessBinding= methodInvocation.getName().resolveBinding();        } else if (selectedNode instanceof FieldAccess) {			FieldAccess fieldAccess= (FieldAccess) selectedNode;			qualifier= fieldAccess.getExpression();			accessBinding= fieldAccess.getName().resolveBinding();		}		if (problem.getProblemId() == IProblem.IndirectAccessToStaticField || problem.getProblemId() == IProblem.IndirectAccessToStaticMethod) {			// indirectAccessToStaticProposal			if (accessBinding != null) {				ITypeBinding declaringTypeBinding= getDeclaringTypeBinding(accessBinding);				if (declaringTypeBinding != null) {					declaringTypeBinding= declaringTypeBinding.getTypeDeclaration(); // use generic to avoid any type arguments					ASTRewrite rewrite= ASTRewrite.create(selectedNode.getAST());					ImportRewrite imports= new ImportRewrite(cu);					String typeName= imports.addImport(declaringTypeBinding);					rewrite.replace(qualifier, ASTNodeFactory.newName(astRoot.getAST(), typeName), null);					String label= Messages.format(CorrectionMessages.LocalCorrectionsSubProcessor_indirectaccesstostatic_description, declaringTypeBinding.getName());					Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);					ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 6, image);					proposal.setImportRewrite(imports);					proposal.setCommandId(ADD_STATIC_ACCESS_ID);					proposals.add(proposal);				}			}			return;		}		ITypeBinding declaringTypeBinding= null;		if (accessBinding != null) {			declaringTypeBinding= getDeclaringTypeBinding(accessBinding);			if (declaringTypeBinding != null) {				declaringTypeBinding= declaringTypeBinding.getTypeDeclaration(); // use generic to avoid any type arguments				ASTRewrite rewrite= ASTRewrite.create(selectedNode.getAST());				ImportRewrite imports= new ImportRewrite(cu);				String label= Messages.format(CorrectionMessages.LocalCorrectionsSubProcessor_changeaccesstostaticdefining_description, declaringTypeBinding.getName());				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 6, image);				proposal.setImportRewrite(imports);				proposal.setCommandId(ADD_STATIC_ACCESS_ID);				String typeName= imports.addImport(declaringTypeBinding);				rewrite.replace(qualifier, ASTNodeFactory.newName(astRoot.getAST(), typeName), null);				proposals.add(proposal);			}		}		if (qualifier != null) {			ITypeBinding instanceTypeBinding= Bindings.normalizeTypeBinding(qualifier.resolveTypeBinding());			if (instanceTypeBinding != null) {				instanceTypeBinding= instanceTypeBinding.getTypeDeclaration();  // use generic to avoid any type arguments				if (instanceTypeBinding.getTypeDeclaration() != declaringTypeBinding) {					ASTRewrite rewrite= ASTRewrite.create(selectedNode.getAST());					ImportRewrite imports= new ImportRewrite(cu);					String label= Messages.format(CorrectionMessages.LocalCorrectionsSubProcessor_changeaccesstostatic_description, instanceTypeBinding.getName());					Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);					ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 5, image);					proposal.setImportRewrite(imports);					String typeName= imports.addImport(instanceTypeBinding);					rewrite.replace(qualifier, ASTNodeFactory.newName(astRoot.getAST(), typeName), null);					proposals.add(proposal);				}			}		}		ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_STATIC, 4);	}