Uploaded image for project: 'CCC Migration Project'
  1. CCC Migration Project
  2. CCC-6415644

Make javax.lang.model.SourceVersion more informative

    Details

    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Add version-sensitive isName and isKeyword methods to SourceVersion.

      Problem

      The javax.lang.model.SourceVersion enum doesn't expose much information that varies by release, such as the set of keywords.

      Solution

      Add new methods for isName and isKeyword which are version-aware.

      Specification

      +    /**
      +     * Returns whether or not {@code name} is a syntactically valid
      +     * qualified name in the given source version.  Unlike {@link
      +     * #isIdentifier isIdentifier}, this method returns {@code false}
      +     * for keywords and literals.
      +     *
      +     * @param name the string to check
      +     * @param version the version to use
      +     * @return {@code true} if this string is a
      +     * syntactically valid name, {@code false} otherwise.
      +     * @jls 6.2 Names and Identifiers
      +     * @since 9
      +     */
      +    public static boolean isName(CharSequence name, SourceVersion version)
      
      +
      +    /**
      +     * Returns whether or not {@code s} is a keyword or literal in the
      +     * given source version.
      +     *
      +     * @param s the string to check
      +     * @param version the version to use
      +     * @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
      +     * @since 9
      +     */
      +    public static boolean isKeyword(CharSequence s, SourceVersion version

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                darcy Joe Darcy
                Reviewed By:
                Jonathan Gibbons
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: