if (!(selectedNode instanceof SimpleName)) {
SimpleName node= null; if (selectedNode instanceof SimpleName) { node= (SimpleName) selectedNode; } else if (selectedNode instanceof QualifiedName) { QualifiedName qualifierName= (QualifiedName) selectedNode; Name qualifier= qualifierName.getQualifier(); if (qualifier instanceof SimpleName) { SimpleName simpleQualifier= (SimpleName) qualifier; Position pos= new Position(simpleQualifier.getStartPosition(), simpleQualifier.getLength()); ProblemPosition updatedProb= new ProblemPosition(pos, problemPos.getAnnotation(), problemPos.getCompilationUnit()); getTypeProposals(updatedProb, SimilarElementsRequestor.REF_TYPES, proposals); } } else if (selectedNode instanceof FieldAccess) { FieldAccess access= (FieldAccess) selectedNode; Expression expression= access.getExpression(); if (expression == null || expression instanceof ThisExpression) { node= access.getName(); } } if (node == null) {
	public static void getVariableProposals(ProblemPosition problemPos, ArrayList proposals) throws CoreException {				ICompilationUnit cu= problemPos.getCompilationUnit();				CompilationUnit astRoot= AST.parseCompilationUnit(cu, true);		ASTNode selectedNode= ASTResolving.findSelectedNode(astRoot, problemPos.getOffset(), problemPos.getLength());				if (!(selectedNode instanceof SimpleName)) {			return;		}		SimpleName node= (SimpleName) selectedNode;		// corrections		SimilarElement[] elements= SimilarElementsRequestor.findSimilarElement(cu, node, SimilarElementsRequestor.VARIABLES);		for (int i= 0; i < elements.length; i++) {			SimilarElement curr= elements[i];			String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changevariable.description", curr.getName()); //$NON-NLS-1$			proposals.add(new ReplaceCorrectionProposal(label, problemPos, curr.getName(), 3));		}				// new field		IJavaElement elem= cu.getElementAt(problemPos.getOffset());		if (elem instanceof IMember) {			String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.description", node.getIdentifier()); //$NON-NLS-1$			proposals.add(new NewVariableCompletionProposal(label, NewVariableCompletionProposal.FIELD, node, (IMember) elem, 2));		}		if (elem instanceof IMethod) {			String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createlocal.description", node.getIdentifier()); //$NON-NLS-1$			proposals.add(new NewVariableCompletionProposal(label, NewVariableCompletionProposal.LOCAL, node, (IMember) elem, 1));					label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createparameter.description", node.getIdentifier()); //$NON-NLS-1$			proposals.add(new NewVariableCompletionProposal(label, NewVariableCompletionProposal.PARAM, node, (IMember) elem, 1));		}							if (node.getParent().getNodeType() == ASTNode.METHOD_INVOCATION) {			MethodInvocation invocation= (MethodInvocation) node.getParent();			if (node.equals(invocation.getExpression())) {				getTypeProposals(problemPos, SimilarElementsRequestor.REF_TYPES, proposals);			}		}	}