View | Details | Raw Unified | Return to bug 73762 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java (-2 / +1 lines)
Lines 137-144 Link Here
137
			TypeDeclaration type = unit.types[i];
137
			TypeDeclaration type = unit.types[i];
138
			if (type.declarationSourceStart < position
138
			if (type.declarationSourceStart < position
139
				&& type.declarationSourceEnd >= position) {
139
				&& type.declarationSourceEnd >= position) {
140
				getParser().scanner.setSource(
140
				getParser().scanner.setSource(unit.compilationResult);
141
					unit.compilationResult.compilationUnit.getContents());
142
				return parseBlockStatements(type, unit, position);
141
				return parseBlockStatements(type, unit, position);
143
			}
142
			}
144
		}
143
		}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-9 / +5 lines)
Lines 7479-7498 Link Here
7479
		if ((unit.bits & ASTNode.HasAllMethodBodies) != 0)
7479
		if ((unit.bits & ASTNode.HasAllMethodBodies) != 0)
7480
			return; //work already done ...
7480
			return; //work already done ...
7481
7481
7482
		//real parse of the method....
7483
		char[] contents = unit.compilationResult.compilationUnit.getContents();
7484
		this.scanner.setSource(contents);
7485
		
7486
		// save existing values to restore them at the end of the parsing process
7482
		// save existing values to restore them at the end of the parsing process
7487
		// see bug 47079 for more details
7483
		// see bug 47079 for more details
7488
		int[] oldLineEnds = this.scanner.lineEnds;
7484
		int[] oldLineEnds = this.scanner.lineEnds;
7489
		int oldLinePtr = this.scanner.linePtr;
7485
		int oldLinePtr = this.scanner.linePtr;
7490
7486
7491
		final int[] lineSeparatorPositions = unit.compilationResult.lineSeparatorPositions;
7487
		//real parse of the method....
7492
		this.scanner.lineEnds = lineSeparatorPositions;
7488
		CompilationResult compilationResult = unit.compilationResult;
7493
		this.scanner.linePtr = lineSeparatorPositions.length - 1;
7489
		this.scanner.setSource(compilationResult);
7494
7490
		
7495
		if (this.javadocParser != null && this.javadocParser.checkDocComment) {
7491
		if (this.javadocParser != null && this.javadocParser.checkDocComment) {
7492
			char[] contents = compilationResult.compilationUnit.getContents();
7496
			this.javadocParser.scanner.setSource(contents);
7493
			this.javadocParser.scanner.setSource(contents);
7497
		}
7494
		}
7498
		if (unit.types != null) {
7495
		if (unit.types != null) {
Lines 7720-7726 Link Here
7720
	//tells the scanner to go for compilation unit parsing
7717
	//tells the scanner to go for compilation unit parsing
7721
7718
7722
	this.firstToken = TokenNamePLUS_PLUS ;
7719
	this.firstToken = TokenNamePLUS_PLUS ;
7723
	this.scanner.linePtr = -1;	
7724
	this.scanner.foundTaskCount = 0;
7720
	this.scanner.foundTaskCount = 0;
7725
	this.scanner.recordLineSeparator = true;
7721
	this.scanner.recordLineSeparator = true;
7726
	this.scanner.currentLine= null;
7722
	this.scanner.currentLine= null;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java (+16 lines)
Lines 14-19 Link Here
14
14
15
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.InvalidInputException;
16
import org.eclipse.jdt.core.compiler.InvalidInputException;
17
import org.eclipse.jdt.internal.compiler.CompilationResult;
17
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
18
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
20
Lines 3217-3222 Link Here
3217
	this.eofPosition = sourceLength;
3218
	this.eofPosition = sourceLength;
3218
	this.initialPosition = this.currentPosition = 0;
3219
	this.initialPosition = this.currentPosition = 0;
3219
	this.containsAssertKeyword = false;
3220
	this.containsAssertKeyword = false;
3221
	this.linePtr = -1;	
3222
}
3223
3224
/*
3225
 * Should be used if a parse (usually a diet parse) has already been performed on the unit, 
3226
 * so as to get the already computed line end positions.
3227
 */
3228
public final void setSource(CompilationResult compilationResult) {
3229
	char[] contents = compilationResult.compilationUnit.getContents();
3230
	setSource(contents);
3231
	int[] lineSeparatorPositions = compilationResult.lineSeparatorPositions;
3232
	if (lineSeparatorPositions != null) {
3233
		this.lineEnds = lineSeparatorPositions;
3234
		this.linePtr = lineSeparatorPositions.length - 1;
3235
	}
3220
}
3236
}
3221
3237
3222
public String toString() {
3238
public String toString() {
(-)dom/org/eclipse/jdt/core/dom/ASTConverter.java (-2 / +1 lines)
Lines 1238-1245 Link Here
1238
	
1238
	
1239
	public CompilationUnit convert(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration unit, char[] source) {
1239
	public CompilationUnit convert(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration unit, char[] source) {
1240
		this.compilationUnitSource = source;
1240
		this.compilationUnitSource = source;
1241
		this.scanner.setSource(source);
1241
		this.scanner.setSource(unit.compilationResult);
1242
		this.scanner.lineEnds = unit.compilationResult().lineSeparatorPositions;
1243
		CompilationUnit compilationUnit = this.ast.newCompilationUnit();
1242
		CompilationUnit compilationUnit = this.ast.newCompilationUnit();
1244
		// handle the package declaration immediately
1243
		// handle the package declaration immediately
1245
		// There is no node corresponding to the package declaration
1244
		// There is no node corresponding to the package declaration
(-)dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java (-2 / +3 lines)
Lines 237-243 Link Here
237
				source, 
237
				source, 
238
				"", //$NON-NLS-1$
238
				"", //$NON-NLS-1$
239
				compilerOptions.defaultEncoding);
239
				compilerOptions.defaultEncoding);
240
		CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit));
240
		CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
241
		CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);
241
		
242
		
242
		if (compilationUnitDeclaration.ignoreMethodBodies) {
243
		if (compilationUnitDeclaration.ignoreMethodBodies) {
243
			compilationUnitDeclaration.ignoreFurtherInvestigation = true;
244
			compilationUnitDeclaration.ignoreFurtherInvestigation = true;
Lines 273-279 Link Here
273
		} else {
274
		} else {
274
			//fill the methods bodies in order for the code to be generated
275
			//fill the methods bodies in order for the code to be generated
275
			//real parse of the method....
276
			//real parse of the method....
276
			parser.scanner.setSource(source);
277
			parser.scanner.setSource(compilationResult);
277
			org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
278
			org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
278
			if (types != null) {
279
			if (types != null) {
279
				for (int i = types.length; --i >= 0;)
280
				for (int i = types.length; --i >= 0;)
(-)dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java (-1 lines)
Lines 224-230 Link Here
224
		
224
		
225
		// Init scanner and start ranges computing
225
		// Init scanner and start ranges computing
226
		this.scanner = sc;
226
		this.scanner = sc;
227
		this.scanner.linePtr = this.scanner.lineEnds.length-1;
228
		this.scanner.tokenizeWhiteSpace = true;
227
		this.scanner.tokenizeWhiteSpace = true;
229
		
228
		
230
		// Start unit visit
229
		// Start unit visit
(-)model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java (-2 / +2 lines)
Lines 112-118 Link Here
112
		
112
		
113
		//fill the methods bodies in order for the code to be generated
113
		//fill the methods bodies in order for the code to be generated
114
		//real parse of the method....
114
		//real parse of the method....
115
		parser.scanner.setSource(source);
115
		parser.scanner.setSource(compilationResult);
116
		org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
116
		org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
117
		if (types != null) {
117
		if (types != null) {
118
			for (int i = types.length; --i >= 0;) {
118
			for (int i = types.length; --i >= 0;) {
Lines 188-194 Link Here
188
		constructorDeclaration.bodyStart = offset;
188
		constructorDeclaration.bodyStart = offset;
189
		constructorDeclaration.bodyEnd = offset + length - 1;
189
		constructorDeclaration.bodyEnd = offset + length - 1;
190
		
190
		
191
		parser.scanner.setSource(source);
191
		parser.scanner.setSource(compilationResult);
192
		parser.scanner.resetTo(offset, offset + length);
192
		parser.scanner.resetTo(offset, offset + length);
193
		parser.parse(constructorDeclaration, compilationUnitDeclaration, true);
193
		parser.parse(constructorDeclaration, compilationUnitDeclaration, true);
194
		
194
		
(-)model/org/eclipse/jdt/internal/core/util/PublicScanner.java (-7 / +24 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.compiler.IScanner;
16
import org.eclipse.jdt.core.compiler.IScanner;
17
import org.eclipse.jdt.core.compiler.ITerminalSymbols;
17
import org.eclipse.jdt.core.compiler.ITerminalSymbols;
18
import org.eclipse.jdt.core.compiler.InvalidInputException;
18
import org.eclipse.jdt.core.compiler.InvalidInputException;
19
import org.eclipse.jdt.internal.compiler.CompilationResult;
19
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
20
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.parser.NLSLine;
22
import org.eclipse.jdt.internal.compiler.parser.NLSLine;
Lines 37-42 Link Here
37
	//flag indicating if processed source contains occurrences of keyword assert 
38
	//flag indicating if processed source contains occurrences of keyword assert 
38
	public boolean containsAssertKeyword = false; 
39
	public boolean containsAssertKeyword = false; 
39
	
40
	
41
	// 1.5 feature
42
	public boolean useEnumAsAnIndentifier = false;
43
	
40
	public boolean recordLineSeparator = false;
44
	public boolean recordLineSeparator = false;
41
	public char currentCharacter;
45
	public char currentCharacter;
42
	public int startPosition;
46
	public int startPosition;
Lines 134-140 Link Here
134
	public /*static*/ final char[][][][] charArray_length = 
138
	public /*static*/ final char[][][][] charArray_length = 
135
		new char[OptimizedLength][TableSize][InternalTableSize][]; 
139
		new char[OptimizedLength][TableSize][InternalTableSize][]; 
136
	// support for detecting non-externalized string literals
140
	// support for detecting non-externalized string literals
137
	NLSLine currentLine= null;
141
	public NLSLine currentLine= null;
138
	public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$
142
	public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$
139
	public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length();
143
	public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length();
140
	public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$
144
	public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$
Lines 1488-1499 Link Here
1488
				default :
1492
				default :
1489
					if (Character.isJavaIdentifierStart(this.currentCharacter))
1493
					if (Character.isJavaIdentifierStart(this.currentCharacter))
1490
						return scanIdentifierOrKeyword();
1494
						return scanIdentifierOrKeyword();
1491
					if (Character.isDigit(this.currentCharacter)) {
1495
					if (isDigit(this.currentCharacter)) {
1492
						if (isDigit(this.currentCharacter)) {
1496
						return scanNumber(false);
1493
							return scanNumber(false);
1494
						} else {
1495
							throw new InvalidInputException(INVALID_FLOAT);
1496
						}
1497
					}						
1497
					}						
1498
					return TokenNameERROR;
1498
					return TokenNameERROR;
1499
			}
1499
			}
Lines 2456-2461 Link Here
2456
	//keywors with the same length AND the same first char, then do another
2456
	//keywors with the same length AND the same first char, then do another
2457
	//dispatch on the second char 
2457
	//dispatch on the second char 
2458
	this.useAssertAsAnIndentifier = false;
2458
	this.useAssertAsAnIndentifier = false;
2459
	this.useEnumAsAnIndentifier = false;
2459
	while (getNextCharAsJavaIdentifierPart()){/*empty*/}
2460
	while (getNextCharAsJavaIdentifierPart()){/*empty*/}
2460
2461
2461
	int index, length;
2462
	int index, length;
Lines 2633-2638 Link Here
2633
							if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
2634
							if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
2634
								return TokenNameenum;
2635
								return TokenNameenum;
2635
							} else {
2636
							} else {
2637
								this.useEnumAsAnIndentifier = true;
2636
								return TokenNameIdentifier;								
2638
								return TokenNameIdentifier;								
2637
							}
2639
							}
2638
						} else {
2640
						} else {
Lines 3213-3218 Link Here
3213
	this.eofPosition = sourceLength;
3215
	this.eofPosition = sourceLength;
3214
	this.initialPosition = this.currentPosition = 0;
3216
	this.initialPosition = this.currentPosition = 0;
3215
	this.containsAssertKeyword = false;
3217
	this.containsAssertKeyword = false;
3218
	this.linePtr = -1;	
3219
}
3220
3221
/*
3222
 * Should be used if a parse (usually a diet parse) has already been performed on the unit, 
3223
 * so as to get the already computed line end positions.
3224
 */
3225
public final void setSource(CompilationResult compilationResult) {
3226
	char[] contents = compilationResult.compilationUnit.getContents();
3227
	setSource(contents);
3228
	int[] lineSeparatorPositions = compilationResult.lineSeparatorPositions;
3229
	if (lineSeparatorPositions != null) {
3230
		this.lineEnds = lineSeparatorPositions;
3231
		this.linePtr = lineSeparatorPositions.length - 1;
3232
	}
3216
}
3233
}
3217
3234
3218
public String toString() {
3235
public String toString() {
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-7 / +3 lines)
Lines 651-665 Link Here
651
	int oldLinePtr = this.parser.scanner.linePtr;
651
	int oldLinePtr = this.parser.scanner.linePtr;
652
	
652
	
653
	try {
653
	try {
654
		char[] contents = unit.compilationResult.compilationUnit.getContents();
654
		CompilationResult compilationResult = unit.compilationResult;
655
		this.parser.scanner.setSource(contents);
655
		this.parser.scanner.setSource(compilationResult);
656
657
		// inline old setLineEnds
658
		final int[] lineSeparatorPositions = unit.compilationResult.lineSeparatorPositions;
659
		this.parser.scanner.lineEnds = lineSeparatorPositions;
660
		this.parser.scanner.linePtr = lineSeparatorPositions.length - 1;
661
656
662
		if (this.parser.javadocParser.checkDocComment) {
657
		if (this.parser.javadocParser.checkDocComment) {
658
			char[] contents = compilationResult.compilationUnit.getContents();
663
			this.parser.javadocParser.scanner.setSource(contents);
659
			this.parser.javadocParser.scanner.setSource(contents);
664
		}
660
		}
665
		this.parser.nodeSet = this.currentPossibleMatch.nodeSet;
661
		this.parser.nodeSet = this.currentPossibleMatch.nodeSet;

Return to bug 73762