first-mate
Advanced tools
Comparing version 2.1.2 to 2.2.0
62
api.json
@@ -6,3 +6,3 @@ { | ||
"filename": "src/grammar-registry.coffee", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L12", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L12", | ||
"sections": [ | ||
@@ -23,3 +23,3 @@ { | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L35", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L35", | ||
"visibility": "Public", | ||
@@ -54,3 +54,3 @@ "summary": "Invoke the given callback when a grammar is added to the registry.", | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L45", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L45", | ||
"visibility": "Public", | ||
@@ -85,3 +85,3 @@ "summary": "Invoke the given callback when a grammar is updated due to a grammar\nit depends on being added or removed from the registry.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L66", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L66", | ||
"visibility": "Public", | ||
@@ -100,3 +100,3 @@ "summary": "Get all the grammars in this registry.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L74", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L74", | ||
"visibility": "Public", | ||
@@ -123,3 +123,3 @@ "summary": "Get a grammar with the given scope name.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L83", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L86", | ||
"visibility": "Public", | ||
@@ -131,27 +131,11 @@ "summary": "Add a grammar to this registry.", | ||
"name": "grammar", | ||
"description": "The {Grammar} to add. This should be a value previously returned from {::readGrammar} or {::readGrammarSync}. ", | ||
"description": "The {Grammar} to add. This should be a value previously returned from {::readGrammar} or {::readGrammarSync}.", | ||
"type": "Grammar", | ||
"isOptional": false | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "removeGrammar", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L96", | ||
"visibility": "Public", | ||
"summary": "Remove a grammar from this registry.", | ||
"description": "Remove a grammar from this registry.", | ||
"arguments": [ | ||
{ | ||
"name": "grammar", | ||
"description": "The {Grammar} to remove.", | ||
"type": "Grammar", | ||
"isOptional": false | ||
} | ||
], | ||
"returnValues": [ | ||
{ | ||
"type": null, | ||
"description": "Returns ." | ||
"type": "Disposable", | ||
"description": "Returns a {Disposable} on which `.dispose()` can be called to remove the\ngrammar." | ||
} | ||
@@ -163,3 +147,3 @@ ] | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L108", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L107", | ||
"visibility": "Public", | ||
@@ -186,3 +170,3 @@ "summary": "Remove the grammar with the given scope name.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L118", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L117", | ||
"visibility": "Public", | ||
@@ -209,3 +193,3 @@ "summary": "Read a grammar synchronously but don't add it to the registry.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L133", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L132", | ||
"visibility": "Public", | ||
@@ -252,3 +236,3 @@ "summary": "Read a grammar asynchronously but don't add it to the registry.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L150", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L149", | ||
"visibility": "Public", | ||
@@ -275,3 +259,3 @@ "summary": "Read a grammar synchronously and add it to this registry.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L163", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L162", | ||
"visibility": "Public", | ||
@@ -318,3 +302,3 @@ "summary": "Read a grammar asynchronously and add it to the registry.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L178", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L177", | ||
"visibility": "Public", | ||
@@ -341,3 +325,3 @@ "summary": "Get the grammar override for the given file path.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L187", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L186", | ||
"visibility": "Public", | ||
@@ -370,3 +354,3 @@ "summary": "Set the grammar override for the given file path.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L196", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L195", | ||
"visibility": "Public", | ||
@@ -393,3 +377,3 @@ "summary": "Remove the grammar override for the given file path.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L203", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L202", | ||
"visibility": "Public", | ||
@@ -408,3 +392,3 @@ "summary": "Remove all grammar overrides.", | ||
"sectionName": "Managing Grammars", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar-registry.coffee#L216", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar-registry.coffee#L215", | ||
"visibility": "Public", | ||
@@ -444,3 +428,3 @@ "summary": "Select a grammar for the given file path and file contents.", | ||
"filename": "src/grammar.coffee", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar.coffee#L22", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar.coffee#L22", | ||
"sections": [ | ||
@@ -461,3 +445,3 @@ { | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar.coffee#L60", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar.coffee#L62", | ||
"visibility": "Public", | ||
@@ -484,3 +468,3 @@ "summary": "Invoke the given callback when this grammar is updated due to a\ngrammar it depends on being added or removed from the registry.", | ||
"sectionName": "Tokenizing", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar.coffee#L80", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar.coffee#L82", | ||
"visibility": "Public", | ||
@@ -507,3 +491,3 @@ "summary": "Tokenize all lines in the given text.", | ||
"sectionName": "Tokenizing", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.1.2/src/grammar.coffee#L101", | ||
"srcUrl": "https://github.com/atom/first-mate/blob/v2.2.0/src/grammar.coffee#L103", | ||
"visibility": "Public", | ||
@@ -510,0 +494,0 @@ "summary": "Tokenize the line of text.", |
(function() { | ||
var CSON, Emitter, EmitterMixin, Grammar, GrammarRegistry, Grim, NullGrammar, _; | ||
var CSON, Disposable, Emitter, EmitterMixin, Grammar, GrammarRegistry, Grim, NullGrammar, _, _ref; | ||
@@ -10,3 +10,3 @@ _ = require('underscore-plus'); | ||
Emitter = require('event-kit').Emitter; | ||
_ref = require('event-kit'), Emitter = _ref.Emitter, Disposable = _ref.Disposable; | ||
@@ -23,7 +23,7 @@ Grim = require('grim'); | ||
function GrammarRegistry(options) { | ||
var _ref; | ||
var _ref1; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.maxTokensPerLine = (_ref = options.maxTokensPerLine) != null ? _ref : Infinity; | ||
this.maxTokensPerLine = (_ref1 = options.maxTokensPerLine) != null ? _ref1 : Infinity; | ||
this.emitter = new Emitter; | ||
@@ -86,3 +86,8 @@ this.grammars = []; | ||
this.emit('grammar-added', grammar); | ||
return this.emitter.emit('did-add-grammar', grammar); | ||
this.emitter.emit('did-add-grammar', grammar); | ||
return new Disposable((function(_this) { | ||
return function() { | ||
return _this.removeGrammar(grammar); | ||
}; | ||
})(this)); | ||
}; | ||
@@ -108,4 +113,4 @@ | ||
GrammarRegistry.prototype.readGrammarSync = function(grammarPath) { | ||
var grammar, _ref; | ||
grammar = (_ref = CSON.readFileSync(grammarPath)) != null ? _ref : {}; | ||
var grammar, _ref1; | ||
grammar = (_ref1 = CSON.readFileSync(grammarPath)) != null ? _ref1 : {}; | ||
if (typeof grammar.scopeName === 'string' && grammar.scopeName.length > 0) { | ||
@@ -198,7 +203,7 @@ return this.createGrammar(grammarPath, grammar); | ||
GrammarRegistry.prototype.grammarUpdated = function(scopeName) { | ||
var grammar, _i, _len, _ref, _results; | ||
_ref = this.grammars; | ||
var grammar, _i, _len, _ref1, _results; | ||
_ref1 = this.grammars; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
grammar = _ref[_i]; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
grammar = _ref1[_i]; | ||
if (grammar.scopeName !== scopeName) { | ||
@@ -205,0 +210,0 @@ if (grammar.grammarUpdated(scopeName)) { |
@@ -31,2 +31,4 @@ (function() { | ||
Grammar.prototype.registration = null; | ||
function Grammar(registry, options) { | ||
@@ -175,3 +177,3 @@ var firstLineMatch, injectionSelector, injections, patterns, repository; | ||
Grammar.prototype.activate = function() { | ||
return this.registry.addGrammar(this); | ||
return this.registration = this.registry.addGrammar(this); | ||
}; | ||
@@ -181,3 +183,3 @@ | ||
this.emitter = new Emitter; | ||
return this.registry.removeGrammar(this); | ||
return this.registration.dispose(); | ||
}; | ||
@@ -184,0 +186,0 @@ |
{ | ||
"name": "first-mate", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "TextMate helpers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/first-mate.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
643687
16225