Skip to content

Instantly share code, notes, and snippets.

@yukitos
Last active April 3, 2017 08:12
Show Gist options
  • Save yukitos/0c76f22ffe28f5658315a5975b3c59c6 to your computer and use it in GitHub Desktop.
Save yukitos/0c76f22ffe28f5658315a5975b3c59c6 to your computer and use it in GitHub Desktop.
FSC 12.0.2 test
Chars
Length
Clone
CompareTo
Contains
CopyTo
EndsWith
Equals
GetEnumerator
GetHashCode
GetType
GetTypeCode
IndexOf
IndexOfAny
Insert
IsNormalized
LastIndexOf
LastIndexOfAny
Normalize
PadLeft
PadRight
Remove
Replace
Split
StartsWith
Substring
ToCharArray
ToLower
ToLowerInvariant
ToString
ToUpper
ToUpperInvariant
Trim
TrimEnd
TrimStart
続行するには何かキーを押してください . . .
open System
open System.IO
open System.Text.RegularExpressions
open Microsoft.FSharp.Compiler.SourceCodeServices
type PostData = { Row:string; Col:string; Line:string; FilePath:string; Source:string }
let asyncGetDeclarationListInfo ( checker:FSharpChecker) ( ps:PostData ) (arr:(string array * string)) : Async<FSharpDeclarationListInfo> = async {
let! (projOptions : FSharpProjectOptions), _ =
checker.GetProjectOptionsFromScript( ps.FilePath , ps.Source )
// Perform parsing and type checking
let! (parseFileResults : FSharpParseFileResults) , (checkFileAnswer: FSharpCheckFileAnswer) =
checker.ParseAndCheckFileInProject( ps.FilePath, 0, ps.Source, projOptions )
let checkFileResults =
match checkFileAnswer with
| FSharpCheckFileAnswer.Succeeded(res) -> res
| res -> failwithf "Parsing did not finish... (%A)" res
return! checkFileResults.GetDeclarationListInfo ( Some parseFileResults, int(ps.Row) , int(ps.Col) , ps.Line, [], "", fun () -> [] )
}
[<EntryPoint>]
let main argv =
let source = """
let foo() =
let msg = "Hello world"
if true then
printfn "%s" msg.
"""
let nameSpace = [|"System"|]
let word = ""
let postData : PostData = {
Row = string 5 // This!!
Col = string 23
Line = source |> fun s -> Regex.Split(s,"\n") |> fun arr -> arr.[4]
FilePath = @"./abc.fsx"
Source = source
}
let li = asyncGetDeclarationListInfo (FSharpChecker.Create(keepAssemblyContents=true)) postData ( nameSpace, word )
|> Async.RunSynchronously
li
|> fun x -> x.Items
|> Array.iter ( fun x -> printfn "%s" x.Name )
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment