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 258679 - Support modules in Js
Summary: Support modules in Js
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: PC Linux
: P1 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks: 242387
  Show dependency tree
 
Reported: 2016-04-06 10:59 UTC by Petr Pisl
Modified: 2016-06-15 19:24 UTC (History)
1 user (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Go To Imported File (41.95 KB, image/png)
2016-04-11 12:35 UTC, Petr Pisl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisl 2016-04-06 10:59:44 UTC
ECMA 6 Script brings possibility write modules in JavaScript. NetBeans has to support writing modules. Mainly import expression:

https://developer.mozilla.org/cs/docs/Web/JavaScript/Reference/Statements/import

and export expression:

https://developer.mozilla.org/cs/docs/Web/JavaScript/Reference/Statements/export

NetBeans has to handle imports in the right way (creating variables in the model, mark occurrences, code completion, coloring etc.). The bulk of these things has to be done for export as well.
Comment 1 Petr Pisl 2016-04-06 11:04:42 UTC
This task depends on the changes in the parser. Currently grall parser doesn't handle import and export expressions in the sufficient way. Needs to be changed there.
Comment 2 Petr Pisl 2016-04-11 12:35:01 UTC
Created attachment 159207 [details]
Go To Imported File

User can use CTRL+click funtinality to navigate into the imported file. When the mouse cursor is over the imported file string and user press down CTRL, then the string is changed to the link. And when a user click on the link and NetBeans are able to find such imported file, then the file is opened.
Comment 3 Petr Hejl 2016-06-15 08:15:07 UTC
Petre, could this be closed as resolved?
Comment 4 dusty 2016-06-15 10:18:20 UTC
I just tested build #2276 and there are still problems with modules.

This code gives error on the second line:

import {LooseParser} from "./state"
import {isDummy} from "./parseutil"

While the error goes away if I add a semicolon on the end of the first line, but semicolons are optional in ES6
Comment 5 dusty 2016-06-15 10:19:20 UTC
(That was an excerpt of the file "expression.js" inside the "acorn" package)
Comment 6 Petr Pisl 2016-06-15 16:06:01 UTC
IMHO according the specification http://www.ecma-international.org/ecma-262/6.0/#sec-imports , there has to be the semicolon in import and export expressions. 

To PetrH.: Yes, this task can be close, if something doesn't work, new defect should be created.
Comment 7 dusty 2016-06-15 18:51:38 UTC
Petr,
according to the specs, there are rules for "Automatic Semicolon Insertion".
Citing from http://www.ecma-international.org/ecma-262/6.0/#sec-automatic-semicolon-insertion 

[...]
Certain ECMAScript statements (empty statement, let, const, import, and export declarations, variable statement, expression statement, debugger statement, continue statement, break statement, return statement, and throw statement) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. For convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations

[...]
When, as a Script or Module is parsed from left to right, a token (called the offending token) is encountered that is not allowed by any production of the grammar, then a semicolon is automatically inserted before the offending token if one or more of the following conditions is true:

    The offending token is separated from the previous token by at least one LineTerminator.
[...]

And I think this is the case I reported above (the statements are separated from one LineTerminator).
Comment 8 dusty 2016-06-15 18:53:02 UTC
I reopened this bug, but maybe you prefer me to create another one about the automatic semicolon insertion?
Comment 9 Petr Pisl 2016-06-15 19:17:50 UTC
It looks like you convinced me. I will try to discuss this with parser group. And you are right, this should be treated as defect and separated from this task. Thanks
Comment 10 dusty 2016-06-15 19:24:30 UTC
Done, thanks!

https://netbeans.org/bugzilla/show_bug.cgi?id=262449