Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 81784 - [comments] Need API to know whether a source position is inside a comment or not
Summary: [comments] Need API to know whether a source position is inside a comment or not
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 41302
  Show dependency tree
 
Reported: 2004-12-22 09:18 EST by Frederic Fusier CLA
Modified: 2007-06-21 07:55 EDT (History)
1 user (show)

See Also:


Attachments
Solution 1) changes without modifying IScanner (1.67 KB, patch)
2004-12-22 09:28 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2004-12-22 09:18:38 EST
In certain circumstances (see bug 41302), it could be interesting to know
whether a source position is inside a comment or not.

We currently have two solutions to offer this kind of information:
1) Directly from scanner (ie. IScanner and/or PublicScanner)
2) Using DOM AST Comment nodes (ie. DefaultCommentMapper through CompilationUnit
public access methods...)
Comment 1 Frederic Fusier CLA 2004-12-22 09:19:40 EST
Of course using solution 1) and modifying IScanner interface would break
existing clients of this interface...
Comment 2 Frederic Fusier CLA 2004-12-22 09:28:21 EST
Created attachment 16808 [details]
Solution 1) changes without modifying IScanner

Add getLastCommentEnd() to Scanner and PublicScanner in JDT/Core land.
Modify CommentAnalyser.checkEnd(IScanner,int) as follow:
private boolean checkEnd(IScanner scanner, int position) {
	return scanner.getCurrentTokenStartPosition() <= position &&
	    position < ((PublicScanner)scanner).getLastCommentEnd();
}

These changes fix bug 41302 and avoid to modify IScanner not to break existing
clients but sounds like a hack...

I have to figure out what could be solution 2)....
Comment 3 Frederic Fusier CLA 2005-03-14 14:53:44 EST
I'll see if this is feasible for M6. Otherwise defer to next release
Comment 4 Frederic Fusier CLA 2005-03-16 11:03:39 EST
Unfortunately, defer post 3.1
Comment 5 Frederic Fusier CLA 2007-06-21 07:53:07 EDT
Reopen as LATER is deprecated...
Comment 6 Frederic Fusier CLA 2007-06-21 07:55:44 EDT
WONTFIX as I cannot reproduced bug 41302 with latest 3.3 RC4...