/// <summary> /// Creates a new CSharpIndentEngine instance. /// </summary> /// <param name="document"> /// An instance of <see cref="IDocument"/> which is being parsed. /// </param> /// <param name="formattingOptions"> /// C# formatting options. /// </param> /// <param name="textEditorOptions"> /// Text editor options for indentation. /// </param> public CSharpIndentEngine(IDocument document, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions) { this.formattingOptions = formattingOptions; this.textEditorOptions = textEditorOptions; this.document = document; this.currentState = new GlobalBodyState(this); this.conditionalSymbols = new HashSet <string>(); this.customConditionalSymbols = new HashSet <string>(); this.wordToken = new StringBuilder(); this.previousKeyword = string.Empty; this.newLineChar = textEditorOptions.EolMarker[0]; }
/// <inheritdoc /> public void Reset() { currentState = IndentStateFactory.Default(this); conditionalSymbols.Clear(); ifDirectiveEvalResult.Clear(); offset = 0; line = 1; column = 1; isLineStart = true; currentChar = '\0'; previousChar = '\0'; currentIndent.Length = 0; lineBeganInsideMultiLineComment = false; lineBeganInsideVerbatimString = false; }
/// <summary> /// Begin a section during which any newline should be indented relative to the last indented offset. /// </summary> public void BeginIndentOnNewLineRelativeToLastIndent(CodeObject codeObject, CodeObject lastCodeObject) { // Use the last indented offset if the code object matches, otherwise just do a normal indent IndentState indentState = _lastPoppedIndentState; if (indentState == null || indentState.IndentObject != lastCodeObject) { BeginIndentOnNewLine(codeObject); } else { indentState.IndentObject = codeObject; _indentStateStack.Push(indentState); } IndentOffset = IndentOffset; // Change current column now if line is empty }
public IndentEngine(IndentEngine prototype) { this.Document = prototype.Document; this.Options = prototype.Options; this.TextEditorOptions = prototype.TextEditorOptions; this.CurrentState = prototype.CurrentState.Clone(); this.ConditionalSymbols = new HashSet <string>(prototype.ConditionalSymbols); this.IfDirectiveEvalResult = prototype.IfDirectiveEvalResult; this.CurrentIndent = new StringBuilder(prototype.CurrentIndent.ToString()); this.offset = prototype.offset; this.line = prototype.line; this.column = prototype.column; this.IsLineStart = prototype.IsLineStart; this.CurrentChar = prototype.CurrentChar; this.PreviousChar = prototype.PreviousChar; }
/// <inheritdoc /> public void Reset() { currentState = new GlobalBodyState(this); conditionalSymbols.Clear(); ifDirectiveEvalResults.Clear(); ifDirectiveIndents.Clear(); offset = 0; line = 1; column = 1; isLineStart = true; currentChar = '\0'; previousChar = '\0'; currentIndent.Length = 0; lineBeganInsideMultiLineComment = false; lineBeganInsideVerbatimString = false; }
/// <summary> /// Creates a new CSharpIndentEngine instance from the given prototype. /// </summary> /// <param name="prototype"> /// An CSharpIndentEngine instance. /// </param> public CSharpIndentEngine(CSharpIndentEngine prototype) { this.formattingOptions = prototype.formattingOptions; this.textEditorOptions = prototype.textEditorOptions; this.document = prototype.document; this.newLineChar = prototype.newLineChar; this.currentState = prototype.currentState.Clone(this); this.conditionalSymbols = new HashSet<string>(prototype.conditionalSymbols); this.customConditionalSymbols = new HashSet<string>(prototype.customConditionalSymbols); this.wordToken = new StringBuilder(prototype.wordToken.ToString()); this.previousKeyword = string.Copy(prototype.previousKeyword); this.offset = prototype.offset; this.line = prototype.line; this.column = prototype.column; this.isLineStart = prototype.isLineStart; this.isLineStartBeforeWordToken = prototype.isLineStartBeforeWordToken; this.currentChar = prototype.currentChar; this.previousChar = prototype.previousChar; this.previousNewline = prototype.previousNewline; this.currentIndent = new StringBuilder(prototype.CurrentIndent.ToString()); this.lineBeganInsideMultiLineComment = prototype.lineBeganInsideMultiLineComment; this.lineBeganInsideVerbatimString = prototype.lineBeganInsideVerbatimString; this.ifDirectiveEvalResults = prototype.ifDirectiveEvalResults.Clone(); this.ifDirectiveIndents = prototype.ifDirectiveIndents.Clone(); this.EnableCustomIndentLevels = prototype.EnableCustomIndentLevels; }
/// <summary> /// Creates a new CSharpIndentEngine instance. /// </summary> /// <param name="document"> /// An instance of <see cref="IDocument"/> which is being parsed. /// </param> /// <param name="formattingOptions"> /// C# formatting options. /// </param> /// <param name="textEditorOptions"> /// Text editor options for indentation. /// </param> public CSharpIndentEngine(IDocument document, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions) { this.formattingOptions = formattingOptions; this.textEditorOptions = textEditorOptions; this.document = document; this.currentState = new GlobalBodyState(this); this.conditionalSymbols = new HashSet<string>(); this.customConditionalSymbols = new HashSet<string>(); this.wordToken = new StringBuilder(); this.previousKeyword = string.Empty; this.newLineChar = textEditorOptions.EolMarker[0]; }
/// <summary> /// Creates a new CSharpIndentEngine instance. /// </summary> /// <param name="formattingOptions"> /// C# formatting options. /// </param> public CSharpIndentEngine(OptionSet formattingOptions) { this.options = formattingOptions; this.currentState = new GlobalBodyState(this); this.conditionalSymbols = new HashSet<string>(); this.customConditionalSymbols = new HashSet<string>(); this.wordToken = new StringBuilder(); this.previousKeyword = string.Empty; this.newLineChar = formattingOptions.GetOption(FormattingOptions.NewLine, LanguageNames.CSharp)[0]; }
/// <summary> /// Resets the engine. /// </summary> public void Reset() { CurrentState = IndentStateFactory.Default(this); ConditionalSymbols.Clear(); IfDirectiveEvalResult = false; CurrentIndent.Length = 0; offset = 0; line = 1; column = 1; IsLineStart = true; CurrentChar = '\0'; PreviousChar = '\0'; }
public IndentEngine(IndentEngine prototype) { this.Document = prototype.Document; this.Options = prototype.Options; this.TextEditorOptions = prototype.TextEditorOptions; this.CurrentState = prototype.CurrentState.Clone(); this.ConditionalSymbols = new HashSet<string>(prototype.ConditionalSymbols); this.IfDirectiveEvalResult = prototype.IfDirectiveEvalResult; this.CurrentIndent = new StringBuilder(prototype.CurrentIndent.ToString()); this.offset = prototype.offset; this.line = prototype.line; this.column = prototype.column; this.IsLineStart = prototype.IsLineStart; this.CurrentChar = prototype.CurrentChar; this.PreviousChar = prototype.PreviousChar; }
public IndentEngine(IDocument document, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions) { this.Document = document; this.Options = formattingOptions; this.TextEditorOptions = textEditorOptions; this.CurrentState = IndentStateFactory.Default(this); }
public IndentScope(IndentState indent) { _indent = indent; _indent.Indent += 1; }