diff --git a/spec/package-manager-spec.coffee b/spec/package-manager-spec.coffee index d9da575a1..cb86bdab4 100644 --- a/spec/package-manager-spec.coffee +++ b/spec/package-manager-spec.coffee @@ -349,8 +349,8 @@ describe "PackageManager", -> atom.packages.activatePackage('package-with-grammars') runs -> - expect(atom.syntax.selectGrammar('a.alot').name).toBe 'Alot' - expect(atom.syntax.selectGrammar('a.alittle').name).toBe 'Alittle' + expect(atom.grammars.selectGrammar('a.alot').name).toBe 'Alot' + expect(atom.grammars.selectGrammar('a.alittle').name).toBe 'Alittle' describe "scoped-property loading", -> it "loads the scoped properties", -> @@ -362,13 +362,13 @@ describe "PackageManager", -> describe "converted textmate packages", -> it "loads the package's grammars", -> - expect(atom.syntax.selectGrammar("file.rb").name).toBe "Null Grammar" + expect(atom.grammars.selectGrammar("file.rb").name).toBe "Null Grammar" waitsForPromise -> atom.packages.activatePackage('language-ruby') runs -> - expect(atom.syntax.selectGrammar("file.rb").name).toBe "Ruby" + expect(atom.grammars.selectGrammar("file.rb").name).toBe "Ruby" it "loads the translated scoped properties", -> expect(atom.config.get(['.source.ruby'], 'editor.commentStart')).toBeUndefined() @@ -454,8 +454,8 @@ describe "PackageManager", -> runs -> atom.packages.deactivatePackage('package-with-grammars') - expect(atom.syntax.selectGrammar('a.alot').name).toBe 'Null Grammar' - expect(atom.syntax.selectGrammar('a.alittle').name).toBe 'Null Grammar' + expect(atom.grammars.selectGrammar('a.alot').name).toBe 'Null Grammar' + expect(atom.grammars.selectGrammar('a.alittle').name).toBe 'Null Grammar' it "removes the package's keymaps", -> waitsForPromise -> @@ -490,15 +490,15 @@ describe "PackageManager", -> describe "textmate packages", -> it "removes the package's grammars", -> - expect(atom.syntax.selectGrammar("file.rb").name).toBe "Null Grammar" + expect(atom.grammars.selectGrammar("file.rb").name).toBe "Null Grammar" waitsForPromise -> atom.packages.activatePackage('language-ruby') runs -> - expect(atom.syntax.selectGrammar("file.rb").name).toBe "Ruby" + expect(atom.grammars.selectGrammar("file.rb").name).toBe "Ruby" atom.packages.deactivatePackage('language-ruby') - expect(atom.syntax.selectGrammar("file.rb").name).toBe "Null Grammar" + expect(atom.grammars.selectGrammar("file.rb").name).toBe "Null Grammar" it "removes the package's scoped properties", -> waitsForPromise -> @@ -527,7 +527,7 @@ describe "PackageManager", -> atom.packages.unloadPackages() GrammarRegistry = require '../src/grammar-registry' - atom.syntax = window.syntax = new GrammarRegistry() + atom.grammars = window.syntax = new GrammarRegistry() it "activates all the packages, and none of the themes", -> atom.packages.activate() diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 306e0bca5..48e0f3958 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -82,7 +82,7 @@ beforeEach -> serializedWindowState = null spyOn(atom, 'saveSync') - atom.syntax.clearGrammarOverrides() + atom.grammars.clearGrammarOverrides() spy = spyOn(atom.packages, 'resolvePackagePath').andCallFake (packageName) -> if specPackageName and packageName is specPackageName @@ -150,7 +150,7 @@ afterEach -> jasmine.unspy(atom, 'saveSync') ensureNoPathSubscriptions() - atom.syntax.clearObservers() + atom.grammars.clearObservers() waits(0) # yield to ui thread to make screen update more frequently ensureNoPathSubscriptions = -> diff --git a/spec/syntax-spec.coffee b/spec/syntax-spec.coffee index 12bd277b7..c7d19e259 100644 --- a/spec/syntax-spec.coffee +++ b/spec/syntax-spec.coffee @@ -23,10 +23,10 @@ describe "the `syntax` global", -> describe "serialization", -> it "remembers grammar overrides by path", -> filePath = '/foo/bar/file.js' - expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby' - atom.syntax.setGrammarOverrideForPath(filePath, 'source.ruby') - syntax2 = atom.deserializers.deserialize(atom.syntax.serialize()) - syntax2.addGrammar(grammar) for grammar in atom.syntax.grammars when grammar isnt atom.syntax.nullGrammar + expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby' + atom.grammars.setGrammarOverrideForPath(filePath, 'source.ruby') + syntax2 = atom.deserializers.deserialize(atom.grammars.serialize()) + syntax2.addGrammar(grammar) for grammar in atom.grammars.grammars when grammar isnt atom.grammars.nullGrammar expect(syntax2.selectGrammar(filePath).name).toBe 'Ruby' describe ".selectGrammar(filePath)", -> @@ -35,15 +35,15 @@ describe "the `syntax` global", -> atom.packages.activatePackage('language-git') runs -> - expect(atom.syntax.selectGrammar("file.js").name).toBe "JavaScript" # based on extension (.js) - expect(atom.syntax.selectGrammar(path.join(temp.dir, '.git', 'config')).name).toBe "Git Config" # based on end of the path (.git/config) - expect(atom.syntax.selectGrammar("Rakefile").name).toBe "Ruby" # based on the file's basename (Rakefile) - expect(atom.syntax.selectGrammar("curb").name).toBe "Null Grammar" - expect(atom.syntax.selectGrammar("/hu.git/config").name).toBe "Null Grammar" + expect(atom.grammars.selectGrammar("file.js").name).toBe "JavaScript" # based on extension (.js) + expect(atom.grammars.selectGrammar(path.join(temp.dir, '.git', 'config')).name).toBe "Git Config" # based on end of the path (.git/config) + expect(atom.grammars.selectGrammar("Rakefile").name).toBe "Ruby" # based on the file's basename (Rakefile) + expect(atom.grammars.selectGrammar("curb").name).toBe "Null Grammar" + expect(atom.grammars.selectGrammar("/hu.git/config").name).toBe "Null Grammar" it "uses the filePath's shebang line if the grammar cannot be determined by the extension or basename", -> filePath = require.resolve("./fixtures/shebang") - expect(atom.syntax.selectGrammar(filePath).name).toBe "Ruby" + expect(atom.grammars.selectGrammar(filePath).name).toBe "Ruby" it "uses the number of newlines in the first line regex to determine the number of lines to test against", -> waitsForPromise -> @@ -51,28 +51,28 @@ describe "the `syntax` global", -> runs -> fileContent = "first-line\n" - expect(atom.syntax.selectGrammar("dummy.coffee", fileContent).name).toBe "CoffeeScript" + expect(atom.grammars.selectGrammar("dummy.coffee", fileContent).name).toBe "CoffeeScript" fileContent = '' - expect(atom.syntax.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Null Grammar" + expect(atom.grammars.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Null Grammar" fileContent += '\n' - expect(atom.syntax.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Property List (XML)" + expect(atom.grammars.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Property List (XML)" it "doesn't read the file when the file contents are specified", -> filePath = require.resolve("./fixtures/shebang") filePathContents = fs.readFileSync(filePath, 'utf8') spyOn(fs, 'read').andCallThrough() - expect(atom.syntax.selectGrammar(filePath, filePathContents).name).toBe "Ruby" + expect(atom.grammars.selectGrammar(filePath, filePathContents).name).toBe "Ruby" expect(fs.read).not.toHaveBeenCalled() it "allows the default grammar to be overridden for a path", -> filePath = '/foo/bar/file.js' - expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby' - atom.syntax.setGrammarOverrideForPath(filePath, 'source.ruby') - expect(atom.syntax.selectGrammar(filePath).name).toBe 'Ruby' - atom.syntax.clearGrammarOverrideForPath(filePath) - expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby' + expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby' + atom.grammars.setGrammarOverrideForPath(filePath, 'source.ruby') + expect(atom.grammars.selectGrammar(filePath).name).toBe 'Ruby' + atom.grammars.clearGrammarOverrideForPath(filePath) + expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby' describe "when multiple grammars have matching fileTypes", -> it "selects the grammar with the longest fileType match", -> @@ -82,8 +82,8 @@ describe "the `syntax` global", -> scopeName: 'source1' fileTypes: ['test'] ) - grammar1 = atom.syntax.loadGrammarSync(grammarPath1) - expect(atom.syntax.selectGrammar('more.test', '')).toBe grammar1 + grammar1 = atom.grammars.loadGrammarSync(grammarPath1) + expect(atom.grammars.selectGrammar('more.test', '')).toBe grammar1 grammarPath2 = temp.path(suffix: '.json') fs.writeFileSync grammarPath2, JSON.stringify( @@ -91,44 +91,44 @@ describe "the `syntax` global", -> scopeName: 'source2' fileTypes: ['test', 'more.test'] ) - grammar2 = atom.syntax.loadGrammarSync(grammarPath2) - expect(atom.syntax.selectGrammar('more.test', '')).toBe grammar2 + grammar2 = atom.grammars.loadGrammarSync(grammarPath2) + expect(atom.grammars.selectGrammar('more.test', '')).toBe grammar2 describe "when there is no file path", -> it "does not throw an exception (regression)", -> - expect(-> atom.syntax.selectGrammar(null, '#!/usr/bin/ruby')).not.toThrow() - expect(-> atom.syntax.selectGrammar(null, '')).not.toThrow() - expect(-> atom.syntax.selectGrammar(null, null)).not.toThrow() + expect(-> atom.grammars.selectGrammar(null, '#!/usr/bin/ruby')).not.toThrow() + expect(-> atom.grammars.selectGrammar(null, '')).not.toThrow() + expect(-> atom.grammars.selectGrammar(null, null)).not.toThrow() describe ".removeGrammar(grammar)", -> it "removes the grammar, so it won't be returned by selectGrammar", -> - grammar = atom.syntax.selectGrammar('foo.js') - atom.syntax.removeGrammar(grammar) - expect(atom.syntax.selectGrammar('foo.js').name).not.toBe grammar.name + grammar = atom.grammars.selectGrammar('foo.js') + atom.grammars.removeGrammar(grammar) + expect(atom.grammars.selectGrammar('foo.js').name).not.toBe grammar.name describe ".getProperty(scopeDescriptor)", -> it "returns the property with the most specific scope selector", -> - atom.syntax.addProperties(".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42) - atom.syntax.addProperties(".source .string.quoted.double", foo: bar: baz: 22) - atom.syntax.addProperties(".source", foo: bar: baz: 11) + atom.grammars.addProperties(".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42) + atom.grammars.addProperties(".source .string.quoted.double", foo: bar: baz: 22) + atom.grammars.addProperties(".source", foo: bar: baz: 11) - expect(atom.syntax.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42 - expect(atom.syntax.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBe 22 - expect(atom.syntax.getProperty([".source.js", ".variable.assignment.js"], "foo.bar.baz")).toBe 11 - expect(atom.syntax.getProperty([".text"], "foo.bar.baz")).toBeUndefined() + expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42 + expect(atom.grammars.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBe 22 + expect(atom.grammars.getProperty([".source.js", ".variable.assignment.js"], "foo.bar.baz")).toBe 11 + expect(atom.grammars.getProperty([".text"], "foo.bar.baz")).toBeUndefined() it "favors the most recently added properties in the event of a specificity tie", -> - atom.syntax.addProperties(".source.coffee .string.quoted.single", foo: bar: baz: 42) - atom.syntax.addProperties(".source.coffee .string.quoted.double", foo: bar: baz: 22) + atom.grammars.addProperties(".source.coffee .string.quoted.single", foo: bar: baz: 42) + atom.grammars.addProperties(".source.coffee .string.quoted.double", foo: bar: baz: 22) - expect(atom.syntax.getProperty([".source.coffee", ".string.quoted.single"], "foo.bar.baz")).toBe 42 - expect(atom.syntax.getProperty([".source.coffee", ".string.quoted.single.double"], "foo.bar.baz")).toBe 22 + expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.single"], "foo.bar.baz")).toBe 42 + expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.single.double"], "foo.bar.baz")).toBe 22 describe ".removeProperties(name)", -> it "allows properties to be removed by name", -> - atom.syntax.addProperties("a", ".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42) - atom.syntax.addProperties("b", ".source .string.quoted.double", foo: bar: baz: 22) + atom.grammars.addProperties("a", ".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42) + atom.grammars.addProperties("b", ".source .string.quoted.double", foo: bar: baz: 22) - atom.syntax.removeProperties("b") - expect(atom.syntax.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBeUndefined() - expect(atom.syntax.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42 + atom.grammars.removeProperties("b") + expect(atom.grammars.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBeUndefined() + expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42 diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 7176a511d..6fb736420 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -2532,7 +2532,7 @@ describe "TextEditorComponent", -> describe "grammar data attributes", -> it "adds and updates the grammar data attribute based on the current grammar", -> expect(wrapperNode.dataset.grammar).toBe 'source js' - editor.setGrammar(atom.syntax.nullGrammar) + editor.setGrammar(atom.grammars.nullGrammar) expect(wrapperNode.dataset.grammar).toBe 'text plain null-grammar' describe "encoding data attributes", -> diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index fe2bf7857..2f757f214 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -3357,17 +3357,17 @@ describe "TextEditor", -> it "switches to the better-matched grammar and re-tokenizes the buffer", -> editor.destroy() - jsGrammar = atom.syntax.selectGrammar('a.js') - atom.syntax.removeGrammar(jsGrammar) + jsGrammar = atom.grammars.selectGrammar('a.js') + atom.grammars.removeGrammar(jsGrammar) waitsForPromise -> atom.workspace.open('sample.js', autoIndent: false).then (o) -> editor = o runs -> - expect(editor.getGrammar()).toBe atom.syntax.nullGrammar + expect(editor.getGrammar()).toBe atom.grammars.nullGrammar expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBe 1 - atom.syntax.addGrammar(jsGrammar) + atom.grammars.addGrammar(jsGrammar) expect(editor.getGrammar()).toBe jsGrammar expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBeGreaterThan 1 @@ -3787,7 +3787,7 @@ describe "TextEditor", -> it "updates the grammar based on grammar overrides", -> expect(editor.getGrammar().name).toBe 'JavaScript' - atom.syntax.setGrammarOverrideForPath(editor.getPath(), 'source.coffee') + atom.grammars.setGrammarOverrideForPath(editor.getPath(), 'source.coffee') editor.reloadGrammar() expect(editor.getGrammar().name).toBe 'CoffeeScript' @@ -3805,7 +3805,7 @@ describe "TextEditor", -> atom.packages.activatePackage('language-hyperlink') runs -> - grammar = atom.syntax.selectGrammar("text.js") + grammar = atom.grammars.selectGrammar("text.js") {tokens} = grammar.tokenizeLine("var i; // http://github.com") expect(tokens[0].value).toBe "var" diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 51d48b5eb..2fcef3e55 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -522,7 +522,7 @@ describe "TokenizedBuffer", -> buffer = atom.project.bufferForPathSync() buffer.setText "