public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set<String> suggestedMethods, Collection<IJavaCompletionProposal> result) throws CoreException { IMethod[] methods= type.getMethods(); if (!type.isInterface()) { String constructorName= type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) { result.add(new MethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500)); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) result.add(new MethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance)); } }
public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set<String> suggestedMethods, Collection<IJavaCompletionProposal> result) throws CoreException { IMethod[] methods= type.getMethods(); if (!type.isInterface()) { String constructorName= type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) { result.add(new MethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500)); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) result.add(new MethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance)); } }
/** * Checks if the given name is a valid Java method name. * * @param name the java method name. * @param context an {@link IJavaElement} or <code>null</code> * @return a refactoring status containing the error message if the * name is not a valid java method name. */ public static RefactoringStatus checkMethodName(String name, IJavaElement context) { RefactoringStatus status= checkName(name, JavaConventionsUtil.validateMethodName(name, context)); if (status.isOK() && !startsWithLowerCase(name)) return RefactoringStatus.createWarningStatus(RefactoringCoreMessages.Checks_method_names_lowercase); else return status; }
/** * Checks if the given name is a valid Java method name. * * @param name the java method name. * @param context an {@link IJavaElement} or <code>null</code> * @return a refactoring status containing the error message if the * name is not a valid java method name. */ public static RefactoringStatus checkMethodName(String name, IJavaElement context) { RefactoringStatus status= checkName(name, JavaConventionsUtil.validateMethodName(name, context)); if (status.isOK() && !startsWithLowerCase(name)) return RefactoringStatus.createWarningStatus(RefactoringCoreMessages.Checks_method_names_lowercase); else return status; }
public static ProcessableMethodDeclarationCompletionProposal newProposal(CompletionProposal proposal, IType type, int relevance) throws CoreException { String prefix = String.valueOf(proposal.getName()); int offset = proposal.getReplaceStart(); int length = proposal.getReplaceEnd() - offset; IMethod[] methods = type.getMethods(); if (!type.isInterface()) { String constructorName = type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName)) { return new ProcessableMethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix)) { if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) return new ProcessableMethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance); } return null; }
@Override public final RefactoringStatus checkNewElementName(String newName) { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ RefactoringStatus status= Checks.checkName(newName, JavaConventionsUtil.validateMethodName(newName, fMethod)); if (status.isOK() && !Checks.startsWithLowerCase(newName)) status= RefactoringStatus.createWarningStatus(fIsComposite ? Messages.format(RefactoringCoreMessages.Checks_method_names_lowercase2, new String[] { BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel()}) : RefactoringCoreMessages.Checks_method_names_lowercase); if (Checks.isAlreadyNamed(fMethod, newName)) status.addFatalError(fIsComposite ? Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_same_name2, new String[] { BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel() } ) : RefactoringCoreMessages.RenameMethodRefactoring_same_name, JavaStatusContext.create(fMethod)); return status; } private String getDeclaringTypeLabel() {
@Override public final RefactoringStatus checkNewElementName(String newName) { Assert.isNotNull(newName, "new name"); //$NON-NLS-1$ RefactoringStatus status= Checks.checkName(newName, JavaConventionsUtil.validateMethodName(newName, fMethod)); if (status.isOK() && !Checks.startsWithLowerCase(newName)) status= RefactoringStatus.createWarningStatus(fIsComposite ? Messages.format(RefactoringCoreMessages.Checks_method_names_lowercase2, new String[] { BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel()}) : RefactoringCoreMessages.Checks_method_names_lowercase); if (Checks.isAlreadyNamed(fMethod, newName)) status.addFatalError(fIsComposite ? Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_same_name2, new String[] { BasicElementLabels.getJavaElementName(newName), getDeclaringTypeLabel() } ) : RefactoringCoreMessages.RenameMethodRefactoring_same_name, JavaStatusContext.create(fMethod)); return status; } private String getDeclaringTypeLabel() {