Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add FSharpChecker.ParseFileNoCache (#7108)
* Add FSharpChecker.ParseFileNoCache

* Review feedback
  • Loading branch information
auduchinok authored and cartermp committed Jul 4, 2019
commit 8c33139acf6557529aa5286661d62a980940fbc5
11 changes: 11 additions & 0 deletions src/fsharp/service/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
return res
}

member bc.ParseFileNoCache(filename, sourceText, options, userOpName) =
async {
let parseErrors, parseTreeOpt, anyErrors = ParseAndCheckFile.parseFile(sourceText, filename, options, userOpName, false)
return FSharpParseFileResults(parseErrors, parseTreeOpt, anyErrors, options.SourceFiles)
}

/// Fetch the parse information from the background compiler (which checks w.r.t. the FileSystem API)
member __.GetBackgroundParseResultsForFileInProject(filename, options, userOpName) =
reactor.EnqueueAndAwaitOpAsync(userOpName, "GetBackgroundParseResultsForFileInProject ", filename, fun ctok ->
Expand Down Expand Up @@ -961,6 +967,11 @@ type FSharpChecker(legacyReferenceResolver,
ic.CheckMaxMemoryReached()
backgroundCompiler.ParseFile(filename, sourceText, options, userOpName)

member ic.ParseFileNoCache(filename, sourceText, options, ?userOpName) =
let userOpName = defaultArg userOpName "Unknown"
ic.CheckMaxMemoryReached()
backgroundCompiler.ParseFileNoCache(filename, sourceText, options, userOpName)

member ic.ParseFileInProject(filename, source: string, options, ?userOpName: string) =
let userOpName = defaultArg userOpName "Unknown"
let parsingOptions, _ = ic.GetParsingOptionsFromProjectOptions(options)
Expand Down
27 changes: 17 additions & 10 deletions src/fsharp/service/service.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,32 @@ type public FSharpChecker =
member MatchBraces: filename: string * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async<(range * range)[]>

/// <summary>
/// <para>Parse a source code file, returning a handle that can be used for obtaining navigation bar information
/// To get the full information, call 'CheckFileInProject' method on the result</para>
/// Parses a source code for a file and caches the results. Returns an AST that can be traversed for various features.
/// </summary>
///
/// <param name="filename">The filename for the file.</param>
/// <param name="sourceText">The full source for the file.</param>
/// <param name="filename">The path for the file. The file name is used as a module name for implicit top level modules (e.g. in scripts).</param>
/// <param name="sourceText">The source to be parsed.</param>
/// <param name="options">Parsing options for the project or script.</param>
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
member ParseFile: filename: string * sourceText: ISourceText * options: FSharpParsingOptions * ?userOpName: string -> Async<FSharpParseFileResults>

/// <summary>
/// <para>Parse a source code file, returning a handle that can be used for obtaining navigation bar information
/// To get the full information, call 'CheckFileInProject' method on the result</para>
/// <para>All files except the one being checked are read from the FileSystem API</para>
/// Parses a source code for a file. Returns an AST that can be traversed for various features.
/// </summary>
///
/// <param name="filename">The filename for the file.</param>
/// <param name="source">The full source for the file.</param>
/// <param name="options">The options for the project or script, used to determine active --define conditionals and other options relevant to parsing.</param>
/// <param name="filename">The path for the file. The file name is also as a module name for implicit top level modules (e.g. in scripts).</param>
/// <param name="sourceText">The source to be parsed.</param>
/// <param name="options">Parsing options for the project or script.</param>
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
member ParseFileNoCache: filename: string * sourceText: ISourceText * options: FSharpParsingOptions * ?userOpName: string -> Async<FSharpParseFileResults>

/// <summary>
/// Parses a source code for a file. Returns an AST that can be traversed for various features.
/// </summary>
///
/// <param name="filename">The path for the file. The file name is also as a module name for implicit top level modules (e.g. in scripts).</param>
/// <param name="sourceText">The source to be parsed.</param>
/// <param name="options">Parsing options for the project or script.</param>
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
[<Obsolete("Please call checker.ParseFile instead. To do this, you must also pass FSharpParsingOptions instead of FSharpProjectOptions. If necessary generate FSharpParsingOptions from FSharpProjectOptions by calling checker.GetParsingOptionsFromProjectOptions(options)")>]
member ParseFileInProject: filename: string * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async<FSharpParseFileResults>
Expand Down