Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368219

Summary: PatternRule does not always honor fBreaksOnEOF
Product: [Eclipse Project] Platform Reporter: Dennis Hendriks <dh_tue>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.8   
Target Milestone: 3.8 M5   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test case. none

Description Dennis Hendriks CLA 2012-01-10 03:01:48 EST
Build Identifier: M20110909-1335 (Eclipse 3.7.1)

In my language I use the org.eclipse.jface.text.rules.MultilineRule to detect /* ... */ comments, and now /** just before the end of the file is detected as multiline comment... (I have no javadoc style /** ... */ comments)

I investigated why this happens, and found out that the org.eclipse.jface.text.rules.PatternRule class does not always honor the fBreaksOnEOF field. In the endSequenceDetected method, the sequenceDetected method is called several times with true as third and final argument. This eofAllowed argument "indicates whether EOF terminates the pattern". I belive the value true should not be provided. Instead the value of the fBreaksOnEOF field should be provided as argument.


Reproducible: Always

Steps to Reproduce:
1. Use a MultilineRule for /* ... */ comments for syntax highlighting in a text editor.
2. Observe how /** just before end of file is detected as comment.
Comment 1 Dani Megert CLA 2012-01-10 03:10:18 EST
Can you either provide steps to reproduce it using the Eclipse SDK (e.g. in a Java file) or provide a test case? Thanks.
Comment 2 Dennis Hendriks CLA 2012-01-10 08:11:02 EST
Created attachment 209255 [details]
Test case.

This attachment contains a Java plug-in project with a test editor. Extract the files and import the project into Eclipse. Then launch a sub-Eclipse instance, and import the project there as well. Open the *.test files in the test_files directory to confirm the bug. That is, for test1.test the /** is highlighted in red, as a comment, because it is immediately followed by end of file. In test2.test however, I added a newline after it, and you see that it is no longer highlighted.
Comment 3 Dani Megert CLA 2012-01-10 12:01:48 EST
Fixed in master: 8c2cb21c418afbdf3849e3a0c31b0b67aab853cf
Comment 4 Dani Megert CLA 2012-01-11 08:59:40 EST
Also added test case in master: ffc8144b38d604904081eaba5ed19ab3065646f3
Comment 5 Dani Megert CLA 2013-06-04 09:43:54 EDT
The fix caused a regression (see bug 409538).