import { apiService } from './api.service';

// 语言服务接口
export const lsifService = {
  async lsifExists(projectPath, sha) {
    return !!(await apiService.post(
      `/webapi/projects/${encodeURIComponent(
        projectPath
      )}/repository/lsif/exists`,
      {
        sha,
      }
    )) ;
  },

  async lsifHover(
    projectId,
    data
  ) {
    return (await apiService.post(
      `/webapi/projects/42422/repository/lsif/hover`,
      undefined,
      {
        ...data,
        method: 'hover',
      }
    )) 
  },

  async lsifDefinitions(
    projectId,
    data
  ) {
    return (await apiService.post(
      `/webapi/projects/42422/repository/lsif/definitions`,
      undefined,
      data
    )) 
  },

  async lsifReferences(
    projectId,
    data
  ) {
    return (await apiService.post(
      `/webapi/projects/42422/repository/lsif/references`,
      undefined,
      data,
      {
        disableBodyConvert: true,
      }
    )) 
  },

  async lsifReferencesV2(
    projectId,
    data
  ) {
    return (await apiService.post(
      `/webapi/projects/42422/repository/lsif/reference/v2`,
      undefined,
      data,
      {
        disableBodyConvert: true,
      }
    )) 
  },
};
