From 7ecb0dcd4b2d582260313f545b5d66b302072b06 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 24 Mar 2014 14:25:14 -0600 Subject: [PATCH 1/7] Upgrade to legal-eagle@0.4.0 to accept slick's MIT license --- build/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/package.json b/build/package.json index b30c7e35f..346024d2b 100644 --- a/build/package.json +++ b/build/package.json @@ -25,7 +25,7 @@ "grunt-shell": "~0.3.1", "harmony-collections": "~0.3.8", "json-front-matter": "~0.1.3", - "legal-eagle": "~0.3.0", + "legal-eagle": "~0.4.0", "minidump": "0.5.x", "rcedit": "~0.1.2", "request": "~2.27.0", From 4aa6e78a4e5a6695385645690bb2dc6fbb69acf6 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 21 Mar 2014 18:23:18 -0600 Subject: [PATCH 2/7] Use scoped-properties-store for faster property lookup Previously we were creating DOM elements on every keystroke to look for certain properties. Now it happens entirely in JavaScript. --- package.json | 5 ++-- src/syntax.coffee | 73 ++++++++++++----------------------------------- 2 files changed, 22 insertions(+), 56 deletions(-) diff --git a/package.json b/package.json index cbf421ef5..3b4e03880 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "git-utils": "^1.1.1", "guid": "0.0.10", "jasmine-tagged": ">=1.1.1 <2.0", - "mkdirp": "0.3.5", "keytar": "1.x", "less-cache": "0.12.0", "mixto": "1.x", + "mkdirp": "0.3.5", "nslog": "0.5.0", "oniguruma": "^1.0.4", "optimist": "0.4.0", @@ -41,6 +41,7 @@ "random-words": "0.0.1", "runas": "0.5.x", "scandal": "0.15.0", + "scoped-property-store": "^0.3.0", "scrollbar-style": "^0.1.0", "season": ">=1.0.2 <2.0", "semver": "1.1.4", @@ -49,7 +50,7 @@ "temp": "0.5.0", "text-buffer": "^1.4.4", "theorist": "1.x", - "underscore-plus": ">=1.0.5 <2.0", + "underscore-plus": "^1.1.0", "vm-compatibility-layer": "0.1.0" }, "packageDependencies": { diff --git a/src/syntax.coffee b/src/syntax.coffee index 881d5fa2a..793d070b2 100644 --- a/src/syntax.coffee +++ b/src/syntax.coffee @@ -2,6 +2,7 @@ _ = require 'underscore-plus' {specificity} = require 'clear-cut' {Subscriber} = require 'emissary' {GrammarRegistry, ScopeSelector} = require 'first-mate' +ScopedPropertyStore = require 'scoped-property-store' {$, $$} = require './space-pen-extensions' Token = require './token' @@ -24,9 +25,7 @@ class Syntax extends GrammarRegistry constructor: -> super - - @scopedPropertiesIndex = 0 - @scopedProperties = [] + @scopedProperties = new ScopedPropertyStore serialize: -> {deserializer: @constructor.name, @grammarOverridesByPath} @@ -36,22 +35,15 @@ class Syntax extends GrammarRegistry addProperties: (args...) -> name = args.shift() if args.length > 2 [selector, properties] = args - - @scopedProperties.unshift( - name: name - selector: selector, - properties: properties, - specificity: specificity(selector), - index: @scopedPropertiesIndex++ - ) + propertiesBySelector = {} + propertiesBySelector[selector] = properties + @scopedProperties.addProperties(name, propertiesBySelector) removeProperties: (name) -> - for properties in @scopedProperties.filter((properties) -> properties.name is name) - _.remove(@scopedProperties, properties) + @scopedProperties.removeProperties(name) clearProperties: -> - @scopedProperties = [] - @scopedPropertiesIndex = 0 + @scopedProperties = new ScopedPropertyStore # Public: Get a property for the given scope and key path. # @@ -66,48 +58,21 @@ class Syntax extends GrammarRegistry # # Returns a {String} property value or undefined. getProperty: (scope, keyPath) -> - for object in @propertiesForScope(scope, keyPath) - value = _.valueForKeyPath(object, keyPath) - return value if value? - undefined + scopeChain = scope + .map (scope) -> + scope = ".#{scope}" unless scope.indexOf('.') is 0 + scope + .join(' ') + @scopedProperties.getPropertyValue(scopeChain, keyPath) propertiesForScope: (scope, keyPath) -> - matchingProperties = [] - candidates = @scopedProperties.filter ({properties}) -> _.valueForKeyPath(properties, keyPath)? - if candidates.length - element = @buildScopeElement(scope) - while element - matchingProperties.push(@matchingPropertiesForElement(element, candidates)...) - element = element.parentNode - matchingProperties + scopeChain = scope + .map (scope) -> + scope = ".#{scope}" unless scope.indexOf('.') is 0 + scope + .join(' ') - matchingPropertiesForElement: (element, candidates) -> - matchingScopedProperties = candidates.filter ({selector}) -> - $.find.matchesSelector(element, selector) - matchingScopedProperties.sort (a, b) -> - if a.specificity == b.specificity - b.index - a.index - else - b.specificity - a.specificity - _.pluck matchingScopedProperties, 'properties' - - buildScopeElement: (scope) -> - scope = scope.slice() - element = $$ -> - elementsForRemainingScopes = => - classString = scope.shift() - classes = classString.replace(/^\./, '').replace(/\./g, ' ') - if scope.length - @div class: classes, elementsForRemainingScopes - else - @div class: classes - elementsForRemainingScopes() - - deepestChild = element.find(":not(:has(*))") - if deepestChild.length - deepestChild[0] - else - element[0] + @scopedProperties.getProperties(scopeChain, keyPath) cssSelectorFromScopeSelector: (scopeSelector) -> new ScopeSelector(scopeSelector).toCssSelector() From 6bd73f26472327e94cafec6682b57478da36e9b7 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 24 Mar 2014 18:05:46 -0600 Subject: [PATCH 3/7] Upgrade to scoped-property-store@0.4.0 to upgrade underscore-plus There's something weird going on and I can't figure it out. I feel like there's a bad version of underscore-plus cached somewhere on CI. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc8dd7d6e..0e957fd26 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "random-words": "0.0.1", "runas": "0.5.x", "scandal": "0.15.0", - "scoped-property-store": "^0.3.0", + "scoped-property-store": "^0.4.0", "scrollbar-style": "^0.1.0", "season": ">=1.0.2 <2.0", "semver": "1.1.4", From bb6aa5eedbb6f5970e1df37623e0a1bc348163dc Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 24 Mar 2014 19:22:52 -0600 Subject: [PATCH 4/7] Add deprecated atom.syntax.scopedProperties for settings-view This is used to determine which snippets apply to the current package. We should really come up with a different approach, but for now this preserves compatibility. --- package.json | 2 +- src/syntax.coffee | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0e957fd26..f0770e82e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "random-words": "0.0.1", "runas": "0.5.x", "scandal": "0.15.0", - "scoped-property-store": "^0.4.0", + "scoped-property-store": "^0.5.0", "scrollbar-style": "^0.1.0", "season": ">=1.0.2 <2.0", "semver": "1.1.4", diff --git a/src/syntax.coffee b/src/syntax.coffee index 793d070b2..c2d1b22bb 100644 --- a/src/syntax.coffee +++ b/src/syntax.coffee @@ -3,6 +3,7 @@ _ = require 'underscore-plus' {Subscriber} = require 'emissary' {GrammarRegistry, ScopeSelector} = require 'first-mate' ScopedPropertyStore = require 'scoped-property-store' +PropertyAccessors = require 'property-accessors' {$, $$} = require './space-pen-extensions' Token = require './token' @@ -15,6 +16,7 @@ Token = require './token' # language-specific comment regexes. module.exports = class Syntax extends GrammarRegistry + PropertyAccessors.includeInto(this) Subscriber.includeInto(this) atom.deserializers.add(this) @@ -25,25 +27,28 @@ class Syntax extends GrammarRegistry constructor: -> super - @scopedProperties = new ScopedPropertyStore + @propertyStore = new ScopedPropertyStore serialize: -> {deserializer: @constructor.name, @grammarOverridesByPath} createToken: (value, scopes) -> new Token({value, scopes}) + # Deprecated: Used by settings-view to display snippets for packages + @::accessor 'scopedProperties', -> @propertyStore.propertySets + addProperties: (args...) -> name = args.shift() if args.length > 2 [selector, properties] = args propertiesBySelector = {} propertiesBySelector[selector] = properties - @scopedProperties.addProperties(name, propertiesBySelector) + @propertyStore.addProperties(name, propertiesBySelector) removeProperties: (name) -> - @scopedProperties.removeProperties(name) + @propertyStore.removeProperties(name) clearProperties: -> - @scopedProperties = new ScopedPropertyStore + @propertyStore = new ScopedPropertyStore # Public: Get a property for the given scope and key path. # @@ -63,7 +68,7 @@ class Syntax extends GrammarRegistry scope = ".#{scope}" unless scope.indexOf('.') is 0 scope .join(' ') - @scopedProperties.getPropertyValue(scopeChain, keyPath) + @propertyStore.getPropertyValue(scopeChain, keyPath) propertiesForScope: (scope, keyPath) -> scopeChain = scope @@ -72,7 +77,7 @@ class Syntax extends GrammarRegistry scope .join(' ') - @scopedProperties.getProperties(scopeChain, keyPath) + @propertyStore.getProperties(scopeChain, keyPath) cssSelectorFromScopeSelector: (scopeSelector) -> new ScopeSelector(scopeSelector).toCssSelector() From d62b3d5236cccd63d1a46149493fe31752abf595 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 24 Mar 2014 19:41:22 -0600 Subject: [PATCH 5/7] Upgrate to tree-view@0.84.0 for flaky spec fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0770e82e..12b0ccd97 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "symbols-view": "0.44.0", "tabs": "0.31.0", "timecop": "0.17.0", - "tree-view": "0.83.0", + "tree-view": "0.84.0", "update-package-dependencies": "0.6.0", "welcome": "0.11.0", "whitespace": "0.21.0", From fd6476e4d1d54f7abbd8d5cb6965f2916bee6c39 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 24 Mar 2014 19:47:39 -0600 Subject: [PATCH 6/7] Update to underscore-plus@1.1.1 to match scoped-property-store --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12b0ccd97..760f4fdf3 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "temp": "0.5.0", "text-buffer": "^1.4.4", "theorist": "1.x", - "underscore-plus": "^1.1.0", + "underscore-plus": "^1.1.1", "vm-compatibility-layer": "0.1.0" }, "packageDependencies": { From 48798dead92dbfdcee11349f7e7ee65f9a06e6b2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 25 Mar 2014 12:03:31 -0600 Subject: [PATCH 7/7] Upgrade to scoped-property-store@0.6.0 for :not pseudoclasses --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 760f4fdf3..a9646afcc 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "random-words": "0.0.1", "runas": "0.5.x", "scandal": "0.15.0", - "scoped-property-store": "^0.5.0", + "scoped-property-store": "^0.6.0", "scrollbar-style": "^0.1.0", "season": ">=1.0.2 <2.0", "semver": "1.1.4",