Bug 216875

Summary: [search] Field- and LocalVariableReferenceMatch confuse read/write for field access on LHS
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.4   
Target Milestone: 3.4 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

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.