This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 135864 - scopeFor(int pos) in TreeUtilities doesn't work for JavaFX
Summary: scopeFor(int pos) in TreeUtilities doesn't work for JavaFX
Status: VERIFIED FIXED
Alias: None
Product: javafx
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: David Strupl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-27 11:30 UTC by Alexey Butenko
Modified: 2008-09-10 12:13 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Butenko 2008-05-27 11:30:54 UTC
This method shoud be rewritten because it is uses getKind() which is suitable for Java code and will return OTHER for JavaFX code in most cases.
Comment 1 David Strupl 2008-05-28 14:17:12 UTC
I have simplified the method in this commit:

564:8b279d346148

Please try it - if it will not work please supply a test case where it shows that it doesn't work and reopen or create a
new issue. 

Thanks, David
Comment 2 David Strupl 2008-05-28 14:18:05 UTC
Marking as fixed for now.
Comment 3 Alexey Butenko 2008-06-10 07:16:05 UTC
I've filled issue on compiler http://openjfx.java.sun.com/jira/browse/JFXC-1255
Comment 4 Alexey Butenko 2008-06-16 12:30:20 UTC
It seems that this method should be rewritten according to the same in Java, because
after http://openjfx.java.sun.com/jira/browse/JFXC-1255 issue was fixed, 
I get following exception when get scope for offset in JFXBlockExpression.

java.lang.UnsupportedOperationException: JFXBlockExpression support not implemented
        at com.sun.tools.javafx.tree.JFXExpression.accept(JFXExpression.java:81)
        at com.sun.tools.javac.tree.TreeCopier.copy(TreeCopier.java:60)
        at com.sun.tools.javafx.api.JavafxcTrees$Copier.copy(JavafxcTrees.java:346)
        at com.sun.tools.javafx.api.JavafxcTrees.getAttrContext(JavafxcTrees.java:272)
        at com.sun.tools.javafx.api.JavafxcTrees.getScope(JavafxcTrees.java:204)
        at org.netbeans.api.javafx.source.TreeUtilities.scopeFor(TreeUtilities.java:279)
        at org.netbeans.modules.debugger.javafx.projects.EditorContextImpl$15.run(EditorContextImpl.java:1761)
        at org.netbeans.modules.debugger.javafx.projects.EditorContextImpl$15.run(EditorContextImpl.java:1731)
        at org.netbeans.api.javafx.source.JavaFXSource.runUserActionTask(JavaFXSource.java:353)
        at org.netbeans.modules.javafx.source.scheduler.CompilationJob.runWhenScanFinished(CompilationJob.java:268)
        at org.netbeans.api.javafx.source.JavaFXSource.runWhenScanFinished(JavaFXSource.java:571)
        at org.netbeans.modules.debugger.javafx.projects.EditorContextImpl.getCurrentElement(EditorContextImpl.java:1728)
        at org.netbeans.modules.debugger.javafx.projects.EditorContextImpl.getCurrentElement(EditorContextImpl.java:1688)
        at org.netbeans.modules.debugger.javafx.projects.EditorContextImpl.getCurrentClassName(EditorContextImpl.java:492)
        at
org.netbeans.modules.debugger.javafx.ui.actions.ToggleMethodFieldBreakpointAction.submitFieldOrMethodBreakpoint(ToggleMethodFieldBreakpointAction.java:136)
        at
org.netbeans.modules.debugger.javafx.ui.actions.ToggleMethodFieldBreakpointAction.actionPerformed(ToggleMethodFieldBreakpointAction.java:126)
        at org.netbeans.editor.GlyphGutter$GutterMouseListener.mouseClicked(GlyphGutter.java:738)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
        at java.awt.Component.processMouseEvent(Component.java:6044)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5806)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Comment 5 Alexey Butenko 2008-06-16 12:32:30 UTC
code is below and position is 77:
package javafxapplication36;

class Test {
    function getNumber():Number {
        var a = 10;
        var b = 20;
        var c = a + b;
        return c;
    }
}

var test = Test {};
var d = test.getNumber();
Comment 6 David Strupl 2008-06-20 10:40:39 UTC
I am sorry but I am marking this as fixed again. The method in the TreeUtilities reads

public Scope scopeFor(int pos) {
        TreePath path = pathFor(pos);
        Scope scope = info.getTrees().getScope(path);
        return scope;
    }

which is IMHO correct. The fact that it fails with some exception in the compiler would be a different issue that should
be filed against the compiler.

Also please note that the fix you are talking about is applied to the trunk of the javafxc but we use branch
technology-preview-1 for now and the fix might not be there ...

Please file an issue to JIRA with a simple test case for them. The text case can be e.g. similar to e.g. this one
https://openjfx-compiler.dev.java.net/svn/openjfx-compiler/trunk/test/src/com/sun/tools/javafx/api/JFXC1205Test.java
where you would copy/paste and adapt methods scopeFor and pathFor from our TreeUtilities and reproduce the excpeption
with just the compiler ...

But I am afraid they will fix it only for the trunk and not for the preview so you will not be able to use the methods
in the preview. Please put me on Cc: on the JIRA issue. Thanks.
Comment 7 Alexey Butenko 2008-09-10 12:13:36 UTC
verified