private static Boolean SelectIsValid(ParsingContext xoContext) { // Break early if (xoContext.CurrentNode == null || xoContext.CurrentNode.Count == 0) { return(false); } // Check Children are valid SyntaxNode oColumnList = xoContext.CurrentNode.FindFirst(SyntaxKind.ColumnListNode); // 0. Cant have an empty column list if (oColumnList == null || oColumnList.Count == 0) { // FAIL return(false); } // 1. If we found an identifier if (oColumnList.Exists( (oNode) => SyntaxKindFacts.IsIdentifier(oNode.ExpectedType) )) { // Does the select node have a from? if (xoContext.CurrentNode.FindFirst(SyntaxKind.FromKeyword) == null) { // FAIL return(false); } } // 2. if we find an aggregate function if (oColumnList.Exists((oNode) => SyntaxKindFacts.IsAggregateFunction(oNode.ExpectedType) )) { // Do we have a Group By and is it correct? if (xoContext.CurrentNode.FindFirst(SyntaxKind.GroupByKeyword) == null) { // fail return(false); } } // default to true return(true); }