-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from rneatherway/colorizations
Provide a command to request colorization info
- Loading branch information
Showing
8 changed files
with
215 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#load "../TestHelpers.fsx" | ||
open TestHelpers | ||
open System.IO | ||
open System | ||
|
||
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ | ||
File.Delete "output.json" | ||
|
||
let p = new FsAutoCompleteWrapper() | ||
|
||
p.parse "Script.fsx" | ||
p.send "colorizations true\n" | ||
p.parse "Script.fsx" | ||
p.send "colorizations false\n" | ||
p.parse "Script.fsx" | ||
p.send "quit\n" | ||
p.finalOutput () | ||
|> writeNormalizedOutput "output.json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
open System | ||
|
||
#nowarn "40" | ||
|
||
let a f = async { let! x = f "hello" | ||
return x } | ||
|
||
type LazyList<'T> = | ||
| Nil | ||
| Cons of 'T * Lazy<LazyList<'T>> | ||
|
||
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | ||
module LazyList = | ||
let ofSeq (s:seq<'T>) = | ||
let en = s.GetEnumerator() | ||
let rec take() = | ||
if en.MoveNext() then | ||
Cons(en.Current, lazy take()) | ||
else | ||
en.Dispose() | ||
Nil | ||
take() | ||
|
||
type Parser<'T> = P of (LazyList<char> -> ('T * LazyList<char>) list) | ||
|
||
|
||
let result v = P(fun c -> [v, c]) | ||
let zero () = P(fun _ -> []) | ||
let bind (P p) f = P(fun inp -> | ||
[ for (pr, inp') in p inp do | ||
let (P pars) = f pr | ||
yield! pars inp' ]) | ||
let plus (P p) (P q) = P (fun inp -> | ||
(p inp) @ (q inp) ) | ||
|
||
let (<|>) p1 p2 = plus p1 p2 | ||
|
||
type ParserBuilder() = | ||
member x.Bind(v, f) = bind v f | ||
member x.Zero() = zero() | ||
member x.Return(v) = result(v) | ||
member x.ReturnFrom(p) = p | ||
member x.Combine(a, b) = plus a b | ||
member x.Delay(f) = f() | ||
|
||
let parser = new ParserBuilder() | ||
|
||
let item = P(function | LazyList.Nil -> [] | LazyList.Cons(c, r) -> [c,r.Value]) | ||
|
||
let sat p = parser { | ||
let! v = item | ||
if (p v) then return v } | ||
|
||
let char x = sat ((=) x) | ||
let digit = sat Char.IsDigit | ||
let lower = sat Char.IsLower | ||
let upper = sat Char.IsUpper | ||
let letter = sat Char.IsLetter | ||
|
||
let alphanum = parser { | ||
return! letter | ||
return! digit } | ||
|
||
let string (str:string) = | ||
let chars = str.ToCharArray() |> List.ofSeq | ||
let rec string' = function | ||
| [] -> result [] | ||
| x::xs -> parser { | ||
let! y = char x | ||
let! ys = string' xs | ||
return y::ys } | ||
string' chars | ||
|
||
#if NOTDEFINED | ||
let a = 1 | ||
#endif | ||
|
||
#if INTERACTIVE | ||
let b = 2 | ||
#endif | ||
|
||
type String = System.String | ||
|
||
type MyDictionary = System.Collections.Generic.Dictionary<String,String> | ||
|
||
type MyAttribute(text : string) = | ||
inherit System.Attribute() | ||
|
||
do printfn "MyAttribute created. Text: %s" text | ||
|
||
member this.Text = text | ||
|
||
[<MyAttribute("Hello world")>] | ||
type MyClass() = | ||
member this.SomeProperty = "This is a property" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"Kind": "info", | ||
"Data": "Synchronous parsing started" | ||
} | ||
{ | ||
"Kind": "errors", | ||
"Data": [] | ||
} | ||
{ | ||
"Kind": "info", | ||
"Data": "Synchronous parsing started" | ||
} | ||
{ | ||
"Kind": "errors", | ||
"Data": [] | ||
} | ||
{ | ||
"Kind": "colorizations", | ||
"Data": [ | ||
{ | ||
"Range": { | ||
"StartColumn": 11, | ||
"StartLine": 5, | ||
"EndColumn": 16, | ||
"EndLine": 5 | ||
}, | ||
"Kind": "Keyword" | ||
}, | ||
{ | ||
"Range": { | ||
"StartColumn": 13, | ||
"StartLine": 50, | ||
"EndColumn": 19, | ||
"EndLine": 50 | ||
}, | ||
"Kind": "Keyword" | ||
}, | ||
{ | ||
"Range": { | ||
"StartColumn": 16, | ||
"StartLine": 60, | ||
"EndColumn": 22, | ||
"EndLine": 60 | ||
}, | ||
"Kind": "Keyword" | ||
}, | ||
{ | ||
"Range": { | ||
"StartColumn": 16, | ||
"StartLine": 68, | ||
"EndColumn": 22, | ||
"EndLine": 68 | ||
}, | ||
"Kind": "Keyword" | ||
} | ||
] | ||
} | ||
{ | ||
"Kind": "info", | ||
"Data": "Synchronous parsing started" | ||
} | ||
{ | ||
"Kind": "errors", | ||
"Data": [] | ||
} |