Community
Participate
Working Groups
Using M9 build I200405180816. While verifying bug 56449, I noticed that it was not possible to make this distinction between Javadoc and Code for package references matches... See also bug 54962...
Does it require an API change ?
Yes, it would imply to modify existing constructor on PackageReferenceLocator to add boolean parameter which shows whether the location is inside a doc comment or not. So, existing constructor: /** * Creates a new package reference match. * * @param enclosingElement the inner-most enclosing member that references this package * @param accuracy one of A_ACCURATE or A_INACCURATE * @param offset the offset the match starts at, or -1 if unknown * @param length the length of the match, or -1 if unknown * @param participant the search participant that created the match * @param resource the resource of the element */ public PackageReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) { super(enclosingElement, accuracy, offset, length, participant, resource); } would become: /** * Creates a new package reference match. * * @param enclosingElement the inner-most enclosing member that references this package * @param accuracy one of A_ACCURATE or A_INACCURATE * @param offset the offset the match starts at, or -1 if unknown * @param length the length of the match, or -1 if unknown * @param insideDocComment whether the match is inside a doc comment * @param participant the search participant that created the match * @param resource the resource of the element */ public PackageReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) { super(enclosingElement, accuracy, offset, length, participant, resource); this.insideDocComment = insideDocComment; }
Created attachment 11006 [details] Implementation for new API on PackageReferenceMatch
Created attachment 11007 [details] Test cases modification to validate this new API
Requested PMC approval: All reference search matches do record the fact they are located inside javadoc, except for package references. We would like to have them all be consistent and take the insideDocComment flag as an argument in their constructor. We are the sole client to this API (used to construct search results for package references). If we do not fix it, then we don't have a way to record this information as our API is quite minimalistic and does not provide setter methods.
We will actually propose a bigger change than originally anticipated so as to make the API more useable (after talking with Jim). Plan is to: - promote the insideDocComment flag onto SearchMatch itself - add setters for all SearchMatch properties - add insideDocComment argument to PackageReferenceMatch constructor (for being consistent with other refs). Rational for setters & promotion is that more setters allow other participant to better interoperate with delegate client search results (think JSP delegating to Java). And in certain languages, there could be some declarations inside doc comments, where in Java it doesn't occur by default (this is why only our reference match constructors are equipped with this flag by default). Frederic - pls prepare enhanced patch asap.
Created attachment 11145 [details] Implementation for new version of API changes Jeem, please verify Javadoc on SearchMatch setters I've added and modify if you think there are some information missing. Thx.
Created attachment 11147 [details] Modified test case for last implementation Note that API changes didn't really change the test case. It's just a refresh due to HEAD changes since last patch...
Created attachment 11153 [details] Improved implementation of new version of API change Frederic, I made the following minor changes to your patch: - moved isInsideDocComment() to SearchMatch and made final - made all new SearchMatch getters and setters final - changed specs of setters to match getters with respect to null
These API changes approved for inclusion in 3.0 RC1.
Thanks Jeem for your buddy check and last improvements. All tests pass (jdt-core+jdt-ui) => released in HEAD.
Verified in 200405281200 that isInsideDocComment has been promoted on SearchMatch