Example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_3

List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_3

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_3.

Prototype

String VERSION_1_3

To view the source code for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_3.

Click Source Link

Usage

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

License:Open Source License

/**
 * Validate the given compilation unit name.
 * <p>//w w w. j a  v  a 2  s . c o  m
 * A compilation unit name must obey the following rules:
 * <ul>
 * <li> it must not be null
 * <li> it must be suffixed by a dot ('.') followed by one of the
 *       {@link org.eclipse.jdt.core.JavaCore#getJavaLikeExtensions() Java-like extensions}
 * <li> its prefix must be a valid identifier
 * <li> it must not contain any characters or substrings that are not valid
 *         on the file system on which workspace root is located.
 * </ul>
 * </p>
 * @param name the name of a compilation unit
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a compilation unit name, otherwise a status
 *      object indicating what is wrong with the name
 * @deprecated Use {@link #validateCompilationUnitName(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateCompilationUnitName(String name) {
    return validateCompilationUnitName(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given .class file name.//from  ww  w .  ja  v a 2 s. c  om
 * <p>
 * A .class file name must obey the following rules:
 * <ul>
 * <li> it must not be null
 * <li> it must include the <code>".class"</code> suffix
 * <li> its prefix must be a valid identifier
 * <li> it must not contain any characters or substrings that are not valid
 *         on the file system on which workspace root is located.
 * </ul>
 * </p>
 * @param name the name of a .class file
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a .class file name, otherwise a status
 *      object indicating what is wrong with the name
 * @since 2.0
 * @deprecated Use {@link #validateClassFileName(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateClassFileName(String name) {
    return validateClassFileName(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given field name./*from www. j  a va  2  s.c om*/
 * <p>
 * Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
 * For example, <code>"x"</code>.
 *
 * @param name the name of a field
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a field name, otherwise a status
 *      object indicating what is wrong with the name
 * @deprecated Use {@link #validateFieldName(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateFieldName(String name) {
    return validateIdentifier(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given Java identifier./*from  ww w  .j av  a  2  s . c om*/
 * The identifier must not have the same spelling as a Java keyword,
 * boolean literal (<code>"true"</code>, <code>"false"</code>), or null literal (<code>"null"</code>).
 * See section 3.8 of the <em>Java Language Specification, Second Edition</em> (JLS2).
 * A valid identifier can act as a simple type name, method name or field name.
 *
 * @param id the Java identifier
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given identifier is a valid Java identifier, otherwise a status
 *      object indicating what is wrong with the identifier
 * @deprecated Use {@link #validateIdentifier(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateIdentifier(String id) {
    return validateIdentifier(id, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given import declaration name.
 * <p>//w w w . java  2  s .c  o m
 * 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
 * @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
 * @deprecated Use {@link #validateImportDeclaration(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateImportDeclaration(String name) {
    return validateImportDeclaration(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given method name.//from w  w  w  .  j a va  2 s.com
 * The special names "&lt;init&gt;" and "&lt;clinit&gt;" are not valid.
 * <p>
 * The syntax for a method  name is defined by Identifier
 * of MethodDeclarator (JLS2 8.4). For example "println".
 *
 * @param name the name of a method
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a method name, otherwise a status
 *      object indicating what is wrong with the name
 * @deprecated Use {@link #validateMethodName(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateMethodName(String name) {
    return validateMethodName(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given package name./*  w w w .j a v a  2 s .  c o m*/
 * <p>
 * The syntax of a package name corresponds to PackageName as
 * defined by PackageDeclaration (JLS2 7.4). For example, <code>"java.lang"</code>.
 * <p>
 * Note that the given name must be a non-empty package name (that is, attempting to
 * validate the default package will return an error status.)
 * Also it must not contain any characters or substrings that are not valid
 * on the file system on which workspace root is located.
 *
 * @param name the name of a package
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a package name, otherwise a status
 *      object indicating what is wrong with the name
 * @deprecated Use {@link #validatePackageName(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validatePackageName(String name) {
    return validatePackageName(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

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

License:Open Source License

/**
 * Validate the given type variable name.
 * <p>/*from   w w w.j a v a2  s  .co m*/
 * Syntax of a type variable name corresponds to a Java identifier (JLS3 4.3).
 * For example, <code>"E"</code>.
 *
 * @param name the name of a type variable
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a type variable name, otherwise a status
 *      object indicating what is wrong with the name
 * @since 3.1
 * @deprecated Use {@link #validateTypeVariableName(String id, String sourceLevel, String complianceLevel)} instead
 */
public static IStatus validateTypeVariableName(String name) {
    return validateIdentifier(name, CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
}

From source file:com.xqbase.compiler.eclipse.EclipseJavaCompiler.java

License:Open Source License

private String decodeVersion(String versionSpec) {
    if (StringUtils.isEmpty(versionSpec)) {
        return null;
    } else if ("1.1".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_1;
    } else if ("1.2".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_2;
    } else if ("1.3".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_3;
    } else if ("1.4".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_4;
    } else if ("1.5".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_5;
    } else if ("1.6".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_6;
    } else if ("1.7".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_7;
    }//from  w w  w .  ja v a2s.  c om
    // added by xqbase-compiler-eclipse
    else if ("1.8".equals(versionSpec)) {
        return CompilerOptions.VERSION_1_8;
    } else {
        getLogger().warn(
                "Unknown version '" + versionSpec + "', no version setting will be given to the compiler.");

        return null;
    }
}

From source file:org.ant4eclipse.ant.jdt.ecj.CompilerOptionsProvider.java

License:Open Source License

/**
 * <p>/* w w w .j a  va 2  s.  co m*/
 * Returns the compiler options specified in the javac task.
 * </p>
 * 
 * @param javac
 *          the javac task
 * @return the compiler options specified in the javac task.
 */
@SuppressWarnings("unchecked")
private static final StringMap getJavacCompilerOptions(Javac javac) {

    StringMap result = new StringMap();

    /*
     * set the source option
     */
    if (Utilities.hasText(javac.getSource())) {

        // get the source
        String source = javac.getSource();
        // set the source
        if (source.equals("1.3")) {
            result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
        } else if (source.equals("1.4")) {
            result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
        } else if (source.equals("1.5") || source.equals("5") || source.equals("5.0")) {
            result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
        } else if (source.equals("1.6") || source.equals("6") || source.equals("6.0")) {
            result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
        } else if (source.equals("1.7") || source.equals("7") || source.equals("7.0")) {
            result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
        } else if (source.equals("1.8") || source.equals("8") || source.equals("8.0")) {
            result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
        } else {
            throw new Ant4EclipseException(EcjExceptionCodes.UNKNOWN_JAVA_SOURCE_OPTION_EXCEPTION, source);
        }
    }

    /*
     * set the target option
     */
    if (Utilities.hasText(javac.getTarget())) {

        // get the target
        String target = javac.getTarget();

        // set the target
        if (target.equals("1.3")) {
            result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3);
            result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3);
        } else if (target.equals("1.4")) {
            result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
            result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
        } else if (target.equals("1.5") || target.equals("5") || target.equals("5.0")) {
            result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
            result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
        } else if (target.equals("1.6") || target.equals("6") || target.equals("6.0")) {
            result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
            result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
        } else if (target.equals("1.7") || target.equals("7") || target.equals("7.0")) {
            result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
            result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7);
        } else if (target.equals("1.8") || target.equals("8") || target.equals("8.0")) {
            result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
            result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
        } else {
            throw new Ant4EclipseException(EcjExceptionCodes.UNKNOWN_JAVA_TARGET_OPTION_EXCEPTION, target);
        }
    }

    /*
     * set the debug options
     */
    if (javac.getDebug()) {

        String debugLevel = javac.getDebugLevel();

        if (debugLevel != null) {
            result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
            result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
            result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE);
            if (debugLevel.length() != 0) {
                if (debugLevel.indexOf("vars") != -1) {
                    result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
                }
                if (debugLevel.indexOf("lines") != -1) {
                    result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
                }
                if (debugLevel.indexOf("source") != -1) {
                    result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
                }
            }
        } else {
            result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
            result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
            result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
        }
    } else {
        result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
        result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
        result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE);
    }

    /*
     * Handle the nowarn option. If none, then we generate all warnings.
     */
    if (javac.getNowarn()) {
        // disable all warnings
        Map.Entry<String, String>[] entries = result.entrySet().toArray(new Map.Entry[result.size()]);
        for (Entry<String, String> entrie : entries) {
            Map.Entry<String, String> entry = entrie;
            if (entry.getValue().equals(CompilerOptions.WARNING)) {
                result.put(entry.getKey(), CompilerOptions.IGNORE);
            }
        }
        result.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING);
        if (javac.getDeprecation()) {
            result.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
            result.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED);
            result.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
                    CompilerOptions.ENABLED);
        }
    } else if (javac.getDeprecation()) {
        result.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
        result.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED);
        result.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
                CompilerOptions.ENABLED);
    } else {
        result.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
        result.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED);
        result.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
                CompilerOptions.DISABLED);
    }

    /*
     * set the encoding option
     */
    if (javac.getEncoding() != null) {
        result.put(CompilerOptions.OPTION_Encoding, javac.getEncoding());
    }

    // return result
    return result;
}