Bug 62794 Stub on code assist: Should check if method name is valid Java id
20040518 - between two method, enter 'while' press code assist - proposal is to create method 'while' created method is of course invalid -> should check if method name is not a keyword
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/MethodCompletionProposal.java
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
public class MethodCompletionProposal extends JavaTypeCompletionProposal {
	
	
	public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set suggestedMethods, Collection result) throws CoreException {
		IMethod[] methods= type.getMethods();
		String constructorName= type.getElementName();
		if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) {
			result.add(new MethodCompletionProposal(type, constructorName, null, offset, length, relevance));
		}
		
		if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { 
			result.add(new MethodCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance));
		}
	}
	
	private static boolean hasMethod(IMethod[] methods, String name) {
		for (int i= 0; i < methods.length; i++) {
			IMethod curr= methods[i];
			if (curr.getElementName().equals(name) && curr.getParameterTypes().length == 0) {
				return true;
			}
		}
		return false;
	}
	
	private final IType fType;