Bug 498433 - Templates like ${enclosing_type} can't resolve context in conditional breakpoints editor
Summary: Templates like ${enclosing_type} can't resolve context in conditional breakpo...
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks: 71020
  Show dependency tree
 
Reported: 2016-07-25 09:29 EDT by Markus Keller CLA
Modified: 2024-04-22 14:16 EDT (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 2016-07-25 09:29:50 EDT
Try to insert the "systrace" template in a conditional breakpoint expression. It will just yield this, instead of properly filling in the context variables:

System.out.println("enclosing_type.enclosing_method()");

Expected for a breakpoint in p.q.MyType#foo(): 

System.out.println("MyType.foo()");

The problem is that org.eclipse.jdt.internal.corext.template.java.CompilationUnitContextType.EnclosingJavaElement#resolve(TemplateContext) is called with a JavaContext whose fCompilationUnit is null, so the context is lost.

org.eclipse.jdt.internal.debug.ui.contentassist.JavaDebugContentAssistProcessor#computeCompletionProposals(ITextViewer, int) probably needs to pass a non-null CU when calling TemplateEngine#complete(ITextViewer, int, ICompilationUnit).

The hard part is that this probably cannot be the actual ICompilationUnit, because that
- would allow template variables like the ImportsResolver to modify a CU that should not be modified, and
- would not work for breakpoints in class files with attached source

JavaDebugContentAssistProcessor#computeCompletionProposals(..) already knows the enclosing "IType type". This could be a starting point for passing on the required context, and TemplateContext#fReadOnly could help avoiding unwanted non-local edits. Another solution could be to actually create a new working copy and then disregard non-local changes.
Comment 1 Sarika Sinha CLA 2016-12-21 05:30:27 EST
(In reply to Markus Keller from comment #0)
I tried passing the Compilation Unit for the document( forgetting about having working copy and throwing the changes) for once, but still I did get the resolved type and method.
org.eclipse.jdt.internal.corext.template.java.CompilationUnitContextType.EnclosingJavaElement.resolve(TemplateContext)
does not get the element.

Where as While working on Tracepoint creation Bug 71020, when passing the Compilation unit and just applying the context to resolve the template, it gets resolved.
Comment 2 Sarika Sinha CLA 2018-04-24 05:02:18 EDT
Moving out.
Comment 3 Eclipse Genie CLA 2020-05-09 15:03:41 EDT
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.
Comment 4 Sarika Sinha CLA 2020-05-11 00:50:22 EDT
Still valid. If someone wants to work on this?
Comment 5 Eclipse Genie CLA 2022-05-02 17:33:58 EDT
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.

If you have further information on the current state of the bug, please add it. 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.
Comment 6 Eclipse Genie CLA 2024-04-22 14:16:23 EDT
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.

If you have further information on the current state of the bug, please add it. 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.