How to use the vscode-languageserver-protocol.Location.create function in vscode-languageserver-protocol

To help you get started, we’ve selected a few vscode-languageserver-protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keesschollaart81 / vscode-home-assistant / src / language-service / src / definition / scripts.ts View on Github external
public onDefinition = async (line: string, uri: string): Promise => {
        let matches = /(.*)(script\.([\S]*))([\s]*)*(.*)/.exec(line);
        if (!matches || matches.length !== 6) {
            return [];
        }
        let scripts = await this.haConfig.getScripts();
        var scriptName = matches[3].replace(":", ""); // might be possible in regex!?
        let ourScript = scripts[scriptName];
        if (!ourScript) {
            return [];
        }
        return [Location.create(ourScript.fileUri, {
            start: { line: ourScript.start[0], character: ourScript.start[1] },
            end: { line: ourScript.end[0], character: ourScript.end[1] }
        })];
    }
}
github neoclide / coc.nvim / src / handler / index.ts View on Github external
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[])
    }
  }
github neoclide / coc.nvim / src / handler / index.ts View on Github external
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)
    }
  }
github neoclide / coc.nvim / src / model / configurations.ts View on Github external
break
      case 11:
        msg = 'unexpected end of comment'
        break
      case 4:
        msg = 'value expected'
        break
      default:
        msg = 'Unknwn error'
        break
    }
    let range: Range = {
      start: document.positionAt(err.offset),
      end: document.positionAt(err.offset + err.length),
    }
    let loc = Location.create(uri, range)
    items.push({ location: loc, message: msg })
  }
  return items
}
github recca0120 / vscode-phpunit / server / src / Filesystem.ts View on Github external
async lineLocation(
        uri: PathLike | URI,
        lineNumber: number
    ): Promise {
        uri = this.asUri(uri).with({ scheme: 'file' });

        return Location.create(
            uri.toString(),
            await this.lineRange(uri, lineNumber)
        );
    }