Community
Participate
Working Groups
Build Identifier: 20110916-0149 The spec says: try ResourceSpecification Block Catches_opt Finally_opt "The scope of a variable declared in a resource specification of a try-with-resources statement (ยง14.20) is from the declaration rightward over the remainder of the resource specification and the entire Block associated with the try." If I do a Quick Fix in the catch/finally block on "is", the resource is available for completion. The variable shouldn't be recognized in the catch/finally block since it is out of scope. Happily, the code doesn't compile when completed, but Quick Fix shouldn't recognize the variable anyway. Reproducible: Always Steps to Reproduce: try (InputStream is = new FileInputStream("C:\\MSG.OUT")) { // empty } catch (IOException e) { is<-- CTRL+1 here } finally { is<-- CTRL+1 here }
Do you mean CTRL-SPACE (content assist)? That's what you'll use to complete code right? I can see that 'is' is siggested in the catch block and thats a content assist bug. Let me know if you intend to report something else.
Yes, the error is from Content Assist (CTRL-SPACE). Thanks for the correction.
There seems to be another problem which I think is related to this behavior. Consider the following block try{ }catch(Exception e){ }finally{ <CTRL+SPACE> e } The codes assist invocation in the finally block incorrectly shows Exception variable e available in the finally block. I think the problem is somewhere in the buildInitialRecoveryState method of org.eclipse.jdt.internal.codeassist.impl.AssistParser. I couldn't continue further with the investigation. Is there some documentation as to how Eclipse AST parser works?
Code Completion/Content Assist also shows the resources where it shouldn't be available. I have posted a question on SO asking about this, and answers/resources confirm this shouldn't be the case. http://stackoverflow.com/questions/18691352 Since we already have this bug, I shan't file a new one. But please look at the question for screenshots.
Anirban, I am assigning the bug to you. You can perhaps look at after the Java 8 support is complete.
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.