-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sketched RequestHoverText * added modified FsAutoComplete.Core for getting Tooltips * removed unused files from FsAutoComplete.Core * added basic tests for `RequestHoverText` in FSharp.Tests * prettier Hover-Messages including current value when possible * HoverText tests now including F# * fixed broken build
- Loading branch information
1 parent
056fb6e
commit 741215f
Showing
19 changed files
with
5,158 additions
and
5 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<LangVersion>preview</LangVersion> | ||
<DefineConstants>NO_EXTENSIONTYPING;$(DefineConstants);DOTNET_SPAWN;NETCORE_FSI</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Utils.fs" /> | ||
<Compile Include="TypedAstUtils.fs" /> | ||
<Compile Include="TypedAstPatterns.fs" /> | ||
<Compile Include="Lexer.fs" /> | ||
<Compile Include="SignatureFormatter.fs" /> | ||
<Compile Include="TipFormatter.fs" /> | ||
<Compile Include="DocumentationFormatter.fs" /> | ||
<Compile Include="KeywordList.fs" /> | ||
<Compile Include="InteractiveDirectives.fs" /> | ||
<Compile Include="ParseAndCheckResults.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="FSharp.Compiler.Private.Scripting" /> | ||
</ItemGroup> | ||
</Project> |
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,114 @@ | ||
module FsAutoComplete.InteractiveDirectives | ||
|
||
open System | ||
open System.Text.RegularExpressions | ||
|
||
/// Remove escaping from standard (non verbatim & non triple quotes) string | ||
let private unescapeStandardString (s: string) = | ||
let mutable result = "" | ||
let mutable escaped = false | ||
let mutable unicodeHeaderChar = '?' | ||
let mutable remainingUnicodeChars = 0 | ||
let mutable currentUnicodeChars = "" | ||
|
||
for i in [ 0 .. s.Length - 1 ] do | ||
let c = s.[i] | ||
if remainingUnicodeChars > 0 then | ||
if (c >= 'A' && c <= 'Z') | ||
|| (c >= 'a' && c <= 'z') | ||
|| (c >= '0' && c <= '9') then | ||
currentUnicodeChars <- currentUnicodeChars + string (c) | ||
remainingUnicodeChars <- remainingUnicodeChars - 1 | ||
|
||
if remainingUnicodeChars = 0 then | ||
result <- | ||
result | ||
+ string (char (Convert.ToUInt32(currentUnicodeChars, 16))) | ||
else | ||
// Invalid unicode sequence, bail out | ||
result <- | ||
result | ||
+ "\\" | ||
+ string (unicodeHeaderChar) | ||
+ currentUnicodeChars | ||
+ string (c) | ||
remainingUnicodeChars <- 0 | ||
else if escaped then | ||
escaped <- false | ||
match c with | ||
| 'b' -> result <- result + "\b" | ||
| 'n' -> result <- result + "\n" | ||
| 'r' -> result <- result + "\r" | ||
| 't' -> result <- result + "\t" | ||
| '\\' -> result <- result + "\\" | ||
| '"' -> result <- result + "\"" | ||
| ''' -> result <- result + "'" | ||
| 'u' -> | ||
unicodeHeaderChar <- 'u' | ||
currentUnicodeChars <- "" | ||
remainingUnicodeChars <- 4 | ||
| 'U' -> | ||
unicodeHeaderChar <- 'U' | ||
currentUnicodeChars <- "" | ||
remainingUnicodeChars <- 8 | ||
| _ -> result <- result + "\\" + string (c) | ||
else if c = '\\' then | ||
escaped <- true | ||
else | ||
result <- result + string (c) | ||
|
||
if remainingUnicodeChars > 0 then | ||
result <- | ||
result | ||
+ "\\" | ||
+ string (unicodeHeaderChar) | ||
+ currentUnicodeChars | ||
else if escaped then | ||
result <- result + "\\" | ||
|
||
result | ||
|
||
|
||
let private loadRegex = Regex(@"#load\s+") | ||
let private standardStringRegex = Regex(@"^""(((\\"")|[^""])*)""") | ||
let private verbatimStringRegex = Regex(@"^@""((""""|[^""])*)""") | ||
let private tripleStringRegex = Regex(@"^""""""(.*?)""""""") | ||
|
||
// The following function can be probably moved to general Utils, as it's general purpose. | ||
// Or is there already such function? | ||
|
||
/// Get the string starting at index in any of the string forms (standard, verbatim or triple quotes) | ||
let private tryParseStringFromStart (s: string) (index: int) = | ||
let s = s.Substring(index) | ||
let verbatim = verbatimStringRegex.Match(s) | ||
if verbatim.Success then | ||
let s = verbatim.Groups.[1].Value | ||
Some(s.Replace("\"\"", "\"")) | ||
else | ||
let triple = tripleStringRegex.Match(s) | ||
if triple.Success then | ||
let s = triple.Groups.[1].Value | ||
Some s | ||
else | ||
let standard = standardStringRegex.Match(s) | ||
if standard.Success then | ||
let s = standard.Groups.[1].Value | ||
Some(unescapeStandardString s) | ||
else | ||
None | ||
|
||
/// Parse the content of a "#load" instruction at the given line. Returns the script file name on success. | ||
let tryParseLoad (line: string) (column: int) = | ||
let potential = | ||
seq { | ||
let matches = loadRegex.Matches(line) | ||
for i in [ 0 .. matches.Count - 1 ] do | ||
let m = matches.[i] | ||
if m.Index <= column then yield m | ||
} | ||
|
||
match potential |> Seq.tryLast with | ||
| Some m -> | ||
let stringIndex = m.Index + m.Length | ||
tryParseStringFromStart line stringIndex | ||
| None -> None |
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,33 @@ | ||
namespace FsAutoComplete | ||
|
||
open FSharp.Compiler.SourceCodeServices | ||
|
||
module KeywordList = | ||
|
||
let keywordDescriptions = | ||
FSharp.Compiler.SourceCodeServices.Keywords.KeywordsWithDescription | ||
|> dict | ||
|
||
let keywordTooltips = | ||
keywordDescriptions | ||
|> Seq.map (fun kv -> | ||
let tip = FSharpToolTipText [FSharpToolTipElement.Single(kv.Key, FSharpXmlDoc.Text kv.Value)] | ||
kv.Key, tip) | ||
|> dict | ||
|
||
let hashDirectives = | ||
[ "r", "References an assembly" | ||
"load", "Reads a source file, compiles it, and runs it." | ||
"I", "Specifies an assembly search path in quotation marks." | ||
"light", "Enables or disables lightweight syntax, for compatibility with other versions of ML" | ||
"if", "Supports conditional compilation" | ||
"else", "Supports conditional compilation" | ||
"endif", "Supports conditional compilation" | ||
"nowarn", "Disables a compiler warning or warnings" | ||
"line", "Indicates the original source code line"] | ||
|> dict | ||
|
||
|
||
let allKeywords : string list = | ||
FSharp.Compiler.SourceCodeServices.Keywords.KeywordsWithDescription | ||
|> List.map fst |
Oops, something went wrong.