Index: codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java,v retrieving revision 1.33 diff -u -r1.33 Engine.java --- codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java 13 Jan 2004 15:48:45 -0000 1.33 +++ codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java 14 Sep 2004 10:38:26 -0000 @@ -137,8 +137,7 @@ TypeDeclaration type = unit.types[i]; if (type.declarationSourceStart < position && type.declarationSourceEnd >= position) { - getParser().scanner.setSource( - unit.compilationResult.compilationUnit.getContents()); + getParser().scanner.setSource(unit.compilationResult); return parseBlockStatements(type, unit, position); } } Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.232 diff -u -r1.232 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 10 Sep 2004 17:33:44 -0000 1.232 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 14 Sep 2004 10:38:27 -0000 @@ -7479,20 +7479,17 @@ if ((unit.bits & ASTNode.HasAllMethodBodies) != 0) return; //work already done ... - //real parse of the method.... - char[] contents = unit.compilationResult.compilationUnit.getContents(); - this.scanner.setSource(contents); - // save existing values to restore them at the end of the parsing process // see bug 47079 for more details int[] oldLineEnds = this.scanner.lineEnds; int oldLinePtr = this.scanner.linePtr; - final int[] lineSeparatorPositions = unit.compilationResult.lineSeparatorPositions; - this.scanner.lineEnds = lineSeparatorPositions; - this.scanner.linePtr = lineSeparatorPositions.length - 1; - + //real parse of the method.... + CompilationResult compilationResult = unit.compilationResult; + this.scanner.setSource(compilationResult); + if (this.javadocParser != null && this.javadocParser.checkDocComment) { + char[] contents = compilationResult.compilationUnit.getContents(); this.javadocParser.scanner.setSource(contents); } if (unit.types != null) { @@ -7720,7 +7717,6 @@ //tells the scanner to go for compilation unit parsing this.firstToken = TokenNamePLUS_PLUS ; - this.scanner.linePtr = -1; this.scanner.foundTaskCount = 0; this.scanner.recordLineSeparator = true; this.scanner.currentLine= null; Index: compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java,v retrieving revision 1.122 diff -u -r1.122 Scanner.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java 10 Sep 2004 17:33:44 -0000 1.122 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java 14 Sep 2004 10:38:27 -0000 @@ -14,6 +14,7 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.InvalidInputException; +import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -3217,6 +3218,21 @@ this.eofPosition = sourceLength; this.initialPosition = this.currentPosition = 0; this.containsAssertKeyword = false; + this.linePtr = -1; +} + +/* + * Should be used if a parse (usually a diet parse) has already been performed on the unit, + * so as to get the already computed line end positions. + */ +public final void setSource(CompilationResult compilationResult) { + char[] contents = compilationResult.compilationUnit.getContents(); + setSource(contents); + int[] lineSeparatorPositions = compilationResult.lineSeparatorPositions; + if (lineSeparatorPositions != null) { + this.lineEnds = lineSeparatorPositions; + this.linePtr = lineSeparatorPositions.length - 1; + } } public String toString() { Index: dom/org/eclipse/jdt/core/dom/ASTConverter.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java,v retrieving revision 1.163 diff -u -r1.163 ASTConverter.java --- dom/org/eclipse/jdt/core/dom/ASTConverter.java 8 Sep 2004 14:44:44 -0000 1.163 +++ dom/org/eclipse/jdt/core/dom/ASTConverter.java 14 Sep 2004 10:38:27 -0000 @@ -1238,8 +1238,7 @@ public CompilationUnit convert(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration unit, char[] source) { this.compilationUnitSource = source; - this.scanner.setSource(source); - this.scanner.lineEnds = unit.compilationResult().lineSeparatorPositions; + this.scanner.setSource(unit.compilationResult); CompilationUnit compilationUnit = this.ast.newCompilationUnit(); // handle the package declaration immediately // There is no node corresponding to the package declaration Index: dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java,v retrieving revision 1.66 diff -u -r1.66 CompilationUnitResolver.java --- dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 24 Mar 2004 10:17:52 -0000 1.66 +++ dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 14 Sep 2004 10:38:27 -0000 @@ -237,7 +237,8 @@ source, "", //$NON-NLS-1$ compilerOptions.defaultEncoding); - CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit)); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); + CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); if (compilationUnitDeclaration.ignoreMethodBodies) { compilationUnitDeclaration.ignoreFurtherInvestigation = true; @@ -273,7 +274,7 @@ } else { //fill the methods bodies in order for the code to be generated //real parse of the method.... - parser.scanner.setSource(source); + parser.scanner.setSource(compilationResult); org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; if (types != null) { for (int i = types.length; --i >= 0;) Index: dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java,v retrieving revision 1.17 diff -u -r1.17 DefaultCommentMapper.java --- dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java 8 Jul 2004 13:32:58 -0000 1.17 +++ dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java 14 Sep 2004 10:38:27 -0000 @@ -224,7 +224,6 @@ // Init scanner and start ranges computing this.scanner = sc; - this.scanner.linePtr = this.scanner.lineEnds.length-1; this.scanner.tokenizeWhiteSpace = true; // Start unit visit Index: model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java,v retrieving revision 1.8 diff -u -r1.8 CodeSnippetParsingUtil.java --- model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java 4 Feb 2004 15:05:23 -0000 1.8 +++ model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java 14 Sep 2004 10:38:27 -0000 @@ -112,7 +112,7 @@ //fill the methods bodies in order for the code to be generated //real parse of the method.... - parser.scanner.setSource(source); + parser.scanner.setSource(compilationResult); org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; if (types != null) { for (int i = types.length; --i >= 0;) { @@ -188,7 +188,7 @@ constructorDeclaration.bodyStart = offset; constructorDeclaration.bodyEnd = offset + length - 1; - parser.scanner.setSource(source); + parser.scanner.setSource(compilationResult); parser.scanner.resetTo(offset, offset + length); parser.parse(constructorDeclaration, compilationUnitDeclaration, true); Index: model/org/eclipse/jdt/internal/core/util/PublicScanner.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java,v retrieving revision 1.51 diff -u -r1.51 PublicScanner.java --- model/org/eclipse/jdt/internal/core/util/PublicScanner.java 7 Jul 2004 01:05:22 -0000 1.51 +++ model/org/eclipse/jdt/internal/core/util/PublicScanner.java 14 Sep 2004 10:38:27 -0000 @@ -16,6 +16,7 @@ import org.eclipse.jdt.core.compiler.IScanner; import org.eclipse.jdt.core.compiler.ITerminalSymbols; import org.eclipse.jdt.core.compiler.InvalidInputException; +import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.parser.NLSLine; @@ -37,6 +38,9 @@ //flag indicating if processed source contains occurrences of keyword assert public boolean containsAssertKeyword = false; + // 1.5 feature + public boolean useEnumAsAnIndentifier = false; + public boolean recordLineSeparator = false; public char currentCharacter; public int startPosition; @@ -134,7 +138,7 @@ public /*static*/ final char[][][][] charArray_length = new char[OptimizedLength][TableSize][InternalTableSize][]; // support for detecting non-externalized string literals - NLSLine currentLine= null; + public NLSLine currentLine= null; public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$ public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length(); public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$ @@ -1488,12 +1492,8 @@ default : if (Character.isJavaIdentifierStart(this.currentCharacter)) return scanIdentifierOrKeyword(); - if (Character.isDigit(this.currentCharacter)) { - if (isDigit(this.currentCharacter)) { - return scanNumber(false); - } else { - throw new InvalidInputException(INVALID_FLOAT); - } + if (isDigit(this.currentCharacter)) { + return scanNumber(false); } return TokenNameERROR; } @@ -2456,6 +2456,7 @@ //keywors with the same length AND the same first char, then do another //dispatch on the second char this.useAssertAsAnIndentifier = false; + this.useEnumAsAnIndentifier = false; while (getNextCharAsJavaIdentifierPart()){/*empty*/} int index, length; @@ -2633,6 +2634,7 @@ if (this.sourceLevel >= ClassFileConstants.JDK1_5) { return TokenNameenum; } else { + this.useEnumAsAnIndentifier = true; return TokenNameIdentifier; } } else { @@ -3213,6 +3215,21 @@ this.eofPosition = sourceLength; this.initialPosition = this.currentPosition = 0; this.containsAssertKeyword = false; + this.linePtr = -1; +} + +/* + * Should be used if a parse (usually a diet parse) has already been performed on the unit, + * so as to get the already computed line end positions. + */ +public final void setSource(CompilationResult compilationResult) { + char[] contents = compilationResult.compilationUnit.getContents(); + setSource(contents); + int[] lineSeparatorPositions = compilationResult.lineSeparatorPositions; + if (lineSeparatorPositions != null) { + this.lineEnds = lineSeparatorPositions; + this.linePtr = lineSeparatorPositions.length - 1; + } } public String toString() { Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v retrieving revision 1.195 diff -u -r1.195 MatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 13 Sep 2004 11:21:17 -0000 1.195 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 14 Sep 2004 10:38:27 -0000 @@ -651,15 +651,11 @@ int oldLinePtr = this.parser.scanner.linePtr; try { - char[] contents = unit.compilationResult.compilationUnit.getContents(); - this.parser.scanner.setSource(contents); - - // inline old setLineEnds - final int[] lineSeparatorPositions = unit.compilationResult.lineSeparatorPositions; - this.parser.scanner.lineEnds = lineSeparatorPositions; - this.parser.scanner.linePtr = lineSeparatorPositions.length - 1; + CompilationResult compilationResult = unit.compilationResult; + this.parser.scanner.setSource(compilationResult); if (this.parser.javadocParser.checkDocComment) { + char[] contents = compilationResult.compilationUnit.getContents(); this.parser.javadocParser.scanner.setSource(contents); } this.parser.nodeSet = this.currentPossibleMatch.nodeSet;