scopeDescriptor -> scopes
Now that we have a real ScopeDescriptor object, these should change back!
Esse commit está contido em:
@@ -3660,10 +3660,10 @@ describe "TextEditor", ->
|
|||||||
{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"
|
||||||
expect(tokens[0].scopeDescriptor).toEqual ["source.js", "storage.modifier.js"]
|
expect(tokens[0].scopes).toEqual ["source.js", "storage.modifier.js"]
|
||||||
|
|
||||||
expect(tokens[6].value).toBe "http://github.com"
|
expect(tokens[6].value).toBe "http://github.com"
|
||||||
expect(tokens[6].scopeDescriptor).toEqual ["source.js", "comment.line.double-slash.js", "markup.underline.link.http.hyperlink"]
|
expect(tokens[6].scopes).toEqual ["source.js", "comment.line.double-slash.js", "markup.underline.link.http.hyperlink"]
|
||||||
|
|
||||||
describe "when the grammar is added", ->
|
describe "when the grammar is added", ->
|
||||||
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
|
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
|
||||||
@@ -3675,7 +3675,7 @@ describe "TextEditor", ->
|
|||||||
|
|
||||||
{tokens} = editor.tokenizedLineForScreenRow(0)
|
{tokens} = editor.tokenizedLineForScreenRow(0)
|
||||||
expect(tokens[1].value).toBe " http://github.com"
|
expect(tokens[1].value).toBe " http://github.com"
|
||||||
expect(tokens[1].scopeDescriptor).toEqual ["source.js", "comment.line.double-slash.js"]
|
expect(tokens[1].scopes).toEqual ["source.js", "comment.line.double-slash.js"]
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage('language-hyperlink')
|
atom.packages.activatePackage('language-hyperlink')
|
||||||
@@ -3683,7 +3683,7 @@ describe "TextEditor", ->
|
|||||||
runs ->
|
runs ->
|
||||||
{tokens} = editor.tokenizedLineForScreenRow(0)
|
{tokens} = editor.tokenizedLineForScreenRow(0)
|
||||||
expect(tokens[2].value).toBe "http://github.com"
|
expect(tokens[2].value).toBe "http://github.com"
|
||||||
expect(tokens[2].scopeDescriptor).toEqual ["source.js", "comment.line.double-slash.js", "markup.underline.link.http.hyperlink"]
|
expect(tokens[2].scopes).toEqual ["source.js", "comment.line.double-slash.js", "markup.underline.link.http.hyperlink"]
|
||||||
|
|
||||||
describe "when the grammar is updated", ->
|
describe "when the grammar is updated", ->
|
||||||
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
|
it "retokenizes existing buffers that contain tokens that match the injection selector", ->
|
||||||
@@ -3695,7 +3695,7 @@ describe "TextEditor", ->
|
|||||||
|
|
||||||
{tokens} = editor.tokenizedLineForScreenRow(0)
|
{tokens} = editor.tokenizedLineForScreenRow(0)
|
||||||
expect(tokens[1].value).toBe " SELECT * FROM OCTOCATS"
|
expect(tokens[1].value).toBe " SELECT * FROM OCTOCATS"
|
||||||
expect(tokens[1].scopeDescriptor).toEqual ["source.js", "comment.line.double-slash.js"]
|
expect(tokens[1].scopes).toEqual ["source.js", "comment.line.double-slash.js"]
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage('package-with-injection-selector')
|
atom.packages.activatePackage('package-with-injection-selector')
|
||||||
@@ -3703,7 +3703,7 @@ describe "TextEditor", ->
|
|||||||
runs ->
|
runs ->
|
||||||
{tokens} = editor.tokenizedLineForScreenRow(0)
|
{tokens} = editor.tokenizedLineForScreenRow(0)
|
||||||
expect(tokens[1].value).toBe " SELECT * FROM OCTOCATS"
|
expect(tokens[1].value).toBe " SELECT * FROM OCTOCATS"
|
||||||
expect(tokens[1].scopeDescriptor).toEqual ["source.js", "comment.line.double-slash.js"]
|
expect(tokens[1].scopes).toEqual ["source.js", "comment.line.double-slash.js"]
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage('language-sql')
|
atom.packages.activatePackage('language-sql')
|
||||||
@@ -3711,7 +3711,7 @@ describe "TextEditor", ->
|
|||||||
runs ->
|
runs ->
|
||||||
{tokens} = editor.tokenizedLineForScreenRow(0)
|
{tokens} = editor.tokenizedLineForScreenRow(0)
|
||||||
expect(tokens[2].value).toBe "SELECT"
|
expect(tokens[2].value).toBe "SELECT"
|
||||||
expect(tokens[2].scopeDescriptor).toEqual ["source.js", "comment.line.double-slash.js", "keyword.other.DML.sql"]
|
expect(tokens[2].scopes).toEqual ["source.js", "comment.line.double-slash.js", "keyword.other.DML.sql"]
|
||||||
|
|
||||||
describe ".normalizeTabsInBufferRange()", ->
|
describe ".normalizeTabsInBufferRange()", ->
|
||||||
it "normalizes tabs depending on the editor's soft tab/tab length settings", ->
|
it "normalizes tabs depending on the editor's soft tab/tab length settings", ->
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ describe "TokenizedBuffer", ->
|
|||||||
it "initially creates un-tokenized screen lines, then tokenizes lines chunk at a time in the background", ->
|
it "initially creates un-tokenized screen lines, then tokenizes lines chunk at a time in the background", ->
|
||||||
line0 = tokenizedBuffer.tokenizedLineForRow(0)
|
line0 = tokenizedBuffer.tokenizedLineForRow(0)
|
||||||
expect(line0.tokens.length).toBe 1
|
expect(line0.tokens.length).toBe 1
|
||||||
expect(line0.tokens[0]).toEqual(value: line0.text, scopeDescriptor: ['source.js'])
|
expect(line0.tokens[0]).toEqual(value: line0.text, scopes: ['source.js'])
|
||||||
|
|
||||||
line11 = tokenizedBuffer.tokenizedLineForRow(11)
|
line11 = tokenizedBuffer.tokenizedLineForRow(11)
|
||||||
expect(line11.tokens.length).toBe 2
|
expect(line11.tokens.length).toBe 2
|
||||||
expect(line11.tokens[0]).toEqual(value: " ", scopeDescriptor: ['source.js'], isAtomic: true)
|
expect(line11.tokens[0]).toEqual(value: " ", scopes: ['source.js'], isAtomic: true)
|
||||||
expect(line11.tokens[1]).toEqual(value: "return sort(Array.apply(this, arguments));", scopeDescriptor: ['source.js'])
|
expect(line11.tokens[1]).toEqual(value: "return sort(Array.apply(this, arguments));", scopes: ['source.js'])
|
||||||
|
|
||||||
# background tokenization has not begun
|
# background tokenization has not begun
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(0).ruleStack).toBeUndefined()
|
expect(tokenizedBuffer.tokenizedLineForRow(0).ruleStack).toBeUndefined()
|
||||||
@@ -149,10 +149,10 @@ describe "TokenizedBuffer", ->
|
|||||||
it "updates tokens to reflect the change", ->
|
it "updates tokens to reflect the change", ->
|
||||||
buffer.setTextInRange([[0, 0], [2, 0]], "foo()\n7\n")
|
buffer.setTextInRange([[0, 0], [2, 0]], "foo()\n7\n")
|
||||||
|
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(0).tokens[1]).toEqual(value: '(', scopeDescriptor: ['source.js', 'meta.brace.round.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(0).tokens[1]).toEqual(value: '(', scopes: ['source.js', 'meta.brace.round.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0]).toEqual(value: '7', scopeDescriptor: ['source.js', 'constant.numeric.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0]).toEqual(value: '7', scopes: ['source.js', 'constant.numeric.js'])
|
||||||
# line 2 is unchanged
|
# line 2 is unchanged
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[2]).toEqual(value: 'if', scopeDescriptor: ['source.js', 'keyword.control.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[2]).toEqual(value: 'if', scopes: ['source.js', 'keyword.control.js'])
|
||||||
|
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
@@ -164,7 +164,7 @@ describe "TokenizedBuffer", ->
|
|||||||
buffer.insert([5, 30], '/* */')
|
buffer.insert([5, 30], '/* */')
|
||||||
changeHandler.reset()
|
changeHandler.reset()
|
||||||
buffer.insert([2, 0], '/*')
|
buffer.insert([2, 0], '/*')
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopeDescriptor).toEqual ['source.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopes).toEqual ['source.js']
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
delete event.bufferChange
|
delete event.bufferChange
|
||||||
@@ -172,9 +172,9 @@ describe "TokenizedBuffer", ->
|
|||||||
changeHandler.reset()
|
changeHandler.reset()
|
||||||
|
|
||||||
advanceClock()
|
advanceClock()
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
delete event.bufferChange
|
delete event.bufferChange
|
||||||
@@ -185,23 +185,23 @@ describe "TokenizedBuffer", ->
|
|||||||
buffer.insert([5, 0], '*/')
|
buffer.insert([5, 0], '*/')
|
||||||
|
|
||||||
buffer.insert([1, 0], 'var ')
|
buffer.insert([1, 0], 'var ')
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
|
|
||||||
describe "when lines are both updated and removed", ->
|
describe "when lines are both updated and removed", ->
|
||||||
it "updates tokens to reflect the change", ->
|
it "updates tokens to reflect the change", ->
|
||||||
buffer.setTextInRange([[1, 0], [3, 0]], "foo()")
|
buffer.setTextInRange([[1, 0], [3, 0]], "foo()")
|
||||||
|
|
||||||
# previous line 0 remains
|
# previous line 0 remains
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(0).tokens[0]).toEqual(value: 'var', scopeDescriptor: ['source.js', 'storage.modifier.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(0).tokens[0]).toEqual(value: 'var', scopes: ['source.js', 'storage.modifier.js'])
|
||||||
|
|
||||||
# previous line 3 should be combined with input to form line 1
|
# previous line 3 should be combined with input to form line 1
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0]).toEqual(value: 'foo', scopeDescriptor: ['source.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0]).toEqual(value: 'foo', scopes: ['source.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[6]).toEqual(value: '=', scopeDescriptor: ['source.js', 'keyword.operator.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[6]).toEqual(value: '=', scopes: ['source.js', 'keyword.operator.js'])
|
||||||
|
|
||||||
# lines below deleted regions should be shifted upward
|
# lines below deleted regions should be shifted upward
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[2]).toEqual(value: 'while', scopeDescriptor: ['source.js', 'keyword.control.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[2]).toEqual(value: 'while', scopes: ['source.js', 'keyword.control.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[4]).toEqual(value: '=', scopeDescriptor: ['source.js', 'keyword.operator.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[4]).toEqual(value: '=', scopes: ['source.js', 'keyword.operator.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[4]).toEqual(value: '<', scopeDescriptor: ['source.js', 'keyword.operator.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[4]).toEqual(value: '<', scopes: ['source.js', 'keyword.operator.js'])
|
||||||
|
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
@@ -214,8 +214,8 @@ describe "TokenizedBuffer", ->
|
|||||||
changeHandler.reset()
|
changeHandler.reset()
|
||||||
|
|
||||||
buffer.setTextInRange([[2, 0], [3, 0]], '/*')
|
buffer.setTextInRange([[2, 0], [3, 0]], '/*')
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js', 'punctuation.definition.comment.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0].scopes).toEqual ['source.js', 'comment.block.js', 'punctuation.definition.comment.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopeDescriptor).toEqual ['source.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopes).toEqual ['source.js']
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
delete event.bufferChange
|
delete event.bufferChange
|
||||||
@@ -223,8 +223,8 @@ describe "TokenizedBuffer", ->
|
|||||||
changeHandler.reset()
|
changeHandler.reset()
|
||||||
|
|
||||||
advanceClock()
|
advanceClock()
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
delete event.bufferChange
|
delete event.bufferChange
|
||||||
@@ -235,19 +235,19 @@ describe "TokenizedBuffer", ->
|
|||||||
buffer.setTextInRange([[1, 0], [2, 0]], "foo()\nbar()\nbaz()\nquux()")
|
buffer.setTextInRange([[1, 0], [2, 0]], "foo()\nbar()\nbaz()\nquux()")
|
||||||
|
|
||||||
# previous line 0 remains
|
# previous line 0 remains
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(0).tokens[0]).toEqual( value: 'var', scopeDescriptor: ['source.js', 'storage.modifier.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(0).tokens[0]).toEqual( value: 'var', scopes: ['source.js', 'storage.modifier.js'])
|
||||||
|
|
||||||
# 3 new lines inserted
|
# 3 new lines inserted
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0]).toEqual(value: 'foo', scopeDescriptor: ['source.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(1).tokens[0]).toEqual(value: 'foo', scopes: ['source.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0]).toEqual(value: 'bar', scopeDescriptor: ['source.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0]).toEqual(value: 'bar', scopes: ['source.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0]).toEqual(value: 'baz', scopeDescriptor: ['source.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0]).toEqual(value: 'baz', scopes: ['source.js'])
|
||||||
|
|
||||||
# previous line 2 is joined with quux() on line 4
|
# previous line 2 is joined with quux() on line 4
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0]).toEqual(value: 'quux', scopeDescriptor: ['source.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0]).toEqual(value: 'quux', scopes: ['source.js'])
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[4]).toEqual(value: 'if', scopeDescriptor: ['source.js', 'keyword.control.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[4]).toEqual(value: 'if', scopes: ['source.js', 'keyword.control.js'])
|
||||||
|
|
||||||
# previous line 3 is pushed down to become line 5
|
# previous line 3 is pushed down to become line 5
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[4]).toEqual(value: '=', scopeDescriptor: ['source.js', 'keyword.operator.js'])
|
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[4]).toEqual(value: '=', scopes: ['source.js', 'keyword.operator.js'])
|
||||||
|
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
@@ -264,17 +264,17 @@ describe "TokenizedBuffer", ->
|
|||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
delete event.bufferChange
|
delete event.bufferChange
|
||||||
expect(event).toEqual(start: 2, end: 2, delta: 2)
|
expect(event).toEqual(start: 2, end: 2, delta: 2)
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js', 'punctuation.definition.comment.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0].scopes).toEqual ['source.js', 'comment.block.js', 'punctuation.definition.comment.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[0].scopeDescriptor).toEqual ['source.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[0].scopes).toEqual ['source.js']
|
||||||
changeHandler.reset()
|
changeHandler.reset()
|
||||||
|
|
||||||
advanceClock() # tokenize invalidated lines in background
|
advanceClock() # tokenize invalidated lines in background
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(5).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(6).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(6).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(7).tokens[0].scopeDescriptor).toEqual ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(7).tokens[0].scopes).toEqual ['source.js', 'comment.block.js']
|
||||||
expect(tokenizedBuffer.tokenizedLineForRow(8).tokens[0].scopeDescriptor).not.toBe ['source.js', 'comment.block.js']
|
expect(tokenizedBuffer.tokenizedLineForRow(8).tokens[0].scopes).not.toBe ['source.js', 'comment.block.js']
|
||||||
|
|
||||||
expect(changeHandler).toHaveBeenCalled()
|
expect(changeHandler).toHaveBeenCalled()
|
||||||
[event] = changeHandler.argsForCall[0]
|
[event] = changeHandler.argsForCall[0]
|
||||||
@@ -343,7 +343,7 @@ describe "TokenizedBuffer", ->
|
|||||||
expect(tokens[0].value).toBe "#"
|
expect(tokens[0].value).toBe "#"
|
||||||
expect(tokens[1].value).toBe " Econ 101"
|
expect(tokens[1].value).toBe " Econ 101"
|
||||||
expect(tokens[2].value).toBe tabAsSpaces
|
expect(tokens[2].value).toBe tabAsSpaces
|
||||||
expect(tokens[2].scopeDescriptor).toEqual tokens[1].scopeDescriptor
|
expect(tokens[2].scopes).toEqual tokens[1].scopes
|
||||||
expect(tokens[2].isAtomic).toBeTruthy()
|
expect(tokens[2].isAtomic).toBeTruthy()
|
||||||
expect(tokens[3].value).toBe ""
|
expect(tokens[3].value).toBe ""
|
||||||
|
|
||||||
@@ -526,7 +526,7 @@ describe "TokenizedBuffer", ->
|
|||||||
fullyTokenize(tokenizedBuffer)
|
fullyTokenize(tokenizedBuffer)
|
||||||
|
|
||||||
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
||||||
expect(tokens[0]).toEqual value: "<div class='name'>", scopeDescriptor: ["text.html.ruby"]
|
expect(tokens[0]).toEqual value: "<div class='name'>", scopes: ["text.html.ruby"]
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage('language-html')
|
atom.packages.activatePackage('language-html')
|
||||||
@@ -534,7 +534,7 @@ describe "TokenizedBuffer", ->
|
|||||||
runs ->
|
runs ->
|
||||||
fullyTokenize(tokenizedBuffer)
|
fullyTokenize(tokenizedBuffer)
|
||||||
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
|
||||||
expect(tokens[0]).toEqual value: '<', scopeDescriptor: ["text.html.ruby","meta.tag.block.any.html","punctuation.definition.tag.begin.html"]
|
expect(tokens[0]).toEqual value: '<', scopes: ["text.html.ruby","meta.tag.block.any.html","punctuation.definition.tag.begin.html"]
|
||||||
|
|
||||||
describe ".tokenForPosition(position)", ->
|
describe ".tokenForPosition(position)", ->
|
||||||
afterEach ->
|
afterEach ->
|
||||||
@@ -545,9 +545,9 @@ describe "TokenizedBuffer", ->
|
|||||||
buffer = atom.project.bufferForPathSync('sample.js')
|
buffer = atom.project.bufferForPathSync('sample.js')
|
||||||
tokenizedBuffer = new TokenizedBuffer({buffer})
|
tokenizedBuffer = new TokenizedBuffer({buffer})
|
||||||
fullyTokenize(tokenizedBuffer)
|
fullyTokenize(tokenizedBuffer)
|
||||||
expect(tokenizedBuffer.tokenForPosition([1,0]).scopeDescriptor).toEqual ["source.js"]
|
expect(tokenizedBuffer.tokenForPosition([1,0]).scopes).toEqual ["source.js"]
|
||||||
expect(tokenizedBuffer.tokenForPosition([1,1]).scopeDescriptor).toEqual ["source.js"]
|
expect(tokenizedBuffer.tokenForPosition([1,1]).scopes).toEqual ["source.js"]
|
||||||
expect(tokenizedBuffer.tokenForPosition([1,2]).scopeDescriptor).toEqual ["source.js", "storage.modifier.js"]
|
expect(tokenizedBuffer.tokenForPosition([1,2]).scopes).toEqual ["source.js", "storage.modifier.js"]
|
||||||
|
|
||||||
describe ".bufferRangeForScopeAtPosition(selector, position)", ->
|
describe ".bufferRangeForScopeAtPosition(selector, position)", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe "TokenizedLine", ->
|
|||||||
ensureValidScopeTree(child, scopeDescriptor.concat([scopeTree.scope]))
|
ensureValidScopeTree(child, scopeDescriptor.concat([scopeTree.scope]))
|
||||||
else
|
else
|
||||||
expect(scopeTree).toBe tokens[tokenIndex++]
|
expect(scopeTree).toBe tokens[tokenIndex++]
|
||||||
expect(scopeDescriptor).toEqual scopeTree.scopeDescriptor
|
expect(scopeDescriptor).toEqual scopeTree.scopes
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.project.open('coffee.coffee').then (o) -> editor = o
|
atom.project.open('coffee.coffee').then (o) -> editor = o
|
||||||
|
|||||||
@@ -650,7 +650,7 @@ class DisplayBuffer extends Model
|
|||||||
left = 0
|
left = 0
|
||||||
column = 0
|
column = 0
|
||||||
for token in @tokenizedLineForScreenRow(targetRow).tokens
|
for token in @tokenizedLineForScreenRow(targetRow).tokens
|
||||||
charWidths = @getScopedCharWidths(token.scopeDescriptor)
|
charWidths = @getScopedCharWidths(token.scopes)
|
||||||
for char in token.value
|
for char in token.value
|
||||||
return {top, left} if column is targetColumn
|
return {top, left} if column is targetColumn
|
||||||
left += charWidths[char] ? defaultCharWidth unless char is '\0'
|
left += charWidths[char] ? defaultCharWidth unless char is '\0'
|
||||||
@@ -669,7 +669,7 @@ class DisplayBuffer extends Model
|
|||||||
left = 0
|
left = 0
|
||||||
column = 0
|
column = 0
|
||||||
for token in @tokenizedLineForScreenRow(row).tokens
|
for token in @tokenizedLineForScreenRow(row).tokens
|
||||||
charWidths = @getScopedCharWidths(token.scopeDescriptor)
|
charWidths = @getScopedCharWidths(token.scopes)
|
||||||
for char in token.value
|
for char in token.value
|
||||||
charWidth = charWidths[char] ? defaultCharWidth
|
charWidth = charWidths[char] ? defaultCharWidth
|
||||||
break if targetLeft <= left + (charWidth / 2)
|
break if targetLeft <= left + (charWidth / 2)
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ LinesComponent = React.createClass
|
|||||||
firstTrailingWhitespacePosition = text.search(/\s*$/)
|
firstTrailingWhitespacePosition = text.search(/\s*$/)
|
||||||
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
|
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
|
||||||
for token in tokens
|
for token in tokens
|
||||||
innerHTML += @updateScopeStack(scopeStack, token.scopeDescriptor)
|
innerHTML += @updateScopeStack(scopeStack, token.scopes)
|
||||||
hasIndentGuide = not mini and showIndentGuide and (token.hasLeadingWhitespace() or (token.hasTrailingWhitespace() and lineIsWhitespaceOnly))
|
hasIndentGuide = not mini and showIndentGuide and (token.hasLeadingWhitespace() or (token.hasTrailingWhitespace() and lineIsWhitespaceOnly))
|
||||||
innerHTML += token.getValueAsHtml({hasIndentGuide})
|
innerHTML += token.getValueAsHtml({hasIndentGuide})
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ class Syntax extends GrammarRegistry
|
|||||||
serialize: ->
|
serialize: ->
|
||||||
{deserializer: @constructor.name, @grammarOverridesByPath}
|
{deserializer: @constructor.name, @grammarOverridesByPath}
|
||||||
|
|
||||||
createToken: (value, scopeDescriptor) -> new Token({value, scopeDescriptor})
|
createToken: (value, scopes) -> new Token({value, scopes})
|
||||||
|
|
||||||
# Deprecated: Used by settings-view to display snippets for packages
|
# Deprecated: Used by settings-view to display snippets for packages
|
||||||
@::accessor 'propertyStore', ->
|
@::accessor 'propertyStore', ->
|
||||||
|
|||||||
@@ -2407,7 +2407,7 @@ class TextEditor extends Model
|
|||||||
# Extended: Determine if the given row is entirely a comment
|
# Extended: Determine if the given row is entirely a comment
|
||||||
isBufferRowCommented: (bufferRow) ->
|
isBufferRowCommented: (bufferRow) ->
|
||||||
if match = @lineTextForBufferRow(bufferRow).match(/\S/)
|
if match = @lineTextForBufferRow(bufferRow).match(/\S/)
|
||||||
scopeDescriptor = @tokenForBufferPosition([bufferRow, match.index]).scopeDescriptor
|
scopeDescriptor = @tokenForBufferPosition([bufferRow, match.index]).scopes
|
||||||
@commentScopeSelector ?= new TextMateScopeSelector('comment.*')
|
@commentScopeSelector ?= new TextMateScopeSelector('comment.*')
|
||||||
@commentScopeSelector.matches(scopeDescriptor)
|
@commentScopeSelector.matches(scopeDescriptor)
|
||||||
|
|
||||||
|
|||||||
+12
-19
@@ -14,35 +14,28 @@ module.exports =
|
|||||||
class Token
|
class Token
|
||||||
value: null
|
value: null
|
||||||
hasPairedCharacter: false
|
hasPairedCharacter: false
|
||||||
scopeDescriptor: null
|
scopes: null
|
||||||
isAtomic: null
|
isAtomic: null
|
||||||
isHardTab: null
|
isHardTab: null
|
||||||
firstNonWhitespaceIndex: null
|
firstNonWhitespaceIndex: null
|
||||||
firstTrailingWhitespaceIndex: null
|
firstTrailingWhitespaceIndex: null
|
||||||
hasInvisibleCharacters: false
|
hasInvisibleCharacters: false
|
||||||
|
|
||||||
Object.defineProperty @::, 'scopes', get: ->
|
constructor: ({@value, @scopes, @isAtomic, @bufferDelta, @isHardTab}) ->
|
||||||
deprecate 'Use ::scopeDescriptor instead'
|
|
||||||
@scopeDescriptor
|
|
||||||
|
|
||||||
constructor: ({@value, @scopeDescriptor, @isAtomic, @bufferDelta, @isHardTab}) ->
|
|
||||||
@screenDelta = @value.length
|
@screenDelta = @value.length
|
||||||
@bufferDelta ?= @screenDelta
|
@bufferDelta ?= @screenDelta
|
||||||
@hasPairedCharacter = textUtils.hasPairedCharacter(@value)
|
@hasPairedCharacter = textUtils.hasPairedCharacter(@value)
|
||||||
|
|
||||||
isEqual: (other) ->
|
isEqual: (other) ->
|
||||||
# TODO: scopes is deprecated. This is here for the sake of lang package tests
|
# TODO: scopes is deprecated. This is here for the sake of lang package tests
|
||||||
scopeDescriptor = other.scopeDescriptor ? other.scopes
|
@value == other.value and _.isEqual(@scopes, other.scopes) and !!@isAtomic == !!other.isAtomic
|
||||||
deprecate 'Test the Token for `scopeDescriptor` rather than `scopes`' if other.scopes?
|
|
||||||
|
|
||||||
@value == other.value and _.isEqual(@scopeDescriptor, scopeDescriptor) and !!@isAtomic == !!other.isAtomic
|
|
||||||
|
|
||||||
isBracket: ->
|
isBracket: ->
|
||||||
/^meta\.brace\b/.test(_.last(@scopeDescriptor))
|
/^meta\.brace\b/.test(_.last(@scopes))
|
||||||
|
|
||||||
splitAt: (splitIndex) ->
|
splitAt: (splitIndex) ->
|
||||||
leftToken = new Token(value: @value.substring(0, splitIndex), scopeDescriptor: @scopeDescriptor)
|
leftToken = new Token(value: @value.substring(0, splitIndex), scopes: @scopes)
|
||||||
rightToken = new Token(value: @value.substring(splitIndex), scopeDescriptor: @scopeDescriptor)
|
rightToken = new Token(value: @value.substring(splitIndex), scopes: @scopes)
|
||||||
|
|
||||||
if @firstNonWhitespaceIndex?
|
if @firstNonWhitespaceIndex?
|
||||||
leftToken.firstNonWhitespaceIndex = Math.min(splitIndex, @firstNonWhitespaceIndex)
|
leftToken.firstNonWhitespaceIndex = Math.min(splitIndex, @firstNonWhitespaceIndex)
|
||||||
@@ -101,7 +94,7 @@ class Token
|
|||||||
else
|
else
|
||||||
breakOutLeadingSoftTabs = false
|
breakOutLeadingSoftTabs = false
|
||||||
value = match[0]
|
value = match[0]
|
||||||
token = new Token({value, @scopeDescriptor})
|
token = new Token({value, @scopes})
|
||||||
column += token.value.length
|
column += token.value.length
|
||||||
outputTokens.push(token)
|
outputTokens.push(token)
|
||||||
|
|
||||||
@@ -115,7 +108,7 @@ class Token
|
|||||||
while index < @value.length
|
while index < @value.length
|
||||||
if textUtils.isPairedCharacter(@value, index)
|
if textUtils.isPairedCharacter(@value, index)
|
||||||
if nonPairStart isnt index
|
if nonPairStart isnt index
|
||||||
outputTokens.push(new Token({value: @value[nonPairStart...index], @scopeDescriptor}))
|
outputTokens.push(new Token({value: @value[nonPairStart...index], @scopes}))
|
||||||
outputTokens.push(@buildPairedCharacterToken(@value, index))
|
outputTokens.push(@buildPairedCharacterToken(@value, index))
|
||||||
index += 2
|
index += 2
|
||||||
nonPairStart = index
|
nonPairStart = index
|
||||||
@@ -123,14 +116,14 @@ class Token
|
|||||||
index++
|
index++
|
||||||
|
|
||||||
if nonPairStart isnt index
|
if nonPairStart isnt index
|
||||||
outputTokens.push(new Token({value: @value[nonPairStart...index], @scopeDescriptor}))
|
outputTokens.push(new Token({value: @value[nonPairStart...index], @scopes}))
|
||||||
|
|
||||||
outputTokens
|
outputTokens
|
||||||
|
|
||||||
buildPairedCharacterToken: (value, index) ->
|
buildPairedCharacterToken: (value, index) ->
|
||||||
new Token(
|
new Token(
|
||||||
value: value[index..index + 1]
|
value: value[index..index + 1]
|
||||||
scopeDescriptor: @scopeDescriptor
|
scopes: @scopes
|
||||||
isAtomic: true
|
isAtomic: true
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -144,7 +137,7 @@ class Token
|
|||||||
tabStop = tabLength - (column % tabLength)
|
tabStop = tabLength - (column % tabLength)
|
||||||
new Token(
|
new Token(
|
||||||
value: _.multiplyString(" ", tabStop)
|
value: _.multiplyString(" ", tabStop)
|
||||||
scopeDescriptor: @scopeDescriptor
|
scopes: @scopes
|
||||||
bufferDelta: if isHardTab then 1 else tabStop
|
bufferDelta: if isHardTab then 1 else tabStop
|
||||||
isAtomic: true
|
isAtomic: true
|
||||||
isHardTab: isHardTab
|
isHardTab: isHardTab
|
||||||
@@ -155,7 +148,7 @@ class Token
|
|||||||
|
|
||||||
matchesScopeSelector: (selector) ->
|
matchesScopeSelector: (selector) ->
|
||||||
targetClasses = selector.replace(StartDotRegex, '').split('.')
|
targetClasses = selector.replace(StartDotRegex, '').split('.')
|
||||||
_.any @scopeDescriptor, (scope) ->
|
_.any @scopes, (scope) ->
|
||||||
scopeClasses = scope.split('.')
|
scopeClasses = scope.split('.')
|
||||||
_.isSubset(targetClasses, scopeClasses)
|
_.isSubset(targetClasses, scopeClasses)
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class TokenizedBuffer extends Model
|
|||||||
hasTokenForSelector: (selector) ->
|
hasTokenForSelector: (selector) ->
|
||||||
for {tokens} in @tokenizedLines
|
for {tokens} in @tokenizedLines
|
||||||
for token in tokens
|
for token in tokens
|
||||||
return true if selector.matches(token.scopeDescriptor)
|
return true if selector.matches(token.scopes)
|
||||||
false
|
false
|
||||||
|
|
||||||
retokenizeLines: ->
|
retokenizeLines: ->
|
||||||
@@ -248,7 +248,7 @@ class TokenizedBuffer extends Model
|
|||||||
|
|
||||||
buildPlaceholderTokenizedLineForRow: (row) ->
|
buildPlaceholderTokenizedLineForRow: (row) ->
|
||||||
line = @buffer.lineForRow(row)
|
line = @buffer.lineForRow(row)
|
||||||
tokens = [new Token(value: line, scopeDescriptor: [@grammar.scopeName])]
|
tokens = [new Token(value: line, scopes: [@grammar.scopeName])]
|
||||||
tabLength = @getTabLength()
|
tabLength = @getTabLength()
|
||||||
indentLevel = @indentLevelForRow(row)
|
indentLevel = @indentLevelForRow(row)
|
||||||
lineEnding = @buffer.lineEndingForRow(row)
|
lineEnding = @buffer.lineEndingForRow(row)
|
||||||
@@ -304,7 +304,7 @@ class TokenizedBuffer extends Model
|
|||||||
0
|
0
|
||||||
|
|
||||||
scopeDescriptorForPosition: (position) ->
|
scopeDescriptorForPosition: (position) ->
|
||||||
new ScopeDescriptor(scopes: @tokenForPosition(position).scopeDescriptor)
|
new ScopeDescriptor(scopes: @tokenForPosition(position).scopes)
|
||||||
|
|
||||||
tokenForPosition: (position) ->
|
tokenForPosition: (position) ->
|
||||||
{row, column} = Point.fromObject(position)
|
{row, column} = Point.fromObject(position)
|
||||||
|
|||||||
@@ -194,9 +194,9 @@ class TokenizedLine
|
|||||||
|
|
||||||
isComment: ->
|
isComment: ->
|
||||||
for token in @tokens
|
for token in @tokens
|
||||||
continue if token.scopeDescriptor.length is 1
|
continue if token.scopes.length is 1
|
||||||
continue if token.isOnlyWhitespace()
|
continue if token.isOnlyWhitespace()
|
||||||
for scope in token.scopeDescriptor
|
for scope in token.scopes
|
||||||
return true if _.contains(scope.split('.'), 'comment')
|
return true if _.contains(scope.split('.'), 'comment')
|
||||||
break
|
break
|
||||||
false
|
false
|
||||||
@@ -226,7 +226,7 @@ class TokenizedLine
|
|||||||
|
|
||||||
scopeStack = []
|
scopeStack = []
|
||||||
for token in @tokens
|
for token in @tokens
|
||||||
@updateScopeStack(scopeStack, token.scopeDescriptor)
|
@updateScopeStack(scopeStack, token.scopes)
|
||||||
_.last(scopeStack).children.push(token)
|
_.last(scopeStack).children.push(token)
|
||||||
|
|
||||||
@scopeTree = scopeStack[0]
|
@scopeTree = scopeStack[0]
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário