Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async handleLocations(definition: Definition | LocationLink[], openCommand?: string | false): Promise {
if (!definition) return
let locations: Location[] = Array.isArray(definition) ? definition as Location[] : [definition]
let len = locations.length
if (len == 0) return
if (len == 1 && openCommand !== false) {
let location = definition[0] as Location
if (LocationLink.is(definition[0])) {
let link = definition[0] as LocationLink
location = Location.create(link.targetUri, link.targetRange)
}
let { uri, range } = location
await workspace.jumpTo(uri, range.start, openCommand)
} else {
await workspace.showLocations(definition as Location[])
}
}
public async getQuickfixItem(loc: Location | LocationLink, text?: string, type = '', module?: string): Promise {
if (LocationLink.is(loc)) {
loc = Location.create(loc.targetUri, loc.targetRange)
}
let doc = this.getDocument(loc.uri)
let { uri, range } = loc
let { line, character } = range.start
let u = URI.parse(uri)
let bufnr = doc ? doc.bufnr : -1
if (!text && u.scheme == 'file') {
text = await this.getLine(uri, line)
character = byteIndex(text, character)
}
let item: QuickfixItem = {
uri,
filename: u.scheme == 'file' ? u.fsPath : uri,
lnum: line + 1,
col: character + 1,
public async handleLocations(definition: Definition | LocationLink[], openCommand?: string): Promise {
if (!definition) return
if (Array.isArray(definition)) {
let len = definition.length
if (len == 0) return
if (len == 1) {
let location = definition[0] as Location
if (LocationLink.is(definition[0])) {
let link = definition[0] as LocationLink
location = Location.create(link.targetUri, link.targetRange)
}
let { uri, range } = location
await workspace.jumpTo(uri, range.start, openCommand)
} else {
await workspace.showLocations(definition as Location[])
}
} else {
let { uri, range } = definition as Location
await workspace.jumpTo(uri, range.start, openCommand)
}
}