Skip to content
Merged
Changes from all commits
Commits
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 @@ -113,46 +113,36 @@ internal static bool TryGetSyntax<TSyntax>(
out TSyntax expression)
where TSyntax : SyntaxNode
{
// Bug 1100661 reports an NRE from this method, but no manual repro has been found. To aid in debugging,
// any NRE thrown from here will generate a dump via FatalError.Report() below. try/catch was added 1/2/2015
// and is expected to be removed by 4/1/2015. --brettfo
try
var token = syntaxFacts.FindTokenOnLeftOfPosition(root, position);
if (triggerReason == SignatureHelpTriggerReason.TypeCharCommand)
{
var token = syntaxFacts.FindTokenOnLeftOfPosition(root, position);
if (triggerReason == SignatureHelpTriggerReason.TypeCharCommand)
if (isTriggerToken(token))
{
if (isTriggerToken(token))
{
expression = token.GetAncestor<TSyntax>();
return true;
}
expression = token.GetAncestor<TSyntax>();
return true;
}
else if (triggerReason == SignatureHelpTriggerReason.InvokeSignatureHelpCommand)
}
else if (triggerReason == SignatureHelpTriggerReason.InvokeSignatureHelpCommand)
{
expression = token.Parent?.GetAncestorsOrThis<TSyntax>().SkipWhile(syntax => !isArgumentListToken(syntax, token)).FirstOrDefault();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The true diff is adding the conditional access on this line token.Parent?.GetAncestorsOrThis and on one line below.

return expression != null;
}
else if (triggerReason == SignatureHelpTriggerReason.RetriggerCommand)
{
if (!syntaxFacts.IsInNonUserCode(root.SyntaxTree, position, cancellationToken) ||
syntaxFacts.IsEntirelyWithinStringOrCharLiteral(root.SyntaxTree, position, cancellationToken))
{
expression = token.Parent.GetAncestorsOrThis<TSyntax>().SkipWhile(syntax => !isArgumentListToken(syntax, token)).FirstOrDefault();
expression = token.Parent?.AncestorsAndSelf()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The true diff is adding the conditional access on this line token.Parent?.AncestorsAndSelf and on one line above.

.TakeWhile(n => !syntaxFacts.IsAnonymousFunction(n))
.OfType<TSyntax>()
.SkipWhile(syntax => !isArgumentListToken(syntax, token))
.FirstOrDefault();
return expression != null;
}
else if (triggerReason == SignatureHelpTriggerReason.RetriggerCommand)
{
if (!syntaxFacts.IsInNonUserCode(root.SyntaxTree, position, cancellationToken) ||
syntaxFacts.IsEntirelyWithinStringOrCharLiteral(root.SyntaxTree, position, cancellationToken))
{
expression = token.Parent.AncestorsAndSelf()
.TakeWhile(n => !syntaxFacts.IsAnonymousFunction(n))
.OfType<TSyntax>()
.SkipWhile(syntax => !isArgumentListToken(syntax, token))
.FirstOrDefault();
return expression != null;
}
}

expression = null;
return false;
}
catch (NullReferenceException e) when (FatalError.Report(e))
{
throw ExceptionUtilities.Unreachable;
}

expression = null;
return false;
}
}
}