Example usage for org.eclipse.jdt.core JavaConventions validateMethodName

List of usage examples for org.eclipse.jdt.core JavaConventions validateMethodName

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaConventions validateMethodName.

Prototype

public static IStatus validateMethodName(String name, String sourceLevel, String complianceLevel) 

Source Link

Document

Validate the given method name for the given source and compliance levels.

Usage

From source file:com.google.gdt.eclipse.core.JavaUtilities.java

License:Open Source License

public static IStatus validateMethodName(String methodName) {
    String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance");
    String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source");
    IStatus nameStatus = JavaConventions.validateMethodName(methodName, sourceLevel, complianceLevel);

    if (!nameStatus.isOK()) {
        return nameStatus;
    }/*from w  w  w . j av  a 2  s  .  c  o m*/

    // The JavaConventions class doesn't seem to be flagging method names with
    // an uppercase first character, so we need to check it ourselves.
    if (!Character.isLowerCase(methodName.charAt(0))) {
        return StatusUtilities.newWarningStatus("Method name should start with a lowercase letter.",
                CorePlugin.PLUGIN_ID);
    }

    return StatusUtilities.OK_STATUS;
}

From source file:com.google.gwt.eclipse.core.util.Util.java

License:Open Source License

public static boolean isValidMethodName(String methodName) {
    String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance");
    String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source");

    return JavaConventions.validateMethodName(methodName, sourceLevel, complianceLevel).isOK();
}

From source file:com.sabre.buildergenerator.ui.wizard.TypeNameValidator.java

License:Open Source License

public IStatus validateMethodPrefix(String fieldName, String prefix, boolean canBeEmpty) {
    if (prefix.length() != 0) {
        String[] compliance = TypeNameValidator.getSourceComplianceLevels(project);
        IStatus val = JavaConventions.validateMethodName(prefix + "XXX", compliance[0], compliance[1]);

        if (val != null) {
            if (val.getSeverity() == IStatus.ERROR) {
                return errorCreator.createError(val.getMessage());
            } else if (val.getSeverity() == IStatus.WARNING) {
                return errorCreator.createWarning(val.getMessage());
            }/* ww  w  .ja v  a2 s . c o  m*/
        }
    } else if (!canBeEmpty) {
        return errorCreator.createError("Field " + fieldName + " can't be left empty");
    }

    return null;
}

From source file:es.bsc.servicess.ide.Checker.java

License:Apache License

/** Check if method name is correct
 * @param methodName Name of the method to be evaluated
 * @return Status.OK if name is correct and Status.ERROR if the name is not correct
 *//*from w  w w.  j a  va  2s  .co  m*/
public static IStatus validateMethodName(String methodName) {
    return JavaConventions.validateMethodName(methodName, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
}

From source file:org.bonitasoft.studio.businessobject.ui.wizard.validator.QueryNameCellEditorValidator.java

License:Open Source License

protected IStatus doValidate(Object value) {
    String name = null;//w w w .ja va2  s  .c  o  m
    if (value != null) {
        name = value.toString();
    }

    IStatus status = JavaConventions.validateMethodName(name, JavaCore.VERSION_1_6, JavaCore.VERSION_1_6);
    if (!status.isOK()) {
        return status;
    }
    status = new InputLengthValidator(name, MAX_QUERY_NAME_LENGTH).validate(name);
    if (!status.isOK()) {
        return status;
    }
    for (String queryName : BDMQueryUtil.getAllProvidedQueriesNameForBusinessObject(bo)) {
        if (name.equalsIgnoreCase(queryName)) {
            return ValidationStatus.error(Messages.bind(Messages.queryNameReserved, name));
        }
    }
    for (Query query : bo.getQueries()) {
        if (query.getName().equalsIgnoreCase(name) && !this.query.equals(query)) {
            return ValidationStatus.error(Messages.queryNameAlreadyExists);
        }
    }
    return ValidationStatus.ok();
}

From source file:org.ebayopensource.turmeric.eclipse.utils.plugin.JDTUtil.java

License:Open Source License

/**
 * Validate method name./*from w w  w.  j a  v  a2  s  .com*/
 *
 * @param methodName the method name
 * @return True if the method name is valid
 */
public static IStatus validateMethodName(String methodName) {
    return JavaConventions.validateMethodName(methodName, COMPILER_OPTIONS_VERSION_1_4,
            COMPILER_OPTIONS_VERSION_1_4);
}

From source file:org.jboss.tools.arquillian.ui.internal.wizards.NewArquillianJUnitTestCaseDeploymentPage.java

License:Open Source License

private IStatus validateMethodName(String name, IJavaElement context) {
    String[] sourceComplianceLevels = getSourceComplianceLevels(context);
    IStatus status = JavaConventions.validateMethodName(name, sourceComplianceLevels[0],
            sourceComplianceLevels[1]);//from  w ww  . jav a2  s  .  c  om
    if (status.isOK() && javaElement != null) {
        try {
            getTypeBinding();
            if (typeBinding != null) {
                IMethodBinding[] declaredMethods = typeBinding.getDeclaredMethods();
                for (int i = 0; i < declaredMethods.length; i++) {
                    if (declaredMethods[i].getName().equals(name)
                            && declaredMethods[i].getParameterTypes().length == 0) {
                        status = new Status(IStatus.ERROR, ArquillianUIActivator.PLUGIN_ID,
                                "The '" + name + "' method already exists.");
                    }
                }
            }
        } catch (JavaModelException e) {
            ArquillianUIActivator.log(e);
        }
    }
    return status;
}