-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Porting tern analysis of JS code to Node. #11948
Conversation
Tagging @nethip @abose @zaggino @ryanstewart @petetnt |
.gitmodules
Outdated
@@ -10,6 +10,9 @@ | |||
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/tern"] | |||
path = src/extensions/default/JavaScriptCodeHints/thirdparty/tern | |||
url = https://github.com/marijnh/tern.git | |||
[submodule "src/extensions/default/JavaScriptCodeHints/node/node_modules/tern"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two tern submodules. Can this be unified?
@abose WIP! Removed the old reference now. |
Would the path change affect the extensions? |
gitmodule mapping changes.
@swmitra Have you done any initial performance benchmarks against the previous implementation yet 📊? I can try and review this ASAP, been a bit busy as of late |
.gitmodules
Outdated
@@ -25,3 +22,9 @@ | |||
[submodule "src/extensions/default/JSLint/thirdparty/jslint"] | |||
path = src/extensions/default/JSLint/thirdparty/jslint | |||
url = https://github.com/peterflynn/JSLint.git | |||
[submodule "src/extensions/default/JavaScriptCodeHints/node/node_modules/acorn"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooc, would not be better to create a package.json
in src/extensions/default/JavaScriptCodeHints/node
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swmitra
we don't need submodules anymore, npm install
will install dependencies defined in src/extensions/default/JavaScriptCodeHints/package.json
, please remove
@swmitra Do you think it would be possible / easier to add the reading of a |
Sorry for late reply. @petetnt Yes I tried to benchmark the performance to have the gain quantified (Will post a detailed result once the implementation is complete).
@ficristo Yes , it's a good idea to have a package.json and resolve the dependencies as node modules. Also we can introduce a tern config file. I will take both this activities outside this PR and do the changes under a separate PR soon after this. |
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, node: true, regexp: true */ | ||
|
||
(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The methods in this function need JSDocs I think 📝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petetnt Sorry for late reply. Was busy with some the type details stuff 😃 . I will add required JSDocs tonight.
Adding JSDoc in ExtractFileContent
# Conflicts: # .gitmodules # src/extensions/default/JavaScriptCodeHints/ScopeManager.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a notice
"name": "brackets-javascript-code-hints", | ||
"dependencies": { | ||
"acorn": "3.3.0", | ||
"tern": "0.20.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest tern is now 0.21.0
. If we can update to that, great. If it has breaking changes, lets keep this one and update later.
Pushing this to next release. We will merge this the moment we release 1.10 and do the first pre-release with this PR. It's breaking a few unit tests and have to resolve them before we merge. |
@swmitra Based on your last comment, this is now ready to be merged. |
Yes @marcelgerber 😄 . If we need a build refresh for the reported dll issue, we would be in trouble in case this PR is merged. I would wait for a couple of days to discuss any possibility of build refresh and then merge this PR for the first pre release. |
@marcelgerber This PR can't be merged right now 😞. There are 2 major issues I found today while testing - TOFIX
While I am working on these 2 issues, if you can spot any problem or a probable cause for this, please let me know. These should be fixed in a day or two. |
* @param {Function} callback - callback handle to post the content back | ||
*/ | ||
function _readFile(fileName, callback) { | ||
fs.readFile(fileName, "utf8", function (err, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that Brackets handles arbitary encodings, should the encoding be passed to this function too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisely I am in a catch 22 situation 😢 . Encoding scheme is only available after detection at shell level, in order to use that, I have to read all the files by hopping on the Brackets main thread, which negates any gain in terms of performance compared to using nodes io. I was relying on Brackets only to fetch dirty files content, but If I start relying on Brackets we will end up with performance issues in case of flat project structure. Prime pump will clog the main thread which in turn will make the entire editor non responsive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petetnt I have fixed most of the issues. Relying on Brackets main thread for content until we figure out a way to pass encoding info.
Acorn and Tern have been upgraded to latest version 5.1.1 and 0.21.0 respectively. Haven't noticed any problem in real use or test suite except the ones mentioned before. |
@marcelgerber @petetnt Just the final bit remaining. Need to re-initialize Tern when node gets restarted after a crash. Can we merge this PR now? We can get some time for testing all the features then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more question
|
||
require("tern/plugin/requirejs"); | ||
require("tern/plugin/doc_comment"); | ||
require("tern/plugin/angular"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Pete. Without these, commonjs dependency analysis and js doc parsing for parameter type inference doesn't work.
LGTM with a follow up PR on the restart-after-crash scenario |
This PR is created to port our js code analysis logic on node for better scalability . This will improve the overall performance and leverage addition of new features like -
and other related features.
TODO