public static bool TryCreate(SyntaxNode nodeWithStatements, out StatementContainer container) { if (nodeWithStatements == null) { throw new ArgumentNullException(nameof(nodeWithStatements)); } switch (nodeWithStatements.Kind()) { case SyntaxKind.Block: { container = new BlockStatementContainer((BlockSyntax)nodeWithStatements); return(true); } case SyntaxKind.SwitchSection: { container = new SwitchSectionStatementContainer((SwitchSectionSyntax)nodeWithStatements); return(true); } default: { container = null; return(false); } } }
public static StatementContainerSelection Create(SwitchSectionSyntax switchSection, TextSpan span) { if (switchSection == null) { throw new ArgumentNullException(nameof(switchSection)); } var container = new StatementContainer(switchSection); return(new StatementContainerSelection(container, span)); }
public static StatementContainerSelection Create(BlockSyntax block, TextSpan span) { if (block == null) { throw new ArgumentNullException(nameof(block)); } var container = new StatementContainer(block); return(new StatementContainerSelection(container, span)); }
public static StatementContainerSelection Create(SwitchSectionSyntax switchSection, TextSpan span) { if (switchSection == null) { throw new ArgumentNullException(nameof(switchSection)); } var container = new StatementContainer(switchSection); (int startIndex, int endIndex) = GetIndexes(container.Statements, span); return(new StatementContainerSelection(container, span, startIndex, endIndex)); }
public static StatementContainerSelection Create(BlockSyntax block, TextSpan span) { if (block == null) { throw new ArgumentNullException(nameof(block)); } var container = new StatementContainer(block); (int startIndex, int endIndex) = GetIndexes(container.Statements, span); return(new StatementContainerSelection(container, span, startIndex, endIndex)); }
public static bool TryCreate(SwitchSectionSyntax switchSection, TextSpan span, out StatementContainerSelection selectedStatements) { StatementContainer container; if (StatementContainer.TryCreate(switchSection, out container)) { return(TryCreate(container, span, out selectedStatements)); } else { selectedStatements = null; return(false); } }
public static bool TryCreate(StatementContainer container, TextSpan span, out StatementContainerSelection selectedStatements) { if (container.Statements.Any()) { IndexPair indexes = GetIndexes(container.Statements, span); if (indexes.StartIndex != -1) { selectedStatements = new StatementContainerSelection(container, span, indexes.StartIndex, indexes.EndIndex); return(true); } } selectedStatements = null; return(false); }
public static bool TryCreate(StatementSyntax statement, out StatementContainer container) { if (statement == null) { throw new ArgumentNullException(nameof(statement)); } SyntaxNode parent = statement.Parent; if (parent != null) { return(TryCreate(parent, out container)); } else { container = null; return(false); } }
public static bool TryCreate(StatementContainer container, TextSpan span, out StatementContainerSelection selection) { selection = null; SyntaxList <StatementSyntax> statements = container.Statements; if (!statements.Any()) { return(false); } (int startIndex, int endIndex) = GetIndexes(statements, span); if (startIndex == -1) { return(false); } selection = new StatementContainerSelection(container, span, startIndex, endIndex); return(true); }
private StatementContainerSelection(StatementContainer container, TextSpan span, int startIndex, int endIndex) : base(container.Statements, span, startIndex, endIndex) { Container = container; }
private StatementContainerSelection(StatementContainer container, TextSpan span) : base(container.Statements, span) { Container = container; }