### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/ToolFactory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java,v retrieving revision 1.81 diff -u -r1.81 ToolFactory.java --- model/org/eclipse/jdt/core/ToolFactory.java 21 Apr 2010 13:06:32 -0000 1.81 +++ model/org/eclipse/jdt/core/ToolFactory.java 21 Apr 2010 18:11:55 -0000 @@ -21,6 +21,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.*; import org.eclipse.jdt.core.compiler.IScanner; +import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.core.formatter.CodeFormatter; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; @@ -377,26 +378,38 @@ * * * - *
- * The returned scanner will tolerate unterminated line comments (missing line separator). It can be made stricter
- * by using API with extra boolean parameter (strictCommentMode
).
- *
+ *
By default the compliance used to create the scanner is the workspace's compliance when running inside the IDE + * or 1.4 if running from outside of a headless eclipse. + *
+ * * @param tokenizeComments if set tofalse
, comments will be silently consumed
* @param tokenizeWhiteSpace if set to false
, white spaces will be silently consumed,
* @param assertMode if set to false
, occurrences of 'assert' will be reported as identifiers
- * (ITerminalSymbols#TokenNameIdentifier
), whereas if set to true
, it
- * would report assert keywords (ITerminalSymbols#TokenNameassert
). Java 1.4 has introduced
+ * ({@link ITerminalSymbols#TokenNameIdentifier}), whereas if set to true
, it
+ * would report assert keywords ({@link ITerminalSymbols#TokenNameassert}). Java 1.4 has introduced
* a new 'assert' keyword.
* @param recordLineSeparator if set to true
, the scanner will record positions of encountered line
* separator ends. In case of multi-character line separators, the last character position is considered. These positions
- * can then be extracted using IScanner#getLineEnds
. Only non-unicode escape sequences are
+ * can then be extracted using {@link IScanner#getLineEnds()}. Only non-unicode escape sequences are
* considered as valid line separators.
* @return a scanner
* @see org.eclipse.jdt.core.compiler.IScanner
+ * @see #createScanner(boolean, boolean, boolean, String, String)
*/
public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator){
-
- PublicScanner scanner = new PublicScanner(tokenizeComments, tokenizeWhiteSpace, false/*nls*/, assertMode ? ClassFileConstants.JDK1_4 : ClassFileConstants.JDK1_3/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
+ // use default workspace compliance
+ long complianceLevelValue = CompilerOptions.versionToJdkLevel(JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE));
+ if (complianceLevelValue == 0) complianceLevelValue = ClassFileConstants.JDK1_4; // fault-tolerance
+ PublicScanner scanner =
+ new PublicScanner(
+ tokenizeComments,
+ tokenizeWhiteSpace,
+ false/*nls*/,
+ assertMode ? ClassFileConstants.JDK1_4 : ClassFileConstants.JDK1_3/*sourceLevel*/,
+ complianceLevelValue,
+ null/*taskTags*/,
+ null/*taskPriorities*/,
+ true/*taskCaseSensitive*/);
scanner.recordLineSeparator = recordLineSeparator;
return scanner;
}
@@ -418,29 +431,41 @@
*
*
*
- *
- * The returned scanner will tolerate unterminated line comments (missing line separator). It can be made stricter
- * by using API with extra boolean parameter (strictCommentMode
).
- *
+ *
By default the compliance used to create the scanner is the workspace's compliance when running inside the IDE + * or 1.4 if running from outside of a headless eclipse. + *
+ * * @param tokenizeComments if set tofalse
, comments will be silently consumed
* @param tokenizeWhiteSpace if set to false
, white spaces will be silently consumed,
* @param recordLineSeparator if set to true
, the scanner will record positions of encountered line
* separator ends. In case of multi-character line separators, the last character position is considered. These positions
- * can then be extracted using IScanner#getLineEnds
. Only non-unicode escape sequences are
+ * can then be extracted using {@link IScanner#getLineEnds()}. Only non-unicode escape sequences are
* considered as valid line separators.
* @param sourceLevel if set to "1.3"
or null
, occurrences of 'assert' will be reported as identifiers
- * (ITerminalSymbols#TokenNameIdentifier
), whereas if set to "1.4"
, it
- * would report assert keywords (ITerminalSymbols#TokenNameassert
). Java 1.4 has introduced
+ * ({@link ITerminalSymbols#TokenNameIdentifier}), whereas if set to "1.4"
, it
+ * would report assert keywords ({@link ITerminalSymbols#TokenNameassert}). Java 1.4 has introduced
* a new 'assert' keyword.
- * @return a scanner
+ * @return a scanner
* @see org.eclipse.jdt.core.compiler.IScanner
- * @since 3.0
+ * @see #createScanner(boolean, boolean, boolean, String, String)
+ * @since 3.0
*/
public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator, String sourceLevel) {
- PublicScanner scanner = null;
- long level = CompilerOptions.versionToJdkLevel(sourceLevel);
- if (level == 0) level = ClassFileConstants.JDK1_3; // fault-tolerance
- scanner = new PublicScanner(tokenizeComments, tokenizeWhiteSpace, false/*nls*/,level /*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
+ // use default workspace compliance
+ long complianceLevelValue = CompilerOptions.versionToJdkLevel(JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE));
+ if (complianceLevelValue == 0) complianceLevelValue = ClassFileConstants.JDK1_4; // fault-tolerance
+ long sourceLevelValue = CompilerOptions.versionToJdkLevel(sourceLevel);
+ if (sourceLevelValue == 0) sourceLevelValue = ClassFileConstants.JDK1_3; // fault-tolerance
+ PublicScanner scanner =
+ new PublicScanner(
+ tokenizeComments,
+ tokenizeWhiteSpace,
+ false/*nls*/,
+ sourceLevelValue /*sourceLevel*/,
+ complianceLevelValue,
+ null/*taskTags*/,
+ null/*taskPriorities*/,
+ true/*taskCaseSensitive*/);
scanner.recordLineSeparator = recordLineSeparator;
return scanner;
}
@@ -462,33 +487,29 @@
*
*
*
- *
- * The returned scanner will tolerate unterminated line comments (missing line separator). It can be made stricter
- * by using API with extra boolean parameter (strictCommentMode
).
- *
* @param tokenizeComments if set to false
, comments will be silently consumed
* @param tokenizeWhiteSpace if set to false
, white spaces will be silently consumed,
* @param recordLineSeparator if set to true
, the scanner will record positions of encountered line
* separator ends. In case of multi-character line separators, the last character position is considered. These positions
- * can then be extracted using IScanner#getLineEnds
. Only non-unicode escape sequences are
+ * can then be extracted using {@link IScanner#getLineEnds()}. Only non-unicode escape sequences are
* considered as valid line separators.
* @param sourceLevel if set to "1.3"
or null
, occurrences of 'assert' will be reported as identifiers
- * (ITerminalSymbols#TokenNameIdentifier
), whereas if set to "1.4"
, it
- * would report assert keywords (ITerminalSymbols#TokenNameassert
). Java 1.4 has introduced
+ * ({@link ITerminalSymbols#TokenNameIdentifier}), whereas if set to "1.4"
, it
+ * would report assert keywords ({@link ITerminalSymbols#TokenNameassert}). Java 1.4 has introduced
* a new 'assert' keyword.
* @param complianceLevel This is used to support the Unicode 4.0 character sets. if set to 1.5 or above,
* the Unicode 4.0 is supporte, otherwise Unicode 3.0 is supported.
- * @return a scanner
+ * @return a scanner
* @see org.eclipse.jdt.core.compiler.IScanner
*
- * @since 3.1
+ * @since 3.1
*/
public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean recordLineSeparator, String sourceLevel, String complianceLevel) {
PublicScanner scanner = null;
long sourceLevelValue = CompilerOptions.versionToJdkLevel(sourceLevel);
if (sourceLevelValue == 0) sourceLevelValue = ClassFileConstants.JDK1_3; // fault-tolerance
long complianceLevelValue = CompilerOptions.versionToJdkLevel(complianceLevel);
- if (complianceLevelValue == 0) complianceLevelValue = ClassFileConstants.JDK1_3; // fault-tolerance
+ if (complianceLevelValue == 0) complianceLevelValue = ClassFileConstants.JDK1_4; // fault-tolerance
scanner = new PublicScanner(tokenizeComments, tokenizeWhiteSpace, false/*nls*/,sourceLevelValue /*sourceLevel*/, complianceLevelValue, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/);
scanner.recordLineSeparator = recordLineSeparator;
return scanner;