<commit_before>﻿namespace MonoDevelopTests
open Microsoft.FSharp.Compiler.SourceCodeServices
open NUnit.Framework
open MonoDevelop.FSharp
open MonoDevelop.Ide.TypeSystem
open MonoDevelop.Core.Text

type FixtureSetup() =
  static let firstRun = ref true
  member x.Initialise() =
    if !firstRun then
      firstRun := false
      MonoDevelop.FSharp.MDLanguageService.DisableVirtualFileSystem()
      MonoDevelop.Ide.DesktopService.Initialize()

module TestHelpers =

  let parseAndCheckFile source filename =
    async {
      try
         let checker = FSharpChecker.Create()
         let! projOptions = checker.GetProjectOptionsFromScript(filename, source)
         let! parseResults, checkAnswer = checker.ParseAndCheckFileInProject(filename, 0, source , projOptions)

         // Construct new typed parse result if the task succeeded
         let results =
           match checkAnswer with
           | FSharpCheckFileAnswer.Succeeded(checkResults) ->
               ParseAndCheckResults(Some checkResults, Some parseResults)
           | FSharpCheckFileAnswer.Aborted ->
               ParseAndCheckResults(None, Some parseResults)
               
         return results
      with exn ->
        return ParseAndCheckResults(None, None) }  |> Async.RunSynchronously

  let createDoc source compilerDefines =
    let file = "test.fsx"
    let options = ParseOptions(FileName = file, Content = StringTextSource(source))

    let results = parseAndCheckFile source file
    let parsedDocument = ParsedDocument.create(options, results, [compilerDefines]) 
                         |> Async.RunSynchronously

    FixtureSetup().Initialise()
    let editor = MonoDevelop.Ide.Editor.TextEditorFactory.CreateNewEditor ()
    editor.Text <- source
    TestDocument(file, parsedDocument, editor)
<commit_msg>Update test code<commit_after>﻿namespace MonoDevelopTests
open Microsoft.FSharp.Compiler.SourceCodeServices
open NUnit.Framework
open MonoDevelop.FSharp
open MonoDevelop.Ide.TypeSystem
open MonoDevelop.Core.Text

type FixtureSetup() =
  static let firstRun = ref true
  member x.Initialise() =
    if !firstRun then
      firstRun := false
      MonoDevelop.FSharp.MDLanguageService.DisableVirtualFileSystem()
      MonoDevelop.Ide.DesktopService.Initialize()

module TestHelpers =

  let parseAndCheckFile source filename =
    async {
      try
         let checker = FSharpChecker.Create()
         let! projOptions = checker.GetProjectOptionsFromScript(filename, source)
         let! parseResults, checkAnswer = checker.ParseAndCheckFileInProject(filename, 0, source , projOptions)

         // Construct new typed parse result if the task succeeded
         let results =
           match checkAnswer with
           | FSharpCheckFileAnswer.Succeeded(checkResults) ->
               ParseAndCheckResults(Some checkResults, Some parseResults)
           | FSharpCheckFileAnswer.Aborted ->
               ParseAndCheckResults(None, Some parseResults)
               
         return results
      with exn ->
        return ParseAndCheckResults(None, None) }  |> Async.RunSynchronously

  let createDoc source compilerDefines =
    let file = "test.fsx"
    let options = ParseOptions(FileName = file, Content = StringTextSource(source))

    let results = parseAndCheckFile source file
    let parsedDocument =
      ParsedDocument.create options results [compilerDefines] |> Async.RunSynchronously

    FixtureSetup().Initialise()
    let editor = MonoDevelop.Ide.Editor.TextEditorFactory.CreateNewEditor ()
    editor.Text <- source
    TestDocument(file, parsedDocument, editor)

{'fraction_non_alphanumeric': 0.07011686143572621, 'fraction_numerical': 0.0005564830272676684, 'mean_word_length': 3.2096018735363, 'pattern_counts': {'":': 0, '<': 5, '<?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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1545105', 'n_tokens_mistral': 986, 'n_tokens_neox': 919, 'n_words': 231}