public static bool CanRefactor(AccessorDeclarationSyntax accessorDeclaration, TextSpan?span = null) { BlockSyntax body = accessorDeclaration.Body; return(body != null && (span?.IsEmptyAndContainedInSpanOrBetweenSpans(accessorDeclaration) != false || span.Value.IsEmptyAndContainedInSpanOrBetweenSpans(body)) && !accessorDeclaration.AttributeLists.Any() && BlockExpressionAnalysis.SupportsExpressionBody(body, allowExpressionStatement: !accessorDeclaration.IsKind(SyntaxKind.GetAccessorDeclaration)) && (accessorDeclaration.Parent as AccessorListSyntax)? .Accessors .SingleOrDefault(shouldThrow: false)? .Kind() != SyntaxKind.GetAccessorDeclaration); }
public static bool CanRefactor(PropertyDeclarationSyntax propertyDeclaration, TextSpan?span = null) { AccessorListSyntax accessorList = propertyDeclaration.AccessorList; if (accessorList != null && span?.IsEmptyAndContainedInSpanOrBetweenSpans(accessorList) != false) { AccessorDeclarationSyntax accessor = propertyDeclaration .AccessorList? .Accessors .SingleOrDefault(shouldThrow: false); if (accessor?.AttributeLists.Any() == false && accessor.IsKind(SyntaxKind.GetAccessorDeclaration) && accessor.Body != null && BlockExpressionAnalysis.SupportsExpressionBody(accessor.Body, allowExpressionStatement: false)) { return(true); } } return(false); }
public static bool CanRefactor(ConversionOperatorDeclarationSyntax operatorDeclaration, TextSpan?span = null) { return(operatorDeclaration.Body != null && span?.IsEmptyAndContainedInSpanOrBetweenSpans(operatorDeclaration.Body) != false && BlockExpressionAnalysis.SupportsExpressionBody(operatorDeclaration.Body, allowExpressionStatement: false)); }
public static bool CanRefactor(MethodDeclarationSyntax methodDeclaration, TextSpan?span = null) { return(methodDeclaration.Body != null && span?.IsEmptyAndContainedInSpanOrBetweenSpans(methodDeclaration.Body) != false && BlockExpressionAnalysis.SupportsExpressionBody(methodDeclaration.Body)); }
public static bool CanRefactor(LocalFunctionStatementSyntax localFunctionStatement, TextSpan?span = null) { return(localFunctionStatement.Body != null && span?.IsEmptyAndContainedInSpanOrBetweenSpans(localFunctionStatement.Body) != false && BlockExpressionAnalysis.SupportsExpressionBody(localFunctionStatement.Body)); }