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 230123 - foreach and with completion issues
Summary: foreach and with completion issues
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: Knockout (show other bugs)
Version: 7.4
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Petr Hejl
URL:
Keywords:
Depends on: 230501
Blocks:
  Show dependency tree
 
Reported: 2013-05-22 14:16 UTC by Marek Fukala
Modified: 2013-06-18 07:19 UTC (History)
2 users (show)

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 Marek Fukala 2013-05-22 14:16:11 UTC
Basically no completion is offered for the active binding context object fields/methods.

Try to invoke completion in the following example:

1) the foreach part - the completion for "text" binding value should provide the fields/methods of the active binding context object (Clobrda as the item of the lidickove array), which it doesn't. It offers no items for no prefix and offers incorrect items (fields of the root model) if one uses $data implicit variable.

2) the with part - the completion for "text" binding value should provide the fields/methods of the active binding context object (Clobrda), which it doesn't. It offers no items for no prefix and no items if one uses $data implicit variable.

Please take this as a description of the behaviour I would expect. I understand that at least some parts may not be easily doable.
-----------------------------------------------------

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300italic,400,700,900" rel="stylesheet" />
        <link href="styles/expenses.css" rel="stylesheet"/>
        <style>
            .jouda { color: red; }
            .king { color: green; }
        </style>
        <script src="libs/knockout-2.2.1.js"></script>
        <script>
            function Bulici() {
                this.pepa = new Clobrda("pepa");
                this.lidickove = [ this.pepa, new Clobrda("jozin")];
            }
            function Clobrda(jmeno) {
                this.jmeno = jmeno;
            }
            function init() {
                ko.applyBindings(new Bulici());
            }
        </script>
    </head>
    <body onload="init();">
        <span data-bind="foreach: lidickove ">
            <div data-bind="text: jmeno, css: jmeno == 'pepa' ? 'jouda' : 'king'"></div>
        </span>
        <hr>
        <span data-bind="with: pepa">
            <div data-bind="text: jmeno"></div>
        </span>
    </body>
</html>
Comment 1 Marek Fukala 2013-05-22 14:17:24 UTC
To reproduce the issue you need to remove the rest of the code to the point where you want to test the completion so the "auto-learning-completion" won't provide the items seen in the code.
Comment 2 Petr Hejl 2013-06-12 21:30:59 UTC
1) Depends on #230501.
2) I have a patch for that in my local repo. Though there might be some more minor issues in type resolution is core JS module.
Comment 3 Petr Hejl 2013-06-14 10:20:02 UTC
2) fixed in web-main 75d46ba1a613
Comment 4 Petr Hejl 2013-06-14 13:19:19 UTC
Theoretically this should be fixed. However in this Marek's sample the array is not properly resolved afaik.

The relevant part of virtual source is (^) for cursor:
(function() {
    var $root = ko.$bindings;
    var $parent = ko.$bindings;
    var $parents = [ko.$bindings];
    var $index = 0;
    with (ko.$bindings) {
        var $data = lidickove[0];
        with (lidickove[0]) {
            (^);
        }
    }
});

The properties of lidickove[0] is not offered in cc.

The similar case with "with" works ok:
(function() {
    var $root = ko.$bindings;
    var $parent = ko.$bindings;
    var $parents = [ko.$bindings];
    with (ko.$bindings) {
        var $data = pepa;
        with (pepa) {
            (^);
        }
    }
});
Comment 5 Petr Hejl 2013-06-14 13:22:10 UTC
Tests added - web-main c012b37bceb4.
Comment 6 Quality Engineering 2013-06-15 03:03:31 UTC
Integrated into 'main-golden', will be available in build *201306142301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/75d46ba1a613
User: Petr Hejl <phejl@netbeans.org>
Log: #230123 - foreach and with completion issues
Comment 7 Petr Hejl 2013-06-17 07:19:24 UTC
It looks like the problem is in SemiTypeResolverVisitor which still does not support arrays.
Comment 8 Petr Hejl 2013-06-17 07:48:41 UTC
I'll try to fix it.
Comment 9 Petr Hejl 2013-06-18 07:19:57 UTC
Hopefully should be fixed in web-main.
9189cb4092df
a4a23ce73a2e
59ff80604f60