Skip to content

Add inferred type hint stage #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 111 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
2312f7b
Add InferredTypeHintHighlightingProcess
saul Apr 2, 2020
1b7ab5c
Merge branch 'net201-pipe-chain-insight' into net201-local-ref-pat-hints
saul Apr 2, 2020
1e49dea
Add tests
saul Apr 2, 2020
7647371
Put && on end of life
saul Apr 2, 2020
cf32c8f
Merge branch 'net201-pipe-chain-insight' into net201-local-ref-pat-hints
saul Apr 2, 2020
d2ab70e
Update InferredTypeHintStage.fs
saul Apr 2, 2020
780727d
Merge branch 'net201-pipe-chain-insight' into net201-local-ref-pat-hints
saul Apr 2, 2020
3c65b47
Merge remote-tracking branch 'upstream/net202' into net201-local-ref-…
saul Apr 29, 2020
054b671
Merge branch 'net201-pipe-chain-insight' into net201-local-ref-pat-hints
saul Apr 29, 2020
008009b
Markups, add more tests
saul Apr 29, 2020
79db589
Add code insight to |> chains (#106)
saul Apr 29, 2020
59d94b7
Add parameter name hints
saul Apr 29, 2020
e955162
Resolve todo
saul Apr 29, 2020
f26344d
Merge branch 'net202-parameter-name-hints' into net201-local-ref-pat-…
saul Apr 29, 2020
28c1297
Merge remote-tracking branch 'upstream/net202' into net201-local-ref-…
saul Apr 29, 2020
1353ac8
Revert "Merge branch 'net202-parameter-name-hints' into net201-local-…
saul Apr 29, 2020
8899fa6
Un-Fantomas
saul Apr 29, 2020
1c60fea
Delete accidentally committed file
saul Apr 29, 2020
5e1a691
Rename ISynExpr -> IFSharpExpression
auduchinok May 1, 2020
62c9290
Rename ISynType -> ITypeUsage
auduchinok May 1, 2020
d7db56a
Update test baselines
auduchinok May 1, 2020
69460d3
Mark expressions recovered from errors
auduchinok May 1, 2020
5b8cf55
Fix getting script dependencies on Core runtime
auduchinok May 2, 2020
06e4af1
Introduce var: disable for named args
auduchinok May 3, 2020
61196c1
Add alignment formatter rules for some expressions (#115)
reacheight May 4, 2020
1ff8d68
Update SDK to 2020.2, fix for API changes
auduchinok May 5, 2020
b1b4a0a
Add useful tools to fsi console's editor (#102)
yarkoe May 5, 2020
7968de2
Fix for API changes (FormatterInfoProviderWithFluentApi)
auduchinok May 7, 2020
e32cc0b
Introduce var: allow replacing source expr itself
auduchinok May 7, 2020
0fbeef8
Introduce var: enable quick fix in more contexts
auduchinok May 8, 2020
aa44e91
Fix for API change (ICompletionSessionStrategy)
auduchinok May 8, 2020
cbd4e5f
Introduce var: enable quick fix for UnitTypeExpectedError
auduchinok May 8, 2020
0e8c4f2
Introduce var: fixes for expressions in sequence expressions
auduchinok May 8, 2020
ea28bc4
Fix for API change (BaseTestWithSingleProject.DoTestSolution) (#122)
saul May 9, 2020
f32b1df
Fix for API change (ProjectModelNodeExtension)
auduchinok May 9, 2020
ed50e71
Simplify grammar lists
auduchinok May 11, 2020
9c6d815
Fix test baselines
auduchinok May 12, 2020
4e0872a
Add RemoveYieldFix
auduchinok May 12, 2020
85d4c6f
Introduce var: move expression to new line for members and auto prope…
auduchinok May 12, 2020
29e744e
Grammar: use common child type for Equals tokens
auduchinok May 12, 2020
041eed4
Commit lost change
auduchinok May 12, 2020
0457c28
Unify letOrUseExpr and letOrUseBangExpr rules
auduchinok May 12, 2020
23f00dc
Commit parser test data
auduchinok May 12, 2020
6c3f3d4
Commit changed parser test baselines
auduchinok May 13, 2020
9a39087
Fix wrong Guid creation in items container test
auduchinok May 13, 2020
c57199f
Introduce var: extract multiple expressions in common seqExpr
auduchinok May 13, 2020
81b4b4c
Introduce var: only keep context expr in lists with multiple usages
auduchinok May 14, 2020
6c6ccbe
Introduce var: keep incomplete letExpr for last expr for easier editing
auduchinok May 14, 2020
b8801a8
Introduce var: keep some expressions single line
auduchinok May 15, 2020
772942b
Introduce var: don't escape let expr
auduchinok May 15, 2020
da1ccba
Introduce var: fix getting tree nodes from replaced refExpr pointers
auduchinok May 15, 2020
aa63ca2
Fully support argument matching (#120)
saul May 15, 2020
f6d8009
Update parser test baselines
auduchinok May 15, 2020
366d425
Introduce var: disable for unit named arg expressions, more tests
auduchinok May 15, 2020
e1d8086
Fix FSharpMethodInvocationUtil.isNamedArgReference for union case fields
auduchinok May 16, 2020
c034840
Introduce var: escape record field bindings
auduchinok May 16, 2020
7b7b052
Merge remote-tracking branch 'upstream/net202' into net201-local-ref-…
saul May 17, 2020
2b779f3
Fix getting module attributes, fix filtering by name
auduchinok May 17, 2020
90658dd
Add redundant qualifier analyzer
auduchinok May 18, 2020
70b3034
Find usages: fix searching compiled modules with Module suffix
auduchinok May 18, 2020
035f556
Redundant qualifier analyzer: take implicit Module suffix into account
auduchinok May 18, 2020
c4a13df
Don't pass Mfv to member declared elements ctors
auduchinok May 19, 2020
32670e3
Project options provider: advice for changes when project model is ready
auduchinok May 21, 2020
f36f2d7
Don't cache FCS parse results for generated trees
auduchinok May 21, 2020
3977dc7
Redundant qualifier analyzer: fix isInOpen check
auduchinok May 22, 2020
944627f
Hook into 'Type Name Hints' settings
saul May 23, 2020
4dbe6b3
Find usages: don't search type-private elements in other files
auduchinok May 23, 2020
ab742ab
Find usages: fix for reducing scope for type-private elements
auduchinok May 23, 2020
f723c6a
Add more tests
saul May 23, 2020
91e6d5d
Add object expression and cast expression to tests
saul May 23, 2020
fc520a6
Merge remote-tracking branch 'upstream/net202' into net201-local-ref-…
saul May 23, 2020
707ef8e
Show background task in UI when FCS reactor is busy (#127)
saul May 25, 2020
527dc20
Disable FcsReactorMonitor
auduchinok May 25, 2020
739e5fd
Don't get FCS resolved attributes when checking AutoOpen
auduchinok May 25, 2020
b9173c0
Enable FcsReactorMonitor, disable in tests
auduchinok May 25, 2020
7ed7095
Schedule hint-related stages after other long-running ones
auduchinok May 25, 2020
b66b010
Minor cleanup
auduchinok May 25, 2020
2d246e7
Fix for API change (ICompletionSessionStrategy)
auduchinok May 27, 2020
0cbdd08
Don't wait for FCS during creation of record field declared element
auduchinok May 27, 2020
c0e1c93
Fix getting symbol for ctor with modifier, don't wait for FCS
auduchinok May 27, 2020
0cbd166
Disable smart copy assist handlers
auduchinok May 28, 2020
f069803
Fix lexing of quote (#130)
misonijnik May 29, 2020
259f5a8
Workaround completion strategy changes
auduchinok Jun 1, 2020
7c5a333
Add more tests for named args patterns
auduchinok Jun 2, 2020
1a46704
Fix stack overflow in redundant qualifier analyzer for compiled modules
auduchinok Jun 2, 2020
a3569a6
Fix for API changes (scriptingApi)
auduchinok Jun 2, 2020
fb9b523
Fix for API change (IHighlighterIntraTextAdornmentProvider)
auduchinok Jun 2, 2020
e0b9e14
Rewrite FCS project properties invalidation
auduchinok May 26, 2020
4cb91a3
More FcsProjectProvider-related cleanup
auduchinok May 26, 2020
0ccaf8a
Fix invalidating projects after non-F# projects build, add tests
auduchinok May 27, 2020
c67e1d7
Better waiting for daemon invalidation in FcsProjectProviderTest
auduchinok Jun 4, 2020
f40f7a6
Subscribe to output assembly changes when on StartPsi
auduchinok Jun 5, 2020
4cb222e
Rename ISynPat -> IFSharpPattern
auduchinok Jun 5, 2020
da1ba1c
Fix ref pat starting with upper case could be mapped as parameter owner
auduchinok Jun 5, 2020
50e59b1
Import type fix: add qualifiers in expressions
auduchinok Jun 6, 2020
4b64a14
Import type fix: add qualifiers in type references
auduchinok Jun 6, 2020
892247c
Introduce var: don't escape top level functions
auduchinok Jun 7, 2020
cbe64e4
Fix for API change (ICodeCleanupModule.Process)
auduchinok Jun 8, 2020
047f7e9
Clean up test data
auduchinok Jun 8, 2020
f3f350b
Redundant new: check type reference is not null
auduchinok Jun 8, 2020
6e23242
Unify member and constructor parameter declarations
auduchinok Jun 8, 2020
e4236f7
Disable ReplaceWithWildPat quick fix for typed pattens with attributes
auduchinok Jun 8, 2020
2c36459
Introduce var: don't escape separated blocks in multi-line binary apps
auduchinok Jun 9, 2020
dabf4d1
Introduce var: try getting context from left arg in binary app exprs
auduchinok Jun 9, 2020
3e5ec03
Reactor monitor improvements (#133)
saul Jun 9, 2020
e412faf
Fix for test API dump changes (DebugTestExecutionContext.dumpFullCurr…
auduchinok Jun 9, 2020
237f734
Update FCS
auduchinok Jun 9, 2020
d3f354d
Shortcut LocalReferencePat.IsDeclaration check by checking lower case
auduchinok Jun 9, 2020
887b7df
Merge remote-tracking branch 'upstream/net202' into net201-local-ref-…
saul Jun 10, 2020
179406c
Markups
saul Jun 10, 2020
8b9dda5
Cleanup, safer getting pattern name
auduchinok Jun 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion ReSharper.FSharp/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup>
<FantomasVersion>2020.1.4</FantomasVersion>
<FSharpCompilerServiceVersion>2020.1.12</FSharpCompilerServiceVersion>
<FSharpCompilerServiceVersion>2020.2.0</FSharpCompilerServiceVersion>
<FSharpCoreVersion>4.7.0</FSharpCoreVersion>
<ValueTupleVersion>4.5.0</ValueTupleVersion>
</PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions ReSharper.FSharp/ReSharper.FSharp.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=deindenting/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=elif/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=exprs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=failwith/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=failwithf/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hotspots/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=noconditionalerasure/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Qualifiable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Rarrow/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=RSRP/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=simpleresolution/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=targetprofile/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tupled/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=warnon/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,65 @@ public static class FSharpSymbolHighlightingUtil
public static string GetEntityHighlightingAttributeId([NotNull] this FSharpEntity entity)
{
if (entity.IsNamespace)
return FSharpHighlightingAttributeIds.Namespace;
return FSharpHighlightingAttributeIdsModule.Namespace;

if (entity.IsEnum)
return FSharpHighlightingAttributeIds.Enum;
return FSharpHighlightingAttributeIdsModule.Enum;

if (entity.IsValueType)
return FSharpHighlightingAttributeIds.Struct;
return FSharpHighlightingAttributeIdsModule.Struct;

if (entity.IsDelegate)
return FSharpHighlightingAttributeIds.Delegate;
return FSharpHighlightingAttributeIdsModule.Delegate;

if (entity.IsFSharpModule)
return FSharpHighlightingAttributeIds.Module;
return FSharpHighlightingAttributeIdsModule.Module;

if (entity.IsFSharpUnion)
return FSharpHighlightingAttributeIds.Union;
return FSharpHighlightingAttributeIdsModule.Union;

if (entity.IsFSharpRecord)
return FSharpHighlightingAttributeIds.Record;
return FSharpHighlightingAttributeIdsModule.Record;

return entity.IsInterface
? FSharpHighlightingAttributeIds.Interface
: FSharpHighlightingAttributeIds.Class;
? FSharpHighlightingAttributeIdsModule.Interface
: FSharpHighlightingAttributeIdsModule.Class;
}

[NotNull]
public static string GetMfvHighlightingAttributeId([NotNull] this FSharpMemberOrFunctionOrValue mfv)
{
if (mfv.IsEvent || mfv.IsEventAddMethod || mfv.IsEventRemoveMethod || mfv.EventForFSharpProperty != null)
return FSharpHighlightingAttributeIds.Event;
return FSharpHighlightingAttributeIdsModule.Event;

if (mfv.IsImplicitConstructor || mfv.IsConstructor)
return mfv.DeclaringEntity?.Value is FSharpEntity declEntity && declEntity.IsValueType
? FSharpHighlightingAttributeIds.Struct
: FSharpHighlightingAttributeIds.Class;
? FSharpHighlightingAttributeIdsModule.Struct
: FSharpHighlightingAttributeIdsModule.Class;

var entity = mfv.DeclaringEntity;
if (mfv.IsModuleValueOrMember && (entity != null && !entity.Value.IsFSharpModule || mfv.IsExtensionMember))
return mfv.IsProperty || mfv.IsPropertyGetterMethod || mfv.IsPropertySetterMethod
? FSharpHighlightingAttributeIds.Property
: FSharpHighlightingAttributeIds.Method;
? FSharpHighlightingAttributeIdsModule.Property
: FSharpHighlightingAttributeIdsModule.Method;

if (mfv.LiteralValue != null)
return FSharpHighlightingAttributeIds.Literal;
return FSharpHighlightingAttributeIdsModule.Literal;

if (mfv.IsActivePattern)
return FSharpHighlightingAttributeIds.ActivePatternCase;
return FSharpHighlightingAttributeIdsModule.ActivePatternCase;

if (mfv.IsMutable || mfv.IsRefCell())
return FSharpHighlightingAttributeIds.MutableValue;
return FSharpHighlightingAttributeIdsModule.MutableValue;

if (IsMangledOpName(mfv.LogicalName))
return FSharpHighlightingAttributeIds.Operator;
return FSharpHighlightingAttributeIdsModule.Operator;

var fsType = mfv.FullType;
if (fsType.HasTypeDefinition && fsType.TypeDefinition is var mfvTypeEntity && mfvTypeEntity.IsByRef)
return FSharpHighlightingAttributeIds.MutableValue;
return FSharpHighlightingAttributeIdsModule.MutableValue;

return FSharpHighlightingAttributeIds.Value;
return FSharpHighlightingAttributeIdsModule.Value;
}

[NotNull]
Expand All @@ -87,21 +87,21 @@ public static string GetHighlightingAttributeId([NotNull] this FSharpSymbol symb

case FSharpField field:
return field.IsLiteral
? FSharpHighlightingAttributeIds.Literal
: FSharpHighlightingAttributeIds.Field;
? FSharpHighlightingAttributeIdsModule.Literal
: FSharpHighlightingAttributeIdsModule.Field;

case FSharpUnionCase _:
return FSharpHighlightingAttributeIds.UnionCase;
return FSharpHighlightingAttributeIdsModule.UnionCase;

case FSharpGenericParameter _:
return FSharpHighlightingAttributeIds.TypeParameter;
return FSharpHighlightingAttributeIdsModule.TypeParameter;

case FSharpActivePatternCase _:
return FSharpHighlightingAttributeIds.ActivePatternCase;
return FSharpHighlightingAttributeIdsModule.ActivePatternCase;
}

// some highlighting is needed for tooltip provider
return FSharpHighlightingAttributeIds.Value;
return FSharpHighlightingAttributeIdsModule.Value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IFSharpIdentifierTooltipProvider
}

[DaemonTooltipProvider(typeof(IFSharpIdentifierTooltipProvider))]
[StaticSeverityHighlighting(Severity.INFO, HighlightingGroupIds.IdentifierHighlightingsGroup,
[StaticSeverityHighlighting(Severity.INFO, typeof(HighlightingGroupIds.IdentifierHighlightings),
OverlapResolve = OverlapResolveKind.NONE, ShowToolTipInStatusBar = false)]
public class FSharpIdentifierHighlighting : ICustomAttributeIdHighlighting
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void AddHighlightings(IEnumerable<FSharpResolvedSymbolUse> symbolsUses,

var highlightingId =
symbolUse.IsFromComputationExpression
? FSharpHighlightingAttributeIds.Keyword
? FSharpHighlightingAttributeIdsModule.Keyword
: symbol.GetHighlightingAttributeId();

if (symbolUse.IsFromDefinition && symbol is FSharpMemberOrFunctionOrValue mfv)
Expand Down
6 changes: 4 additions & 2 deletions ReSharper.FSharp/src/FSharp.Common/FSharp.Common.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
<Compile Include="src\ProjectModel\FSharpFileService.fs" />
<Compile Include="src\ProjectModel\FSharpProjectPresenter.fs" />
<Compile Include="src\ProjectModel\ProjectLoadDiagnostics.fs" />
<Compile Include="src\Checker\FSharpProjectOptionsBuilder.fs" />
<Compile Include="src\Checker\FSharpProjectOptionsProvider.fs" />
<Compile Include="src\Checker\ScriptFcsProjectProvider.fs" />
<Compile Include="src\Checker\FcsProjectBuilder.fs" />
<Compile Include="src\Checker\FcsProjectProvider.fs" />
<Compile Include="src\FcsReactorMonitor.fs" />
<Compile Include="src\PaketRestoreTargetsAnalyzer.fs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace rec JetBrains.ReSharper.Plugins.FSharp.Checker

open System
open System.Collections.Generic
open System.Runtime.InteropServices
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Text
Expand All @@ -11,6 +10,7 @@ open JetBrains.Application
open JetBrains.Application.Settings
open JetBrains.DataFlow
open JetBrains.DocumentModel
open JetBrains.Lifetimes
open JetBrains.ProjectModel
open JetBrains.ReSharper.Feature.Services
open JetBrains.ReSharper.Plugins.FSharp
Expand All @@ -21,10 +21,15 @@ open JetBrains.ReSharper.Psi.Modules
open JetBrains.ReSharper.Psi.Tree
open JetBrains.Util

module FSharpCheckerService =
let getSourceText (document: IDocument) =
SourceText.ofString(document.GetText())


[<ShellComponent; AllowNullLiteral>]
type FSharpCheckerService
(lifetime, logger: ILogger, onSolutionCloseNotifier: OnSolutionCloseNotifier, settingsStore: ISettingsStore,
settingsSchema: SettingsSchema) =
(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotifier: OnSolutionCloseNotifier,
settingsStore: ISettingsStore, settingsSchema: SettingsSchema) =

let checker =
Environment.SetEnvironmentVariable("FCS_CheckFileInProjectCacheSize", "20")
Expand Down Expand Up @@ -55,13 +60,23 @@ type FSharpCheckerService
if checker.IsValueCreated then
checker.Value.InvalidateAll())

member val OptionsProvider = Unchecked.defaultof<IFSharpProjectOptionsProvider> with get, set
member val FcsReactorMonitor = Unchecked.defaultof<IFcsReactorMonitor> with get, set
member val FcsProjectProvider = Unchecked.defaultof<IFcsProjectProvider> with get, set

member x.Checker = checker.Value

member x.ParseFile(path: FileSystemPath, document: IDocument, parsingOptions: FSharpParsingOptions) =
let source = SourceText.ofString (document.GetText())
member x.ParseFile(path, document, parsingOptions, [<Optional; DefaultParameterValue(false)>] noCache: bool) =
try
let parseResults = x.Checker.ParseFile(path.FullPath, source, parsingOptions).RunAsTask()
let source = FSharpCheckerService.getSourceText document
let fullPath = getFullPath path

let parseAsync =
if noCache then
x.Checker.ParseFileNoCache(fullPath, source, parsingOptions)
else
x.Checker.ParseFile(fullPath, source, parsingOptions)

let parseResults = parseAsync.RunAsTask()
Some parseResults
with
| OperationCanceled -> reraise()
Expand All @@ -71,21 +86,23 @@ type FSharpCheckerService
None

member x.ParseFile([<NotNull>] sourceFile: IPsiSourceFile) =
let parsingOptions = x.OptionsProvider.GetParsingOptions(sourceFile)
let parsingOptions = x.FcsProjectProvider.GetParsingOptions(sourceFile)
x.ParseFile(sourceFile.GetLocation(), sourceFile.Document, parsingOptions)

member x.ParseAndCheckFile([<NotNull>] file: IPsiSourceFile, opName,
[<Optional; DefaultParameterValue(false)>] allowStaleResults) =
match x.OptionsProvider.GetProjectOptions(file) with
match x.FcsProjectProvider.GetProjectOptions(file) with
| None -> None
| Some options ->

let path = file.GetLocation().FullPath
let source = SourceText.ofString (file.Document.GetText())
let source = FSharpCheckerService.getSourceText file.Document
logger.Trace("ParseAndCheckFile: start {0}, {1}", path, opName)

use op = x.FcsReactorMonitor.MonitorOperation opName

// todo: don't cancel the computation when file didn't change
match x.Checker.ParseAndCheckDocument(path, source, options, allowStaleResults, opName).RunAsTask() with
match x.Checker.ParseAndCheckDocument(path, source, options, allowStaleResults, op.OperationName).RunAsTask() with
| Some (parseResults, checkResults) when parseResults.ParseTree.IsSome ->
logger.Trace("ParseAndCheckFile: finish {0}, {1}", path, opName)
Some { ParseResults = parseResults; CheckResults = checkResults }
Expand All @@ -95,7 +112,7 @@ type FSharpCheckerService
None

member x.TryGetStaleCheckResults([<NotNull>] file: IPsiSourceFile, opName) =
match x.OptionsProvider.GetProjectOptions(file) with
match x.FcsProjectProvider.GetProjectOptions(file) with
| None -> None
| Some options ->

Expand All @@ -111,9 +128,9 @@ type FSharpCheckerService
logger.Trace("TryGetStaleCheckResults: fail {0}, {1}", path, opName)
None

member x.InvalidateFSharpProject(fsProject: FSharpProject) =
member x.InvalidateFcsProject(fcsProjectOptions: FSharpProjectOptions) =
if checker.IsValueCreated then
checker.Value.InvalidateConfiguration(fsProject.ProjectOptions, false)
checker.Value.InvalidateConfiguration(fcsProjectOptions, false)

/// Use with care: returns wrong symbol inside its non-recursive declaration, see dotnet/fsharp#7694.
member x.ResolveNameAtLocation(sourceFile: IPsiSourceFile, names, coords, opName) =
Expand All @@ -123,7 +140,9 @@ type FSharpCheckerService
let checkResults = results.CheckResults
let fcsPos = getPosFromCoords coords
let lineText = sourceFile.Document.GetLineText(coords.Line)
checkResults.GetSymbolUseAtLocation(fcsPos.Line, fcsPos.Column, lineText, names, opName).RunAsTask())

use op = x.FcsReactorMonitor.MonitorOperation opName
checkResults.GetSymbolUseAtLocation(fcsPos.Line, fcsPos.Column, lineText, names, op.OperationName).RunAsTask())

/// Use with care: returns wrong symbol inside its non-recursive declaration, see dotnet/fsharp#7694.
member x.ResolveNameAtLocation(sourceFile: IPsiSourceFile, name, coords, opName) =
Expand All @@ -137,31 +156,37 @@ type FSharpCheckerService
x.ResolveNameAtLocation(sourceFile, names, coords, opName)


type FSharpProject =
{ ProjectOptions: FSharpProjectOptions
ParsingOptions: FSharpParsingOptions
FileIndices: IDictionary<FileSystemPath, int>
ImplFilesWithSigs: ISet<FileSystemPath> }

member x.ContainsFile(file: IPsiSourceFile) =
x.FileIndices.ContainsKey(file.GetLocation())


type FSharpParseAndCheckResults =
{ ParseResults: FSharpParseFileResults
CheckResults: FSharpCheckFileResults }


type IFSharpProjectOptionsProvider =
type IFcsProjectProvider =
abstract GetProjectOptions: IPsiSourceFile -> FSharpProjectOptions option
abstract GetParsingOptions: IPsiSourceFile -> FSharpParsingOptions
abstract GetFileIndex: IPsiSourceFile -> int

// Indicates if implementation file has an associated signature file.
abstract HasPairFile: IPsiSourceFile -> bool
abstract Invalidate: IProject -> bool

/// Returns True when the project has been invalidated.
abstract InvalidateReferencesToProject: IProject -> bool

abstract ModuleInvalidated: ISignal<IPsiModule>
abstract HasFSharpProjects: bool

/// True when any F# projects are currently known to project options provider after requesting info from FCS.
abstract HasFcsProjects: bool


type IFSharpScriptProjectOptionsProvider =
type IScriptFcsProjectProvider =
abstract GetScriptOptions: IPsiSourceFile -> FSharpProjectOptions option
abstract GetScriptOptions: FileSystemPath * string -> FSharpProjectOptions option


type IMonitoredReactorOperation =
inherit IDisposable
abstract OperationName : string


type IFcsReactorMonitor =
abstract MonitorOperation : opName: string -> IMonitoredReactorOperation
Loading