Skip to content

Commit 7eb066d

Browse files
committed
Performance degradation with lombok
1 parent 88859c2 commit 7eb066d

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,9 @@ else if (c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE) {
18461846
}
18471847
} //-----------------end switch while try--------------------
18481848
catch (IndexOutOfBoundsException e) {
1849-
if (this.tokenizeWhiteSpace && (whiteStart != this.currentPosition - 1)) {
1849+
if (this.currentPosition < 0) {
1850+
this.currentPosition = this.source.length - 1;
1851+
} else if (this.tokenizeWhiteSpace && (whiteStart != this.currentPosition - 1)) {
18501852
// reposition scanner in case we are interested by spaces as tokens
18511853
this.currentPosition--;
18521854
this.startPosition = whiteStart;

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,10 @@ public int lastTrailingCommentIndex(ASTNode node) {
751751
* @since 3.0
752752
*/
753753
void initCommentMapper(Scanner scanner) {
754-
this.commentMapper = new DefaultCommentMapper(this.optionalCommentTable);
755-
this.commentMapper.initialize(this, scanner);
754+
if (this.optionalCommentTable != null && this.optionalCommentTable.length > 0) {
755+
this.commentMapper = new DefaultCommentMapper(this.optionalCommentTable);
756+
this.commentMapper.initialize(this, scanner);
757+
}
756758
}
757759

758760
@Override

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultCommentMapper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,18 @@ class CommentMapperVisitor extends DefaultASTVisitor {
562562
@Override
563563
protected boolean visitNode(ASTNode node) {
564564

565+
// skip generated node - https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4712
566+
if (node.getStartPosition() <= 0 && node.getLength() <= 0) {
567+
return false;
568+
}
565569
// Get default previous end
566570
ASTNode parent = node.getParent();
567571
int previousEnd = parent.getStartPosition();
568572

569573
// Look for sibling node
570574
ASTNode sibling = parent == this.topSiblingParent ? (ASTNode) this.siblings[this.siblingPtr] : null;
571-
if (sibling != null) {
575+
// skip generated node - https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4712
576+
if (sibling != null && sibling.getLength() > 0) {
572577
// Found one previous sibling, so compute its trailing comments using current node start position
573578
try {
574579
previousEnd = storeTrailingComments(sibling, node.getStartPosition(), false, this.parentLineRange[this.siblingPtr]);
@@ -624,7 +629,8 @@ protected void endVisitNode(ASTNode node) {
624629

625630
// Look if a child node is waiting for trailing comments computing
626631
ASTNode sibling = this.topSiblingParent == node ? (ASTNode) this.siblings[this.siblingPtr] : null;
627-
if (sibling != null) {
632+
// skip generated node - https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4712
633+
if (sibling != null && sibling.getLength() > 0) {
628634
try {
629635
storeTrailingComments(sibling, node.getStartPosition()+node.getLength()-1, true, this.parentLineRange[this.siblingPtr]);
630636
} catch (Exception ex) {

0 commit comments

Comments
 (0)