Bug 216875 - [search] Field- and LocalVariableReferenceMatch confuse read/write for field access on LHS
Summary: [search] Field- and LocalVariableReferenceMatch confuse read/write for field ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-29 04:19 EST by Markus Keller CLA
Modified: 2008-02-05 08:05 EST (History)
0 users

See Also:


Attachments
Proposed patch (14.94 KB, patch)
2008-01-30 12:43 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 Markus Keller CLA 2008-01-29 04:19:52 EST
I20080122-1600, probably been like this for a long time

FieldReferenceMatch and LocalVariableReferenceMatch confuse isReadAccess() and isWriteAccess() for qualifier of field access expressions on the leftHandSide of an assignment expression.

public class Try {
    int fField;

    void m() {
        Try t; // refs to t
        t = new Try();
        t.fField = 42; // match for t is writeAccess, should be readAccess
    }
}

class Wrapper {
    Try fWrapped; // refs to fWrapped

    void wrapper() {
        fWrapped.fField = 12; // match for fWrapped is writeAccess
    }
}
Comment 1 Frederic Fusier CLA 2008-01-29 07:10:28 EST
In fact it seems that the 't' and 'fWrapped' are neither readAccess nor writeAccess.

Searching for write access on t gives only one match on line 't = new Try();' (correct); but searching for read access does not give any match (wrong).

Searching for 'fWrapped' write access does not give any match (correct), but searching for read access also does not give any match (wrong).

I'll investigate...
Comment 2 Markus Keller CLA 2008-01-29 08:17:28 EST
(In reply to comment #1)
It also depends on how you perform the search. If I use Search > Write Access > Workspace, I can confirm the findings from comment 1.

However, when I search for all references to 't' or 'fWrapped' and then use the Read and Write filters in the search result view, I see that reference search find all references, but categorizes them wrongly (see //comments in comment 0)
Comment 3 Frederic Fusier CLA 2008-01-30 12:43:15 EST
Created attachment 88312 [details]
Proposed patch
Comment 4 Frederic Fusier CLA 2008-01-30 12:43:40 EST
Released for 3.4M5 in HEAD stream.
Comment 5 Maxime Daniel CLA 2008-02-05 08:05:00 EST
Verified for 34M5 using I20080204-0010 build.