зеркало из https://github.com/microsoft/Power-Fx.git
Fix: Null Handling in NodeKind Intellisense (#2552)
CurNode in IntellisenseData can be Null in different scenarios and we have a NullNodeIntellisense Handler for this specific reason which suggests global/ in scope Values , However this may not be applicable to all the cases such as suggesting types for UDF. Not handling null here forces us to have a very strict order in running intellisense handlers , otherwise raising an exception which leads to no Intellisense results. It is safe for us to assume CurNode could be null and skip the current suggestion handler instead of throwing an exception.
This commit is contained in:
Родитель
d585995527
Коммит
bc081425a1
|
@ -32,8 +32,8 @@ namespace Microsoft.PowerFx.Intellisense.IntellisenseData
|
|||
{
|
||||
Contracts.AssertValue(context);
|
||||
Contracts.AssertValid(expectedType);
|
||||
Contracts.AssertValue(binding);
|
||||
Contracts.AssertValue(curNode);
|
||||
Contracts.AssertValueOrNull(binding);
|
||||
Contracts.AssertValueOrNull(curNode);
|
||||
Contracts.Assert(context.CursorPosition >= 0 && context.CursorPosition <= context.InputText.Length);
|
||||
Contracts.AssertValue(isValidSuggestionFunc);
|
||||
Contracts.AssertValueOrNull(missingTypes);
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
// For Error Kind, suggest top level values only in the context of a callNode and
|
||||
// ThisItemProperties only in the context of thisItem.
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -24,9 +24,9 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
public bool Run(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
Contracts.AssertValueOrNull(intellisenseData.CurNode);
|
||||
|
||||
if (intellisenseData.CurNode.Kind != _kind)
|
||||
if (intellisenseData.CurNode == null || intellisenseData.CurNode.Kind != _kind)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Microsoft.PowerFx.Intellisense
|
|||
internal override bool TryAddSuggestionsForNodeKind(IntellisenseData.IntellisenseData intellisenseData)
|
||||
{
|
||||
Contracts.AssertValue(intellisenseData);
|
||||
Contracts.AssertValue(intellisenseData.CurNode);
|
||||
|
||||
var curNode = intellisenseData.CurNode;
|
||||
var cursorPos = intellisenseData.CursorPos;
|
||||
|
|
Загрузка…
Ссылка в новой задаче