diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-11-23 16:45:18 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-11-23 16:45:18 +0300 |
commit | a94ef4314d4bbbc96c0c80f15762335bf86df663 (patch) | |
tree | fcf7244620c9a1b9b735476ec2d9ae3f7d7f3407 /main/src/core | |
parent | 26e5c5b5cf30799e0b263fd3a26de017a72b1f49 (diff) | |
parent | a05bc0f6d0591f71c5e4e5786108118f51c68fe1 (diff) |
Merge remote-tracking branch 'origin/roslyn' into roslyn-nogtkshell
Diffstat (limited to 'main/src/core')
58 files changed, 819 insertions, 842 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs index 297da792ba..04e25725bd 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs @@ -445,6 +445,10 @@ namespace Mono.TextEditor.Highlighting [ColorDescription(UserTypesTypeParametersKey, VSSetting = "User Types(Type parameters)")] public ChunkStyle UserTypesTypeParameters { get; private set; } + public const string UserTypesMutableKey = "User Types(Mutable)"; + [ColorDescription(UserTypesMutableKey, VSSetting = "User Types(Mutable")] + public ChunkStyle UserTypesMutable { get; private set; } + public const string UserFieldUsageKey = "User Field Usage"; [ColorDescription(UserFieldUsageKey, VSSetting = "Identifier")] public ChunkStyle UserFieldUsage { get; private set; } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/DocumentUpdateRequest.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/DocumentUpdateRequest.cs index baa5551ec1..a964098a25 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/DocumentUpdateRequest.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/DocumentUpdateRequest.cs @@ -83,7 +83,7 @@ namespace Mono.TextEditor public override void Update (MonoTextEditor editor) { - editor.TextViewMargin.PurgeLayoutCache (); + //editor.TextViewMargin.PurgeLayoutCache (); editor.RedrawLines (start, end); } } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/LayoutCache.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/LayoutCache.cs index ab99a0fa95..aa7127d6dd 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/LayoutCache.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/LayoutCache.cs @@ -33,10 +33,10 @@ namespace Mono.TextEditor /// </summary> public class LayoutCache : IDisposable { - readonly Gtk.Widget widget; + readonly MonoTextEditor widget; readonly Queue<LayoutProxy> layoutQueue = new Queue<LayoutProxy> (); - public LayoutCache (Gtk.Widget widget) + public LayoutCache (MonoTextEditor widget) { if (widget == null) throw new ArgumentNullException ("widget"); @@ -65,6 +65,7 @@ namespace Mono.TextEditor { readonly LayoutCache layoutCache; readonly Pango.Layout layout; + int width = -1, height = -1, lineCount = -1; public LayoutProxy (LayoutCache layoutCache, Pango.Layout layout) { @@ -134,11 +135,12 @@ namespace Mono.TextEditor } public int LineCount { - get { return layout.LineCount; } + get { return lineCount < 0 ? lineCount = layout.LineCount : lineCount; } } public void SetText (string text) { + this.width = this.height = lineCount = -1; layout.SetText (text); } @@ -159,7 +161,14 @@ namespace Mono.TextEditor public void GetSize (out int width, out int height) { - layout.GetSize (out width, out height); + if (this.width >= 0) { + width = this.width; + height = this.height; + return; + } + layout.GetSize (out width, out height); + this.width = width; + this.height = height; } public bool XyToIndex (int x, int y, out int index, out int trailing) @@ -174,11 +183,29 @@ namespace Mono.TextEditor public void GetPixelSize (out int width, out int height) { - layout.GetPixelSize (out width, out height); + if (this.width >= 0) { + width = (int)(this.width / Pango.Scale.PangoScale); + height = (int)(this.height / Pango.Scale.PangoScale); + return; + } + + layout.GetPixelSize (out width, out height); + this.width = (int)(width * Pango.Scale.PangoScale); + this.height = (int)(height * Pango.Scale.PangoScale); } public void GetExtents (out Pango.Rectangle ink_rect, out Pango.Rectangle logical_rect) { + if (this.width >= 0) { + ink_rect = logical_rect = new Pango.Rectangle { + X = 0, + Y = 0, + Width = width, + Height = height + }; + return; + } + layout.GetExtents (out ink_rect, out logical_rect); } } 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 a3e4b4794f..f1d19cbfa1 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs @@ -37,6 +37,7 @@ using Gdk; using Gtk; using System.Timers; using ICSharpCode.NRefactory; +using System.Diagnostics; namespace Mono.TextEditor { @@ -869,144 +870,164 @@ namespace Mono.TextEditor uint curChunkIndex = 0, byteChunkIndex = 0; uint oldEndIndex = 0; - foreach (Chunk chunk in chunks) { - 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; - HandleSelection (lineOffset, logicalRulerColumn, selectionStart, selectionEnd, chunk.Offset, chunk.EndOffset, delegate(int start, int end) { - if (containsPreedit) { - if (textEditor.preeditOffset < start) - start += (int)preeditLength; - if (textEditor.preeditOffset < end) - end += (int)preeditLength; - } - 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); - var color = ColorStyle.GetForeground (chunkStyle); - foreach (var marker in markers) { - var chunkMarker = marker as IChunkMarker; - if (chunkMarker == null) - continue; - chunkMarker.ChangeForeColor (textEditor, chunk, ref color); - } - atts.AddForegroundAttribute ((HslColor)color, si, ei); - - if (!chunkStyle.TransparentBackground && GetPixel (ColorStyle.PlainText.Background) != GetPixel (chunkStyle.Background)) { - wrapper.AddBackground (chunkStyle.Background, (int)si, (int)ei); - } else if (chunk.SpanStack != null && ColorStyle != null) { - foreach (var span in chunk.SpanStack) { - if (span == null || string.IsNullOrEmpty (span.Color)) + bool disableHighlighting = false; + var sw = new Stopwatch (); + sw.Start (); + try { + restart: + foreach (Chunk chunk in chunks) { + if (!disableHighlighting && sw.ElapsedMilliseconds > 50) { + chunks.Clear (); + chunks.Add (new Chunk (line.Offset, line.Length, "Plain Text")); + disableHighlighting = true; + atts.Dispose (); + atts = new FastPangoAttrList (); + curIndex = byteIndex = 0; + curChunkIndex = byteChunkIndex = 0; + oldEndIndex = 0; + goto restart; + } + 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; + HandleSelection (lineOffset, logicalRulerColumn, selectionStart, selectionEnd, chunk.Offset, chunk.EndOffset, delegate (int start, int end) { + if (containsPreedit) { + if (textEditor.preeditOffset < start) + start += (int)preeditLength; + if (textEditor.preeditOffset < end) + end += (int)preeditLength; + } + 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); + var color = ColorStyle.GetForeground (chunkStyle); + foreach (var marker in markers) { + var chunkMarker = marker as IChunkMarker; + if (chunkMarker == null) continue; - var spanStyle = ColorStyle.GetChunkStyle (span.Color); - if (spanStyle != null && !spanStyle.TransparentBackground && GetPixel (ColorStyle.PlainText.Background) != GetPixel (spanStyle.Background)) { - wrapper.AddBackground (spanStyle.Background, (int)si, (int)ei); - break; + chunkMarker.ChangeForeColor (textEditor, chunk, ref color); + } + atts.AddForegroundAttribute ((HslColor)color, si, ei); + + if (!chunkStyle.TransparentBackground && GetPixel (ColorStyle.PlainText.Background) != GetPixel (chunkStyle.Background)) { + wrapper.AddBackground (chunkStyle.Background, (int)si, (int)ei); + } else if (chunk.SpanStack != null && ColorStyle != null) { + foreach (var span in chunk.SpanStack) { + if (span == null || string.IsNullOrEmpty (span.Color)) + continue; + var spanStyle = ColorStyle.GetChunkStyle (span.Color); + if (spanStyle != null && !spanStyle.TransparentBackground && GetPixel (ColorStyle.PlainText.Background) != GetPixel (spanStyle.Background)) { + wrapper.AddBackground (spanStyle.Background, (int)si, (int)ei); + break; + } } } - } - }, delegate(int start, int end) { - if (containsPreedit) { - if (textEditor.preeditOffset < start) - start += (int)preeditLength; - if (textEditor.preeditOffset < end) - end += (int)preeditLength; - } - 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); - var color = !SelectionColor.TransparentForeground ? SelectionColor.Foreground : ColorStyle.GetForeground (chunkStyle); - foreach (var marker in markers) { - var chunkMarker = marker as IChunkMarker; - if (chunkMarker == null) - continue; - chunkMarker.ChangeForeColor (textEditor, chunk, ref color); - } - atts.AddForegroundAttribute ((HslColor)color, si, ei); - if (!wrapper.StartSet) - wrapper.SelectionStartIndex = (int)si; - wrapper.SelectionEndIndex = (int)ei; - }); + }, delegate (int start, int end) { + if (containsPreedit) { + if (textEditor.preeditOffset < start) + start += (int)preeditLength; + if (textEditor.preeditOffset < end) + end += (int)preeditLength; + } + 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); + var color = !SelectionColor.TransparentForeground ? SelectionColor.Foreground : ColorStyle.GetForeground (chunkStyle); + foreach (var marker in markers) { + var chunkMarker = marker as IChunkMarker; + if (chunkMarker == null) + continue; + chunkMarker.ChangeForeColor (textEditor, chunk, ref color); + } + atts.AddForegroundAttribute ((HslColor)color, si, ei); + if (!wrapper.StartSet) + wrapper.SelectionStartIndex = (int)si; + wrapper.SelectionEndIndex = (int)ei; + }); - var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex); - var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex); + var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex); + var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex); - if (chunkStyle.FontWeight != Xwt.Drawing.FontWeight.Normal) - atts.AddWeightAttribute ((Pango.Weight)chunkStyle.FontWeight, translatedStartIndex, translatedEndIndex); + if (chunkStyle.FontWeight != Xwt.Drawing.FontWeight.Normal) + atts.AddWeightAttribute ((Pango.Weight)chunkStyle.FontWeight, translatedStartIndex, translatedEndIndex); - if (chunkStyle.FontStyle != Xwt.Drawing.FontStyle.Normal) - atts.AddStyleAttribute ((Pango.Style)chunkStyle.FontStyle, translatedStartIndex, translatedEndIndex); + if (chunkStyle.FontStyle != Xwt.Drawing.FontStyle.Normal) + atts.AddStyleAttribute ((Pango.Style)chunkStyle.FontStyle, translatedStartIndex, translatedEndIndex); - if (chunkStyle.Underline) - atts.AddUnderlineAttribute (Pango.Underline.Single, translatedStartIndex, translatedEndIndex); + if (chunkStyle.Underline) + atts.AddUnderlineAttribute (Pango.Underline.Single, translatedStartIndex, translatedEndIndex); + } } - } - if (containsPreedit) { - var si = TranslateToUTF8Index (lineChars, (uint)(textEditor.preeditOffset - offset), ref curIndex, ref byteIndex); - var ei = TranslateToUTF8Index (lineChars, (uint)(textEditor.preeditOffset - offset + preeditLength), ref curIndex, ref byteIndex); + if (containsPreedit) { + var si = TranslateToUTF8Index (lineChars, (uint)(textEditor.preeditOffset - offset), ref curIndex, ref byteIndex); + var ei = TranslateToUTF8Index (lineChars, (uint)(textEditor.preeditOffset - offset + preeditLength), ref curIndex, ref byteIndex); - if (textEditor.GetTextEditorData ().IsCaretInVirtualLocation) { - uint len = (uint)textEditor.GetTextEditorData ().GetIndentationString (textEditor.Caret.Location).Length; - si += len; - ei += len; - } - - atts.AddForegroundAttribute ((HslColor)ColorStyle.PlainText.Foreground, si, ei); - var hasBackground = wrapper.BackgroundColors.Any (bg => bg.FromIdx <= si && bg.ToIdx >= ei); - if (hasBackground) - atts.AddBackgroundAttribute ((HslColor)ColorStyle.PlainText.Background, si, ei); - atts.InsertOffsetList (textEditor.preeditAttrs, si, ei); - } - wrapper.LineChars = lineChars; - wrapper.Layout.SetText (lineText); - wrapper.IndentSize = 0; - var tabSize = textEditor.Options != null ? textEditor.Options.TabSize : 4; - for (int i = 0; i < lineChars.Length; i++) { - char ch = lineChars [i]; - if (ch == ' ') { - wrapper.IndentSize ++; - } else if (ch == '\t') { - wrapper.IndentSize = GetNextTabstop (textEditor.GetTextEditorData (), wrapper.IndentSize, tabSize); - } else { - break; + if (textEditor.GetTextEditorData ().IsCaretInVirtualLocation) { + uint len = (uint)textEditor.GetTextEditorData ().GetIndentationString (textEditor.Caret.Location).Length; + si += len; + ei += len; + } + + atts.AddForegroundAttribute ((HslColor)ColorStyle.PlainText.Foreground, si, ei); + var hasBackground = wrapper.BackgroundColors.Any (bg => bg.FromIdx <= si && bg.ToIdx >= ei); + if (hasBackground) + atts.AddBackgroundAttribute ((HslColor)ColorStyle.PlainText.Background, si, ei); + atts.InsertOffsetList (textEditor.preeditAttrs, si, ei); + } + wrapper.LineChars = lineChars; + wrapper.Layout.SetText (lineText); + wrapper.IndentSize = 0; + var tabSize = textEditor.Options != null ? textEditor.Options.TabSize : 4; + for (int i = 0; i < lineChars.Length; i++) { + char ch = lineChars [i]; + if (ch == ' ') { + wrapper.IndentSize++; + } else if (ch == '\t') { + wrapper.IndentSize = GetNextTabstop (textEditor.GetTextEditorData (), wrapper.IndentSize, tabSize); + } else { + break; + } } - } - var nextLine = line.NextLine; - wrapper.EolSpanStack = nextLine != null ? nextLine.StartSpan : null; - atts.AssignTo (wrapper.Layout); - atts.Dispose (); - int w, h; - wrapper.Layout.GetSize (out w, out h); - wrapper.Width = System.Math.Floor (w / Pango.Scale.PangoScale); - wrapper.Height = System.Math.Floor (h / Pango.Scale.PangoScale); + var nextLine = line.NextLine; + wrapper.EolSpanStack = nextLine != null ? nextLine.StartSpan : null; + atts.AssignTo (wrapper.Layout); + atts.Dispose (); + int w, h; + wrapper.Layout.GetSize (out w, out h); + wrapper.Width = System.Math.Floor (w / Pango.Scale.PangoScale); + wrapper.Height = System.Math.Floor (h / Pango.Scale.PangoScale); + + var lines = wrapper.Layout.LineCount; + + if (lines == 1) { + wrapper.LastLineWidth = wrapper.Width; + } else { + var layoutLine = wrapper.Layout.GetLine (lines - 1); + Pango.Rectangle iR = Pango.Rectangle.Zero; + Pango.Rectangle lR = Pango.Rectangle.Zero; + layoutLine.GetExtents (ref iR, ref lR); + wrapper.LastLineWidth = System.Math.Floor (lR.Width / Pango.Scale.PangoScale); + } - var lines = wrapper.Layout.LineCount; - if (lines == 1) { - wrapper.LastLineWidth = wrapper.Width; - } else { - var layoutLine = wrapper.Layout.GetLine (lines - 1); - Pango.Rectangle iR = Pango.Rectangle.Zero; - Pango.Rectangle lR = Pango.Rectangle.Zero; - layoutLine.GetExtents (ref iR, ref lR); - wrapper.LastLineWidth = System.Math.Floor (lR.Width / Pango.Scale.PangoScale); + selectionStart = System.Math.Max (line.Offset - 1, selectionStart); + selectionEnd = System.Math.Min (line.EndOffsetIncludingDelimiter + 1, selectionEnd); + descriptor = new LayoutDescriptor (line, offset, length, wrapper, selectionStart, selectionEnd); + if (!containsPreedit) { + layoutDict [line] = descriptor; + } + // textEditor.GetTextEditorData ().HeightTree.SetLineHeight (line.LineNumber, System.Math.Max (LineHeight, wrapper.Height)); + return wrapper; + } finally { + sw.Stop (); } - - - selectionStart = System.Math.Max (line.Offset - 1, selectionStart); - selectionEnd = System.Math.Min (line.EndOffsetIncludingDelimiter + 1, selectionEnd); - descriptor = new LayoutDescriptor (line, offset, length, wrapper, selectionStart, selectionEnd); - if (!containsPreedit) - layoutDict [line] = descriptor; -// textEditor.GetTextEditorData ().HeightTree.SetLineHeight (line.LineNumber, System.Math.Max (LineHeight, wrapper.Height)); - return wrapper; } public void RemoveCachedLine (DocumentLine line) diff --git a/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json b/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json index 9289beff15..75b35b1085 100644 --- a/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/DefaultStyle.json @@ -191,6 +191,7 @@ { "name":"User Types(Delegates)", "fore":"skyblue2" }, { "name":"User Types(Value types)", "fore":"skyblue2" }, { "name":"User Types(Type parameters)", "fore":"skyblue2" }, + { "name":"User Types(Mutable)", "fore":"aluminium1", "back":"invalid-red" }, { "name":"User Field Usage", "fore":"text-black" }, { "name":"User Field Declaration", "fore":"text-black" }, diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/IBuildTarget.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/IBuildTarget.cs index 1e31ca4df0..4838362f9d 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/IBuildTarget.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/IBuildTarget.cs @@ -66,6 +66,13 @@ namespace MonoDevelop.Projects bool CanExecute (ExecutionContext context, ConfigurationSelector configuration); /// <summary> + /// Determines whether this target can be built using the specified configuration. + /// </summary> + /// <returns><c>true</c> if this instance can be built; otherwise, <c>false</c>.</returns> + /// <param name="configuration">Configuration.</param> + bool CanBuild (ConfigurationSelector configuration); + + /// <summary> /// Prepares the target for execution /// </summary> /// <returns>The execution.</returns> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index 5258723bc1..11570a89bf 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -1437,10 +1437,7 @@ namespace MonoDevelop.Projects } if (UsingMSBuildEngine (configuration)) { - var result = await RunMSBuildTarget (monitor, "Clean", configuration, context); - if (!result.BuildResult.Failed) - SetFastBuildCheckClean (configuration); - return result; + return await RunMSBuildTarget (monitor, "Clean", configuration, context); } monitor.Log.WriteLine ("Removing output files..."); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs index 642afc4621..5b5697fc85 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs @@ -488,6 +488,7 @@ namespace MonoDevelop.Projects pf.Project = null; pf.VirtualPathChanged = null; pf.PathChanged = null; + pf.BackingItem = null; return pf; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItem.cs index 8edff833dc..dfd1fc06e3 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectItem.cs @@ -69,7 +69,7 @@ namespace MonoDevelop.Projects } set { backingItem = value; - UnevaluatedInclude = backingItem.Include; + UnevaluatedInclude = backingItem?.Include; } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs index 4235c0fe1c..ded10dee83 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Solution.cs @@ -630,6 +630,11 @@ namespace MonoDevelop.Projects } } + bool IBuildTarget.CanBuild (ConfigurationSelector configuration) + { + return true; + } + public Task<BuildResult> Clean (ProgressMonitor monitor, string configuration) { return Clean (monitor, (SolutionConfigurationSelector) configuration); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs index a4368996c8..f290e327e4 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolder.cs @@ -564,6 +564,11 @@ namespace MonoDevelop.Projects return null; } + bool IBuildTarget.CanBuild (ConfigurationSelector configuration) + { + return true; + } + public async Task<BuildResult> Clean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext = null) { if (ParentSolution == null) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs index 7887b13f3d..1bf201f4cf 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs @@ -468,6 +468,11 @@ namespace MonoDevelop.Projects get { return fileStatusTracker.ItemFilesChanged; } } + bool IBuildTarget.CanBuild (ConfigurationSelector configuration) + { + return SupportsBuild (); + } + public bool SupportsBuild () { return ItemExtension.OnGetSupportedFeatures ().HasFlag (ProjectFeatures.Build); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Workspace.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Workspace.cs index 1604358c93..2a6342bfdc 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Workspace.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Workspace.cs @@ -73,6 +73,11 @@ namespace MonoDevelop.Projects base.OnDispose (); } + bool IBuildTarget.CanBuild (ConfigurationSelector configuration) + { + return true; + } + [ThreadSafe] public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs index bbf681d4b7..bac92d6f21 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest.Results/GtkWidgetResult.cs @@ -446,12 +446,13 @@ namespace MonoDevelop.Components.AutoTest.Results return; } - Cairo.Context cr = Gdk.CairoHelper.Create (resultWidget.GdkWindow); - cr.SetSourceRGB (1.0, 0.0, 0.0); + using (var cr = Gdk.CairoHelper.Create (resultWidget.GdkWindow)) { + cr.SetSourceRGB (1.0, 0.0, 0.0); - Gdk.Rectangle allocation = resultWidget.Allocation; - Gdk.CairoHelper.Rectangle (cr, allocation); - cr.Stroke (); + Gdk.Rectangle allocation = resultWidget.Allocation; + Gdk.CairoHelper.Rectangle (cr, allocation); + cr.Stroke (); + } } public override void Flash () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs index f69f95cc89..daacba7a22 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs @@ -345,7 +345,7 @@ namespace MonoDevelop.Components.MainToolbar bool SelectActiveRuntime (ref bool selected, ref ExecutionTarget defaultTarget, ref int defaultIter) { var runtimes = ToolbarView.RuntimeModel.Cast<RuntimeModel> ().ToList (); - string lastRuntimeForProject = currentStartupProject.UserProperties.GetValue<string> ("PreferredExecutionTarget", defaultValue: null); + string lastRuntimeForProject = currentStartupProject?.UserProperties.GetValue<string> ("PreferredExecutionTarget", defaultValue: null); var activeTarget = IdeApp.Workspace.ActiveExecutionTarget; var activeTargetId = activeTarget != null ? activeTarget.Id : null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs index 189f21b7c7..9ad1fba8bc 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs @@ -191,9 +191,9 @@ namespace MonoDevelop.Components.MainToolbar return; if (region.Length <= 0) { if (Pattern.LineNumber == 0) { - IdeApp.Workbench.OpenDocument (SelectedItemFileName); + IdeApp.Workbench.OpenDocument (SelectedItemFileName, project: null); } else { - IdeApp.Workbench.OpenDocument (SelectedItemFileName, Pattern.LineNumber, Pattern.HasColumn ? Pattern.Column : 1); + IdeApp.Workbench.OpenDocument (SelectedItemFileName, null, Pattern.LineNumber, Pattern.HasColumn ? Pattern.Column : 1); } } else { IdeApp.Workbench.OpenDocument (new FileOpenInformation (SelectedItemFileName, null) { @@ -304,21 +304,23 @@ namespace MonoDevelop.Components.MainToolbar Task.WhenAll (collectors.Select (c => c.Task)).ContinueWith (t => { if (t.IsCanceled) - return; - if (t.IsFaulted) { - LoggingService.LogError ("Error getting search results", t.Exception); - } else { - Application.Invoke (delegate { - RemoveTimeout (); - if (token.IsCancellationRequested) - return; - foreach (var col in collectors) { - ShowResult (col.Category, col.Results); - } - isInSearch = false; - AnimatedResize (); - }); - } + return;
+ Application.Invoke (delegate {
+ RemoveTimeout ();
+ if (token.IsCancellationRequested)
+ return;
+ foreach (var col in collectors) {
+ if (col.Task.IsCanceled) {
+ continue;
+ } else if (col.Task.IsFaulted) { + LoggingService.LogError ($"Error getting search results for {col.Category}", col.Task.Exception);
+ } else {
+ ShowResult (col.Category, col.Results);
+ }
+ }
+ isInSearch = false;
+ AnimatedResize (); + }); }, token); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs index e8e78b0a62..9c55d54b90 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs @@ -272,7 +272,12 @@ namespace MonoDevelop.Components.MainToolbar public override bool IsValid { get { if (ci == null) { + //GetCommandInfo throws exception if GetActionCommand returns null + if (CommandManager.ToCommandId (IdeApp.CommandService.GetActionCommand (command.Id)) == null) { + return false; + } DispatchService.GuiSyncDispatch (delegate { + ci = IdeApp.CommandService.GetCommandInfo (command.Id, new CommandTargetRoute (MainToolbar.LastCommandTarget)); }); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileChooserAction.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileChooserAction.cs index 0ce8ea0e45..1136f7bde7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileChooserAction.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/FileChooserAction.cs @@ -27,30 +27,32 @@ using System; namespace MonoDevelop.Components { + [Flags] public enum FileChooserAction { - Open, - Save, - SelectFolder, - CreateFolder, + Open = 0x1, + Save = 0x2, + SelectFolder = 0x4, + CreateFolder = 0x8, + + FolderFlags = CreateFolder | SelectFolder, + FileFlags = Open | Save, } static class FileChooserActionExtensions { public static Gtk.FileChooserAction ToGtkAction(this FileChooserAction action) { - switch (action) { - case FileChooserAction.Open: + if ((action & FileChooserAction.CreateFolder) != 0) + return Gtk.FileChooserAction.CreateFolder; + else if ((action & FileChooserAction.SelectFolder) != 0) + return Gtk.FileChooserAction.SelectFolder; + else if ((action & FileChooserAction.Open) != 0) return Gtk.FileChooserAction.Open; - case FileChooserAction.Save: + else if ((action & FileChooserAction.Save) != 0) return Gtk.FileChooserAction.Save; - case FileChooserAction.SelectFolder: - return Gtk.FileChooserAction.SelectFolder; - case FileChooserAction.CreateFolder: - return Gtk.FileChooserAction.CreateFolder; - default: + else throw new NotSupportedException (); - } } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormatterService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormatterService.cs index 6459b3b821..3c028ac631 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormatterService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeFormatting/CodeFormatterService.cs @@ -83,7 +83,7 @@ namespace MonoDevelop.Ide.CodeFormatting if (fmt == null) return; if (fmt.SupportsOnTheFlyFormatting) { - fmt.OnTheFlyFormat (editor, ctx, segment.Offset, segment.EndOffset); + fmt.OnTheFlyFormat (editor, ctx, segment); return; } editor.Text = fmt.FormatText (ctx.HasProject ? ctx.Project.Policies : null, editor.Text, segment); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs index 376002197d..d3f0f3a801 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs @@ -452,7 +452,7 @@ namespace MonoDevelop.Ide.CodeTemplates if (prettyPrinter != null && prettyPrinter.SupportsOnTheFlyFormatting) { int endOffset = template.InsertPosition + template.Code.Length; var oldVersion = data.Version; - prettyPrinter.OnTheFlyFormat (editor, context, template.InsertPosition, endOffset); + prettyPrinter.OnTheFlyFormat (editor, context, TextSegment.FromBounds (template.InsertPosition, endOffset)); foreach (var textLink in template.TextLinks) { for (int i = 0; i < textLink.Links.Count; i++) { var segment = textLink.Links [i]; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs index 568003eb4a..dfeea4fe2d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs @@ -39,6 +39,7 @@ using MonoDevelop.Ide.Projects; using MonoDevelop.Ide.Desktop; using System.Linq; using MonoDevelop.Components; +using MonoDevelop.Components.Extensions; namespace MonoDevelop.Ide.Commands { @@ -294,7 +295,7 @@ namespace MonoDevelop.Ide.Commands protected override void Run (object dataItem) { - IdeApp.Workbench.OpenDocument ((string)dataItem); + IdeApp.Workbench.OpenDocument ((string)dataItem, project: null); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs index 79f19fb9ac..03a3f1bff2 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs @@ -173,7 +173,7 @@ namespace MonoDevelop.Ide.Commands { if (IdeApp.Workspace.IsOpen) { IBuildTarget buildTarget = IdeApp.ProjectOperations.CurrentSelectedBuildTarget; - info.Enabled = (buildTarget != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted); + info.Enabled = (buildTarget != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted) && buildTarget.CanBuild (IdeApp.Workspace.ActiveConfiguration); if (buildTarget != null) { info.Text = GettextCatalog.GetString ("B_uild {0}", buildTarget.Name.Replace ("_","__")); if (buildTarget is SolutionFolder) @@ -214,7 +214,7 @@ namespace MonoDevelop.Ide.Commands { if (IdeApp.Workspace.IsOpen) { IBuildTarget buildTarget = IdeApp.ProjectOperations.CurrentSelectedBuildTarget; - info.Enabled = (buildTarget != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted); + info.Enabled = (buildTarget != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted) && buildTarget.CanBuild (IdeApp.Workspace.ActiveConfiguration); if (buildTarget != null) { info.Text = GettextCatalog.GetString ("R_ebuild {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name.Replace ("_","__")); info.Description = GettextCatalog.GetString ("Rebuild {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name); @@ -349,6 +349,7 @@ namespace MonoDevelop.Ide.Commands if (IdeApp.ProjectOperations.CurrentSelectedBuildTarget == null) info.Enabled = false; else { + info.Enabled = IdeApp.ProjectOperations.CurrentSelectedBuildTarget.CanBuild (IdeApp.Workspace.ActiveConfiguration); info.Text = GettextCatalog.GetString ("C_lean {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name.Replace ("_","__")); info.Description = GettextCatalog.GetString ("Clean {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs index 4b3f30e788..e6e69d3824 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs @@ -37,6 +37,7 @@ using MonoDevelop.Core; using MonoDevelop.Ide.Extensions; using MonoDevelop.Ide.Tasks; using MonoDevelop.Projects; +using System.Threading.Tasks; namespace MonoDevelop.Ide.CustomTools { @@ -250,32 +251,65 @@ namespace MonoDevelop.Ide.CustomTools TaskService.Errors.ClearByOwner (file); - //if this file is already being run, cancel it + TaskInfo runningTask; + TaskCompletionSource<bool> newTask = new TaskCompletionSource<bool> (); + var result = new SingleFileCustomToolResult (); + Task existingTask = null; + CancellationTokenSource cs = new CancellationTokenSource (); + + // if this file is already being run, cancel it + lock (runningTasks) { - TaskInfo runningTask; if (runningTasks.TryGetValue (file.FilePath, out runningTask)) { runningTask.CancellationTokenSource.Cancel (); runningTasks.Remove (file.FilePath); + existingTask = runningTask.Task; } + runningTask = new TaskInfo { Task = newTask.Task, CancellationTokenSource = cs, Result = result }; + runningTasks.Add (file.FilePath, runningTask); } - CancellationTokenSource cs = new CancellationTokenSource (); + // If a task was already running, wait for it to finish. Running the same task in parallel may lead + // to file sharing violation errors + + if (existingTask != null) { + try { + await existingTask; + } catch { + // Ignore exceptions, they are handled elsewhere + } + } + + // Maybe I was cancelled while I was waiting. In that case, the task has already been removed from + // the runningTasks collection + + if (cs.IsCancellationRequested) + return; + + // Execute the generator + + Exception error = null; var monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (false).WithCancellationSource (cs); - var result = new SingleFileCustomToolResult (); + try { monitor.BeginTask (GettextCatalog.GetString ("Running generator '{0}' on file '{1}'...", file.Generator, file.Name), 1); - var op = tool.Generate (monitor, file, result); - lock (runningTasks) { - runningTasks.Add (file.FilePath, new TaskInfo { Task = op, CancellationTokenSource = cs, Result = result }); + + try { + await tool.Generate (monitor, file, result); + } catch (Exception ex) { + error = ex; + result.UnhandledException = ex; } - await op; + + // Generation has finished. Remove the task from the runningTasks collection + lock (runningTasks) { - TaskInfo runningTask; - if (runningTasks.TryGetValue (file.FilePath, out runningTask) && runningTask.Task == op) { + TaskInfo registeredTask; + if (runningTasks.TryGetValue (file.FilePath, out registeredTask) && registeredTask == runningTask) { runningTasks.Remove (file.FilePath); UpdateCompleted (monitor, file, genFile, result, false); } else { - //it was cancelled because another was run for the same file, so just clean up + // it was cancelled because another was run for the same file, so just clean up monitor.EndTask (); monitor.ReportWarning (GettextCatalog.GetString ("Cancelled because generator ran again for the same file")); monitor.Dispose (); @@ -284,6 +318,12 @@ namespace MonoDevelop.Ide.CustomTools } catch (Exception ex) { result.UnhandledException = ex; UpdateCompleted (monitor, file, genFile, result, false); + } finally { + if (error == null) + newTask.SetResult (true); + else { + newTask.SetException (error); + } } } @@ -408,7 +448,7 @@ namespace MonoDevelop.Ide.CustomTools return ns; } - public static bool WaitForRunningTools (ProgressMonitor monitor) + public static Task WaitForRunningTools (ProgressMonitor monitor) { TaskInfo[] operations; lock (runningTasks) { @@ -416,30 +456,30 @@ namespace MonoDevelop.Ide.CustomTools } if (operations.Length == 0) - return true; + return Task.FromResult (true); monitor.BeginTask ("Waiting for custom tools...", operations.Length); - var evt = new AutoResetEvent (false); + List<Task> tasks = new List<Task> (); foreach (var t in operations) { - t.Task.ContinueWith (ta => { - monitor.Step (1); - if (operations.All (op => op.Task.IsCompleted)) - evt.Set (); - }); + tasks.Add (t.Task.ContinueWith (ta => { + if (!monitor.CancellationToken.IsCancellationRequested) + monitor.Step (1); + })); } - monitor.CancellationToken.Register (delegate { - evt.Set (); - }); - - evt.WaitOne (); + var cancelTask = new TaskCompletionSource<bool> (); + var allDone = Task.WhenAll (tasks); - monitor.EndTask (); + var cancelReg = monitor.CancellationToken.Register (() => { + cancelTask.SetResult (true); + }); - //the tool operations display warnings themselves - return operations.Any (op => !op.Result.SuccessWithWarnings); + return Task.WhenAny (allDone, cancelTask.Task).ContinueWith (t => { + monitor.EndTask (); + cancelReg.Dispose (); + }); } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs new file mode 100644 index 0000000000..33c015e4a7 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs @@ -0,0 +1,36 @@ +// +// AbstractNavigationExtension.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com) +// +// 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 System; +namespace MonoDevelop.Ide.Editor.Extension +{ + public class AbstractNavigationExtension + { + public AbstractNavigationExtension () + { + } + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractUsagesExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractUsagesExtension.cs index 186860ca86..3c80bf6d19 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractUsagesExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractUsagesExtension.cs @@ -128,7 +128,7 @@ namespace MonoDevelop.Ide.Editor.Extension /// <returns>The references.</returns> /// <param name="resolveResult">The resolve result given in 'TryResolve'.</param> /// <param name="token">A cancellation token to cancel the operation.</param> - protected abstract IEnumerable<MemberReference> GetReferences (T resolveResult, CancellationToken token); + protected abstract Task<IEnumerable<MemberReference>> GetReferencesAsync (T resolveResult, CancellationToken token); async void DelayedTooltipShow () { @@ -142,16 +142,13 @@ namespace MonoDevelop.Ide.Editor.Extension ClearQuickTasks (); return; } - - Task.Run (delegate { - var list = GetReferences (result, token).ToList (); - if (!token.IsCancellationRequested) { - Gtk.Application.Invoke (delegate { - if (!token.IsCancellationRequested) - ShowReferences (list); - }); - } - }); + var list = await GetReferencesAsync (result, token); + if (!token.IsCancellationRequested) { + Gtk.Application.Invoke (delegate { + if (!token.IsCancellationRequested) + ShowReferences (list); + }); + } } catch (Exception e) { LoggingService.LogError ("Unhandled Exception in HighlightingUsagesExtension", e); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs index d71c68b6bd..f6448bcc37 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs @@ -445,6 +445,10 @@ namespace MonoDevelop.Ide.Editor.Highlighting [ColorDescription(UserTypesTypeParametersKey, VSSetting = "User Types(Type parameters)")] public ChunkStyle UserTypesTypeParameters { get; private set; } + public const string UserTypesMutableKey = "User Types(Mutable)"; + [ColorDescription(UserTypesMutableKey, VSSetting = "User Types(Mutable")] + public ChunkStyle UserTypesMutable { get; private set; } + public const string UserFieldUsageKey = "User Field Usage"; [ColorDescription(UserFieldUsageKey, VSSetting = "Identifier")] public ChunkStyle UserFieldUsage { get; private set; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs index 3f60819204..7d58d9f4d3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs @@ -31,14 +31,6 @@ using MonoDevelop.Ide.Editor.Extension; namespace MonoDevelop.Ide.Editor { - [Obsolete ("Use WordNavigationStyle")] - public enum ControlLeftRightMode - { - MonoDevelop, - Emacs, - SharpDevelop - } - public enum WordNavigationStyle { Unix, @@ -246,11 +238,8 @@ namespace MonoDevelop.Ide.Editor DefaultSourceEditorOptions (TextStylePolicy currentPolicy) { - var defaultControlMode = (ControlLeftRightMode)Enum.Parse (typeof(ControlLeftRightMode), DesktopService.DefaultControlLeftRightBehavior); - controlLeftRightMode = ConfigurationProperty.Create ("ControlLeftRightMode", defaultControlMode); - WordNavigationStyle defaultWordNavigation = WordNavigationStyle.Unix; - if (Platform.IsWindows || controlLeftRightMode.Value == ControlLeftRightMode.SharpDevelop) { + if (Platform.IsWindows) { defaultWordNavigation = WordNavigationStyle.Windows; } wordNavigationStyle = ConfigurationProperty.Create ("WordNavigationStyle", defaultWordNavigation); @@ -439,18 +428,6 @@ namespace MonoDevelop.Ide.Editor } } } - - ConfigurationProperty<ControlLeftRightMode> controlLeftRightMode; - [Obsolete("Use WordNavigationStyle")] - public ControlLeftRightMode ControlLeftRightMode { - get { - return controlLeftRightMode; - } - set { - if (controlLeftRightMode.Set (value)) - OnChanged (EventArgs.Empty); - } - } ConfigurationProperty<WordNavigationStyle> wordNavigationStyle; public WordNavigationStyle WordNavigationStyle { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs index c00d0ee970..661e23c914 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs @@ -680,6 +680,7 @@ namespace MonoDevelop.Ide.Editor [CommandUpdateHandler (EditCommands.ToggleCodeComment)] void OnUpdateToggleComment (CommandInfo info) { + info.Bypass = true; var lineComments = TextEditorFactory.GetSyntaxProperties (textEditor.MimeType, "LineComment"); if (lineComments != null && lineComments.Length > 0) { info.Visible = true; @@ -801,7 +802,7 @@ namespace MonoDevelop.Ide.Editor var anchor = textEditor.SelectionAnchorOffset; int lines = 0; - IDocumentLine first = null; + //IDocumentLine first = null; IDocumentLine last = null; var oldVersion = textEditor.Version; foreach (var line in GetSelectedLines (textEditor)) { @@ -811,7 +812,7 @@ namespace MonoDevelop.Ide.Editor lines++; } - first = line; + //first = line; if (last == null) last = line; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs index e1bb7cf4b4..30b9bdca95 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs @@ -698,7 +698,7 @@ namespace MonoDevelop.Ide.FindInFiles if (result != null) { var loc = GetLocation (result); store.SetValue (iter, DidReadColumn, true); - IdeApp.Workbench.OpenDocument (result.FileName, loc.Line, loc.Column); + IdeApp.Workbench.OpenDocument (result.FileName, null, loc.Line, loc.Column); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs index 6f48569971..e81704dc8e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/LogView.cs @@ -111,8 +111,11 @@ namespace MonoDevelop.Ide.Gui.Components var clipboard = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); clipboard.Text = text; - clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false)); - clipboard.Text = text; + if (Platform.IsLinux) { + // gtk has different clipboards for CLIPBOARD and PRIMARY only on Linux. + clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false)); + clipboard.Text = text; + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ReferenceNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ReferenceNodeBuilder.cs index e6292949ca..ae7b59f8f4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ReferenceNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ReferenceNodeBuilder.cs @@ -123,7 +123,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad ProjectReference pref = CurrentNode.DataItem as ProjectReference; if (pref != null) { foreach (string fileName in pref.GetReferencedFileNames (IdeApp.Workspace.ActiveConfiguration)) - IdeApp.Workbench.OpenDocument (fileName); + IdeApp.Workbench.OpenDocument (fileName, project: null); } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ImplicitFrameworkAssemblyReferenceNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ImplicitFrameworkAssemblyReferenceNodeBuilder.cs index 08233fc98f..e42d8e6dd4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ImplicitFrameworkAssemblyReferenceNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ImplicitFrameworkAssemblyReferenceNodeBuilder.cs @@ -74,7 +74,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public override void ActivateItem () { var aref = (ImplicitFrameworkAssemblyReference) CurrentNode.DataItem; - IdeApp.Workbench.OpenDocument (aref.Assembly.Location); + IdeApp.Workbench.OpenDocument (aref.Assembly.Location, project: null); } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs index 497cd3a870..353cae8399 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderFileNodeBuilder.cs @@ -119,7 +119,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public override void ActivateItem () { SolutionFolderFileNode file = (SolutionFolderFileNode) CurrentNode.DataItem; - IdeApp.Workbench.OpenDocument (file.FileName); + IdeApp.Workbench.OpenDocument (file.FileName, project: null); } public override DragOperation CanDragNode () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderNodeBuilder.cs index d2ff61eff9..2888fc3365 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionFolderNodeBuilder.cs @@ -120,17 +120,27 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad if (tb != null) tb.Update (); } - void OnEntryAdded (object sender, SolutionItemEventArgs e) + void OnEntryAdded (object sender, SolutionItemChangeEventArgs e) { ITreeBuilder tb = Context.GetTreeBuilder (e.SolutionItem.ParentFolder); if (tb != null) { - tb.AddChild (e.SolutionItem, true); - tb.Expanded = true; + if (e.Reloading) + // When reloading we ignore the removed event, and we do an UpdateAll here. This will + // replace the reloaded instance and will preserve the tree status + tb.UpdateAll (); + else { + tb.AddChild (e.SolutionItem, true); + tb.Expanded = true; + } } } - void OnEntryRemoved (object sender, SolutionItemEventArgs e) + void OnEntryRemoved (object sender, SolutionItemChangeEventArgs e) { + // If reloading, ignore the event. We handle it in OnEntryAdded. + if (e.Reloading) + return; + ITreeBuilder tb = Context.GetTreeBuilder (e.SolutionItem); if (tb != null) tb.Remove (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionNodeBuilder.cs index 82d17cde9c..02bd790d3b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SolutionNodeBuilder.cs @@ -144,13 +144,23 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad { ITreeBuilder tb = Context.GetTreeBuilder (e.SolutionItem.ParentSolution); if (tb != null) { - tb.AddChild (e.SolutionItem, true); - tb.Expanded = true; + if (e.Reloading) + // When reloading we ignore the removed event, and we do an UpdateAll here. This will + // replace the reloaded instance and will preserve the tree status + tb.UpdateAll (); + else { + tb.AddChild (e.SolutionItem, true); + tb.Expanded = true; + } } } void OnEntryRemoved (object sender, SolutionItemChangeEventArgs e) { + // If reloading, ignore the event. We handle it in OnEntryAdded. + if (e.Reloading) + return; + ITreeBuilder tb = Context.GetTreeBuilder (e.SolutionItem); if (tb != null) tb.Remove (); @@ -311,7 +321,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public void OnEditSolution () { var solution = (Solution) CurrentNode.DataItem; - IdeApp.Workbench.OpenDocument (solution.FileName); + IdeApp.Workbench.OpenDocument (solution.FileName, project:null); } [CommandUpdateHandler (ProjectCommands.EditSolutionItem)] diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs index 393636a54f..2188ddec1f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs @@ -118,7 +118,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public override void ActivateItem () { SystemFile file = CurrentNode.DataItem as SystemFile; - IdeApp.Workbench.OpenDocument (file.Path); + IdeApp.Workbench.OpenDocument (file.Path, project: null); } public override void DeleteMultipleItems () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/UnknownEntryNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/UnknownEntryNodeBuilder.cs index d831511d57..33ae288549 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/UnknownEntryNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/UnknownEntryNodeBuilder.cs @@ -151,7 +151,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad public void OnEditUnknownSolutionItem () { UnknownSolutionItem si = (UnknownSolutionItem) CurrentNode.DataItem; - IdeApp.Workbench.OpenDocument (si.FileName); + IdeApp.Workbench.OpenDocument (si.FileName, project: null); } [CommandUpdateHandler (ProjectCommands.EditSolutionItem)] diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs index 9282f6fc17..a17fbc3e95 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs @@ -124,7 +124,7 @@ namespace MonoDevelop.Ide.Gui.Pads DockItemToolbar toolbar = window.GetToolbar (DockPositionType.Top); - errorBtn = new ToggleButton (); + errorBtn = new ToggleButton { Name = "toggleErrors" }; errorBtn.Active = ShowErrors; errorBtn.Image = new Gtk.Image (Stock.Error, Gtk.IconSize.Menu); errorBtn.Image.Show (); @@ -133,7 +133,7 @@ namespace MonoDevelop.Ide.Gui.Pads UpdateErrorsNum(); toolbar.Add (errorBtn); - warnBtn = new ToggleButton (); + warnBtn = new ToggleButton { Name = "toggleWarnings" }; warnBtn.Active = ShowWarnings; warnBtn.Image = new Gtk.Image (Stock.Warning, Gtk.IconSize.Menu); warnBtn.Image.Show (); @@ -141,8 +141,8 @@ namespace MonoDevelop.Ide.Gui.Pads warnBtn.TooltipText = GettextCatalog.GetString ("Show Warnings"); UpdateWarningsNum(); toolbar.Add (warnBtn); - - msgBtn = new ToggleButton (); + + msgBtn = new ToggleButton { Name = "toggleMessages" }; msgBtn.Active = ShowMessages; msgBtn.Image = new Gtk.Image (Stock.Information, Gtk.IconSize.Menu); msgBtn.Image.Show (); @@ -153,7 +153,7 @@ namespace MonoDevelop.Ide.Gui.Pads toolbar.Add (new SeparatorToolItem ()); - logBtn = new ToggleButton (); + logBtn = new ToggleButton { Name = "toggleBuildOutput" }; logBtn.Label = GettextCatalog.GetString ("Build Output"); logBtn.Image = ImageService.GetImage ("md-message-log", Gtk.IconSize.Menu); logBtn.Image.Show (); @@ -229,7 +229,7 @@ namespace MonoDevelop.Ide.Gui.Pads control.Add1 (sw); - outputView = new LogView (); + outputView = new LogView { Name = "buildOutput" }; control.Add2 (outputView); control.ShowAll (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs index 0efff2531d..59ebe4460c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs @@ -54,6 +54,8 @@ using Microsoft.CodeAnalysis.Options; using MonoDevelop.Ide.Editor; using MonoDevelop.Ide.Editor.Highlighting; using MonoDevelop.Core.Text; +using MonoDevelop.Components.Extensions; +using MonoDevelop.Projects.SharedAssetsProjects; namespace MonoDevelop.Ide.Gui { @@ -237,7 +239,7 @@ namespace MonoDevelop.Ide.Gui public Task<Microsoft.CodeAnalysis.Compilation> GetCompilationAsync(CancellationToken cancellationToken = default(CancellationToken)) { - var project = TypeSystemService.GetCodeAnalysisProject (Project ?? adhocProject); + var project = TypeSystemService.GetCodeAnalysisProject (adhocProject ?? Project); if (project == null) return new Task<Microsoft.CodeAnalysis.Compilation> (() => null); return project.GetCompilationAsync (cancellationToken); @@ -720,7 +722,7 @@ namespace MonoDevelop.Ide.Gui TypeSystemService.AddSkippedFile (currentParseFile); var currentParseText = editor.CreateDocumentSnapshot (); CancelOldParsing(); - var project = Project ?? adhocProject; + var project = adhocProject ?? Project; var options = new ParseOptions { Project = project, @@ -763,7 +765,7 @@ namespace MonoDevelop.Ide.Gui analysisDocument = null; return SpecializedTasks.EmptyTask; } - if (Project != null && Editor.MimeType == "text/x-csharp") { + if (Project != null && Editor.MimeType == "text/x-csharp" && !IsUnreferencedSharedProject(Project)) { RoslynWorkspace = TypeSystemService.GetWorkspace (this.Project.ParentSolution); analysisDocument = TypeSystemService.GetDocumentId (this.Project, this.FileName); if (analysisDocument != null) { @@ -805,6 +807,12 @@ namespace MonoDevelop.Ide.Gui } return SpecializedTasks.EmptyTask; } + + bool IsUnreferencedSharedProject (Project project) + { + return project is SharedAssetsProject; + } + object adhocProjectLock = new object(); void UnloadAdhocProject () @@ -855,7 +863,7 @@ namespace MonoDevelop.Ide.Gui string mimeType = editor.MimeType; CancelOldParsing (); var token = parseTokenSource.Token; - var project = Project ?? adhocProject; + var project = adhocProject ?? Project; var projectFile = project?.GetProjectFile (currentParseFile); ThreadPool.QueueUserWorkItem (delegate { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs index ea9bbf240d..dbd798402d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs @@ -92,7 +92,7 @@ namespace MonoDevelop.Ide.Gui public Document OpenFile (string filePath, Encoding encoding) { if (binding != null) - return IdeApp.Workbench.OpenDocument (filePath, -1, -1, OpenDocumentOptions.Default, encoding, binding); + return IdeApp.Workbench.OpenDocument (filePath, null, -1, -1, OpenDocumentOptions.Default, encoding, binding); else { app.Launch (filePath); return null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StartupInfo.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StartupInfo.cs index abaa1b0225..9a7e1c5206 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StartupInfo.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StartupInfo.cs @@ -85,7 +85,7 @@ namespace MonoDevelop.Ide.Gui int.TryParse (fileMatch.Groups["line"].Value, out line); if (fileMatch.Groups["column"].Success) int.TryParse (fileMatch.Groups["column"].Value, out column); - var file = new FileOpenInformation (filename, line, column, OpenDocumentOptions.Default); + var file = new FileOpenInformation (filename, null, line, column, OpenDocumentOptions.Default); requestedFileList.Add (file); } } else if (a[0] == '-' || a[0] == '/') { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewFileDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewFileDialog.cs index 693a958f71..9fa9c0c92a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewFileDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewFileDialog.cs @@ -166,10 +166,13 @@ namespace MonoDevelop.Ide.Projects { string key = "Dialogs.NewFileDialog.LastSelectedCategory"; if (proj != null) { - key += "." + proj.GetTypeTags ().First (); - var dnp = proj as DotNetProject; - if (dnp != null) - key += "." + dnp.LanguageName; + string projectType = proj.GetTypeTags ().FirstOrDefault (); + if (projectType != null) { + key += "." + projectType; + var dnp = proj as DotNetProject; + if (dnp != null) + key += "." + dnp.LanguageName; + } } return key; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs index 8ff86d6fbf..1f7eb8dd0a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs @@ -718,7 +718,7 @@ namespace MonoDevelop.Ide.Projects static void RunTemplateActions (ProcessedTemplateResult templateResult)
{
foreach (string action in templateResult.Actions) {
- IdeApp.Workbench.OpenDocument (Path.Combine (templateResult.ProjectBasePath, action));
+ IdeApp.Workbench.OpenDocument (Path.Combine (templateResult.ProjectBasePath, action), project: null);
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs index 269b29b964..4d3a4e0c27 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs @@ -526,7 +526,7 @@ namespace MonoDevelop.Ide.Tasks { TaskListEntry task = SelectedTask; if (task != null && ! String.IsNullOrEmpty (task.FileName)) { - var doc = IdeApp.Workbench.OpenDocument (task.FileName, Math.Max (1, task.Line), Math.Max (1, task.Column)); + var doc = IdeApp.Workbench.OpenDocument (task.FileName, null, Math.Max (1, task.Line), Math.Max (1, task.Column)); if (doc != null && doc.HasProject && doc.Project is DotNetProject) { string[] commentTags = doc.CommentTags; if (commentTags != null && commentTags.Length == 1) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/UserTasksView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/UserTasksView.cs index babddca228..6f76fb1faa 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/UserTasksView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/UserTasksView.cs @@ -98,6 +98,7 @@ namespace MonoDevelop.Ide.Tasks cellRendCompleted.Toggled += new ToggledHandler (UserTaskCompletedToggled); cellRendCompleted.Activatable = true; col = view.AppendColumn (String.Empty, cellRendCompleted, "active", Columns.Completed); + col.SortColumnId = (int)Columns.Completed; cellRendDesc = view.TextRenderer; cellRendDesc.Editable = true; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs index cbc833b176..3b8517e7cd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs @@ -6,6 +6,7 @@ // Michael Hutchinson (mhutchinson@novell.com) // Marek Sieradzki (marek.sieradzki@gmail.com) // Viktoria Dudka (viktoriad@remobjects.com) +// Vincent Dondain (vincent@xamarin.com) // // Copyright (c) 2009 RemObjects Software // @@ -29,229 +30,161 @@ // // - using System; -using MonoDevelop.Core; -using Mono.Addins; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Xml; using Gtk; -using System.Collections.Generic; -using System.Collections; +using Mono.Addins; +using MonoDevelop.Core; using MonoDevelop.Ide.Codons; -using System.Xml; -using System.Linq; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Projects; namespace MonoDevelop.Ide.Templates { - class FileTemplate - { - - - public static List<FileTemplate> fileTemplates = new List<FileTemplate> (); - - - private List<FileDescriptionTemplate> files = new List<FileDescriptionTemplate> (); - public List<FileDescriptionTemplate> Files - { - get { return files; } - } - - private List<FileTemplateCondition> conditions = new List<FileTemplateCondition> (); - public List<FileTemplateCondition> Сonditions - { - get { return conditions; } - } - - private string id = String.Empty; - public string Id - { - get { return id; } - } - - private string icon = String.Empty; - public IconId Icon - { - get { return icon; } - } - - private string category = String.Empty; - public string Category - { - get { return category; } - } - - private string wizardPath = String.Empty; - public string WizardPath - { - get { return wizardPath; } - } - - private string description = String.Empty; - public string Description - { - get { return description; } - } - - private bool isFixedFilename = false; - public bool IsFixedFilename - { - get { return isFixedFilename; } - } - - private string defaultFilename = String.Empty; - public string DefaultFilename - { - get { return defaultFilename; } - } - - public string name = String.Empty; - public string Name - { - get { return name; } - } - - private string languageName = String.Empty; - public string LanguageName - { - get { return languageName; } - } - - private string originator = String.Empty; - public string Originator - { - get { return originator; } - } - - private string created = String.Empty; - public string Created - { - get { return created; } - } - - private string lastModified = String.Empty; - public string LastModified - { - get { return lastModified; } - } - - private string projecttype = String.Empty; - public string ProjectType - { - get { return projecttype; } - } - - - private static FileTemplate LoadFileTemplate (RuntimeAddin addin, ProjectTemplateCodon codon) - { + class FileTemplate + { + public string Category { get; private set; } = String.Empty; + + public List<FileTemplateCondition> Conditions { get; private set; } = new List<FileTemplateCondition> (); + + public string Created { get; private set; } = String.Empty; + + public string DefaultFilename { get; private set; } = String.Empty; + + public string Description { get; private set; } = String.Empty; + + public List<FileDescriptionTemplate> Files { get; private set; } = new List<FileDescriptionTemplate> (); + + public static List<FileTemplate> fileTemplates = new List<FileTemplate> (); + + public IconId Icon { get; private set; } = String.Empty; + + public string Id { get; private set; } = String.Empty; + + public bool IsFixedFilename { get; private set; } + + public string LanguageName { get; private set; } = String.Empty; + + public string LastModified { get; private set; } = String.Empty; + + public string Name { get; private set; } = String.Empty; + + public string Originator { get; private set; } = String.Empty; + + public string ProjectType { get; private set; } = String.Empty; + + public string WizardPath { get; private set; } = String.Empty; + + static FileTemplate LoadFileTemplate (RuntimeAddin addin, ProjectTemplateCodon codon) + { XmlDocument xmlDocument = codon.GetTemplate (); FilePath baseDirectory = codon.BaseDirectory; - //Configuration - XmlElement xmlNodeConfig = xmlDocument.DocumentElement["TemplateConfiguration"]; - - FileTemplate fileTemplate = null; - if (xmlNodeConfig["Type"] != null) { - Type configType = addin.GetType (xmlNodeConfig["Type"].InnerText); - - if (typeof (FileTemplate).IsAssignableFrom (configType)) { - fileTemplate = (FileTemplate)Activator.CreateInstance (configType); - } - else - throw new InvalidOperationException (string.Format ("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig["Type"].InnerText)); - } - else - fileTemplate = new FileTemplate (); - - fileTemplate.originator = xmlDocument.DocumentElement.GetAttribute ("Originator"); - fileTemplate.created = xmlDocument.DocumentElement.GetAttribute ("Created"); - fileTemplate.lastModified = xmlDocument.DocumentElement.GetAttribute ("LastModified"); - - if (xmlNodeConfig["_Name"] != null) { - fileTemplate.name = xmlNodeConfig["_Name"].InnerText; - } - else { - throw new InvalidOperationException (string.Format ("Missing element '_Name' in file template: {0}", codon.Id)); - } - - if (xmlNodeConfig["_Category"] != null) { - fileTemplate.category = xmlNodeConfig["_Category"].InnerText; - } - else { - throw new InvalidOperationException (string.Format ("Missing element '_Category' in file template: {0}", codon.Id)); - } - - if (xmlNodeConfig["LanguageName"] != null) { - fileTemplate.languageName = xmlNodeConfig["LanguageName"].InnerText; - } - - if (xmlNodeConfig["ProjectType"] != null) { - fileTemplate.projecttype = xmlNodeConfig["ProjectType"].InnerText; - } - - if (xmlNodeConfig["_Description"] != null) { - fileTemplate.description = xmlNodeConfig["_Description"].InnerText; - } - - if (xmlNodeConfig["Icon"] != null) { - fileTemplate.icon = ImageService.GetStockId (addin, xmlNodeConfig["Icon"].InnerText, IconSize.Dnd); //xmlNodeConfig["_Description"].InnerText; - } - - if (xmlNodeConfig["Wizard"] != null) { - fileTemplate.icon = xmlNodeConfig["Wizard"].Attributes["path"].InnerText; - } - - if (xmlNodeConfig["DefaultFilename"] != null) { - fileTemplate.defaultFilename = xmlNodeConfig["DefaultFilename"].InnerText; - string isFixed = xmlNodeConfig["DefaultFilename"].GetAttribute ("IsFixed"); + //Configuration + XmlElement xmlNodeConfig = xmlDocument.DocumentElement ["TemplateConfiguration"]; + + FileTemplate fileTemplate; + if (xmlNodeConfig ["Type"] != null) { + Type configType = addin.GetType (xmlNodeConfig ["Type"].InnerText); + + if (typeof(FileTemplate).IsAssignableFrom (configType)) { + fileTemplate = (FileTemplate)Activator.CreateInstance (configType); + } else + throw new InvalidOperationException (string.Format ("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig ["Type"].InnerText)); + } else + fileTemplate = new FileTemplate (); + + fileTemplate.Originator = xmlDocument.DocumentElement.GetAttribute ("Originator"); + fileTemplate.Created = xmlDocument.DocumentElement.GetAttribute ("Created"); + fileTemplate.LastModified = xmlDocument.DocumentElement.GetAttribute ("LastModified"); + + if (xmlNodeConfig ["_Name"] != null) { + fileTemplate.Name = xmlNodeConfig ["_Name"].InnerText; + } else { + throw new InvalidOperationException (string.Format ("Missing element '_Name' in file template: {0}", codon.Id)); + } + + if (xmlNodeConfig ["_Category"] != null) { + fileTemplate.Category = xmlNodeConfig ["_Category"].InnerText; + } else { + throw new InvalidOperationException (string.Format ("Missing element '_Category' in file template: {0}", codon.Id)); + } + + if (xmlNodeConfig ["LanguageName"] != null) { + fileTemplate.LanguageName = xmlNodeConfig ["LanguageName"].InnerText; + } + + if (xmlNodeConfig ["ProjectType"] != null) { + fileTemplate.ProjectType = xmlNodeConfig ["ProjectType"].InnerText; + } + + if (xmlNodeConfig ["_Description"] != null) { + fileTemplate.Description = xmlNodeConfig ["_Description"].InnerText; + } + + if (xmlNodeConfig ["Icon"] != null) { + fileTemplate.Icon = ImageService.GetStockId (addin, xmlNodeConfig ["Icon"].InnerText, IconSize.Dnd); + } + + if (xmlNodeConfig ["Wizard"] != null) { + fileTemplate.Icon = xmlNodeConfig ["Wizard"].Attributes ["path"].InnerText; + } + + if (xmlNodeConfig ["DefaultFilename"] != null) { + fileTemplate.DefaultFilename = xmlNodeConfig ["DefaultFilename"].InnerText; + string isFixed = xmlNodeConfig ["DefaultFilename"].GetAttribute ("IsFixed"); if (isFixed.Length > 0) { bool bFixed; if (bool.TryParse (isFixed, out bFixed)) - fileTemplate.isFixedFilename = bFixed; + fileTemplate.IsFixedFilename = bFixed; else throw new InvalidOperationException ("Invalid value for IsFixed in template."); } - } + } - //Template files - XmlNode xmlNodeTemplates = xmlDocument.DocumentElement["TemplateFiles"]; + //Template files + XmlNode xmlNodeTemplates = xmlDocument.DocumentElement ["TemplateFiles"]; - if(xmlNodeTemplates != null) { - foreach(XmlNode xmlNode in xmlNodeTemplates.ChildNodes) { - if(xmlNode is XmlElement) { - fileTemplate.files.Add ( - FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory)); + if (xmlNodeTemplates != null) { + foreach (XmlNode xmlNode in xmlNodeTemplates.ChildNodes) { + var xmlElement = xmlNode as XmlElement; + if (xmlElement != null) { + fileTemplate.Files.Add ( + FileDescriptionTemplate.CreateTemplate (xmlElement, baseDirectory)); } } } - //Conditions - XmlNode xmlNodeConditions = xmlDocument.DocumentElement["Conditions"]; - if(xmlNodeConditions != null) { - foreach(XmlNode xmlNode in xmlNodeConditions.ChildNodes) { - if(xmlNode is XmlElement) { - fileTemplate.conditions.Add (FileTemplateCondition.CreateCondition ((XmlElement)xmlNode)); + //Conditions + XmlNode xmlNodeConditions = xmlDocument.DocumentElement ["Conditions"]; + if (xmlNodeConditions != null) { + foreach (XmlNode xmlNode in xmlNodeConditions.ChildNodes) { + var xmlElement = xmlNode as XmlElement; + if (xmlElement != null) { + fileTemplate.Conditions.Add (FileTemplateCondition.CreateCondition (xmlElement)); } } } - return fileTemplate; - } + return fileTemplate; + } - static FileTemplate() - { - AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/FileTemplates", OnExtensionChanged); - } + static FileTemplate () + { + AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/FileTemplates", OnExtensionChanged); + } static void OnExtensionChanged (object s, ExtensionNodeEventArgs args) - { - if (args.Change == ExtensionChange.Add) { - ProjectTemplateCodon codon = (ProjectTemplateCodon) args.ExtensionNode; - try { - FileTemplate t = LoadFileTemplate (codon.Addin, codon); - t.id = codon.Id; - fileTemplates.Add (t); + { + if (args.Change == ExtensionChange.Add) { + var codon = (ProjectTemplateCodon)args.ExtensionNode; + try { + FileTemplate t = LoadFileTemplate (codon.Addin, codon); + t.Id = codon.Id; + fileTemplates.Add (t); } catch (Exception e) { string extId = null, addinId = null; if (codon != null) { @@ -261,19 +194,18 @@ namespace MonoDevelop.Ide.Templates addinId = codon.Addin.Id; } LoggingService.LogError ("Error loading template id {0} in addin {1}:\n{2}", - extId ?? "(null)", addinId ?? "(null)", e.ToString ()); + extId ?? "(null)", addinId ?? "(null)", e.ToString ()); + } + } else { + var codon = (ProjectTemplateCodon)args.ExtensionNode; + foreach (FileTemplate t in fileTemplates) { + if (t.Id == codon.Id) { + fileTemplates.Remove (t); + break; + } } - } - else { - ProjectTemplateCodon codon = (ProjectTemplateCodon) args.ExtensionNode; - foreach (FileTemplate t in fileTemplates) { - if (t.Id == codon.Id) { - fileTemplates.Remove (t); - break; - } - } - } - } + } + } internal static List<FileTemplate> GetFileTemplates (Project project, string projectPath) { @@ -286,45 +218,37 @@ namespace MonoDevelop.Ide.Templates } internal static FileTemplate GetFileTemplateByID (string templateID) - { - foreach (FileTemplate t in fileTemplates) - if (t.Id == templateID) - return t; + { + foreach (FileTemplate t in fileTemplates) + if (t.Id == templateID) + return t; - return null; - } + return null; + } public virtual bool Create (SolutionFolderItem policyParent, Project project, string directory, string language, string name) - { - if (!String.IsNullOrEmpty(WizardPath)) { - //Properties customizer = new Properties(); - //customizer.Set("Template", item); - //customizer.Set("Creator", this); - //WizardDialog wizard = new WizardDialog("File Wizard", customizer, item.WizardPath); - //if (wizard.ShowDialog() == DialogResult.OK) { - //DialogResult = DialogResult.OK; - //} - return false; + { + if (!String.IsNullOrEmpty (WizardPath)) { + return false; } else { - foreach (FileDescriptionTemplate newfile in Files) - if (!CreateFile (newfile, policyParent, project, directory, language, name)) - return false; - return true; - } - } + foreach (FileDescriptionTemplate newfile in Files) + if (!CreateFile (newfile, policyParent, project, directory, language, name)) + return false; + return true; + } + } public virtual bool IsValidName (string name, string language) - { - if (isFixedFilename) - return (name == defaultFilename); + { + if (IsFixedFilename) + return (name == DefaultFilename); - bool valid = true; - foreach (FileDescriptionTemplate templ in Files) - if (!templ.IsValidName (name, language)) - valid = false; + bool valid = true; + foreach (FileDescriptionTemplate templ in Files) + valid &= templ.IsValidName (name, language); - return valid; - } + return valid; + } public static string GuessMimeType (string fileName) { @@ -337,17 +261,17 @@ namespace MonoDevelop.Ide.Templates FileService.MoveFile (fn, fn + n + ext); string mimeType = DesktopService.GetMimeTypeForUri (fn + n + ext); FileService.DeleteFile (fn + n + ext); - if (mimeType == null || mimeType == "") + if (string.IsNullOrEmpty (mimeType)) mimeType = "text"; return mimeType; } - + public virtual bool CanCreateUnsavedFiles (FileDescriptionTemplate newfile, SolutionFolderItem policyParent, Project project, string directory, string language, string name) { if (project != null) { return true; } else { - SingleFileDescriptionTemplate singleFile = newfile as SingleFileDescriptionTemplate; + var singleFile = newfile as SingleFileDescriptionTemplate; if (singleFile == null) return false; @@ -362,144 +286,144 @@ namespace MonoDevelop.Ide.Templates } protected virtual bool CreateFile (FileDescriptionTemplate newfile, SolutionFolderItem policyParent, Project project, string directory, string language, string name) - { - if (project != null) { + { + if (project != null) { var model = project.GetStringTagModel (new DefaultConfigurationSelector ()); newfile.SetProjectTagModel (model); try { - if (newfile.AddToProject (policyParent, project, language, directory, name)) { - newfile.Show (); - return true; + if (newfile.AddToProject (policyParent, project, language, directory, name)) { + newfile.Show (); + return true; } } finally { newfile.SetProjectTagModel (null); } } else { - SingleFileDescriptionTemplate singleFile = newfile as SingleFileDescriptionTemplate; - if (singleFile == null) - throw new InvalidOperationException ("Single file template expected"); + var singleFile = newfile as SingleFileDescriptionTemplate; + if (singleFile == null) + throw new InvalidOperationException ("Single file template expected"); - if (directory != null) { - string fileName = singleFile.SaveFile (policyParent, project, language, directory, name); - if (fileName != null) { + if (directory != null) { + string fileName = singleFile.SaveFile (policyParent, project, language, directory, name); + if (fileName != null) { IdeApp.Workbench.OpenDocument (fileName, project); - return true; - } + return true; + } } else { - string fileName = singleFile.GetFileName (policyParent, project, language, directory, name); - Stream stream = singleFile.CreateFileContent (policyParent, project, language, fileName, name); + string fileName = singleFile.GetFileName (policyParent, project, language, directory, name); + Stream stream = singleFile.CreateFileContent (policyParent, project, language, fileName, name); string mimeType = GuessMimeType (fileName); IdeApp.Workbench.NewDocument (fileName, mimeType, stream); return true; - } - } - return false; - } + } + } + return false; + } protected virtual bool IsValidForProject (Project project, string projectPath) - { - // When there is no project, only single template files can be created. - if (project == null) { - foreach (FileDescriptionTemplate f in files) - if (!(f is SingleFileDescriptionTemplate)) - return false; - } - - // Filter on templates - foreach (FileDescriptionTemplate f in files) - if (!f.SupportsProject (project, projectPath)) - return false; - - //filter on conditions - if (project != null) { - if (!string.IsNullOrEmpty (projecttype) && project.GetTypeTags ().All (p => p != projecttype)) - return false; - - foreach (FileTemplateCondition condition in conditions) - if (!condition.ShouldEnableFor (project, projectPath)) - return false; - } - - return true; - } + { + // When there is no project, only single template files can be created. + if (project == null) { + foreach (FileDescriptionTemplate f in Files) + if (!(f is SingleFileDescriptionTemplate)) + return false; + } + + // Filter on templates + foreach (FileDescriptionTemplate f in Files) + if (!f.SupportsProject (project, projectPath)) + return false; + + //filter on conditions + if (project != null) { + if (!string.IsNullOrEmpty (ProjectType) && project.GetTypeTags ().All (p => p != ProjectType)) + return false; + + foreach (FileTemplateCondition condition in Conditions) + if (!condition.ShouldEnableFor (project, projectPath)) + return false; + } + + return true; + } public virtual List<string> GetCompatibleLanguages (Project project, string projectPath) - { - if (project == null) - return SupportedLanguages; - - //find the languages that both the template and the project support - List<string> langMatches = MatchLanguagesWithProject (project); - - //filter on conditions - List<string> filtered = new List<string> (); - foreach (string lang in langMatches) { - bool shouldEnable = true; - foreach (FileTemplateCondition condition in conditions) { - if (!condition.ShouldEnableFor (project, projectPath, lang)) { - shouldEnable = false; - break; - } - } - if (shouldEnable) - filtered.Add (lang); - } - - return filtered; - } - - //The languages that the template supports - //FIXME: would it be memory-effective to cache this? + { + if (project == null) + return SupportedLanguages; + + //find the languages that both the template and the project support + List<string> langMatches = MatchLanguagesWithProject (project); + + //filter on conditions + var filtered = new List<string> (); + foreach (string lang in langMatches) { + bool shouldEnable = true; + foreach (FileTemplateCondition condition in Conditions) { + if (!condition.ShouldEnableFor (project, projectPath, lang)) { + shouldEnable = false; + break; + } + } + if (shouldEnable) + filtered.Add (lang); + } + + return filtered; + } + + //The languages that the template supports + //FIXME: would it be memory-effective to cache this? List<string> SupportedLanguages { get { - List<string> templateLangs = new List<string> (); - foreach (string s in this.LanguageName.Split (',')) - templateLangs.Add (s.Trim ()); - ExpandLanguageWildcards (templateLangs); - return templateLangs; - } - } + var templateLangs = new List<string> (); + foreach (string s in LanguageName.Split (',')) + templateLangs.Add (s.Trim ()); + ExpandLanguageWildcards (templateLangs); + return templateLangs; + } + } List<string> MatchLanguagesWithProject (Project project) - { - //The languages that the project supports - List<string> projectLangs = new List<string> (project.SupportedLanguages); - ExpandLanguageWildcards (projectLangs); - - List<string> templateLangs = SupportedLanguages; - - //Find all matches between the language strings of project and template - List<string> langMatches = new List<string> (); - - foreach (string templLang in templateLangs) - foreach (string projLang in projectLangs) - if (templLang == projLang) - langMatches.Add (projLang); - - //Eliminate duplicates - int pos = 0; - while (pos < langMatches.Count) { - int next = langMatches.IndexOf (langMatches [pos], pos +1); - if (next != -1) - langMatches.RemoveAt (next); - else - pos++; - } - - return langMatches; - } - - void ExpandLanguageWildcards (List<string> list) - { - //Template can match all CodeDom .NET languages with a "*" - if (list.Contains ("*")) { - foreach (var lb in LanguageBindingService.LanguageBindings) { - if (lb.GetCodeDomProvider () != null) - list.Add (lb.Language); - list.Remove ("*"); - } - } - } - } + { + //The languages that the project supports + var projectLangs = new List<string> (project.SupportedLanguages); + ExpandLanguageWildcards (projectLangs); + + List<string> templateLangs = SupportedLanguages; + + //Find all matches between the language strings of project and template + var langMatches = new List<string> (); + + foreach (string templLang in templateLangs) + foreach (string projLang in projectLangs) + if (templLang == projLang) + langMatches.Add (projLang); + + //Eliminate duplicates + int pos = 0; + while (pos < langMatches.Count) { + int next = langMatches.IndexOf (langMatches [pos], pos + 1); + if (next != -1) + langMatches.RemoveAt (next); + else + pos++; + } + + return langMatches; + } + + static void ExpandLanguageWildcards (ICollection<string> list) + { + //Template can match all CodeDom .NET languages with a "*" + if (list.Contains ("*")) { + foreach (var lb in LanguageBindingService.LanguageBindings) { + if (lb.GetCodeDomProvider () != null) + list.Add (lb.Language); + list.Remove ("*"); + } + } + } + } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs index d4ba526f26..dfb83e7deb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs @@ -312,7 +312,7 @@ namespace MonoDevelop.Ide.Templates { if (await IdeApp.Workspace.OpenWorkspaceItem (createdSolutionName)) { foreach (string action in actions) - IdeApp.Workbench.OpenDocument (Path.Combine (createdProjectInformation.ProjectBasePath, action)); + IdeApp.Workbench.OpenDocument (Path.Combine (createdProjectInformation.ProjectBasePath, action), project:null); return true; } return false; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs index db7cc01c6b..e01f260840 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs @@ -185,7 +185,7 @@ namespace MonoDevelop.Ide.Templates public override void Show () { if (!suppressAutoOpen) - IdeApp.Workbench.OpenDocument (generatedFile); + IdeApp.Workbench.OpenDocument (generatedFile, project: null); } // Creates a file and saves it to disk. Returns the path to the new file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/Ambience.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/Ambience.cs index fe53a0c8e4..8d206a8efe 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/Ambience.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/Ambience.cs @@ -240,7 +240,7 @@ namespace MonoDevelop.Ide.TypeSystem if (entity != null) { var ambience = new ICSharpCode.NRefactory.CSharp.CSharpAmbience (); ambience.ConversionFlags = ICSharpCode.NRefactory.TypeSystem.ConversionFlags.ShowParameterList | ICSharpCode.NRefactory.TypeSystem.ConversionFlags.ShowParameterNames | ICSharpCode.NRefactory.TypeSystem.ConversionFlags.ShowTypeParameterList; - return ambience.ConvertEntity (entity); + return ambience.ConvertSymbol (entity); } } catch (Exception e) { LoggingService.LogWarning ("Invalid cref:" + cref, e); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs index 77d8e818eb..57c1bd4d58 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs @@ -80,11 +80,11 @@ namespace MonoDevelop.Ide.TypeSystem } } - static Timer timer; + //static Timer timer; static MetadataReferenceCache () { - timer = new Timer ((o) => CheckForChanges (), null, 10000, 10000); + //timer = new Timer ((o) => CheckForChanges (), null, 10000, 10000); } //TODO: Call this method when focus returns to MD or even better use FileSystemWatcher diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs index b701bd8ecc..2eac2636ac 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs @@ -435,7 +435,7 @@ namespace MonoDevelop.Ide.TypeSystem static DocumentInfo CreateDocumentInfo (SolutionData data, string projectName, ProjectData id, MonoDevelop.Projects.ProjectFile f) { var filePath = f.FilePath; - var sourceCodeKind = filePath.Extension == ".sketchcs" ? SourceCodeKind.Interactive : SourceCodeKind.Regular; + var sourceCodeKind = filePath.Extension == ".sketchcs" ? SourceCodeKind.Script : SourceCodeKind.Regular; return DocumentInfo.Create ( id.GetOrCreateDocumentId (filePath), f.FilePath, @@ -756,9 +756,9 @@ namespace MonoDevelop.Ide.TypeSystem startOffset = originalOffset; } if (change.NewText.Length == 0) { - formatter.OnTheFlyFormat ((TextEditor)data, documentContext, Math.Max (0, startOffset - 1), Math.Min (data.Length, startOffset + 1)); + formatter.OnTheFlyFormat ((TextEditor)data, documentContext, TextSegment.FromBounds (Math.Max (0, startOffset - 1), Math.Min (data.Length, startOffset + 1))); } else { - formatter.OnTheFlyFormat ((TextEditor)data, documentContext, startOffset, startOffset + change.NewText.Length); + formatter.OnTheFlyFormat ((TextEditor)data, documentContext, new TextSegment (startOffset, change.NewText.Length)); } } } @@ -801,8 +801,6 @@ namespace MonoDevelop.Ide.TypeSystem IdeApp.ProjectOperations.SaveAsync (mdProject); }); } - - OnDocumentAdded (info.WithTextLoader (new MonoDevelopTextLoader (path))); } string DetermineFilePath (DocumentId id, string name, string filePath, IReadOnlyList<string> docFolders, bool createDirectory = false) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs index 533731445f..14021cc0a4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ProjectCacheService.cs @@ -538,8 +538,8 @@ namespace MonoDevelop.Ide.TypeSystem private static Action<Exception> s_fatalHandler; private static Action<Exception> s_nonFatalHandler; - private static Exception s_reportedException; - private static string s_reportedExceptionMessage; + //private static Exception s_reportedException; + //private static string s_reportedExceptionMessage; /// <summary> /// Set by the host to a fail fast trigger, @@ -658,8 +658,8 @@ namespace MonoDevelop.Ide.TypeSystem private static void Report (Exception exception, Action<Exception> handler) { // hold onto last exception to make investigation easier - s_reportedException = exception; - s_reportedExceptionMessage = exception.ToString (); + //s_reportedException = exception; + //s_reportedExceptionMessage = exception.ToString (); handler?.Invoke (exception); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/StockIcons.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/StockIcons.cs index 52e572386b..94208220a0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/StockIcons.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/StockIcons.cs @@ -26,161 +26,57 @@ using System; using MonoDevelop.Core; using Mono.Cecil; +using Microsoft.CodeAnalysis; namespace MonoDevelop.Ide.TypeSystem { public static class Stock { - static readonly IconId Class = "md-class"; - static readonly IconId Enum = "md-enum"; - static readonly IconId Event = "md-event"; - static readonly IconId Field = "md-field"; - static readonly IconId Interface = "md-interface"; - static readonly IconId Method = "md-method"; - static readonly IconId ExtensionMethod = "md-extensionmethod"; - static readonly IconId Property = "md-property"; - static readonly IconId Struct = "md-struct"; - static readonly IconId Delegate = "md-delegate"; public static readonly IconId Namespace = "md-name-space"; - static readonly IconId InternalClass = "md-internal-class"; - static readonly IconId InternalDelegate = "md-internal-delegate"; - static readonly IconId InternalEnum = "md-internal-enum"; - static readonly IconId InternalEvent = "md-internal-event"; - static readonly IconId InternalField = "md-internal-field"; - static readonly IconId InternalInterface = "md-internal-interface"; - static readonly IconId InternalMethod = "md-internal-method"; - static readonly IconId InternalExtensionMethod = "md-internal-extensionmethod"; - static readonly IconId InternalProperty = "md-internal-property"; - static readonly IconId InternalStruct = "md-internal-struct"; - - static readonly IconId InternalAndProtectedClass = "md-InternalAndProtected-class"; - static readonly IconId InternalAndProtectedDelegate = "md-InternalAndProtected-delegate"; - static readonly IconId InternalAndProtectedEnum = "md-InternalAndProtected-enum"; - static readonly IconId InternalAndProtectedEvent = "md-InternalAndProtected-event"; - static readonly IconId InternalAndProtectedField = "md-InternalAndProtected-field"; - static readonly IconId InternalAndProtectedInterface = "md-InternalAndProtected-interface"; - static readonly IconId InternalAndProtectedMethod = "md-InternalAndProtected-method"; - static readonly IconId InternalAndProtectedExtensionMethod = "md-InternalAndProtected-extensionmethod"; - static readonly IconId InternalAndProtectedProperty = "md-InternalAndProtected-property"; - static readonly IconId InternalAndProtectedStruct = "md-InternalAndProtected-struct"; - - static readonly IconId PrivateClass = "md-private-class"; - static readonly IconId PrivateDelegate = "md-private-delegate"; - static readonly IconId PrivateEnum = "md-private-enum"; - static readonly IconId PrivateEvent = "md-private-event"; - static readonly IconId PrivateField = "md-private-field"; - static readonly IconId PrivateInterface = "md-private-interface"; - static readonly IconId PrivateMethod = "md-private-method"; - static readonly IconId PrivateExtensionMethod = "md-private-extensionmethod"; - static readonly IconId PrivateProperty = "md-private-property"; - static readonly IconId PrivateStruct = "md-private-struct"; - - static readonly IconId ProtectedClass = "md-protected-class"; - static readonly IconId ProtectedDelegate = "md-protected-delegate"; - static readonly IconId ProtectedEnum = "md-protected-enum"; - static readonly IconId ProtectedEvent = "md-protected-event"; - static readonly IconId ProtectedField = "md-protected-field"; - static readonly IconId ProtectedInterface = "md-protected-interface"; - static readonly IconId ProtectedMethod = "md-protected-method"; - static readonly IconId ProtectedExtensionMethod = "md-protected-extensionmethod"; - static readonly IconId ProtectedProperty = "md-protected-property"; - static readonly IconId ProtectedStruct = "md-protected-struct"; - - static readonly IconId ProtectedOrInternalClass = "md-ProtectedOrInternal-class"; - static readonly IconId ProtectedOrInternalDelegate = "md-ProtectedOrInternal-delegate"; - static readonly IconId ProtectedOrInternalEnum = "md-ProtectedOrInternal-enum"; - static readonly IconId ProtectedOrInternalEvent = "md-ProtectedOrInternal-event"; - static readonly IconId ProtectedOrInternalField = "md-ProtectedOrInternal-field"; - static readonly IconId ProtectedOrInternalInterface = "md-ProtectedOrInternal-interface"; - static readonly IconId ProtectedOrInternalMethod = "md-ProtectedOrInternal-method"; - static readonly IconId ProtectedOrInternalExtensionMethod = "md-ProtectedOrInternal-extensionmethod"; - static readonly IconId ProtectedOrInternalProperty = "md-ProtectedOrInternal-property"; - static readonly IconId ProtectedOrInternalStruct = "md-ProtectedOrInternal-struct"; - - static IconId[,] typeIconTable = new IconId[,] { - {Class, PrivateClass, Class, ProtectedClass, InternalClass, ProtectedOrInternalClass, InternalAndProtectedClass}, // class - {Enum, PrivateEnum, Enum, ProtectedEnum, InternalEnum, ProtectedOrInternalEnum, InternalAndProtectedEnum}, // enum - {Interface, PrivateInterface, Interface, ProtectedInterface, InternalInterface, ProtectedOrInternalInterface, InternalAndProtectedInterface}, // interface - {Struct, PrivateStruct, Struct, ProtectedStruct, InternalStruct, ProtectedOrInternalStruct, InternalAndProtectedStruct}, // struct - {Delegate, PrivateDelegate, Delegate, ProtectedDelegate, InternalDelegate, ProtectedOrInternalDelegate, InternalAndProtectedDelegate} // delegate - }; - static readonly IconId[] fieldIconTable = { - Stock.Field, Stock.PrivateField, Stock.Field, Stock.ProtectedField, Stock.InternalField, Stock.ProtectedOrInternalField, Stock.InternalAndProtectedField - }; - static readonly IconId[] methodIconTable = { - Stock.Method, Stock.PrivateMethod, Stock.Method, Stock.ProtectedMethod, Stock.InternalMethod, Stock.ProtectedOrInternalMethod, Stock.InternalAndProtectedMethod - }; - static readonly IconId[] extensionMethodIconTable = { - Stock.ExtensionMethod, Stock.PrivateExtensionMethod, Stock.ExtensionMethod, Stock.ProtectedExtensionMethod, Stock.InternalExtensionMethod, Stock.ProtectedOrInternalExtensionMethod, Stock.InternalAndProtectedExtensionMethod - }; - static readonly IconId[] propertyIconTable = { - Stock.Property, Stock.PrivateProperty, Stock.Property, Stock.ProtectedProperty, Stock.InternalProperty, Stock.ProtectedOrInternalProperty, Stock.InternalAndProtectedProperty - }; - static readonly IconId[] eventIconTable = { - Stock.Event, Stock.PrivateEvent, Stock.Event, Stock.ProtectedEvent, Stock.InternalEvent, Stock.ProtectedOrInternalEvent, Stock.InternalAndProtectedEvent - }; - -// public static IconId GetStockIcon (this INamedElement element) -// { -// if (element is IType) -// return ((IType)element).GetStockIcon (); -// if (element is ITypeParameter) -// return ((ITypeParameter)element).GetStockIcon (); -// if (element is IUnresolvedEntity) -// return ((IUnresolvedEntity)element).GetStockIcon (); -// return ((IEntity)element).GetStockIcon (); -// } -// -// public static IconId GetStockIcon (this ITypeDefinition entity) -// { -// return GetStockIcon ((IType)entity); -// } -// -// public static IconId GetStockIcon (this IType entity) -// { -// var def = entity.GetDefinition (); -// if (def == null) -// return Class; -// switch (def.Kind) { -// case TypeKind.Class: -// return typeIconTable [0, (int)def.Accessibility]; -// case TypeKind.Enum: -// return typeIconTable [1, (int)def.Accessibility]; -// case TypeKind.Interface: -// return typeIconTable [2, (int)def.Accessibility]; -// case TypeKind.Struct: -// return typeIconTable [3, (int)def.Accessibility]; -// case TypeKind.Delegate: -// return typeIconTable [4, (int)def.Accessibility]; -// default: -// return typeIconTable [0, (int)def.Accessibility]; -// } -// } + public static IconId GetStockIcon (this Microsoft.CodeAnalysis.ISymbol symbol) + { + return "md-" + GetAccess (symbol.DeclaredAccessibility) + GetGlobal (symbol) + GetSource (symbol); + } - static int GetIndex (Microsoft.CodeAnalysis.Accessibility accessibility) + internal static string GetAccess (Accessibility accessibility) { switch (accessibility) { case Microsoft.CodeAnalysis.Accessibility.NotApplicable: - return 0; + return ""; case Microsoft.CodeAnalysis.Accessibility.Private: - return 1; + return "private-"; case Microsoft.CodeAnalysis.Accessibility.ProtectedAndInternal: - return 5; + return "ProtectedOrInternal-"; case Microsoft.CodeAnalysis.Accessibility.Protected: - return 3; + return "protected-"; case Microsoft.CodeAnalysis.Accessibility.Internal: - return 4; + return "internal-"; case Microsoft.CodeAnalysis.Accessibility.ProtectedOrInternal: - return 5; + return "ProtectedOrInternal-"; case Microsoft.CodeAnalysis.Accessibility.Public: - return 2; + return ""; default: throw new ArgumentOutOfRangeException (); + } + } + + static string GetGlobal (ISymbol symbol) + { + switch (symbol.Kind) { + case Microsoft.CodeAnalysis.SymbolKind.NamedType: + return ""; + case Microsoft.CodeAnalysis.SymbolKind.Event: + case Microsoft.CodeAnalysis.SymbolKind.Field: + case Microsoft.CodeAnalysis.SymbolKind.Method: + case Microsoft.CodeAnalysis.SymbolKind.Property: + return symbol.IsStatic ? "static-" : ""; + default: + return ""; } } - public static IconId GetStockIcon (this Microsoft.CodeAnalysis.ISymbol symbol) + static string GetSource(Microsoft.CodeAnalysis.ISymbol symbol) { switch (symbol.Kind) { case Microsoft.CodeAnalysis.SymbolKind.Alias: @@ -192,69 +88,40 @@ namespace MonoDevelop.Ide.TypeSystem case Microsoft.CodeAnalysis.SymbolKind.Local: case Microsoft.CodeAnalysis.SymbolKind.NetModule: case Microsoft.CodeAnalysis.SymbolKind.PointerType: - return Field; - case Microsoft.CodeAnalysis.SymbolKind.NamedType: - var namedTypeSymbol = (Microsoft.CodeAnalysis.INamedTypeSymbol)symbol; - return typeIconTable [GetTypeIndex(namedTypeSymbol.TypeKind ), GetIndex (namedTypeSymbol.DeclaredAccessibility)]; - case Microsoft.CodeAnalysis.SymbolKind.Event: - var evtSymbol = (Microsoft.CodeAnalysis.IEventSymbol)symbol; - return eventIconTable [GetIndex (evtSymbol.DeclaredAccessibility)]; case Microsoft.CodeAnalysis.SymbolKind.Field: - var fieldSymbol = (Microsoft.CodeAnalysis.IFieldSymbol)symbol; - return fieldIconTable [GetIndex (fieldSymbol.DeclaredAccessibility)]; - case Microsoft.CodeAnalysis.SymbolKind.Method: - var methodSymbol = (Microsoft.CodeAnalysis.IMethodSymbol)symbol; - return methodIconTable [GetIndex (methodSymbol.DeclaredAccessibility)]; - case Microsoft.CodeAnalysis.SymbolKind.Namespace: - return Namespace; case Microsoft.CodeAnalysis.SymbolKind.Parameter: - return Field; - case Microsoft.CodeAnalysis.SymbolKind.Property: - var propertySymbol = (Microsoft.CodeAnalysis.IPropertySymbol)symbol; - return propertyIconTable [GetIndex (propertySymbol.DeclaredAccessibility)]; case Microsoft.CodeAnalysis.SymbolKind.RangeVariable: - return Field; case Microsoft.CodeAnalysis.SymbolKind.TypeParameter: - return Stock.typeIconTable [0, 0]; case Microsoft.CodeAnalysis.SymbolKind.Preprocessing: - return Field; - default: - throw new ArgumentOutOfRangeException (); - } - } - - static int GetTypeIndex (Microsoft.CodeAnalysis.TypeKind typeKind) - { - switch (typeKind) { - case Microsoft.CodeAnalysis.TypeKind.Unknown: - case Microsoft.CodeAnalysis.TypeKind.Array: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Class: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Delegate: - return 4; - case Microsoft.CodeAnalysis.TypeKind.Dynamic: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Enum: - return 1; - case Microsoft.CodeAnalysis.TypeKind.Error: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Interface: - return 2; - case Microsoft.CodeAnalysis.TypeKind.Module: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Pointer: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Struct: - return 3; - case Microsoft.CodeAnalysis.TypeKind.TypeParameter: - return 0; - case Microsoft.CodeAnalysis.TypeKind.Submission: - return 0; + return "field"; + case Microsoft.CodeAnalysis.SymbolKind.NamedType: + var namedTypeSymbol = (Microsoft.CodeAnalysis.INamedTypeSymbol)symbol; + switch (namedTypeSymbol.TypeKind) { + case Microsoft.CodeAnalysis.TypeKind.Class: + return "class"; + case Microsoft.CodeAnalysis.TypeKind.Delegate: + return "delegate"; + case Microsoft.CodeAnalysis.TypeKind.Enum: + return "enum"; + case Microsoft.CodeAnalysis.TypeKind.Interface: + return "interface"; + case Microsoft.CodeAnalysis.TypeKind.Struct: + return "struct"; + default: + return "class"; + } + + case Microsoft.CodeAnalysis.SymbolKind.Method: + return "method"; + case Microsoft.CodeAnalysis.SymbolKind.Namespace: + return "name-space"; + case Microsoft.CodeAnalysis.SymbolKind.Property: + return "property"; + case Microsoft.CodeAnalysis.SymbolKind.Event: + return "event"; default: throw new ArgumentOutOfRangeException (); } } - } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 8efc231214..6516c0abb4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -3507,8 +3507,8 @@ <Compile Include="MonoDevelop.Components.AutoTest.Operations\SelectedOperation.cs" /> <Compile Include="MonoDevelop.Components\Windows\GtkWPFWidget.cs" /> <Compile Include="MonoDevelop.Components\Windows\GtkWin32Interop.cs" /> - <Compile Include="MonoDevelop.Components.Docking\DockPositionType.cs" /> <Compile Include="MonoDevelop.Components\FileChooserAction.cs" /> + <Compile Include="MonoDevelop.Components.Docking\DockPositionType.cs" /> <Compile Include="MonoDevelop.Components\ButtonEvent.cs" /> <Compile Include="MonoDevelop.Components\Window.cs" /> <Compile Include="MonoDevelop.Components\Dialog.cs" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs index 4b2c18a232..b5ce18e2e7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs @@ -344,7 +344,7 @@ namespace MonoDevelop.Ide foreach (var file in filteredFiles) { try { - Workbench.OpenDocument (file.FileName, file.Line, file.Column, file.Options); + Workbench.OpenDocument (file.FileName, null, file.Line, file.Column, file.Options); } catch (Exception ex) { MessageService.ShowError (GettextCatalog.GetString ("Could not open file: {0}", file.FileName), ex); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdePreferences.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdePreferences.cs index 0f7395e565..1b79545e62 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdePreferences.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdePreferences.cs @@ -143,7 +143,7 @@ namespace MonoDevelop.Ide public readonly ConfigurationProperty<bool> IncludeEditorBrowsableAdvancedMembers = ConfigurationProperty.Create ("IncludeEditorBrowsableAdvancedMembers", true); public readonly ConfigurationProperty<int> CompletionListRows = ConfigurationProperty.Create ("CompletionListRows", 7); - public readonly ConfigurationProperty<bool> EnableSourceAnalysis = ConfigurationProperty.Create ("MonoDevelop.AnalysisCore.AnalysisEnabled", false); + public readonly ConfigurationProperty<bool> EnableSourceAnalysis = ConfigurationProperty.Create ("MonoDevelop.AnalysisCore.AnalysisEnabled", true); public readonly ConfigurationProperty<bool> EnableUnitTestEditorIntegration = ConfigurationProperty.Create ("Testing.EnableUnitTestEditorIntegration", false); public readonly ConfigurationProperty<string> ColorScheme = ConfigurationProperty.Create ("ColorScheme", "Default"); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs index f0d27c6c1a..3cb1ce17ab 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs @@ -1346,7 +1346,7 @@ namespace MonoDevelop.Ide } //wait for any custom tools that were triggered by the save, since the build may depend on them - MonoDevelop.Ide.CustomTools.CustomToolService.WaitForRunningTools (monitor); + await MonoDevelop.Ide.CustomTools.CustomToolService.WaitForRunningTools (monitor); if (skipPrebuildCheck || result.ErrorCount == 0) { tt.Trace ("Building item"); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs index 317e98810e..369bdd3200 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/RootWorkspace.cs @@ -226,7 +226,12 @@ namespace MonoDevelop.Ide monitor.Dispose (); } } - + + bool IBuildTarget.CanBuild (ConfigurationSelector configuration) + { + return true; + } + bool IBuildTarget.CanExecute (ExecutionContext context, ConfigurationSelector configuration) { if (IdeApp.ProjectOperations.CurrentSelectedSolution != null) @@ -488,7 +493,7 @@ namespace MonoDevelop.Ide } if (closedDocs != null) { foreach (string doc in closedDocs) { - IdeApp.Workbench.OpenDocument (doc, false); + IdeApp.Workbench.OpenDocument (doc, null, false); } } } @@ -1062,20 +1067,23 @@ namespace MonoDevelop.Ide void NotifyItemRemovedFromSolution (object sender, SolutionItemChangeEventArgs args) { - NotifyItemRemovedFromSolutionRec (sender, args.SolutionItem, args.Solution); + NotifyItemRemovedFromSolutionRec (sender, args.SolutionItem, args.Solution, args); } - void NotifyItemRemovedFromSolutionRec (object sender, SolutionFolderItem e, Solution sol) + void NotifyItemRemovedFromSolutionRec (object sender, SolutionFolderItem e, Solution sol, SolutionItemChangeEventArgs originalArgs) { if (e == IdeApp.ProjectOperations.CurrentSelectedSolutionItem) IdeApp.ProjectOperations.CurrentSelectedSolutionItem = null; if (e is SolutionFolder) { foreach (SolutionFolderItem ce in ((SolutionFolder)e).Items) - NotifyItemRemovedFromSolutionRec (sender, ce, sol); + NotifyItemRemovedFromSolutionRec (sender, ce, sol, null); } + + // For the root item send the original args, since they contain reload information + if (ItemRemovedFromSolution != null) - ItemRemovedFromSolution (sender, new SolutionItemChangeEventArgs (e, sol, false)); + ItemRemovedFromSolution (sender, originalArgs ?? new SolutionItemChangeEventArgs (e, sol, false)); } void NotifyDescendantItemAdded (object s, WorkspaceItemEventArgs args) |