diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs')
-rw-r--r-- | main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs index 0782defa74..2970e88724 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentVirtualSpaceManager.cs @@ -24,62 +24,44 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using Mono.TextEditor; -using ICSharpCode.NRefactory.CSharp; using System; using MonoDevelop.Core; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Ide.Editor.Extension; +using ICSharpCode.NRefactory6.CSharp; namespace MonoDevelop.CSharp.Formatting { - class IndentVirtualSpaceManager : IIndentationTracker + class IndentVirtualSpaceManager : IndentationTracker { - readonly TextEditorData data; - readonly CacheIndentEngine stateTracker;
-
- public IndentVirtualSpaceManager(TextEditorData data, CacheIndentEngine stateTracker) + readonly TextEditor data; + readonly CacheIndentEngine stateTracker; + + public IndentVirtualSpaceManager(TextEditor data, CacheIndentEngine stateTracker) { this.data = data; this.stateTracker = stateTracker; } - string GetIndentationString (DocumentLocation loc) + #region IndentationTracker implementation + public override string GetIndentationString (int lineNumber) { - var line = data.Document.GetLine (loc.Line); + var line = data.GetLine (lineNumber); if (line == null) return ""; // Get context to the end of the line w/o changing the main engine's state var offset = line.Offset; - string curIndent = line.GetIndentation (data.Document); + string curIndent = line.GetIndentation (data); try { - stateTracker.Update (Math.Min (data.Length, offset + Math.Min (line.Length, loc.Column - 1))); + stateTracker.Update (data, Math.Min (data.Length, offset + line.Length)); int nlwsp = curIndent.Length; - if (!stateTracker.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && data.Document.GetCharAt (offset + nlwsp) == '*')) + if (!stateTracker.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && data.GetCharAt (offset + nlwsp) == '*')) return stateTracker.ThisLineIndent; } catch (Exception e) { - LoggingService.LogError ("Error while indenting at "+ loc, e); + LoggingService.LogError ("Error while indenting at line " + lineNumber, e); } return curIndent; } - - public string GetIndentationString (int lineNumber, int column) - { - return GetIndentationString (new DocumentLocation (lineNumber, column)); - } - - public string GetIndentationString (int offset) - { - return GetIndentationString (data.OffsetToLocation (offset)); - } - - public int GetVirtualIndentationColumn (int offset) - { - return 1 + GetIndentationString (offset).Length; - } - - public int GetVirtualIndentationColumn (int lineNumber, int column) - { - return 1 + GetIndentationString (lineNumber, column).Length; - } + #endregion } -} - +}
\ No newline at end of file |