Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

LESS Refactoring - add LanguageManager #2844

Merged
merged 57 commits into from
Feb 27, 2013
Merged

LESS Refactoring - add LanguageManager #2844

merged 57 commits into from
Feb 27, 2013

Conversation

DennisKehrig
Copy link
Contributor

Submitting this as a pull request so it can get tracked the usual way :)

@ghost ghost assigned peterflynn Feb 12, 2013
@DennisKehrig
Copy link
Contributor Author

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;
}
});
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Member

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

@peterflynn
Copy link
Member

I'm unable to run unit tests from your branch. There are a couple of problems:

  • Editor-test has one broken suite that depends on EditorUtils, and it prevents the whole test-runner from loading since it can't find that module. If you fix or comment that out, then you can see the other issues...
  • Lots of tests fail -- e.g. about 1/2 of EditorCommandHandlers-test, most of CSSUtils-test, one more test in Editor-test, etc.
  • The console gets a big spew of errors about being unable to load various CM modes. I think your change in brackets.js may need to go into SpecRunner.js also. @jasonsanjose probably understands how Require is affected by unit tests the best, though. I'm guessing fixing this will fix a bunch of the test failures too...

@peterflynn
Copy link
Member

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) {
Copy link
Member

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?

Copy link
Contributor Author

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.

@DennisKehrig
Copy link
Contributor Author

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.

@jasonsanjose
Copy link
Member

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?
Copy link
Member

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.

Copy link
Member

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
@jasonsanjose
Copy link
Member

@peterflynn @DennisKehrig Merged with master, fixed conflict in FileUtils.

@peterflynn
Copy link
Member

@jasonsanjose Pushed the updates to fix JS code hints -- turned out to be simple. Want to review my commit real quick?

@jasonsanjose
Copy link
Member

JavaScriptCodeHints changes look good

@peterflynn
Copy link
Member

@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.

peterflynn added a commit that referenced this pull request Feb 27, 2013
Add language extensibility APIs; refactor LESS support out into a default extension using those APIs
@peterflynn peterflynn merged commit fee1311 into master Feb 27, 2013
@jasonsanjose jasonsanjose deleted the dk/less-refactoring branch February 27, 2013 00:12
jasonsanjose added a commit that referenced this pull request Feb 27, 2013
@peterflynn
Copy link
Member

I've spun off all the remaining smaller code review comments into #2968.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants