Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Perform parsing off the main thread when Tree-sitter is enabled #17339

Merged
merged 7 commits into from
May 23, 2018
Prev Previous commit
Next Next commit
Rename out-of-date property: layer -> languageMode
  • Loading branch information
maxbrunsfeld committed May 23, 2018
commit 7a2667406b08c5e4e1cf8351df1ce650d5403fb2
14 changes: 7 additions & 7 deletions src/tree-sitter-language-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ class TreeSitterLanguageMode {
}

class TreeSitterHighlightIterator {
constructor (layer, treeCursor) {
this.layer = layer
constructor (languageMode, treeCursor) {
this.languageMode = languageMode
this.treeCursor = treeCursor

// In order to determine which selectors match its current node, the iterator maintains
Expand Down Expand Up @@ -414,7 +414,7 @@ class TreeSitterHighlightIterator {
this.containingNodeTypes.length = 0
this.containingNodeChildIndices.length = 0
this.currentPosition = targetPosition
this.currentIndex = this.layer.buffer.characterIndexForPosition(targetPosition)
this.currentIndex = this.languageMode.buffer.characterIndexForPosition(targetPosition)

// Descend from the root of the tree to the smallest node that spans the given position.
// Keep track of any nodes along the way that are associated with syntax highlighting
Expand All @@ -429,7 +429,7 @@ class TreeSitterHighlightIterator {

const scopeName = this.currentScopeName()
if (scopeName) {
const id = this.layer.grammar.idForScope(scopeName)
const id = this.languageMode.grammar.idForScope(scopeName)
if (this.currentIndex === this.treeCursor.startIndex) {
this.openTags.push(id)
} else {
Expand Down Expand Up @@ -531,7 +531,7 @@ class TreeSitterHighlightIterator {
}

currentScopeName () {
return this.layer.grammar.scopeMap.get(
return this.languageMode.grammar.scopeMap.get(
this.containingNodeTypes,
this.containingNodeChildIndices,
this.treeCursor.nodeIsNamed
Expand All @@ -540,7 +540,7 @@ class TreeSitterHighlightIterator {

pushCloseTag () {
const scopeName = this.currentScopeName()
if (scopeName) this.closeTags.push(this.layer.grammar.idForScope(scopeName))
if (scopeName) this.closeTags.push(this.languageMode.grammar.idForScope(scopeName))
this.containingNodeTypes.pop()
this.containingNodeChildIndices.pop()
}
Expand All @@ -549,7 +549,7 @@ class TreeSitterHighlightIterator {
this.containingNodeTypes.push(this.treeCursor.nodeType)
this.containingNodeChildIndices.push(this.currentChildIndex)
const scopeName = this.currentScopeName()
if (scopeName) this.openTags.push(this.layer.grammar.idForScope(scopeName))
if (scopeName) this.openTags.push(this.languageMode.grammar.idForScope(scopeName))
}
}

Expand Down