-
Notifications
You must be signed in to change notification settings - Fork 56
Fully support argument matching #120
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7ed9f73
Fully support argument matching
saul 939e37f
Merge remote-tracking branch 'upstream/net202' into net202-arg-matching
saul 0f07629
Fix issues post merge
saul 83ee9ea
Add more tests
saul a28914b
Markups
saul c0a621a
Cache arguments on tree nodes
saul f944fa5
Named param recovery
saul 3cba158
Cache matching parameter on FSharpExpressionBase
saul 4af1694
Revert "Cache matching parameter on FSharpExpressionBase"
saul 2818642
Moved tests
saul ae476c2
Remove todo - no need to cache this
saul b72b7e3
Add tests for passing unit arguments
saul e29d5fe
Merge remote-tracking branch 'upstream/net202' into net202-arg-matching
saul 08b7381
Fix test compile error
saul c3036f3
Merge remote-tracking branch 'upstream/net202' into net202-arg-matching
saul bbe951a
Merge remote-tracking branch 'upstream/net202' into net202-arg-matching
saul cd271d9
Merge branch 'net202' into net202-arg-matching
saul bf9f988
Remove extra reference reported via prefix app expressions
auduchinok fbdfa6a
Remove ExpectErrors (moved to another PR), cleanup
auduchinok ec1c71f
Update occurrence kind test baselines
auduchinok 00c0cfc
Cleanup
auduchinok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 60 additions & 19 deletions
79
ReSharper.FSharp/src/FSharp.Psi.Features/src/Util/FSharpMethodInvocationUtil.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using JetBrains.ReSharper.Plugins.FSharp.Psi.Resolve; | ||
| using JetBrains.ReSharper.Plugins.FSharp.Psi.Tree; | ||
| using JetBrains.ReSharper.Psi.Tree; | ||
| using JetBrains.Util; | ||
|
|
||
| namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Impl.Tree | ||
| { | ||
| internal partial class NewExpr | ||
| { | ||
| public FSharpSymbolReference Reference { get; private set; } | ||
|
|
||
| protected override void PreInit() | ||
| { | ||
| base.PreInit(); | ||
| Reference = new CtorReference(this); | ||
| } | ||
|
|
||
| public IList<IArgument> Arguments | ||
| { | ||
| get | ||
| { | ||
| // todo: this is same as Attribute.Arguments | ||
| switch (ArgumentExpression.IgnoreInnerParens()) | ||
| { | ||
| case IUnitExpr _: | ||
| return EmptyList<IArgument>.Instance; | ||
| case ITupleExpr tupleExpr: | ||
| return tupleExpr.Expressions.Select(arg => arg as IArgument).ToList(); | ||
| case IArgument argExpr: | ||
| return new List<IArgument> { argExpr }; | ||
| default: | ||
| return EmptyList<IArgument>.Instance; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public IFSharpIdentifier FSharpIdentifier => TypeName?.Identifier; | ||
|
|
||
| public IFSharpReferenceOwner SetName(string name) | ||
| { | ||
| throw new System.NotImplementedException(); | ||
| } | ||
|
|
||
| public override ReferenceCollection GetFirstClassReferences() => | ||
| new ReferenceCollection(Reference); | ||
|
|
||
| public IList<IFSharpExpression> AppliedExpressions => new List<IFSharpExpression> {ArgumentExpression}; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ReSharper.FSharp/src/FSharp.Psi/src/Tree/FSharpArgumentsOwnerNavigator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using JetBrains.Annotations; | ||
|
|
||
| namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Tree | ||
| { | ||
| public class FSharpArgumentOwnerNavigator | ||
| { | ||
| public static IFSharpArgumentsOwner GetByArgumentExpression([CanBeNull] IFSharpExpression param) => | ||
| (IFSharpArgumentsOwner)AppLikeExprNavigator.GetByArgumentExpression(param) ?? | ||
| AttributeNavigator.GetByExpression(param); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Tree | ||
| { | ||
| public partial interface IAppLikeExpr : IFSharpArgumentsOwner | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Tree | ||
| { | ||
| public partial interface IAttribute : IFSharpReferenceOwner | ||
| public partial interface IAttribute : IFSharpArgumentsOwner | ||
| { | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
ReSharper.FSharp/src/FSharp.Psi/src/Tree/IFSharpArgumentsOwner.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
| using JetBrains.ReSharper.Psi.Tree; | ||
|
|
||
| namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Tree | ||
| { | ||
| public interface IFSharpArgumentsOwner : IArgumentsOwner, IFSharpReferenceOwner | ||
| { | ||
| IList<IFSharpExpression> AppliedExpressions { get; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| using System.Collections.Generic; | ||
| using System; | ||
| using JetBrains.Annotations; | ||
| using JetBrains.ReSharper.Plugins.FSharp.Psi.Resolve; | ||
| using JetBrains.ReSharper.Psi; | ||
| using JetBrains.ReSharper.Psi.Tree; | ||
|
|
||
| namespace JetBrains.ReSharper.Plugins.FSharp.Psi.Tree | ||
| { | ||
| public partial interface IPrefixAppExpr | ||
| { | ||
| [CanBeNull] IReferenceExpr InvokedReferenceExpression { get; } | ||
|
|
||
| [CanBeNull] FSharpSymbolReference InvokedFunctionReference { get; } | ||
| [NotNull] IList<IExpression> Arguments { get; } | ||
| } | ||
| } |
4 changes: 4 additions & 0 deletions
4
ReSharper.FSharp/test/data/parsing/arguments/Attribute 01 - Multiple args.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| open System.ComponentModel | ||
|
|
||
| [<{selstart}DefaultValue(typeof<string>, "hi"){selend}>] | ||
| let x = "" |
8 changes: 8 additions & 0 deletions
8
ReSharper.FSharp/test/data/parsing/arguments/Attribute 01 - Multiple args.gold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| open System.ComponentModel | ||
|
|
||
| [<DefaultValue(|typeof<string>|(arg #0), |"hi"|(arg #1))>] | ||
| let x = "" | ||
|
|
||
| --------------------------------------------------------- | ||
| (arg #0) => type | ||
| (arg #1) => value |
4 changes: 4 additions & 0 deletions
4
ReSharper.FSharp/test/data/parsing/arguments/Attribute 02 - Single arg - no parens.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| open System.ComponentModel | ||
|
|
||
| [<{selstart}Description "hi"{selend}>] | ||
| let x = "" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.