Fix executeAstMock to be more lenient
This commit is contained in:
@ -15,7 +15,11 @@ import {
|
|||||||
recast,
|
recast,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
} from 'lang/wasm'
|
} from 'lang/wasm'
|
||||||
import { expectNodeOnPath, getLastNodeFromPath } from './queryAst'
|
import {
|
||||||
|
expectNodeOnPath,
|
||||||
|
getLastNodeFromPath,
|
||||||
|
getNodeFromPath,
|
||||||
|
} from './queryAst'
|
||||||
import { codeManager, editorManager, sceneInfra } from 'lib/singletons'
|
import { codeManager, editorManager, sceneInfra } from 'lib/singletons'
|
||||||
import { Diagnostic } from '@codemirror/lint'
|
import { Diagnostic } from '@codemirror/lint'
|
||||||
|
|
||||||
@ -315,12 +319,14 @@ export class KclManager {
|
|||||||
Object.entries(this.engineCommandManager.artifactMap).forEach(
|
Object.entries(this.engineCommandManager.artifactMap).forEach(
|
||||||
([commandId, artifact]) => {
|
([commandId, artifact]) => {
|
||||||
if (!artifact.pathToNode) return
|
if (!artifact.pathToNode) return
|
||||||
const node = expectNodeOnPath<CallExpression>(
|
const _node = getNodeFromPath<CallExpression>(
|
||||||
this.ast,
|
this.ast,
|
||||||
artifact.pathToNode,
|
artifact.pathToNode,
|
||||||
'CallExpression'
|
'CallExpression'
|
||||||
)
|
)
|
||||||
if (err(node)) return
|
if (err(_node)) return
|
||||||
|
const { node } = _node
|
||||||
|
if (isArray(node) || node.type !== 'CallExpression') return
|
||||||
const [oldStart, oldEnd] = artifact.range
|
const [oldStart, oldEnd] = artifact.range
|
||||||
if (oldStart === 0 && oldEnd === 0) return
|
if (oldStart === 0 && oldEnd === 0) return
|
||||||
if (oldStart === node.start && oldEnd === node.end) return
|
if (oldStart === node.start && oldEnd === node.end) return
|
||||||
|
|||||||
Reference in New Issue
Block a user