File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -375,7 +375,7 @@ protected boolean commentParse() {
375375 pushText (this .textStart , textEndPosition );
376376 }
377377 refreshInlineTagPosition (previousPosition );
378- } else if ((this .source [this .index ] == '\n' || this .source [this .index ] == '\r' ) && previousChar == ' ' ) {
378+ } else if ((this .source [this .index ] == '\n' || this .source [this .index ] == '\r' ) && ! shouldAbortDueToJavadocTag ( previousPosition ) ) {
379379 pushText (previousPosition , this .index ); // Enables adding closing curly brackets to node elements in Javadoc when the TagElement spans multiple lines
380380 }
381381 if (!isFormatterParser && !treatAsText && (!this .inlineReturn || this .inlineReturnOpenBraces <= 0 ))
@@ -560,6 +560,35 @@ protected boolean commentParse() {
560560 return validComment ;
561561 }
562562
563+ /**
564+ * Scans backwards from current position to find if `{ @` pattern exists
565+ * before a newline. Returns true immediately when pattern is found.
566+ */
567+ protected boolean shouldAbortDueToJavadocTag (int currPos ) {
568+ int pos = currPos - 1 ;
569+ if (this .source == null || pos < 0 || pos >= this .source .length ) {
570+ return false ;
571+ }
572+
573+ while (pos >= 0 ) {
574+ char currentChar = this .source [pos ];
575+
576+ // If encounter a newline, stop scanning
577+ if (currentChar == '\n' || currentChar == '\r' ) {
578+ pos --;
579+ break ;
580+ }
581+
582+ // Check for pattern
583+ if (currentChar == '@' && pos > 0 && this .source [pos - 1 ] == '{' ) {
584+ return true ;
585+ }
586+
587+ pos --;
588+ }
589+ return false ;
590+ }
591+
563592 protected void addFragmentToInlineReturn () {
564593 // do nothing
565594 }
You can’t perform that action at this time.
0 commit comments