Replace atom.syntax with atom.grammars
Esse commit está contido em:
@@ -349,8 +349,8 @@ describe "PackageManager", ->
|
|||||||
atom.packages.activatePackage('package-with-grammars')
|
atom.packages.activatePackage('package-with-grammars')
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(atom.syntax.selectGrammar('a.alot').name).toBe 'Alot'
|
expect(atom.grammars.selectGrammar('a.alot').name).toBe 'Alot'
|
||||||
expect(atom.syntax.selectGrammar('a.alittle').name).toBe 'Alittle'
|
expect(atom.grammars.selectGrammar('a.alittle').name).toBe 'Alittle'
|
||||||
|
|
||||||
describe "scoped-property loading", ->
|
describe "scoped-property loading", ->
|
||||||
it "loads the scoped properties", ->
|
it "loads the scoped properties", ->
|
||||||
@@ -362,13 +362,13 @@ describe "PackageManager", ->
|
|||||||
|
|
||||||
describe "converted textmate packages", ->
|
describe "converted textmate packages", ->
|
||||||
it "loads the package's grammars", ->
|
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 ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage('language-ruby')
|
atom.packages.activatePackage('language-ruby')
|
||||||
|
|
||||||
runs ->
|
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", ->
|
it "loads the translated scoped properties", ->
|
||||||
expect(atom.config.get(['.source.ruby'], 'editor.commentStart')).toBeUndefined()
|
expect(atom.config.get(['.source.ruby'], 'editor.commentStart')).toBeUndefined()
|
||||||
@@ -454,8 +454,8 @@ describe "PackageManager", ->
|
|||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
atom.packages.deactivatePackage('package-with-grammars')
|
atom.packages.deactivatePackage('package-with-grammars')
|
||||||
expect(atom.syntax.selectGrammar('a.alot').name).toBe 'Null Grammar'
|
expect(atom.grammars.selectGrammar('a.alot').name).toBe 'Null Grammar'
|
||||||
expect(atom.syntax.selectGrammar('a.alittle').name).toBe 'Null Grammar'
|
expect(atom.grammars.selectGrammar('a.alittle').name).toBe 'Null Grammar'
|
||||||
|
|
||||||
it "removes the package's keymaps", ->
|
it "removes the package's keymaps", ->
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
@@ -490,15 +490,15 @@ describe "PackageManager", ->
|
|||||||
|
|
||||||
describe "textmate packages", ->
|
describe "textmate packages", ->
|
||||||
it "removes the package's grammars", ->
|
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 ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage('language-ruby')
|
atom.packages.activatePackage('language-ruby')
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(atom.syntax.selectGrammar("file.rb").name).toBe "Ruby"
|
expect(atom.grammars.selectGrammar("file.rb").name).toBe "Ruby"
|
||||||
atom.packages.deactivatePackage('language-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", ->
|
it "removes the package's scoped properties", ->
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
@@ -527,7 +527,7 @@ describe "PackageManager", ->
|
|||||||
atom.packages.unloadPackages()
|
atom.packages.unloadPackages()
|
||||||
|
|
||||||
GrammarRegistry = require '../src/grammar-registry'
|
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", ->
|
it "activates all the packages, and none of the themes", ->
|
||||||
atom.packages.activate()
|
atom.packages.activate()
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ beforeEach ->
|
|||||||
serializedWindowState = null
|
serializedWindowState = null
|
||||||
|
|
||||||
spyOn(atom, 'saveSync')
|
spyOn(atom, 'saveSync')
|
||||||
atom.syntax.clearGrammarOverrides()
|
atom.grammars.clearGrammarOverrides()
|
||||||
|
|
||||||
spy = spyOn(atom.packages, 'resolvePackagePath').andCallFake (packageName) ->
|
spy = spyOn(atom.packages, 'resolvePackagePath').andCallFake (packageName) ->
|
||||||
if specPackageName and packageName is specPackageName
|
if specPackageName and packageName is specPackageName
|
||||||
@@ -150,7 +150,7 @@ afterEach ->
|
|||||||
|
|
||||||
jasmine.unspy(atom, 'saveSync')
|
jasmine.unspy(atom, 'saveSync')
|
||||||
ensureNoPathSubscriptions()
|
ensureNoPathSubscriptions()
|
||||||
atom.syntax.clearObservers()
|
atom.grammars.clearObservers()
|
||||||
waits(0) # yield to ui thread to make screen update more frequently
|
waits(0) # yield to ui thread to make screen update more frequently
|
||||||
|
|
||||||
ensureNoPathSubscriptions = ->
|
ensureNoPathSubscriptions = ->
|
||||||
|
|||||||
+45
-45
@@ -23,10 +23,10 @@ describe "the `syntax` global", ->
|
|||||||
describe "serialization", ->
|
describe "serialization", ->
|
||||||
it "remembers grammar overrides by path", ->
|
it "remembers grammar overrides by path", ->
|
||||||
filePath = '/foo/bar/file.js'
|
filePath = '/foo/bar/file.js'
|
||||||
expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby'
|
expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby'
|
||||||
atom.syntax.setGrammarOverrideForPath(filePath, 'source.ruby')
|
atom.grammars.setGrammarOverrideForPath(filePath, 'source.ruby')
|
||||||
syntax2 = atom.deserializers.deserialize(atom.syntax.serialize())
|
syntax2 = atom.deserializers.deserialize(atom.grammars.serialize())
|
||||||
syntax2.addGrammar(grammar) for grammar in atom.syntax.grammars when grammar isnt atom.syntax.nullGrammar
|
syntax2.addGrammar(grammar) for grammar in atom.grammars.grammars when grammar isnt atom.grammars.nullGrammar
|
||||||
expect(syntax2.selectGrammar(filePath).name).toBe 'Ruby'
|
expect(syntax2.selectGrammar(filePath).name).toBe 'Ruby'
|
||||||
|
|
||||||
describe ".selectGrammar(filePath)", ->
|
describe ".selectGrammar(filePath)", ->
|
||||||
@@ -35,15 +35,15 @@ describe "the `syntax` global", ->
|
|||||||
atom.packages.activatePackage('language-git')
|
atom.packages.activatePackage('language-git')
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(atom.syntax.selectGrammar("file.js").name).toBe "JavaScript" # based on extension (.js)
|
expect(atom.grammars.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.grammars.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.grammars.selectGrammar("Rakefile").name).toBe "Ruby" # based on the file's basename (Rakefile)
|
||||||
expect(atom.syntax.selectGrammar("curb").name).toBe "Null Grammar"
|
expect(atom.grammars.selectGrammar("curb").name).toBe "Null Grammar"
|
||||||
expect(atom.syntax.selectGrammar("/hu.git/config").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", ->
|
it "uses the filePath's shebang line if the grammar cannot be determined by the extension or basename", ->
|
||||||
filePath = require.resolve("./fixtures/shebang")
|
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", ->
|
it "uses the number of newlines in the first line regex to determine the number of lines to test against", ->
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
@@ -51,28 +51,28 @@ describe "the `syntax` global", ->
|
|||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
fileContent = "first-line\n<html>"
|
fileContent = "first-line\n<html>"
|
||||||
expect(atom.syntax.selectGrammar("dummy.coffee", fileContent).name).toBe "CoffeeScript"
|
expect(atom.grammars.selectGrammar("dummy.coffee", fileContent).name).toBe "CoffeeScript"
|
||||||
|
|
||||||
fileContent = '<?xml version="1.0" encoding="UTF-8"?>'
|
fileContent = '<?xml version="1.0" encoding="UTF-8"?>'
|
||||||
expect(atom.syntax.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Null Grammar"
|
expect(atom.grammars.selectGrammar("grammar.tmLanguage", fileContent).name).toBe "Null Grammar"
|
||||||
|
|
||||||
fileContent += '\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
|
fileContent += '\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
|
||||||
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", ->
|
it "doesn't read the file when the file contents are specified", ->
|
||||||
filePath = require.resolve("./fixtures/shebang")
|
filePath = require.resolve("./fixtures/shebang")
|
||||||
filePathContents = fs.readFileSync(filePath, 'utf8')
|
filePathContents = fs.readFileSync(filePath, 'utf8')
|
||||||
spyOn(fs, 'read').andCallThrough()
|
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()
|
expect(fs.read).not.toHaveBeenCalled()
|
||||||
|
|
||||||
it "allows the default grammar to be overridden for a path", ->
|
it "allows the default grammar to be overridden for a path", ->
|
||||||
filePath = '/foo/bar/file.js'
|
filePath = '/foo/bar/file.js'
|
||||||
expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby'
|
expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby'
|
||||||
atom.syntax.setGrammarOverrideForPath(filePath, 'source.ruby')
|
atom.grammars.setGrammarOverrideForPath(filePath, 'source.ruby')
|
||||||
expect(atom.syntax.selectGrammar(filePath).name).toBe 'Ruby'
|
expect(atom.grammars.selectGrammar(filePath).name).toBe 'Ruby'
|
||||||
atom.syntax.clearGrammarOverrideForPath(filePath)
|
atom.grammars.clearGrammarOverrideForPath(filePath)
|
||||||
expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby'
|
expect(atom.grammars.selectGrammar(filePath).name).not.toBe 'Ruby'
|
||||||
|
|
||||||
describe "when multiple grammars have matching fileTypes", ->
|
describe "when multiple grammars have matching fileTypes", ->
|
||||||
it "selects the grammar with the longest fileType match", ->
|
it "selects the grammar with the longest fileType match", ->
|
||||||
@@ -82,8 +82,8 @@ describe "the `syntax` global", ->
|
|||||||
scopeName: 'source1'
|
scopeName: 'source1'
|
||||||
fileTypes: ['test']
|
fileTypes: ['test']
|
||||||
)
|
)
|
||||||
grammar1 = atom.syntax.loadGrammarSync(grammarPath1)
|
grammar1 = atom.grammars.loadGrammarSync(grammarPath1)
|
||||||
expect(atom.syntax.selectGrammar('more.test', '')).toBe grammar1
|
expect(atom.grammars.selectGrammar('more.test', '')).toBe grammar1
|
||||||
|
|
||||||
grammarPath2 = temp.path(suffix: '.json')
|
grammarPath2 = temp.path(suffix: '.json')
|
||||||
fs.writeFileSync grammarPath2, JSON.stringify(
|
fs.writeFileSync grammarPath2, JSON.stringify(
|
||||||
@@ -91,44 +91,44 @@ describe "the `syntax` global", ->
|
|||||||
scopeName: 'source2'
|
scopeName: 'source2'
|
||||||
fileTypes: ['test', 'more.test']
|
fileTypes: ['test', 'more.test']
|
||||||
)
|
)
|
||||||
grammar2 = atom.syntax.loadGrammarSync(grammarPath2)
|
grammar2 = atom.grammars.loadGrammarSync(grammarPath2)
|
||||||
expect(atom.syntax.selectGrammar('more.test', '')).toBe grammar2
|
expect(atom.grammars.selectGrammar('more.test', '')).toBe grammar2
|
||||||
|
|
||||||
describe "when there is no file path", ->
|
describe "when there is no file path", ->
|
||||||
it "does not throw an exception (regression)", ->
|
it "does not throw an exception (regression)", ->
|
||||||
expect(-> atom.syntax.selectGrammar(null, '#!/usr/bin/ruby')).not.toThrow()
|
expect(-> atom.grammars.selectGrammar(null, '#!/usr/bin/ruby')).not.toThrow()
|
||||||
expect(-> atom.syntax.selectGrammar(null, '')).not.toThrow()
|
expect(-> atom.grammars.selectGrammar(null, '')).not.toThrow()
|
||||||
expect(-> atom.syntax.selectGrammar(null, null)).not.toThrow()
|
expect(-> atom.grammars.selectGrammar(null, null)).not.toThrow()
|
||||||
|
|
||||||
describe ".removeGrammar(grammar)", ->
|
describe ".removeGrammar(grammar)", ->
|
||||||
it "removes the grammar, so it won't be returned by selectGrammar", ->
|
it "removes the grammar, so it won't be returned by selectGrammar", ->
|
||||||
grammar = atom.syntax.selectGrammar('foo.js')
|
grammar = atom.grammars.selectGrammar('foo.js')
|
||||||
atom.syntax.removeGrammar(grammar)
|
atom.grammars.removeGrammar(grammar)
|
||||||
expect(atom.syntax.selectGrammar('foo.js').name).not.toBe grammar.name
|
expect(atom.grammars.selectGrammar('foo.js').name).not.toBe grammar.name
|
||||||
|
|
||||||
describe ".getProperty(scopeDescriptor)", ->
|
describe ".getProperty(scopeDescriptor)", ->
|
||||||
it "returns the property with the most specific scope selector", ->
|
it "returns the property with the most specific scope selector", ->
|
||||||
atom.syntax.addProperties(".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
|
atom.grammars.addProperties(".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
|
||||||
atom.syntax.addProperties(".source .string.quoted.double", foo: bar: baz: 22)
|
atom.grammars.addProperties(".source .string.quoted.double", foo: bar: baz: 22)
|
||||||
atom.syntax.addProperties(".source", foo: bar: baz: 11)
|
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.grammars.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.grammars.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.grammars.getProperty([".source.js", ".variable.assignment.js"], "foo.bar.baz")).toBe 11
|
||||||
expect(atom.syntax.getProperty([".text"], "foo.bar.baz")).toBeUndefined()
|
expect(atom.grammars.getProperty([".text"], "foo.bar.baz")).toBeUndefined()
|
||||||
|
|
||||||
it "favors the most recently added properties in the event of a specificity tie", ->
|
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.grammars.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.double", foo: bar: baz: 22)
|
||||||
|
|
||||||
expect(atom.syntax.getProperty([".source.coffee", ".string.quoted.single"], "foo.bar.baz")).toBe 42
|
expect(atom.grammars.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.double"], "foo.bar.baz")).toBe 22
|
||||||
|
|
||||||
describe ".removeProperties(name)", ->
|
describe ".removeProperties(name)", ->
|
||||||
it "allows properties to be removed by name", ->
|
it "allows properties to be removed by name", ->
|
||||||
atom.syntax.addProperties("a", ".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
|
atom.grammars.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("b", ".source .string.quoted.double", foo: bar: baz: 22)
|
||||||
|
|
||||||
atom.syntax.removeProperties("b")
|
atom.grammars.removeProperties("b")
|
||||||
expect(atom.syntax.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBeUndefined()
|
expect(atom.grammars.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
|
expect(atom.grammars.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42
|
||||||
|
|||||||
@@ -2532,7 +2532,7 @@ describe "TextEditorComponent", ->
|
|||||||
describe "grammar data attributes", ->
|
describe "grammar data attributes", ->
|
||||||
it "adds and updates the grammar data attribute based on the current grammar", ->
|
it "adds and updates the grammar data attribute based on the current grammar", ->
|
||||||
expect(wrapperNode.dataset.grammar).toBe 'source js'
|
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'
|
expect(wrapperNode.dataset.grammar).toBe 'text plain null-grammar'
|
||||||
|
|
||||||
describe "encoding data attributes", ->
|
describe "encoding data attributes", ->
|
||||||
|
|||||||
@@ -3357,17 +3357,17 @@ describe "TextEditor", ->
|
|||||||
it "switches to the better-matched grammar and re-tokenizes the buffer", ->
|
it "switches to the better-matched grammar and re-tokenizes the buffer", ->
|
||||||
editor.destroy()
|
editor.destroy()
|
||||||
|
|
||||||
jsGrammar = atom.syntax.selectGrammar('a.js')
|
jsGrammar = atom.grammars.selectGrammar('a.js')
|
||||||
atom.syntax.removeGrammar(jsGrammar)
|
atom.grammars.removeGrammar(jsGrammar)
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.workspace.open('sample.js', autoIndent: false).then (o) -> editor = o
|
atom.workspace.open('sample.js', autoIndent: false).then (o) -> editor = o
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
expect(editor.getGrammar()).toBe atom.syntax.nullGrammar
|
expect(editor.getGrammar()).toBe atom.grammars.nullGrammar
|
||||||
expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBe 1
|
expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBe 1
|
||||||
|
|
||||||
atom.syntax.addGrammar(jsGrammar)
|
atom.grammars.addGrammar(jsGrammar)
|
||||||
expect(editor.getGrammar()).toBe jsGrammar
|
expect(editor.getGrammar()).toBe jsGrammar
|
||||||
expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBeGreaterThan 1
|
expect(editor.tokenizedLineForScreenRow(0).tokens.length).toBeGreaterThan 1
|
||||||
|
|
||||||
@@ -3787,7 +3787,7 @@ describe "TextEditor", ->
|
|||||||
|
|
||||||
it "updates the grammar based on grammar overrides", ->
|
it "updates the grammar based on grammar overrides", ->
|
||||||
expect(editor.getGrammar().name).toBe 'JavaScript'
|
expect(editor.getGrammar().name).toBe 'JavaScript'
|
||||||
atom.syntax.setGrammarOverrideForPath(editor.getPath(), 'source.coffee')
|
atom.grammars.setGrammarOverrideForPath(editor.getPath(), 'source.coffee')
|
||||||
editor.reloadGrammar()
|
editor.reloadGrammar()
|
||||||
expect(editor.getGrammar().name).toBe 'CoffeeScript'
|
expect(editor.getGrammar().name).toBe 'CoffeeScript'
|
||||||
|
|
||||||
@@ -3805,7 +3805,7 @@ describe "TextEditor", ->
|
|||||||
atom.packages.activatePackage('language-hyperlink')
|
atom.packages.activatePackage('language-hyperlink')
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
grammar = atom.syntax.selectGrammar("text.js")
|
grammar = atom.grammars.selectGrammar("text.js")
|
||||||
{tokens} = grammar.tokenizeLine("var i; // http://github.com")
|
{tokens} = grammar.tokenizeLine("var i; // http://github.com")
|
||||||
|
|
||||||
expect(tokens[0].value).toBe "var"
|
expect(tokens[0].value).toBe "var"
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ describe "TokenizedBuffer", ->
|
|||||||
buffer = atom.project.bufferForPathSync()
|
buffer = atom.project.bufferForPathSync()
|
||||||
buffer.setText "<div class='name'><%= User.find(2).full_name %></div>"
|
buffer.setText "<div class='name'><%= User.find(2).full_name %></div>"
|
||||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||||
tokenizedBuffer.setGrammar(atom.syntax.selectGrammar('test.erb'))
|
tokenizedBuffer.setGrammar(atom.grammars.selectGrammar('test.erb'))
|
||||||
fullyTokenize(tokenizedBuffer)
|
fullyTokenize(tokenizedBuffer)
|
||||||
|
|
||||||
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ describe "Window", ->
|
|||||||
describe ".unloadEditorWindow()", ->
|
describe ".unloadEditorWindow()", ->
|
||||||
it "saves the serialized state of the window so it can be deserialized after reload", ->
|
it "saves the serialized state of the window so it can be deserialized after reload", ->
|
||||||
workspaceState = atom.workspace.serialize()
|
workspaceState = atom.workspace.serialize()
|
||||||
syntaxState = atom.syntax.serialize()
|
syntaxState = atom.grammars.serialize()
|
||||||
projectState = atom.project.serialize()
|
projectState = atom.project.serialize()
|
||||||
|
|
||||||
atom.unloadEditorWindow()
|
atom.unloadEditorWindow()
|
||||||
|
|||||||
+8
-4
@@ -131,8 +131,8 @@ class Atom extends Model
|
|||||||
# Public: A {Project} instance
|
# Public: A {Project} instance
|
||||||
project: null
|
project: null
|
||||||
|
|
||||||
# Public: A {Syntax} instance
|
# Public: A {GrammarRegistry} instance
|
||||||
syntax: null
|
grammars: null
|
||||||
|
|
||||||
# Public: A {PackageManager} instance
|
# Public: A {PackageManager} instance
|
||||||
packages: null
|
packages: null
|
||||||
@@ -241,7 +241,11 @@ class Atom extends Model
|
|||||||
@menu = new MenuManager({resourcePath})
|
@menu = new MenuManager({resourcePath})
|
||||||
@clipboard = new Clipboard()
|
@clipboard = new Clipboard()
|
||||||
|
|
||||||
@syntax = @deserializers.deserialize(@state.syntax) ? new GrammarRegistry()
|
@grammars = @deserializers.deserialize(@state.grammars ? @state.syntax) ? new GrammarRegistry()
|
||||||
|
|
||||||
|
Object.defineProperty this, 'syntax', get: ->
|
||||||
|
deprecate "The atom.syntax global is deprecated. Use atom.grammars instead."
|
||||||
|
@grammars
|
||||||
|
|
||||||
@subscribe @packages.onDidActivateAll => @watchThemes()
|
@subscribe @packages.onDidActivateAll => @watchThemes()
|
||||||
|
|
||||||
@@ -554,7 +558,7 @@ class Atom extends Model
|
|||||||
unloadEditorWindow: ->
|
unloadEditorWindow: ->
|
||||||
return if not @project and not @workspaceView
|
return if not @project and not @workspaceView
|
||||||
|
|
||||||
@state.syntax = @syntax.serialize()
|
@state.grammars = @grammars.serialize()
|
||||||
@state.project = @project.serialize()
|
@state.project = @project.serialize()
|
||||||
@state.workspace = @workspace.serialize()
|
@state.workspace = @workspace.serialize()
|
||||||
@packages.deactivatePackages()
|
@packages.deactivatePackages()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Token = require './token'
|
|||||||
|
|
||||||
# Extended: Syntax class holding the grammars used for tokenizing.
|
# Extended: Syntax class holding the grammars used for tokenizing.
|
||||||
#
|
#
|
||||||
# An instance of this class is always available as the `atom.syntax` global.
|
# An instance of this class is always available as the `atom.grammars` global.
|
||||||
#
|
#
|
||||||
# The Syntax class also contains properties for things such as the
|
# The Syntax class also contains properties for things such as the
|
||||||
# language-specific comment regexes. See {::getProperty} for more details.
|
# language-specific comment regexes. See {::getProperty} for more details.
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class Package
|
|||||||
grammarPaths = fs.listSync(grammarsDirPath, ['json', 'cson'])
|
grammarPaths = fs.listSync(grammarsDirPath, ['json', 'cson'])
|
||||||
for grammarPath in grammarPaths
|
for grammarPath in grammarPaths
|
||||||
try
|
try
|
||||||
grammar = atom.syntax.readGrammarSync(grammarPath)
|
grammar = atom.grammars.readGrammarSync(grammarPath)
|
||||||
grammar.packageName = @name
|
grammar.packageName = @name
|
||||||
@grammars.push(grammar)
|
@grammars.push(grammar)
|
||||||
grammar.activate()
|
grammar.activate()
|
||||||
@@ -268,7 +268,7 @@ class Package
|
|||||||
return Q() if @grammarsLoaded
|
return Q() if @grammarsLoaded
|
||||||
|
|
||||||
loadGrammar = (grammarPath, callback) =>
|
loadGrammar = (grammarPath, callback) =>
|
||||||
atom.syntax.readGrammar grammarPath, (error, grammar) =>
|
atom.grammars.readGrammar grammarPath, (error, grammar) =>
|
||||||
if error?
|
if error?
|
||||||
console.warn("Failed to load grammar: #{grammarPath}", error.stack ? error)
|
console.warn("Failed to load grammar: #{grammarPath}", error.stack ? error)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ class TokenizedBuffer extends Model
|
|||||||
constructor: ({@buffer, @tabLength, @invisibles}) ->
|
constructor: ({@buffer, @tabLength, @invisibles}) ->
|
||||||
@emitter = new Emitter
|
@emitter = new Emitter
|
||||||
|
|
||||||
@subscribe atom.syntax.onDidAddGrammar(@grammarAddedOrUpdated)
|
@subscribe atom.grammars.onDidAddGrammar(@grammarAddedOrUpdated)
|
||||||
@subscribe atom.syntax.onDidUpdateGrammar(@grammarAddedOrUpdated)
|
@subscribe atom.grammars.onDidUpdateGrammar(@grammarAddedOrUpdated)
|
||||||
|
|
||||||
@subscribe @buffer.preemptDidChange (e) => @handleBufferChange(e)
|
@subscribe @buffer.preemptDidChange (e) => @handleBufferChange(e)
|
||||||
@subscribe @buffer.onDidChangePath (@bufferPath) => @reloadGrammar()
|
@subscribe @buffer.onDidChangePath (@bufferPath) => @reloadGrammar()
|
||||||
@@ -98,7 +98,7 @@ class TokenizedBuffer extends Model
|
|||||||
@emitter.emit 'did-change-grammar', grammar
|
@emitter.emit 'did-change-grammar', grammar
|
||||||
|
|
||||||
reloadGrammar: ->
|
reloadGrammar: ->
|
||||||
if grammar = atom.syntax.selectGrammar(@buffer.getPath(), @buffer.getText())
|
if grammar = atom.grammars.selectGrammar(@buffer.getPath(), @buffer.getText())
|
||||||
@setGrammar(grammar)
|
@setGrammar(grammar)
|
||||||
else
|
else
|
||||||
throw new Error("No grammar found for path: #{path}")
|
throw new Error("No grammar found for path: #{path}")
|
||||||
|
|||||||
@@ -105,13 +105,13 @@ class Workspace extends Model
|
|||||||
|
|
||||||
packageNames.push(packageName)
|
packageNames.push(packageName)
|
||||||
for scopeName in includedGrammarScopes ? []
|
for scopeName in includedGrammarScopes ? []
|
||||||
addGrammar(atom.syntax.grammarForScopeName(scopeName))
|
addGrammar(atom.grammars.grammarForScopeName(scopeName))
|
||||||
|
|
||||||
editors = @getTextEditors()
|
editors = @getTextEditors()
|
||||||
addGrammar(editor.getGrammar()) for editor in editors
|
addGrammar(editor.getGrammar()) for editor in editors
|
||||||
|
|
||||||
if editors.length > 0
|
if editors.length > 0
|
||||||
for grammar in atom.syntax.getGrammars() when grammar.injectionSelector
|
for grammar in atom.grammars.getGrammars() when grammar.injectionSelector
|
||||||
addGrammar(grammar)
|
addGrammar(grammar)
|
||||||
|
|
||||||
_.uniq(packageNames)
|
_.uniq(packageNames)
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário