-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
To develop a codemirror mode for typescript, I'm forced to use the indenter independently of the language service, to do so I do :
var sourceFile = ts.createSourceFile(Math.random()+ '.ts', text, ts.ScriptTarget.Latest, Math.random() + '');
var indent = indenter.getIndentation(position, sourceFile, {
IndentSize: options.indentUnit,
TabSize: options.tabSize,
NewLineCharacter: '\n',
ConvertTabsToSpaces: !options.indentWithTabs
});
However it constantly error in getTokenPosOfNode, apparently it fails to find the sourceFile, after some investigation it seems that some node does not have parent. I had to tranform the obtained sourceFile with :
function setParents(parent: ts.Node) {
parent.getChildren().forEach(node => {
if (!node.parent) {
node.parent = parent;
}
setParents(node);
})
}
Is there a something in the lifecycle that I should do ? Or is it a bug ?
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code