<commit_before>namespace MonoDevelop.FSharp

open System
open System.IO
open MonoDevelop.Core
open MonoDevelop.Ide.Gui.Components
open MonoDevelop.Projects
open MonoDevelop.Ide
open MonoDevelop.Ide.Gui
open MonoDevelop.Ide.Gui.Pads.ProjectPad

open System.Collections.Generic
open System.Linq
open System.Xml
open System.Xml.Linq
open Linq2Xml

/// The command handler type for nodes in F# projects in the solution explorer.
type FSharpProjectNodeCommandHandler() =
  inherit NodeCommandHandler()

  /// Reload project causing the node tree up refresh with new ordering
  let reloadProject (currentNode: ITreeNavigator) =
    use monitor = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)
    monitor.BeginTask("Reloading Project", 1)
    let file = currentNode.DataItem :?> ProjectFile
    file.Project.ParentFolder.ReloadItem(monitor, file.Project) |> ignore
    monitor.Step (1)
    monitor.EndTask()

  let moveNodes (currentNode: ITreeNavigator) (movingNode:ProjectFile) position =
    let moveToNode = currentNode.DataItem :?> ProjectFile
    let projectFile = movingNode.Project.FileName.ToString()

    ///partially apply the default namespace of msbuild to xs
    let xd = xs "http://schemas.microsoft.com/developer/msbuild/2003"

    //open project file
    use file = IO.File.Open(projectFile, FileMode.Open)
    let xdoc = XElement.Load(file)
    file.Close()

    //get all the compile nodes from the project file
    let compileNodes = xdoc |> descendants (xd "Compile")

    let findByIncludeFile name seq = 
        seq |> where (fun elem -> (elem |> attributeValue "Include") = Path.GetFileName(name) )
            |> firstOrNone
    
    let getFullName (pf:ProjectFile) = pf.ProjectVirtualPath.ToString().Replace("/", "\\")
<commit_msg>Fix #302: Drag and drop for linked files<commit_after>namespace MonoDevelop.FSharp

open System
open System.IO
open MonoDevelop.Core
open MonoDevelop.Ide.Gui.Components
open MonoDevelop.Projects
open MonoDevelop.Ide
open MonoDevelop.Ide.Gui
open MonoDevelop.Ide.Gui.Pads.ProjectPad

open System.Collections.Generic
open System.Linq
open System.Xml
open System.Xml.Linq
open Linq2Xml

/// The command handler type for nodes in F# projects in the solution explorer.
type FSharpProjectNodeCommandHandler() =
  inherit NodeCommandHandler()

  /// Reload project causing the node tree up refresh with new ordering
  let reloadProject (currentNode: ITreeNavigator) =
    use monitor = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)
    monitor.BeginTask("Reloading Project", 1)
    let file = currentNode.DataItem :?> ProjectFile
    file.Project.ParentFolder.ReloadItem(monitor, file.Project) |> ignore
    monitor.Step (1)
    monitor.EndTask()

  let moveNodes (currentNode: ITreeNavigator) (movingNode:ProjectFile) position =
    let moveToNode = currentNode.DataItem :?> ProjectFile
    let projectFile = movingNode.Project.FileName.ToString()

    ///partially apply the default namespace of msbuild to xs
    let xd = xs "http://schemas.microsoft.com/developer/msbuild/2003"

    // If the "Compile" element contains a "Link" element then it is a linked file,
    // so use that value for comparison when finding the node.
    let nodeName (node:XElement) = 
       let link = node.Descendants(xd "Link") |> firstOrNone
       match link with
       | Some l -> l.Value
       | None   -> node |> attributeValue "Include"

    //open project file
    use file = IO.File.Open(projectFile, FileMode.Open)
    let xdoc = XElement.Load(file)
    file.Close()

    //get all the compile nodes from the project file
    let compileNodes = xdoc |> descendants (xd "Compile")

    let findByIncludeFile name seq = 
        seq |> where (fun elem -> nodeName elem = name )
            |> firstOrNone
    
    let getFullName (pf:ProjectFile) = pf.ProjectVirtualPath.ToString().Replace("/", "\\")

{'fraction_non_alphanumeric': 0.0926164136866478, 'fraction_numerical': 0.004373552868536146, 'mean_word_length': 3.7414634146341466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '983521', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1086, 'n_words': 338}