-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Namedtype suggestions for Type arguments in IntelliSense (#2625)
Adds Namedtype suggestions for Type arguments in functions that accept type (ParseJSON, IsType, AsType). Suggestion handler for TypeLiteralNode is currently in PAclient and will be moved to this repo in a follow up PR.
- Loading branch information
1 parent
d6aa0dd
commit 3c7c076
Showing
8 changed files
with
151 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
39 changes: 39 additions & 0 deletions
39
...owerFx.Core/Texl/Intellisense/SuggestionHandlers/CleanupHandlers/TypeArgCleanUpHandler.cs
This file contains 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,39 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.PowerFx.Core.Utils; | ||
using Microsoft.PowerFx.Intellisense; | ||
using Microsoft.PowerFx.Intellisense.IntellisenseData; | ||
|
||
namespace Microsoft.PowerFx.Core.Texl.Intellisense.SuggestionHandlers.CleanupHandlers | ||
{ | ||
// Power Fx Intellisense uses clean-up handlers to filter any unnecessary intellisense data that is added as a part of default logic. | ||
// For Type arguments, we do not want to suggest suggestions other than SuggestionKind.Type as they are not relevant. | ||
// This handler is added to Intellisense.CleanupHandlers when only type suggestions are expected in the output. | ||
internal sealed class TypeArgCleanUpHandler : ISpecialCaseHandler | ||
{ | ||
public bool Run(IIntellisenseContext context, IntellisenseData intellisenseData, List<IntellisenseSuggestion> suggestions) | ||
{ | ||
Contracts.AssertValue(context); | ||
Contracts.AssertValue(suggestions); | ||
Contracts.AssertValue(intellisenseData.CurFunc); | ||
Contracts.Assert(intellisenseData.CurFunc.ArgIsType(intellisenseData.ArgIndex)); | ||
|
||
var removedAny = false; | ||
|
||
var iterateSuggestions = suggestions.ToArray(); | ||
|
||
foreach (var suggestion in iterateSuggestions) | ||
{ | ||
if (suggestion.Kind != SuggestionKind.Type) | ||
{ | ||
suggestions.Remove(suggestion); | ||
removedAny = true; | ||
} | ||
} | ||
|
||
return removedAny; | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -19,5 +19,6 @@ public enum SuggestionKind | |
ServiceFunctionOption, | ||
Service, | ||
ScopeVariable, | ||
Type, | ||
} | ||
} |
This file contains 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 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