Skip to content

Commit

Permalink
Merge pull request #11014 from dotnet/merges/main-to-feature/tasks
Browse files Browse the repository at this point in the history
Merge main to feature/tasks
  • Loading branch information
KevinRansom authored Feb 5, 2021
2 parents 2cf9ab7 + 341121b commit 51d4c36
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 94 deletions.
1 change: 0 additions & 1 deletion docs/fcs/compiler.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ First, we need to reference the libraries that contain F# interactive service:
#r "FSharp.Compiler.Service.dll"
open System.IO
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Text

// Create an interactive checker instance
let checker = FSharpChecker.Create()
Expand Down
10 changes: 4 additions & 6 deletions docs/fcs/editor.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ open System
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Text
open FSharp.Compiler.Tokenization

// Create an interactive checker instance
let checker = FSharpChecker.Create()
Expand Down Expand Up @@ -119,7 +120,7 @@ this is the type that lets you implement most of the interesting F# source code
### Getting a tool tip
To get a tool tip, you can use `GetToolTipTextAlternate` method. The method takes a line number and character
To get a tool tip, you can use `GetToolTip` method. The method takes a line number and character
offset. Both of the numbers are zero-based. In the sample code, we want to get tooltip for the `foo`
function that is defined on line 3 (line 0 is blank) and the letter `f` starts at index 7 (the tooltip
would work anywhere inside the identifier).
Expand All @@ -132,13 +133,11 @@ identifier (the other option lets you get tooltip with full assembly location wh
let identToken = FSharpTokenTag.Identifier

// Get tool tip at the specified location
let tip = checkFileResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken)
let tip = checkFileResults.GetToolTip(4, 7, inputLines.[1], ["foo"], identToken)
printfn "%A" tip

(**
> **NOTE:** `GetToolTipTextAlternate` is an alternative name for the old `GetToolTipText`. The old `GetToolTipText` was
deprecated because it accepted zero-based line numbers. At some point it will be removed, and `GetToolTipTextAlternate` will be renamed back to `GetToolTipText`.
*)

(**
Expand Down Expand Up @@ -201,8 +200,7 @@ let methods =

// Print concatenated parameter lists
for mi in methods.Methods do
[ for p in mi.Parameters -> p.Display ]
|> List.collect (Array.map (fun tt -> tt.Text) >> Array.toList)
[ for p in mi.Parameters do for tt in p.Display do yield tt.Text ]
|> String.concat ", "
|> printfn "%s(%s)" methods.MethodName
(**
Expand Down
1 change: 0 additions & 1 deletion docs/fcs/filesystem.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ let projectOptions =
ProjectId = None
SourceFiles = [| fileName1; fileName2 |]
OriginalLoadReferences = []
ExtraProjectInfo=None
Stamp = None
OtherOptions = allFlags
ReferencedProjects = [| |]
Expand Down
8 changes: 4 additions & 4 deletions docs/fcs/interactive.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ First, we need to reference the libraries that contain F# interactive service:

#r "FSharp.Compiler.Service.dll"
open FSharp.Compiler.Interactive.Shell
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Tokenization

(**
To communicate with F# interactive, we need to create streams that represent input and
Expand Down Expand Up @@ -142,7 +142,7 @@ Gives:

// show the errors and warnings
for w in warnings do
printfn "Warning %s at %d,%d" w.Message w.StartLineAlternate w.StartColumn
printfn "Warning %s at %d,%d" w.Message w.StartLine w.StartColumn

(**
Gives:
Expand All @@ -157,7 +157,7 @@ For expressions:
let evalExpressionTyped2<'T> text =
let res, warnings = fsiSession.EvalExpressionNonThrowing(text)
for w in warnings do
printfn "Warning %s at %d,%d" w.Message w.StartLineAlternate w.StartColumn
printfn "Warning %s at %d,%d" w.Message w.StartLine w.StartColumn
match res with
| Choice1Of2 (Some value) -> value.ReflectionValue |> unbox<'T>
| Choice1Of2 None -> failwith "null or no result"
Expand Down Expand Up @@ -229,7 +229,7 @@ You can also request declaration list information, tooltip text and symbol resol
*)

// get a tooltip
checkResults.GetToolTipText(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)
checkResults.GetToolTip(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)

checkResults.GetSymbolUseAtLocation(1, 2, "xxx + xx", ["xxx"]) // symbol xxx

Expand Down
8 changes: 3 additions & 5 deletions docs/fcs/ja/editor.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ open System
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Text
open FSharp.Compiler.Tokenization

// インタラクティブチェッカーのインスタンスを作成
let checker = FSharpChecker.Create()
Expand Down Expand Up @@ -141,14 +142,11 @@ let checkFileResults =
// 最後の引数に指定する、IDENTトークンのタグを取得

// 特定の位置におけるツールチップを取得
let tip = checkFileResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], FSharpTokenTag.Identifier)
let tip = checkFileResults.GetToolTip(4, 7, inputLines.[1], ["foo"], FSharpTokenTag.Identifier)
printfn "%A" tip

(**
> **注意:** `GetToolTipTextAlternate` は古い関数 `GetToolTipText` に代わるものです。
`GetToolTipText` は0から始まる行番号を受け取るようになっていたため、非推奨になりました。
この関数には位置とトークンの種類の他にも、
(ソースコードの変更時に役立つように)特定行の現在の内容と、
現時点における完全修飾された `名前` を表す文字列のリストを指定する必要があります。
Expand Down Expand Up @@ -217,7 +215,7 @@ let methods =

// 連結された引数リストを表示
for mi in methods.Methods do
[ for p in mi.Parameters -> p.Display ]
[ for p in mi.Parameters do for tt in p.Display do yield tt.Text ]
|> String.concat ", "
|> printfn "%s(%s)" methods.MethodName
(**
Expand Down
2 changes: 0 additions & 2 deletions docs/fcs/ja/filesystem.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ open System.IO
open System.Text
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.IO
open FSharp.Compiler.Text

let defaultFileSystem = FileSystem

Expand Down Expand Up @@ -126,7 +125,6 @@ let projectOptions =
ProjectId = None
SourceFiles = [| fileName1; fileName2 |]
OriginalLoadReferences = []
ExtraProjectInfo=None
Stamp = None
OtherOptions = allFlags
ReferencedProjects=[| |]
Expand Down
10 changes: 4 additions & 6 deletions docs/fcs/ja/interactive.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ F# Interactiveの開始
*)

#r "FSharp.Compiler.Service.dll"
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Text
open FSharp.Compiler.Tokenization
open FSharp.Compiler.Interactive.Shell

(**
Expand Down Expand Up @@ -158,7 +156,7 @@ match result with

// エラーと警告を表示する
for w in warnings do
printfn "警告 %s 場所 %d,%d" w.Message w.StartLineAlternate w.StartColumn
printfn "警告 %s 場所 %d,%d" w.Message w.StartLine w.StartColumn

(**
は次のようになります:
Expand All @@ -173,7 +171,7 @@ for w in warnings do
let evalExpressionTyped2<'T> text =
let res, warnings = fsiSession.EvalExpressionNonThrowing(text)
for w in warnings do
printfn "警告 %s 場所 %d,%d" w.Message w.StartLineAlternate w.StartColumn
printfn "警告 %s 場所 %d,%d" w.Message w.StartLine w.StartColumn
match res with
| Choice1Of2 (Some value) -> value.ReflectionValue |> unbox<'T>
| Choice1Of2 None -> failwith "null または結果がありません"
Expand Down Expand Up @@ -248,7 +246,7 @@ checkResults.Diagnostics.Length // 1
*)

// ツールチップを取得する
checkResults.GetToolTipText(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)
checkResults.GetToolTip(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT)

checkResults.GetSymbolUseAtLocation(1, 2, "xxx + xx", ["xxx"]) // シンボル xxx

Expand Down
6 changes: 3 additions & 3 deletions docs/fcs/ja/project.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
// F#コンパイラAPIへの参照
#r "FSharp.Compiler.Service.dll"

open System
open System.Collections.Generic
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Symbols
open FSharp.Compiler.Text

// インタラクティブチェッカーのインスタンスを作成
Expand Down Expand Up @@ -113,8 +113,8 @@ let wholeProjectResults = checker.ParseAndCheckProject(projectOptions) |> Async.
wholeProjectResults.Diagnostics.Length // 1
wholeProjectResults.Diagnostics.[0].Message.Contains("Incomplete pattern matches on this expression") // true

wholeProjectResults.Diagnostics.[0].StartLineAlternate // 13
wholeProjectResults.Diagnostics.[0].EndLineAlternate // 13
wholeProjectResults.Diagnostics.[0].StartLine // 13
wholeProjectResults.Diagnostics.[0].EndLine // 13
wholeProjectResults.Diagnostics.[0].StartColumn // 15
wholeProjectResults.Diagnostics.[0].EndColumn // 16

Expand Down
1 change: 0 additions & 1 deletion docs/fcs/ja/symbols.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// F#コンパイラAPIへの参照
#r "FSharp.Compiler.Service.dll"

open System
open System.IO
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Text
Expand Down
6 changes: 2 additions & 4 deletions docs/fcs/ja/tokenizer.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ F#のソースコードに対して、トークナイザは
------------------
トークナイザを使用するには、 `FSharp.Compiler.Service.dll` への参照を追加した後に
`SourceCodeServices` 名前空間をオープンします:
`Tokenization` 名前空間をオープンします:
*)
#r "FSharp.Compiler.Service.dll"
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Text
open FSharp.Compiler.Tokenization
(**
すると `FSharpSourceTokenizer` のインスタンスを作成できるようになります。
このクラスには2つの引数を指定します。
Expand Down
10 changes: 5 additions & 5 deletions docs/fcs/ja/untypedtree.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
インタラクティブチェッカーを使用するには、
`FSharp.Compiler.Service.dll` への参照を追加した後、
`SourceCodeServices` 名前空間をオープンします:
`CodeAnalysis` 名前空間をオープンします:
*)
#r "FSharp.Compiler.Service.dll"
open System
Expand Down Expand Up @@ -164,8 +164,8 @@ let rec visitExpression = function
// ('let .. = .. and .. = .. in ...' に対しては複数回走査されることがある)
printfn "以下のバインディングを含むLetOrUse:"
for binding in bindings do
let (Binding(access, kind, inlin, mutabl, attrs, xmlDoc,
data, pat, retInfo, init, m, sp)) = binding
let (SynBinding(access, kind, inlin, mutabl, attrs, xmlDoc,
data, pat, retInfo, init, m, sp)) = binding
visitPattern pat
visitExpression init
// 本体の式を走査
Expand Down Expand Up @@ -199,8 +199,8 @@ let visitDeclarations decls =
// (visitExpressionで処理したような)式としてのletバインディングと
// 似ているが、本体を持たない
for binding in bindings do
let (Binding(access, kind, inlin, mutabl, attrs, xmlDoc,
data, pat, retInfo, body, m, sp)) = binding
let (SynBinding(access, kind, inlin, mutabl, attrs, xmlDoc,
data, pat, retInfo, body, m, sp)) = binding
visitPattern pat
visitExpression body
| _ -> printfn " - サポート対象外の宣言: %A" declaration
Expand Down
5 changes: 3 additions & 2 deletions docs/fcs/project.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ of `InteractiveChecker`:
open System
open System.Collections.Generic
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Symbols
open FSharp.Compiler.Text

// Create an interactive checker instance
Expand Down Expand Up @@ -131,8 +132,8 @@ Now look at the errors and warnings:
wholeProjectResults.Diagnostics.Length // 1
wholeProjectResults.Diagnostics.[0].Message.Contains("Incomplete pattern matches on this expression") // yes it does

wholeProjectResults.Diagnostics.[0].StartLineAlternate // 13
wholeProjectResults.Diagnostics.[0].EndLineAlternate // 13
wholeProjectResults.Diagnostics.[0].StartLine // 13
wholeProjectResults.Diagnostics.[0].EndLine // 13
wholeProjectResults.Diagnostics.[0].StartColumn // 15
wholeProjectResults.Diagnostics.[0].EndColumn // 16

Expand Down
1 change: 1 addition & 0 deletions docs/fcs/symbols.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ of `FSharpChecker`:
open System
open System.IO
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Symbols
open FSharp.Compiler.Text

// Create an interactive checker instance
Expand Down
6 changes: 2 additions & 4 deletions docs/fcs/tokenizer.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ Creating the tokenizer
---------------------
To use the tokenizer, reference `FSharp.Compiler.Service.dll` and open the
`SourceCodeServices` namespace:
`FSharp.Compiler.Tokenization` namespace:
*)
#r "FSharp.Compiler.Service.dll"
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Text
open FSharp.Compiler.Tokenization
(**
Now you can create an instance of `FSharpSourceTokenizer`. The class takes two
arguments - the first is the list of defined symbols and the second is the
Expand Down
Loading

0 comments on commit 51d4c36

Please sign in to comment.