Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public select(path: string): void {
// Clear previous selection
this.clearCurrentSelection();
// Select the new thing
let doc: Document = this.documentService.currentDocument();
let visitor: MainSelectionVisitor = new MainSelectionVisitor();
let npath: NodePath = new NodePath(path);
npath.resolveWithVisitor(doc, visitor);
// Fire an event with the new selection path
this._selectionTopic.send(path);
}
private clearCurrentSelection(): void {
let previousSelection: string = this.currentSelection();
if (previousSelection) {
let doc: Document = this.documentService.currentDocument();
if (doc) {
let visitor: MainSelectionVisitor = new MainSelectionVisitor(true);
let npath: NodePath = new NodePath(previousSelection);
npath.resolveWithVisitor(doc, visitor);
}
}
}
navigateToDefinition(): void {
let path: NodePath = new NodePath(this.responseDefPathPrefix());
path.appendSegment(this.definitionName(), true);
this.selectionService.select(path.toString());
}