diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2012-03-29 17:37:20 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2012-03-29 17:37:20 +0400 |
commit | 7b4258bcc0db025ae4d02d41e11dd85ab7d0d831 (patch) | |
tree | 48e37c7bec965a4523e564846816dfe9687e7896 /main/src | |
parent | 31d57d9ed259f4dec12c9c6536d7edb9d8410939 (diff) |
Track API changes.
Diffstat (limited to 'main/src')
8 files changed, 39 insertions, 29 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpReferenceFinder.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpReferenceFinder.cs index cb077d1282..d96c74386d 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpReferenceFinder.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpReferenceFinder.cs @@ -206,7 +206,7 @@ namespace MonoDevelop.CSharp.Refactoring } foreach (var file in files) { - string text = Mono.TextEditor.Utils.TextFileReader.ReadAllText (file); + string text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (file); if (memberName != null && text.IndexOf (memberName, StringComparison.Ordinal) < 0 && (keywordName == null || text.IndexOf (keywordName, StringComparison.Ordinal) < 0)) continue; diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/DomMethodNodeBuilder.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/DomMethodNodeBuilder.cs index 35dff510db..60b1b9d077 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/DomMethodNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/TreeNodes/DomMethodNodeBuilder.cs @@ -208,7 +208,7 @@ namespace MonoDevelop.AssemblyBrowser return false; var method = (IUnresolvedEntity)navigator.DataItem; - data.Text = Mono.TextEditor.Utils.TextFileReader.ReadAllText (method.Region.FileName); + data.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (method.Region.FileName); data.Caret.Location = method.Region.Begin; data.CenterToCaret (); return true; @@ -230,7 +230,7 @@ namespace MonoDevelop.AssemblyBrowser var method = (IUnresolvedMethod)navigator.DataItem; var resolved = Resolve (navigator, method); if (GetMainAssembly (navigator) == null) { - return Mono.TextEditor.Utils.TextFileReader.ReadAllText (method.Region.FileName); + return Mono.TextEditor.Utils.TextFileUtility.ReadAllText (method.Region.FileName); } StringBuilder result = new StringBuilder (); result.Append ("<big>"); diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewDialog.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewDialog.cs index 326540de53..d492b452e2 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewDialog.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewDialog.cs @@ -108,7 +108,7 @@ namespace MonoDevelop.Refactoring } Mono.TextEditor.TextDocument doc = new Mono.TextEditor.TextDocument (); - doc.Text = Mono.TextEditor.Utils.TextFileReader.ReadAllText (replaceChange.FileName); + doc.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (replaceChange.FileName); DocumentLocation loc = doc.OffsetToLocation (replaceChange.Offset); string text = string.Format (GettextCatalog.GetString ("(Line:{0}, Column:{1})"), loc.Line, loc.Column); @@ -137,7 +137,7 @@ namespace MonoDevelop.Refactoring Mono.TextEditor.TextDocument originalDocument = new Mono.TextEditor.TextDocument (); originalDocument.FileName = replaceChange.FileName; if (openDocument == null) { - originalDocument.Text = Mono.TextEditor.Utils.TextFileReader.ReadAllText (replaceChange.FileName); + originalDocument.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (replaceChange.FileName); } else { originalDocument.Text = openDocument.Editor.Document.Text; } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs index 44bf05eebf..774c369d3f 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/AutoSave.cs @@ -153,7 +153,7 @@ namespace MonoDevelop.SourceEditor public static string LoadAutoSave (string fileName) { string autoSaveFileName = GetAutoSaveFileName (fileName); - return Mono.TextEditor.Utils.TextFileReader.ReadAllText (autoSaveFileName); + return Mono.TextEditor.Utils.TextFileUtility.ReadAllText (autoSaveFileName); } public static void RemoveAutoSaveFile (string fileName) diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs index 5e8392ba24..7599ee9dcf 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs @@ -50,6 +50,7 @@ using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.Semantics; using MonoDevelop.SourceEditor.QuickTasks; +using System.Text; namespace MonoDevelop.SourceEditor { @@ -380,9 +381,9 @@ namespace MonoDevelop.SourceEditor Save (fileName, this.encoding); } - public void Save (string fileName, string encoding) + public void Save (string fileName, Encoding encoding) { - if (!widget.EnsureCorrectEolMarker (fileName, encoding)) + if (!widget.EnsureCorrectEolMarker (fileName)) return; if (widget.HasMessageBar) return; @@ -428,7 +429,14 @@ namespace MonoDevelop.SourceEditor } } try { - TextFile.WriteFile (fileName, Document.Text, encoding, hadBom); + var writeEncoding = encoding; + var writeBom = hadBom; + var writeText = Document.Text; + if (writeEncoding == null) { + writeEncoding = Encoding.UTF8; + writeBom = !Mono.TextEditor.Utils.TextFileUtility.IsASCII (writeText); + } + Mono.TextEditor.Utils.TextFileUtility.WriteText (fileName, writeText, writeEncoding, writeBom); } catch (InvalidEncodingException) { var result = MessageService.AskQuestion (GettextCatalog.GetString ("Can't save file witch current codepage."), GettextCatalog.GetString ("Some unicode characters in this file could not be saved with the current encoding.\nDo you want to resave this file as Unicode ?\nYou can choose another encoding in the 'save as' dialog."), @@ -437,8 +445,8 @@ namespace MonoDevelop.SourceEditor new AlertButton (GettextCatalog.GetString ("Save as Unicode"))); if (result != AlertButton.Cancel) { this.hadBom = true; - this.encoding = "UTF-8"; - TextFile.WriteFile (fileName, Document.Text, this.encoding, this.hadBom); + this.encoding = Encoding.UTF8; + Mono.TextEditor.Utils.TextFileUtility.WriteText (fileName, Document.Text, encoding, hadBom); } else { return; } @@ -494,7 +502,7 @@ namespace MonoDevelop.SourceEditor widget.UpdateParsedDocument (foldingParser.Parse (Document.FileName, text)); } - public void Load (string fileName, string encoding) + public void Load (string fileName, Encoding encoding) { // Handle the "reload" case. if (ContentName == fileName) @@ -515,14 +523,16 @@ namespace MonoDevelop.SourceEditor this.encoding = encoding; didLoadCleanly = false; } else { - TextFile file = TextFile.ReadFile (fileName, encoding); + inLoad = true; - Document.Text = text = file.Text; + if (encoding == null) { + text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (fileName, out hadBom, out encoding); + } else { + text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (fileName, encoding, out hadBom); + } + Document.Text = text; inLoad = false; - this.encoding = file.SourceEncoding; - this.hadBom = file.HadBOM; didLoadCleanly = true; - } // TODO: Would be much easier if the view would be created after the containers. @@ -605,7 +615,7 @@ namespace MonoDevelop.SourceEditor internal void StoreSettings () { - Dictionary<int, bool> foldingStates = new Dictionary<int, bool> (); + var foldingStates = new Dictionary<int, bool> (); foreach (var f in widget.TextEditor.Document.FoldSegments) { foldingStates [f.Offset] = f.IsFolded; } @@ -621,10 +631,10 @@ namespace MonoDevelop.SourceEditor bool warnOverwrite = false; bool inLoad = false; - string encoding = null; + Encoding encoding = null; bool hadBom = false; - public void Load (string fileName, string content, string encoding) + public void Load (string fileName, string content, Encoding encoding) { if (warnOverwrite) { warnOverwrite = false; @@ -642,7 +652,7 @@ namespace MonoDevelop.SourceEditor UpdateExecutionLocation (); UpdateBreakpoints (); UpdatePinnedWatches (); - this.IsDirty = false; + IsDirty = false; Document.InformLoadComplete (); } @@ -665,7 +675,7 @@ namespace MonoDevelop.SourceEditor } } - public string SourceEncoding { + public Encoding SourceEncoding { get { return encoding; } } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs index 5c13eefb2f..d674658527 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs @@ -839,7 +839,7 @@ namespace MonoDevelop.SourceEditor #region Eol marker check bool useIncorrectMarkers; - internal bool EnsureCorrectEolMarker (string fileName, string encoding) + internal bool EnsureCorrectEolMarker (string fileName) { if (useIncorrectMarkers) return true; @@ -849,7 +849,7 @@ namespace MonoDevelop.SourceEditor if (firstDelimiter != TextEditor.Options.DefaultEolMarker) { switch (DefaultSourceEditorOptions.Instance.LineEndingConversion) { case LineEndingConversion.Ask: - ShowIncorretEolMarkers (fileName, encoding); + ShowIncorretEolMarkers (fileName); return false; case LineEndingConversion.ConvertAlways: ConvertLineEndings (); @@ -874,7 +874,7 @@ namespace MonoDevelop.SourceEditor TextEditor.Text = newText.ToString (); } - void ShowIncorretEolMarkers (string fileName, string encoding) + void ShowIncorretEolMarkers (string fileName) { RemoveMessageBar (); @@ -890,7 +890,7 @@ namespace MonoDevelop.SourceEditor b1.Clicked += delegate(object sender, EventArgs e) { try { ConvertLineEndings (); - view.Save (fileName, encoding); + view.Save (fileName, view.SourceEncoding); } finally { RemoveMessageBar (); view.WorkbenchWindow.ShowNotification = false; @@ -905,7 +905,7 @@ namespace MonoDevelop.SourceEditor RemoveMessageBar (); view.WorkbenchWindow.ShowNotification = false; - view.Save (fileName, encoding); + view.Save (fileName, view.SourceEncoding); }; messageBar.ActionArea.Add (b2); } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index 8ac86aa9fd..33283273e7 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -857,7 +857,7 @@ namespace MonoDevelop.VersionControl.Git string GetCommitTextContent (RevCommit c, FilePath file) { - return Mono.TextEditor.Utils.TextFileReader.GetText (GetCommitContent (c, file)); + return Mono.TextEditor.Utils.TextFileUtility.GetText (GetCommitContent (c, file)); } string GenerateDiff (byte[] data1, byte[] data2) diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs index 2ebb28eeb3..54332ecfad 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs @@ -82,7 +82,7 @@ namespace MonoDevelop.VersionControl.Views public void Load (string fileName) { MainEditor.Document.MimeType = DesktopService.GetMimeTypeForUri (fileName); - MainEditor.Document.Text = Mono.TextEditor.Utils.TextFileReader.ReadAllText (fileName); + MainEditor.Document.Text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (fileName); this.CreateDiff (); Show (); |