Bug 362509 - [1.7] Improve AST recovery for TryStatement resource with missing type
Summary: [1.7] Improve AST recovery for TryStatement resource with missing type
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 362510
  Show dependency tree
 
Reported: 2011-10-31 12:25 EDT by Markus Keller CLA
Modified: 2020-02-22 11:31 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-10-31 12:25:41 EDT
3.8 M3

Improve AST recovery for a TryStatement where the resource is missing a declared type. This is not a dup of bug 340837 (that one is about a complete absence of a TryStatement node).

    void foo() throws IOException {
        FileReader reader0 = new FileReader("file");
        writer0 = new FileWriter("out");

        try (FileReader reader = new FileReader("file");
                writer = new FileWriter("out")) {
            int ch;
            while ((ch = reader.read()) != -1) {
                System.out.println(ch);
            }
        }
    }

The 'writer = new FileWriter("out")' currently gets these errors on the second (incorrect) resource declaration:
- writer cannot be resolved to a type
- Syntax error on token "writer", VariableDeclaratorId expected after this

=> Would better be 'writer cannot be resolved to a variable', like for 'writer0'.

The AST would better also consider 'writer' as variable name and the type as missing.

Note: If I remove the type of 'FileReader reader' as well, then the recovery completely breaks down, and TryStatements has no resources any more.
Comment 1 Eclipse Genie CLA 2020-02-22 11:31:29 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.