declaration= ASTResolving.findParentBodyDeclaration(declaration.getParent());
if (!Modifier.isStatic(declaration.getModifiers())) { declaration= ASTResolving.findParentBodyDeclaration(declaration.getParent()); } else { declaration= null; }
	private static void addNewTypeProposals(ICompilationUnit cu, Name refNode, int kind, int relevance, Collection proposals) throws JavaModelException {		Name node= refNode;		do {			String typeName= ASTNodes.getSimpleNameIdentifier(node);			Name qualifier= null;			// only propose to create types for qualifiers when the name starts with upper case			boolean isPossibleName= isLikelyTypeName(typeName) || (node == refNode);			if (isPossibleName) {				IPackageFragment enclosingPackage= null;				IType enclosingType= null;				if (node.isSimpleName()) {					enclosingPackage= (IPackageFragment) cu.getParent();					// don't suggest member type, user can select it in wizard				} else {					Name qualifierName= ((QualifiedName) node).getQualifier();					 IBinding binding= qualifierName.resolveBinding();					 if (binding instanceof ITypeBinding) {						enclosingType=(IType) binding.getJavaElement();					 } else if (binding instanceof IPackageBinding) {						qualifier= qualifierName;					 	enclosingPackage= (IPackageFragment) binding.getJavaElement();					 } else {					 	IJavaElement[] res= cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength());						if (res!= null && res.length > 0 && res[0] instanceof IType) {							enclosingType= (IType) res[0];						} else {							qualifier= qualifierName;							enclosingPackage= JavaModelUtil.getPackageFragmentRoot(cu).getPackageFragment(ASTResolving.getFullName(qualifierName));						}					 }				}				int rel= relevance;				if (enclosingPackage != null && isLikelyPackageName(enclosingPackage.getElementName())) {					rel += 3;				}				if ((enclosingPackage != null && !enclosingPackage.getCompilationUnit(typeName + ".java").exists()) // new top level type //$NON-NLS-1$						|| (enclosingType != null && !enclosingType.isReadOnly() && !enclosingType.getType(typeName).exists())) { // new member type					IJavaElement enclosing= enclosingPackage != null ? (IJavaElement) enclosingPackage : enclosingType;					if ((kind & SimilarElementsRequestor.CLASSES) != 0) {			            proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, NewCUCompletionUsingWizardProposal.K_CLASS, enclosing, rel+2));					}					if ((kind & SimilarElementsRequestor.INTERFACES) != 0) {			            proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, NewCUCompletionUsingWizardProposal.K_INTERFACE, enclosing, rel+1));					}					if ((kind & SimilarElementsRequestor.ENUMS) != 0) {			            proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, NewCUCompletionUsingWizardProposal.K_ENUM, enclosing, rel));					}					if (kind == SimilarElementsRequestor.ANNOTATIONS) { // only when in annotation			            proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, NewCUCompletionUsingWizardProposal.K_ANNOTATION, enclosing, rel+4));					}				}			}			node= qualifier;		} while (node != null);		// type parameter proposals		if (refNode.isSimpleName() && ((kind & SimilarElementsRequestor.VARIABLES)  != 0)) {			CompilationUnit root= (CompilationUnit) refNode.getRoot();			String name= ((SimpleName) refNode).getIdentifier();			BodyDeclaration declaration= ASTResolving.findParentBodyDeclaration(refNode);			int baseRel= relevance;			if (isLikelyTypeParameterName(name)) {				baseRel += 4;			}			while (declaration != null) {				IBinding binding= null;				int rel= baseRel;				if (declaration instanceof MethodDeclaration) {					binding= ((MethodDeclaration) declaration).resolveBinding();				} else if (declaration instanceof TypeDeclaration) {					binding= ((TypeDeclaration) declaration).resolveBinding();					rel++;				}				if (binding != null) {					AddTypeParameterProposal proposal= new AddTypeParameterProposal(cu, binding, root, name, null, rel);					proposals.add(proposal);				}				declaration= ASTResolving.findParentBodyDeclaration(declaration.getParent());			}		}	}