Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.309 diff -u -r1.309 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 9 Jun 2005 14:03:38 -0000 1.309 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 14 Jun 2005 18:45:59 -0000 @@ -863,11 +863,15 @@ if (this.modifiersSourceStart < 0) this.modifiersSourceStart = this.scanner.startPosition; } +public void flushComments() { + this.scanner.commentPtr = -1; +} public void checkComment() { // discard obsolete comments while inside methods or fields initializer (see bug 74369) - if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) { - flushCommentsDefinedPriorTo(this.endStatementPosition); + if (this.nestedMethod[this.nestedType] != 0 && this.scanner.commentPtr >= 0) { + flushComments(); + return; } int lastComment = this.scanner.commentPtr; Index: model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java,v retrieving revision 1.15 diff -u -r1.15 DocumentElementParser.java --- model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java 31 May 2005 11:47:48 -0000 1.15 +++ model/org/eclipse/jdt/internal/compiler/DocumentElementParser.java 14 Jun 2005 18:45:59 -0000 @@ -73,6 +73,11 @@ */ public void checkComment() { + // discard obsolete comments while inside methods or fields initializer (see bug 74369) + if (this.nestedMethod[this.nestedType] != 0 && this.scanner.commentPtr >= 0) { + flushComments(); + return; + } /* persisting javadoc positions */ pushOnIntArrayStack(this.getJavaDocPositions()); boolean deprecated = false; Index: model/org/eclipse/jdt/internal/compiler/SourceElementParser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java,v retrieving revision 1.48 diff -u -r1.48 SourceElementParser.java --- model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 11 May 2005 21:08:50 -0000 1.48 +++ model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 14 Jun 2005 18:45:59 -0000 @@ -112,11 +112,11 @@ this.localDeclarationVisitor = new LocalDeclarationVisitor(); } } - public void checkComment() { // discard obsolete comments while inside methods or fields initializer (see bug 74369) - if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) { - flushCommentsDefinedPriorTo(this.endStatementPosition); + if (this.nestedMethod[this.nestedType] != 0 && this.scanner.commentPtr >= 0) { + flushComments(); + return; } int lastComment = this.scanner.commentPtr; Index: model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java,v retrieving revision 1.15 diff -u -r1.15 CommentRecorderParser.java --- model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java 18 May 2005 15:28:34 -0000 1.15 +++ model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java 14 Jun 2005 18:45:59 -0000 @@ -42,8 +42,9 @@ public void checkComment() { // discard obsolete comments while inside methods or fields initializer (see bug 74369) - if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) { - flushCommentsDefinedPriorTo(this.endStatementPosition); + if (this.nestedMethod[this.nestedType] != 0 && this.scanner.commentPtr >= 0) { + flushComments(); + return; } boolean deprecated = false; boolean checkDeprecated = false; @@ -141,7 +142,12 @@ } return unit; } - + public void flushComments() { + final int lastCommentIndex = this.scanner.commentPtr; + if (lastCommentIndex < 0) return; // no comment + pushOnCommentsStack(0, lastCommentIndex); // store comment before flushing them + this.scanner.commentPtr = -1; + } /* (non-Javadoc) * Save all source comments currently stored before flushing them. * @see org.eclipse.jdt.internal.compiler.parser.Parser#flushCommentsDefinedPriorTo(int)