public static Task <Document> RefactorAsync( Document document, ThrowExpressionSyntax throwExpression, CancellationToken cancellationToken) { return(RefactorAsync(document, throwExpression, throwExpression.Expression, cancellationToken)); }
private Doc PrintThrowExpressionSyntax(ThrowExpressionSyntax node) { return(Concat( this.PrintSyntaxToken(node.ThrowKeyword, " "), this.Print(node.Expression) )); }
public static Doc Print(ThrowExpressionSyntax node) { return(Doc.Concat( Token.PrintWithSuffix(node.ThrowKeyword, " "), Node.Print(node.Expression) )); }
public override void VisitThrowExpression(ThrowExpressionSyntax throwExpression) { bool isReported = CheckThrowExpression(throwExpression.Expression, throwExpression); if (!isReported) { base.VisitThrowExpression(throwExpression); } }
public static async Task ComputeRefactoringAsync(RefactoringContext context, ThrowExpressionSyntax throwExpression) { ExpressionSyntax expression = throwExpression.Expression; if (expression?.IsMissing == false && context.Span.IsContainedInSpanOrBetweenSpans(throwExpression)) { await ComputeRefactoringAsync(context, throwExpression, expression).ConfigureAwait(false); } }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { if (!PreVisit(node)) { return; } node.Expression?.Accept(this); base.VisitThrowExpression(node); PostVisit(node); }
public override void VisitThrowExpression(ThrowExpressionSyntax throwExpression) { ThrowIfCancellationRequested(); if (IsPXSetupNotEnteredException(throwExpression.Expression)) { ReportDiagnostic(_context.ReportDiagnostic, _descriptor, throwExpression); } else { base.VisitThrowExpression(throwExpression); } }
public static AddExceptionToDocumentationCommentAnalysis Analyze( ThrowExpressionSyntax throwExpression, SemanticModel semanticModel, CancellationToken cancellationToken) { ExpressionSyntax expression = throwExpression.Expression; if (expression?.IsMissing == false) { return(Analyze(throwExpression, expression, semanticModel, cancellationToken)); } else { return(AddExceptionToDocumentationCommentAnalysis.NoSuccess); } }
public static AddExceptionToDocumentationCommentAnalysisResult Analyze( ThrowExpressionSyntax throwExpression, INamedTypeSymbol exceptionSymbol, SemanticModel semanticModel, CancellationToken cancellationToken) { ExpressionSyntax expression = throwExpression.Expression; if (expression?.IsMissing == false) { return(Analyze(throwExpression, expression, exceptionSymbol, semanticModel, cancellationToken)); } else { return(Fail); } }
public bool IsArgumentException(SyntaxNodeAnalysisContext context, SyntaxNode syntaxNode) { var exceptionExpression = syntaxNode switch { ThrowStatementSyntax throwStatement => throwStatement.Expression, ThrowExpressionSyntax throwExpression => throwExpression.Expression, _ => null, }; if (exceptionExpression == null) { return(false); } var type = context.SemanticModel.GetTypeInfo(exceptionExpression, context.CancellationToken).Type; return(type != null && type.IsOrInheritFrom(_argumentSymbol)); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { base.VisitThrowExpression(node); ReportDiagnostic(AddDiagnostic, DiagnosticDescriptor, node); }
internal static void Analyze(SyntaxNodeAnalysisContext context, ThrowExpressionSyntax throwExpression) { Analyze(context, throwExpression.Expression); }
public override Evaluation VisitThrowExpression(ThrowExpressionSyntax node) { node.Expression?.Accept <Evaluation>(this); return(base.VisitThrowExpression(node)); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { throw new NotImplementedException(); }
/// <inheritdoc/> public override SyntaxNode?VisitThrowExpression(ThrowExpressionSyntax node) { Diagnostics.Add(ThrowExpressionOrStatement, node); return(base.VisitThrowExpression(node)); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { Log(node, "Unsupported Syntax !"); }
public static async Task ComputeRefactoringsAsync(RefactoringContext context, ThrowExpressionSyntax throwExpression) { if (context.IsRefactoringEnabled(RefactoringIdentifiers.AddExceptionToDocumentationComment) && context.Span.IsContainedInSpanOrBetweenSpans(throwExpression)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); INamedTypeSymbol exceptionSymbol = semanticModel.GetTypeByMetadataName(MetadataNames.System_Exception); AddExceptionToDocumentationCommentAnalysisResult analysis = AddExceptionToDocumentationCommentAnalysis.Analyze(throwExpression, exceptionSymbol, semanticModel, context.CancellationToken); if (analysis.Success) { context.RegisterRefactoring( "Add exception to documentation comment", cancellationToken => AddExceptionToDocumentationCommentRefactoring.RefactorAsync(context.Document, analysis, cancellationToken)); } } }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { this.throws.Add(node.ThrowKeyword); base.VisitThrowExpression(node); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { node.Expression?.Accept(this); base.VisitThrowExpression(node); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { this.VisitExpression(node); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { }
public override SyntaxNode VisitThrowExpression(ThrowExpressionSyntax node) { if (node.Parent is ExpressionStatementSyntax es && es.Expression == node || node.Parent is ThrowStatementSyntax) { return(base.VisitThrowExpression(node)); } var typeInfo = semanticModel.GetTypeInfo(node); node = (ThrowExpressionSyntax)base.VisitThrowExpression(node); if ((typeInfo.ConvertedType ?? typeInfo.Type) != null) { var type = typeInfo.ConvertedType ?? typeInfo.Type; var invocation = SyntaxFactory.InvocationExpression( SyntaxFactory.ParenthesizedExpression( SyntaxFactory.CastExpression( SyntaxFactory.QualifiedName( SyntaxFactory.IdentifierName(SYSTEM_IDENTIFIER), SyntaxFactory.GenericName( SyntaxFactory.Identifier(FUNC_IDENTIFIER)) .WithTypeArgumentList( SyntaxFactory.TypeArgumentList( SyntaxFactory.SingletonSeparatedList <TypeSyntax>( SyntaxFactory.ParseTypeName(type.ToMinimalDisplayString(semanticModel, node.GetLocation().SourceSpan.Start)) )) .WithLessThanToken( SyntaxFactory.Token(SyntaxKind.LessThanToken)) .WithGreaterThanToken( SyntaxFactory.Token(SyntaxKind.GreaterThanToken)))) .WithDotToken( SyntaxFactory.Token(SyntaxKind.DotToken)), SyntaxFactory.ParenthesizedExpression( SyntaxFactory.ParenthesizedLambdaExpression( SyntaxFactory.Block( SyntaxFactory.SingletonList <StatementSyntax>( SyntaxFactory.ThrowStatement(node.Expression) .WithThrowKeyword( SyntaxFactory.Token(SyntaxKind.ThrowKeyword)) .WithSemicolonToken( SyntaxFactory.Token(SyntaxKind.SemicolonToken)) .NormalizeWhitespace())) .WithOpenBraceToken( SyntaxFactory.Token(SyntaxKind.OpenBraceToken)) .WithCloseBraceToken( SyntaxFactory.Token(SyntaxKind.CloseBraceToken))) .WithParameterList( SyntaxFactory.ParameterList() .WithOpenParenToken( SyntaxFactory.Token(SyntaxKind.OpenParenToken)) .WithCloseParenToken( SyntaxFactory.Token(SyntaxKind.CloseParenToken))) .WithArrowToken( SyntaxFactory.Token(SyntaxKind.EqualsGreaterThanToken))) .WithOpenParenToken( SyntaxFactory.Token(SyntaxKind.OpenParenToken)) .WithCloseParenToken( SyntaxFactory.Token(SyntaxKind.CloseParenToken))) .WithOpenParenToken( SyntaxFactory.Token(SyntaxKind.OpenParenToken)) .WithCloseParenToken( SyntaxFactory.Token(SyntaxKind.CloseParenToken))) .WithOpenParenToken( SyntaxFactory.Token(SyntaxKind.OpenParenToken)) .WithCloseParenToken( SyntaxFactory.Token(SyntaxKind.CloseParenToken))) .WithArgumentList( SyntaxFactory.ArgumentList() .WithOpenParenToken( SyntaxFactory.Token(SyntaxKind.OpenParenToken)) .WithCloseParenToken( SyntaxFactory.Token(SyntaxKind.CloseParenToken))); return(invocation); } return(node); }
public override BoundNode VisitThrowExpression(ThrowExpressionSyntax node) { throw new System.NotSupportedException("UdonSharp does not support throwing exceptions since Udon does not have support for exception throwing at the moment"); }
public static void GoExpression(HaxeWriter writer, ThrowExpressionSyntax expr) { writer.Write("throw "); Core.Write(writer, expr.Expression); }
public override void VisitThrowExpression(ThrowExpressionSyntax node) { CanUseExceptionFilter = false; }
/// <inheritdoc/> public override void VisitThrowExpression(ThrowExpressionSyntax node) { this.throwStatementsAndExpressions.Add(node); base.VisitThrowExpression(node); }
/// <inheritdoc /> public override Expression VisitThrowExpression(ThrowExpressionSyntax node) { return(Expression.Throw(node.Expression.Accept(this))); }
public static async Task ComputeRefactoringsAsync(RefactoringContext context, ThrowExpressionSyntax throwExpression) { if (context.IsRefactoringEnabled(RefactoringDescriptors.AddExceptionElementToDocumentationComment) && context.Span.IsContainedInSpanOrBetweenSpans(throwExpression)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); AddExceptionToDocumentationCommentAnalysisResult analysis = AddExceptionToDocumentationCommentAnalysis.Analyze( throwExpression, semanticModel.GetTypeByMetadataName("System.Exception"), semanticModel, context.CancellationToken); if (analysis.Success) { context.RegisterRefactoring( "Add 'exception' element to documentation comment", ct => AddExceptionElementToDocumentationCommentRefactoring.RefactorAsync(context.Document, analysis, ct), RefactoringDescriptors.AddExceptionElementToDocumentationComment); } } }
internal ThrowExpressionInfo(ThrowExpressionSyntax node, ExpressionSyntax expression, ITypeSymbol exceptionSymbol) : base(node, expression, exceptionSymbol) { }
public static void WriteThrowExpression(ScalaWriter writer, ThrowExpressionSyntax syntax) { writer.Write("throw "); Core.Write(writer, syntax.Expression); }