// TODO: extension method public static bool IsCompleteOrInvalid(SourceCodeProperties props, bool allowIncompleteStatement) { return props == SourceCodeProperties.IsInvalid || props != SourceCodeProperties.IsIncompleteToken && (allowIncompleteStatement || props != SourceCodeProperties.IsIncompleteStatement); }
// TODO: extension method public static bool IsCompleteOrInvalid(SourceCodeProperties props, bool allowIncompleteStatement) { return (props == SourceCodeProperties.IsInvalid || props != SourceCodeProperties.IsIncompleteToken && (allowIncompleteStatement || props != SourceCodeProperties.IsIncompleteStatement)); }
/// <summary> /// Read a statement, which can potentially be a multiple-line statement suite (like a class declaration). /// </summary> /// <param name="continueInteraction">Should the console session continue, or did the user indicate /// that it should be terminated?</param> /// <returns>Expression to evaluate. null for empty input</returns> public string ReadStatement(out bool continueInteraction) { StringBuilder b = new StringBuilder(); int autoIndentSize = 0; if (!LanguageProvider.InputRedirected) { _console.Write(Prompt, Style.Prompt); } while (true) { string line = ReadLine(autoIndentSize); continueInteraction = true; if (line == null) { continueInteraction = false; return(null); } bool allowIncompleteStatement = TreatAsBlankLine(line, autoIndentSize); b.Append(line); b.Append("\n"); string code = b.ToString(); SourceCodeProperties props = _engine.GetCodeProperties(code, SourceCodeKind.InteractiveCode); if (SourceCodePropertiesUtils.IsCompleteOrInvalid(props, allowIncompleteStatement)) { return(props != SourceCodeProperties.IsEmpty ? code : null); } if (_options.AutoIndent && _options.AutoIndentSize != 0) { autoIndentSize = GetNextAutoIndentSize(code); } if (!LanguageProvider.InputRedirected) { // Keep on reading input _console.Write(PromptContinuation, Style.Prompt); } } }