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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-12 / +17 lines)
Lines 26-31 Link Here
26
import org.eclipse.jdt.internal.compiler.ast.*;
26
import org.eclipse.jdt.internal.compiler.ast.*;
27
import org.eclipse.jdt.internal.compiler.parser.*;
27
import org.eclipse.jdt.internal.compiler.parser.*;
28
import org.eclipse.jdt.internal.compiler.problem.*;
28
import org.eclipse.jdt.internal.compiler.problem.*;
29
import org.eclipse.jdt.internal.compiler.util.Util;
29
import org.eclipse.jdt.core.compiler.CharOperation;
30
import org.eclipse.jdt.core.compiler.CharOperation;
30
import org.eclipse.jdt.core.compiler.InvalidInputException;
31
import org.eclipse.jdt.core.compiler.InvalidInputException;
31
import org.eclipse.jdt.internal.codeassist.impl.*;
32
import org.eclipse.jdt.internal.codeassist.impl.*;
Lines 264-270 Link Here
264
			if (method != null){
265
			if (method != null){
265
				AbstractMethodDeclaration methodDecl = method.methodDeclaration;
266
				AbstractMethodDeclaration methodDecl = method.methodDeclaration;
266
				if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
267
				if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
267
					&& (scanner.getLineNumber(orphan.sourceStart) == scanner.getLineNumber(methodDecl.sourceEnd))){
268
					&& (Util.getLineNumber(orphan.sourceStart, scanner.lineEnds, 0, scanner.linePtr) 
269
							== Util.getLineNumber(methodDecl.sourceEnd, scanner.lineEnds, 0, scanner.linePtr))){
268
					return;
270
					return;
269
				}
271
				}
270
			}
272
			}
Lines 440-446 Link Here
440
			if (method != null){
442
			if (method != null){
441
				AbstractMethodDeclaration methodDecl = method.methodDeclaration;
443
				AbstractMethodDeclaration methodDecl = method.methodDeclaration;
442
				if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
444
				if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
443
					&& (this.scanner.getLineNumber(node.sourceStart) == this.scanner.getLineNumber(methodDecl.sourceEnd))){
445
					&& (Util.getLineNumber(node.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr) 
446
						== Util.getLineNumber(methodDecl.sourceEnd, this.scanner.lineEnds, 0, this.scanner.linePtr))){
444
					return;
447
					return;
445
				}
448
				}
446
			}
449
			}
Lines 463-469 Link Here
463
			if (method != null){
466
			if (method != null){
464
				AbstractMethodDeclaration methodDecl = method.methodDeclaration;
467
				AbstractMethodDeclaration methodDecl = method.methodDeclaration;
465
				if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
468
				if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
466
					&& (scanner.getLineNumber(expression.sourceStart) == scanner.getLineNumber(methodDecl.sourceEnd))){
469
					&& (Util.getLineNumber(expression.sourceStart, scanner.lineEnds, 0, scanner.linePtr) 
470
						== Util.getLineNumber(methodDecl.sourceEnd, scanner.lineEnds, 0, scanner.linePtr))){
467
					return;
471
					return;
468
				}
472
				}
469
			}
473
			}
Lines 1540-1547 Link Here
1540
		/* check if on line with an error already - to avoid completing inside
1544
		/* check if on line with an error already - to avoid completing inside
1541
			illegal type names e.g.  int[<cursor> */
1545
			illegal type names e.g.  int[<cursor> */
1542
		if (lastErrorEndPosition <= cursorLocation+1
1546
		if (lastErrorEndPosition <= cursorLocation+1
1543
			&& scanner.getLineNumber(lastErrorEndPosition)
1547
			&& Util.getLineNumber(lastErrorEndPosition, scanner.lineEnds, 0, scanner.linePtr)
1544
				== scanner.getLineNumber(((CompletionScanner)scanner).completedIdentifierStart)){
1548
					== Util.getLineNumber(((CompletionScanner)scanner).completedIdentifierStart, scanner.lineEnds, 0, scanner.linePtr)){
1545
			return false;
1549
			return false;
1546
		}
1550
		}
1547
 		RecoveredMethod recoveredMethod = (RecoveredMethod)currentElement;
1551
 		RecoveredMethod recoveredMethod = (RecoveredMethod)currentElement;
Lines 1593-1600 Link Here
1593
		/* check if on line with an error already - to avoid completing inside
1597
		/* check if on line with an error already - to avoid completing inside
1594
			illegal type names e.g.  int[<cursor> */
1598
			illegal type names e.g.  int[<cursor> */
1595
		if ((lastErrorEndPosition <= cursorLocation+1)
1599
		if ((lastErrorEndPosition <= cursorLocation+1)
1596
			&& scanner.getLineNumber(lastErrorEndPosition)
1600
			&& Util.getLineNumber(lastErrorEndPosition, scanner.lineEnds, 0, scanner.linePtr)
1597
				== scanner.getLineNumber(((CompletionScanner)scanner).completedIdentifierStart)){
1601
					== Util.getLineNumber(((CompletionScanner)scanner).completedIdentifierStart, scanner.lineEnds, 0, scanner.linePtr)){
1598
			return false;
1602
			return false;
1599
		}
1603
		}
1600
		RecoveredType recoveredType = (RecoveredType)currentElement;
1604
		RecoveredType recoveredType = (RecoveredType)currentElement;
Lines 2030-2037 Link Here
2030
2034
2031
				if (!(currentElement instanceof RecoveredType)
2035
				if (!(currentElement instanceof RecoveredType)
2032
					&& (currentToken == TokenNameDOT
2036
					&& (currentToken == TokenNameDOT
2033
						|| (scanner.getLineNumber(type.sourceStart)
2037
						|| (Util.getLineNumber(type.sourceStart, scanner.lineEnds, 0, scanner.linePtr)
2034
								!= scanner.getLineNumber(nameSourceStart)))){
2038
								!= Util.getLineNumber(nameSourceStart, scanner.lineEnds, 0, scanner.linePtr)))){
2035
					lastCheckPoint = nameSourceStart;
2039
					lastCheckPoint = nameSourceStart;
2036
					restartRecovery = true;
2040
					restartRecovery = true;
2037
					return;
2041
					return;
Lines 2296-2302 Link Here
2296
				int declarationSourceStart = intStack[intPtr--];
2300
				int declarationSourceStart = intStack[intPtr--];
2297
				int mod = intStack[intPtr--];
2301
				int mod = intStack[intPtr--];
2298
2302
2299
				if(scanner.getLineNumber(type.sourceStart) != scanner.getLineNumber((int) (selectorSource >>> 32))) {
2303
				if(Util.getLineNumber(type.sourceStart, scanner.lineEnds, 0, scanner.linePtr) 
2304
						!= Util.getLineNumber((int) (selectorSource >>> 32), scanner.lineEnds, 0, scanner.linePtr)) {
2300
					FieldDeclaration completionFieldDecl = new CompletionOnFieldType(type, false);
2305
					FieldDeclaration completionFieldDecl = new CompletionOnFieldType(type, false);
2301
					// consume annotations
2306
					// consume annotations
2302
					int length;
2307
					int length;
Lines 2381-2388 Link Here
2381
		if (currentElement != null){
2386
		if (currentElement != null){
2382
			if (currentElement instanceof RecoveredType
2387
			if (currentElement instanceof RecoveredType
2383
				//|| md.modifiers != 0
2388
				//|| md.modifiers != 0
2384
				|| (scanner.getLineNumber(md.returnType.sourceStart)
2389
				|| (Util.getLineNumber(md.returnType.sourceStart, scanner.lineEnds, 0, scanner.linePtr)
2385
						== scanner.getLineNumber(md.sourceStart))){
2390
						== Util.getLineNumber(md.sourceStart, scanner.lineEnds, 0, scanner.linePtr))){
2386
				lastCheckPoint = md.bodyStart;
2391
				lastCheckPoint = md.bodyStart;
2387
				currentElement = currentElement.add(md, 0);
2392
				currentElement = currentElement.add(md, 0);
2388
				lastIgnoredToken = -1;
2393
				lastIgnoredToken = -1;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/diagnose/LexStream.java (-2 / +3 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.core.compiler.InvalidInputException;
14
import org.eclipse.jdt.core.compiler.InvalidInputException;
15
import org.eclipse.jdt.internal.compiler.parser.Scanner;
15
import org.eclipse.jdt.internal.compiler.parser.Scanner;
16
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
16
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
17
import org.eclipse.jdt.internal.compiler.util.Util;
17
18
18
public class LexStream implements TerminalTokens {
19
public class LexStream implements TerminalTokens {
19
	public static final int IS_AFTER_JUMP = 1;
20
	public static final int IS_AFTER_JUMP = 1;
Lines 89-95 Link Here
89
						token.name = scanner.getCurrentTokenSource();
90
						token.name = scanner.getCurrentTokenSource();
90
						token.start = start;
91
						token.start = start;
91
						token.end = end;
92
						token.end = end;
92
						token.line = scanner.getLineNumber(end);
93
						token.line = Util.getLineNumber(end, scanner.lineEnds, 0, scanner.linePtr);
93
						
94
						
94
						if(currentInterval != previousInterval && (intervalFlagsToSkip[currentInterval] & RangeUtil.IGNORE) == 0){
95
						if(currentInterval != previousInterval && (intervalFlagsToSkip[currentInterval] & RangeUtil.IGNORE) == 0){
95
							token.flags = IS_AFTER_JUMP;
96
							token.flags = IS_AFTER_JUMP;
Lines 113-119 Link Here
113
					token.name = CharOperation.NO_CHAR;
114
					token.name = CharOperation.NO_CHAR;
114
					token.start = start;
115
					token.start = start;
115
					token.end = end;
116
					token.end = end;
116
					token.line = scanner.getLineNumber(end);
117
					token.line = Util.getLineNumber(end, scanner.lineEnds, 0, scanner.linePtr);
117
					
118
					
118
					tokenCache[++tokenCacheIndex % length] = token;
119
					tokenCache[++tokenCacheIndex % length] = token;
119
					
120
					
(-)compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java (-2 / +4 lines)
Lines 61-67 Link Here
61
		if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return;
61
		if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return;
62
		this.problem.setSourceStart(invocationSite.sourceStart());
62
		this.problem.setSourceStart(invocationSite.sourceStart());
63
		this.problem.setSourceEnd(invocationSite.sourceEnd());
63
		this.problem.setSourceEnd(invocationSite.sourceEnd());
64
		this.problem.setSourceLineNumber(Util.searchLineNumber(unitResult.getLineSeparatorPositions(), invocationSite.sourceStart()));
64
		int[] lineEnds = unitResult.getLineSeparatorPositions();
65
		this.problem.setSourceLineNumber(Util.getLineNumber(invocationSite.sourceStart(), lineEnds, 0, lineEnds.length-1));
65
		this.compilationResult = unitResult;
66
		this.compilationResult = unitResult;
66
	}
67
	}
67
68
Lines 70-76 Link Here
70
		if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return;
71
		if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return;
71
		this.problem.setSourceStart(astNode.sourceStart());
72
		this.problem.setSourceStart(astNode.sourceStart());
72
		this.problem.setSourceEnd(astNode.sourceEnd());
73
		this.problem.setSourceEnd(astNode.sourceEnd());
73
		this.problem.setSourceLineNumber(Util.searchLineNumber(unitResult.getLineSeparatorPositions(), astNode.sourceStart()));
74
		int[] lineEnds = unitResult.getLineSeparatorPositions();
75
		this.problem.setSourceLineNumber(Util.getLineNumber(astNode.sourceStart(), lineEnds, 0, lineEnds.length-1));
74
		this.compilationResult = unitResult;
76
		this.compilationResult = unitResult;
75
	}
77
	}
76
}
78
}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java (-1 / +2 lines)
Lines 100-107 Link Here
100
		}
100
		}
101
	}
101
	}
102
102
103
	int[] lineEnds;
103
	int lineNumber = problemStartPosition >= 0
104
	int lineNumber = problemStartPosition >= 0
104
			? Util.searchLineNumber(unitResult.getLineSeparatorPositions(), problemStartPosition)
105
			? Util.getLineNumber(problemStartPosition, lineEnds = unitResult.getLineSeparatorPositions(), 0, lineEnds.length-1)
105
			: 0;
106
			: 0;
106
	int columnNumber = problemStartPosition >= 0
107
	int columnNumber = problemStartPosition >= 0
107
			? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
108
			? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-8 / +9 lines)
Lines 3030-3037 Link Here
3030
		if (!(this.currentElement instanceof RecoveredType)
3030
		if (!(this.currentElement instanceof RecoveredType)
3031
			&& (this.currentToken == TokenNameDOT
3031
			&& (this.currentToken == TokenNameDOT
3032
				//|| declaration.modifiers != 0
3032
				//|| declaration.modifiers != 0
3033
				|| (this.scanner.getLineNumber(declaration.type.sourceStart)
3033
				|| (Util.getLineNumber(declaration.type.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
3034
						!= this.scanner.getLineNumber((int) (namePosition >>> 32))))){
3034
						!= Util.getLineNumber((int) (namePosition >>> 32), this.scanner.lineEnds, 0, this.scanner.linePtr)))){
3035
			this.lastCheckPoint = (int) (namePosition >>> 32);
3035
			this.lastCheckPoint = (int) (namePosition >>> 32);
3036
			this.restartRecovery = true;
3036
			this.restartRecovery = true;
3037
			return;
3037
			return;
Lines 4267-4274 Link Here
4267
	if (this.currentElement != null){
4267
	if (this.currentElement != null){
4268
		if (this.currentElement instanceof RecoveredType 
4268
		if (this.currentElement instanceof RecoveredType 
4269
			//|| md.modifiers != 0
4269
			//|| md.modifiers != 0
4270
			|| (this.scanner.getLineNumber(md.returnType.sourceStart)
4270
			|| (Util.getLineNumber(md.returnType.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
4271
					== this.scanner.getLineNumber(md.sourceStart))){
4271
					== Util.getLineNumber(md.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr))){
4272
			this.lastCheckPoint = md.bodyStart;
4272
			this.lastCheckPoint = md.bodyStart;
4273
			this.currentElement = this.currentElement.add(md, 0);
4273
			this.currentElement = this.currentElement.add(md, 0);
4274
			this.lastIgnoredToken = -1;
4274
			this.lastIgnoredToken = -1;
Lines 4330-4337 Link Here
4330
		boolean isType;
4330
		boolean isType;
4331
		if ((isType = this.currentElement instanceof RecoveredType) 
4331
		if ((isType = this.currentElement instanceof RecoveredType) 
4332
			//|| md.modifiers != 0
4332
			//|| md.modifiers != 0
4333
			|| (this.scanner.getLineNumber(md.returnType.sourceStart)
4333
			|| (Util.getLineNumber(md.returnType.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
4334
					== this.scanner.getLineNumber(md.sourceStart))){
4334
					== Util.getLineNumber(md.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr))){
4335
			if(isType) {
4335
			if(isType) {
4336
				((RecoveredType) this.currentElement).pendingTypeParameters = null;
4336
				((RecoveredType) this.currentElement).pendingTypeParameters = null;
4337
			}
4337
			}
Lines 7256-7262 Link Here
7256
					this.scanner.getCurrentTokenSourceString(), 
7256
					this.scanner.getCurrentTokenSourceString(), 
7257
					this.scanner.startPosition, 
7257
					this.scanner.startPosition, 
7258
					this.scanner.currentPosition - 1,
7258
					this.scanner.currentPosition - 1,
7259
					this.scanner.getLineNumber(this.scanner.startPosition));
7259
					Util.getLineNumber(this.scanner.startPosition, this.scanner.lineEnds, 0, this.scanner.linePtr));
7260
				this.compilationUnit.recordStringLiteral(stringLiteral);
7260
				this.compilationUnit.recordStringLiteral(stringLiteral);
7261
			} else {
7261
			} else {
7262
				stringLiteral = this.createStringLiteral(
7262
				stringLiteral = this.createStringLiteral(
Lines 8091-8097 Link Here
8091
		if (immediateCommentEnd > 0){ // only tolerating non-javadoc comments
8091
		if (immediateCommentEnd > 0){ // only tolerating non-javadoc comments
8092
			// is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
8092
			// is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
8093
			immediateCommentEnd--; // comment end in one char too far
8093
			immediateCommentEnd--; // comment end in one char too far
8094
			if (this.scanner.getLineNumber(position) == this.scanner.getLineNumber(immediateCommentEnd)){
8094
			if (Util.getLineNumber(position, this.scanner.lineEnds, 0, this.scanner.linePtr) 
8095
					== Util.getLineNumber(immediateCommentEnd, this.scanner.lineEnds, 0, this.scanner.linePtr)){
8095
				position = immediateCommentEnd;
8096
				position = immediateCommentEnd;
8096
				validCount--; // flush this comment
8097
				validCount--; // flush this comment
8097
				index++;
8098
				index++;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java (-22 / +2 lines)
Lines 3543-3576 Link Here
3543
3543
3544
	return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
3544
	return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
3545
}
3545
}
3546
3546
/**
3547
/**
3547
 * Search the line number corresponding to a specific position
3548
 * Search the line number corresponding to a specific position
3548
 * @param position int
3549
 * @param position int
3549
 * @return int
3550
 * @return int
3550
 */
3551
 */
3551
public final int getLineNumber(int position) {
3552
public final int getLineNumber(int position) {
3552
3553
	return Util.getLineNumber(position, this.lineEnds, 0, this.linePtr);
3553
	if (this.lineEnds == null)
3554
		return 1;
3555
	int length = this.linePtr+1;
3556
	if (length == 0)
3557
		return 1;
3558
	int g = 0, d = length - 1;
3559
	int m = 0;
3560
	while (g <= d) {
3561
		m = g + (d - g) /2;
3562
		if (position < this.lineEnds[m]) {
3563
			d = m-1;
3564
		} else if (position > this.lineEnds[m]) {
3565
			g = m+1;
3566
		} else {
3567
			return m + 1;
3568
		}
3569
	}
3570
	if (position < this.lineEnds[m]) {
3571
		return m+1;
3572
	}
3573
	return m+2;
3574
}
3554
}
3575
public final void setSource(char[] sourceString){
3555
public final void setSource(char[] sourceString){
3576
	//the source-buffer is set to sourceString
3556
	//the source-buffer is set to sourceString
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java (-2 / +4 lines)
Lines 28-33 Link Here
28
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
28
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
29
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
29
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
30
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
31
import org.eclipse.jdt.internal.compiler.util.Util;
31
32
32
/**
33
/**
33
 * Internal method structure for parsing recovery 
34
 * Internal method structure for parsing recovery 
Lines 502-509 Link Here
502
	int lastParameterEnd = parameters[parameters.length - 1].sourceEnd;
503
	int lastParameterEnd = parameters[parameters.length - 1].sourceEnd;
503
	
504
	
504
	Parser parser = this.parser();
505
	Parser parser = this.parser();
505
	if(parser.scanner.getLineNumber(methodDeclaration.declarationSourceStart)
506
	Scanner scanner = parser.scanner;
506
			!= parser.scanner.getLineNumber(lastParameterEnd)) return;
507
	if(Util.getLineNumber(methodDeclaration.declarationSourceStart, scanner.lineEnds, 0, scanner.linePtr)
508
			!= Util.getLineNumber(lastParameterEnd, scanner.lineEnds, 0, scanner.linePtr)) return;
507
	
509
	
508
	if(parser.modifiersSourceStart > lastParameterEnd
510
	if(parser.modifiersSourceStart > lastParameterEnd
509
			&& parser.modifiersSourceStart < methodDeclaration.declarationSourceStart) return;
511
			&& parser.modifiersSourceStart < methodDeclaration.declarationSourceStart) return;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (-2 / +4 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.compiler.InvalidInputException;
16
import org.eclipse.jdt.core.compiler.InvalidInputException;
17
import org.eclipse.jdt.internal.compiler.ast.*;
17
import org.eclipse.jdt.internal.compiler.ast.*;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.util.Util;
19
20
20
/**
21
/**
21
 * Parser specialized for decoding javadoc comments
22
 * Parser specialized for decoding javadoc comments
Lines 82-89 Link Here
82
			} else {
83
			} else {
83
				
84
				
84
				// Parse comment
85
				// Parse comment
85
				int firstLineNumber = this.sourceParser.scanner.getLineNumber(javadocStart);
86
				Scanner sourceScanner = this.sourceParser.scanner;
86
				int lastLineNumber = this.sourceParser.scanner.getLineNumber(javadocEnd);
87
				int firstLineNumber = Util.getLineNumber(javadocStart, sourceScanner.lineEnds, 0, sourceScanner.linePtr);
88
				int lastLineNumber = Util.getLineNumber(javadocEnd, sourceScanner.lineEnds, 0, sourceScanner.linePtr);
87
				this.index = javadocStart +3;
89
				this.index = javadocStart +3;
88
	
90
	
89
				// scan line per line, since tags must be at beginning of lines only
91
				// scan line per line, since tags must be at beginning of lines only
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java (-1 / +2 lines)
Lines 21-26 Link Here
21
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
21
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
22
import org.eclipse.jdt.internal.compiler.ast.Statement;
22
import org.eclipse.jdt.internal.compiler.ast.Statement;
23
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
23
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
24
import org.eclipse.jdt.internal.compiler.util.Util;
24
25
25
public class RecoveredElement {
26
public class RecoveredElement {
26
27
Lines 210-216 Link Here
210
	Scanner scanner = parser.scanner;
211
	Scanner scanner = parser.scanner;
211
	if (scanner.lineEnds == null) return position;
212
	if (scanner.lineEnds == null) return position;
212
	
213
	
213
	int index = scanner.getLineNumber(position);
214
	int index = Util.getLineNumber(position, scanner.lineEnds, 0, scanner.linePtr);
214
	if (index < 2) return position;
215
	if (index < 2) return position;
215
	int previousLineEnd = scanner.lineEnds[index-2];
216
	int previousLineEnd = scanner.lineEnds[index-2];
216
217
(-)compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java (-20 / +3 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.core.compiler.InvalidInputException;
17
import org.eclipse.jdt.core.compiler.InvalidInputException;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.util.Util;
19
20
20
/**
21
/**
21
 * Parser specialized for decoding javadoc comments
22
 * Parser specialized for decoding javadoc comments
Lines 358-386 Link Here
358
	private int getLineNumber(int position) {
359
	private int getLineNumber(int position) {
359
	
360
	
360
		if (this.scanner.linePtr != -1) {
361
		if (this.scanner.linePtr != -1) {
361
			return this.scanner.getLineNumber(position);
362
			return Util.getLineNumber(position, this.scanner.lineEnds, 0, this.scanner.linePtr);
362
		}
363
		}
363
		if (this.lineEnds == null)
364
		if (this.lineEnds == null)
364
			return 1;
365
			return 1;
365
		int length = this.lineEnds.length;
366
		return Util.getLineNumber(position, this.lineEnds, 0, this.lineEnds.length-1);
366
		if (length == 0)
367
			return 1;
368
		int g = 0, d = length - 1;
369
		int m = 0;
370
		while (g <= d) {
371
			m = g + (d - g) /2;
372
			if (position < this.lineEnds[m]) {
373
				d = m-1;
374
			} else if (position > this.lineEnds[m]) {
375
				g = m+1;
376
			} else {
377
				return m + 1;
378
			}
379
		}
380
		if (position < this.lineEnds[m]) {
381
			return m+1;
382
		}
383
		return m+2;
384
	}
367
	}
385
368
386
	private int getTokenEndPosition() {
369
	private int getTokenEndPosition() {
(-)model/org/eclipse/jdt/internal/core/util/PublicScanner.java (-23 / +3 lines)
Lines 65-71 Link Here
65
	public boolean scanningFloatLiteral = false;
65
	public boolean scanningFloatLiteral = false;
66
66
67
	//support for /** comments
67
	//support for /** comments
68
	public static int COMMENT_ARRAYS_SIZE = 30;
68
	public final static int COMMENT_ARRAYS_SIZE = 30;
69
	public int[] commentStops = new int[COMMENT_ARRAYS_SIZE];
69
	public int[] commentStops = new int[COMMENT_ARRAYS_SIZE];
70
	public int[] commentStarts = new int[COMMENT_ARRAYS_SIZE];
70
	public int[] commentStarts = new int[COMMENT_ARRAYS_SIZE];
71
	public int[] commentTagStarts = new int[COMMENT_ARRAYS_SIZE];
71
	public int[] commentTagStarts = new int[COMMENT_ARRAYS_SIZE];
Lines 3540-3573 Link Here
3540
3540
3541
	return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
3541
	return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
3542
}
3542
}
3543
3543
/**
3544
/**
3544
 * Search the line number corresponding to a specific position
3545
 * Search the line number corresponding to a specific position
3545
 * @param position int
3546
 * @param position int
3546
 * @return int
3547
 * @return int
3547
 */
3548
 */
3548
public final int getLineNumber(int position) {
3549
public final int getLineNumber(int position) {
3549
3550
	return Util.getLineNumber(position, this.lineEnds, 0, this.linePtr);
3550
	if (this.lineEnds == null)
3551
		return 1;
3552
	int length = this.linePtr+1;
3553
	if (length == 0)
3554
		return 1;
3555
	int g = 0, d = length - 1;
3556
	int m = 0;
3557
	while (g <= d) {
3558
		m = g + (d - g) /2;
3559
		if (position < this.lineEnds[m]) {
3560
			d = m-1;
3561
		} else if (position > this.lineEnds[m]) {
3562
			g = m+1;
3563
		} else {
3564
			return m + 1;
3565
		}
3566
	}
3567
	if (position < this.lineEnds[m]) {
3568
		return m+1;
3569
	}
3570
	return m+2;
3571
}
3551
}
3572
public final void setSource(char[] sourceString){
3552
public final void setSource(char[] sourceString){
3573
	//the source-buffer is set to sourceString
3553
	//the source-buffer is set to sourceString
(-)model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java (-1 / +2 lines)
Lines 164-170 Link Here
164
			while (index<lastCommentIndex && (immediateCommentEnd = -this.scanner.commentStops[index+1])  > 0){ // only tolerating non-javadoc comments (non-javadoc comment end positions are negative)
164
			while (index<lastCommentIndex && (immediateCommentEnd = -this.scanner.commentStops[index+1])  > 0){ // only tolerating non-javadoc comments (non-javadoc comment end positions are negative)
165
				// is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
165
				// is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
166
				immediateCommentEnd--; // comment end in one char too far
166
				immediateCommentEnd--; // comment end in one char too far
167
				if (this.scanner.getLineNumber(position) != this.scanner.getLineNumber(immediateCommentEnd)) break;
167
				if (org.eclipse.jdt.internal.compiler.util.Util.getLineNumber(position, this.scanner.lineEnds, 0, this.scanner.linePtr) 
168
						!= org.eclipse.jdt.internal.compiler.util.Util.getLineNumber(immediateCommentEnd, this.scanner.lineEnds, 0, this.scanner.linePtr)) break;
168
				position = immediateCommentEnd;
169
				position = immediateCommentEnd;
169
				validCount--; // flush this comment
170
				validCount--; // flush this comment
170
				index++;
171
				index++;
(-)dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java (-21 / +65 lines)
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.dom;
11
package org.eclipse.jdt.core.dom;
12
12
13
import java.util.HashMap;
14
15
import org.eclipse.jdt.core.compiler.CharOperation;
13
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.InvalidInputException;
14
import org.eclipse.jdt.core.compiler.InvalidInputException;
17
import org.eclipse.jdt.internal.compiler.parser.Scanner;
15
import org.eclipse.jdt.internal.compiler.parser.Scanner;
18
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
16
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
17
import org.eclipse.jdt.internal.compiler.util.Util;
19
18
20
/**
19
/**
21
 * Internal class for associating comments with AST nodes.
20
 * Internal class for associating comments with AST nodes.
Lines 135-140 Link Here
135
	}
134
	}
136
135
137
	/*
136
	/*
137
	 * Search the line number corresponding to a specific position
138
	 * between the given line range (inclusive)
139
	 * @param position int
140
	 * @parem lineRange size-2 int[]
141
	 * @return int
142
	 */
143
	public final int getLineNumber(int position, int[] lineRange) {
144
		int[] lineEnds = this.scanner.lineEnds;
145
		int length = lineEnds.length;
146
		return Util.getLineNumber(position, lineEnds, (lineRange[0] > length ? length : lineRange[0]) -1, (lineRange[1] > length ? length : lineRange[1]) - 1);
147
	}
148
149
	/*
138
	 * Returns the extended end position of the given node.
150
	 * Returns the extended end position of the given node.
139
	 */
151
	 */
140
	public int getExtendedEnd(ASTNode node) {
152
	public int getExtendedEnd(ASTNode node) {
Lines 285-298 Link Here
285
	 * If finally there's leading still comments, then stores indexes of the first and last one
297
	 * If finally there's leading still comments, then stores indexes of the first and last one
286
	 * in leading comments table.
298
	 * in leading comments table.
287
	 */
299
	 */
288
	int storeLeadingComments(ASTNode node, int previousEnd) {
300
	int storeLeadingComments(ASTNode node, int previousEnd, int[] parentLineRange) {
289
		// Init extended position
301
		// Init extended position
290
		int nodeStart = node.getStartPosition();
302
		int nodeStart = node.getStartPosition();
291
		int extended = nodeStart;
303
		int extended = nodeStart;
292
		
304
		
293
		// Get line of node start position
305
		// Get line of node start position
294
		int previousEndLine = this.scanner.getLineNumber(previousEnd);
306
		int previousEndLine = getLineNumber(previousEnd, parentLineRange);
295
		int nodeStartLine = this.scanner.getLineNumber(nodeStart);
307
		int nodeStartLine = getLineNumber(nodeStart, parentLineRange);
296
		
308
		
297
		// Find first comment index
309
		// Find first comment index
298
		int idx = getCommentIndex(0, nodeStart, -1);
310
		int idx = getCommentIndex(0, nodeStart, -1);
Lines 309-315 Link Here
309
			Comment comment = this.comments[idx];
321
			Comment comment = this.comments[idx];
310
			int commentStart = comment.getStartPosition();
322
			int commentStart = comment.getStartPosition();
311
			int end = commentStart+comment.getLength()-1;
323
			int end = commentStart+comment.getLength()-1;
312
			int commentLine = this.scanner.getLineNumber(commentStart);
324
			int commentLine = getLineNumber(commentStart, parentLineRange);
313
			if (end <= previousEnd || (commentLine == previousEndLine && commentLine != nodeStartLine)) {
325
			if (end <= previousEnd || (commentLine == previousEndLine && commentLine != nodeStartLine)) {
314
				// stop search on condition 1) and 2)
326
				// stop search on condition 1) and 2)
315
				break;
327
				break;
Lines 360-368 Link Here
360
				} catch (InvalidInputException e) {
372
				} catch (InvalidInputException e) {
361
					// do nothing
373
					// do nothing
362
				}
374
				}
363
				int lastTokenLine = this.scanner.getLineNumber(lastTokenEnd);
375
				int lastTokenLine = getLineNumber(lastTokenEnd, parentLineRange);
364
				int length = this.comments.length;
376
				int length = this.comments.length;
365
				while (startIdx<length && lastTokenLine == this.scanner.getLineNumber(this.comments[startIdx].getStartPosition()) && nodeStartLine != lastTokenLine) {
377
				while (startIdx<length && lastTokenLine == getLineNumber(this.comments[startIdx].getStartPosition(), parentLineRange) && nodeStartLine != lastTokenLine) {
366
					startIdx++;
378
					startIdx++;
367
				}
379
				}
368
			}
380
			}
Lines 405-411 Link Here
405
	 * If finally there's still trailing comments, then stores indexes of the first and last one
417
	 * If finally there's still trailing comments, then stores indexes of the first and last one
406
	 * in trailing comments table.
418
	 * in trailing comments table.
407
	 */
419
	 */
408
	int storeTrailingComments(ASTNode node, int nextStart,  boolean lastChild) {
420
	int storeTrailingComments(ASTNode node, int nextStart,  boolean lastChild, int[] parentLineRange) {
409
421
410
		// Init extended position
422
		// Init extended position
411
		int nodeEnd = node.getStartPosition()+node.getLength()-1;
423
		int nodeEnd = node.getStartPosition()+node.getLength()-1;
Lines 427-433 Link Here
427
		int extended = nodeEnd;
439
		int extended = nodeEnd;
428
		
440
		
429
		// Get line number
441
		// Get line number
430
		int nodeEndLine = this.scanner.getLineNumber(nodeEnd);
442
		int nodeEndLine = getLineNumber(nodeEnd, parentLineRange);
431
		
443
		
432
		// Find comments range index
444
		// Find comments range index
433
		int idx = getCommentIndex(0, nodeEnd, 1);
445
		int idx = getCommentIndex(0, nodeEnd, 1);
Lines 480-486 Link Here
480
				}
492
				}
481
			}
493
			}
482
			// Store index if we're on the same line than node end
494
			// Store index if we're on the same line than node end
483
			int commentLine = this.scanner.getLineNumber(commentStart);
495
			int commentLine = getLineNumber(commentStart, parentLineRange);
484
			if (commentLine == nodeEndLine) {
496
			if (commentLine == nodeEndLine) {
485
				sameLineIdx = idx;
497
				sameLineIdx = idx;
486
			}
498
			}
Lines 491-498 Link Here
491
		if (endIdx != -1) {
503
		if (endIdx != -1) {
492
			// Verify that following node start is separated
504
			// Verify that following node start is separated
493
			if (!lastChild) {
505
			if (!lastChild) {
494
				int nextLine = this.scanner.getLineNumber(nextStart);
506
				int nextLine = getLineNumber(nextStart, parentLineRange);
495
				int previousLine = this.scanner.getLineNumber(previousEnd);
507
				int previousLine = getLineNumber(previousEnd, parentLineRange);
496
				if((nextLine - previousLine) <= 1) {
508
				if((nextLine - previousLine) <= 1) {
497
					if (sameLineIdx == -1) return nodeEnd;
509
					if (sameLineIdx == -1) return nodeEnd;
498
					endIdx = sameLineIdx;
510
					endIdx = sameLineIdx;
Lines 541-560 Link Here
541
553
542
	class CommentMapperVisitor extends DefaultASTVisitor {
554
	class CommentMapperVisitor extends DefaultASTVisitor {
543
555
544
		HashMap waitingSiblings = new HashMap(10);
556
		ASTNode topSiblingParent = null;
557
		ASTNode[] siblings = new ASTNode[10];
558
		int[][] parentLineRange = new int[10][];
559
		int siblingPtr = -1;
545
560
546
		protected boolean visitNode(ASTNode node) {
561
		protected boolean visitNode(ASTNode node) {
547
562
548
			// Get default previous end
563
			// Get default previous end
549
			ASTNode parent = node.getParent();
564
			ASTNode parent = node.getParent();
550
			int previousEnd = parent.getStartPosition();
565
			int previousEnd = parent.getStartPosition();
551
566
			
552
			// Look for sibling node
567
			// Look for sibling node
553
			ASTNode sibling = (ASTNode) this.waitingSiblings.get(parent);
568
 			ASTNode sibling = parent == this.topSiblingParent ? (ASTNode) this.siblings[this.siblingPtr] : null;
554
			if (sibling != null) {
569
			if (sibling != null) {
555
				// Found one previous sibling, so compute its trailing comments using current node start position
570
				// Found one previous sibling, so compute its trailing comments using current node start position
556
				try {
571
				try {
557
					previousEnd = storeTrailingComments(sibling, node.getStartPosition(), false);
572
					previousEnd = storeTrailingComments(sibling, node.getStartPosition(), false, this.parentLineRange[this.siblingPtr]);
558
				} catch (Exception ex) {
573
				} catch (Exception ex) {
559
					// Give up extended ranges at this level if unexpected exception happens...
574
					// Give up extended ranges at this level if unexpected exception happens...
560
				}
575
				}
Lines 566-579 Link Here
566
			}
581
			}
567
582
568
			// Compute leading comments for current node
583
			// Compute leading comments for current node
584
			int[] previousLineRange = this.siblingPtr > -1 ? this.parentLineRange[this.siblingPtr] : new int[] {1, DefaultCommentMapper.this.scanner.linePtr+1};
569
			try {
585
			try {
570
				storeLeadingComments(node, previousEnd);
586
				storeLeadingComments(node, previousEnd, previousLineRange);
571
			} catch (Exception ex) {
587
			} catch (Exception ex) {
572
				// Give up extended ranges at this level if unexpected exception happens...
588
				// Give up extended ranges at this level if unexpected exception happens...
573
			}
589
			}
574
			
590
			
575
			// Store current node as waiting sibling for its parent
591
			// Store current node as waiting sibling for its parent
576
			this.waitingSiblings.put(parent, node);
592
			if (this.topSiblingParent != parent) {
593
				if (this.siblings.length == ++this.siblingPtr) {
594
					System.arraycopy(this.siblings, 0, this.siblings = new ASTNode[this.siblingPtr*2], 0, this.siblingPtr);
595
					System.arraycopy(this.parentLineRange, 0, this.parentLineRange = new int[this.siblingPtr*2][], 0, this.siblingPtr);
596
				}
597
				if (this.topSiblingParent == null) {
598
					// node is a CompilationUnit
599
					this.parentLineRange[this.siblingPtr] = previousLineRange;
600
				} else {
601
					int parentStart = parent.getStartPosition();
602
					int firstLine = getLineNumber(parentStart, previousLineRange);
603
					int lastLine = getLineNumber(parentStart + parent.getLength() - 1, previousLineRange);
604
					if (this.parentLineRange[this.siblingPtr] == null) {
605
						this.parentLineRange[this.siblingPtr] = new int[] {firstLine, lastLine};
606
					} else {
607
						int[] lineRange = this.parentLineRange[this.siblingPtr];
608
						lineRange[0] = firstLine;
609
						lineRange[1] = lastLine;
610
					}
611
				}
612
				this.topSiblingParent = parent;
613
			}
614
			this.siblings[this.siblingPtr] = node;
577
615
578
			// We're always ok to visit sub-levels
616
			// We're always ok to visit sub-levels
579
			return true;
617
			return true;
Lines 582-595 Link Here
582
		protected void endVisitNode(ASTNode node) {
620
		protected void endVisitNode(ASTNode node) {
583
621
584
			// Look if a child node is waiting for trailing comments computing
622
			// Look if a child node is waiting for trailing comments computing
585
			ASTNode sibling = (ASTNode) this.waitingSiblings.get(node);
623
			ASTNode sibling = this.topSiblingParent == node ? (ASTNode) this.siblings[this.siblingPtr] : null;
586
			if (sibling != null) {
624
			if (sibling != null) {
587
				try {
625
				try {
588
					storeTrailingComments(sibling, node.getStartPosition()+node.getLength()-1, true);
626
					storeTrailingComments(sibling, node.getStartPosition()+node.getLength()-1, true, this.parentLineRange[this.siblingPtr]);
589
				} catch (Exception ex) {
627
				} catch (Exception ex) {
590
					// Give up extended ranges at this level if unexpected exception happens...
628
					// Give up extended ranges at this level if unexpected exception happens...
591
				}
629
				}
592
			}
630
			}
631
			// Remove sibling if needed
632
			if (this.topSiblingParent != null /*not a CompilationUnit*/
633
					&& this.topSiblingParent == node) {
634
				this.siblingPtr--;
635
				this.topSiblingParent = node.getParent();
636
			}
593
		}
637
		}
594
638
595
		public boolean visit ( CompilationUnit node) {
639
		public boolean visit ( CompilationUnit node) {
(-)dom/org/eclipse/jdt/core/dom/DefaultASTVisitor.java (+6 lines)
Lines 239-244 Link Here
239
	public boolean visit(LineComment node) {
239
	public boolean visit(LineComment node) {
240
		return visitNode(node);
240
		return visitNode(node);
241
	}
241
	}
242
	public boolean visit(MarkerAnnotation node) {
243
		return visitNode(node);
244
	}
242
	public boolean visit(MemberRef node) {
245
	public boolean visit(MemberRef node) {
243
		return visitNode(node);
246
		return visitNode(node);
244
	}
247
	}
Lines 455-460 Link Here
455
	public void endVisit(LineComment node) {
458
	public void endVisit(LineComment node) {
456
		endVisitNode(node);
459
		endVisitNode(node);
457
	}
460
	}
461
	public void endVisit(MarkerAnnotation node) {
462
		endVisitNode(node);
463
	}
458
	public void endVisit(MemberRef node) {
464
	public void endVisit(MemberRef node) {
459
		endVisitNode(node);
465
		endVisitNode(node);
460
	}
466
	}
(-)compiler/org/eclipse/jdt/internal/compiler/util/Util.java (-25 / +22 lines)
Lines 248-253 Link Here
248
		return contents;
248
		return contents;
249
	}
249
	}
250
	
250
	
251
	public static int getLineNumber(int position, int[] lineEnds, int g, int d) {
252
		if (lineEnds == null)
253
			return 1;
254
		if (d == -1)
255
			return 1;
256
		int m = g, start;
257
		while (g <= d) {
258
			m = g + (d - g) /2;
259
			if (position < (start = lineEnds[m])) {
260
				d = m-1;
261
			} else if (position > start) {
262
				g = m+1;
263
			} else {
264
				return m + 1;
265
			}
266
		}
267
		if (position < lineEnds[m]) {
268
			return m+1;
269
		}
270
		return m+2;
271
	}
272
251
	/**
273
	/**
252
	 * Returns the contents of the given zip entry as a byte array.
274
	 * Returns the contents of the given zip entry as a byte array.
253
	 * @throws IOException if a problem occured reading the zip entry.
275
	 * @throws IOException if a problem occured reading the zip entry.
Lines 425-455 Link Here
425
		}
447
		}
426
	}
448
	}
427
	/**
449
	/**
428
	 * INTERNAL USE-ONLY
429
	 * Search the line number corresponding to a specific position
430
	 */
431
	public static final int searchLineNumber(int[] startLineIndexes, int position) {
432
		int length = startLineIndexes.length;
433
		if (length == 0)
434
			return 1;
435
		int g = 0, d = length - 1;
436
		int m = 0, start;
437
		while (g <= d) {
438
			m = d + (g - d) / 2;
439
			if (position < (start = startLineIndexes[m])) {
440
				d = m - 1;
441
			} else if (position > start) {
442
				g = m + 1;
443
			} else {
444
				return m + 1;
445
			}
446
		}
447
		if (position < startLineIndexes[m]) {
448
			return m + 1;
449
		}
450
		return m + 2;
451
	}
452
	/**
453
	 * Converts a boolean value into Boolean.
450
	 * Converts a boolean value into Boolean.
454
	 * @param bool The boolean to convert
451
	 * @param bool The boolean to convert
455
	 * @return The corresponding Boolean object (TRUE or FALSE).
452
	 * @return The corresponding Boolean object (TRUE or FALSE).
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-1 / +1 lines)
Lines 5765-5771 Link Here
5765
		// resize the array pcToSourceMap
5765
		// resize the array pcToSourceMap
5766
		System.arraycopy(pcToSourceMap, 0, pcToSourceMap = new int[pcToSourceMapSize << 1], 0, pcToSourceMapSize);
5766
		System.arraycopy(pcToSourceMap, 0, pcToSourceMap = new int[pcToSourceMapSize << 1], 0, pcToSourceMapSize);
5767
	}
5767
	}
5768
	int lineNumber = Util.searchLineNumber(lineSeparatorPositions, sourcePos);
5768
	int lineNumber = Util.getLineNumber(sourcePos, lineSeparatorPositions, 0, lineSeparatorPositions.length-1);
5769
	// lastEntryPC represents the endPC of the lastEntry.
5769
	// lastEntryPC represents the endPC of the lastEntry.
5770
	if (pcToSourceMapSize > 0) {
5770
	if (pcToSourceMapSize > 0) {
5771
		// in this case there is already an entry in the table
5771
		// in this case there is already an entry in the table
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-3 / +3 lines)
Lines 3270-3276 Link Here
3270
			this.contents[localContentsOffset++] = 0;
3270
			this.contents[localContentsOffset++] = 0;
3271
			this.contents[localContentsOffset++] = 1;
3271
			this.contents[localContentsOffset++] = 1;
3272
			if (problemLine == 0) {
3272
			if (problemLine == 0) {
3273
				problemLine = Util.searchLineNumber(startLineIndexes, binding.sourceStart());
3273
				problemLine = Util.getLineNumber(binding.sourceStart(), startLineIndexes, 0, startLineIndexes.length-1);
3274
			}
3274
			}
3275
			// first entry at pc = 0
3275
			// first entry at pc = 0
3276
			this.contents[localContentsOffset++] = 0;
3276
			this.contents[localContentsOffset++] = 0;
Lines 3712-3718 Link Here
3712
			this.contents[localContentsOffset++] = 0;
3712
			this.contents[localContentsOffset++] = 0;
3713
			this.contents[localContentsOffset++] = 1;
3713
			this.contents[localContentsOffset++] = 1;
3714
			if (problemLine == 0) {
3714
			if (problemLine == 0) {
3715
				problemLine = Util.searchLineNumber(startLineIndexes, binding.sourceStart());
3715
				problemLine = Util.getLineNumber(binding.sourceStart(), startLineIndexes, 0, startLineIndexes.length-1);
3716
			}
3716
			}
3717
			// first entry at pc = 0
3717
			// first entry at pc = 0
3718
			this.contents[localContentsOffset++] = 0;
3718
			this.contents[localContentsOffset++] = 0;
Lines 4431-4437 Link Here
4431
			localContentsOffset += 6;
4431
			localContentsOffset += 6;
4432
			// leave space for attribute_length and line_number_table_length
4432
			// leave space for attribute_length and line_number_table_length
4433
			// Seems like do would be better, but this preserves the existing behavior.
4433
			// Seems like do would be better, but this preserves the existing behavior.
4434
			index = Util.searchLineNumber(startLineIndexes, binding.sourceStart);
4434
			index = Util.getLineNumber(binding.sourceStart, startLineIndexes, 0, startLineIndexes.length-1);
4435
			contents[localContentsOffset++] = 0;
4435
			contents[localContentsOffset++] = 0;
4436
			contents[localContentsOffset++] = 0;
4436
			contents[localContentsOffset++] = 0;
4437
			contents[localContentsOffset++] = (byte) (index >> 8);
4437
			contents[localContentsOffset++] = (byte) (index >> 8);
(-)codeassist/org/eclipse/jdt/internal/codeassist/UnresolvedReferenceNameFinder.java (-2 / +3 lines)
Lines 30-35 Link Here
30
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
30
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
31
import org.eclipse.jdt.internal.compiler.lookup.Scope;
31
import org.eclipse.jdt.internal.compiler.lookup.Scope;
32
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
32
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
33
import org.eclipse.jdt.internal.compiler.util.Util;
33
34
34
public class UnresolvedReferenceNameFinder extends ASTVisitor {
35
public class UnresolvedReferenceNameFinder extends ASTVisitor {
35
	private static final int MAX_LINE_COUNT = 100;
36
	private static final int MAX_LINE_COUNT = 100;
Lines 111-117 Link Here
111
		
112
		
112
		int maxEnd =
113
		int maxEnd =
113
			this.completionScanner.getLineEnd(
114
			this.completionScanner.getLineEnd(
114
					this.completionScanner.getLineNumber(from) + maxLineCount);
115
					Util.getLineNumber(from, this.completionScanner.lineEnds, 0, this.completionScanner.linePtr) + maxLineCount);
115
		
116
		
116
		int end;
117
		int end;
117
		if (maxEnd < 0) {
118
		if (maxEnd < 0) {
Lines 160-166 Link Here
160
		
161
		
161
		int minStart =
162
		int minStart =
162
			this.completionScanner.getLineStart(
163
			this.completionScanner.getLineStart(
163
					this.completionScanner.getLineNumber(to) - maxLineCount);
164
					Util.getLineNumber(to, this.completionScanner.lineEnds, 0, this.completionScanner.linePtr) - maxLineCount);
164
		
165
		
165
		int start;
166
		int start;
166
		int fakeBlocksCount;
167
		int fakeBlocksCount;

Return to bug 179684