Example usage for org.eclipse.jdt.internal.core.util Messages convention_import_unqualifiedImport

List of usage examples for org.eclipse.jdt.internal.core.util Messages convention_import_unqualifiedImport

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Messages convention_import_unqualifiedImport.

Prototype

String convention_import_unqualifiedImport

To view the source code for org.eclipse.jdt.internal.core.util Messages convention_import_unqualifiedImport.

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.core.JavaConventions.java

License:Open Source License

/**
 * Validate the given import declaration name for the given source and compliance levels.
 * <p>/*from ww w .  ja v  a 2 s  . com*/
 * The name of an import corresponds to a fully qualified type name
 * or an on-demand package name as defined by ImportDeclaration (JLS2 7.5).
 * For example, <code>"java.util.*"</code> or <code>"java.util.Hashtable"</code>.
 *
 * @param name the import declaration
 * @param sourceLevel the source level
 * @param complianceLevel the compliance level
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as an import declaration, otherwise a status
 *      object indicating what is wrong with the name
 * @since 3.3
 */
public static IStatus validateImportDeclaration(String name, String sourceLevel, String complianceLevel) {
    if (name == null || name.length() == 0) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1,
                Messages.convention_import_nullImport, null);
    }
    if (name.charAt(name.length() - 1) == '*') {
        if (name.charAt(name.length() - 2) == '.') {
            return validatePackageName(name.substring(0, name.length() - 2), sourceLevel, complianceLevel);
        } else {
            return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1,
                    Messages.convention_import_unqualifiedImport, null);
        }
    }
    return validatePackageName(name, sourceLevel, complianceLevel);
}