diff options
Diffstat (limited to 'main/src')
18 files changed, 192 insertions, 185 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ResolveCommandHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ResolveCommandHandler.cs index daf9f3a843..82f7404953 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ResolveCommandHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ResolveCommandHandler.cs @@ -329,7 +329,8 @@ namespace MonoDevelop.Refactoring compilations.Add (Tuple.Create (TypeSystemService.GetCompilation (systemAssembly, doc.Compilation), new MonoDevelop.Projects.ProjectReference (systemAssembly))); } } catch (Exception e) { - LoggingService.LogError ("Error while looking up framework extension methods.", e); + if (!TypeSystemService.RecreateFrameworkLookup (netProject)) + LoggingService.LogError ("Error while looking up framework extension methods.", e); } } bool foundIdentifier = false; @@ -427,7 +428,8 @@ namespace MonoDevelop.Refactoring lookups.Add (Tuple.Create (r, systemAssembly)); } } catch (Exception e) { - LoggingService.LogError ("Error while looking up framework types.", e); + if (!TypeSystemService.RecreateFrameworkLookup (netProject)) + LoggingService.LogError ("Error while looking up framework types.", e); } foreach(var kv in lookups) yield return new PossibleNamespace (kv.Item1.Namespace, true, new MonoDevelop.Projects.ProjectReference (kv.Item2)); @@ -447,7 +449,8 @@ namespace MonoDevelop.Refactoring lookups.Add (Tuple.Create (r, systemAssembly)); } } catch (Exception e) { - LoggingService.LogError ("Error while looking up framework types.", e); + if (!TypeSystemService.RecreateFrameworkLookup (netProject)) + LoggingService.LogError ("Error while looking up framework types.", e); } foreach(var kv in lookups) yield return new PossibleNamespace (kv.Item1.Namespace, true, new MonoDevelop.Projects.ProjectReference (kv.Item2)); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionNodeExtension.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionNodeExtension.cs index 2fe6ae665c..b31938e789 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionNodeExtension.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionNodeExtension.cs @@ -72,20 +72,23 @@ namespace MonoDevelop.VersionControl.Subversion [CommandUpdateHandler (Commands.Resolve)]
protected void UpdateResolve (CommandInfo item) { - foreach (VersionControlItem vit in GetItems ()) { + foreach (VersionControlItem vit in GetItems (false)) { if (!(vit.Repository is SubversionRepository)) { item.Visible = false; return; } - if (!vit.IsDirectory) { - VersionInfo vi = vit.Repository.GetVersionInfo (vit.Path); - if (vi != null && (vi.Status & VersionStatus.Conflicted) == 0) { - item.Visible = false; - return; - } + if (vit.IsDirectory) { + item.Visible = false; + return; } - }
+ + VersionInfo vi = vit.Repository.GetVersionInfo (vit.Path); + if (vi != null && (vi.Status & VersionStatus.Conflicted) == 0) { + item.Visible = false; + return; + } + } }
}
} diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs index 8123ad5e00..b4921f802a 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs @@ -424,7 +424,7 @@ namespace MonoDevelop.VersionControl.Subversion void MakeDirVersioned (string dir, IProgressMonitor monitor)
{
- if (Directory.Exists (Path.Combine (dir, ".svn")))
+ if (Directory.Exists (SubversionBackend.GetDirectoryDotSvn (VersionControlSystem, dir)))
return;
// Make the parent versioned
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs index d938f71dae..5deddc7616 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs @@ -50,7 +50,7 @@ namespace MonoDevelop.VersionControl.Subversion { public abstract string GetTextBase (string sourcefile); - protected static string GetDirectoryDotSvn (SubversionVersionControl vcs, FilePath path) + internal static string GetDirectoryDotSvn (SubversionVersionControl vcs, FilePath path) { return vcs.GetDirectoryDotSvn (path); } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs index 42e827a26b..a3acb31b22 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs @@ -446,7 +446,9 @@ namespace MonoDevelop.VersionControl.Views hscrollbar.Destroy (); } - children.ForEach (child => child.Child.Destroy ()); + foreach (var child in children.ToArray ()) { + child.Child.Destroy (); + } base.OnDestroyed (); } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs index b311c05a05..917c7e8a34 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs @@ -30,6 +30,7 @@ using Mono.Addins; using MonoDevelop.VersionControl; using MonoDevelop.Ide.Gui; using MonoDevelop.Core.LogReporting; +using MonoDevelop.Projects; namespace MonoDevelop.VersionControl.Views { @@ -44,10 +45,23 @@ namespace MonoDevelop.VersionControl.Views { var document = Ide.IdeApp.Workbench.ActiveDocument; try { - if (document == null || !document.IsFile || document.Project == null || document.Window.FindView<IDiffView> () >= 0) + if (document == null || !document.IsFile || document.Window.FindView<IDiffView> () >= 0) return; + + IWorkspaceObject project = document.Project; + if (project == null) { + // Fix for broken .csproj and .sln files not being seen as having a project. + foreach (var projItem in Ide.IdeApp.Workspace.GetAllSolutionItems<UnknownSolutionItem> ()) { + if (projItem.FileName == document.FileName) { + project = projItem; + } + } + + if (project == null) + return; + } - var repo = VersionControlService.GetRepository (document.Project); + var repo = VersionControlService.GetRepository (project); if (repo == null) return; @@ -55,7 +69,7 @@ namespace MonoDevelop.VersionControl.Views if (!versionInfo.IsVersioned) return; - var item = new VersionControlItem (repo, document.Project, document.FileName, false, null); + var item = new VersionControlItem (repo, project, document.FileName, false, null); var vcInfo = new VersionControlDocumentInfo (document.PrimaryView, item, item.Repository); TryAttachView <IDiffView> (document, vcInfo, DiffCommand.DiffViewHandlers); TryAttachView <IBlameView> (document, vcInfo, BlameCommand.BlameViewHandlers); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj index 5919e2a283..c4058cc3f7 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj @@ -236,6 +236,7 @@ <Compile Include="MonoDevelop.VersionControl\BlameCommand.cs" /> <Compile Include="MonoDevelop.VersionControl\VersionInfoCache.cs" /> <Compile Include="MonoDevelop.VersionControl\IgnoreCommand.cs" /> + <Compile Include="MonoDevelop.VersionControl\ResolveConflictsCommand.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs index a6f81f02a8..80aa37a43a 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs @@ -26,7 +26,8 @@ namespace MonoDevelop.VersionControl HideAnnotations, CreatePatch, Ignore, - Unignore + Unignore, + ResolveConflicts } class SolutionVersionControlCommandHandler: CommandHandler diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ResolveConflictsCommand.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ResolveConflictsCommand.cs new file mode 100644 index 0000000000..c288504686 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/ResolveConflictsCommand.cs @@ -0,0 +1,52 @@ +//
+// ResolveConflictsCommands.cs
+//
+// Author:
+// Therzok <teromario@yahoo.com>
+//
+// Copyright (c) 2013 Therzok
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using MonoDevelop.Ide;
+using MonoDevelop.VersionControl.Views;
+using MonoDevelop.Ide.Gui;
+
+namespace MonoDevelop.VersionControl
+{
+ public class ResolveConflictsCommand
+ {
+ public static bool ResolveConflicts (VersionControlItemList list, bool test)
+ {
+ VersionStatus status = list [0].VersionInfo.Status;
+ bool conflicted = (status & VersionStatus.Conflicted) == VersionStatus.Conflicted;
+ if (test)
+ return conflicted;
+
+ foreach (var item in list) {
+ Document doc = IdeApp.Workbench.OpenDocument (item.Path, true);
+ foreach (var view in doc.Views) {
+ if (view.GetContent <MergeView> () != null)
+ view.Select ();
+ }
+ }
+ return true;
+ }
+ }
+}
+
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlCommandHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlCommandHandler.cs index ebf2a95537..90a1a020a5 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlCommandHandler.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlCommandHandler.cs @@ -99,6 +99,11 @@ namespace MonoDevelop.VersionControl path = proj.FileName; isDir = false; pentry = proj; + } else if (!projRecurse && obj is UnknownSolutionItem) { + UnknownSolutionItem item = (UnknownSolutionItem)obj; + path = item.FileName; + isDir = false; + pentry = item; } else if (obj is IWorkspaceObject) { pentry = ((IWorkspaceObject)obj); path = pentry.BaseDirectory; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs index 1c2bd2a11e..53bff837a2 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs @@ -411,6 +411,23 @@ namespace MonoDevelop.VersionControl TestCommand(Commands.Unignore, item);
}
+ [CommandHandler (Commands.ResolveConflicts)]
+ protected void OnResolveConflicts ()
+ {
+ RunCommand (Commands.ResolveConflicts, false, false);
+ }
+
+ [CommandUpdateHandler (Commands.ResolveConflicts)]
+ protected void UpdateResolveConflicts (CommandInfo item)
+ {
+ if (!(CurrentNode.DataItem is UnknownSolutionItem)) {
+ item.Visible = false;
+ return;
+ }
+
+ TestCommand (Commands.ResolveConflicts, item, false);
+ }
+
private void TestCommand(Commands cmd, CommandInfo item, bool projRecurse = true)
{
TestResult res = RunCommand(cmd, true, projRecurse);
@@ -484,6 +501,9 @@ namespace MonoDevelop.VersionControl case Commands.Unignore:
res = UnignoreCommand.Unignore (items, test);
break;
+ case Commands.ResolveConflicts:
+ res = ResolveConflictsCommand.ResolveConflicts (items, test);
+ break;
}
}
catch (Exception ex) { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml index 7cd5d5b5f5..d0d84d596a 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml @@ -194,6 +194,9 @@ <Command id = "MonoDevelop.VersionControl.Commands.Unignore" _label = "Remove from ignore list" description = "Add items to version control ignore list"/> + <Command id = "MonoDevelop.VersionControl.Commands.ResolveConflicts" + _label = "Resolve Conflicts" + description = "Resolve conflicts on the project file."/> <Command id = "MonoDevelop.VersionControl.Views.BlameCommands.CopyRevision" _label = "_Copy revision"/> @@ -246,6 +249,7 @@ <Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad"> <Condition id="ItemType" value="IFileItem|IFolderItem"> <ItemSet id = "VersionControl" _label = "_Version Control" insertafter = "Tools"> + <CommandItem id = "MonoDevelop.VersionControl.Commands.ResolveConflicts"/> <Condition id="ItemType" value="Project|WorkspaceItem"> <CommandItem id = "MonoDevelop.VersionControl.Commands.Publish"/> </Condition> diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs index 7fa85b554f..c19851e80a 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SemanticRule.cs @@ -40,7 +40,7 @@ namespace Mono.TextEditor public class HighlightUrlSemanticRule : SemanticRule { - const string urlRegexStr = @"(http|ftp)s?\:\/\/[\w\d\._/\-~%@()+:?&=#!]*[\w\d/]"; + const string urlRegexStr = @"(http|ftp)s?\:\/\/[\w\d\.,;_/\-~%@()+:?&^=#!]*[\w\d/]"; public static readonly Regex UrlRegex = new Regex (urlRegexStr, RegexOptions.Compiled | RegexOptions.ExplicitCapture); public static readonly Regex MailRegex = new Regex (@"[\w\d._%+-]+@[\w\d.-]+\.\w{2,4}", RegexOptions.Compiled); diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs index df1ddaecfd..ee83ac7b7d 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs @@ -2996,6 +2996,7 @@ namespace Mono.TextEditor return LocationToPoint (loc, false); } + public Cairo.Point LocationToPoint (int line, int column, bool useAbsoluteCoordinates) { return LocationToPoint (new DocumentLocation (line, column), useAbsoluteCoordinates); @@ -3028,157 +3029,16 @@ namespace Mono.TextEditor } if (line == null || line.Length == 0 || column < 0) return 0; - int logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn); - int lineOffset = line.Offset; - StringBuilder textBuilder = new StringBuilder (); - ISyntaxMode mode = Document.SyntaxMode != null && textEditor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : new SyntaxMode (Document); - var startChunk = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, lineOffset, line.Length); - foreach (Chunk chunk in startChunk) { - try { - textBuilder.Append (Document.GetTextAt (chunk)); - } catch (Exception e) { - Console.WriteLine (e); - return 0; - } - } - string lineText = textBuilder.ToString (); - char[] lineChars = lineText.ToCharArray (); - - bool containsPreedit = textEditor.ContainsPreedit (lineOffset, line.Length); - uint preeditLength = 0; - - if (containsPreedit) { - lineText = lineText.Insert (textEditor.preeditOffset - lineOffset, textEditor.preeditString); - preeditLength = (uint)textEditor.preeditString.Length; - } - if (column < lineText.Length) - lineText = lineText.Substring (0, column); - - var layout = PangoUtil.CreateLayout (textEditor, lineText); - layout.Alignment = Pango.Alignment.Left; - layout.FontDescription = textEditor.Options.Font; - layout.Tabs = tabArray; - - int startOffset = lineOffset, endOffset = lineOffset + line.Length; - uint curIndex = 0, byteIndex = 0; - uint curChunkIndex = 0, byteChunkIndex = 0; - List<Pango.Attribute> attributes = new List<Pango.Attribute> (); - uint oldEndIndex = 0; - - Cairo.Color curFgColor = textEditor.ColorStyle.PlainText.Foreground; - Cairo.Color curBgColor = textEditor.ColorStyle.PlainText.Background; - var curWeight = Xwt.Drawing.FontWeight.Normal; - var curStyle = Xwt.Drawing.FontStyle.Normal; - - foreach (Chunk chunk in startChunk) { - ChunkStyle chunkStyle = chunk != null ? textEditor.ColorStyle.GetChunkStyle (chunk) : null; - - foreach (TextLineMarker marker in line.Markers) - chunkStyle = marker.GetStyle (chunkStyle); - - if (chunkStyle != null) { - startOffset = chunk.Offset; - endOffset = chunk.EndOffset; - - uint startIndex = (uint)(oldEndIndex); - uint endIndex = (uint)(startIndex + chunk.Length); - oldEndIndex = endIndex; - if (containsPreedit) { - if (textEditor.preeditOffset < startOffset) - startIndex += preeditLength; - if (textEditor.preeditOffset < endOffset) - endIndex += preeditLength; - } + var wrapper = GetLayout (line); + uint curIndex = 0; + uint byteIndex = 0; - HandleSelection (lineOffset, logicalRulerColumn, - 1, -1, chunk.Offset, chunk.EndOffset, delegate(int start, int end) { - var color = textEditor.ColorStyle.GetForeground (chunkStyle); - var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex); - var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex); - if (!color.Equals (curFgColor)) { - curFgColor = color; - var foreGround = new Pango.AttrForeground ( - (ushort)(color.R * ushort.MaxValue), - (ushort)(color.G * ushort.MaxValue), - (ushort)(color.B * ushort.MaxValue)); - foreGround.StartIndex = si; - foreGround.EndIndex = ei; - attributes.Add (foreGround); - } - if (!chunkStyle.TransparentBackground) { - color = chunkStyle.Background; - if (!color.Equals (curBgColor)) { - var background = new Pango.AttrBackground ( - (ushort)(color.R * ushort.MaxValue), - (ushort)(color.G * ushort.MaxValue), - (ushort)(color.B * ushort.MaxValue)); - background.StartIndex = si; - background.EndIndex = ei; - attributes.Add (background); - } - } - }, delegate(int start, int end) { - Pango.AttrForeground selectedForeground; - if (!SelectionColor.TransparentForeground) { - var color = SelectionColor.Foreground; - if (color.Equals (curFgColor)) - return; - curFgColor = color; - selectedForeground = new Pango.AttrForeground ( - (ushort)(color.R * ushort.MaxValue), - (ushort)(color.G * ushort.MaxValue), - (ushort)(color.B * ushort.MaxValue)); - } else { - var color = ColorStyle.GetForeground (chunkStyle); - if (color.Equals (curFgColor)) - return; - curFgColor = color; - selectedForeground = new Pango.AttrForeground ( - (ushort)(color.R * ushort.MaxValue), - (ushort)(color.G * ushort.MaxValue), - (ushort)(color.B * ushort.MaxValue)); - } - selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex); - selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex); - attributes.Add (selectedForeground); - }); - - var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex); - var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex); - - if (chunkStyle.FontWeight != curWeight) { - curWeight = chunkStyle.FontWeight; - var attrWeight = new Pango.AttrWeight ((Pango.Weight)chunkStyle.FontWeight); - attrWeight.StartIndex = translatedStartIndex; - attrWeight.EndIndex = translatedEndIndex; - attributes.Add (attrWeight); - } - - if (chunkStyle.FontStyle != curStyle) { - curStyle = chunkStyle.FontStyle; - Pango.AttrStyle attrStyle = new Pango.AttrStyle ((Pango.Style)chunkStyle.FontStyle); - attrStyle.StartIndex = translatedStartIndex; - attrStyle.EndIndex = translatedEndIndex; - attributes.Add (attrStyle); - } + var pos = wrapper.Layout.IndexToPos ((int)TranslateToUTF8Index (wrapper.LineChars, (uint)column, ref curIndex, ref byteIndex)); + if (wrapper.IsUncached) + wrapper.Dispose (); - if (chunkStyle.Underline) { - var attrUnderline = new Pango.AttrUnderline (Pango.Underline.Single); - attrUnderline.StartIndex = translatedStartIndex; - attrUnderline.EndIndex = translatedEndIndex; - attributes.Add (attrUnderline); - } - } - } - Pango.AttrList attributeList = new Pango.AttrList (); - attributes.ForEach (attr => attributeList.Insert (attr)); - layout.Attributes = attributeList; - Pango.Rectangle inkrect, logicalrect; - layout.GetExtents (out inkrect, out logicalrect); - attributes.ForEach (attr => attr.Dispose ()); - attributeList.Dispose (); - layout.Dispose (); - return (logicalrect.Width + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale; + return (pos.X + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale; } public int YToLine (double yPos) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs index 04c4f495d4..a7adb8224e 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs @@ -55,6 +55,11 @@ namespace MonoDevelop.Core.Assemblies internal void Initialize () { + Initialize (false); + } + + internal void Initialize (bool synchronous) + { CreateFrameworks (); runtimes = new List<TargetRuntime> (); foreach (ITargetRuntimeFactory factory in AddinManager.GetExtensionObjects ("/MonoDevelop/Core/Runtimes", typeof(ITargetRuntimeFactory))) { @@ -73,20 +78,17 @@ namespace MonoDevelop.Core.Assemblies if (CurrentRuntime == null) LoggingService.LogFatalError ("Could not create runtime info for current runtime"); - CurrentRuntime.StartInitialization (); + if (synchronous) + CurrentRuntime.EnsureInitialized (); + else + CurrentRuntime.StartInitialization (); LoadUserAssemblyContext (); userAssemblyContext.Changed += delegate { SaveUserAssemblyContext (); }; } - - void InitializeRuntime (TargetRuntime runtime) - { - runtime.Initialized += HandleRuntimeInitialized; - runtime.StartInitialization (); - } - + void HandleRuntimeInitialized (object sender, EventArgs e) { var runtime = (TargetRuntime) sender; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs index 962a9cb47c..9d67f10a66 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs @@ -52,9 +52,14 @@ namespace MonoDevelop.Core static AddinSetupService setupService; static ApplicationService applicationService; static bool initialized; - + public static void Initialize (bool updateAddinRegistry) { + Initialize (updateAddinRegistry, false); + } + + public static void Initialize (bool updateAddinRegistry, bool synchronousRuntimeInitialization) + { if (initialized) return; Counters.RuntimeInitialization.BeginTiming (); @@ -114,7 +119,7 @@ namespace MonoDevelop.Core Counters.RuntimeInitialization.Trace ("Initializing Assembly Service"); systemAssemblyService = new SystemAssemblyService (); - systemAssemblyService.Initialize (); + systemAssemblyService.Initialize (synchronousRuntimeInitialization); initialized = true; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs index be87bba685..9a4a5c542f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs @@ -2150,15 +2150,29 @@ namespace MonoDevelop.Ide.TypeSystem return assemblies.Values; } - readonly static Dictionary<string, Task<FrameworkLookup>> frameworkLookup = new Dictionary<string, Task<FrameworkLookup>> (); + class FrameworkTask + { + public int RetryCount { get; set; } + public Task<FrameworkLookup> Task { get; set; } + + } + + readonly static Dictionary<string, FrameworkTask> frameworkLookup = new Dictionary<string, FrameworkTask> (); static void StartFrameworkLookup (DotNetProject netProject) { + if (netProject == null) + throw new ArgumentNullException ("netProject"); lock (frameworkLookup) { - Task<FrameworkLookup> result; - if (frameworkLookup.TryGetValue (netProject.TargetFramework.Name, out result)) + FrameworkTask result; + if (netProject.TargetFramework == null) return; - frameworkLookup[netProject.TargetFramework.Name] = Task.Factory.StartNew (delegate { + var frameworkName = netProject.TargetFramework.Name; + if (!frameworkLookup.TryGetValue (frameworkName, out result)) + frameworkLookup [frameworkName] = result = new FrameworkTask (); + if (result.Task != null) + return; + result.Task = Task.Factory.StartNew (delegate { return GetFrameworkLookup (netProject); }); } @@ -2167,13 +2181,13 @@ namespace MonoDevelop.Ide.TypeSystem public static bool TryGetFrameworkLookup (DotNetProject project, out FrameworkLookup lookup) { lock (frameworkLookup) { - Task<FrameworkLookup> result; + FrameworkTask result; if (frameworkLookup.TryGetValue (project.TargetFramework.Name, out result)) { - if (!result.IsCompleted) { + if (!result.Task.IsCompleted) { lookup = null; return false; } - lookup = result.Result; + lookup = result.Task.Result; return true; } } @@ -2181,6 +2195,23 @@ namespace MonoDevelop.Ide.TypeSystem return false; } + public static bool RecreateFrameworkLookup (DotNetProject netProject) + { + lock (frameworkLookup) { + FrameworkTask result; + if (!frameworkLookup.TryGetValue (netProject.TargetFramework.Name, out result)) + return false; + if (result.RetryCount > 5) { + LoggingService.LogError ("Can't create framework lookup for:" + netProject.TargetFramework.Name); + return false; + } + result.RetryCount++; + LoggingService.LogInfo ("Trying to recreate framework lookup for {0}, try {1}.", netProject.TargetFramework.Name, result.RetryCount); + StartFrameworkLookup (netProject); + return true; + } + } + static FrameworkLookup GetFrameworkLookup (DotNetProject netProject) { FrameworkLookup result; @@ -2597,6 +2628,7 @@ namespace MonoDevelop.Ide.TypeSystem } } #endregion + } internal sealed class AssemblyLoadedEventArgs : EventArgs diff --git a/main/src/tools/mdtool/src/mdtool.cs b/main/src/tools/mdtool/src/mdtool.cs index fece250a66..0ce1031224 100644 --- a/main/src/tools/mdtool/src/mdtool.cs +++ b/main/src/tools/mdtool/src/mdtool.cs @@ -40,7 +40,10 @@ public class MonoDevelopProcessHost public static int Main (string[] args) { try { - Runtime.Initialize (false); + // If we are running mdtool setup reg-build we *must* ensure we do all our initialization synchronously. Otherwise we can end up + // in a situation where some addins are trying to use Mono.Addins while we are rebuilding the registry. As you can imagine, this + // causes all kinds of strange and unusual crashes and errors. + Runtime.Initialize (true, true); Runtime.SetProcessName ("mdtool"); if (args.Length == 0 || args [0] == "--help") { |