diff --git a/src/Libraries/NRefactory/Project/Src/OperatorPrecedence.cs b/src/Libraries/NRefactory/Project/Src/OperatorPrecedence.cs index a6df6178bc..7487e7ef57 100644 --- a/src/Libraries/NRefactory/Project/Src/OperatorPrecedence.cs +++ b/src/Libraries/NRefactory/Project/Src/OperatorPrecedence.cs @@ -73,8 +73,8 @@ namespace ICSharpCode.NRefactory public static int ComparePrecedenceCSharp(BinaryOperatorType op1, BinaryOperatorType op2) { - int p1 = GetOperatorPrecedence(vbDict, op1); - int p2 = GetOperatorPrecedence(vbDict, op2); + int p1 = GetOperatorPrecedence(csharpDict, op1); + int p2 = GetOperatorPrecedence(csharpDict, op2); return p1.CompareTo(p2); } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/DerivedTypesNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/DerivedTypesNode.cs index 0d955cbaf2..978c46af52 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/DerivedTypesNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/DerivedTypesNode.cs @@ -57,19 +57,18 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser base.Initialize(); Nodes.Clear(); - List contentList = new List(1); - contentList.Add(null); + List contentList = new List(); if (ProjectService.OpenSolution != null) { foreach (IProject project in ProjectService.OpenSolution.Projects) { IProjectContent projectContent = ParserService.GetProjectContent(project); if (projectContent != null) { - contentList[0] = projectContent; - foreach (IClass derivedClass in RefactoringService.FindDerivedClasses(c, contentList, true)) { - new ClassNode(project, derivedClass).AddTo(this); - } + contentList.Add(projectContent); } } } + foreach (IClass derivedClass in RefactoringService.FindDerivedClasses(c, contentList, true)) { + new ClassNode(project, derivedClass).AddTo(this); + } if (Nodes.Count == 0) { SetIcon(ClosedIcon); diff --git a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs index 6c1e0e2b17..2334df0f96 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs @@ -329,7 +329,14 @@ namespace ICSharpCode.SharpDevelop.Gui public void ShowView(IViewContent content, bool switchToOpenedView) { - System.Diagnostics.Debug.Assert(layout != null); + if (content == null) + throw new ArgumentNullException("content"); + if (content.WorkbenchWindow != null) + throw new ArgumentException("Cannot show view content that is already visible in another workbench window"); + + if (layout == null) + throw new InvalidOperationException("No layout is attached."); + primaryViewContentCollection.Add(content); if (PropertyService.Get("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) { try { diff --git a/src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs b/src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs index 3381a4f8ab..7ab26f8edc 100644 --- a/src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs +++ b/src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.SharpDevelop /// This class handles the installed display bindings /// and provides a simple access point to these bindings. /// - internal static class DisplayBindingService + public static class DisplayBindingService { const string displayBindingPath = "/SharpDevelop/Workbench/DisplayBindings"; @@ -39,6 +39,7 @@ namespace ICSharpCode.SharpDevelop public static DisplayBindingDescriptor AddExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding) { + WorkbenchSingleton.AssertMainThread(); if (binding == null) throw new ArgumentNullException("binding"); DisplayBindingDescriptor descriptor = AddExternalProcessDisplayBindingInternal(binding); @@ -64,6 +65,7 @@ namespace ICSharpCode.SharpDevelop public static void RemoveExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding) { + WorkbenchSingleton.AssertMainThread(); if (binding == null) throw new ArgumentNullException("binding"); if (!externalProcessDisplayBindings.Remove(binding)) @@ -83,6 +85,7 @@ namespace ICSharpCode.SharpDevelop /// public static IDisplayBinding GetBindingPerFileName(string filename) { + WorkbenchSingleton.AssertMainThread(); DisplayBindingDescriptor codon = GetDefaultCodonPerFileName(filename); return codon == null ? null : codon.Binding; } @@ -92,6 +95,8 @@ namespace ICSharpCode.SharpDevelop /// public static DisplayBindingDescriptor GetDefaultCodonPerFileName(string filename) { + WorkbenchSingleton.AssertMainThread(); + string defaultCommandID = displayBindingServiceProperties.Get("Default" + Path.GetExtension(filename).ToLowerInvariant()) as string; if (!string.IsNullOrEmpty(defaultCommandID)) { foreach (DisplayBindingDescriptor binding in bindings) { @@ -113,11 +118,12 @@ namespace ICSharpCode.SharpDevelop public static void SetDefaultCodon(string extension, DisplayBindingDescriptor bindingDescriptor) { + WorkbenchSingleton.AssertMainThread(); if (bindingDescriptor == null) throw new ArgumentNullException("bindingDescriptor"); if (extension == null) throw new ArgumentNullException("extension"); - if (!extension.StartsWith(".")) + if (!extension.StartsWith(".", StringComparison.Ordinal)) throw new ArgumentException("extension must start with '.'"); displayBindingServiceProperties.Set("Default" + extension.ToLowerInvariant(), bindingDescriptor.Id); @@ -128,6 +134,8 @@ namespace ICSharpCode.SharpDevelop /// public static IList GetCodonsPerFileName(string filename) { + WorkbenchSingleton.AssertMainThread(); + List list = new List(); foreach (DisplayBindingDescriptor binding in bindings) { if (IsPrimaryBindingValidForFileName(binding, filename)) { @@ -154,6 +162,10 @@ namespace ICSharpCode.SharpDevelop /// This is a reattaching pass public static void AttachSubWindows(IViewContent viewContent, bool isReattaching) { + WorkbenchSingleton.AssertMainThread(); + if (viewContent == null) + throw new ArgumentNullException("viewContent"); + foreach (DisplayBindingDescriptor binding in bindings) { if (binding.IsSecondary && binding.CanOpenFile(viewContent.PrimaryFileName)) { ISecondaryDisplayBinding displayBinding = binding.SecondaryBinding; diff --git a/src/Main/Base/Project/Src/Services/DisplayBinding/ExternalProcessDisplayBinding.cs b/src/Main/Base/Project/Src/Services/DisplayBinding/ExternalProcessDisplayBinding.cs index b0763a7aeb..c80fe9e402 100644 --- a/src/Main/Base/Project/Src/Services/DisplayBinding/ExternalProcessDisplayBinding.cs +++ b/src/Main/Base/Project/Src/Services/DisplayBinding/ExternalProcessDisplayBinding.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.SharpDevelop /// Display binding for opening a file in an external process. /// [TypeConverter(typeof(ExternalProcessDisplayBindingConverter))] - sealed class ExternalProcessDisplayBinding : IDisplayBinding + public sealed class ExternalProcessDisplayBinding : IDisplayBinding { public string FileExtension { get; set; } public string CommandLine { get; set; } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs index 49825f14d8..1cf343b323 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs @@ -159,7 +159,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring progressMonitor.BeginTask("${res:SharpDevelop.Refactoring.FindingReferences}", files.Count, true); } #if DEBUG - if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Control) { + if (System.Windows.Forms.Control.ModifierKeys == DefaultEditor.Gui.Editor.SharpDevelopTextAreaControl.DebugBreakModifiers) { System.Diagnostics.Debugger.Break(); } #endif diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs index 2573c5cd07..3b76322fb7 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionDataProvider.cs @@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } #if DEBUG - public bool DebugMode = false; + internal bool DebugMode = false; #endif protected void GenerateCompletionData(TextArea textArea, ExpressionResult expressionResult) diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs index 9e8a535948..b39da24834 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs @@ -208,11 +208,15 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } + #if DEBUG + internal const Keys DebugBreakModifiers = Keys.Control | Keys.Shift | Keys.Alt; + #endif + void GenerateEditActions() { #if DEBUG - editactions[Keys.Control | Keys.OemPeriod] = new DebugDotCompletionAction(); - editactions[Keys.Control | Keys.Shift | Keys.Space] = new DebugCtrlSpaceCodeCompletionAction(); + editactions[DebugBreakModifiers | Keys.OemPeriod] = new DebugDotCompletionAction(); + editactions[DebugBreakModifiers | Keys.Space] = new DebugCtrlSpaceCodeCompletionAction(); #endif try { IEditAction[] actions = (IEditAction[])(AddInTree.GetTreeNode(editActionsPath).BuildChildItems(this)).ToArray(typeof(IEditAction));