Skip to content

Commit

Permalink
Merge pull request atom#19172 from atom/mb-tree-sitter-upgrade-test-t…
Browse files Browse the repository at this point in the history
…ravis

Try upgrading Tree-sitter for a third time
  • Loading branch information
maxbrunsfeld authored May 7, 2019
2 parents 1de1764 + e33ac81 commit fa10086
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 41 deletions.
39 changes: 8 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"temp": "^0.9.0",
"text-buffer": "13.15.1",
"timecop": "https://www.atom.io/api/packages/timecop/versions/0.36.2/tarball",
"tree-sitter": "0.13.23",
"tree-sitter": "0.15.0",
"tree-sitter-css": "^0.13.7",
"tree-view": "https://www.atom.io/api/packages/tree-view/versions/0.227.0/tarball",
"typescript-simple": "1.0.0",
Expand Down
2 changes: 2 additions & 0 deletions spec/spec-helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ FindParentDir = require 'find-parent-dir'
TextEditor = require '../src/text-editor'
TextEditorElement = require '../src/text-editor-element'
TextMateLanguageMode = require '../src/text-mate-language-mode'
TreeSitterLanguageMode = require '../src/tree-sitter-language-mode'
{clipboard} = require 'electron'

jasmineStyle = document.createElement('style')
Expand Down Expand Up @@ -101,6 +102,7 @@ beforeEach ->

# make tokenization synchronous
TextMateLanguageMode.prototype.chunkSize = Infinity
TreeSitterLanguageMode.prototype.syncTimeoutMicros = Infinity
spyOn(TextMateLanguageMode.prototype, "tokenizeInBackground").andCallFake -> @tokenizeNextChunk()

# Without this spy, TextEditor.onDidTokenize callbacks would not be called
Expand Down
8 changes: 4 additions & 4 deletions spec/tree-sitter-language-mode-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('TreeSitterLanguageMode', () => {
languageMode.tree.rootNode
.descendantForPosition(Point(1, 2), Point(1, 6))
.toString()
).toBe('(declaration (primitive_type) (identifier) (MISSING))')
).toBe('(declaration (primitive_type) (identifier) (MISSING ";"))')

expectTokensToEqual(editor, [
[
Expand Down Expand Up @@ -414,7 +414,7 @@ describe('TreeSitterLanguageMode', () => {
const languageMode = new TreeSitterLanguageMode({
buffer,
grammar,
syncOperationLimit: 0
syncTimeoutMicros: 0
})
buffer.setLanguageMode(languageMode)
await nextHighlightingUpdate(languageMode)
Expand Down Expand Up @@ -797,7 +797,7 @@ describe('TreeSitterLanguageMode', () => {
buffer,
grammar: htmlGrammar,
grammars: atom.grammars,
syncOperationLimit: 0
syncTimeoutMicros: 0
})
buffer.setLanguageMode(languageMode)

Expand Down Expand Up @@ -827,7 +827,7 @@ describe('TreeSitterLanguageMode', () => {
)
atom.grammars.loadGrammarSync(jsGrammarPath)
atom.grammars.assignLanguageMode(buffer, 'source.js')
buffer.getLanguageMode().syncOperationLimit = 0
buffer.getLanguageMode().syncTimeoutMicros = 0

const initialSeed = Date.now()
for (let i = 0, trialCount = 10; i < trialCount; i++) {
Expand Down
10 changes: 5 additions & 5 deletions src/tree-sitter-language-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TreeSitterLanguageMode {
}
}

constructor ({buffer, grammar, config, grammars, syncOperationLimit}) {
constructor ({buffer, grammar, config, grammars, syncTimeoutMicros}) {
TreeSitterLanguageMode._patchSyntaxNode()
this.id = nextId++
this.buffer = buffer
Expand All @@ -35,8 +35,8 @@ class TreeSitterLanguageMode {
this.rootLanguageLayer = new LanguageLayer(this, grammar)
this.injectionsMarkerLayer = buffer.addMarkerLayer()

if (syncOperationLimit != null) {
this.syncOperationLimit = syncOperationLimit
if (syncTimeoutMicros != null) {
this.syncTimeoutMicros = syncTimeoutMicros
}

this.rootScopeDescriptor = new ScopeDescriptor({scopes: [this.grammar.scopeName]})
Expand Down Expand Up @@ -111,7 +111,7 @@ class TreeSitterLanguageMode {
const parser = PARSER_POOL.pop() || new Parser()
parser.setLanguage(language)
const result = parser.parseTextBuffer(this.buffer.buffer, oldTree, {
syncOperationLimit: this.syncOperationLimit,
syncTimeoutMicros: this.syncTimeoutMicros,
includedRanges: ranges
})

Expand Down Expand Up @@ -1225,6 +1225,6 @@ function hasMatchingFoldSpec (specs, node) {
})

TreeSitterLanguageMode.LanguageLayer = LanguageLayer
TreeSitterLanguageMode.prototype.syncOperationLimit = 1000
TreeSitterLanguageMode.prototype.syncTimeoutMicros = 1000

module.exports = TreeSitterLanguageMode

0 comments on commit fa10086

Please sign in to comment.