MCPcopy Create free account
hub / github.com/tree-sitter/tree-sitter-javascript / LineComponent

Class LineComponent

examples/text-editor-component.js:3880–4013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3878}
3879
3880class LineComponent {
3881 constructor (props) {
3882 const {nodePool, screenRow, screenLine, lineComponentsByScreenLineId, offScreen} = props
3883 this.props = props
3884 this.element = nodePool.getElement('DIV', this.buildClassName(), null)
3885 this.element.dataset.screenRow = screenRow
3886 this.textNodes = []
3887
3888 if (offScreen) {
3889 this.element.style.position = 'absolute'
3890 this.element.style.visibility = 'hidden'
3891 this.element.dataset.offScreen = true
3892 }
3893
3894 this.appendContents()
3895 lineComponentsByScreenLineId.set(screenLine.id, this)
3896 }
3897
3898 update (newProps) {
3899 if (this.props.lineDecoration !== newProps.lineDecoration) {
3900 this.props.lineDecoration = newProps.lineDecoration
3901 this.element.className = this.buildClassName()
3902 }
3903
3904 if (this.props.screenRow !== newProps.screenRow) {
3905 this.props.screenRow = newProps.screenRow
3906 this.element.dataset.screenRow = newProps.screenRow
3907 }
3908
3909 if (!textDecorationsEqual(this.props.textDecorations, newProps.textDecorations)) {
3910 this.props.textDecorations = newProps.textDecorations
3911 this.element.firstChild.remove()
3912 this.appendContents()
3913 }
3914 }
3915
3916 destroy () {
3917 const {nodePool, lineComponentsByScreenLineId, screenLine} = this.props
3918
3919 if (lineComponentsByScreenLineId.get(screenLine.id) === this) {
3920 lineComponentsByScreenLineId.delete(screenLine.id)
3921 }
3922
3923 this.element.remove()
3924 nodePool.release(this.element)
3925 }
3926
3927 appendContents () {
3928 const {displayLayer, nodePool, screenLine, textDecorations} = this.props
3929
3930 this.textNodes.length = 0
3931
3932 const {lineText, tags} = screenLine
3933 let openScopeNode = nodePool.getElement('SPAN', null, null)
3934 this.element.appendChild(openScopeNode)
3935
3936 let decorationIndex = 0
3937 let column = 0

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…