<commit_before>module.exports =
class Client

  port: null
  manager: null
  projectDir: null

  constructor: (manager, projectDir) ->
    @manager = manager
    @projectDir = projectDir

  completions: (file, end) ->
    @post(JSON.stringify
      query:
        type: 'completions'
        file: file
        end: end
        types: true
        includeKeywords: true
        sort: @manager.packageConfig.options.sort
        guess: @manager.packageConfig.options.guess
        docs: @manager.packageConfig.options.documentation
        urls: @manager.packageConfig.options.urls
        origins: @manager.packageConfig.options.origins
        lineCharPositions: true
        caseInsensitive: @manager.packageConfig.options.caseInsensitive
    )

  refs: (file, end) ->
    @post(JSON.stringify
      query:
        type: 'refs'
        file: file
        end: end
    )

  update: (editor) ->
    _editor = @manager.getEditor(editor)
    return Promise.resolve() if _editor?.diffs.length is 0
    # buffer = editor.getBuffer()
    # if buffer.getMaxCharacterIndex() > 5000
    #   doDiff = true
    #   for diff in _editor.diffs
    #     start = Math.max(0, diff.oldRange.start.row - 50)
    #     end = Math.min(buffer.getLineCount(), diff.oldRange.end.row + 20)
    #   text = buffer.getTextInRange([[start, 0], [end, buffer.lineLengthForRow(end)]])
    _editor.diffs = []
    # if (false)
      # @post(JSON.stringify
      #   files: [
      #       type: 'part'
      #       name: editor.getURI()
      #       text: text
      #       offsetLines: start<commit_msg>check if _editor is defined<commit_after>module.exports =
class Client

  port: null
  manager: null
  projectDir: null

  constructor: (manager, projectDir) ->
    @manager = manager
    @projectDir = projectDir

  completions: (file, end) ->
    @post(JSON.stringify
      query:
        type: 'completions'
        file: file
        end: end
        types: true
        includeKeywords: true
        sort: @manager.packageConfig.options.sort
        guess: @manager.packageConfig.options.guess
        docs: @manager.packageConfig.options.documentation
        urls: @manager.packageConfig.options.urls
        origins: @manager.packageConfig.options.origins
        lineCharPositions: true
        caseInsensitive: @manager.packageConfig.options.caseInsensitive
    )

  refs: (file, end) ->
    @post(JSON.stringify
      query:
        type: 'refs'
        file: file
        end: end
    )

  update: (editor) ->
    _editor = @manager.getEditor(editor)
    return Promise.resolve() if _editor?.diffs.length is 0
    _editor?.diffs = []
    # buffer = editor.getBuffer()
    # if buffer.getMaxCharacterIndex() > 5000
    #   doDiff = true
    #   for diff in _editor.diffs
    #     start = Math.max(0, diff.oldRange.start.row - 50)
    #     end = Math.min(buffer.getLineCount(), diff.oldRange.end.row + 20)
    #   text = buffer.getTextInRange([[start, 0], [end, buffer.lineLengthForRow(end)]])
    # if (false)
      # @post(JSON.stringify
      #   files: [
      #       type: 'part'
      #       name: editor.getURI()
      #       text: text
      #       offsetLines: start
{'fraction_non_alphanumeric': 0.11406003159557662, 'fraction_numerical': 0.0069510268562401265, 'mean_word_length': 2.2876427829698858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6174985', 'n_tokens_mistral': 996, 'n_tokens_neox': 961, 'n_words': 209}