Skip to content
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

Initial generation signature feature toggle. #481

Draft
wants to merge 76 commits into
base: net232
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
1dcd7f3
Initial generation signature feature toggle.
nojaf Feb 13, 2023
dcecc1b
After pair programming session.
nojaf Feb 14, 2023
932adba
Open signature file after generation.
nojaf Feb 15, 2023
9cbf0da
Right after pair programming session.
nojaf Feb 28, 2023
90ccfad
Refactor TypeDeclarationGroup grouping. Take care of the and keyword.
nojaf Mar 1, 2023
1472686
Migrate code to FSharpGenerateSignatureProvider
nojaf Apr 3, 2023
e30febe
Queue the project model transaction after the psi transaction
auduchinok Apr 19, 2023
8e167d0
Use existing text control lifetime
auduchinok Apr 19, 2023
4539663
Add namespace test.
nojaf Apr 19, 2023
39733c3
Remove old tests file.
nojaf Apr 19, 2023
b6e573a
Add _.fsi test.
nojaf Apr 20, 2023
0258529
Add initial unit tests.
nojaf Apr 20, 2023
ae3d794
add test 01 for recursive types
dawedawe Apr 20, 2023
e5f5898
add test for record with static member
dawedawe Apr 24, 2023
90e700e
add test for union with static member
dawedawe Apr 24, 2023
4de6d35
Add test for instance member.
nojaf Apr 26, 2023
e4946ff
add test for instance member with optional parameter
dawedawe Apr 27, 2023
f5f677b
start supporting structs, we might handle it as IObjectModelTypeRepre…
dawedawe Apr 27, 2023
d59037c
start supporting signature generation for ILetBindingsDeclaration
dawedawe May 2, 2023
8665b3f
remove superfluous indentation
dawedawe May 2, 2023
d9fe302
Use "\n" instead of System.Environment.NewLine
dawedawe May 2, 2023
a181292
Add basic exception.
nojaf May 8, 2023
acde246
Add members to exceptions.
nojaf May 8, 2023
91bf31b
Add support for delegates.
nojaf May 8, 2023
ee4dd8c
Implicit unit constructor.
nojaf May 8, 2023
3fde6ee
Implicit constructor with parameters.
nojaf May 8, 2023
4778cc4
Reuse lineEnding
nojaf May 8, 2023
5222573
Filter out IExceptionFieldDeclaration for IExceptionDeclaration.
nojaf May 8, 2023
78cf4fb
Remove invalid comment.
nojaf May 8, 2023
a3339fa
Remove redundant unit pat check in createPrimaryConstructorSignature.
nojaf May 8, 2023
7e2bf99
Don't show workflow item is setting is not enabled.
nojaf May 8, 2023
e676130
Use TypeMembers for IExceptionDeclaration.
nojaf May 8, 2023
60e73bc
Small fixes after rebase.
nojaf May 8, 2023
c97a42e
Support attributes on module members
dawedawe May 9, 2023
6f9fffc
Add attribute with parameter for test
dawedawe May 10, 2023
ec038a2
Use GetText() to get original attributes from impl file.
dawedawe May 10, 2023
2bf881c
WIP, add attributes and xml comments
dawedawe May 13, 2023
1defbf4
refactor to not add whitespace before node to indent
dawedawe May 13, 2023
b5d33d2
cleanup
dawedawe May 13, 2023
83321e4
Initial generation signature feature toggle.
nojaf Feb 13, 2023
db546ce
After pair programming session.
nojaf Feb 14, 2023
7bb4e8b
Open signature file after generation.
nojaf Feb 15, 2023
7bf8314
Right after pair programming session.
nojaf Feb 28, 2023
1888eaa
Refactor TypeDeclarationGroup grouping. Take care of the and keyword.
nojaf Mar 1, 2023
2981c92
Migrate code to FSharpGenerateSignatureProvider
nojaf Apr 3, 2023
3f9c3d3
Queue the project model transaction after the psi transaction
auduchinok Apr 19, 2023
355b36e
Use existing text control lifetime
auduchinok Apr 19, 2023
f9d5919
Add namespace test.
nojaf Apr 19, 2023
501058e
Remove old tests file.
nojaf Apr 19, 2023
6aa2c4e
Add _.fsi test.
nojaf Apr 20, 2023
4c82a24
Add initial unit tests.
nojaf Apr 20, 2023
c9e864c
add test 01 for recursive types
dawedawe Apr 20, 2023
bc9797b
add test for record with static member
dawedawe Apr 24, 2023
d9d21c7
add test for union with static member
dawedawe Apr 24, 2023
f7e3638
Add test for instance member.
nojaf Apr 26, 2023
d4d33aa
add test for instance member with optional parameter
dawedawe Apr 27, 2023
7429d6d
start supporting structs, we might handle it as IObjectModelTypeRepre…
dawedawe Apr 27, 2023
f1cb32e
start supporting signature generation for ILetBindingsDeclaration
dawedawe May 2, 2023
c487f06
remove superfluous indentation
dawedawe May 2, 2023
30f8bb4
Use "\n" instead of System.Environment.NewLine
dawedawe May 2, 2023
a73a6db
Add basic exception.
nojaf May 8, 2023
1d3699d
Add members to exceptions.
nojaf May 8, 2023
1f388e7
Add support for delegates.
nojaf May 8, 2023
f662765
Implicit unit constructor.
nojaf May 8, 2023
62a8938
Implicit constructor with parameters.
nojaf May 8, 2023
0fac3aa
Reuse lineEnding
nojaf May 8, 2023
86f4a93
Filter out IExceptionFieldDeclaration for IExceptionDeclaration.
nojaf May 8, 2023
335bf48
Remove invalid comment.
nojaf May 8, 2023
a7833ab
Remove redundant unit pat check in createPrimaryConstructorSignature.
nojaf May 8, 2023
40d85a8
Don't show workflow item is setting is not enabled.
nojaf May 8, 2023
877ab51
Use TypeMembers for IExceptionDeclaration.
nojaf May 8, 2023
b3d2de7
Small fixes after rebase.
nojaf May 8, 2023
da1180f
Support attributes on module members
dawedawe May 9, 2023
9713991
Add attribute with parameter for test
dawedawe May 10, 2023
de6092e
Use GetText() to get original attributes from impl file.
dawedawe May 10, 2023
f93cdc0
Merge remote-tracking branch 'nojaf/generate-signature-two' into pr/481
dawedawe May 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module FSharpExperimentalFeatures =
let [<Literal>] outOfProcessTypeProviders = "Host type providers out-of-process"
let [<Literal>] generativeTypeProvidersInMemoryAnalysis = "Enable generative type providers analysis in C#/VB.NET projects"
let [<Literal>] tryRecoverFcsProjects = "Try to reuse FCS results on project changes"

let [<Literal>] generateSignatureFile = "Generate signature file"

[<SettingsKey(typeof<FSharpOptions>, "F# experimental features")>]
type FSharpExperimentalFeatures =
Expand All @@ -109,8 +109,10 @@ type FSharpExperimentalFeatures =
mutable GenerativeTypeProvidersInMemoryAnalysis: bool

[<SettingsEntry(false, FSharpExperimentalFeatures.tryRecoverFcsProjects); DefaultValue>]
mutable TryRecoverFcsProjects: bool }
mutable TryRecoverFcsProjects: bool

[<SettingsEntry(false, FSharpExperimentalFeatures.generateSignatureFile); DefaultValue>]
mutable GenerateSignatureFile: bool }

[<AllowNullLiteral>]
type FSharpSettingsProviderBase<'T>(lifetime: Lifetime, settings: IContextBoundSettingsStoreLive,
Expand Down Expand Up @@ -146,6 +148,7 @@ type FSharpExperimentalFeaturesProvider(lifetime, solution, settings, settingsSc
member val OutOfProcessTypeProviders = base.GetValueProperty<bool>("OutOfProcessTypeProviders")
member val GenerativeTypeProvidersInMemoryAnalysis = base.GetValueProperty<bool>("GenerativeTypeProvidersInMemoryAnalysis")
member val TryRecoverFcsProjects = base.GetValueProperty<bool>("TryRecoverFcsProjects")
member val GenerateSignatureFile = base.GetValueProperty<bool>("GenerateSignatureFile")


[<SolutionInstanceComponent>]
Expand Down Expand Up @@ -220,6 +223,7 @@ type FSharpOptionsPage(lifetime: Lifetime, optionsPageContext, settings,
this.AddBoolOption((fun key -> key.PostfixTemplates), RichText(FSharpExperimentalFeatures.postfixTemplates), null) |> ignore
this.AddBoolOption((fun key -> key.RedundantParensAnalysis), RichText(FSharpExperimentalFeatures.redundantParenAnalysis), null) |> ignore
this.AddBoolOption((fun key -> key.Formatter), RichText(FSharpExperimentalFeatures.formatter), null) |> ignore
this.AddBoolOption((fun key -> key.GenerateSignatureFile), RichText(FSharpExperimentalFeatures.generateSignatureFile)) |> ignore


[<ShellComponent>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ExperimentalFeature =
| RedundantParenAnalysis = 3
| AssemblyReaderShim = 4
| TryRecoverFcsProjects = 5
| GenerateSignatureFile = 6

type FSharpExperimentalFeatureCookie(feature: ExperimentalFeature) =
static let cookies = OneToListMap<ExperimentalFeature, IDisposable>()
Expand Down Expand Up @@ -45,6 +46,7 @@ type FSharpExperimentalFeatures() =
| ExperimentalFeature.PostfixTemplates -> experimentalFeatures.EnablePostfixTemplates.Value
| ExperimentalFeature.RedundantParenAnalysis -> experimentalFeatures.RedundantParensAnalysis.Value
| ExperimentalFeature.TryRecoverFcsProjects -> experimentalFeatures.TryRecoverFcsProjects.Value
| ExperimentalFeature.GenerateSignatureFile -> experimentalFeatures.GenerateSignatureFile.Value
| _ -> failwith $"Unexpected feature: {feature}"

[<Extension>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ type FSharpImplTreeBuilder(lexer, document, decls, lifetime, path, projectedOffs
let (SynModuleOrNamespace(lid, _, moduleKind, decls, XmlDoc xmlDoc, attrs, _, range, _)) = moduleOrNamespace
let mark, elementType = x.StartTopLevelDeclaration(lid, attrs, moduleKind, xmlDoc, range)
for decl in decls do
x.ProcessModuleMemberDeclaration(decl)
x.ProcessModuleMemberDeclaration(decl, moduleOrNamespace.Range)
x.EnsureMembersAreFinished()
x.FinishTopLevelDeclaration(mark, range, elementType)

member x.ProcessModuleMemberDeclaration(moduleMember) =
member x.ProcessModuleMemberDeclaration(moduleMember, parentRange) =
match unfinishedDeclaration with
| None -> ()
| Some(mark, range, elementType) ->
Expand All @@ -53,7 +53,12 @@ type FSharpImplTreeBuilder(lexer, document, decls, lifetime, path, projectedOffs
| SynModuleDecl.NestedModule(SynComponentInfo(attrs, _, _, _, XmlDoc xmlDoc, _, _, _), _, decls, _, range, _) ->
let mark = x.MarkAndProcessIntro(attrs, xmlDoc, null, range)
for decl in decls do
x.ProcessModuleMemberDeclaration(decl)
x.ProcessModuleMemberDeclaration(decl, parentRange)

if decls.IsEmpty then
x.AdvanceToTokenOrRangeEnd(FSharpTokenType.END, parentRange)
x.Advance()

x.Done(range, mark, ElementType.NESTED_MODULE_DECLARATION)

| SynModuleDecl.Types(typeDefns, range) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type FSharpParser(lexer: ILexer, document: IDocument, path: VirtualFileSystemPat
ResolvedSymbolsCache = symbolsCache,
LanguageType = language)

static member val SandBoxPath = VirtualFileSystemPath.Parse("Sandbox.fs", InteractionContext.SolutionContext)
static member val SandBoxSignaturePath = VirtualFileSystemPath.Parse("Sandbox.fsi", InteractionContext.SolutionContext)

new (lexer, [<NotNull>] sourceFile: IPsiSourceFile, checkerService, symbolsCache) =
// During rename of type + file the source file returns the new path,
// but the parsing/project options still have the old one. It doesn't seem to affect anything.
Expand All @@ -75,9 +78,6 @@ type FSharpParser(lexer: ILexer, document: IDocument, path: VirtualFileSystemPat

FSharpParser(lexer, document, path, sourceFile, checkerService, symbolsCache)

static member val SandBoxPath = VirtualFileSystemPath.Parse("Sandbox.fs", InteractionContext.SolutionContext)
static member val SandBoxSignaturePath = VirtualFileSystemPath.Parse("Sandbox.fsi", InteractionContext.SolutionContext)

interface IFSharpParser with
member this.ParseFSharpFile(noCache) = parseFile noCache
member this.ParseFile() = parseFile false :> _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Compile Include="src\Generate\FSharpGeneratorContext.fs" />
<Compile Include="src\Generate\GenerateOverrides.fs" />
<Compile Include="src\Generate\GenerateProvider.fs" />
<Compile Include="src\Generate\GenerateSignatureProvider.fs" />
<Compile Include="src\Refactorings\Rename.fs" />
<Compile Include="src\Refactorings\IntroduceVariable.fs" />
<Compile Include="src\Refactorings\FSharpInlineVariable.fs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type FSharpGeneratorContext(kind, [<NotNull>] treeNode: ITreeNode, [<CanBeNull>]

override x.Language = FSharpLanguage.Instance :> _

override x.Root = typeDecl :> _
override x.Root = treeNode
override val Anchor = null with get, set

override x.PsiModule = treeNode.GetPsiModule()
Expand Down
Loading