diff options
author | Vsevolod Kukol <sevoku@xamarin.com> | 2016-01-27 02:33:28 +0300 |
---|---|---|
committer | Vsevolod Kukol <sevoku@xamarin.com> | 2016-01-27 02:33:28 +0300 |
commit | f05ea610e96df57457fd3a859c09b189b30142db (patch) | |
tree | 7191a9f62a73537765c141741cb0dd0cc20de2f3 /main | |
parent | f0f7a0ccaf9e163dbfe041607756f85b07bbb3ea (diff) | |
parent | bfe44fe0f6b9993de00782bd4c44cc3ece062b29 (diff) |
Merge remote-tracking branch 'origin/master' into roslyn-dark-skin
Diffstat (limited to 'main')
133 files changed, 1678 insertions, 810 deletions
diff --git a/main/Main.sln b/main/Main.sln index c7a23bfe5b..37186ef153 100644 --- a/main/Main.sln +++ b/main/Main.sln @@ -900,17 +900,17 @@ Global {7926DB5B-96A7-47A7-9870-DB42FA5C3548}.ReleaseWin32|Any CPU.Build.0 = Release|Any CPU
{7B57882B-AD46-469B-84E7-06DF98D11468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B57882B-AD46-469B-84E7-06DF98D11468}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugGnome|Any CPU.Build.0 = Debug|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugMac|Any CPU.Build.0 = Debug|Any CPU
+ {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugGnome|Any CPU.ActiveCfg = DebugGnome|Any CPU
+ {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugGnome|Any CPU.Build.0 = DebugGnome|Any CPU
+ {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU + {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugMac|Any CPU.Build.0 = Debug|Any CPU {7B57882B-AD46-469B-84E7-06DF98D11468}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
{7B57882B-AD46-469B-84E7-06DF98D11468}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B57882B-AD46-469B-84E7-06DF98D11468}.Release|Any CPU.Build.0 = Release|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
- {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
+ {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseGnome|Any CPU.ActiveCfg = ReleaseGnome|Any CPU
+ {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseGnome|Any CPU.Build.0 = ReleaseGnome|Any CPU
+ {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU + {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {7B57882B-AD46-469B-84E7-06DF98D11468}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{7E4B15FB-E8C4-419A-A31C-9310FD9062BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E4B15FB-E8C4-419A-A31C-9310FD9062BD}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
@@ -1172,16 +1172,16 @@ Global {9A415695-CF80-4845-AA80-0DA26CF1E256}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.DebugGnome|Any CPU.Build.0 = Debug|Any CPU
+ {9BC670A8-1851-40EC-9685-279F4C98433D}.DebugGnome|Any CPU.ActiveCfg = DebugGnome|Any CPU
+ {9BC670A8-1851-40EC-9685-279F4C98433D}.DebugGnome|Any CPU.Build.0 = DebugGnome|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.DebugMac|Any CPU.Build.0 = Debug|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.Release|Any CPU.Build.0 = Release|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
- {9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
+ {9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseGnome|Any CPU.ActiveCfg = ReleaseGnome|Any CPU
+ {9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseGnome|Any CPU.Build.0 = ReleaseGnome|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
{9BC670A8-1851-40EC-9685-279F4C98433D}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
@@ -1411,16 +1411,16 @@ Global {B841F25D-4F6D-4E0D-885F-212B54381F28}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugGnome|Any CPU.ActiveCfg = Debug|Any CPU
- {BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugGnome|Any CPU.Build.0 = Debug|Any CPU
+ {BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugGnome|Any CPU.ActiveCfg = DebugGnome|Any CPU
+ {BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugGnome|Any CPU.Build.0 = DebugGnome|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugMac|Any CPU.Build.0 = Debug|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.Release|Any CPU.Build.0 = Release|Any CPU
- {BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseGnome|Any CPU.ActiveCfg = Release|Any CPU
- {BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseGnome|Any CPU.Build.0 = Release|Any CPU
+ {BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseGnome|Any CPU.ActiveCfg = ReleaseGnome|Any CPU
+ {BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseGnome|Any CPU.Build.0 = ReleaseGnome|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
{BA9020AD-A2D1-47C8-9A7C-756162C38296}.ReleaseWin32|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/main/external/fsharpbinding b/main/external/fsharpbinding -Subproject 7a2fd956d6111d14b55e94059c8ff7d67529ff5 +Subproject a272259013b350bfc7eb0a6f6f85d8be44a5d3b diff --git a/main/external/libgit-binary b/main/external/libgit-binary -Subproject 944fba6f5eb9636542e824b6fd95c294d91e97a +Subproject 8d9ac291c1e34357efc6c95891ff420c513ff00 diff --git a/main/external/libgit2 b/main/external/libgit2 -Subproject e8b8948f5a07cd813ccad7b97490b7f040d364c +Subproject ab8e88a96b5b9e1a59a6f8742fe0136b1315871 diff --git a/main/external/libgit2sharp b/main/external/libgit2sharp -Subproject 06bbc96251eea534ed66a32e8f2e2edaaa90307 +Subproject 9a12910ac3809881ad85c0e05b1290a352684a5 diff --git a/main/src/addins/CBinding/AddinInfo.cs b/main/src/addins/CBinding/AddinInfo.cs index 2d04910221..88555948ba 100644 --- a/main/src/addins/CBinding/AddinInfo.cs +++ b/main/src/addins/CBinding/AddinInfo.cs @@ -6,7 +6,14 @@ using Mono.Addins.Description; [assembly:Addin ("CBinding", Namespace = "MonoDevelop", Version = MonoDevelop.BuildInfo.Version, - Category = "Language bindings")] + Category = "Language bindings", + EnabledByDefault = + #if GNOME + true + #else + false + #endif +)] [assembly:AddinName ("C/C++ Language Binding")] [assembly:AddinDescription ("C/C++ Language binding")] diff --git a/main/src/addins/CBinding/CBinding.csproj b/main/src/addins/CBinding/CBinding.csproj index d50c30baf7..1c4ee03b17 100644 --- a/main/src/addins/CBinding/CBinding.csproj +++ b/main/src/addins/CBinding/CBinding.csproj @@ -7,9 +7,9 @@ <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{7B57882B-AD46-469B-84E7-06DF98D11468}</ProjectGuid> <OutputType>Library</OutputType> - <AssemblyName>MonoDevelop.CBinding</AssemblyName> <RootNamespace>CBinding</RootNamespace> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <AssemblyName>MonoDevelop.CBinding</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> @@ -41,6 +41,37 @@ <NoWarn>1591;1573</NoWarn> <DocumentationFile>..\..\..\build\AddIns\BackendBindings\MonoDevelop.CBinding.xml</DocumentationFile> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugGnome|AnyCPU' "> + <DebugSymbols>True</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>False</Optimize> + <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>False</ConsolePause> + <Execution> + <Execution clr-version="Net_2_0" /> + </Execution> + <AssemblyOriginatorKeyFile>.</AssemblyOriginatorKeyFile> + <DefineConstants>DEBUG;GNOME</DefineConstants> + <NoWarn>1591;1573</NoWarn> + <DocumentationFile>..\..\..\build\AddIns\BackendBindings\MonoDevelop.CBinding.xml</DocumentationFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseGnome|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>True</Optimize> + <OutputPath>..\..\..\build\AddIns\BackendBindings\</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>False</ConsolePause> + <Execution> + <Execution clr-version="Net_2_0" /> + </Execution> + <DebugSymbols>true</DebugSymbols> + <DefineConstants>GNOME</DefineConstants> + <NoWarn>1591;1573</NoWarn> + <DocumentationFile>..\..\..\build\AddIns\BackendBindings\MonoDevelop.CBinding.xml</DocumentationFile> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs index 5e4447f063..1d6bb95822 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs @@ -465,10 +465,9 @@ namespace MonoDevelop.CSharp.CodeRefactorings.InlineTemporary var newVariableDeclarator = await FindDeclaratorAsync(updatedDocument, cancellationToken).ConfigureAwait(false); localSymbol = (ILocalSymbol)semanticModel.GetDeclaredSymbol(newVariableDeclarator, cancellationToken); - bool wasCastAdded; - var explicitCastExpression = newExpression.CastIfPossible(localSymbol.Type, newVariableDeclarator.SpanStart, semanticModel, out wasCastAdded); + var explicitCastExpression = newExpression.CastIfPossible(localSymbol.Type, newVariableDeclarator.SpanStart, semanticModel); - if (wasCastAdded) + if (explicitCastExpression != newExpression) { updatedDocument = await updatedDocument.ReplaceNodeAsync(newExpression, explicitCastExpression, cancellationToken).ConfigureAwait(false); semanticModel = await updatedDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs index dce6229d79..ee941bfb76 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs @@ -308,6 +308,10 @@ namespace MonoDevelop.CSharp.Completion } } + static bool IsIdentifierPart (char ch) + { + return char.IsLetterOrDigit (ch) || ch == '_'; + } public override Task<ICompletionDataList> HandleBackspaceOrDeleteCodeCompletionAsync (CodeCompletionContext completionContext, SpecialKey key, char triggerCharacter, CancellationToken token = default(CancellationToken)) { @@ -318,13 +322,15 @@ namespace MonoDevelop.CSharp.Completion //char completionChar = Editor.GetCharAt (completionContext.TriggerOffset - 1); //Console.WriteLine ("completion char: " + completionChar); // var timer = Counters.ResolveTime.BeginTiming (); + + if (key == SpecialKey.BackSpace || key == SpecialKey.Delete) { + char ch = completionContext.TriggerOffset > 0 ? Editor.GetCharAt (completionContext.TriggerOffset - 1) : '\0'; + char ch2 = completionContext.TriggerOffset < Editor.Length ? Editor.GetCharAt (completionContext.TriggerOffset) : '\0'; + if (!IsIdentifierPart (ch) && !IsIdentifierPart (ch2)) + return null; + } try { int triggerWordLength = 0; - //if (char.IsLetterOrDigit (completionChar) || completionChar == '_') { - // if (completionContext.TriggerOffset > 1 && char.IsLetterOrDigit (Editor.GetCharAt (completionContext.TriggerOffset - 2))) - // return null; - // triggerWordLength = 1; - //} return InternalHandleCodeCompletion (completionContext, triggerCharacter, true, triggerWordLength, token).ContinueWith ( t => { var result = (CompletionDataList)t.Result; if (result == null) diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs index 6b7d3b3a23..9e7e51ec2a 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs @@ -82,6 +82,8 @@ namespace MonoDevelop.CSharp.Completion this.factory = factory; this.text = text; Symbol = symbol; + if (IsObsolete (Symbol)) + DisplayFlags |= DisplayFlags.Obsolete; } static readonly SymbolDisplayFormat nameOnlyFormat = @@ -437,35 +439,40 @@ namespace MonoDevelop.CSharp.Completion return ret; } + static bool IsObsolete (ISymbol symbol) + { + return symbol.GetAttributes ().Any (attr => attr.AttributeClass.Name == "ObsoleteAttribute" && attr.AttributeClass.ContainingNamespace.GetFullName () == "System"); + } + -// public static TooltipInformation CreateTooltipInformation (ICompilation compilation, CSharpUnresolvedFile file, TextEditorData textEditorData, MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy formattingPolicy, IType type, bool smartWrap, bool createFooter = false) -// { -// var tooltipInfo = new TooltipInformation (); -// var resolver = file != null ? file.GetResolver (compilation, textEditorData.Caret.Location) : new CSharpResolver (compilation); -// var sig = new SignatureMarkupCreator (resolver, formattingPolicy.CreateOptions ()); -// sig.BreakLineAfterReturnType = smartWrap; -// try { -// tooltipInfo.SignatureMarkup = sig.GetMarkup (type.IsParameterized ? type.GetDefinition () : type); -// } catch (Exception e) { -// LoggingService.LogError ("Got exception while creating markup for :" + type, e); -// return new TooltipInformation (); -// } -// if (type.IsParameterized) { -// var typeInfo = new StringBuilder (); -// for (int i = 0; i < type.TypeParameterCount; i++) { -// typeInfo.AppendLine (type.GetDefinition ().TypeParameters [i].Name + " is " + sig.GetTypeReferenceString (type.TypeArguments [i])); -// } -// tooltipInfo.AddCategory ("Type Parameters", typeInfo.ToString ()); -// } -// -// var def = type.GetDefinition (); -// if (def != null) { -// if (createFooter) -// tooltipInfo.FooterMarkup = sig.CreateFooter (def); -// tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup (def) ?? ""; -// } -// return tooltipInfo; -// } + // public static TooltipInformation CreateTooltipInformation (ICompilation compilation, CSharpUnresolvedFile file, TextEditorData textEditorData, MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy formattingPolicy, IType type, bool smartWrap, bool createFooter = false) + // { + // var tooltipInfo = new TooltipInformation (); + // var resolver = file != null ? file.GetResolver (compilation, textEditorData.Caret.Location) : new CSharpResolver (compilation); + // var sig = new SignatureMarkupCreator (resolver, formattingPolicy.CreateOptions ()); + // sig.BreakLineAfterReturnType = smartWrap; + // try { + // tooltipInfo.SignatureMarkup = sig.GetMarkup (type.IsParameterized ? type.GetDefinition () : type); + // } catch (Exception e) { + // LoggingService.LogError ("Got exception while creating markup for :" + type, e); + // return new TooltipInformation (); + // } + // if (type.IsParameterized) { + // var typeInfo = new StringBuilder (); + // for (int i = 0; i < type.TypeParameterCount; i++) { + // typeInfo.AppendLine (type.GetDefinition ().TypeParameters [i].Name + " is " + sig.GetTypeReferenceString (type.TypeArguments [i])); + // } + // tooltipInfo.AddCategory ("Type Parameters", typeInfo.ToString ()); + // } + // + // var def = type.GetDefinition (); + // if (def != null) { + // if (createFooter) + // tooltipInfo.FooterMarkup = sig.CreateFooter (def); + // tooltipInfo.SummaryMarkup = AmbienceService.GetSummaryMarkup (def) ?? ""; + // } + // return tooltipInfo; + // } } } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs index 51c715a90a..8e91700613 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/EnumMemberContextHandler.cs @@ -114,10 +114,10 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion // Does type have any aliases? ISymbol alias = await type.FindApplicableAlias(completionContext.Position, model, cancellationToken).ConfigureAwait(false); + var displayString = RoslynCompletionData.SafeMinimalDisplayString (type, model, completionContext.Position, SymbolDisplayFormat.CSharpErrorMessageFormat); if (string.IsNullOrEmpty(completionResult.DefaultCompletionString)) - completionResult.DefaultCompletionString = type.Name; - - result.Add (engine.Factory.CreateSymbolCompletionData(this, type, RoslynCompletionData.SafeMinimalDisplayString (type, model, completionContext.Position, SymbolDisplayFormat.CSharpErrorMessageFormat))); + completionResult.DefaultCompletionString = displayString; + result.Add (engine.Factory.CreateSymbolCompletionData(this, type, displayString)); foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>()) { if (field.DeclaredAccessibility == Accessibility.Public && (field.IsConst || field.IsStatic)) { result.Add (engine.Factory.CreateEnumMemberCompletionData(this, alias, field)); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterUtil.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterUtil.cs index d66df9ee8e..ad10ebc87d 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterUtil.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/ParameterHinting/ParameterUtil.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory6.CSharp List<string> usedNamedParameters = null; var tree = await document.GetSyntaxTreeAsync (cancellationToken).ConfigureAwait (false); var root = await tree.GetRootAsync (cancellationToken).ConfigureAwait (false); - if (startOffset >= root.Span.Length) + if (startOffset >= root.FullSpan.Length) return ParameterIndexResult.Invalid; var token = root.FindToken (startOffset); @@ -73,7 +73,6 @@ namespace ICSharpCode.NRefactory6.CSharp n is ElementAccessExpressionSyntax || n is ConstructorInitializerSyntax || n is AttributeSyntax); - if (invocation is InvocationExpressionSyntax) { argList = ((InvocationExpressionSyntax)invocation).ArgumentList; } else if (invocation is ObjectCreationExpressionSyntax) { diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs index 08854ab7b2..55f6a35992 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs @@ -113,12 +113,16 @@ namespace MonoDevelop.CSharp.Formatting var doc = Formatter.FormatAsync (analysisDocument, span, optionSet).Result; var newTree = doc.GetSyntaxTreeAsync ().Result; var caretOffset = editor.CaretOffset; - foreach (var change in newTree.GetChanges (syntaxTree).OrderByDescending (c => c.Span.Start) ) { - if (!exact && change.Span.Start >= caretOffset) + + int delta = 0; + foreach (var change in newTree.GetChanges (syntaxTree)) { + if (!exact && change.Span.Start + delta >= caretOffset) continue; var newText = change.NewText; - editor.ReplaceText (change.Span.Start, change.Span.Length, newText); + editor.ReplaceText (delta + change.Span.Start, change.Span.Length, newText); + delta = delta - change.Span.Length + newText.Length; } + editor.CaretOffset = caretOffset + delta; if (editor.CaretColumn == 1) editor.CaretColumn = editor.GetVirtualIndentationColumn (editor.CaretLine); } catch (Exception e) { diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/CSharpSelectionSurroundingProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/CSharpSelectionSurroundingProvider.cs index 57f283bbb8..6ad5575720 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/CSharpSelectionSurroundingProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/CSharpSelectionSurroundingProvider.cs @@ -110,14 +110,21 @@ namespace MonoDevelop.CSharp.Highlighting var selectionRange = editor.SelectionRange; int anchorOffset = selectionRange.Offset; int leadOffset = selectionRange.EndOffset; - - editor.InsertText (anchorOffset, start); - editor.InsertText (leadOffset >= anchorOffset ? leadOffset + start.Length : leadOffset, end); - // textEditorData.SetSelection (anchorOffset + start.Length, leadOffset + start.Length); - if (CSharpTextEditorIndentation.OnTheFlyFormatting) { - var l1 = editor.GetLineByOffset (anchorOffset); - var l2 = editor.GetLineByOffset (leadOffset); - OnTheFlyFormatter.Format (editor, context, l1.Offset, l2.EndOffsetIncludingDelimiter); + var text = editor.GetTextAt (selectionRange); + if (editor.Options.GenerateFormattingUndoStep) { + using (var undo = editor.OpenUndoGroup ()) { + editor.ReplaceText (selectionRange, start); + } + using (var undo = editor.OpenUndoGroup ()) { + editor.ReplaceText (anchorOffset, 1, start + text + end); + editor.SetSelection (anchorOffset + start.Length, leadOffset + start.Length + end.Length); + } + } else { + using (var undo = editor.OpenUndoGroup ()) { + editor.InsertText (anchorOffset, start); + editor.InsertText (leadOffset >= anchorOffset ? leadOffset + start.Length : leadOffset, end); + editor.SetSelection (anchorOffset + start.Length, leadOffset + start.Length + end.Length); + } } } } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs index a9bdaeea5b..dbbfd5f907 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpCodeGenerator.cs @@ -715,7 +715,7 @@ namespace MonoDevelop.CSharp.Refactoring result.Append (" "); } result.Append (CSharpAmbience.FilterName (p.Name)); - if (p.HasExplicitDefaultValue) { + if (asParameterList && p.HasExplicitDefaultValue) { result.Append (" = "); if (p.ExplicitDefaultValue is Enum) { var name = Enum.GetName (p.ExplicitDefaultValue.GetType (), p.ExplicitDefaultValue); @@ -733,6 +733,8 @@ namespace MonoDevelop.CSharp.Refactoring result.Append ("\"" + CSharpTextEditorIndentation.ConvertToStringLiteral ((string)p.ExplicitDefaultValue) + "\""); } else if (p.ExplicitDefaultValue is bool) { result.Append ((bool)p.ExplicitDefaultValue ? "true" : "false"); + } else if (p.ExplicitDefaultValue == null) { + result.Append ("null"); } else { result.Append (p.ExplicitDefaultValue); } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpFeaturesTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpFeaturesTextEditorExtension.cs index 56dfd6d5f0..4ec807c365 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpFeaturesTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/CSharpFeaturesTextEditorExtension.cs @@ -89,9 +89,9 @@ namespace MonoDevelop.CSharp.Refactoring } [CommandHandler (EditCommands.Rename)] - public void RenameCommand () + public async void RenameCommand () { - new RenameHandler ().Run (Editor, DocumentContext); + await new RenameHandler ().Run (Editor, DocumentContext); } [CommandUpdateHandler (RefactoryCommands.GotoDeclaration)] diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs index cb690e0d82..37e0ab49fc 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethodCommandHandler.cs @@ -95,7 +95,7 @@ namespace MonoDevelop.CSharp.Refactoring var info = RefactoringSymbolInfo.GetSymbolInfoAsync (doc, extractionResult.InvocationNameToken.Span.Start).Result; var sym = info.DeclaredSymbol ?? info.Symbol; if (sym != null) - new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym); + await new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym); } catch (Exception e) { LoggingService.LogError ("Error while extracting method", e); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs index 6be48879bf..b7327c3b14 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs @@ -69,7 +69,7 @@ namespace MonoDevelop.CSharp.Refactoring result.Text = GettextCatalog.GetString ("Fix"); foreach (var diagnostic in container.CodeFixActions) { var info = new CommandInfo (diagnostic.CodeAction.Title); - result.CommandInfos.Add (info, new Action (new CodeActionEditorExtension.ContextActionRunner (diagnostic.CodeAction, editor, ctx).Run)); + result.CommandInfos.Add (info, new Action (async () => await new CodeActionEditorExtension.ContextActionRunner (diagnostic.CodeAction, editor, ctx).Run ())); } if (result.CommandInfos.Count == 0) return result; @@ -188,8 +188,8 @@ namespace MonoDevelop.CSharp.Refactoring bool canRename = RenameHandler.CanRename (info.Symbol ?? info.DeclaredSymbol); if (canRename) { - ciset.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (MonoDevelop.Ide.Commands.EditCommands.Rename), new Action (delegate { - new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (info.Symbol ?? info.DeclaredSymbol); + ciset.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (MonoDevelop.Ide.Commands.EditCommands.Rename), new Action (async delegate { + await new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (info.Symbol ?? info.DeclaredSymbol); })); added = true; } @@ -199,7 +199,7 @@ namespace MonoDevelop.CSharp.Refactoring if (added & first && ciset.CommandInfos.Count > 0) ciset.CommandInfos.AddSeparator (); var info2 = new CommandInfo (fix.CodeAction.Title); - ciset.CommandInfos.Add (info2, new Action (new CodeActionEditorExtension.ContextActionRunner (fix.CodeAction, doc.Editor, doc).Run)); + ciset.CommandInfos.Add (info2, new Action (async () => await new CodeActionEditorExtension.ContextActionRunner (fix.CodeAction, doc.Editor, doc).Run ())); added = true; first = false; } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RenameHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RenameHandler.cs index c64225a77c..4d23c0de5e 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RenameHandler.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RenameHandler.cs @@ -37,6 +37,8 @@ using ICSharpCode.NRefactory6.CSharp; using MonoDevelop.Refactoring; using MonoDevelop.Refactoring.Rename; using MonoDevelop.Ide.TypeSystem; +using System.Threading.Tasks; +using System.Threading; namespace MonoDevelop.CSharp.Refactoring { @@ -71,21 +73,24 @@ namespace MonoDevelop.CSharp.Refactoring return false; } - protected override void Run (object data) + protected override async void Run (object data) { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.FileName == FilePath.Null) return; - Run (doc.Editor, doc); + await Run (doc.Editor, doc); } - internal void Run (TextEditor editor, DocumentContext ctx) + internal async Task Run (TextEditor editor, DocumentContext ctx) { - var info = RefactoringSymbolInfo.GetSymbolInfoAsync (ctx, editor.CaretOffset).Result; + var cts = new CancellationTokenSource (); + var getSymbolTask = RefactoringSymbolInfo.GetSymbolInfoAsync (ctx, editor.CaretOffset, cts.Token); + var message = GettextCatalog.GetString ("Resolving symbol…"); + var info = await MessageService.ExecuteTaskAndShowWaitDialog (getSymbolTask, message, cts); var sym = info.DeclaredSymbol ?? info.Symbol; if (!CanRename (sym)) return; - new RenameRefactoring ().Rename (sym); + await new RenameRefactoring ().Rename (sym); } } } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstStockIcons.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstStockIcons.cs index 9c433d95d9..634229726e 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstStockIcons.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstStockIcons.cs @@ -47,8 +47,10 @@ namespace MonoDevelop.CSharp static readonly IconId Property = "md-property"; static readonly IconId Struct = "md-struct"; static readonly IconId Delegate = "md-delegate"; + static readonly IconId Constant = "md-literal"; public static readonly IconId Namespace = "md-name-space"; + static void AdjustAccessibility (SyntaxTokenList modifiers, ref Accessibility acc, ref bool isStatic, ref bool result) { isStatic = modifiers.Any (mod => mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.StaticKeyword); @@ -108,12 +110,24 @@ namespace MonoDevelop.CSharp AdjustAccessibility (((BaseMethodDeclarationSyntax)element).Modifiers, ref acc, ref isStatic, ref result); return result; } - + + static bool IsConst (SyntaxTokenList modifiers) + { + return modifiers.Any (mod => mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.ConstKeyword); + } + + static bool IsConst (SyntaxNode element) + { + if (element is BaseFieldDeclarationSyntax) + return IsConst (((BaseFieldDeclarationSyntax)element).Modifiers); + if (element is LocalDeclarationStatementSyntax) + return IsConst (((LocalDeclarationStatementSyntax)element).Modifiers); + return false; + } public static string GetStockIcon (this SyntaxNode element) { Accessibility acc = Accessibility.Public; bool isStatic = false; - if (element is NamespaceDeclarationSyntax) return Namespace; @@ -165,8 +179,18 @@ namespace MonoDevelop.CSharp return "md-" + GetAccess (acc) + GetGlobal (isStatic) + "property"; if (element is EventDeclarationSyntax || element is EventFieldDeclarationSyntax) return "md-" + GetAccess (acc) + GetGlobal (isStatic) + "event"; - if (element.Parent is EnumDeclarationSyntax) - return "md-" + GetAccess (acc) + "enum"; + if (element is EnumMemberDeclarationSyntax) + return "md-literal"; + if (element?.Parent?.Parent is FieldDeclarationSyntax || element?.Parent?.Parent is LocalDeclarationStatementSyntax) { + if (IsConst (element.Parent.Parent)) + return "md-" + GetAccess (acc) + "literal"; + } + + if (element is FieldDeclarationSyntax || element is LocalDeclarationStatementSyntax) { + if (IsConst (element)) + return "md-" + GetAccess (acc) + "literal"; + } + return "md-" + GetAccess (acc) + GetGlobal (isStatic) + "field"; } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/DeclaredSymbolInfo.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/DeclaredSymbolInfo.cs index 5834286ce9..a6110bdae7 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/DeclaredSymbolInfo.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/DeclaredSymbolInfo.cs @@ -479,14 +479,16 @@ namespace MonoDevelop.CSharp return TypeSystemService.GetCodeAnalysisDocument (type.DocumentId, token); } - public override async Task<TooltipInformation> GetTooltipInformation (CancellationToken token) + public override Task<TooltipInformation> GetTooltipInformation (CancellationToken token) { - var doc = GetDocument (token); - if (doc == null) { - return new TooltipInformation (); - } - var symbol = await type.GetSymbolAsync (doc, token); - return await Ambience.GetTooltip (token, symbol); + return Task.Run (async delegate { + var doc = GetDocument (token); + if (doc == null) { + return null; + } + var symbol = await type.GetSymbolAsync (doc, token); + return await Ambience.GetTooltip (token, symbol); + }); } public override string Description { diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs index 4a13d0bebc..6ed61d9ca2 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs @@ -699,7 +699,7 @@ namespace MonoDevelop.CSharp return; } - var curMember = node != null ? node.AncestorsAndSelf ().FirstOrDefault (m => m is VariableDeclaratorSyntax || (m is MemberDeclarationSyntax && !(m is NamespaceDeclarationSyntax))) : null; + var curMember = node != null ? node.AncestorsAndSelf ().FirstOrDefault (m => m is VariableDeclaratorSyntax && m.Parent != null && !(m.Parent.Parent is LocalDeclarationStatementSyntax) || (m is MemberDeclarationSyntax && !(m is NamespaceDeclarationSyntax))) : null; var curType = node != null ? node.AncestorsAndSelf ().FirstOrDefault (IsType) : null; var curProject = ownerProjects != null && ownerProjects.Count > 1 ? DocumentContext.Project : null; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs index b445328784..b304f7d898 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/ProjectSearchCategory.cs @@ -296,13 +296,12 @@ namespace MonoDevelop.CSharp void AllResults (ISearchResultCallback searchResultCallback, WorkerResult lastResult, WorkerResult newResult, IReadOnlyList<DeclaredSymbolInfo> completeTypeList, CancellationToken token) { - uint x = 0; // Search Types newResult.filteredSymbols = new List<DeclaredSymbolInfo> (); bool startsWithLastFilter = lastResult.pattern != null && newResult.pattern.StartsWith (lastResult.pattern, StringComparison.Ordinal) && lastResult.filteredSymbols != null; var allTypes = startsWithLastFilter ? lastResult.filteredSymbols : completeTypeList; foreach (var type in allTypes) { - if (unchecked(x++) % 100 == 0 && token.IsCancellationRequested) { + if (token.IsCancellationRequested) { newResult.filteredSymbols = null; return; } diff --git a/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs index e916ed1e00..5fce0d401b 100644 --- a/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs +++ b/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs @@ -30,9 +30,13 @@ namespace ICSharpCode.NRefactory6.CSharp static ExpressionSyntaxExtensions () { - var typeInfo = Type.GetType ("Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true); - castIfPossibleMethod = typeInfo.GetMethod ("CastIfPossible", BindingFlags.Static | BindingFlags.Public); - tryReduceOrSimplifyExplicitNameMethod = typeInfo.GetMethod ("TryReduceOrSimplifyExplicitName", BindingFlags.Static | BindingFlags.Public); + var typeInfo = Type.GetType("Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions" + ReflectionNamespaces.CSWorkspacesAsmName, true); + castIfPossibleMethod = typeInfo.GetMethod("CastIfPossible", BindingFlags.Static | BindingFlags.Public); + if (castIfPossibleMethod == null) + throw new Exception ("ExpressionSyntaxExtensions: CastIfPossible not found"); + tryReduceOrSimplifyExplicitNameMethod = typeInfo.GetMethod("TryReduceOrSimplifyExplicitName", BindingFlags.Static | BindingFlags.Public); + if (tryReduceOrSimplifyExplicitNameMethod == null) + throw new Exception ("ExpressionSyntaxExtensions: TryReduceOrSimplifyExplicitName not found"); } /// <summary> @@ -43,13 +47,11 @@ namespace ICSharpCode.NRefactory6.CSharp this ExpressionSyntax expression, ITypeSymbol targetType, int position, - SemanticModel semanticModel, - out bool wasCastAdded) + SemanticModel semanticModel) { try { - var args = new object [] { expression, targetType, position, semanticModel, false }; + var args = new object [] { expression, targetType, position, semanticModel}; var result = (ExpressionSyntax)castIfPossibleMethod.Invoke (null, args); - wasCastAdded = (bool)args [4]; return result; } catch (TargetInvocationException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs index b3d738acc3..e7dc673155 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/AddinInfo.cs @@ -6,7 +6,14 @@ using Mono.Addins.Description; [assembly:Addin ("Deployment.Linux", Namespace = "MonoDevelop", Version = MonoDevelop.BuildInfo.Version, - Category = "Deployment")] + Category = "Deployment", + EnabledByDefault = + #if GNOME + true + #else + false + #endif +)] [assembly:AddinName ("Deployment Services for Linux")] [assembly:AddinDescription ("Provides basic deployment services for Linux")] diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj index 795bf7eab9..e9a5783a2e 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj +++ b/main/src/addins/Deployment/MonoDevelop.Deployment.Linux/MonoDevelop.Deployment.Linux.csproj @@ -40,6 +40,36 @@ <NoWarn>1591;1573</NoWarn> <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.Linux.xml</DocumentationFile> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugGnome|AnyCPU' "> + <DebugSymbols>True</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.Deployment</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>False</ConsolePause> + <Execution> + <Execution clr-version="Net_2_0" /> + </Execution> + <DefineConstants>DEBUG;GNOME</DefineConstants> + <NoWarn>1591;1573</NoWarn> + <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.Linux.xml</DocumentationFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseGnome|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>True</Optimize> + <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.Deployment</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>False</ConsolePause> + <Execution> + <Execution clr-version="Net_2_0" /> + </Execution> + <DebugSymbols>true</DebugSymbols> + <DefineConstants>GNOME</DefineConstants> + <NoWarn>1591;1573</NoWarn> + <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.Linux.xml</DocumentationFile> + </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> <Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project> diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs b/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs index db9f908173..990811ac25 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/AddinInfo.cs @@ -6,7 +6,14 @@ using Mono.Addins.Description; [assembly:Addin ("Deployment", Namespace = "MonoDevelop", Version = MonoDevelop.BuildInfo.Version, - Category = "Deployment")] + Category = "Deployment", + EnabledByDefault = + #if GNOME + true + #else + false + #endif + )] [assembly:AddinName ("Deployment Services Core")] [assembly:AddinDescription ("Provides basic deployment services")] diff --git a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj index 036befb130..5369de6b67 100644 --- a/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj +++ b/main/src/addins/Deployment/MonoDevelop.Deployment/MonoDevelop.Deployment.csproj @@ -40,6 +40,36 @@ <NoWarn>1591;1573</NoWarn> <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.xml</DocumentationFile> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugGnome|AnyCPU' "> + <DebugSymbols>True</DebugSymbols> + <Optimize>false</Optimize> + <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.Deployment</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>False</ConsolePause> + <Execution> + <Execution clr-version="Net_2_0" /> + </Execution> + <DefineConstants>DEBUG;GNOME</DefineConstants> + <NoWarn>1591;1573</NoWarn> + <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.xml</DocumentationFile> + <DebugType>full</DebugType> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseGnome|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>True</Optimize> + <OutputPath>..\..\..\..\build\AddIns\MonoDevelop.Deployment</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>False</ConsolePause> + <Execution> + <Execution clr-version="Net_2_0" /> + </Execution> + <DebugSymbols>true</DebugSymbols> + <DefineConstants>GNOME</DefineConstants> + <NoWarn>1591;1573</NoWarn> + <DocumentationFile>..\..\..\..\build\AddIns\MonoDevelop.Deployment\MonoDevelop.Deployment.xml</DocumentationFile> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="Mono.Posix" /> diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NRefactoryStock.cs b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NRefactoryStock.cs index c350fdfb50..661e52c07d 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NRefactoryStock.cs +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser/NRefactoryStock.cs @@ -99,13 +99,16 @@ namespace MonoDevelop.AssemblyBrowser static string GetGlobal (IEntity entity) { switch (entity.SymbolKind) { - case SymbolKind.Field: - case SymbolKind.Method: - case SymbolKind.Constructor: - case SymbolKind.Destructor: - case SymbolKind.Operator: - case SymbolKind.Property: - case SymbolKind.Indexer: + case SymbolKind.Field: + if (((IField)entity).IsConst) + return ""; + return entity.IsStatic ? "static-" : ""; + case SymbolKind.Method: + case SymbolKind.Constructor: + case SymbolKind.Destructor: + case SymbolKind.Operator: + case SymbolKind.Property: + case SymbolKind.Indexer: return entity.IsStatic ? "static-" : ""; } return ""; @@ -131,8 +134,11 @@ namespace MonoDevelop.AssemblyBrowser } return "class"; case SymbolKind.Field: - case SymbolKind.Event: + if (((IField)entity).IsConst) + return "literal"; return "field"; + case SymbolKind.Event: + return "event"; case SymbolKind.Method: case SymbolKind.Constructor: case SymbolKind.Destructor: @@ -207,7 +213,8 @@ namespace MonoDevelop.AssemblyBrowser } return "class"; case SymbolKind.Field: - return "field"; + var field = (IUnresolvedField)entity; + return field.IsConst ? "literal" : "field"; case SymbolKind.Event: return "event"; case SymbolKind.Method: diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs index 5da2ab92d6..b2a2c09794 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs @@ -480,10 +480,19 @@ namespace MonoDevelop.Debugger } } + Adjustment oldHadjustment; + Adjustment oldVadjustment; + //Don't convert this event handler to override OnSetScrollAdjustments as it causes problems void HandleScrollAdjustmentsSet (object o, ScrollAdjustmentsSetArgs args) { - Hadjustment.ValueChanged += UpdatePreviewPosition; - Vadjustment.ValueChanged += UpdatePreviewPosition; + if (oldHadjustment != null) { + oldHadjustment.ValueChanged -= UpdatePreviewPosition; + oldVadjustment.ValueChanged -= UpdatePreviewPosition; + } + oldHadjustment = Hadjustment; + oldVadjustment = Vadjustment; + oldHadjustment.ValueChanged += UpdatePreviewPosition; + oldVadjustment.ValueChanged += UpdatePreviewPosition; } void UpdatePreviewPosition (object sender, EventArgs e) @@ -540,8 +549,13 @@ namespace MonoDevelop.Debugger valueCol.RemoveNotification ("width", OnColumnWidthChanged); expCol.RemoveNotification ("width", OnColumnWidthChanged); - Hadjustment.ValueChanged -= UpdatePreviewPosition; - Vadjustment.ValueChanged -= UpdatePreviewPosition; + ScrollAdjustmentsSet -= HandleScrollAdjustmentsSet; + if (oldHadjustment != null) { + oldHadjustment.ValueChanged -= UpdatePreviewPosition; + oldVadjustment.ValueChanged -= UpdatePreviewPosition; + oldHadjustment = null; + oldVadjustment = null; + } values.Clear (); valueNames.Clear (); diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/TextEntryWithCodeCompletion.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/TextEntryWithCodeCompletion.cs index b581c8a87f..108ea39c90 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/TextEntryWithCodeCompletion.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/TextEntryWithCodeCompletion.cs @@ -52,6 +52,12 @@ namespace MonoDevelop.Debugger CompletionWindowManager.WindowClosed += HandleWindowClosed; } + protected override void Dispose (bool disposing)
+ { + CompletionWindowManager.WindowClosed -= HandleWindowClosed;
+ base.Dispose (disposing);
+ } + void HandleWindowClosed (object sender, EventArgs e) { ctx = null; diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ItemToolboxNode.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ItemToolboxNode.cs index f719a3468b..263f31f300 100644 --- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ItemToolboxNode.cs +++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ItemToolboxNode.cs @@ -58,7 +58,10 @@ namespace MonoDevelop.DesignerSupport.Toolbox string category = ""; [ItemProperty ("description")] - string description = ""; + string description = "";
+
+ [ItemProperty ("source")]
+ string source = ""; List <ToolboxItemFilterAttribute> itemFilters = new List <ToolboxItemFilterAttribute> (); @@ -94,6 +97,11 @@ namespace MonoDevelop.DesignerSupport.Toolbox public virtual string Description { get { return description; } set { description = value; } + }
+
+ public virtual string Source {
+ get { return source; }
+ set { source = value; }
} [Browsable(false)] @@ -113,13 +121,14 @@ namespace MonoDevelop.DesignerSupport.Toolbox public virtual bool Filter (string keyword) { return ((Name != null) && (Name.IndexOf (keyword, StringComparison.InvariantCultureIgnoreCase) >= 0)) - || ((Description != null) && (Description.IndexOf (keyword, StringComparison.InvariantCultureIgnoreCase) >= 0)); + || ((Description != null) && (Description.IndexOf (keyword, StringComparison.InvariantCultureIgnoreCase) >= 0))
+ || ((Source != null) && (Source.IndexOf (keyword, StringComparison.InvariantCultureIgnoreCase) >= 0)); } public override bool Equals (object o) { ItemToolboxNode node = o as ItemToolboxNode; - return (node != null) && (node.Name == this.Name) && (node.Category == this.Category) && (node.Description == this.Description); + return (node != null) && (node.Name == this.Name) && (node.Category == this.Category) && (node.Description == this.Description) && (node.Source == this.Source); } public override int GetHashCode () @@ -131,6 +140,8 @@ namespace MonoDevelop.DesignerSupport.Toolbox code ^= Category.GetHashCode ();
if (Description != null)
code ^= Description.GetHashCode ();
+ if (Source != null)
+ code ^= Source.GetHashCode ();
return code; } diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ToolboxWidget.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ToolboxWidget.cs index 15b0e219dc..8c1f52522a 100644 --- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ToolboxWidget.cs +++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/ToolboxWidget.cs @@ -259,7 +259,7 @@ namespace MonoDevelop.DesignerSupport.Toolbox cr.SetSourceColor (MonoDevelop.Ide.Gui.Styles.PadCategoryBorderColor.ToCairoColor ()); cr.Stroke (); - headerLayout.SetText (category.Text); + headerLayout.SetMarkup (category.Text); int width, height; cr.SetSourceColor (MonoDevelop.Ide.Gui.Styles.PadCategoryLabelColor.ToCairoColor ()); layout.GetPixelSize (out width, out height); @@ -284,7 +284,7 @@ namespace MonoDevelop.DesignerSupport.Toolbox } if (listMode || !curCategory.CanIconizeItems) { cr.DrawImage (this, item.Icon, xpos + ItemLeftPadding, ypos + Math.Round ((itemDimension.Height - item.Icon.Height) / 2)); - layout.SetText (item.Text); + layout.SetMarkup (item.Text); int width, height; layout.GetPixelSize (out width, out height); cr.SetSourceColor (Style.Text (item != this.SelectedItem ? StateType.Normal : StateType.Selected).ToCairoColor ()); @@ -827,7 +827,7 @@ namespace MonoDevelop.DesignerSupport.Toolbox int x, y = item.ItemHeight; if (y == 0) { - layout.SetText (item.Text); + layout.SetMarkup (item.Text); layout.GetPixelSize (out x, out y); y = Math.Max (IconSize.Height, y); y += ItemTopBottomPadding * 2; @@ -867,7 +867,7 @@ namespace MonoDevelop.DesignerSupport.Toolbox int x, y = category.ItemHeight; if (y == 0) { - layout.SetText (category.Text); + layout.SetMarkup (category.Text); layout.GetPixelSize (out x, out y); y += CategoryTopBottomPadding * 2; category.ItemHeight = y; @@ -1126,8 +1126,14 @@ namespace MonoDevelop.DesignerSupport.Toolbox public string Text { get { - if (node != null) - return node.Name; + if (node != null) { + var t = GLib.Markup.EscapeText (node.Name); + if (!string.IsNullOrEmpty (node.Source)) { + var c = MonoDevelop.Ide.Gui.Styles.DimTextColor.ToHexString ().Substring (0, 7); + t += string.Format (" <span size=\"smaller\" color=\"{1}\">{0}</span>", node.Source, c); + } + return t; + } return text; } } @@ -1174,7 +1180,7 @@ namespace MonoDevelop.DesignerSupport.Toolbox public Item (Xwt.Drawing.Image icon, string text, string tooltip, object tag) { this.icon = icon; - this.text = text; + this.text = GLib.Markup.EscapeText (text); this.tooltip = tooltip; this.tag = tag; } diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs index ba794c06f8..bef385e027 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupView.cs @@ -197,9 +197,9 @@ namespace MonoDevelop.GtkCore.GuiBuilder codeBinder.BindSignal (a.Signal); } - void OnSignalChanged (object s, Stetic.ComponentSignalEventArgs a) + async void OnSignalChanged (object s, Stetic.ComponentSignalEventArgs a) { - codeBinder.UpdateSignal (a.OldSignal, a.Signal); + await codeBinder.UpdateSignal (a.OldSignal, a.Signal); } async void OnBindField (object s, EventArgs args) diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs index 3076ef4d8d..bff4e49428 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs @@ -135,7 +135,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder return cls.GetMembers (signal.Handler).OfType<IMethodSymbol> ().FirstOrDefault (); } - public void UpdateField (Stetic.Component obj, string oldName) + public async Task UpdateField (Stetic.Component obj, string oldName) { if (targetObject == null) return; @@ -152,7 +152,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (cls != null) { var f = ClassUtils.FindWidgetField (cls, oldName); if (f != null) { - MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (f, newName); + await MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (f, newName); } } } @@ -195,7 +195,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder return cls.Locations.First (); } - public void UpdateSignal (Stetic.Signal oldSignal, Stetic.Signal newSignal) + public async Task UpdateSignal (Stetic.Signal oldSignal, Stetic.Signal newSignal) { if (targetObject == null) return; @@ -209,7 +209,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder var met = FindSignalHandler (cls, oldSignal); if (met == null) return; - MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (met, newSignal.Handler); + await MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (met, newSignal.Handler); } /// Adds a field to the class diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs index c0ae7f6a29..00845bd1f2 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderView.cs @@ -267,7 +267,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder codeBinder.TargetObject = designer.RootComponent; } - void OnComponentNameChanged (object s, Stetic.ComponentNameEventArgs args) + async void OnComponentNameChanged (object s, Stetic.ComponentNameEventArgs args) { try { // Make sure the fields in the partial class are up to date. @@ -278,7 +278,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (gproject.Project.UsePartialTypes) GuiBuilderService.GenerateSteticCodeStructure ((DotNetProject)gproject.Project, designer.RootComponent, args, false, false); - codeBinder.UpdateField (args.Component, args.OldName); + await codeBinder.UpdateField (args.Component, args.OldName); } catch (Exception ex) { LoggingService.LogInternalError (ex); @@ -323,9 +323,9 @@ namespace MonoDevelop.GtkCore.GuiBuilder { } - void OnSignalChanged (object sender, Stetic.ComponentSignalEventArgs args) + async void OnSignalChanged (object sender, Stetic.ComponentSignalEventArgs args) { - codeBinder.UpdateSignal (args.OldSignal, args.Signal); + await codeBinder.UpdateSignal (args.OldSignal, args.Signal); } public override async Task Save (FileSaveInformation fileSaveInformation) diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs index 07b7b9917b..98eff922a8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs @@ -91,8 +91,7 @@ namespace MonoDevelop.PackageManagement ImageLoadedEventArgs LoadImage (Uri uri, object state)
{
try {
- var httpClient = new HttpClient (uri);
- Stream stream = httpClient.GetResponse ().GetResponseStream ();
+ Stream stream = GetResponseStream (uri);
Image image = Image.FromStream (stream);
return new ImageLoadedEventArgs (image, uri, state);
@@ -101,6 +100,17 @@ namespace MonoDevelop.PackageManagement }
}
+ static Stream GetResponseStream (Uri uri)
+ {
+ if (uri.IsFile) {
+ var request = WebRequest.Create (uri);
+ return request.GetResponse ().GetResponseStream ();
+ }
+
+ var httpClient = new HttpClient (uri);
+ return httpClient.GetResponse ().GetResponseStream ();
+ }
+
void OnLoaded (ITask<ImageLoadedEventArgs> task, Uri uri, object state)
{
if (task.IsFaulted) {
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs index 421f6c311a..9a7e31ccdc 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs @@ -103,7 +103,7 @@ namespace MonoDevelop.CodeActions Editor.CaretPositionChanged -= HandleCaretPositionChanged; Editor.SelectionChanged -= HandleSelectionChanged; DocumentContext.DocumentParsed -= HandleDocumentDocumentParsed; - Editor.BeginMouseHover -= HandleBeginHover; + Editor.MouseMoved -= HandleBeginHover; Editor.TextChanged -= Editor_TextChanged; Editor.EndAtomicUndoOperation -= Editor_EndAtomicUndoOperation; RemoveWidget (); @@ -178,12 +178,12 @@ namespace MonoDevelop.CodeActions var diagnosticsAtCaret = Editor.GetTextSegmentMarkersAt (Editor.CaretOffset) - .OfType<IGenericTextSegmentMarker> () - .Select (rm => rm.Tag) - .OfType<DiagnosticResult> () - .Select (dr => dr.Diagnostic) - .ToList (); - + .OfType<IGenericTextSegmentMarker> () + .Select (rm => rm.Tag) + .OfType<DiagnosticResult> () + .Select (dr => dr.Diagnostic) + .ToList (); + var errorList = Editor .GetTextSegmentMarkersAt (Editor.CaretOffset) .OfType<IErrorMarker> () @@ -289,10 +289,8 @@ namespace MonoDevelop.CodeActions { readonly List<FixMenuEntry> items = new List<FixMenuEntry> (); - public IReadOnlyList<FixMenuEntry> Items - { - get - { + public IReadOnlyList<FixMenuEntry> Items { + get { return items; } } @@ -310,8 +308,7 @@ namespace MonoDevelop.CodeActions items.Add (entry); } - public object MotionNotifyEvent - { + public object MotionNotifyEvent { get; set; } @@ -325,10 +322,10 @@ namespace MonoDevelop.CodeActions //ICSharpCode.NRefactory.CSharp.AstNode node; int items = 0; -// if (AddPossibleNamespace != null) { -// AddPossibleNamespace (Editor, DocumentContext, menu); -// items = menu.Items.Count; -// } + // if (AddPossibleNamespace != null) { + // AddPossibleNamespace (Editor, DocumentContext, menu); + // items = menu.Items.Count; + // } PopulateFixes (fixMenu, ref items); @@ -399,11 +396,11 @@ namespace MonoDevelop.CodeActions static string CreateLabel (string title, ref int mnemonic) { var escapedLabel = title.Replace ("_", "__"); - #if MAC +#if MAC return escapedLabel; - #else +#else return (mnemonic <= 10) ? "_" + mnemonic++ % 10 + " \u2013 " + escapedLabel : " " + escapedLabel; - #endif +#endif } internal class FixAllDiagnosticProvider : FixAllContext.DiagnosticProvider @@ -426,7 +423,7 @@ namespace MonoDevelop.CodeActions /// </summary> private readonly Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> _getProjectDiagnosticsAsync; - public FixAllDiagnosticProvider( + public FixAllDiagnosticProvider ( ImmutableHashSet<string> diagnosticIds, Func<Microsoft.CodeAnalysis.Document, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getDocumentDiagnosticsAsync, Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getProjectDiagnosticsAsync) @@ -436,19 +433,19 @@ namespace MonoDevelop.CodeActions _getProjectDiagnosticsAsync = getProjectDiagnosticsAsync; } - public override Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync(Microsoft.CodeAnalysis.Document document, CancellationToken cancellationToken) + public override Task<IEnumerable<Diagnostic>> GetDocumentDiagnosticsAsync (Microsoft.CodeAnalysis.Document document, CancellationToken cancellationToken) { - return _getDocumentDiagnosticsAsync(document, _diagnosticIds, cancellationToken); + return _getDocumentDiagnosticsAsync (document, _diagnosticIds, cancellationToken); } - public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) + public override Task<IEnumerable<Diagnostic>> GetAllDiagnosticsAsync (Project project, CancellationToken cancellationToken) { - return _getProjectDiagnosticsAsync(project, true, _diagnosticIds, cancellationToken); + return _getProjectDiagnosticsAsync (project, true, _diagnosticIds, cancellationToken); } - public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) + public override Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync (Project project, CancellationToken cancellationToken) { - return _getProjectDiagnosticsAsync(project, false, _diagnosticIds, cancellationToken); + return _getProjectDiagnosticsAsync (project, false, _diagnosticIds, cancellationToken); } } void PopulateFixes (FixMenuDescriptor menu, ref int items) @@ -467,8 +464,8 @@ namespace MonoDevelop.CodeActions var fix = fix_; var label = CreateLabel (fix.CodeAction.Title, ref mnemonic); - var thisInstanceMenuItem = new FixMenuEntry (label, delegate { - new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run (null, EventArgs.Empty); + var thisInstanceMenuItem = new FixMenuEntry (label,async delegate { + await new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run (); ConfirmUsage (fix.CodeAction.EquivalenceKey); }); menu.Add (thisInstanceMenuItem); @@ -484,8 +481,8 @@ namespace MonoDevelop.CodeActions } var label = CreateLabel (fix.CodeAction.Title, ref mnemonic); - var thisInstanceMenuItem = new FixMenuEntry (label, delegate { - new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run (null, EventArgs.Empty); + var thisInstanceMenuItem = new FixMenuEntry (label, async delegate { + await new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run (); ConfirmUsage (fix.CodeAction.EquivalenceKey); }); menu.Add (thisInstanceMenuItem); @@ -560,7 +557,7 @@ namespace MonoDevelop.CodeActions return await compilationWithAnalyzer.GetAnalyzerSemanticDiagnosticsAsync (model, null, token); }, (Project arg1, bool arg2, ImmutableHashSet<string> arg3, CancellationToken arg4) => { - return Task.FromResult ((IEnumerable<Diagnostic>)new Diagnostic[] { }); + return Task.FromResult ((IEnumerable<Diagnostic>)new Diagnostic [] { }); }); var ctx = new FixAllContext ( this.DocumentContext.AnalysisDocument, @@ -577,7 +574,7 @@ namespace MonoDevelop.CodeActions } }); subMenu2.Add (menuItem); - subMenu.Add (FixMenuEntry.Separator); + subMenu.Add (FixMenuEntry.Separator); subMenu.Add (subMenu2); } @@ -599,14 +596,9 @@ namespace MonoDevelop.CodeActions this.documentContext = documentContext; } - public void Run (object sender, EventArgs e) + public async Task Run () { - Run (); - } - - internal async void Run () - { - var token = default(CancellationToken); + var token = default (CancellationToken); var insertionAction = act as InsertionAction; if (insertionAction != null) { var insertion = await insertionAction.CreateInsertion (token).ConfigureAwait (false); @@ -655,7 +647,7 @@ namespace MonoDevelop.CodeActions operation.Apply (documentContext.RoslynWorkspace, token); } } - TryStartRenameSession (documentContext.RoslynWorkspace, oldSolution, updatedSolution, token); + await TryStartRenameSession (documentContext.RoslynWorkspace, oldSolution, updatedSolution, token); } static IEnumerable<DocumentId> GetChangedDocuments (Solution newSolution, Solution oldSolution) @@ -670,30 +662,30 @@ namespace MonoDevelop.CodeActions } } - async void TryStartRenameSession (Workspace workspace, Solution oldSolution, Solution newSolution, CancellationToken cancellationToken) + async Task TryStartRenameSession (Workspace workspace, Solution oldSolution, Solution newSolution, CancellationToken cancellationToken) { var changedDocuments = GetChangedDocuments (newSolution, oldSolution); foreach (var documentId in changedDocuments) { var document = newSolution.GetDocument (documentId); var root = await document.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false); SyntaxToken? renameTokenOpt = root.GetAnnotatedNodesAndTokens (RenameAnnotation.Kind) - .Where (s => s.IsToken) - .Select (s => s.AsToken ()) - .Cast<SyntaxToken?> () - .FirstOrDefault (); + .Where (s => s.IsToken) + .Select (s => s.AsToken ()) + .Cast<SyntaxToken?> () + .FirstOrDefault (); if (renameTokenOpt.HasValue) { var latestDocument = workspace.CurrentSolution.GetDocument (documentId); var latestModel = await latestDocument.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false); var latestRoot = await latestDocument.GetSyntaxRootAsync (cancellationToken).ConfigureAwait (false); - Application.Invoke (delegate { + await Runtime.RunInMainThread (async delegate { try { var node = latestRoot.FindNode (renameTokenOpt.Value.Parent.Span, false, false); if (node == null) return; var info = latestModel.GetSymbolInfo (node); var sym = info.Symbol ?? latestModel.GetDeclaredSymbol (node); - if (sym != null) - new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym); + if (sym != null) + await new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym); } catch (Exception ex) { LoggingService.LogError ("Error while renaming " + renameTokenOpt.Value.Parent, ex); } @@ -723,11 +715,11 @@ namespace MonoDevelop.CodeActions return; } -// var container = editor.Parent; -// if (container == null) { -// RemoveWidget (); -// return; -// } + // var container = editor.Parent; + // if (container == null) { + // RemoveWidget (); + // return; + // } bool first = true; var smartTagLocBegin = offset; foreach (var fix in fixes.CodeFixActions.Concat (fixes.CodeRefactoringActions)) { @@ -739,19 +731,19 @@ namespace MonoDevelop.CodeActions } first = false; } -// if (smartTagLocBegin.Line != loc.Line) -// smartTagLocBegin = new DocumentLocation (loc.Line, 1); + // if (smartTagLocBegin.Line != loc.Line) + // smartTagLocBegin = new DocumentLocation (loc.Line, 1); // got no fix location -> try to search word start -// if (first) { -// int offset = document.Editor.LocationToOffset (smartTagLocBegin); -// while (offset > 0) { -// char ch = document.Editor.GetCharAt (offset - 1); -// if (!char.IsLetterOrDigit (ch) && ch != '_') -// break; -// offset--; -// } -// smartTagLocBegin = document.Editor.OffsetToLocation (offset); -// } + // if (first) { + // int offset = document.Editor.LocationToOffset (smartTagLocBegin); + // while (offset > 0) { + // char ch = document.Editor.GetCharAt (offset - 1); + // if (!char.IsLetterOrDigit (ch) && ch != '_') + // break; + // offset--; + // } + // smartTagLocBegin = document.Editor.OffsetToLocation (offset); + // } if (currentSmartTag != null && currentSmartTagBegin == smartTagLocBegin) { return; @@ -783,7 +775,7 @@ namespace MonoDevelop.CodeActions base.Initialize (); DocumentContext.DocumentParsed += HandleDocumentDocumentParsed; Editor.SelectionChanged += HandleSelectionChanged; - Editor.BeginMouseHover += HandleBeginHover; + Editor.MouseMoved += HandleBeginHover; Editor.CaretPositionChanged += HandleCaretPositionChanged; Editor.TextChanged += Editor_TextChanged; Editor.EndAtomicUndoOperation += Editor_EndAtomicUndoOperation; @@ -832,7 +824,7 @@ namespace MonoDevelop.CodeActions HandleCaretPositionChanged (null, EventArgs.Empty); } - [CommandUpdateHandler(RefactoryCommands.QuickFix)] + [CommandUpdateHandler (RefactoryCommands.QuickFix)] public void UpdateQuickFixCommand (CommandInfo ci) { if (AnalysisOptions.EnableFancyFeatures) { @@ -846,13 +838,13 @@ namespace MonoDevelop.CodeActions { CancelSmartTagPopupTimeout (); smartTagPopupTimeoutId = GLib.Timeout.Add (menuTimeout, delegate { - PopupQuickFixMenu (null, menu => {}); + PopupQuickFixMenu (null, menu => { }); smartTagPopupTimeoutId = 0; return false; }); } - [CommandHandler(RefactoryCommands.QuickFix)] + [CommandHandler (RefactoryCommands.QuickFix)] void OnQuickFixCommand () { if (!AnalysisOptions.EnableFancyFeatures) { diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameItemDialog.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameItemDialog.cs index 705d830ac6..df89b5ae2d 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameItemDialog.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameItemDialog.cs @@ -35,14 +35,15 @@ using MonoDevelop.Ide.ProgressMonitoring; using System.Linq; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis; +using System.Threading.Tasks; namespace MonoDevelop.Refactoring.Rename { public partial class RenameItemDialog : Gtk.Dialog { - Func<RenameRefactoring.RenameProperties, IList<Change>> rename; + Func<RenameRefactoring.RenameProperties, Task<IList<Change>>> rename; - public RenameItemDialog (string title, string currentName, Func<RenameRefactoring.RenameProperties, IList<Change>> renameOperation) + public RenameItemDialog (string title, string currentName, Func<RenameRefactoring.RenameProperties, Task<IList<Change>>> renameOperation) { this.Build (); Init (title, currentName, renameOperation); @@ -112,11 +113,11 @@ namespace MonoDevelop.Refactoring.Rename } - Init (title, symbol.Name, prop => { rename.PerformChanges (symbol, prop); return new List<Change> (); }); + Init (title, symbol.Name, async prop => { await rename.PerformChangesAsync (symbol, prop); return new List<Change> (); }); } - void Init (string title, string currenName, Func<RenameRefactoring.RenameProperties, IList<Change>> rename) + void Init (string title, string currenName, Func<RenameRefactoring.RenameProperties, Task<IList<Change>>> rename) { this.Title = title; this.rename = rename; @@ -178,20 +179,20 @@ namespace MonoDevelop.Refactoring.Rename } } - void OnOKClicked (object sender, EventArgs e) + async void OnOKClicked (object sender, EventArgs e) { var properties = Properties; ((Widget)this).Destroy (); - var changes = this.rename (properties); + var changes = await this.rename (properties); ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor (Title, null); RefactoringService.AcceptChanges (monitor, changes); } - void OnPreviewClicked (object sender, EventArgs e) + async void OnPreviewClicked (object sender, EventArgs e) { var properties = Properties; ((Widget)this).Destroy (); - var changes = this.rename (properties); + var changes = await this.rename (properties); using (var dlg = new RefactoringPreviewDialog (changes)) MessageService.ShowCustomDialog (dlg); } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs index 533fc2fddc..c3da0aae9a 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs @@ -41,19 +41,21 @@ using MonoDevelop.Ide.Gui; using MonoDevelop.Core.Text; using MonoDevelop.Ide.Editor; using Microsoft.CodeAnalysis.Rename; +using System.Threading.Tasks; +using System.Threading; namespace MonoDevelop.Refactoring.Rename { public class RenameRefactoring { - public static bool Rename (ISymbol symbol, string newName) + public static async Task<bool> Rename (ISymbol symbol, string newName) { if (symbol == null) throw new ArgumentNullException ("symbol"); if (newName == null) throw new ArgumentNullException ("newName"); try { - new RenameRefactoring ().PerformChanges (symbol, new RenameProperties () { NewName = newName }); + await new RenameRefactoring ().PerformChangesAsync (symbol, new RenameProperties () { NewName = newName }); return true; } catch (AggregateException ae) { foreach (var inner in ae.Flatten ().InnerExceptions) @@ -73,20 +75,22 @@ namespace MonoDevelop.Refactoring.Rename } } - public void Rename (ISymbol symbol) + public async Task Rename (ISymbol symbol) { - var solution = IdeApp.ProjectOperations.CurrentSelectedSolution; var ws = TypeSystemService.GetWorkspace (solution); var currentSolution = ws.CurrentSolution; - var newSolution = Renamer.RenameSymbolAsync (currentSolution, symbol, "_" + symbol.Name + "_", ws.Options).Result; + var cts = new CancellationTokenSource (); + var newSolution = await MessageService.ExecuteTaskAndShowWaitDialog (Task.Run (() => Renamer.RenameSymbolAsync (currentSolution, symbol, "_" + symbol.Name + "_", ws.Options, cts.Token)), GettextCatalog.GetString ("Looking for all references"), cts); var projectChanges = currentSolution.GetChanges (newSolution).GetProjectChanges ().ToList (); var changedDocuments = new HashSet<string> (); - foreach (var change in projectChanges) + foreach (var change in projectChanges) { foreach (var changedDoc in change.GetChangedDocuments ()) { changedDocuments.Add (ws.CurrentSolution.GetDocument (changedDoc).FilePath); } + } + if (changedDocuments.Count > 1) { using (var dlg = new RenameItemDialog (symbol, this)) MessageService.ShowCustomDialog (dlg); @@ -110,7 +114,7 @@ namespace MonoDevelop.Refactoring.Rename var oldDoc = projectChange.OldProject.GetDocument (cd); var newDoc = projectChange.NewProject.GetDocument (cd); var oldVersion = editor.Version; - foreach (var textChange in oldDoc.GetTextChangesAsync (newDoc).Result) { + foreach (var textChange in await oldDoc.GetTextChangesAsync (newDoc)) { var segment = new TextSegment (textChange.Span.Start, textChange.Span.Length); if (segment.Offset <= editor.CaretOffset && editor.CaretOffset <= segment.EndOffset) { link.Links.Insert (0, segment); @@ -149,12 +153,12 @@ namespace MonoDevelop.Refactoring.Rename } } - public void PerformChanges (ISymbol symbol, RenameProperties properties) + public async Task PerformChangesAsync (ISymbol symbol, RenameProperties properties) { var solution = IdeApp.ProjectOperations.CurrentSelectedSolution; var ws = TypeSystemService.GetWorkspace (solution); - var newSolution = Renamer.RenameSymbolAsync (ws.CurrentSolution, symbol, properties.NewName, ws.Options).Result; + var newSolution = await Renamer.RenameSymbolAsync (ws.CurrentSolution, symbol, properties.NewName, ws.Options); ws.TryApplyChanges (newSolution); } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringSymbolInfo.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringSymbolInfo.cs index a901409aba..bad5206b3d 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringSymbolInfo.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringSymbolInfo.cs @@ -76,22 +76,32 @@ namespace MonoDevelop.Refactoring this.symbolInfo = symbolInfo; } - public static async Task<RefactoringSymbolInfo> GetSymbolInfoAsync (DocumentContext document, int offset, CancellationToken cancellationToken = default(CancellationToken)) + public static Task<RefactoringSymbolInfo> GetSymbolInfoAsync (DocumentContext document, int offset, CancellationToken cancellationToken = default (CancellationToken)) { if (document == null) throw new ArgumentNullException (nameof (document)); - if (document.ParsedDocument == null) - return RefactoringSymbolInfo.Empty; - var unit = await document.AnalysisDocument.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false); + if (document.AnalysisDocument == null) + return Task.FromResult (RefactoringSymbolInfo.Empty); + + if (Runtime.IsMainThread) {//InternalGetSymbolInfoAsync can be CPU heavy, go to ThreadPool if we are on UI thread + return Task.Run (() => InternalGetSymbolInfoAsync (document.AnalysisDocument, offset, cancellationToken)); + } else { + return InternalGetSymbolInfoAsync (document.AnalysisDocument, offset, cancellationToken); + } + } + + static async Task<RefactoringSymbolInfo> InternalGetSymbolInfoAsync (Microsoft.CodeAnalysis.Document document, int offset, CancellationToken cancellationToken = default (CancellationToken)) + { + var unit = await document.GetSemanticModelAsync (cancellationToken).ConfigureAwait (false); if (unit != null) { var root = await unit.SyntaxTree.GetRootAsync (cancellationToken).ConfigureAwait (false); try { var token = root.FindToken (offset); if (!token.Span.IntersectsWith (offset)) return RefactoringSymbolInfo.Empty; - var symbol = unit.GetSymbolInfo (token.Parent); + var symbol = unit.GetSymbolInfo (token.Parent, cancellationToken); return new RefactoringSymbolInfo (symbol) { - DeclaredSymbol = token.IsKind (SyntaxKind.IdentifierToken) ? unit.GetDeclaredSymbol (token.Parent) : null, + DeclaredSymbol = token.IsKind (SyntaxKind.IdentifierToken) ? unit.GetDeclaredSymbol (token.Parent, cancellationToken) : null, Node = token.Parent, Model = unit }; diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/BehaviorPanel.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/BehaviorPanel.cs index 5d9067d374..3a49025ecf 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/BehaviorPanel.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/BehaviorPanel.cs @@ -63,6 +63,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels checkbuttonFormatOnSave.Active = PropertyService.Get ("AutoFormatDocumentOnSave", false); checkbuttonAutoSetSearchPatternCasing.Active = PropertyService.Get ("AutoSetPatternCasing", false); + checkbuttonEnableSelectionSurrounding.Active = DefaultSourceEditorOptions.Instance.EnableSelectionWrappingKeys; HandleAutoInsertBraceCheckbuttonToggled (null, null); return this; } @@ -84,6 +85,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels DefaultSourceEditorOptions.Instance.GenerateFormattingUndoStep = checkbuttonGenerateFormattingUndoStep.Active; PropertyService.Set ("AutoSetPatternCasing", checkbuttonAutoSetSearchPatternCasing.Active); PropertyService.Set ("AutoFormatDocumentOnSave", checkbuttonFormatOnSave.Active); + DefaultSourceEditorOptions.Instance.EnableSelectionWrappingKeys = checkbuttonEnableSelectionSurrounding.Active; } public void Initialize (OptionsDialog dialog, object dataObject) diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs index cf9c19719c..9308a6cd92 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/HighlightingPanel.cs @@ -239,6 +239,11 @@ namespace MonoDevelop.SourceEditor.OptionPanels bool success = true; try { + if (File.Exists (newFileName)) { + MessageService.ShowError (string.Format (GettextCatalog.GetString ("Highlighting with the same name already exists. Remove {0} first."), System.IO.Path.GetFileNameWithoutExtension (newFileName))); + return; + } + File.Copy (dialog.SelectedFile.FullPath, newFileName); } catch (Exception e) { success = false; diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskMiniMapMode.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskMiniMapMode.cs index 9933a283cc..79fab2b7a6 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskMiniMapMode.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskMiniMapMode.cs @@ -41,6 +41,7 @@ namespace MonoDevelop.SourceEditor.QuickTasks { Minimpap minimap; QuickTaskOverviewMode rightMap; + Adjustment vadjustment; public QuickTaskMiniMapMode (QuickTaskStrip parent) { @@ -49,6 +50,23 @@ namespace MonoDevelop.SourceEditor.QuickTasks rightMap = new QuickTaskOverviewMode (parent); PackStart (rightMap, true, true, 0); + vadjustment = parent.VAdjustment; + + vadjustment.ValueChanged += RedrawOnVAdjustmentChange; + + } + + + protected override void OnDestroyed () + { + vadjustment.ValueChanged -= RedrawOnVAdjustmentChange; + + base.OnDestroyed (); + } + + void RedrawOnVAdjustmentChange (object sender, EventArgs e) + { + QueueDraw (); } public void ForceDraw () diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs index 01594651b1..a9057f8d7f 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs @@ -112,5 +112,15 @@ namespace MonoDevelop.SourceEditor.Wrappers } } #endregion + + public override bool Equals (object obj) + { + if (ReferenceEquals (obj, this)) + return true; + var other = obj as MonoDevelop.Ide.Editor.IDocumentLine; + if (other == null) + return false; + return Line.Offset == other.Offset && Line.Length == other.Length; + } } }
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs index 689dbc590e..27c2595dfe 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueWindow.cs @@ -139,24 +139,42 @@ namespace MonoDevelop.SourceEditor tree.AddValue (value); tree.Selection.UnselectAll (); tree.SizeAllocated += OnTreeSizeChanged; - tree.PinStatusChanged += delegate { - Destroy (); - }; + tree.PinStatusChanged += OnPinStatusChanged; sw.ShowAll (); - tree.StartEditing += delegate { - Modal = true; - }; - - tree.EndEditing += delegate { - Modal = false; - }; + tree.StartEditing += OnStartEditing; + tree.EndEditing += OnEndEditing; ShowArrow = true; Theme.CornerRadius = 3; } + void OnStartEditing (object sender, EventArgs args) + { + Modal = true; + } + + void OnEndEditing (object sender, EventArgs args) + { + Modal = false; + } + + void OnPinStatusChanged (object sender, EventArgs args) + { + Destroy (); + } + + protected override void OnDestroyed ()
+ { + tree.StartEditing -= OnStartEditing; + tree.EndEditing -= OnEndEditing; + tree.PinStatusChanged -= OnPinStatusChanged; + tree.SizeAllocated -= OnTreeSizeChanged; +
+ base.OnDestroyed ();
+ } + protected override bool OnEnterNotifyEvent (EventCrossing evnt) { if (!AcceptFocus) diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs index 5c8909100b..ea20ea46d3 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/MessageBubbleTextMarker.cs @@ -350,8 +350,14 @@ namespace MonoDevelop.SourceEditor } #region IActionTextMarker implementation + int curError = 0; public bool MousePressed (MonoTextEditor editor, MarginMouseEventArgs args) { + if (bubbleDrawX < args.X && args.X < bubbleDrawX + bubbleWidth) { + errors [curError].Task.SelectInPad (); + curError = (curError + 1) % errors.Count; + return true; + } return false; } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs index 3db816764c..26a12a5474 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs @@ -205,8 +205,17 @@ namespace MonoDevelop.SourceEditor if (oldPattern != SearchAndReplaceOptions.SearchPattern) UpdateSearchEntry (); var history = GetHistory (seachHistoryProperty); + + // Don't do anything to the history if we have a blank search + if (string.IsNullOrWhiteSpace (SearchPattern)) { + return; + } + if (history.Count > 0 && history [0] == oldPattern) { - ChangeHistory (seachHistoryProperty, SearchAndReplaceOptions.SearchPattern); + // Only update the current history item if we're adding to the search string + if (!oldPattern.StartsWith (SearchPattern)) { + ChangeHistory (seachHistoryProperty, SearchAndReplaceOptions.SearchPattern); + } } else { UpdateSearchHistory (SearchAndReplaceOptions.SearchPattern); } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs index 7812988d49..bcc5a19c1f 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs @@ -2468,7 +2468,7 @@ namespace MonoDevelop.SourceEditor } } - event EventHandler ITextEditorImpl.BeginMouseHover { + event EventHandler<Xwt.MouseMovedEventArgs> ITextEditorImpl.MouseMoved { add { TextEditor.BeginHover += value; } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs index df5664c837..79c2d07437 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs @@ -319,12 +319,19 @@ namespace MonoDevelop.SourceEditor protected override void OnDestroyed () { + if (scrolledWindow == null) + return; if (scrolledWindow.Child != null) RemoveEvents (); SetSuppressScrollbar (false); QuickTaskStrip.EnableFancyFeatures.Changed -= FancyFeaturesChanged; scrolledWindow.ButtonPressEvent -= PrepareEvent; - + scrolledWindow.Vadjustment.Destroy (); + scrolledWindow.Hadjustment.Destroy (); + scrolledWindow.Destroy (); + scrolledWindow = null; + strip.Destroy (); + strip = null; base.OnDestroyed (); } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs index 8cdd4bdf2e..a4a333c89f 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs @@ -316,6 +316,15 @@ namespace MonoDevelop.SourceEditor } } + public override bool EnableSelectionWrappingKeys { + get { + return optionsCore.EnableSelectionWrappingKeys; + } + set { + throw new NotSupportedException (); + } + } + #endregion diff --git a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.BehaviorPanel.cs b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.BehaviorPanel.cs index b11d711164..58b57721bb 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.BehaviorPanel.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.BehaviorPanel.cs @@ -28,6 +28,8 @@ namespace MonoDevelop.SourceEditor.OptionPanels private global::Gtk.CheckButton checkbuttonGenerateFormattingUndoStep; + private global::Gtk.CheckButton checkbuttonEnableSelectionSurrounding; + private global::Gtk.Label GtkLabel7; private global::Gtk.Alignment GtkAlignment; @@ -172,12 +174,24 @@ namespace MonoDevelop.SourceEditor.OptionPanels w9.Position = 5; w9.Expand = false; w9.Fill = false; + // Container child vbox4.Gtk.Box+BoxChild + this.checkbuttonEnableSelectionSurrounding = new global::Gtk.CheckButton(); + this.checkbuttonEnableSelectionSurrounding.CanFocus = true; + this.checkbuttonEnableSelectionSurrounding.Name = "checkbuttonEnableSelectionSurrounding"; + this.checkbuttonEnableSelectionSurrounding.Label = global::Mono.Unix.Catalog.GetString("Enable _selection surrounding keys"); + this.checkbuttonEnableSelectionSurrounding.DrawIndicator = true; + this.checkbuttonEnableSelectionSurrounding.UseUnderline = true; + this.vbox4.Add(this.checkbuttonEnableSelectionSurrounding); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox4[this.checkbuttonEnableSelectionSurrounding])); + w10.Position = 6; + w10.Expand = false; + w10.Fill = false; this.alignment3.Add(this.vbox4); this.vbox1.Add(this.alignment3); - global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.alignment3])); - w11.Position = 1; - w11.Expand = false; - w11.Fill = false; + global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.alignment3])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.GtkLabel7 = new global::Gtk.Label(); this.GtkLabel7.Name = "GtkLabel7"; @@ -185,10 +199,10 @@ namespace MonoDevelop.SourceEditor.OptionPanels this.GtkLabel7.LabelProp = global::Mono.Unix.Catalog.GetString("<b>Indentation</b>"); this.GtkLabel7.UseMarkup = true; this.vbox1.Add(this.GtkLabel7); - global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkLabel7])); - w12.Position = 2; - w12.Expand = false; - w12.Fill = false; + global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkLabel7])); + w13.Position = 2; + w13.Expand = false; + w13.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.GtkAlignment = new global::Gtk.Alignment(0F, 0F, 1F, 1F); this.GtkAlignment.Name = "GtkAlignment"; @@ -207,23 +221,23 @@ namespace MonoDevelop.SourceEditor.OptionPanels this.label1.LabelProp = global::Mono.Unix.Catalog.GetString("_Indentation mode:"); this.label1.UseUnderline = true; this.hbox1.Add(this.label1); - global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label1])); - w13.Position = 0; - w13.Expand = false; - w13.Fill = false; + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label1])); + w14.Position = 0; + w14.Expand = false; + w14.Fill = false; // Container child hbox1.Gtk.Box+BoxChild this.indentationCombobox = global::Gtk.ComboBox.NewText(); this.indentationCombobox.Name = "indentationCombobox"; this.hbox1.Add(this.indentationCombobox); - global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.indentationCombobox])); - w14.Position = 1; - w14.Expand = false; - w14.Fill = false; - this.vbox2.Add(this.hbox1); - global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox1])); - w15.Position = 0; + global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.indentationCombobox])); + w15.Position = 1; w15.Expand = false; w15.Fill = false; + this.vbox2.Add(this.hbox1); + global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox1])); + w16.Position = 0; + w16.Expand = false; + w16.Fill = false; // Container child vbox2.Gtk.Box+BoxChild this.tabAsReindentCheckbutton = new global::Gtk.CheckButton(); this.tabAsReindentCheckbutton.CanFocus = true; @@ -232,16 +246,16 @@ namespace MonoDevelop.SourceEditor.OptionPanels this.tabAsReindentCheckbutton.DrawIndicator = true; this.tabAsReindentCheckbutton.UseUnderline = true; this.vbox2.Add(this.tabAsReindentCheckbutton); - global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.tabAsReindentCheckbutton])); - w16.Position = 1; - w16.Expand = false; - w16.Fill = false; + global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.tabAsReindentCheckbutton])); + w17.Position = 1; + w17.Expand = false; + w17.Fill = false; this.GtkAlignment.Add(this.vbox2); this.vbox1.Add(this.GtkAlignment); - global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkAlignment])); - w18.Position = 3; - w18.Expand = false; - w18.Fill = false; + global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkAlignment])); + w19.Position = 3; + w19.Expand = false; + w19.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.GtkLabel9 = new global::Gtk.Label(); this.GtkLabel9.Name = "GtkLabel9"; @@ -249,10 +263,10 @@ namespace MonoDevelop.SourceEditor.OptionPanels this.GtkLabel9.LabelProp = global::Mono.Unix.Catalog.GetString("<b>Navigation</b>"); this.GtkLabel9.UseMarkup = true; this.vbox1.Add(this.GtkLabel9); - global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkLabel9])); - w19.Position = 4; - w19.Expand = false; - w19.Fill = false; + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkLabel9])); + w20.Position = 4; + w20.Expand = false; + w20.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.alignment4 = new global::Gtk.Alignment(0.5F, 0.5F, 1F, 1F); this.alignment4.Name = "alignment4"; @@ -271,29 +285,29 @@ namespace MonoDevelop.SourceEditor.OptionPanels this.label2.LabelProp = global::Mono.Unix.Catalog.GetString("Word _break mode:"); this.label2.UseUnderline = true; this.hbox3.Add(this.label2); - global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.label2])); - w20.Position = 0; - w20.Expand = false; - w20.Fill = false; + global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.label2])); + w21.Position = 0; + w21.Expand = false; + w21.Fill = false; // Container child hbox3.Gtk.Box+BoxChild this.controlLeftRightCombobox = global::Gtk.ComboBox.NewText(); this.controlLeftRightCombobox.Name = "controlLeftRightCombobox"; this.hbox3.Add(this.controlLeftRightCombobox); - global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.controlLeftRightCombobox])); - w21.Position = 1; - w21.Expand = false; - w21.Fill = false; - this.vbox5.Add(this.hbox3); - global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox3])); - w22.Position = 0; + global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.controlLeftRightCombobox])); + w22.Position = 1; w22.Expand = false; w22.Fill = false; + this.vbox5.Add(this.hbox3); + global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox3])); + w23.Position = 0; + w23.Expand = false; + w23.Fill = false; this.alignment4.Add(this.vbox5); this.vbox1.Add(this.alignment4); - global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.alignment4])); - w24.Position = 5; - w24.Expand = false; - w24.Fill = false; + global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.alignment4])); + w25.Position = 5; + w25.Expand = false; + w25.Fill = false; this.Add(this.vbox1); if ((this.Child != null)) { diff --git a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic index 9e2236c02c..19f98120aa 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic +++ b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic @@ -8,6 +8,7 @@ <widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" /> <widget-library name="../../../../build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll" /> <widget-library name="../../../../build/bin/Mono.TextEditor.dll" /> + <widget-library name="../../../../external/xwt/Xwt.Gtk/bin/Debug/Xwt.Gtk.dll" /> <widget-library name="../../../../build/AddIns/DisplayBindings/SourceEditor/MonoDevelop.SourceEditor.dll" internal="true" /> </import> <widget class="Gtk.Bin" id="MonoDevelop.SourceEditor.OptionPanels.GeneralOptionsPanel" design-size="454 364"> @@ -733,6 +734,22 @@ <property name="Fill">False</property> </packing> </child> + <child> + <widget class="Gtk.CheckButton" id="checkbuttonEnableSelectionSurrounding"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Label" translatable="yes">Enable _selection surrounding keys</property> + <property name="DrawIndicator">True</property> + <property name="HasLabel">True</property> + <property name="UseUnderline">True</property> + </widget> + <packing> + <property name="Position">6</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> </widget> </child> </widget> diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Dialogs/WebReferenceDialog.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Dialogs/WebReferenceDialog.cs index e3c4f90232..e8d02975b7 100644 --- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Dialogs/WebReferenceDialog.cs +++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Dialogs/WebReferenceDialog.cs @@ -609,6 +609,17 @@ namespace MonoDevelop.WebReferences.Dialogs } } + + protected override void OnDestroyed ()
+ { + btnNavBack.Activated -= Browser_BackButtonClicked; + btnNavNext.Activated -= Browser_NextButtonClicked; + btnRefresh.Activated -= Browser_RefreshButtonClicked; + btnStop.Activated -= Browser_StopButtonClicked; + btnHome.Activated -= Browser_HomeButtonClicked; +
+ base.OnDestroyed ();
+ } } class AskCredentials: GuiSyncObject, ICredentials diff --git a/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs b/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs index 5768b7d358..3bbfc1f11f 100644 --- a/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs +++ b/main/src/addins/NUnit/Services/NUnitProjectTestSuite.cs @@ -91,7 +91,7 @@ namespace MonoDevelop.NUnit return null; } var ctx = task.Result; - var cls = ctx.Assembly.GetTypeByMetadataName (string.IsNullOrEmpty (fixtureTypeNamespace) ? fixtureTypeName : fixtureTypeNamespace + "." + fixtureTypeName); + var cls = ctx?.Assembly?.GetTypeByMetadataName (string.IsNullOrEmpty (fixtureTypeNamespace) ? fixtureTypeName : fixtureTypeNamespace + "." + fixtureTypeName); if (cls == null) return null; diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj index fec16c1aac..2358b38595 100644 --- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj +++ b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj @@ -42,6 +42,7 @@ <Compile Include="TemplatingEngineHelper.cs" /> <Compile Include="TemplateEnginePreprocessTemplateTests.cs" /> <Compile Include="GenerateIndentedClassCodeTests.cs" /> + <Compile Include="TextTemplatingSessionTests.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj"> diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs new file mode 100644 index 0000000000..c5b0606394 --- /dev/null +++ b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TextTemplatingSessionTests.cs @@ -0,0 +1,57 @@ +//
+// TextTemplatingSessionTests.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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;
+using System.Reflection;
+using Microsoft.VisualStudio.TextTemplating;
+using NUnit.Framework;
+
+namespace Mono.TextTemplating.Tests
+{
+ [TestFixture]
+ public class TextTemplatingSessionTests
+ {
+ [Test]
+ public void AppDomainSerializationTest ()
+ {
+ var guid = Guid.NewGuid ();
+ var appDomain = AppDomain.CreateDomain ("TextTemplatingSessionSerializationTestAppDomain");
+
+ var session = (TextTemplatingSession)appDomain.CreateInstanceFromAndUnwrap (
+ typeof(TextTemplatingSession).Assembly.Location,
+ typeof(TextTemplatingSession).FullName,
+ false,
+ BindingFlags.Public | BindingFlags.Instance,
+ null,
+ new object[] { guid },
+ null,
+ null);
+
+ Assert.AreEqual (guid, session.Id);
+ }
+ }
+}
+
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs index ce362d10c6..cf1fc83b20 100644 --- a/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs +++ b/main/src/addins/TextTemplating/Mono.TextTemplating/Microsoft.VisualStudio.TextTemplating/TextTemplatingSession.cs @@ -31,12 +31,18 @@ using System.Runtime.Serialization; namespace Microsoft.VisualStudio.TextTemplating
{
[Serializable]
- public sealed class TextTemplatingSession : Dictionary<string, Object>, ITextTemplatingSession
+ public sealed class TextTemplatingSession : Dictionary<string, Object>, ITextTemplatingSession, ISerializable
{
public TextTemplatingSession () : this (Guid.NewGuid ())
{
}
-
+
+ TextTemplatingSession (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ Id = (Guid)info.GetValue ("Id", typeof (Guid));
+ }
+
public TextTemplatingSession (Guid id)
{
this.Id = id;
@@ -66,6 +72,12 @@ namespace Microsoft.VisualStudio.TextTemplating {
return other != null && other.Id == this.Id;
}
+
+ void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ info.AddValue ("Id", Id);
+ }
}
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index 7eb72c5417..a33b65d06f 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -713,6 +713,9 @@ namespace MonoDevelop.VersionControl.Git Revert (RootRepository.FromGitPath (conflictFile.Ancestor.Path), false, monitor); break; } + if (res == Git.ConflictResult.Continue) { + Add (RootRepository.FromGitPath (conflictFile.Ancestor.Path), false, monitor); + } } if (!string.IsNullOrEmpty (message)) { var sig = GetSignature (); @@ -779,7 +782,7 @@ namespace MonoDevelop.VersionControl.Git } } - public void Merge (string branch, GitUpdateOptions options, ProgressMonitor monitor) + public void Merge (string branch, GitUpdateOptions options, ProgressMonitor monitor, FastForwardStrategy strategy = FastForwardStrategy.Default) { int stashIndex = -1; var oldHead = RootRepository.Head.Tip; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs index 74c3028d13..d5df4fa89d 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitService.cs @@ -88,7 +88,7 @@ namespace MonoDevelop.VersionControl.Git using (ProgressMonitor monitor = VersionControlService.GetProgressMonitor (GettextCatalog.GetString ("Merging branch '{0}'...", dlg.SelectedBranch))) { if (dlg.IsRemote) repo.Fetch (monitor, dlg.RemoteName); - repo.Merge (dlg.SelectedBranch, dlg.StageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor); + repo.Merge (dlg.SelectedBranch, dlg.StageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor, FastForwardStrategy.NoFastForward); } } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs index 7051c33650..1bc77b05ed 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs @@ -61,16 +61,19 @@ namespace MonoDevelop.VersionControl.Views info.Start (); BlameWidget widget = Control.GetNativeWidget<BlameWidget> (); widget.Reset (); - var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> (); - if (sourceEditor != null) { - widget.Editor.Caret.Location = sourceEditor.TextEditor.Caret.Location; - widget.Editor.VAdjustment.Value = sourceEditor.TextEditor.VAdjustment.Value; + + var buffer = info.Document.GetContent<MonoDevelop.Ide.Editor.TextEditor> (); + if (buffer != null) { + var loc = buffer.CaretLocation; + int line = loc.Line < 1 ? 1 : loc.Line; + int column = loc.Column < 1 ? 1 : loc.Column; + widget.Editor.SetCaretTo (line, column); } } protected override void OnDeselected () { - var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> (); + var sourceEditor = info.Document.ParentDocument.Editor.GetContent<MonoDevelop.SourceEditor.SourceEditorView> (); if (sourceEditor != null) { sourceEditor.TextEditor.Caret.Location = widget.Editor.Caret.Location; sourceEditor.TextEditor.VAdjustment.Value = widget.Editor.VAdjustment.Value; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs index 53d9421ca1..a34f3e7fd7 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs @@ -574,11 +574,16 @@ namespace MonoDevelop.VersionControl.Views } Runtime.RunInMainThread (delegate { + var location = widget.Editor.Caret.Location; + var adj = widget.editor.VAdjustment.Value; if (widget.revision != null) { document.Text = widget.VersionControlItem.Repository.GetTextAtRevision (widget.Document.FileName, widget.revision); } else { document.Text = widget.Document.Editor.Text; } + widget.editor.Caret.Location = location; + widget.editor.VAdjustment.Value = adj; + ctx.AutoPulse = false; ctx.Dispose (); UpdateWidth (); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs index a338eaf966..42ad1a28b3 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs @@ -55,7 +55,7 @@ namespace MonoDevelop.VersionControl.Views } } - protected override MonoTextEditor MainEditor { + protected internal override MonoTextEditor MainEditor { get { return editors[1]; } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs index ff20b25996..61de8f1d70 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs @@ -78,7 +78,7 @@ namespace MonoDevelop.VersionControl.Views } } - protected abstract MonoTextEditor MainEditor { + protected internal abstract MonoTextEditor MainEditor { get; } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs index 5408740683..013522ae03 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs @@ -59,6 +59,14 @@ namespace MonoDevelop.VersionControl.Views { widget.UpdateLocalText (); widget.info.Start (); + + var buffer = info.Document.GetContent<MonoDevelop.Ide.Editor.TextEditor> (); + if (buffer != null) { + var loc = buffer.CaretLocation; + int line = loc.Line < 1 ? 1 : loc.Line; + int column = loc.Column < 1 ? 1 : loc.Column; + widget.MainEditor.SetCaretTo (line, column); + } } } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs index 4998d00663..2c7e09f2e0 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.VersionControl.Views { public class MergeWidget : EditorCompareWidgetBase { - protected override MonoTextEditor MainEditor { + protected internal override MonoTextEditor MainEditor { get { return editors != null && editors.Length >= 2 ? editors[1] : null; } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Revision.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Revision.cs index f37d8297a4..ef32af62e3 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Revision.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Revision.cs @@ -97,6 +97,25 @@ namespace MonoDevelop.VersionControl } return msg.TrimStart (' ', '\t'); } + + public static bool operator ==(Revision a, Revision b) + { + if (System.Object.ReferenceEquals(a, b)) + { + return true; + } + + if (((object)a == null) || ((object)b == null)) + { + return false; + }
+
return a.ToString () == b.ToString (); + } + + public static bool operator !=(Revision a, Revision b) + { + return !(a == b); + } } public class RevisionPath diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml index bdabcfa114..f366187d73 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml @@ -150,7 +150,7 @@ defaultHandler="MonoDevelop.VersionControl.UpdateCommandHandler" description = "Updates the local copy with remote changes."/> <Command id = "MonoDevelop.VersionControl.Commands.Publish" - _label = "_Publish..." + _label = "_Publish in Version Control..." icon = "vc-push" description = "Publish actual project into repository."/> <Command id = "MonoDevelop.VersionControl.Commands.Checkout" diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/Dialogs/CommonFileDialogExtensions.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/Dialogs/CommonFileDialogExtensions.cs index 71cbbdc966..bbb3c798d4 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/Dialogs/CommonFileDialogExtensions.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/Dialogs/CommonFileDialogExtensions.cs @@ -55,7 +55,7 @@ namespace MonoDevelop.Platform var fileDialog = dialog as CommonOpenFileDialog;
if (fileDialog != null) {
fileDialog.Multiselect = data.SelectMultiple;
- if (data.Action == FileChooserAction.SelectFolder) {
+ if ((data.Action & FileChooserAction.SelectFolder) != 0) {
fileDialog.IsFolderPicker = true;
return;
}
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs index febaddd336..c579ab60f3 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs @@ -14,13 +14,14 @@ namespace WindowsPlatform.MainToolbar {
public class TitleMenuItem : MenuItem
{
- public TitleMenuItem (MonoDevelop.Components.Commands.CommandManager manager, CommandEntry entry, CommandInfo commandArrayInfo = null, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null)
+ public TitleMenuItem (MonoDevelop.Components.Commands.CommandManager manager, CommandEntry entry, CommandInfo commandArrayInfo = null, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null, Menu menu = null)
{
this.manager = manager;
this.initialCommandTarget = initialCommandTarget;
this.commandSource = commandSource;
this.commandArrayInfo = commandArrayInfo;
+ this.menu = menu;
menuEntry = entry;
menuEntrySet = entry as CommandEntrySet;
menuLinkEntry = entry as LinkCommandEntry;
@@ -34,7 +35,7 @@ namespace WindowsPlatform.MainToolbar if (item.IsArraySeparator)
Items.Add (new Separator { UseLayoutRounding = true, });
else
- Items.Add (new TitleMenuItem (manager, entry, item, commandSource, initialCommandTarget));
+ Items.Add (new TitleMenuItem (manager, entry, item, commandSource, initialCommandTarget, menu));
}
}
}
@@ -46,7 +47,7 @@ namespace WindowsPlatform.MainToolbar if (item.CommandId == MonoDevelop.Components.Commands.Command.Separator) {
Items.Add (new Separator { UseLayoutRounding = true, });
} else
- Items.Add (new TitleMenuItem (manager, item));
+ Items.Add (new TitleMenuItem (manager, item, menu: menu));
}
} else if (menuLinkEntry != null) {
Header = menuLinkEntry.Text;
@@ -75,6 +76,8 @@ namespace WindowsPlatform.MainToolbar UseLayoutRounding = true;
}
+ Menu menu;
+
/// <summary>
/// Updates a command entry. Should only be called from a toplevel node.
/// This will update all the menu's children.
@@ -132,7 +135,7 @@ namespace WindowsPlatform.MainToolbar if (child.IsArraySeparator) {
toAdd = new Separator ();
} else {
- toAdd = new TitleMenuItem (manager, menuEntry, child);
+ toAdd = new TitleMenuItem (manager, menuEntry, child, menu: menu);
}
toRemoveFromParent.Add (toAdd);
@@ -194,19 +197,28 @@ namespace WindowsPlatform.MainToolbar return ret;
}
+ static bool closingSent;
protected override void OnSubmenuOpened (RoutedEventArgs e)
{
- if (Parent is Menu)
+ if (Parent is Menu) {
Update ();
+ closingSent = false;
+ }
base.OnSubmenuOpened (e);
}
+
protected override void OnSubmenuClosed (RoutedEventArgs e)
{
if (Parent is Menu)
Clear ();
+ if (!closingSent) {
+ OnSubmenuClosing ();
+ closingSent = false;
+ }
+
base.OnSubmenuClosed (e);
}
@@ -215,7 +227,8 @@ namespace WindowsPlatform.MainToolbar if (!hasCommand)
return;
- SubmenuClosing?.Invoke (this, e);
+ closingSent = true;
+ OnSubmenuClosing ();
Xwt.Application.Invoke(() => {
if (commandArrayInfo != null) {
@@ -231,7 +244,13 @@ namespace WindowsPlatform.MainToolbar DesktopService.ShowUrl (menuLinkEntry.Url);
}
- internal event EventHandler SubmenuClosing;
+ void OnSubmenuClosing ()
+ {
+ bool shouldFocusIde = !menu.Items.OfType<MenuItem> ().Any (mi => mi.IsSubmenuOpen);
+ if (shouldFocusIde)
+ IdeApp.Workbench.RootWindow.Present ();
+ }
+
readonly MonoDevelop.Components.Commands.CommandManager manager;
readonly object initialCommandTarget;
readonly CommandSource commandSource;
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs index d245d97cc7..5182f66273 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/WPFToolbar.cs @@ -171,7 +171,7 @@ namespace WindowsPlatform.MainToolbar set {
toolbar.SearchBar.SearchText = value;
FocusSearchBar ();
- toolbar.SearchBar.SearchBar.SelectAll ();
+ toolbar.SearchBar.SearchBar.Select (value.Length, 0);
}
}
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs index 82c7eb6ac2..de3de3e03e 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs @@ -115,13 +115,7 @@ namespace MonoDevelop.Platform }; foreach (CommandEntrySet ce in ces)
{
- var item = new TitleMenuItem(commandManager, ce); - item.SubmenuClosing += (o, e) =>
- {
- bool shouldFocusIde = !mainMenu.Items.OfType<MenuItem>().Any(mi => mi.IsSubmenuOpen);
- if (shouldFocusIde)
- IdeApp.Workbench.RootWindow.Present();
- };
+ var item = new TitleMenuItem (commandManager, ce, menu: mainMenu);
mainMenu.Items.Add(item);
}
diff --git a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs index 70bd5e151f..1433928fae 100644 --- a/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs +++ b/main/src/addins/Xml/Editor/BaseXmlEditorExtension.cs @@ -602,13 +602,36 @@ namespace MonoDevelop.Xml.Editor elements.Add (el); } } - + + //Prevents code completion on -, so <!-- doesn't code complete too soon + class IgnoreDashKeyHandler : ICompletionKeyHandler + { + public bool PreProcessKey (CompletionListWindow listWindow, KeyDescriptor descriptor, out KeyActions keyAction) + { + keyAction = KeyActions.None; + if (descriptor.KeyChar == '-') { + return true; + } + return false; + } + + public bool PostProcessKey (CompletionListWindow listWindow, KeyDescriptor descriptor, out KeyActions keyAction) + { + keyAction = KeyActions.None; + if (descriptor.KeyChar == '-') { + return true; + } + return false; + } + } + /// <summary> /// Adds CDATA and comment begin tags. /// </summary> protected static void AddMiscBeginTags (CompletionDataList list) { list.Add ("!--", "md-literal", GettextCatalog.GetString ("Comment")); + list.AddKeyHandler (new IgnoreDashKeyHandler ()); list.Add ("![CDATA[", "md-literal", GettextCatalog.GetString ("Character data")); } 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 9e49c331ea..9b702806ac 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs @@ -33,6 +33,7 @@ using System.Reflection; using System.Text; using System.Xml; using Xwt.Drawing; +using Mono.TextEditor.Utils; namespace Mono.TextEditor.Highlighting { @@ -756,7 +757,12 @@ namespace Mono.TextEditor.Highlighting public static ColorScheme LoadFrom (Stream stream) { var result = new ColorScheme (); - var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (stream, new System.Xml.XmlDictionaryReaderQuotas ()); + byte [] bytes; + using (var sr = TextFileUtility.OpenStream (stream)) { + bytes = System.Text.Encoding.UTF8.GetBytes (sr.ReadToEnd ()); + } + + var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (bytes, new System.Xml.XmlDictionaryReaderQuotas ()); var root = XElement.Load(reader); diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs index 0b74632ea2..87d55740a9 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/SyntaxModeService.cs @@ -487,9 +487,10 @@ namespace Mono.TextEditor.Highlighting static string ScanStyle (Stream stream) { try { - var file = new StreamReader (stream); + var file = Utils.TextFileUtility.OpenStream (stream); file.ReadLine (); var nameLine = file.ReadLine (); + file.Close (); var match = nameRegex.Match (nameLine); if (!match.Success) return null; diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs index d55779e20f..0f1c623191 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs @@ -272,13 +272,12 @@ namespace Mono.TextEditor throw new ArgumentOutOfRangeException (nameof (count), "must be > 0, was: " + count); InterruptFoldWorker (); + //int oldLineCount = LineCount; var args = new DocumentChangeEventArgs (offset, count > 0 ? GetTextAt (offset, count) : "", value, anchorMovementType); - if (value != null) - EnsureSegmentIsUnfolded (offset, value.Length); - OnTextReplacing (args); - value = args.InsertedText.Text; + UndoOperation operation = null; + bool endUndo = false; if (!isInUndo) { operation = new UndoOperation (args); if (currentAtomicOperation != null) { @@ -286,10 +285,17 @@ namespace Mono.TextEditor } else { OnBeginUndo (); undoStack.Push (operation); - OnEndUndo (new UndoOperationEventArgs (operation)); + endUndo = true; } redoStack.Clear (); } + + if (value != null) + EnsureSegmentIsUnfolded (offset, value.Length); + + OnTextReplacing (args); + value = args.InsertedText.Text; + cachedText = null; buffer = buffer.RemoveText(offset, count); if (!string.IsNullOrEmpty (value)) @@ -298,6 +304,8 @@ namespace Mono.TextEditor splitter.TextReplaced (this, args); versionProvider.AppendChange (args); OnTextReplaced (args); + if (endUndo) + OnEndUndo (new UndoOperationEventArgs (operation)); } public string GetTextBetween (int startOffset, int endOffset) @@ -652,16 +660,14 @@ namespace Mono.TextEditor public override void Undo (TextDocument doc, bool fireEvent = true) { - doc.currentAtomicUndoOperationType.Push (operationType); - doc.atomicUndoLevel++; + doc.BeginAtomicUndo (operationType); try { for (int i = operations.Count - 1; i >= 0; i--) { operations [i].Undo (doc, false); doc.OnUndone (new UndoOperationEventArgs (operations [i])); } } finally { - doc.atomicUndoLevel--; - doc.currentAtomicUndoOperationType.Pop (); + doc.EndAtomicUndo (); } if (fireEvent) OnUndoDone (); @@ -669,12 +675,15 @@ namespace Mono.TextEditor public override void Redo (TextDocument doc, bool fireEvent = true) { - doc.currentAtomicUndoOperationType.Push (operationType); - foreach (UndoOperation operation in this.operations) { - operation.Redo (doc, false); - doc.OnRedone (new UndoOperationEventArgs (operation)); + doc.BeginAtomicUndo (operationType); + try { + foreach (UndoOperation operation in this.operations) { + operation.Redo (doc, false); + doc.OnRedone (new UndoOperationEventArgs (operation)); + } + } finally { + doc.EndAtomicUndo (); } - doc.currentAtomicUndoOperationType.Pop (); if (fireEvent) OnRedoDone (); } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs index 90fcd4a2e8..3385275a32 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs @@ -117,11 +117,11 @@ namespace Mono.TextEditor HideMouseCursor (); + if (textEditorData.IsSomethingSelected && textEditorData.Options.EnableSelectionWrappingKeys && IsSpecialKeyForSelection (unicodeKey)) { + textEditorData.SelectionSurroundingProvider.HandleSpecialSelectionKey (textEditorData, unicodeKey); + return; + } using (var undo = Document.OpenUndoGroup ()) { - if (textEditorData.IsSomethingSelected && textEditorData.Options.EnableSelectionWrappingKeys && IsSpecialKeyForSelection (unicodeKey)) { - textEditorData.SelectionSurroundingProvider.HandleSpecialSelectionKey (textEditorData, unicodeKey); - return; - } textEditorData.DeleteSelectedText ( textEditorData.IsSomethingSelected ? textEditorData.MainSelection.SelectionMode != SelectionMode.Block : true); diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs index 7bfa843b97..651072e227 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/MonoTextEditor.cs @@ -1269,7 +1269,7 @@ namespace Mono.TextEditor { textArea.SetCaretTo (line, column, highlight, centerCaret); } - public event EventHandler BeginHover { + public event EventHandler<Xwt.MouseMovedEventArgs> BeginHover { add { textArea.BeginHover += value; } remove { textArea.BeginHover -= value; } } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs index fd5a6b01d4..c17308e1bf 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs @@ -1292,9 +1292,9 @@ namespace Mono.TextEditor Margin oldMargin = null; bool overChildWidget; - public event EventHandler BeginHover; + public event EventHandler<Xwt.MouseMovedEventArgs> BeginHover; - protected virtual void OnBeginHover (EventArgs e) + protected virtual void OnBeginHover (Xwt.MouseMovedEventArgs e) { var handler = BeginHover; if (handler != null) @@ -1303,7 +1303,7 @@ namespace Mono.TextEditor protected override bool OnMotionNotifyEvent (Gdk.EventMotion e) { - OnBeginHover (EventArgs.Empty); + OnBeginHover (new Xwt.MouseMovedEventArgs (e.Time, e.X, e.Y)); try { // The coordinates have to be properly adjusted to the origin since // the event may come from a child widget @@ -1311,6 +1311,7 @@ namespace Mono.TextEditor GdkWindow.GetOrigin (out rx, out ry); double x = (int) e.XRoot - rx; double y = (int) e.YRoot - ry; + overChildWidget = containerChildren.Any (w => w.Child.Allocation.Contains ((int)x, (int)y)); RemoveScrollWindowTimer (); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs index 2be51b1f9e..adec8d3baf 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs @@ -41,6 +41,7 @@ using MonoDevelop.Core.Serialization; using Mono.Addins; using Mono.PkgConfig; using MonoDevelop.Core.Instrumentation; +using System.Linq; namespace MonoDevelop.Core.Assemblies { @@ -292,6 +293,16 @@ namespace MonoDevelop.Core.Assemblies return Directory.GetFiles (facades, "*.dll"); } + //MonoDroid is special case because it's keeping Fascades in v1.0 folder + if (tx.Id.Identifier == TargetFrameworkMoniker.ID_MONODROID) { + var frameworkFolder = GetFrameworkFolders (tx).FirstOrDefault (); + if (frameworkFolder != null) { + var facades = Path.Combine (Path.Combine (Path.GetDirectoryName (frameworkFolder), "v1.0"), "Facades"); + if (Directory.Exists (facades)) + return Directory.GetFiles (facades, "*.dll"); + } + } + return new string[0]; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs index 73068cd5c3..3563c445d4 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/DefaultMSBuildEngine.cs @@ -218,7 +218,7 @@ namespace MonoDevelop.Projects.MSBuild var include = context.EvaluateString (item.Include); var exclude = context.EvaluateString (item.Exclude); - var it = CreateEvaluatedItem (context, project.Project, item, include); + var it = CreateEvaluatedItem (context, project, project.Project, item, include); var trueCond = conditionIsTrue && (string.IsNullOrEmpty (it.Condition) || SafeParseAndEvaluate (project, context, it.Condition)); @@ -240,7 +240,7 @@ namespace MonoDevelop.Projects.MSBuild if (path == "**" || path.EndsWith ("\\**")) path = path + "/*"; var subpath = path.Split ('\\'); - foreach (var eit in ExpandWildcardFilePath (project.Project, context, item, project.Project.BaseDirectory, FilePath.Null, false, subpath, 0)) { + foreach (var eit in ExpandWildcardFilePath (project, project.Project, context, item, project.Project.BaseDirectory, FilePath.Null, false, subpath, 0)) { if (excludeRegex != null && excludeRegex.IsMatch (eit.Include)) continue; project.EvaluatedItemsIgnoringCondition.Add (eit); @@ -251,7 +251,7 @@ namespace MonoDevelop.Projects.MSBuild else if (include != it.Include) { if (excludeRegex != null && excludeRegex.IsMatch (include)) return; - it = CreateEvaluatedItem (context, project.Project, item, include); + it = CreateEvaluatedItem (context, project, project.Project, item, include); project.EvaluatedItemsIgnoringCondition.Add (it); if (trueCond) project.EvaluatedItems.Add (it); @@ -274,7 +274,7 @@ namespace MonoDevelop.Projects.MSBuild Evaluate (project, context, item, evalItems); } - static IEnumerable<MSBuildItemEvaluated> ExpandWildcardFilePath (MSBuildProject project, MSBuildEvaluationContext context, MSBuildItem sourceItem, FilePath basePath, FilePath baseRecursiveDir, bool recursive, string[] filePath, int index) + static IEnumerable<MSBuildItemEvaluated> ExpandWildcardFilePath (ProjectInfo pinfo, MSBuildProject project, MSBuildEvaluationContext context, MSBuildItem sourceItem, FilePath basePath, FilePath baseRecursiveDir, bool recursive, string[] filePath, int index) { var res = Enumerable.Empty<MSBuildItemEvaluated> (); @@ -284,10 +284,10 @@ namespace MonoDevelop.Projects.MSBuild var path = filePath [index]; if (path == "..") - return ExpandWildcardFilePath (project, context, sourceItem, basePath.ParentDirectory, baseRecursiveDir, recursive, filePath, index + 1); + return ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath.ParentDirectory, baseRecursiveDir, recursive, filePath, index + 1); if (path == ".") - return ExpandWildcardFilePath (project, context, sourceItem, basePath, baseRecursiveDir, recursive, filePath, index + 1); + return ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath, baseRecursiveDir, recursive, filePath, index + 1); if (!Directory.Exists (basePath)) return res; @@ -301,13 +301,13 @@ namespace MonoDevelop.Projects.MSBuild if (baseRecursiveDir.IsNullOrEmpty) baseRecursiveDir = basePath; - return ExpandWildcardFilePath (project, context, sourceItem, basePath, baseRecursiveDir, true, filePath, index + 1); + return ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath, baseRecursiveDir, true, filePath, index + 1); } if (recursive) { // Recursive search. Try to match the remaining subpath in all subdirectories. foreach (var dir in Directory.GetDirectories (basePath)) - res = res.Concat (ExpandWildcardFilePath (project, context, sourceItem, dir, baseRecursiveDir, true, filePath, index)); + res = res.Concat (ExpandWildcardFilePath (pinfo, project, context, sourceItem, dir, baseRecursiveDir, true, filePath, index)); } if (index == filePath.Length - 1) { @@ -321,7 +321,7 @@ namespace MonoDevelop.Projects.MSBuild res = res.Concat (Directory.GetFiles (basePath, path).Select (f => { context.SetItemContext (f, recursiveDir); var ev = baseDir + Path.GetFileName (f); - return CreateEvaluatedItem (context, project, sourceItem, ev); + return CreateEvaluatedItem (context, pinfo, project, sourceItem, ev); })); } else { @@ -332,9 +332,9 @@ namespace MonoDevelop.Projects.MSBuild if (path.IndexOfAny (wildcards) != -1) { foreach (var dir in Directory.GetDirectories (basePath, path)) - res = res.Concat (ExpandWildcardFilePath (project, context, sourceItem, dir, baseRecursiveDir, false, filePath, index + 1)); + res = res.Concat (ExpandWildcardFilePath (pinfo, project, context, sourceItem, dir, baseRecursiveDir, false, filePath, index + 1)); } else - res = res.Concat (ExpandWildcardFilePath (project, context, sourceItem, basePath.Combine (path), baseRecursiveDir, false, filePath, index + 1)); + res = res.Concat (ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath.Combine (path), baseRecursiveDir, false, filePath, index + 1)); } return res; @@ -375,12 +375,13 @@ namespace MonoDevelop.Projects.MSBuild static char [] regexEscapeChars = { '\\', '^', '$', '{', '}', '[', ']', '(', ')', '.', '*', '+', '?', '|', '<', '>', '-', '&' }; - static MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, MSBuildProject project, MSBuildItem sourceItem, string include) + static MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, ProjectInfo pinfo, MSBuildProject project, MSBuildItem sourceItem, string include) { var it = new MSBuildItemEvaluated (project, sourceItem.Name, sourceItem.Include, include); var md = new Dictionary<string,IMSBuildPropertyEvaluated> (); foreach (var c in sourceItem.Metadata.GetProperties ()) { - md [c.Name] = new MSBuildPropertyEvaluated (project, c.Name, c.Value, context.EvaluateString (c.Value)); + if (string.IsNullOrEmpty (c.Condition) || SafeParseAndEvaluate (pinfo, context, c.Condition, true)) + md [c.Name] = new MSBuildPropertyEvaluated (project, c.Name, c.Value, context.EvaluateString (c.Value)); } ((MSBuildPropertyGroupEvaluated)it.Metadata).SetProperties (md); it.SourceItem = sourceItem; @@ -401,7 +402,7 @@ namespace MonoDevelop.Projects.MSBuild MSBuildItemEvaluated Evaluate (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item) { - return CreateEvaluatedItem (context, project.Project, item, context.EvaluateString (item.Include)); + return CreateEvaluatedItem (context, project, project.Project, item, context.EvaluateString (item.Include)); } IEnumerable<ProjectInfo> GetImportedProjects (ProjectInfo project, MSBuildImport import) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs index e3604edc2d..ea5dfd7104 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs @@ -1192,7 +1192,7 @@ namespace MonoDevelop.Projects.Policies static string GetPolicyFile (PolicySet set) { - return PoliciesFolder.Combine ((set.Name ?? set.Id) + ".mdpolicy.xml"); + return PoliciesFolder.Combine ((set.Id ?? set.Name) + ".mdpolicy.xml"); } static void LoadPolicies () diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs index bb7f931af2..90e985ef4c 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs @@ -878,7 +878,7 @@ namespace MonoDevelop.Projects RemoteProjectBuilder builder = await GetProjectBuilder (); var configs = GetConfigurations (configuration, false); - string[] refs; + string [] refs; using (Counters.ResolveMSBuildReferencesTimer.BeginTiming (GetProjectEventMetadata (configuration))) refs = await builder.ResolveAssemblyReferences (configs, CancellationToken.None); foreach (var r in refs) @@ -914,6 +914,37 @@ namespace MonoDevelop.Projects if (sa != null) result.Add (sa.Location); } + var addFacadeAssemblies = false; + foreach (var r in GetReferencedAssemblyProjects (configuration)) { + if (r.IsPortableLibrary) { + addFacadeAssemblies = true; + break; + } + } + if (!addFacadeAssemblies) { + foreach (var refFilename in result) { + string fullPath = null; + if (!Path.IsPathRooted (refFilename)) { + fullPath = Path.Combine (Path.GetDirectoryName (FileName), refFilename); + } else { + fullPath = Path.GetFullPath (refFilename); + } + if (SystemAssemblyService.ContainsReferenceToSystemRuntime (fullPath)) { + addFacadeAssemblies = true; + break; + } + } + } + + if (addFacadeAssemblies) { + var runtime = TargetRuntime ?? MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime; + var facades = runtime.FindFacadeAssembliesForPCL (TargetFramework); + foreach (var facade in facades) { + if (!File.Exists (facade)) + continue; + result.Add (facade); + } + } return result; } @@ -1080,7 +1111,6 @@ namespace MonoDevelop.Projects cmd.WorkingDirectory = Path.GetDirectoryName (configuration.CompiledOutputName); cmd.EnvironmentVariables = configuration.GetParsedEnvironmentVariables (); cmd.TargetRuntime = TargetRuntime; - cmd.UserAssemblyPaths = GetUserAssemblyPaths (configSel); return cmd; } @@ -1493,6 +1523,11 @@ namespace MonoDevelop.Projects protected virtual async Task OnExecuteCommand (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, ExecutionCommand executionCommand) { + var dotNetExecutionCommand = executionCommand as DotNetExecutionCommand; + if (dotNetExecutionCommand != null) {
+ dotNetExecutionCommand.UserAssemblyPaths = GetUserAssemblyPaths (configuration); + } + var dotNetProjectConfig = GetConfiguration (configuration) as DotNetProjectConfiguration; var console = dotNetProjectConfig.ExternalConsole ? context.ExternalConsoleFactory.CreateConsole (!dotNetProjectConfig.PauseConsoleOutput, monitor.CancellationToken) diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml index b72d86a5da..7ad178a66f 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml @@ -341,7 +341,7 @@ <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.ExportSolution" defaultHandler = "MonoDevelop.Ide.Commands.ExportSolutionHandler" _description = "Convert selected solution to another format" - _label = "_Export..." /> + _label = "Convert solution format..." /> <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.SelectActiveConfiguration" type = "radio|array" defaultHandler = "MonoDevelop.Ide.Commands.SelectActiveConfigurationHandler" diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml index 16a8ba2aaf..e35c0feea3 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/StockIcons.addin.xml @@ -342,6 +342,8 @@ <StockIcon stockid="md-internal-static-method" icon="res:element-method-16.png|res:element-visibility-internal-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-internal-static-property" icon="res:element-property-16.png|res:element-visibility-internal-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-internal-struct" icon="res:element-struct-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> + <!-- TODO: VV md-internal-literal --> + <StockIcon stockid="md-internal-literal" icon="res:element-constant-16.png|res:element-visibility-internal-overlay-16.png" size="Menu" /> <StockIcon stockid="md-InternalAndProtected-class" icon="res:element-class-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> <StockIcon stockid="md-InternalAndProtected-delegate" icon="res:element-delegate-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> <StockIcon stockid="md-InternalAndProtected-enum" icon="res:element-enum-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> @@ -356,6 +358,8 @@ <StockIcon stockid="md-InternalAndProtected-static-method" icon="res:element-method-16.png|res:element-visibility-internal-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-InternalAndProtected-static-property" icon="res:element-property-16.png|res:element-visibility-internal-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-InternalAndProtected-struct" icon="res:element-struct-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> + <!-- TODO: VV md-InternalAndProtected-literal --> + <StockIcon stockid="md-InternalAndProtected-literal" icon="res:element-constant-16.png|res:element-visibility-internal-an-protected-overlay-16.png" size="Menu" /> <StockIcon stockid="md-private-class" icon="res:element-class-16.png|res:element-visibility-private-diamond-overlay-16.png" size="Menu" /> <StockIcon stockid="md-private-delegate" icon="res:element-delegate-16.png|res:element-visibility-private-diamond-overlay-16.png" size="Menu" /> <StockIcon stockid="md-private-enum" icon="res:element-enum-16.png|res:element-visibility-private-diamond-overlay-16.png" size="Menu" /> @@ -370,6 +374,8 @@ <StockIcon stockid="md-private-static-method" icon="res:element-method-16.png|res:element-visibility-private-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-private-static-property" icon="res:element-property-16.png|res:element-visibility-private-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-private-struct" icon="res:element-struct-16.png|res:element-visibility-private-diamond-overlay-16.png" size="Menu" /> + <!-- TODO: VV md-private-literal --> + <StockIcon stockid="md-private-literal" icon="res:element-constant-16.png|res:element-visibility-private-overlay-16.png" size="Menu" /> <StockIcon stockid="md-project-console" icon="md-project|res:project-console-overlay-32.png" size="Dnd" /> <StockIcon stockid="md-project-gui" icon="md-project|res:project-gui-overlay-32.png" size="Dnd" /> <StockIcon stockid="md-project-library" icon="md-project|md-library-overlay" size="Dnd" /> @@ -389,6 +395,8 @@ <StockIcon stockid="md-protected-static-method" icon="res:element-method-16.png|res:element-visibility-protected-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-protected-static-property" icon="res:element-property-16.png|res:element-visibility-protected-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-protected-struct" icon="res:element-struct-16.png|res:element-visibility-protected-diamond-overlay-16.png" size="Menu" /> + <!-- TODO: VV md-protected-literal --> + <StockIcon stockid="md-protected-literal" icon="res:element-constant-16.png|res:element-visibility-protected-overlay-16.png" size="Menu" /> <StockIcon stockid="md-ProtectedOrInternal-class" icon="res:element-class-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> <StockIcon stockid="md-ProtectedOrInternal-delegate" icon="res:element-delegate-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> <StockIcon stockid="md-ProtectedOrInternal-enum" icon="res:element-enum-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> @@ -403,6 +411,8 @@ <StockIcon stockid="md-ProtectedOrInternal-static-method" icon="res:element-method-16.png|res:element-visibility-internal-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-ProtectedOrInternal-static-property" icon="res:element-property-16.png|res:element-visibility-internal-square-overlay-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-ProtectedOrInternal-struct" icon="res:element-struct-16.png|res:element-visibility-internal-diamond-overlay-16.png" size="Menu" /> + <!-- TODO: VV md-ProtectedOrInternal-literal --> + <StockIcon stockid="md-ProtectedOrInternal-literal" icon="res:element-constant-16.png|res:element-visibility-internal-or-protected-overlay-16.png" size="Menu" /> <StockIcon stockid="md-static-event" icon="res:element-event-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-static-field" icon="res:element-field-16.png|res:element-static-overlay-16.png" size="Menu" /> <StockIcon stockid="md-static-method" icon="res:element-method-16.png|res:element-static-overlay-16.png" size="Menu" /> diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml index 959aeb83da..fa6c2893f8 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/Templates.addin.xml @@ -99,7 +99,7 @@ </Extension> <Extension path="/MonoDevelop/Ide/ProjectTemplateCategories"> - <Category id="multiplat" name="Multi-platform" icon="md-platform-crossplatform"> + <Category id="multiplat" name="Multiplatform" icon="md-platform-crossplatform"> <Category id="library" name="Library"> <Category id="general" name="General" mappedCategories="crossplat/library/general" /> </Category> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs index 81878d1ab2..e3251563aa 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestClientSession.cs @@ -213,6 +213,11 @@ namespace MonoDevelop.Components.AutoTest return session.ErrorCount (severity); } + public List<TaskListEntryDTO> GetErrors (TaskSeverity severity) + { + return session.GetErrors (severity); + } + public void WaitForEvent (string name) { WaitForEvent (name, defaultEventWaitTimeout); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs index 805b29718d..66072db1b4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AutoTestSession.cs @@ -242,6 +242,17 @@ namespace MonoDevelop.Components.AutoTest return TaskService.Errors.Count (x => x.Severity == severity); } + public List<TaskListEntryDTO> GetErrors (TaskSeverity severity) + { + return TaskService.Errors.Where (x => x.Severity == severity).Select (x => new TaskListEntryDTO () { + Line = x.Line, + Description = x.Description, + File = x.FileName.FileName, + Path = x.FileName.FullPath, + Project = x.WorkspaceObject.Name + }).ToList (); + } + object SafeObject (object ob) { if (ob == null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/DataTransferObjects.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/DataTransferObjects.cs new file mode 100644 index 0000000000..acd6e94e2e --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/DataTransferObjects.cs @@ -0,0 +1,60 @@ +// +// DataTransferObjects.cs +// +// Author: +// kylewhite <kyle.white@xamarin.com> +// +// Copyright (c) 2016 kylewhite +// +// 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; +using MonoDevelop.Core; + +namespace MonoDevelop.Components.AutoTest +{ + [Serializable] + public class TaskListEntryDTO + { + public string Description { + get; + set; + } + + public string File { + get; + set; + } + + public string Path { + get; + set; + } + + public int Line { + get; + set; + } + + public string Project { + get; + set; + } + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs index 4eda2000c4..5db3ed8216 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs @@ -42,32 +42,50 @@ namespace MonoDevelop.Components.MainToolbar { class FileSearchCategory : SearchCategory { - public FileSearchCategory () : base (GettextCatalog.GetString("Files")) + public FileSearchCategory () : base (GettextCatalog.GetString ("Files")) { } - IEnumerable<ProjectFile> AllFiles { - get { - foreach (var doc in IdeApp.Workbench.Documents) { - // We only want to check it here if it's not part - // of the open combine. Otherwise, it will get - // checked down below. - if (doc.Project == null && doc.IsFile) - yield return new ProjectFile (doc.Name); + static FileSearchCategory () + { + IdeApp.Workspace.SolutionLoaded += delegate { allFilesCache = null; }; + IdeApp.Workspace.SolutionUnloaded += delegate { allFilesCache = null; }; + IdeApp.Workspace.ItemAddedToSolution += delegate { allFilesCache = null; }; + IdeApp.Workspace.ItemRemovedFromSolution += delegate { allFilesCache = null; }; + IdeApp.Workspace.FileAddedToProject += delegate { allFilesCache = null; }; + IdeApp.Workspace.FileRemovedFromProject += delegate { allFilesCache = null; }; + IdeApp.Workspace.FileRenamedInProject += delegate { allFilesCache = null; }; + IdeApp.Workbench.DocumentOpened += delegate { allFilesCache = null; }; + IdeApp.Workbench.DocumentClosed += delegate { allFilesCache = null; }; + } + + List<Tuple<string, string, ProjectFile>> GenerateAllFiles () + { + //Slowest thing here is GetRelProjectPath, hence Tuple<,,> needs to be cached + var list = new List<Tuple<string, string, ProjectFile>> (); + foreach (var doc in IdeApp.Workbench.Documents) { + // We only want to check it here if it's not part + // of the open combine. Otherwise, it will get + // checked down below. + if (doc.Project == null && doc.IsFile) { + var pf = new ProjectFile (doc.Name); + list.Add (new Tuple<string, string, ProjectFile> (System.IO.Path.GetFileName (pf.FilePath), FileSearchResult.GetRelProjectPath (pf), pf)); } - - var projects = IdeApp.Workspace.GetAllProjects (); + } + + var projects = IdeApp.Workspace.GetAllProjects (); - foreach (var p in projects) { - foreach (ProjectFile file in p.Files) { - if (file.Subtype != Subtype.Directory && (file.Flags & ProjectItemFlags.Hidden) != ProjectItemFlags.Hidden) - yield return file; + foreach (var p in projects) { + foreach (ProjectFile pf in p.Files) { + if (pf.Subtype != Subtype.Directory && (pf.Flags & ProjectItemFlags.Hidden) != ProjectItemFlags.Hidden) { + list.Add (new Tuple<string, string, ProjectFile> (System.IO.Path.GetFileName (pf.FilePath), FileSearchResult.GetRelProjectPath (pf), pf)); } } } + return list; } - string[] validTags = new [] { "file" , "f" }; + string [] validTags = new [] { "file", "f" }; public override string [] Tags { get { @@ -80,25 +98,34 @@ namespace MonoDevelop.Components.MainToolbar return validTags.Any (t => t == tag); } + static List<Tuple<string, string, ProjectFile>> allFilesCache; + public override Task GetResults (ISearchResultCallback searchResultCallback, SearchPopupSearchPattern pattern, CancellationToken token) { return Task.Run (delegate { - var files = AllFiles.ToList (); + var files = allFilesCache = allFilesCache ?? GenerateAllFiles (); var matcher = StringMatcher.GetMatcher (pattern.Pattern, false); var savedMatches = new Dictionary<string, MatchResult> (); - foreach (ProjectFile file in files) { + foreach (var file in files) { if (token.IsCancellationRequested) break; - int rank; - string matchString = System.IO.Path.GetFileName (file.FilePath); - if (MatchName (savedMatches, matcher, matchString, out rank)) - searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, matchString, rank, file, true)); - matchString = FileSearchResult.GetRelProjectPath (file); - if (MatchName (savedMatches, matcher, matchString, out rank)) - searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, matchString, rank, file, true)); - + int rank1; + int rank2; + var match1 = MatchName (savedMatches, matcher, file.Item1, out rank1); + var match2 = MatchName (savedMatches, matcher, file.Item2, out rank2); + if (match1 && match2) { + if (rank1 > rank2 || (rank1 == rank2 && String.CompareOrdinal (file.Item1, file.Item2) > 0)) { + searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, file.Item1, rank1, file.Item3)); + } else { + searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, file.Item2, rank2, file.Item3)); + } + } else if (match1) { + searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, file.Item1, rank1, file.Item3)); + } else if (match2) { + searchResultCallback.ReportResult (new FileSearchResult (pattern.Pattern, file.Item2, rank2, file.Item3)); + } } - }, token); + }, token); } static bool MatchName (Dictionary<string, MatchResult> savedMatches, StringMatcher matcher, string name, out int matchRank) @@ -110,7 +137,7 @@ namespace MonoDevelop.Components.MainToolbar MatchResult savedMatch; if (!savedMatches.TryGetValue (name, out savedMatch)) { bool doesMatch = matcher.CalcMatchRank (name, out matchRank); - savedMatches[name] = savedMatch = new MatchResult (doesMatch, matchRank); + savedMatches [name] = savedMatch = new MatchResult (doesMatch, matchRank); } matchRank = savedMatch.Rank; 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 85e73b3b23..44d6118ed4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs @@ -401,6 +401,11 @@ namespace MonoDevelop.Components.MainToolbar } UpdateBuildConfiguration (); } + + var runtime = (RuntimeModel)ToolbarView.ActiveRuntime; + if (runtime != null && runtime.Command == null) { + currentStartupProject.UserProperties.SetValue<string> ("PreferredExecutionTarget", runtime.TargetId); + } } } finally { ignoreRuntimeChangedCount--; @@ -444,9 +449,6 @@ namespace MonoDevelop.Components.MainToolbar void TrackStartupProject () { if (currentStartupProject != null && ((currentSolution != null && currentStartupProject != currentSolution.StartupItem) || currentSolution == null)) { - var runtime = (RuntimeModel)ToolbarView.ActiveRuntime; - if (runtime != null && runtime.Command == null) - currentStartupProject.UserProperties.SetValue<string> ("PreferredExecutionTarget", runtime.TargetId); currentStartupProject.ExecutionTargetsChanged -= executionTargetsChanged; currentStartupProject.Saved -= HandleUpdateCombos; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchCategory.cs index 156883cbd9..a685eacaa8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchCategory.cs @@ -38,33 +38,15 @@ namespace MonoDevelop.Components.MainToolbar internal class DataItemComparer : IComparer<SearchResult> { - CancellationToken Token { - get; set; - } - - public DataItemComparer () - { - } - - public DataItemComparer (CancellationToken token) - { - Token = token; - } - - static uint compareTick; public int Compare (SearchResult o1, SearchResult o2) { - if (unchecked(compareTick++) % 100 == 0) - Token.ThrowIfCancellationRequested (); - var r = o2.Rank.CompareTo (o1.Rank); if (r == 0) r = o1.SearchResultType.CompareTo (o2.SearchResultType); if (r == 0) - return String.CompareOrdinal (o1.MatchedString, o2.MatchedString); + return string.CompareOrdinal (o1.MatchedString, o2.MatchedString); return r; } - } protected struct MatchResult 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 7a941c3f0d..08d921ff59 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchPopupWindow.cs @@ -52,7 +52,6 @@ namespace MonoDevelop.Components.MainToolbar List<SearchCategory> categories = new List<SearchCategory> (); List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> results = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (); - List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> incompleteResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (); Pango.Layout layout, headerLayout; CancellationTokenSource src; Cairo.Color headerColor; @@ -143,20 +142,6 @@ namespace MonoDevelop.Components.MainToolbar Events = Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonMotionMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.ExposureMask | Gdk.EventMask.PointerMotionMask; ItemActivated += (sender, e) => OpenFile (); - /* - SizeRequested += delegate(object o, SizeRequestedArgs args) { - if (inResize) - return; - if (args.Requisition.Width != Allocation.Width || args.Requisition.Height != Allocation.Height) { - inResize = true; -// Visible = false; - Resize (args.Requisition.Width, args.Requisition.Height); -// Visible = true; - if (!Visible) - Visible = true; - inResize = false; - } - };*/ } bool inResize = false; @@ -219,8 +204,7 @@ namespace MonoDevelop.Components.MainToolbar class SearchResultCollector : ISearchResultCallback { - readonly SearchPopupWindow parent; - ImmutableList<SearchResult> searchResults = ImmutableList<SearchResult>.Empty; + List<SearchResult> searchResults = new List<SearchResult> (maxItems); public IReadOnlyList<SearchResult> Results { get { @@ -230,9 +214,8 @@ namespace MonoDevelop.Components.MainToolbar public SearchCategory Category { get; private set;} - public SearchResultCollector (SearchPopupWindow parent, SearchCategory cat) + public SearchResultCollector (SearchCategory cat) { - this.parent = parent; this.Category = cat; } @@ -241,46 +224,37 @@ namespace MonoDevelop.Components.MainToolbar #region ISearchResultCallback implementation void ISearchResultCallback.ReportResult (SearchResult result) { - int i = Math.Min (maxItems, searchResults.Count); - while (i > 0) { - if (cmp.Compare (result, searchResults [i - 1]) > 0) - break; - i--; + if (maxItems == searchResults.Count) { + int i = searchResults.Count; + while (i > 0) { + if (cmp.Compare (result, searchResults [i - 1]) > 0) + break; + i--; + } + if (i == maxItems) { + return;//this means it's worse then current worst + } else { + if (!result.IsValid) + return; + searchResults.RemoveAt (maxItems - 1); + searchResults.Insert (i, result); + } + } else { + if (!result.IsValid) + return; + int i = searchResults.Count; + while (i > 0) { + if (cmp.Compare (result, searchResults [i - 1]) > 0) + break; + i--; + } + searchResults.Insert (i, result); } - - if (i >= maxItems || !result.IsValid) - return; - searchResults = searchResults.Insert (i, result); - Runtime.RunInMainThread (delegate { - parent.UpdateSearchCollectors (); - }); } #endregion } - uint timeout; - - void UpdateSearchCollectors() - { - RemoveTimeout (); - timeout = GLib.Timeout.Add (200, delegate { - foreach (var col in collectors) { - ShowResult (col.Category, col.Results); - } - QueueResize (); - timeout = 0; - return false; - }); - } - void RemoveTimeout () - { - if (timeout == 0) - return; - GLib.Source.Remove (timeout); - timeout = 0; - } - List<SearchResultCollector> collectors = new List<SearchResultCollector> (); public void Update (SearchPopupSearchPattern pattern) { // in case of 'string:' it's not clear if the user ment 'tag:pattern' or 'pattern:line' therefore guess @@ -292,95 +266,71 @@ namespace MonoDevelop.Components.MainToolbar this.pattern = pattern; if (src != null) src.Cancel (); - RemoveTimeout (); HideTooltip (); src = new CancellationTokenSource (); isInSearch = true; if (results.Count == 0) { QueueDraw (); } - incompleteResults.Clear (); var collectors = new List<SearchResultCollector> (); var token = src.Token; foreach (var _cat in categories) { var cat = _cat; if (!string.IsNullOrEmpty (pattern.Tag) && !cat.IsValidTag (pattern.Tag)) continue; - var col = new SearchResultCollector (this, _cat); + var col = new SearchResultCollector (_cat); collectors.Add (col); col.Task = cat.GetResults (col, pattern, token); } Task.WhenAll (collectors.Select (c => c.Task)).ContinueWith (t => { - if (t.IsCanceled) - return; Application.Invoke (delegate { - RemoveTimeout (); if (token.IsCancellationRequested) return; + var newResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (collectors.Count); 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); + newResults.Add (Tuple.Create (col.Category, col.Results)); } } + ShowResults (newResults); isInSearch = false; AnimatedResize (); }); }, token); } - void ShowResult (SearchCategory cat, IReadOnlyList<SearchResult> result) + void ShowResults (List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> newResults) { - bool found = false; - for (int i = 0; i < incompleteResults.Count; i++) { - var ir = incompleteResults [i]; - if (ir.Item1 == cat) { - incompleteResults[i] = Tuple.Create (cat, result); - found = true; - break; - } - } - if (!found) { - incompleteResults.Add (Tuple.Create (cat, result)); - incompleteResults.Sort ((x, y) => { - return categories.IndexOf (x.Item1).CompareTo (categories.IndexOf (y.Item1)); - }); - } - - //if (incompleteResults.Count == categories.Count) - { - results.Clear (); - results.AddRange (incompleteResults); - List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> failedResults = null; - topItem = null; - - for (int i = 0; i < results.Count; i++) { - var tuple = results [i]; - try { - if (tuple.Item2.Count == 0) - continue; - if (topItem == null || topItem.DataSource[topItem.Item].Weight < tuple.Item2[0].Weight) - topItem = new ItemIdentifier(tuple.Item1, tuple.Item2, 0); - } catch (Exception e) { - LoggingService.LogError ("Error while showing result " + i, e); - if (failedResults == null) - failedResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (); - failedResults.Add (results [i]); + results = newResults; + List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> failedResults = null; + topItem = null; + + for (int i = 0; i < results.Count; i++) { + var tuple = results [i]; + try { + if (tuple.Item2.Count == 0) continue; - } + if (topItem == null || topItem.DataSource [topItem.Item].Weight < tuple.Item2 [0].Weight) + topItem = new ItemIdentifier (tuple.Item1, tuple.Item2, 0); + } catch (Exception e) { + LoggingService.LogError ("Error while showing result " + i, e); + if (failedResults == null) + failedResults = new List<Tuple<SearchCategory, IReadOnlyList<SearchResult>>> (); + failedResults.Add (results [i]); + continue; } - selectedItem = topItem; - - if (failedResults != null) - failedResults.ForEach (failedResult => results.Remove (failedResult)); + } + selectedItem = topItem; - ShowTooltip (); + if (failedResults != null) + failedResults.ForEach (failedResult => results.Remove (failedResult)); - } + ShowTooltip (); } int calculatedItems; @@ -665,19 +615,19 @@ namespace MonoDevelop.Components.MainToolbar TooltipInformation tooltip; try { - tooltip = await currentSelectedItem.DataSource[i].GetTooltipInformation (token); + tooltip = await currentSelectedItem.DataSource [i].GetTooltipInformation (token); + } catch (OperationCanceledException) { + return; } catch (Exception e) { LoggingService.LogError ("Error while creating search popup window tooltip", e); return; } if (tooltip == null || string.IsNullOrEmpty (tooltip.SignatureMarkup) || token.IsCancellationRequested) return; - Application.Invoke (delegate { - declarationviewwindow.Clear (); - declarationviewwindow.AddOverload (tooltip); - declarationviewwindow.CurrentOverload = 0; - declarationViewTimer = GLib.Timeout.Add (250, DelayedTooltipShow); - }); + declarationviewwindow.Clear (); + declarationviewwindow.AddOverload (tooltip); + declarationviewwindow.CurrentOverload = 0; + declarationViewTimer = GLib.Timeout.Add (250, DelayedTooltipShow); } bool DelayedTooltipShow () @@ -821,15 +771,17 @@ namespace MonoDevelop.Components.MainToolbar if (state.HasFlag (Xwt.ModifierKeys.Command)) goto case Xwt.Key.PageUp; if (state.HasFlag (Xwt.ModifierKeys.Control)) - goto case Xwt.Key.Home; - SelectItemUp (); + SelectFirstCategory (); + else + SelectItemUp (); return true; case Xwt.Key.Down: if (state.HasFlag (Xwt.ModifierKeys.Command)) goto case Xwt.Key.PageDown; if (state.HasFlag (Xwt.ModifierKeys.Control)) - goto case Xwt.Key.End; - SelectItemDown (); + SelectLastCatgory (); + else + SelectItemDown (); return true; case (Xwt.Key)Gdk.Key.KP_Page_Down: case Xwt.Key.PageDown: @@ -839,12 +791,6 @@ namespace MonoDevelop.Components.MainToolbar case Xwt.Key.PageUp: SelectPrevCategory (); return true; - case Xwt.Key.Home: - SelectFirstCategory (); - return true; - case Xwt.Key.End: - SelectLastCatgory (); - return true; case Xwt.Key.Return: OnItemActivated (EventArgs.Empty); return true; 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 33ac200a5b..fdab266827 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchResult.cs @@ -137,55 +137,44 @@ namespace MonoDevelop.Components.MainToolbar } } - class FileSearchResult: SearchResult + class FileSearchResult : SearchResult { ProjectFile file; - bool useFileName; public override SearchResultType SearchResultType { get { return SearchResultType.File; } } public override string PlainText { get { - if (useFileName) - return System.IO.Path.GetFileName (file.FilePath); - return GetRelProjectPath (file); + return System.IO.Path.GetFileName (file.FilePath); } } - + public override string File { get { return file.FilePath; } } - + public override Xwt.Drawing.Image Icon { get { return DesktopService.GetIconForFile (file.FilePath, IconSize.Menu); } } - public override Task<TooltipInformation> GetTooltipInformation (CancellationToken token) - { - return Task.FromResult<TooltipInformation> (null); - } - public override string Description { get { - if (useFileName) - return file.Project != null - ? GettextCatalog.GetString ("file \"{0}\" in project \"{1}\"", GetRelProjectPath (file), file.Project.Name) - : GettextCatalog.GetString ("file \"{0}\"", GetRelProjectPath (file)); - return file.Project != null ? GettextCatalog.GetString ("file in project \"{0}\"", file.Project.Name) : ""; + return file.Project != null + ? GettextCatalog.GetString ("file \"{0}\" in project \"{1}\"", GetRelProjectPath (file), file.Project.Name) + : GettextCatalog.GetString ("file \"{0}\"", GetRelProjectPath (file)); } } - - public FileSearchResult (string match, string matchedString, int rank, ProjectFile file, bool useFileName) + + public FileSearchResult (string match, string matchedString, int rank, ProjectFile file) : base (match, matchedString, rank) { this.file = file; - this.useFileName = useFileName; } - + internal static string GetRelProjectPath (ProjectFile file) { if (file.Project != null) @@ -231,11 +220,6 @@ namespace MonoDevelop.Components.MainToolbar } } - public override Task<TooltipInformation> GetTooltipInformation (CancellationToken token) - { - return Task.FromResult<TooltipInformation> (null); - } - public override string Description { get { string desc = ""; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Control.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Control.cs index b9da8f0b15..61a3bdb059 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Control.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Control.cs @@ -75,10 +75,7 @@ namespace MonoDevelop.Components c.FocusChain = new [] { gtkWidget }; c.Show (); nativeWidget = c; - c.Destroyed += delegate { - GC.SuppressFinalize (this); - Dispose (true); - }; + c.Destroyed += OnGtkDestroyed; toCache = c; } else { nativeWidget = w; @@ -97,6 +94,12 @@ namespace MonoDevelop.Components throw new NotSupportedException (); } + void OnGtkDestroyed (object sender, EventArgs args) + { + GC.SuppressFinalize (this); + Dispose (true); + } + static object ConvertToType (Type t, object w) { if (t.IsInstanceOfType (w)) @@ -186,9 +189,9 @@ namespace MonoDevelop.Components public void Dispose () { - if (nativeWidget is Gtk.Widget) { - ((Gtk.Widget)nativeWidget).Destroy (); - return; + var gtkWidget = nativeWidget as Gtk.Widget; + if (gtkWidget != null) { + gtkWidget.Destroy (); } #if MAC else if (nativeWidget is NSView) @@ -202,6 +205,11 @@ namespace MonoDevelop.Components { if (nativeWidget != null) cache.Remove (nativeWidget); + + var gtkWidget = nativeWidget as Gtk.Widget; + if (gtkWidget != null) { + gtkWidget.Destroyed -= OnGtkDestroyed; + } } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkUtil.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkUtil.cs index 2c0fba321a..61d8d2d456 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkUtil.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkUtil.cs @@ -219,10 +219,7 @@ namespace MonoDevelop.Components tree.ScrollEvent += HandleTreeScrollEvent; tree.Hidden += HandleTreeHidden; tree.Unrealized += HandleTreeHidden; - tree.Destroyed += delegate { - ResetTooltip (tree); - treeData.Remove (tree); - }; + tree.Destroyed += HandleTreeDestroyed; } static void ResetTooltip (Gtk.TreeView tree) @@ -243,6 +240,14 @@ namespace MonoDevelop.Components ResetTooltip ((Gtk.TreeView) sender); } + static void HandleTreeDestroyed (object sender, EventArgs e) + { + var tree = (Gtk.TreeView)sender; + + ResetTooltip (tree); + treeData.Remove (tree); + } + [GLib.ConnectBeforeAttribute] static void HandleTreeScrollEvent (object o, ScrollEventArgs args) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs index 7b1afbfcdf..3a59ca1ec1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs @@ -483,6 +483,9 @@ namespace MonoDevelop.Ide.CodeCompletion if (descriptor.KeyChar == ' ' && (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift) return KeyActions.CloseWindow | KeyActions.Process; + if (char.IsDigit (descriptor.KeyChar) && string.IsNullOrEmpty (CurrentCompletionText)) + return KeyActions.CloseWindow | KeyActions.Process; + // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::' if (char.IsPunctuation (descriptor.KeyChar) && descriptor.KeyChar != '_') { if (descriptor.KeyChar == ':') { 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 d3f0f3a801..2c82c997fb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs @@ -157,7 +157,9 @@ namespace MonoDevelop.Ide.CodeTemplates public static string GetTemplateShortcutBeforeCaret (TextEditor editor) { int offset = editor.CaretOffset; - int start = FindPrevWordStart (editor, offset); + if (offset == 0) + return ""; + int start = FindPrevWordStart (editor, offset - 1); return editor.GetTextBetween (start, offset); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/EditTemplateDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/EditTemplateDialog.cs index f434379a70..2fd8c29936 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/EditTemplateDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/EditTemplateDialog.cs @@ -59,7 +59,7 @@ namespace MonoDevelop.Ide.CodeTemplates this.comboboxentryMime.Entry.Text = template.MimeType ?? ""; this.entryDescription.Text = template.Description ?? ""; this.textEditor.MimeType = template.MimeType; - this.textEditor.Text = template.Code; + this.textEditor.Text = template.Code ?? ""; checkbuttonExpansion.Active = (template.CodeTemplateType & CodeTemplateType.Expansion) == CodeTemplateType.Expansion; checkbuttonSurroundWith.Active = (template.CodeTemplateType & CodeTemplateType.SurroundsWith) == CodeTemplateType.SurroundsWith; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs index 3991f81909..09d33e34a9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs @@ -37,6 +37,7 @@ using System.Threading.Tasks; using System.Linq; using MonoDevelop.Ide.Editor; using MonoDevelop.Ide.Editor.Extension; +using System.Web.SessionState; namespace MonoDevelop.Ide.CodeTemplates { @@ -141,7 +142,7 @@ namespace MonoDevelop.Ide.CodeTemplates ITypeSymbol GetElementType (Compilation compilation, ITypeSymbol type) { - ITypeSymbol tmp = type; + ITypeSymbol tmp = null; foreach (var baseType in type.AllInterfaces) { if (baseType != null && baseType.Name == "IEnumerable") { if (baseType.TypeArguments.Length > 0) { @@ -188,7 +189,12 @@ namespace MonoDevelop.Ide.CodeTemplates CurrentContext.DocumentContext.GetContent <MonoDevelop.Ide.CodeCompletion.ICompletionWidget> ().CurrentCodeCompletionContext).Result; foreach (var data in list.OfType<ISymbolCompletionData> ()) { - if (GetElementType (compilation, data.Symbol.GetReturnType ()).TypeKind != TypeKind.Error) { + if (data.Symbol == null) + continue; + var type = data.Symbol.GetReturnType (); + if (type == null) + continue; + if (GetElementType (compilation, type) != null) { var method = data as IMethodSymbol; if (method != null) { if (method.Parameters.Length == 0) @@ -203,7 +209,7 @@ namespace MonoDevelop.Ide.CodeTemplates foreach (var data in list.OfType<ISymbolCompletionData> ()) { var m = data.Symbol as IParameterSymbol; if (m != null) { - if (GetElementType (compilation, m.Type).TypeKind != TypeKind.Error) + if (GetElementType (compilation, m.Type) != null) result.Add (new CodeTemplateVariableValue (m.Name, ((CompletionData)data).Icon)); } } @@ -212,8 +218,8 @@ namespace MonoDevelop.Ide.CodeTemplates var m = sym.Symbol as ILocalSymbol; if (m == null) continue; - if (GetElementType (compilation, m.Type).TypeKind != TypeKind.Error) - result.Add (new CodeTemplateVariableValue (m.Name, ((CompletionData)m).Icon)); + if (GetElementType (compilation, m.Type) != null) + result.Add (new CodeTemplateVariableValue (m.Name, ((CompletionData)sym).Icon)); } } return new CodeTemplateListDataProvider (result); 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 index 87ccb5446a..f60a9926b9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/AbstractNavigationExtension.cs @@ -30,6 +30,8 @@ using System.Threading.Tasks; using ICSharpCode.NRefactory.Editor; using System.Threading; using MonoDevelop.Core; +using Xwt; +using System.Linq; namespace MonoDevelop.Ide.Editor.Extension { @@ -110,11 +112,11 @@ namespace MonoDevelop.Ide.Editor.Extension static bool IsTriggerKey (Gdk.EventKey evnt) { - #if MAC +#if MAC return evnt.Key == Gdk.Key.Meta_L || evnt.Key == Gdk.Key.Meta_R; - #else +#else return evnt.Key == Gdk.Key.Control_L || evnt.Key == Gdk.Key.Control_R; - #endif +#endif } #endregion @@ -128,7 +130,7 @@ namespace MonoDevelop.Ide.Editor.Extension { LinksShownChanged += AbstractNavigationExtension_LinksShownChanged; this.DocumentContext.DocumentParsed += DocumentContext_DocumentParsed; - this.Editor.LineShown += Editor_LineShown; + this.Editor.MouseMoved += Editor_MouseMoved; if (LinksShown) ShowLinks (); @@ -155,36 +157,40 @@ namespace MonoDevelop.Ide.Editor.Extension } List<ITextSegmentMarker> markers = new List<ITextSegmentMarker> (); - - async void ShowLinks () + List<IDocumentLine> visibleLines = new List<IDocumentLine> (); + void ShowLinks () { HideLinks (); try { - foreach (var line in Editor.VisibleLines) { - if (line.Length <= 0) - continue; - foreach (var segment in await RequestLinksAsync (line.Offset, line.Length, default (CancellationToken))) { - var marker = Editor.TextMarkerFactory.CreateLinkMarker (Editor, segment.Offset, segment.Length, delegate { segment.Activate (); }); - marker.OnlyShowLinkOnHover = true; - Editor.AddMarker (marker); - markers.Add (marker); - } - } + Editor_MouseMoved (this, null); } catch (Exception e) { LoggingService.LogError ("Error while retrieving nav links.", e); } } - async void Editor_LineShown (object sender, Ide.Editor.LineEventArgs e) + double x, y; + async void Editor_MouseMoved (object sender, MouseMovedEventArgs e) { + if (e != null) { + x = e.X; + y = e.Y; + } if (LinksShown) { - var line = e.Line; - foreach (var segment in await RequestLinksAsync (line.Offset, line.Length, default (CancellationToken))) { - var marker = Editor.TextMarkerFactory.CreateLinkMarker (Editor, segment.Offset, segment.Length, delegate { segment.Activate (); }); - marker.OnlyShowLinkOnHover = true; - Editor.AddMarker (marker); - markers.Add (marker); + var lineNumber = Editor.PointToLocation (x, y).Line; + var line = Editor.GetLine (lineNumber); + if (visibleLines.Any (l => l.Equals (line))) { + return; } + visibleLines.Add (line); + var segments = await RequestLinksAsync (line.Offset, line.Length, default (CancellationToken)); + await Runtime.RunInMainThread (delegate { + foreach (var segment in segments) { + var marker = Editor.TextMarkerFactory.CreateLinkMarker (Editor, segment.Offset, segment.Length, delegate { segment.Activate (); }); + marker.OnlyShowLinkOnHover = true; + Editor.AddMarker (marker); + markers.Add (marker); + } + }); } } @@ -194,6 +200,7 @@ namespace MonoDevelop.Ide.Editor.Extension Editor.RemoveMarker (m); } markers.Clear (); + visibleLines.Clear (); } void RemoveTimer () @@ -206,11 +213,10 @@ namespace MonoDevelop.Ide.Editor.Extension { LinksShownChanged -= AbstractNavigationExtension_LinksShownChanged; DocumentContext.DocumentParsed -= DocumentContext_DocumentParsed; - Editor.LineShown -= Editor_LineShown; + this.Editor.MouseMoved -= Editor_MouseMoved; HideLinks (); RemoveTimer (); base.Dispose (); } - } }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs index 942df69669..9172c2e371 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs @@ -57,7 +57,11 @@ namespace MonoDevelop.Ide.Editor.Extension get { return completionWidget; } set { + if (completionWidget != null) + completionWidget.CompletionContextChanged -= OnCompletionContextChanged; completionWidget = value; + if (completionWidget != null) + completionWidget.CompletionContextChanged += OnCompletionContextChanged; } } @@ -592,8 +596,6 @@ namespace MonoDevelop.Ide.Editor.Extension base.Initialize (); CompletionWindowManager.WindowClosed += HandleWindowClosed; CompletionWidget = DocumentContext.GetContent <ICompletionWidget> () ?? CompletionWidget; - if (CompletionWidget != null) - CompletionWidget.CompletionContextChanged += OnCompletionContextChanged; Editor.CaretPositionChanged += HandlePositionChanged; // document.Editor.Paste += HandlePaste; // if (document.Editor.Parent != null) @@ -641,8 +643,7 @@ namespace MonoDevelop.Ide.Editor.Extension { Editor.CaretPositionChanged -= HandlePositionChanged; CompletionWindowManager.WindowClosed -= HandleWindowClosed; - if (CompletionWidget != null) - CompletionWidget.CompletionContextChanged -= OnCompletionContextChanged; + CompletionWidget = null; } } 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 48cff66ce5..126fd79a13 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 @@ -749,7 +749,12 @@ namespace MonoDevelop.Ide.Editor.Highlighting internal static ColorScheme LoadFrom (Stream stream) { var result = new ColorScheme (); - var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (stream, new System.Xml.XmlDictionaryReaderQuotas ()); + byte [] bytes; + using (var sr = Core.Text.TextFileUtility.OpenStream (stream)) { + bytes = System.Text.Encoding.UTF8.GetBytes (sr.ReadToEnd ()); + } + + var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (bytes, new System.Xml.XmlDictionaryReaderQuotas ()); var root = XElement.Load(reader); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs index 7e5a14aba5..db4d199846 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/SyntaxModeService.cs @@ -36,6 +36,7 @@ using System.Xml.Schema; using System.Linq; using Mono.Addins; using MonoDevelop.Core; +using MonoDevelop.Core.Text; namespace MonoDevelop.Ide.Editor.Highlighting { @@ -103,6 +104,7 @@ namespace MonoDevelop.Ide.Editor.Highlighting styles [name] = ColorScheme.LoadFrom (stream); } } catch (Exception e) { + LoggingService.LogError ("Error while loading style :" + name, e); throw new IOException ("Error while loading style :" + name, e); } finally { stream.Close (); @@ -168,9 +170,10 @@ namespace MonoDevelop.Ide.Editor.Highlighting static string ScanStyle (Stream stream) { try { - var file = new StreamReader (stream); + var file = TextFileUtility.OpenStream (stream); file.ReadLine (); var nameLine = file.ReadLine (); + file.Close (); var match = nameRegex.Match (nameLine); if (!match.Success) return null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/CustomEditorOptions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/CustomEditorOptions.cs index a3932167e2..17f830a088 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/CustomEditorOptions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/CustomEditorOptions.cs @@ -130,6 +130,11 @@ namespace MonoDevelop.Ide.Editor set; } + public bool EnableSelectionWrappingKeys { + get; + set; + } + public ShowWhitespaces ShowWhitespaces { get; set; @@ -172,6 +177,7 @@ namespace MonoDevelop.Ide.Editor ColorScheme = initializeFrom.ColorScheme; DefaultEolMarker = initializeFrom.DefaultEolMarker; GenerateFormattingUndoStep = initializeFrom.GenerateFormattingUndoStep; + EnableSelectionWrappingKeys = initializeFrom.EnableSelectionWrappingKeys; ShowWhitespaces = initializeFrom.ShowWhitespaces; IncludeWhitespaces = initializeFrom.IncludeWhitespaces; } 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 64915e042e..6b37d6d84c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs @@ -218,6 +218,12 @@ namespace MonoDevelop.Ide.Editor } } + bool ITextEditorOptions.EnableSelectionWrappingKeys { + get { + return DefaultSourceEditorOptions.Instance.EnableSelectionWrappingKeys; + } + } + ShowWhitespaces ITextEditorOptions.ShowWhitespaces { get { return ShowWhitespaces.Never; @@ -705,7 +711,18 @@ namespace MonoDevelop.Ide.Editor OnChanged (EventArgs.Empty); } } - + + ConfigurationProperty<bool> enableSelectionWrappingKeys = ConfigurationProperty.Create ("EnableSelectionWrappingKeys", false); + public bool EnableSelectionWrappingKeys { + get { + return enableSelectionWrappingKeys; + } + set { + if (enableSelectionWrappingKeys.Set (value)) + OnChanged (EventArgs.Empty); + } + } + bool overrideDocumentEolMarker = false; public bool OverrideDocumentEolMarker { get { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextEditorOptions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextEditorOptions.cs index 223f2cf2ec..b2c8655b90 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextEditorOptions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextEditorOptions.cs @@ -96,6 +96,7 @@ namespace MonoDevelop.Ide.Editor string DefaultEolMarker { get; } bool GenerateFormattingUndoStep { get; } + bool EnableSelectionWrappingKeys { get; } ShowWhitespaces ShowWhitespaces { get; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs index cdb7cd0416..83fe4e1a81 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs @@ -30,6 +30,7 @@ using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Editor.Extension; using MonoDevelop.Ide.Editor.Highlighting; using MonoDevelop.Components; +using Xwt; namespace MonoDevelop.Ide.Editor { @@ -83,7 +84,7 @@ namespace MonoDevelop.Ide.Editor ViewContent ViewContent { get; } string ContentName { get; set; } - + EditMode EditMode { get; } ITextEditorOptions Options { get; set; } @@ -112,7 +113,7 @@ namespace MonoDevelop.Ide.Editor event EventHandler CaretPositionChanged; - event EventHandler BeginMouseHover; + event EventHandler<MouseMovedEventArgs> MouseMoved; event EventHandler VAdjustmentChanged; @@ -160,8 +161,7 @@ namespace MonoDevelop.Ide.Editor void CenterTo (int offset); - IList<SkipChar> SkipChars - { + IList<SkipChar> SkipChars { get; } @@ -211,14 +211,12 @@ namespace MonoDevelop.Ide.Editor #region Internal use only API (do not mirror in TextEditor) - TextEditorExtension EditorExtension - { + TextEditorExtension EditorExtension { get; set; } - IEnumerable<TooltipProvider> TooltipProvider - { + IEnumerable<TooltipProvider> TooltipProvider { get; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs index 3631e25186..89b948f251 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs @@ -40,6 +40,7 @@ using System.ComponentModel; using MonoDevelop.Ide.TypeSystem; using System.Threading; using MonoDevelop.Ide.Editor.Projection; +using Xwt; namespace MonoDevelop.Ide.Editor { @@ -112,9 +113,9 @@ namespace MonoDevelop.Ide.Editor remove { ReadWriteTextDocument.TextChanged -= value; } } - public event EventHandler BeginMouseHover { - add { textEditorImpl.BeginMouseHover += value; } - remove { textEditorImpl.BeginMouseHover -= value; } + public event EventHandler<MouseMovedEventArgs> MouseMoved { + add { textEditorImpl.MouseMoved += value; } + remove { textEditorImpl.MouseMoved -= value; } } internal event EventHandler VAdjustmentChanged { @@ -1406,7 +1407,6 @@ namespace MonoDevelop.Ide.Editor textEditorImpl.UpdateBraceMatchingResult (result); } - internal IEnumerable<IDocumentLine> VisibleLines { get { return textEditorImpl.VisibleLines; } } internal event EventHandler<LineEventArgs> LineShown { add { textEditorImpl.LineShown += value; } remove { textEditorImpl.LineShown -= value; } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs index c78724a007..cd974b4cdb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindInFilesDialog.cs @@ -34,6 +34,7 @@ using MonoDevelop.Components; using Gtk; using System.Collections.Generic; using MonoDevelop.Ide.Gui.Content; +using System.Threading.Tasks; namespace MonoDevelop.Ide.FindInFiles { @@ -779,22 +780,18 @@ namespace MonoDevelop.Ide.FindInFiles SearchReplace (comboboxentryFind.Entry.Text, null, GetScope (), GetFilterOptions (), () => UpdateStopButton ()); } - readonly static List<CancellationTokenSource> searchesInProgress = new List<CancellationTokenSource> (); + static CancellationTokenSource searchTokenSource = new CancellationTokenSource (); + static Task currentTask; uint updateTimer; void UpdateStopButton () { - buttonStop.Sensitive = searchesInProgress.Count > 0; + buttonStop.Sensitive = currentTask != null && !currentTask.IsCompleted; } void ButtonStopClicked (object sender, EventArgs e) { - lock (searchesInProgress) { - if (searchesInProgress.Count == 0) - return; - var ts = searchesInProgress[searchesInProgress.Count - 1]; - ts.Cancel (); - } + searchTokenSource.Cancel (); } internal static void SearchReplace (string findPattern, string replacePattern, Scope scope, FilterOptions options, System.Action UpdateStopButton) @@ -802,13 +799,9 @@ namespace MonoDevelop.Ide.FindInFiles if (find != null && find.IsRunning) { if (!MessageService.Confirm (GettextCatalog.GetString ("There is a search already in progress. Do you want to stop it?"), AlertButton.Stop)) return; - lock (searchesInProgress) { - foreach (var ts in searchesInProgress) - ts.Cancel (); - searchesInProgress.Clear (); - } } - + searchTokenSource.Cancel (); + if (scope == null) return; @@ -826,16 +819,15 @@ namespace MonoDevelop.Ide.FindInFiles MessageService.ShowError (GettextCatalog.GetString ("Replace pattern is invalid")); return; } - - ThreadPool.QueueUserWorkItem (delegate { - CancellationTokenSource cancelSource = new CancellationTokenSource (); + var cancelSource = new CancellationTokenSource (); + searchTokenSource = cancelSource; + var token = cancelSource.Token; + currentTask = Task.Run (delegate { using (SearchProgressMonitor searchMonitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true, cancellationTokenSource:cancelSource)) { searchMonitor.PathMode = scope.PathMode; searchMonitor.ReportStatus (scope.GetDescription (options, pattern, null)); - lock (searchesInProgress) - searchesInProgress.Add (cancelSource); if (UpdateStopButton != null) { Application.Invoke (delegate { UpdateStopButton (); @@ -847,8 +839,8 @@ namespace MonoDevelop.Ide.FindInFiles try { var results = new List<SearchResult> (); - foreach (SearchResult result in find.FindAll (scope, searchMonitor, pattern, replacePattern, options)) { - if (searchMonitor.CancellationToken.IsCancellationRequested) + foreach (SearchResult result in find.FindAll (scope, searchMonitor, pattern, replacePattern, options, token)) { + if (token.IsCancellationRequested) return; results.Add (result); } @@ -873,7 +865,6 @@ namespace MonoDevelop.Ide.FindInFiles } searchMonitor.ReportStatus (message); searchMonitor.Log.WriteLine (GettextCatalog.GetString ("Search time: {0} seconds."), (DateTime.Now - timer).TotalSeconds); - searchesInProgress.Remove (cancelSource); } if (UpdateStopButton != null) { Application.Invoke (delegate { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindReplace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindReplace.cs index 559a39503e..aaae54a669 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindReplace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/FindReplace.cs @@ -70,7 +70,7 @@ namespace MonoDevelop.Ide.FindInFiles { if (filter.RegexSearch) { try { - new Regex (pattern, RegexOptions.Compiled); + new Regex (pattern); return true; } catch (Exception) { return false; @@ -79,7 +79,7 @@ namespace MonoDevelop.Ide.FindInFiles return true; } - public IEnumerable<SearchResult> FindAll (Scope scope, ProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter) + public IEnumerable<SearchResult> FindAll (Scope scope, ProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter, CancellationToken token) { if (filter.RegexSearch) { RegexOptions regexOptions = RegexOptions.Compiled; @@ -97,6 +97,8 @@ namespace MonoDevelop.Ide.FindInFiles var contents = new List<Tuple<FileProvider, string, List<SearchResult>>>(); foreach (var provider in scope.GetFiles (monitor, filter)) { + if (token.IsCancellationRequested) + return Enumerable.Empty<SearchResult> (); try { searchedFilesCount++; contents.Add(Tuple.Create (provider, provider.ReadString (), new List<SearchResult> ())); @@ -110,11 +112,16 @@ namespace MonoDevelop.Ide.FindInFiles var results = new List<SearchResult>(); if (filter.RegexSearch && replacePattern != null) { foreach (var content in contents) { + if (token.IsCancellationRequested) + return Enumerable.Empty<SearchResult> (); results.AddRange (RegexSearch (monitor, content.Item1, content.Item2, replacePattern, filter)); } } else { - Parallel.ForEach (contents, content => { - if (monitor.CancellationToken.IsCancellationRequested)
+ var options = new ParallelOptions (); + options.MaxDegreeOfParallelism = 4; + options.CancellationToken = token; + Parallel.ForEach (contents, options, content => { + if (token.IsCancellationRequested)
return; try { Interlocked.Increment (ref searchedFilesCount); @@ -132,6 +139,8 @@ namespace MonoDevelop.Ide.FindInFiles if (replacePattern != null) { foreach (var content in contents) { + if (token.IsCancellationRequested) + return Enumerable.Empty<SearchResult> (); if (content.Item3.Count == 0) continue; try { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultPad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultPad.cs index 91ad074358..c57389edd9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultPad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultPad.cs @@ -99,6 +99,8 @@ namespace MonoDevelop.Ide.FindInFiles protected override void Initialize (IPadWindow window) { window.Icon = Stock.FindIcon; + + IdeApp.Workspace.LastWorkspaceItemClosed += (sender, e) => widget.Reset (); base.Initialize (window); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectNodeBuilder.cs index da06f56488..275e555542 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectNodeBuilder.cs @@ -469,17 +469,18 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad } [CommandHandler (ProjectCommands.EditSolutionItem)] + [AllowMultiSelection] public void OnEditProject () { - var project = (Project) CurrentNode.DataItem; - IdeApp.Workbench.OpenDocument (project.FileName, project); + foreach (var nav in CurrentNodes) { + IdeApp.Workbench.OpenDocument (((Project)nav.DataItem).FileName, (Project)nav.DataItem); + } } [CommandUpdateHandler (ProjectCommands.EditSolutionItem)] public void OnEditProjectUpdate (CommandInfo info) { - var project = (Project) CurrentNode.DataItem; - info.Visible = info.Enabled = !string.IsNullOrEmpty (project.FileName) && File.Exists (project.FileName); + info.Visible = info.Enabled = CurrentNodes.All (nav => File.Exists (((Project)nav.DataItem).FileName)); } public override DragOperation CanDragNode () 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 cd461a48d1..a793bddcd3 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 @@ -50,6 +50,8 @@ using MonoDevelop.Components.Commands; using MonoDevelop.Ide.Commands; using MonoDevelop.Components; using System.Linq; +using MonoDevelop.Components.AutoTest; +using System.ComponentModel; namespace MonoDevelop.Ide.Gui.Pads { @@ -189,6 +191,8 @@ namespace MonoDevelop.Ide.Gui.Pads typeof (bool), // read? typeof (TaskListEntry), // read? -- use Pango weight typeof (string)); + SemanticModelAttribute modelAttr = new SemanticModelAttribute ("store__Type", "store__Read", "store__Task", "store__Description"); + TypeDescriptor.AddAttributes (store, modelAttr); TreeModelFilterVisibleFunc filterFunct = new TreeModelFilterVisibleFunc (FilterTasks); filter = new TreeModelFilter (store, null); @@ -298,6 +302,21 @@ namespace MonoDevelop.Ide.Gui.Pads } } while (view.Model.IterNext (ref it)); } + + internal void SelectTaskListEntry (TaskListEntry taskListEntry) + { + TreeIter iter; + if (!view.Model.GetIterFirst (out iter)) + return; + do { + var t = (TaskListEntry) view.Model.GetValue (iter, DataColumns.Task); + if (t == taskListEntry) { + view.Selection.SelectIter (iter); + view.ScrollToCell (view.Model.GetPath (iter), view.Columns[0], false, 0, 0); + return; + } + } while (view.Model.IterNext (ref iter)); + } void LoadColumnsVisibility () { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs index c7131bc81f..7640f14774 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -623,18 +623,24 @@ namespace MonoDevelop.Ide.Gui viewContentCollection.CopyTo (views, 0); foreach (var content in views) { if (content.ContentName.StartsWith (e.FileName, StringComparison.CurrentCulture)) { - content.UntitledName = content.ContentName; - content.ContentName = null; - content.IsDirty = true; + if (content.IsDirty) { + content.UntitledName = content.ContentName; + content.ContentName = null; + } else { + ((SdiWorkspaceWindow)content.WorkbenchWindow).CloseWindow (true, true); + } } } } else { foreach (var content in viewContentCollection) { if (content.ContentName != null && content.ContentName == e.FileName) { - content.UntitledName = content.ContentName; - content.ContentName = null; - content.IsDirty = true; + if (content.IsDirty) { + content.UntitledName = content.ContentName; + content.ContentName = null; + } else { + ((SdiWorkspaceWindow)content.WorkbenchWindow).CloseWindow (true, true); + } return; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs index af42da6311..ba93f44736 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs @@ -616,7 +616,7 @@ namespace MonoDevelop.Ide Title = pad.Title, Tag = pad }; - if (pad.Window.Content.Control.HasFocus) + if (pad.InternalContent.Initialized && pad.Window.Content.Control.HasFocus) activeItem = item; padCategory.AddItem (item); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs index 134d1502e0..a489d72dbf 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs @@ -277,14 +277,18 @@ namespace MonoDevelop.Ide.Gui pad = IdeApp.Workbench.ShowPad (monitorPad, newPadId, title, basePadId + "/Center Bottom", Stock.FindIcon); pad.Sticky = true; - searchMonitors.Add (pad); - - if (searchMonitors.Count > 1) { - // Additional search pads will be destroyed when hidden - pad.Window.PadHidden += delegate { - searchMonitors.Remove (pad); - pad.Destroy (); - }; + lock (searchMonitors) {
+ searchMonitors.Add (pad);
+
+ if (searchMonitors.Count > 1) {
+ // Additional search pads will be destroyed when hidden
+ pad.Window.PadHidden += delegate { + lock (searchMonitors) { + searchMonitors.Remove (pad); + } + pad.Destroy (); + };
+ } } if (bringToFront) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs index 02523169e7..4da5584e7a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs @@ -279,7 +279,7 @@ namespace MonoDevelop.Ide.Projects { OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File")); dlg.TransientFor = this; - dlg.InitialFileName = currentSet.Name + ".mdpolicy"; + dlg.InitialFileName = currentSet.Id + ".mdpolicy"; dlg.Action = MonoDevelop.Components.FileChooserAction.Save; dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy"); dlg.AddAllFilesFilter (); 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 6aa31e3068..dc254ada5b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewFileDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewFileDialog.cs @@ -38,6 +38,8 @@ using Gtk; using MonoDevelop.Ide.Gui.Components; using System.Linq; using MonoDevelop.Components; +using MonoDevelop.Components.AutoTest; +using System.ComponentModel; namespace MonoDevelop.Ide.Projects { @@ -762,6 +764,9 @@ namespace MonoDevelop.Ide.Projects HeadersVisible = false; templateStore = new ListStore (typeof(string), typeof(string), typeof(TemplateItem)); Model = templateStore; + + SemanticModelAttribute modelAttr = new SemanticModelAttribute ("templateStore__Icon", "templateStore__Name", "templateStore__Template"); + TypeDescriptor.AddAttributes (templateStore, modelAttr); TreeViewColumn col = new TreeViewColumn (); CellRendererImage crp = new CellRendererImage (); 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 78948aed96..6c787743d5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs @@ -706,6 +706,9 @@ namespace MonoDevelop.Ide.Projects static bool ProjectNameIsLanguageKeyword (string language, string projectName)
{
+ if (String.IsNullOrEmpty (language))
+ return false;
+
LanguageBinding binding = LanguageBindingService.GetBindingPerLanguageName (language);
if (binding != null) {
var codeDomProvider = binding.GetCodeDomProvider ();
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskListEntry.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskListEntry.cs index 675513d2d4..769ba00227 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskListEntry.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskListEntry.cs @@ -34,6 +34,7 @@ using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide.Gui.Pads.ProjectPad; using MonoDevelop.Core; using MonoDevelop.Core.Serialization; +using MonoDevelop.Ide.Gui.Pads; namespace MonoDevelop.Ide.Tasks { @@ -251,7 +252,17 @@ namespace MonoDevelop.Ide.Tasks } TaskService.InformJumpToTask (this); } - + + public void SelectInPad() + { + var pad = IdeApp.Workbench.GetPad<ErrorListPad> (); + if (pad == null) + return; + pad.BringToFront (); + var errorList = pad.Content as ErrorListPad; + errorList?.SelectTaskListEntry (this); + } + public bool BelongsToItem (WorkspaceObject item, bool checkHierarchy) { if (!checkHierarchy) 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 eedf7fc4f8..216dcb47bb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MetadataReferenceCache.cs @@ -163,11 +163,15 @@ namespace MonoDevelop.Ide.TypeSystem timeStamp = File.GetLastWriteTimeUtc (path); if (timeStamp == NonExistentFile) { Reference = null; + LoggingService.LogError ("Error while loading reference " + path + ": File doesn't exist"); } else { - Reference = MetadataReference.CreateFromFile (path, MetadataReferenceProperties.Assembly); + try { + Reference = MetadataReference.CreateFromFile (path, MetadataReferenceProperties.Assembly); + } catch (Exception e) { + LoggingService.LogError ("Error while loading reference " + path + ": " + e.Message, e); + } } } } } -} - +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceText.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceText.cs new file mode 100644 index 0000000000..41f2e00834 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceText.cs @@ -0,0 +1,132 @@ +// +// MonoDevelopSourceText.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2016 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; +using Microsoft.CodeAnalysis; +using System.Linq; +using System.IO; +using MonoDevelop.Core; +using System.Collections.Generic; +using System.Threading; +using System.Reflection; +using MonoDevelop.Ide.Editor; +using MonoDevelop.Core.Text; +using Microsoft.CodeAnalysis.Text; + +namespace MonoDevelop.Ide.TypeSystem +{ + sealed class MonoDevelopSourceText : SourceText + { + readonly ITextSource doc; + TextLineCollectionWrapper wrapper; + + public override System.Text.Encoding Encoding { + get { + return doc.Encoding; + } + } + + public MonoDevelopSourceText (ITextSource doc) + { + if (doc == null) + throw new ArgumentNullException (nameof (doc)); + this.doc = doc; + } + + protected override TextLineCollection GetLinesCore () + { + var textDoc = doc as IReadonlyTextDocument; + if (textDoc != null) { + if (wrapper == null) + wrapper = new TextLineCollectionWrapper (this, textDoc); + return wrapper; + } + return base.GetLinesCore (); + } + + class TextLineCollectionWrapper : TextLineCollection + { + readonly MonoDevelopSourceText parent; + readonly IReadonlyTextDocument textDoc; + + public TextLineCollectionWrapper (MonoDevelopSourceText parent, IReadonlyTextDocument textDoc) + { + this.parent = parent; + this.textDoc = textDoc; + } + + public override int Count { + get { + return textDoc.LineCount; + } + } + + public override TextLine this[int index] { + get { + var line = textDoc.GetLine (index + 1); + return TextLine.FromSpan (parent, new TextSpan(line.Offset, line.Length)); + } + } + + public override TextLine GetLineFromPosition (int position) + { + var line = textDoc.GetLineByOffset (position); + return TextLine.FromSpan (parent, new TextSpan(line.Offset, line.Length)); + } + + public override LinePosition GetLinePosition (int position) + { + var loc = textDoc.OffsetToLocation (position); + return new LinePosition (loc.Line - 1, loc.Column - 1); + } + + public override int IndexOf (int position) + { + return textDoc.OffsetToLineNumber (position) - 1; + } + } + + #region implemented abstract members of SourceText + public override void CopyTo (int sourceIndex, char[] destination, int destinationIndex, int count) + { + doc.CopyTo (sourceIndex, destination, destinationIndex, count); + } + + public override int Length { + get { + return doc.Length; + } + } + + public override char this [int index] { + get { + return doc.GetCharAt (index); + } + } + #endregion + } + +}
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceTextContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceTextContainer.cs index a8eed4fad2..2814a22de7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceTextContainer.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopSourceTextContainer.cs @@ -37,97 +37,6 @@ using Microsoft.CodeAnalysis.Text; namespace MonoDevelop.Ide.TypeSystem { - sealed class MonoDevelopSourceText : SourceText - { - readonly ITextSource doc; - TextLineCollectionWrapper wrapper; - - public override System.Text.Encoding Encoding { - get { - return doc.Encoding; - } - } - - public MonoDevelopSourceText (ITextSource doc) - { - if (doc == null) - throw new ArgumentNullException (nameof (doc)); - this.doc = doc; - } - - protected override TextLineCollection GetLinesCore () - { - var textDoc = doc as IReadonlyTextDocument; - if (textDoc != null) { - if (wrapper == null) - wrapper = new TextLineCollectionWrapper (this, textDoc); - return wrapper; - } - return base.GetLinesCore (); - } - - class TextLineCollectionWrapper : TextLineCollection - { - readonly MonoDevelopSourceText parent; - readonly IReadonlyTextDocument textDoc; - - public TextLineCollectionWrapper (MonoDevelopSourceText parent, IReadonlyTextDocument textDoc) - { - this.parent = parent; - this.textDoc = textDoc; - } - - public override int Count { - get { - return textDoc.LineCount; - } - } - - public override TextLine this[int index] { - get { - var line = textDoc.GetLine (index + 1); - return TextLine.FromSpan (parent, new TextSpan(line.Offset, line.Length)); - } - } - - public override TextLine GetLineFromPosition (int position) - { - var line = textDoc.GetLineByOffset (position); - return TextLine.FromSpan (parent, new TextSpan(line.Offset, line.Length)); - } - - public override LinePosition GetLinePosition (int position) - { - var loc = textDoc.OffsetToLocation (position); - return new LinePosition (loc.Line - 1, loc.Column - 1); - } - - public override int IndexOf (int position) - { - return textDoc.OffsetToLineNumber (position) - 1; - } - } - - #region implemented abstract members of SourceText - public override void CopyTo (int sourceIndex, char[] destination, int destinationIndex, int count) - { - doc.CopyTo (sourceIndex, destination, destinationIndex, count); - } - - public override int Length { - get { - return doc.Length; - } - } - - public override char this [int index] { - get { - return doc.GetCharAt (index); - } - } - #endregion - } - sealed class MonoDevelopSourceTextContainer : SourceTextContainer, IDisposable { readonly ITextDocument document; @@ -148,7 +57,7 @@ namespace MonoDevelop.Ide.TypeSystem { this.document = document; this.document.TextChanging += HandleTextReplacing; - this.document.TextChanged += Document_TextChanged;; + this.document.TextChanged += Document_TextChanged; } void HandleTextReplacing (object sender, Core.Text.TextChangeEventArgs e) @@ -170,6 +79,7 @@ namespace MonoDevelop.Ide.TypeSystem { if (isDisposed) return; + currentText = null; document.TextChanging -= HandleTextReplacing; document.TextChanged -= Document_TextChanged;; isDisposed = true; @@ -178,8 +88,9 @@ namespace MonoDevelop.Ide.TypeSystem #region implemented abstract members of SourceTextContainer public override SourceText CurrentText { get { - if (currentText == null) + if (currentText == null) { currentText = new MonoDevelopSourceText (document.CreateDocumentSnapshot ()); + } return currentText; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTextLoader.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTextLoader.cs index 3d9b16b6a1..4b95fb2c5b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTextLoader.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTextLoader.cs @@ -29,6 +29,8 @@ using System.Threading; using Microsoft.CodeAnalysis.Text; using MonoDevelop.Core.Text; using System.IO; +using System.Linq; +using MonoDevelop.Core; namespace MonoDevelop.Ide.TypeSystem { @@ -45,18 +47,12 @@ namespace MonoDevelop.Ide.TypeSystem async Task<TextAndVersion> GetTextAndVersion (Workspace workspace, DocumentId documentId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested (); - - if (!File.Exists (fileName)) { - var document = ((MonoDevelopWorkspace)workspace).GetDocument (documentId); - if (document == null) - return null; - return TextAndVersion.Create (await document.GetTextAsync (cancellationToken), VersionStamp.Create ()); - } SourceText text; - if (workspace.IsDocumentOpen (documentId)) { + if (IdeApp.Workbench?.Documents.Any (doc => FilePath.PathComparer.Compare (doc.FileName, fileName) == 0) == true) { text = new MonoDevelopSourceText (TextFileProvider.Instance.GetTextEditorData (fileName).CreateDocumentSnapshot ()); - } - else { + } else { + if (!File.Exists (fileName)) + return TextAndVersion.Create (SourceText.From (""), VersionStamp.Create ()); ; text = SourceText.From (await TextFileUtility.GetTextAsync (fileName, cancellationToken)); } return TextAndVersion.Create (text, VersionStamp.Create ()); 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 3eba45019e..14d954da11 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs @@ -294,6 +294,7 @@ namespace MonoDevelop.Ide.TypeSystem { lock (projectIdMap) { ProjectData result; + if (projectDataMap.TryGetValue (id, out result)) { return result; } @@ -526,8 +527,6 @@ namespace MonoDevelop.Ide.TypeSystem var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default; var hashSet = new HashSet<string> (FilePath.PathComparer); - bool addFacadeAssemblies = false; - try { foreach (string file in await netProject.GetReferencedAssemblies (configurationSelector, false).ConfigureAwait (false)) { if (token.IsCancellationRequested) @@ -541,26 +540,18 @@ namespace MonoDevelop.Ide.TypeSystem if (hashSet.Contains (fileName)) continue; hashSet.Add (fileName); - if (!File.Exists (fileName)) + if (!File.Exists (fileName)) { + LoggingService.LogError ("Error while getting referenced Assembly " + fileName + " for project " + netProject.Name + ": File doesn't exist"); continue; - result.Add (MetadataReferenceCache.LoadReference (projectId, fileName)); - addFacadeAssemblies |= MonoDevelop.Core.Assemblies.SystemAssemblyService.ContainsReferenceToSystemRuntime (fileName); + } + var metadataReference = MetadataReferenceCache.LoadReference (projectId, fileName); + if (metadataReference == null) + continue; + result.Add (metadataReference); } } catch (Exception e) { LoggingService.LogError ("Error while getting referenced assemblies", e); } - // HACK: Facade assemblies should be added by the project system. Remove that when the project system can do that. - if (addFacadeAssemblies) { - if (netProject != null) { - var runtime = netProject.TargetRuntime ?? MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime; - var facades = runtime.FindFacadeAssembliesForPCL (netProject.TargetFramework); - foreach (var facade in facades) { - if (!File.Exists (facade)) - continue; - result.Add (MetadataReferenceCache.LoadReference (projectId, facade)); - } - } - } foreach (var pr in netProject.GetReferencedItems (configurationSelector)) { if (token.IsCancellationRequested) @@ -570,9 +561,13 @@ namespace MonoDevelop.Ide.TypeSystem continue; if (TypeSystemService.IsOutputTrackedProject (referencedProject)) { var fileName = referencedProject.GetOutputFileName (configurationSelector); - if (!File.Exists (fileName)) + if (!File.Exists (fileName)) { + LoggingService.LogError ("Error while getting project Reference (" + referencedProject.Name + ") " + fileName + " for project " + netProject.Name + ": File doesn't exist"); continue; - result.Add (MetadataReferenceCache.LoadReference (projectId, fileName)); + } + var metadataReference = MetadataReferenceCache.LoadReference (projectId, fileName); + if (metadataReference != null) + result.Add (metadataReference); } } return result; @@ -608,7 +603,7 @@ namespace MonoDevelop.Ide.TypeSystem } Document InternalInformDocumentOpen (DocumentId documentId, ITextDocument editor) - {
+ { var document = this.GetDocument (documentId); if (document == null || IsDocumentOpen (documentId)) { return document; @@ -1062,4 +1057,4 @@ namespace MonoDevelop.Ide.TypeSystem // } // } -}
\ No newline at end of file +} 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 94208220a0..5ff022e63d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/StockIcons.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/StockIcons.cs @@ -66,8 +66,12 @@ namespace MonoDevelop.Ide.TypeSystem switch (symbol.Kind) { case Microsoft.CodeAnalysis.SymbolKind.NamedType: return ""; - case Microsoft.CodeAnalysis.SymbolKind.Event: case Microsoft.CodeAnalysis.SymbolKind.Field: + var field = (IFieldSymbol)symbol; + if (field.IsConst) + return ""; + return symbol.IsStatic ? "static-" : ""; + case Microsoft.CodeAnalysis.SymbolKind.Event: case Microsoft.CodeAnalysis.SymbolKind.Method: case Microsoft.CodeAnalysis.SymbolKind.Property: return symbol.IsStatic ? "static-" : ""; @@ -85,15 +89,25 @@ namespace MonoDevelop.Ide.TypeSystem case Microsoft.CodeAnalysis.SymbolKind.DynamicType: case Microsoft.CodeAnalysis.SymbolKind.ErrorType: case Microsoft.CodeAnalysis.SymbolKind.Label: - case Microsoft.CodeAnalysis.SymbolKind.Local: + case Microsoft.CodeAnalysis.SymbolKind.NetModule: case Microsoft.CodeAnalysis.SymbolKind.PointerType: - case Microsoft.CodeAnalysis.SymbolKind.Field: - case Microsoft.CodeAnalysis.SymbolKind.Parameter: case Microsoft.CodeAnalysis.SymbolKind.RangeVariable: case Microsoft.CodeAnalysis.SymbolKind.TypeParameter: case Microsoft.CodeAnalysis.SymbolKind.Preprocessing: return "field"; + case Microsoft.CodeAnalysis.SymbolKind.Parameter: + return "variable"; + case Microsoft.CodeAnalysis.SymbolKind.Field: + var field = (IFieldSymbol)symbol; + if (field.IsConst) + return "literal"; + return "field"; + case Microsoft.CodeAnalysis.SymbolKind.Local: + var local = (ILocalSymbol)symbol; + if (local.IsConst) + return "literal"; + return "variable"; case Microsoft.CodeAnalysis.SymbolKind.NamedType: var namedTypeSymbol = (Microsoft.CodeAnalysis.INamedTypeSymbol)symbol; switch (namedTypeSymbol.TypeKind) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index ac752e1c15..b8ecdbe4b5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -7720,6 +7720,8 @@ <Compile Include="MonoDevelop.Components\ButtonEvent.cs" /> <Compile Include="MonoDevelop.Components\Window.cs" /> <Compile Include="MonoDevelop.Components\Dialog.cs" /> + <Compile Include="MonoDevelop.Ide.TypeSystem\MonoDevelopSourceText.cs" /> + <Compile Include="MonoDevelop.Components.AutoTest\DataTransferObjects.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs index 08ad6c4daf..d0dda71c02 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs @@ -258,7 +258,8 @@ namespace MonoDevelop.Ide } errorsList = null; - + AddinManager.AddinLoadError -= OnAddinError; + // FIXME: we should probably track the last 'selected' one // and do this more cleanly try { @@ -290,7 +291,6 @@ namespace MonoDevelop.Ide IdeApp.Customizer.OnCoreShutdown (); InstrumentationService.Stop (); - AddinManager.AddinLoadError -= OnAddinError; return 0; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs index e19ee14d2f..07674bf7cc 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/MessageService.cs @@ -34,6 +34,7 @@ using MonoDevelop.Components; using MonoDevelop.Core; using MonoDevelop.Components.Extensions; using MonoDevelop.Ide.Gui; +using System.Threading.Tasks; #if MAC using AppKit; @@ -505,6 +506,40 @@ namespace MonoDevelop.Ide { return messageService.GenericAlert (parent, message); } + + public static async Task<T> ExecuteTaskAndShowWaitDialog<T> (Task<T> task, string waitMessage, CancellationTokenSource cts) + { + bool taskFinished = false; + var dontExitMethodUntilDialogClosed = new TaskCompletionSource<bool> (); + var delayTask = Task.Delay (1000);//Don't show wait dialog immediately, wait 1 sec before showing + var finishedTask = await Task.WhenAny (delayTask, task).ConfigureAwait (false); + if (finishedTask == task)//If task finished before delayTask, great return value and never display dialog + return task.Result; + //cancelDialog is used to close dialog when task is finished + var cancelDialog = new CancellationTokenSource (); + Gtk.Application.Invoke (delegate { + if (cancelDialog.Token.IsCancellationRequested) + return; + var gm = new GenericMessage (waitMessage, null, cancelDialog.Token); + gm.Buttons.Add (AlertButton.Cancel); + gm.DefaultButton = 0; + GenericAlert (gm); + dontExitMethodUntilDialogClosed.SetResult (true); + if (!taskFinished) { + //Don't cancel if task finished already, we closed dialog via cancelDialog.Cancel (); + //caller of this method might reuse this cts for other tasks + cts.Cancel (); + } + }); + try { + await task.ConfigureAwait (false); + } finally { + taskFinished = true; + cancelDialog.Cancel (); + } + await dontExitMethodUntilDialogClosed.Task.ConfigureAwait (false); + return task.Result; + } public static string GetTextResponse (string question, string caption, string initialValue) { diff --git a/main/tests/UnitTests/MonoDevelop.Ide.Gui/CompletionListWindowTests.cs b/main/tests/UnitTests/MonoDevelop.Ide.Gui/CompletionListWindowTests.cs index 05164f5f47..3b326ae2f2 100644 --- a/main/tests/UnitTests/MonoDevelop.Ide.Gui/CompletionListWindowTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Ide.Gui/CompletionListWindowTests.cs @@ -954,6 +954,16 @@ namespace MonoDevelop.Ide.Gui Assert.AreEqual ("foo", output); } + /// <summary> + /// Bug 37985 - Code completion is selecting 'int32' instead of letting me type '2' + /// </summary> + [Test] + public void TestBug37985 () + { + var output = RunSimulation ("", "3\t", false, false, false, new [] { "Int32" } ); + Assert.AreEqual (null, output); + } + [TestFixtureSetUp] public void SetUp() diff --git a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs index 60aac3a4a0..44dd2ff514 100644 --- a/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Projects/MSBuildTests.cs @@ -1526,6 +1526,27 @@ namespace MonoDevelop.Projects var refXml = File.ReadAllText (p.FileName.ChangeName ("project-with-duplicated-conf-saved")); Assert.AreEqual (refXml, savedXml); } + + [Test] + public async Task ConditionedHintPath () + { + // A reference with several hint paths with conditions. Only the hint path with the true condition + // will be used + + string projFile = Util.GetSampleProject ("msbuild-tests", "conditioned-hintpath.csproj"); + var p = (DotNetProject)await Services.ProjectService.ReadSolutionItem (Util.GetMonitor (), projFile); + + Assert.AreEqual (2, p.References.Count); + + Assert.AreEqual (p.ItemDirectory.Combine ("a.dll").ToString (), p.References[0].HintPath.ToString ()); + Assert.AreEqual (p.ItemDirectory.Combine ("b.dll").ToString (), p.References[1].HintPath.ToString ()); + + var refXml = File.ReadAllText (p.FileName); + await p.SaveAsync (Util.GetMonitor ()); + + var savedXml = File.ReadAllText (p.FileName); + Assert.AreEqual (refXml, savedXml); + } } class MyProjectTypeNode: ProjectTypeNode diff --git a/main/tests/test-projects/msbuild-tests/conditioned-hintpath.csproj b/main/tests/test-projects/msbuild-tests/conditioned-hintpath.csproj new file mode 100755 index 0000000000..f9d94b1f9b --- /dev/null +++ b/main/tests/test-projects/msbuild-tests/conditioned-hintpath.csproj @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProjectGuid>{94F1D011-147F-43F6-9070-F95E5D4D36CB}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>borra104</RootNamespace> + <AssemblyName>borra104</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <Foo>Bar</Foo> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ExternalConsole>true</ExternalConsole> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ExternalConsole>true</ExternalConsole> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <ItemGroup> + <Reference Include="Test1"> + <HintPath Condition=" '$(Foo)' == 'Bar' ">a.dll</HintPath> + <HintPath Condition=" '$(Foo)' != 'Bar' ">b.dll</HintPath> + </Reference> + <Reference Include="Test2"> + <HintPath Condition=" '$(Foo)' != 'Bar' ">a.dll</HintPath> + <HintPath Condition=" '$(Foo)' == 'Bar' ">b.dll</HintPath> + </Reference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file |