package org.eclipse.jdt.internal.core.util;
import java.util.Arrays;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
public class extends Parser {
int[] = new int[10];
int[] = new int[10];
int = -1;
protected final static int = 100;
public (ProblemReporter problemReporter, boolean optimizeStringLiterals) {
super(problemReporter, optimizeStringLiterals);
}
@Override
public void () {
if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) {
flushCommentsDefinedPriorTo(this.endStatementPosition);
}
boolean deprecated = false;
boolean checkDeprecated = false;
int lastCommentIndex = -1;
nextComment : for (lastCommentIndex = this.scanner.commentPtr; lastCommentIndex >= 0; lastCommentIndex--){
int commentSourceStart = this.scanner.commentStarts[lastCommentIndex];
if ((commentSourceStart < 0) ||
(this.modifiersSourceStart != -1 && this.modifiersSourceStart < commentSourceStart) ||
(this.scanner.commentStops[lastCommentIndex] < 0))
{
continue nextComment;
}
checkDeprecated = true;
int commentSourceEnd = this.scanner.commentStops[lastCommentIndex] - 1;
if (this.javadocParser.shouldReportProblems) {
this.javadocParser.reportProblems = this.currentElement == null || commentSourceEnd > this.lastJavadocEnd;
} else {
this.javadocParser.reportProblems = false;
}
deprecated = this.javadocParser.checkDeprecation(lastCommentIndex);
this.javadoc = this.javadocParser.docComment;
if (this.currentElement == null) this.lastJavadocEnd = commentSourceEnd;
break nextComment;
}
if (deprecated) {
checkAndSetModifiers(ClassFileConstants.AccDeprecated);
}
if (lastCommentIndex >= 0 && checkDeprecated) {
int lastCommentStart = this.scanner.commentStarts[lastCommentIndex];
if (lastCommentStart < 0) lastCommentStart = -lastCommentStart;
if (this.forStartPosition == 0 || this.forStartPosition < lastCommentStart) {
this.modifiersSourceStart = lastCommentStart;
}
}
}
@Override
protected void () {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.consumeAnnotationTypeDeclarationHeader();
}
@Override
protected void () {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.consumeClassHeader();
}
@Override
protected void () {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.consumeEmptyTypeDeclaration();
}
@Override
protected void consumeEnterAnonymousClassBody(boolean qualified) {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.consumeEnterAnonymousClassBody(qualified);
}
@Override
protected void () {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.consumeEnumHeader();
}
@Override
protected void () {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.consumeInterfaceHeader();
}
@Override
protected CompilationUnitDeclaration (int act) {
CompilationUnitDeclaration unit = super.endParse(act);
if (unit.comments == null) {
pushOnCommentsStack(0, this.scanner.commentPtr);
unit.comments = getCommentsPositions();
}
return unit;
}
@Override
public int (int position) {
int lastCommentIndex = getCommentPtr();
if (lastCommentIndex < 0) return position;
int index = lastCommentIndex;
int validCount = 0;
while (index >= 0){
int commentEnd = this.scanner.commentStops[index];
if (commentEnd < 0) commentEnd = -commentEnd;
if (commentEnd <= position){
break;
}
index--;
validCount++;
}
if (validCount > 0){
int immediateCommentEnd = 0;
while (index<lastCommentIndex && (immediateCommentEnd = -this.scanner.commentStops[index+1]) > 0){
immediateCommentEnd--;
if (org.eclipse.jdt.internal.compiler.util.Util.getLineNumber(position, this.scanner.lineEnds, 0, this.scanner.linePtr)
!= org.eclipse.jdt.internal.compiler.util.Util.getLineNumber(immediateCommentEnd, this.scanner.lineEnds, 0, this.scanner.linePtr)) break;
position = immediateCommentEnd;
validCount--;
index++;
}
}
if (index < 0) return position;
pushOnCommentsStack(0, index);
switch (validCount) {
case 0:
break;
case 2:
this.scanner.commentStarts[0] = this.scanner.commentStarts[index+1];
this.scanner.commentStops[0] = this.scanner.commentStops[index+1];
this.scanner.commentTagStarts[0] = this.scanner.commentTagStarts[index+1];
this.scanner.commentStarts[1] = this.scanner.commentStarts[index+2];
this.scanner.commentStops[1] = this.scanner.commentStops[index+2];
this.scanner.commentTagStarts[1] = this.scanner.commentTagStarts[index+2];
break;
case 1:
this.scanner.commentStarts[0] = this.scanner.commentStarts[index+1];
this.scanner.commentStops[0] = this.scanner.commentStops[index+1];
this.scanner.commentTagStarts[0] = this.scanner.commentTagStarts[index+1];
break;
default:
System.arraycopy(this.scanner.commentStarts, index + 1, this.scanner.commentStarts, 0, validCount);
System.arraycopy(this.scanner.commentStops, index + 1, this.scanner.commentStops, 0, validCount);
System.arraycopy(this.scanner.commentTagStarts, index + 1, this.scanner.commentTagStarts, 0, validCount);
}
this.scanner.commentPtr = validCount - 1;
return position;
}
protected int () {
int lastComment = this.scanner.commentPtr;
if (lastComment == -1 && this.currentElement != null) {
lastComment = this.commentPtr;
if (lastComment >= 0) {
if (lastComment >= this.scanner.commentStarts.length) {
return -1;
} else {
int start = this.scanner.commentStarts[lastComment];
if (start <= 0)
return -1;
int currentStart = this.currentElement.getLastStart();
if (currentStart == -1)
currentStart = this.scanner.currentPosition;
if (start > currentStart)
return -1;
}
}
}
return lastComment;
}
public int[][] () {
int[][] positions = new int[this.commentPtr+1][2];
for (int i = 0, max = this.commentPtr; i <= max; i++){
positions[i][0] = this.commentStarts[i];
positions[i][1] = this.commentStops[i];
}
return positions;
}
@Override
public void (boolean parsingCompilationUnit) {
super.initialize(parsingCompilationUnit);
this.commentPtr = -1;
}
@Override
public void () {
super.initialize();
this.commentPtr = -1;
}
@Override
public void () {
this.scanner = new Scanner(
false ,
false ,
this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore ,
this.options.sourceLevel ,
this.options.taskTags,
this.options.taskPriorities,
this.options.isTaskCaseSensitive,
this.options.enablePreviewFeatures );
}
private void (int start, int end) {
for (int i=start; i<=end; i++) {
if (this.scanner.commentPtr < i) break;
int scannerStart = this.scanner.commentStarts[i]<0 ? -this.scanner.commentStarts[i] : this.scanner.commentStarts[i];
int commentStart = this.commentPtr == -1 ? -1 : (this.commentStarts[this.commentPtr]<0 ? -this.commentStarts[this.commentPtr] : this.commentStarts[this.commentPtr]);
if (commentStart == -1 || scannerStart > commentStart) {
int stackLength = this.commentStarts.length;
if (++this.commentPtr >= stackLength) {
System.arraycopy(
this.commentStarts, 0,
this.commentStarts = new int[stackLength + CommentIncrement], 0,
stackLength);
System.arraycopy(
this.commentStops, 0,
this.commentStops = new int[stackLength + CommentIncrement], 0,
stackLength);
}
this.commentStarts[this.commentPtr] = this.scanner.commentStarts[i];
this.commentStops[this.commentPtr] = this.scanner.commentStops[i];
}
}
}
@Override
protected void () {
pushOnCommentsStack(0, this.scanner.commentPtr);
super.resetModifiers();
}
public void () {
this.commentPtr = -1;
Arrays.fill(this.commentStarts, 0);
Arrays.fill(this.commentStops, 0);
Arrays.fill(this.scanner.commentStops, 0);
Arrays.fill(this.scanner.commentStarts, 0);
Arrays.fill(this.scanner.commentTagStarts, 0);
this.scanner.commentPtr = -1;
this.scanner.lastCommentLinePosition = -1;
}
}