-
Notifications
You must be signed in to change notification settings - Fork 7.6k
LESS Refactoring - add LanguageManager #2844
Conversation
Rebased once more. We should merge this early in a sprint to catch possible mistakes I made when merging. |
if (file.fullPath === newName) { | ||
_this.language = null; | ||
} | ||
}); |
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.
This introduces a memory leak -- $(module.exports) will keep references to every Document ever created. Why not do this down in the existing notifyPathNameChanged() in the existing code that loops over _openDocuments?
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.
Also, we should document that all this is doing is throwing away a cache -- language will lazily get set back to something valid as soon as it's asked for.
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.
Good catch!
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 memory leak issue (now a TODO in the code) is spun off as #2961
I'm unable to run unit tests from your branch. There are a couple of problems:
|
Done reviewing. Mostly minor changes, I hope, except for the big Languages.js comment and possibly some of the suggestions in DocumentManager... Great work! I'm very psyched about getting this into Sprint 21... |
* @param {!string} description A helpful identifier for value | ||
* @param {function(*, !string) validateEntry A function to validate the array's entries with | ||
*/ | ||
function _validateArray(value, description, validateEntry) { |
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.
Unused function. Perhaps this was used to validate in _setMode
?
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.
Ah, thanks! That was used to validate mode aliases.
Hey @jasonsanjose, thanks for the review! I updated the code. There are two things that I commented on that you may not yet be satisfied with. |
Thanks @DennisKehrig. The latest changes are good, but there were additional comments that weren't addressed yet. |
@@ -598,6 +599,11 @@ define(function (require, exports, module) { | |||
this.file = file; | |||
this.refreshText(rawText, initialTimestamp); | |||
|
|||
this._updateLanguage(); | |||
// TODO: remove this listener when the document object is obsolete. | |||
// But when is this the case? When _refCount === 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.
Hmm, yes this is a little tricky given the lack of weak references (/ weak listeners) in JS... The FileEntry will probably be a lot less permanent than the DocumentManager singleton this code used to listen to, but nonetheless we probably still do need to clean up the listener.
How about this -- on the first addRef() we add this listener, and on the last releaseRef() we clean it up. Anyone keeping a Document around for an asynchronous length of time is required to addRef() it, so the listener only matters when the refcount is non-zero.
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.
Spun off as #2961
Conflicts: src/file/FileUtils.js
@peterflynn @DennisKehrig Merged with master, fixed conflict in FileUtils. |
… and Editor APIs.
@jasonsanjose Pushed the updates to fix JS code hints -- turned out to be simple. Want to review my commit real quick? |
JavaScriptCodeHints changes look good |
@DennisKehrig: There are still a few issues to address here (I think mostly nits) but @jasonsanjose and I agreed it's better to merge this now to get more bake time. Merging now, and then I'll file spinoff bugs assigned to you for the remaining bits. |
Add language extensibility APIs; refactor LESS support out into a default extension using those APIs
I've spun off all the remaining smaller code review comments into #2968. |
Submitting this as a pull request so it can get tracked the usual way :)