Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 38d12b3

Browse files
0x6a62nosami
authored andcommitted
FCS Doc update - SourceText (dotnet#7446)
* Fix typos * Add SourceText type conversion to FCS docs
1 parent 91e0ec7 commit 38d12b3

File tree

10 files changed

+29
-21
lines changed

10 files changed

+29
-21
lines changed

DEVGUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ VSIXInstaller.exe /u:"VisualFSharp"
138138
VSIXInstaller.exe artifacts\VSSetup\Release\VisualFSharpFull.vsix
139139
```
140140

141-
It's important to use `Release` if you want to see if your changes have had a noticable performance impact.
141+
It's important to use `Release` if you want to see if your changes have had a noticeable performance impact.
142142

143143
### Performance and debugging
144144

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ You're invited to contribute to future releases of the F# compiler, core library
88

99
Build from the command line:
1010

11-
```bash
11+
```
1212
build.cmd
1313
```
1414

@@ -18,8 +18,8 @@ After it's finished, open either `FSharp.sln` or `VisualFSharp.sln` in your edit
1818

1919
Build from the command line:
2020

21-
```bash
22-
sh ./build.sh
21+
```
22+
./build.sh
2323
```
2424

2525
After it's finished, open `FSharp.sln` in your editor of choice.

fcs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ FSharp.Compiler.Service is a somewhat awkward component. There are some things w
9999
1. Remove the use of Paket and FAKE
100100
1. Move all projects under fcs\... to new .NET SDK project file format
101101
1. Drop the use of ``dotnet mergenupkg`` since we should be able to use cross targeting
102-
1. Make FCS a DLL similar ot the rest of the build and make this an official component from Microsoft (signed etc.)
102+
1. Make FCS a DLL similar to the rest of the build and make this an official component from Microsoft (signed etc.)
103103
1. Replace FSharp.Compiler.Private by FSharp.Compiler.Service

fcs/docsrc/content/devnotes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This repo should be _identical_ to 'fsharp' except:
2020
- No bootstrap or proto compiler is used - an installed F# compiler is assumed
2121

2222
- Build script using FAKE that builds everything, produces NuGet package and
23-
generates documentation, files for publising NuGet packages etc.
23+
generates documentation, files for publishing NuGet packages etc.
2424
(following [F# project scaffold](https://github.com/fsprojects/FSharp.ProjectScaffold))
2525

2626
- Changes to compiler source code to expose new functionality; Changes to the
@@ -30,7 +30,7 @@ This repo should be _identical_ to 'fsharp' except:
3030

3131
- Additions to compiler source code which add new functionality to the compiler service API
3232

33-
If language or compiler addiitons are committed to `fsharp/fsharp`, they should be merged into
33+
If language or compiler additions are committed to `fsharp/fsharp`, they should be merged into
3434
this repo and a new NuGet package released.
3535

3636
## Building and NuGet

fcs/docsrc/content/editor.fsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ of `InteractiveChecker`:
2727

2828
open System
2929
open FSharp.Compiler.SourceCodeServices
30+
open FSharp.Compiler.Text
3031

3132
// Create an interactive checker instance
3233
let checker = FSharpChecker.Create()
@@ -53,7 +54,7 @@ let inputLines = input.Split('\n')
5354
let file = "/home/user/Test.fsx"
5455

5556
let projOptions, errors =
56-
checker.GetProjectOptionsFromScript(file, input)
57+
checker.GetProjectOptionsFromScript(file, SourceText.ofString input)
5758
|> Async.RunSynchronously
5859

5960
let parsingOptions, _errors = checker.GetParsingOptionsFromProjectOptions(projOptions)
@@ -68,7 +69,7 @@ together.
6869
// Perform parsing
6970

7071
let parseFileResults =
71-
checker.ParseFile(file, input, parsingOptions)
72+
checker.ParseFile(file, SourceText.ofString input, parsingOptions)
7273
|> Async.RunSynchronously
7374
(**
7475
Before we look at the interesting operations provided by `TypeCheckResults`, we
@@ -78,15 +79,15 @@ result (but it may contain incorrectly "guessed" results).
7879

7980
// Perform type checking
8081
let checkFileAnswer =
81-
checker.CheckFileInProject(parseFileResults, file, 0, input, projOptions)
82+
checker.CheckFileInProject(parseFileResults, file, 0, SourceText.ofString input, projOptions)
8283
|> Async.RunSynchronously
8384

8485
(**
8586
Alternatively you can use `ParseAndCheckFileInProject` to check both in one step:
8687
*)
8788

8889
let parseResults2, checkFileAnswer2 =
89-
checker.ParseAndCheckFileInProject(file, 0, input, projOptions)
90+
checker.ParseAndCheckFileInProject(file, 0, SourceText.ofString input, projOptions)
9091
|> Async.RunSynchronously
9192

9293
(**

fcs/docsrc/content/interactive.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ open System.IO
4444
open System.Text
4545

4646
// Intialize output and input streams
47-
let sbOut = new StringBuilder()
48-
let sbErr = new StringBuilder()
47+
let sbOut = StringBuilder()
48+
let sbErr = StringBuilder()
4949
let inStream = new StringReader("")
5050
let outStream = new StringWriter(sbOut)
5151
let errStream = new StringWriter(sbErr)
@@ -242,7 +242,7 @@ If you want your scripting code to be able to access the 'fsi' object, you shoul
242242
Normally the one fromm FSharp.Compiler.Interactive.Settings.dll is used.
243243
*)
244244

245-
let fsiConfig2 = FsiEvaluationSession.GetDefaultConfiguration(fsi)
245+
let fsiConfig2 = FsiEvaluationSession.GetDefaultConfiguration(fsiSession)
246246

247247
(**
248248
Collectible code generation

fcs/docsrc/content/project.fsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ of `InteractiveChecker`:
2828
open System
2929
open System.Collections.Generic
3030
open FSharp.Compiler.SourceCodeServices
31+
open FSharp.Compiler.Text
3132

3233
// Create an interactive checker instance
3334
let checker = FSharpChecker.Create()
@@ -220,7 +221,7 @@ in the project are still read from disk, unless you are using the [FileSystem AP
220221
*)
221222

222223
let parseResults1, checkAnswer1 =
223-
checker.ParseAndCheckFileInProject(Inputs.fileName1, 0, Inputs.fileSource1, projectOptions)
224+
checker.ParseAndCheckFileInProject(Inputs.fileName1, 0, SourceText.ofString Inputs.fileSource1, projectOptions)
224225
|> Async.RunSynchronously
225226

226227
let checkResults1 =
@@ -229,7 +230,7 @@ let checkResults1 =
229230
| _ -> failwith "unexpected aborted"
230231

231232
let parseResults2, checkAnswer2 =
232-
checker.ParseAndCheckFileInProject(Inputs.fileName2, 0, Inputs.fileSource2, projectOptions)
233+
checker.ParseAndCheckFileInProject(Inputs.fileName2, 0, SourceText.ofString Inputs.fileSource2, projectOptions)
233234
|> Async.RunSynchronously
234235

235236
let checkResults2 =

fcs/docsrc/content/symbols.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ of `FSharpChecker`:
1919
open System
2020
open System.IO
2121
open FSharp.Compiler.SourceCodeServices
22+
open FSharp.Compiler.Text
2223

2324
// Create an interactive checker instance
2425
let checker = FSharpChecker.Create()
@@ -72,7 +73,7 @@ type C() =
7273
member x.P = 1
7374
"""
7475
let parseFileResults, checkFileResults =
75-
parseAndTypeCheckSingleFile(file, input2)
76+
parseAndTypeCheckSingleFile(file, SourceText.ofString input2)
7677

7778
(**
7879
Now get the partial assembly signature for the code:

fcs/docsrc/content/typedtree.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ To use the interactive checker, reference `FSharp.Compiler.Service.dll` and open
2626
open System
2727
open System.IO
2828
open FSharp.Compiler.SourceCodeServices
29+
open FSharp.Compiler.Text
2930
(**
3031
3132
### Checking code
@@ -42,7 +43,7 @@ let parseAndCheckSingleFile (input) =
4243
File.WriteAllText(file, input)
4344
// Get context representing a stand-alone (script) file
4445
let projOptions, _errors =
45-
checker.GetProjectOptionsFromScript(file, input)
46+
checker.GetProjectOptionsFromScript(file, SourceText.ofString input)
4647
|> Async.RunSynchronously
4748

4849
checker.ParseAndCheckProject(projOptions)

fcs/docsrc/content/untypedtree.fsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ To use the interactive checker, reference `FSharp.Compiler.Service.dll` and open
3131
#r "FSharp.Compiler.Service.dll"
3232
open System
3333
open FSharp.Compiler.SourceCodeServices
34+
open FSharp.Compiler.Text
3435
(**
3536
3637
### Performing untyped parse
@@ -201,16 +202,19 @@ with location of the file. The location does not have to exist (it is used only
201202
information) and it can be in both Unix and Windows formats:
202203
*)
203204
// Sample input for the compiler service
204-
let input = """
205+
let input =
206+
"""
205207
let foo() =
206208
let msg = "Hello world"
207209
if true then
208-
printfn "%s" msg """
210+
printfn "%s" msg
211+
"""
212+
209213
// File name in Unix format
210214
let file = "/home/user/Test.fsx"
211215

212216
// Get the AST of sample F# code
213-
let tree = getUntypedTree(file, input)
217+
let tree = getUntypedTree(file, SourceText.ofString input)
214218
(**
215219
When you run the code in F# interactive, you can enter `tree;;` in the interactive console and
216220
see pretty printed representation of the data structure - the tree contains a lot of information,

0 commit comments

Comments
 (0)