private bool TryGetConstructorInitializer( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ConstructorInitializerSyntax expression ) { if ( !CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression ) ) { return(false); } return(expression.ArgumentList != null); }
internal SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char?triggerCharacter = null) : this() { Contract.ThrowIfTrue(triggerReason == SignatureHelpTriggerReason.TypeCharCommand && triggerCharacter == null); this.TriggerReason = triggerReason; this.TriggerCharacter = triggerCharacter; }
internal SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char? triggerCharacter = null) : this() { Contract.ThrowIfTrue(triggerReason == SignatureHelpTriggerReason.TypeCharCommand && triggerCharacter == null); this.TriggerReason = triggerReason; this.TriggerCharacter = triggerCharacter; }
internal void MapsCorrectly(SignatureHelpTriggerReason triggerReason) { var actual = FSharpSignatureHelpTriggerReasonHelpers.ConvertFrom(triggerReason); var expected = GetExpectedTriggerReason(triggerReason); Assert.Equal(expected, actual); }
internal static FSharpSignatureHelpTriggerReason GetExpectedTriggerReason(SignatureHelpTriggerReason triggerReason) { switch (triggerReason) { case SignatureHelpTriggerReason.InvokeSignatureHelpCommand: { return(FSharpSignatureHelpTriggerReason.InvokeSignatureHelpCommand); } case SignatureHelpTriggerReason.RetriggerCommand: { return(FSharpSignatureHelpTriggerReason.RetriggerCommand); } case SignatureHelpTriggerReason.TypeCharCommand: { return(FSharpSignatureHelpTriggerReason.TypeCharCommand); } default: { throw ExceptionUtilities.UnexpectedValue(triggerReason); } } }
internal static bool TryGetSyntax( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax?identifier, out SyntaxToken openBrace ) { if ( CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out ElementAccessExpressionSyntax elementAccessExpression ) ) { identifier = elementAccessExpression.Expression; openBrace = elementAccessExpression.ArgumentList.OpenBracketToken; return(true); } identifier = null; openBrace = default; return(false); }
internal static bool TryGetSyntax( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax?identifier, out SyntaxToken openBrace ) { if ( CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out ArrayTypeSyntax arrayTypeSyntax ) ) { identifier = arrayTypeSyntax.ElementType; openBrace = arrayTypeSyntax.RankSpecifiers.First().OpenBracketToken; return(true); } identifier = null; openBrace = default; return(false); }
private bool TryGetAttributeExpression( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out AttributeSyntax attribute ) { if ( !CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out attribute ) ) { return(false); } return(attribute.ArgumentList != null); }
protected virtual bool TryGetGenericIdentifier( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out SyntaxToken genericIdentifier, out SyntaxToken lessThanToken ) { if ( CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out GenericNameSyntax name ) ) { genericIdentifier = name.Identifier; lessThanToken = name.TypeArgumentList.LessThanToken; return(true); } genericIdentifier = default; lessThanToken = default; return(false); }
private bool TryGetConstructorInitializer(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ConstructorInitializerSyntax expression) { if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression)) { return false; } return expression.ArgumentList != null; }
public SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char?triggerCharacter = null) { if (triggerReason == SignatureHelpTriggerReason.TypeCharCommand && triggerCharacter == null) { throw new ArgumentException(); } TriggerReason = triggerReason; TriggerCharacter = triggerCharacter; }
private bool TryGetAttributeExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out AttributeSyntax attribute) { if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out attribute)) { return false; } return attribute.ArgumentList != null; }
internal static bool TryGetSyntax <TSyntax>( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, Func <SyntaxToken, bool> isTriggerToken, Func <TSyntax, SyntaxToken, bool> isArgumentListToken, CancellationToken cancellationToken, out TSyntax expression ) where TSyntax : SyntaxNode { var token = syntaxFacts.FindTokenOnLeftOfPosition(root, position); if (triggerReason == SignatureHelpTriggerReason.TypeCharCommand) { if ( isTriggerToken(token) && !syntaxFacts.IsInNonUserCode(root.SyntaxTree, position, cancellationToken) ) { expression = token.GetAncestor <TSyntax>(); return(true); } } else if (triggerReason == SignatureHelpTriggerReason.InvokeSignatureHelpCommand) { expression = token.Parent ?.GetAncestorsOrThis <TSyntax>() .SkipWhile(syntax => !isArgumentListToken(syntax, token)) .FirstOrDefault(); return(expression != null); } else if (triggerReason == SignatureHelpTriggerReason.RetriggerCommand) { if ( !syntaxFacts.IsInNonUserCode(root.SyntaxTree, position, cancellationToken) || syntaxFacts.IsEntirelyWithinStringOrCharOrNumericLiteral( 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); }
internal static bool TryGetSyntax <TSyntax>( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, Func <SyntaxToken, bool> isTriggerToken, Func <TSyntax, SyntaxToken, bool> isArgumentListToken, CancellationToken cancellationToken, 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) { if (isTriggerToken(token)) { expression = token.GetAncestor <TSyntax>(); return(true); } } else if (triggerReason == SignatureHelpTriggerReason.InvokeSignatureHelpCommand) { expression = token.Parent.GetAncestorsOrThis <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; } }
static SIGHLP.SignatureHelpTriggerReason ToSignatureHelpTriggerReason(SignatureHelpTriggerReason triggerReason) { switch (triggerReason) { case SignatureHelpTriggerReason.InvokeSignatureHelpCommand: return(SIGHLP.SignatureHelpTriggerReason.InvokeSignatureHelpCommand); case SignatureHelpTriggerReason.TypeCharCommand: return(SIGHLP.SignatureHelpTriggerReason.TypeCharCommand); case SignatureHelpTriggerReason.RetriggerCommand: return(SIGHLP.SignatureHelpTriggerReason.RetriggerCommand); default: throw new ArgumentOutOfRangeException(nameof(triggerReason)); } }
protected override bool TryGetGenericIdentifier( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out SyntaxToken genericIdentifier, out SyntaxToken lessThanToken ) => root.SyntaxTree.IsInPartiallyWrittenGeneric( position, cancellationToken, out genericIdentifier, out lessThanToken );
protected virtual bool TryGetGenericIdentifier( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out SyntaxToken genericIdentifier, out SyntaxToken lessThanToken) { if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out GenericNameSyntax name)) { genericIdentifier = name.Identifier; lessThanToken = name.TypeArgumentList.LessThanToken; return true; } genericIdentifier = default(SyntaxToken); lessThanToken = default(SyntaxToken); return false; }
internal static bool TryGetSyntax( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax?identifier, out SyntaxToken openBrace ) { if ( CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out ElementBindingExpressionSyntax elementBindingExpression ) ) { // Find the first conditional access expression that starts left of our open bracket var conditionalAccess = elementBindingExpression.FirstAncestorOrSelf < ConditionalAccessExpressionSyntax, ElementBindingExpressionSyntax >( (c, elementBindingExpression) => c.SpanStart < elementBindingExpression.SpanStart, elementBindingExpression ) !; identifier = conditionalAccess.Expression; openBrace = elementBindingExpression.ArgumentList.OpenBracketToken; return(true); } identifier = null; openBrace = default; return(false); }
private bool TryGetInitializerExpression( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out InitializerExpressionSyntax expression ) => CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTriggerToken, IsInitializerExpressionToken, cancellationToken, out expression ) && expression != null;
private bool TryGetTupleExpression( SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, CancellationToken cancellationToken, [NotNullWhen(true)] out TupleExpressionSyntax?tupleExpression ) { return(CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsTupleExpressionTriggerToken, IsTupleArgumentListToken, cancellationToken, out tupleExpression )); }
private bool TryGetParenthesizedExpression( SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, CancellationToken cancellationToken, [NotNullWhen(true)] out ParenthesizedExpressionSyntax?parenthesizedExpression ) { return(CommonSignatureHelpUtilities.TryGetSyntax( root, position, syntaxFacts, triggerReason, IsParenthesizedExpressionTriggerToken, IsParenthesizedExpressionToken, cancellationToken, out parenthesizedExpression )); }
private static bool TryGetElementAccessExpression( SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax?identifier, out SyntaxToken openBrace ) { return(CompleteElementAccessExpression.TryGetSyntax( root, position, syntaxFacts, triggerReason, cancellationToken, out identifier, out openBrace ) || IncompleteElementAccessExpression.TryGetSyntax( root, position, syntaxFacts, triggerReason, cancellationToken, out identifier, out openBrace ) || ConditionalAccessExpression.TryGetSyntax( root, position, syntaxFacts, triggerReason, cancellationToken, out identifier, out openBrace )); }
private static bool TryGetElementAccessExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ExpressionSyntax identifier, out SyntaxToken openBrace) { return CompleteElementAccessExpression.TryGetSyntax(root, position, syntaxFacts, triggerReason, cancellationToken, out identifier, out openBrace) || IncompleteElementAccessExpression.TryGetSyntax(root, position, syntaxFacts, triggerReason, cancellationToken, out identifier, out openBrace); }
internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ExpressionSyntax identifier, out SyntaxToken openBrace) { ArrayTypeSyntax arrayTypeSyntax; if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out arrayTypeSyntax)) { identifier = arrayTypeSyntax.ElementType; openBrace = arrayTypeSyntax.RankSpecifiers.First().OpenBracketToken; return true; } identifier = null; openBrace = default(SyntaxToken); return false; }
internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ExpressionSyntax identifier, out SyntaxToken openBrace) { ElementAccessExpressionSyntax elementAccessExpression; if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out elementAccessExpression)) { identifier = elementAccessExpression.Expression; openBrace = elementAccessExpression.ArgumentList.OpenBracketToken; return true; } identifier = null; openBrace = default(SyntaxToken); return false; }
public SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char? triggerCharacter = null) { if (triggerReason == SignatureHelpTriggerReason.TypeCharCommand && triggerCharacter == null) throw new ArgumentException(); TriggerReason = triggerReason; TriggerCharacter = triggerCharacter; }
private bool TryGetParenthesizedExpression(SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, CancellationToken cancellationToken, out ParenthesizedExpressionSyntax parenthesizedExpression) { return CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsParenthesizedExpressionTriggerToken, IsParenthesizedExpressionToken, cancellationToken, out parenthesizedExpression); }
private bool TryGetTupleExpression(SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, CancellationToken cancellationToken, out TupleExpressionSyntax tupleExpression) { return CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTupleExpressionTriggerToken, IsTupleArgumentListToken, cancellationToken, out tupleExpression); }
internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ExpressionSyntax identifier, out SyntaxToken openBrace) { ElementBindingExpressionSyntax elementBindingExpression; if (CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out elementBindingExpression)) { identifier = ((ConditionalAccessExpressionSyntax)elementBindingExpression.Parent).Expression; openBrace = elementBindingExpression.ArgumentList.OpenBracketToken; return(true); } identifier = null; openBrace = default(SyntaxToken); return(false); }
static SIGHLP.SignatureHelpTriggerReason ToSignatureHelpTriggerReason(SignatureHelpTriggerReason triggerReason) { switch (triggerReason) { case SignatureHelpTriggerReason.InvokeSignatureHelpCommand: return SIGHLP.SignatureHelpTriggerReason.InvokeSignatureHelpCommand; case SignatureHelpTriggerReason.TypeCharCommand: return SIGHLP.SignatureHelpTriggerReason.TypeCharCommand; case SignatureHelpTriggerReason.RetriggerCommand: return SIGHLP.SignatureHelpTriggerReason.RetriggerCommand; default: throw new ArgumentOutOfRangeException(nameof(triggerReason)); } }
private bool TryGetInvocationExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out InvocationExpressionSyntax expression) { if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression)) { return false; } return expression.ArgumentList != null; }
public SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char?triggerCharacter = null) { Inner = new Microsoft.CodeAnalysis.Editor.SignatureHelpTriggerInfo( (Microsoft.CodeAnalysis.Editor.SignatureHelpTriggerReason)triggerReason, triggerCharacter); }
public SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char?triggerCharacter = null) { TriggerReason = triggerReason; TriggerCharacter = triggerCharacter; }
public SignatureHelpTriggerInfo(SignatureHelpTriggerReason triggerReason, char? triggerCharacter = null) { Inner = new Microsoft.CodeAnalysis.Editor.SignatureHelpTriggerInfo( (Microsoft.CodeAnalysis.Editor.SignatureHelpTriggerReason)triggerReason, triggerCharacter); }
protected override bool TryGetGenericIdentifier(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out SyntaxToken genericIdentifier, out SyntaxToken lessThanToken) { return root.SyntaxTree.IsInPartiallyWrittenGeneric(position, cancellationToken, out genericIdentifier, out lessThanToken); }