From 0c9ebf6dc21ddebfd573db8e4cf02436bfca0f18 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 9 Sep 2005 17:56:46 +0000 Subject: [PATCH] Reduced number of allocations: - do not load xml documentation keys into memory but load only the hash code and keep everything else cached on disk. - made Dom's region a value-type. - do not create a SortedList for every using statement but only when the using statements actually uses aliases. Overall SD should use ca. 10 MB RAM less when working on a big solution like SharpDevelop.sln. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@468 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/CSharpCompletionBinding.cs | 2 +- .../CSharpFormattingStrategy.cs | 4 +- .../Project/Src/Parser/Parser.cs | 6 +- .../Project/Src/MyNamespaceBuilder.cs | 12 +- .../VBNetBinding/Project/Src/Parser/Parser.cs | 6 +- .../Project/Configuration/AssemblyInfo.cs | 2 +- .../Project/ICSharpCode.SharpDevelop.csproj | 3 +- .../Base/Project/Src/Dom/FoldingRegion.cs | 6 +- src/Main/Base/Project/Src/Dom/IClass.cs | 2 +- src/Main/Base/Project/Src/Dom/IComment.cs | 2 +- src/Main/Base/Project/Src/Dom/IEvent.cs | 2 +- src/Main/Base/Project/Src/Dom/IMember.cs | 2 +- src/Main/Base/Project/Src/Dom/IMethod.cs | 2 +- src/Main/Base/Project/Src/Dom/IParameter.cs | 2 +- src/Main/Base/Project/Src/Dom/IProperty.cs | 4 +- src/Main/Base/Project/Src/Dom/IRegion.cs | 34 ----- src/Main/Base/Project/Src/Dom/IUsing.cs | 15 ++- .../Src/Dom/Implementations/AbstractMember.cs | 6 +- .../Dom/Implementations/ArrayReturnType.cs | 4 +- .../Src/Dom/Implementations/DefaultClass.cs | 8 +- .../Src/Dom/Implementations/DefaultComment.cs | 6 +- .../Implementations/DefaultCompilationUnit.cs | 6 +- .../Src/Dom/Implementations/DefaultEvent.cs | 6 +- .../Src/Dom/Implementations/DefaultField.cs | 2 +- .../Src/Dom/Implementations/DefaultMethod.cs | 12 +- .../Dom/Implementations/DefaultParameter.cs | 6 +- .../Dom/Implementations/DefaultProperty.cs | 18 +-- .../Src/Dom/Implementations/DefaultUsing.cs | 90 ++++++++----- .../NRefactoryASTConvertVisitor.cs | 54 ++++---- .../NRefactoryResolver/NRefactoryResolver.cs | 22 +-- .../Dom/ReflectionLayer/ReflectionClass.cs | 100 +++++++++----- .../Dom/ReflectionLayer/ReflectionProperty.cs | 8 +- .../DefaultRegion.cs => Region.cs} | 77 ++++++----- .../Base/Project/Src/Dom/ResolveResult.cs | 16 +-- src/Main/Base/Project/Src/Dom/Tag.cs | 8 +- src/Main/Base/Project/Src/Dom/XmlDoc.cs | 126 ++++++++++++------ .../Gui/Pads/ClassBrowser/Nodes/ClassNode.cs | 4 +- .../Gui/Pads/ClassBrowser/Nodes/MemberNode.cs | 6 +- .../Src/Gui/Pads/PropertyPad/PropertyPad.cs | 34 ++--- .../AmbienceReflectionDecorator.cs | 2 +- .../ParserService/DefaultProjectContent.cs | 4 +- .../Services/ParserService/ParserService.cs | 6 + .../ParserService/ReflectionProjectContent.cs | 7 +- .../RefactoringMenuBuilder.cs | 8 +- .../Commands/ClassBookmarkMenuBuilder.cs | 2 +- .../Commands/ClassMemberMenuBuilder.cs | 2 +- .../Commands/ParserBookmarkMenuBuilderBase.cs | 4 +- .../Src/TextEditor/Gui/Dialogs/GotoDialog.cs | 4 +- .../CommentCompletionDataProvider.cs | 2 +- .../Gui/Editor/ParserFoldingStrategy.cs | 10 +- .../Gui/Editor/QuickClassBrowserPanel.cs | 20 +-- .../Gui/Editor/TextEditorDisplayBinding.cs | 10 +- src/Main/Base/Test/ReflectionLayerTests.cs | 6 +- 53 files changed, 441 insertions(+), 371 deletions(-) delete mode 100644 src/Main/Base/Project/Src/Dom/IRegion.cs rename src/Main/Base/Project/Src/Dom/{Implementations/DefaultRegion.cs => Region.cs} (68%) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpCompletionBinding.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpCompletionBinding.cs index 7619b770a7..0b50e57bab 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpCompletionBinding.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpCompletionBinding.cs @@ -106,7 +106,7 @@ namespace CSharpBinding ResolveResult resolveResult = ParserService.Resolve(result, editor.ActiveTextAreaControl.Caret.Line, editor.ActiveTextAreaControl.Caret.Column, editor.FileName, documentText); if (resolveResult != null && resolveResult.ResolvedType != null) { IClass underlyingClass = resolveResult.ResolvedType.GetUnderlyingClass(); - if (underlyingClass.IsTypeInInheritanceTree(ProjectContentRegistry.Mscorlib.GetClass("System.MulticastDelegate"))) { + if (underlyingClass != null && underlyingClass.IsTypeInInheritanceTree(ProjectContentRegistry.Mscorlib.GetClass("System.MulticastDelegate"))) { EventHandlerCompletitionDataProvider eventHandlerProvider = new EventHandlerCompletitionDataProvider(result.Expression, resolveResult); eventHandlerProvider.InsertSpace = true; editor.ShowCompletionWindow(eventHandlerProvider, ch); diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs index 5cab44f689..89a7a9e61d 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs @@ -233,9 +233,9 @@ namespace CSharpBinding.FormattingStrategy - bool IsBeforeRegion(TextArea textArea, IRegion region, int lineNr) + bool IsBeforeRegion(TextArea textArea, DomRegion region, int lineNr) { - if (region == null) { + if (region.IsEmpty) { return false; } return region.BeginLine - 2 <= lineNr && lineNr <= region.BeginLine; diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs index 710f5ec027..429b2b32e4 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -64,7 +64,7 @@ namespace CSharpBinding.Parser case "#endregion": --deep; if (deep == 0) { - cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim(), new DefaultRegion(directive.StartPosition, nextDirective.EndPosition))); + cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim(), new DomRegion(directive.StartPosition, nextDirective.EndPosition))); goto end; } break; @@ -111,7 +111,7 @@ namespace CSharpBinding.Parser void AddCommentTags(ICompilationUnit cu, System.Collections.Generic.List tagComments) { foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in tagComments) { - DefaultRegion tagRegion = new DefaultRegion(tagComment.StartPosition.Y, tagComment.StartPosition.X); + DomRegion tagRegion = new DomRegion(tagComment.StartPosition.Y, tagComment.StartPosition.X); ICSharpCode.SharpDevelop.Dom.Tag tag = new ICSharpCode.SharpDevelop.Dom.Tag(tagComment.Tag, tagRegion); tag.CommentString = tagComment.CommentText; cu.TagComments.Add(tag); diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs index 3ca28c64d1..40629f65e6 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -49,21 +49,21 @@ namespace VBNetBinding c.Properties.Add(new DefaultProperty("Application", new GetClassReturnType(pc, myApp.FullyQualifiedName), ModifierEnum.Public | ModifierEnum.Static, - null, null, c)); + DomRegion.Empty, DomRegion.Empty, c)); c.Properties.Add(new DefaultProperty("Computer", new GetClassReturnType(pc, myComp.FullyQualifiedName), ModifierEnum.Public | ModifierEnum.Static, - null, null, c)); + DomRegion.Empty, DomRegion.Empty, c)); if (myForms != null) { c.Properties.Add(new DefaultProperty("Forms", new GetClassReturnType(pc, myForms.FullyQualifiedName), ModifierEnum.Public | ModifierEnum.Static, - null, null, c)); + DomRegion.Empty, DomRegion.Empty, c)); } c.Properties.Add(new DefaultProperty("User", new GetClassReturnType(pc, "Microsoft.VisualBasic.ApplicationServices.User"), ModifierEnum.Public | ModifierEnum.Static, - null, null, c)); + DomRegion.Empty, DomRegion.Empty, c)); cu.Classes.Add(c); pc.UpdateCompilationUnit(null, cu, cu.FileName, false); } @@ -130,7 +130,7 @@ namespace VBNetBinding properties.Add(new DefaultProperty(c.Name, new GetClassReturnType(this.ProjectContent, c.FullyQualifiedName), ModifierEnum.Public | ModifierEnum.Static, - null, null, c)); + DomRegion.Empty, DomRegion.Empty, c)); } } return properties; diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs index e89d9b83bd..03d72bfd2b 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -74,7 +74,7 @@ namespace VBNetBinding.Parser if (nextDirective.Arg.ToLower() == "region") { --deep; if (deep == 0) { - cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim('"'), new DefaultRegion(directive.StartPosition, nextDirective.EndPosition))); + cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim('"'), new DomRegion(directive.StartPosition, nextDirective.EndPosition))); goto end; } } @@ -134,7 +134,7 @@ namespace VBNetBinding.Parser { foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in tagComments) { - DefaultRegion tagRegion = new DefaultRegion(tagComment.StartPosition.Y, tagComment.StartPosition.X); + DomRegion tagRegion = new DomRegion(tagComment.StartPosition.Y, tagComment.StartPosition.X); ICSharpCode.SharpDevelop.Dom.Tag tag = new ICSharpCode.SharpDevelop.Dom.Tag(tagComment.Tag, tagRegion); tag.CommentString = tagComment.CommentText; cu.TagComments.Add(tag); diff --git a/src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs b/src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs index f5ea869f4c..53cb433b51 100644 --- a/src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs +++ b/src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs @@ -31,7 +31,7 @@ using System.Runtime.CompilerServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly: AssemblyVersion("2.0.0.3")] +[assembly: AssemblyVersion("2.0.0.1")] // The following attributes specify the key for the sign of your assembly. See the // .NET Framework documentation for more information about signing. diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index f3379f22e1..aa380a5f22 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -74,7 +74,7 @@ - + @@ -82,7 +82,6 @@ - diff --git a/src/Main/Base/Project/Src/Dom/FoldingRegion.cs b/src/Main/Base/Project/Src/Dom/FoldingRegion.cs index f594d053b5..55160e32ec 100644 --- a/src/Main/Base/Project/Src/Dom/FoldingRegion.cs +++ b/src/Main/Base/Project/Src/Dom/FoldingRegion.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom public class FoldingRegion { string name; - IRegion region; + DomRegion region; public string Name { get { @@ -23,13 +23,13 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public IRegion Region { + public DomRegion Region { get { return region; } } - public FoldingRegion(string name, IRegion region) + public FoldingRegion(string name, DomRegion region) { this.name = name; this.region = region; diff --git a/src/Main/Base/Project/Src/Dom/IClass.cs b/src/Main/Base/Project/Src/Dom/IClass.cs index e9b0fbe69b..aa96178ecc 100644 --- a/src/Main/Base/Project/Src/Dom/IClass.cs +++ b/src/Main/Base/Project/Src/Dom/IClass.cs @@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Dom get; } - IRegion Region { + DomRegion Region { get; } diff --git a/src/Main/Base/Project/Src/Dom/IComment.cs b/src/Main/Base/Project/Src/Dom/IComment.cs index 53d97bcb8e..ab58ed7886 100644 --- a/src/Main/Base/Project/Src/Dom/IComment.cs +++ b/src/Main/Base/Project/Src/Dom/IComment.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom get; } - IRegion Region { + DomRegion Region { get; } } diff --git a/src/Main/Base/Project/Src/Dom/IEvent.cs b/src/Main/Base/Project/Src/Dom/IEvent.cs index 2a59525269..5e942ad7e4 100644 --- a/src/Main/Base/Project/Src/Dom/IEvent.cs +++ b/src/Main/Base/Project/Src/Dom/IEvent.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom { public interface IEvent : IMember { - IRegion BodyRegion { + DomRegion BodyRegion { get; } diff --git a/src/Main/Base/Project/Src/Dom/IMember.cs b/src/Main/Base/Project/Src/Dom/IMember.cs index ae1f8c0f10..d02a58dd1d 100644 --- a/src/Main/Base/Project/Src/Dom/IMember.cs +++ b/src/Main/Base/Project/Src/Dom/IMember.cs @@ -16,7 +16,7 @@ namespace ICSharpCode.SharpDevelop.Dom get; } - IRegion Region { + DomRegion Region { get; } diff --git a/src/Main/Base/Project/Src/Dom/IMethod.cs b/src/Main/Base/Project/Src/Dom/IMethod.cs index 02bf800ea1..d52a92bc03 100644 --- a/src/Main/Base/Project/Src/Dom/IMethod.cs +++ b/src/Main/Base/Project/Src/Dom/IMethod.cs @@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom { public interface IMethodOrProperty : IMember { - IRegion BodyRegion { + DomRegion BodyRegion { get; } diff --git a/src/Main/Base/Project/Src/Dom/IParameter.cs b/src/Main/Base/Project/Src/Dom/IParameter.cs index 5a476210b6..a00475efc4 100644 --- a/src/Main/Base/Project/Src/Dom/IParameter.cs +++ b/src/Main/Base/Project/Src/Dom/IParameter.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Dom get; } - IRegion Region { + DomRegion Region { get; } diff --git a/src/Main/Base/Project/Src/Dom/IProperty.cs b/src/Main/Base/Project/Src/Dom/IProperty.cs index 2b14cdcd9e..031bfcfdc1 100644 --- a/src/Main/Base/Project/Src/Dom/IProperty.cs +++ b/src/Main/Base/Project/Src/Dom/IProperty.cs @@ -13,11 +13,11 @@ namespace ICSharpCode.SharpDevelop.Dom { public interface IProperty : IMethodOrProperty { - IRegion GetterRegion { + DomRegion GetterRegion { get; } - IRegion SetterRegion { + DomRegion SetterRegion { get; } diff --git a/src/Main/Base/Project/Src/Dom/IRegion.cs b/src/Main/Base/Project/Src/Dom/IRegion.cs deleted file mode 100644 index 2d7cc2eda3..0000000000 --- a/src/Main/Base/Project/Src/Dom/IRegion.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -// 2002-2005 AlphaSierraPapa -// GNU General Public License -// -// $Revision$ -// - -using System; - -namespace ICSharpCode.SharpDevelop.Dom -{ - public interface IRegion: IComparable - { - int BeginLine { - get; - } - - int BeginColumn { - get; - } - - int EndColumn { - get; - set; - } - - int EndLine { - get; - set; - } - - bool IsInside(int row, int column); - } -} diff --git a/src/Main/Base/Project/Src/Dom/IUsing.cs b/src/Main/Base/Project/Src/Dom/IUsing.cs index 704ec0fbf6..57bc059ce7 100644 --- a/src/Main/Base/Project/Src/Dom/IUsing.cs +++ b/src/Main/Base/Project/Src/Dom/IUsing.cs @@ -12,18 +12,25 @@ namespace ICSharpCode.SharpDevelop.Dom { public interface IUsing { - IRegion Region { + DomRegion Region { get; } - + List Usings { get; } - + + bool HasAliases { get; } + + void AddAlias(string alias, IReturnType type); + + /// + /// Gets the list of aliases. Can be null when there are no aliases! + /// SortedList Aliases { get; } - + IReturnType SearchType(string partitialTypeName); string SearchNamespace(string partitialNamespaceName); } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs index 44e2d232b3..3a9a1cb205 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -13,9 +13,9 @@ namespace ICSharpCode.SharpDevelop.Dom public abstract class AbstractMember : AbstractNamedEntity, IMember { IReturnType returnType; - IRegion region; + DomRegion region; - public virtual IRegion Region { + public virtual DomRegion Region { get { return region; } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/ArrayReturnType.cs b/src/Main/Base/Project/Src/Dom/Implementations/ArrayReturnType.cs index f043881e9c..3a8312406b 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/ArrayReturnType.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/ArrayReturnType.cs @@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Dom public class ArrayIndexer : DefaultProperty { public ArrayIndexer(IReturnType elementType) - : base("Indexer", elementType, ModifierEnum.Public, null, null, ReflectionReturnType.Array.GetUnderlyingClass()) + : base("Indexer", elementType, ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, ReflectionReturnType.Array.GetUnderlyingClass()) { IsIndexer = true; } @@ -80,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.Dom List l = base.GetProperties(); ArrayIndexer property = new ArrayIndexer(elementType); for (int i = 0; i < dimensions; ++i) { - property.Parameters.Add(new DefaultParameter("index", ReflectionReturnType.Int, null)); + property.Parameters.Add(new DefaultParameter("index", ReflectionReturnType.Int, DomRegion.Empty)); } l.Add(property); return l; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs index 8ae9f4aa10..71c6f72644 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.SharpDevelop.Dom public class DefaultClass : AbstractNamedEntity, IClass, IComparable { ClassType classType; - IRegion region; + DomRegion region; ICompilationUnit compilationUnit; @@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Dom this.compilationUnit = compilationUnit; } - public DefaultClass(ICompilationUnit compilationUnit, ClassType classType, ModifierEnum modifiers, IRegion region, IClass declaringType) : base(declaringType) + public DefaultClass(ICompilationUnit compilationUnit, ClassType classType, ModifierEnum modifiers, DomRegion region, IClass declaringType) : base(declaringType) { this.compilationUnit = compilationUnit; this.region = region; @@ -102,7 +102,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public IRegion Region { + public DomRegion Region { get { return region; } @@ -362,7 +362,7 @@ namespace ICSharpCode.SharpDevelop.Dom public IClass GetInnermostClass(int caretLine, int caretColumn) { foreach (IClass c in InnerClasses) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + if (c != null && c.Region.IsInside(caretLine, caretColumn)) { return c.GetInnermostClass(caretLine, caretColumn); } } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultComment.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultComment.cs index 7d573ce56a..6682bd4e10 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultComment.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultComment.cs @@ -16,9 +16,9 @@ namespace ICSharpCode.SharpDevelop.Dom { bool isBlockComment; string commentTag; string commentText; - IRegion region; + DomRegion region; - public DefaultComment(bool isBlockComment, string commentTag, string commentText, IRegion region) + public DefaultComment(bool isBlockComment, string commentTag, string commentText, DomRegion region) { this.isBlockComment = isBlockComment; this.commentTag = commentTag; @@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } } - public IRegion Region { + public DomRegion Region { get { return region; } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultCompilationUnit.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultCompilationUnit.cs index 2b110a51cf..d1835d90d1 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultCompilationUnit.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultCompilationUnit.cs @@ -113,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Dom public IClass GetInnermostClass(int caretLine, int caretColumn) { foreach (IClass c in Classes) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + if (c != null && c.Region.IsInside(caretLine, caretColumn)) { return c.GetInnermostClass(caretLine, caretColumn); } } @@ -133,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.Dom List classes = new List(); IClass innerMostClass = GetInnermostClass(caretLine, caretColumn); foreach (IClass c in Classes) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + if (c != null && c.Region.IsInside(caretLine, caretColumn)) { if (c != innerMostClass) { GetOuterClasses(classes, c, caretLine, caretColumn); if (!classes.Contains(c)) { @@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.Dom if (curClass != null && curClass.InnerClasses.Count > 0) { IClass innerMostClass = GetInnermostClass(caretLine, caretColumn); foreach (IClass c in curClass.InnerClasses) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + if (c != null && c.Region.IsInside(caretLine, caretColumn)) { if (c != innerMostClass) { GetOuterClasses(classes, c, caretLine, caretColumn); if (!classes.Contains(c)) { diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs index 66dbd9cef4..f3964911ce 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs @@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom [Serializable] public class DefaultEvent : AbstractMember, IEvent { - protected IRegion bodyRegion; + protected DomRegion bodyRegion; protected EventAttributes eventAttributes; protected IMethod addMethod; protected IMethod removeMethod; @@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public virtual IRegion BodyRegion { + public virtual DomRegion BodyRegion { get { return bodyRegion; } @@ -46,7 +46,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } - public DefaultEvent(string name, IReturnType type, ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType, name) + public DefaultEvent(string name, IReturnType type, ModifierEnum m, DomRegion region, DomRegion bodyRegion, IClass declaringType) : base(declaringType, name) { this.ReturnType = type; this.Region = region; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs index 1578086451..eee8873ccd 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } - public DefaultField(IReturnType type, string name, ModifierEnum m, IRegion region, IClass declaringType) : base(declaringType, name) + public DefaultField(IReturnType type, string name, ModifierEnum m, DomRegion region, IClass declaringType) : base(declaringType, name) { this.ReturnType = type; this.Region = region; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs index 457e22bb5e..4d021706bb 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs @@ -15,14 +15,14 @@ namespace ICSharpCode.SharpDevelop.Dom [Serializable] public class Constructor : DefaultMethod { - public Constructor(ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) + public Constructor(ModifierEnum m, DomRegion region, DomRegion bodyRegion, IClass declaringType) : base("#ctor", declaringType.DefaultReturnType, m, region, bodyRegion, declaringType) { } public Constructor(ModifierEnum m, IReturnType returnType) - : base("#ctor", returnType, m, null, null, null) + : base("#ctor", returnType, m, DomRegion.Empty, DomRegion.Empty, null) { } @@ -42,7 +42,7 @@ namespace ICSharpCode.SharpDevelop.Dom [Serializable] public class Destructor : DefaultMethod { - public Destructor(IRegion region, IRegion bodyRegion, IClass declaringType) + public Destructor(DomRegion region, DomRegion bodyRegion, IClass declaringType) : base("#dtor", null, ModifierEnum.None, region, bodyRegion, declaringType) { } @@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Dom [Serializable] public class DefaultMethod : AbstractMember, IMethod { - protected IRegion bodyRegion; + protected DomRegion bodyRegion; List parameters = null; List typeParameters = null; @@ -100,7 +100,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public virtual IRegion BodyRegion { + public virtual DomRegion BodyRegion { get { return bodyRegion; } @@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } - public DefaultMethod(string name, IReturnType type, ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType, name) + public DefaultMethod(string name, IReturnType type, ModifierEnum m, DomRegion region, DomRegion bodyRegion, IClass declaringType) : base(declaringType, name) { this.ReturnType = type; this.Region = region; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs index d7414f5c4a..52a0e48533 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.SharpDevelop.Dom protected IReturnType returnType; protected ParameterModifiers modifier; - protected IRegion region; + protected DomRegion region; List attributes; protected DefaultParameter(string name) @@ -38,13 +38,13 @@ namespace ICSharpCode.SharpDevelop.Dom this.returnType = p.ReturnType; } - public DefaultParameter(string name, IReturnType type, IRegion region) : this(name) + public DefaultParameter(string name, IReturnType type, DomRegion region) : this(name) { returnType = type; this.region = region; } - public IRegion Region { + public DomRegion Region { get { return region; } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs index c01498a788..55d2612c9e 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs @@ -14,10 +14,10 @@ namespace ICSharpCode.SharpDevelop.Dom { [Serializable] public class DefaultProperty : AbstractMember, IProperty { - protected IRegion bodyRegion; + protected DomRegion bodyRegion = DomRegion.Empty; - IRegion getterRegion; - IRegion setterRegion; + DomRegion getterRegion = DomRegion.Empty; + DomRegion setterRegion = DomRegion.Empty; protected IMethod getterMethod; protected IMethod setterMethod; @@ -39,7 +39,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } } - public virtual IRegion BodyRegion { + public virtual DomRegion BodyRegion { get { return bodyRegion; } @@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } } - public IRegion GetterRegion { + public DomRegion GetterRegion { get { return getterRegion; } @@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } } - public IRegion SetterRegion { + public DomRegion SetterRegion { get { return setterRegion; } @@ -97,13 +97,13 @@ namespace ICSharpCode.SharpDevelop.Dom { public virtual bool CanGet { get { - return getterRegion != null; + return !getterRegion.IsEmpty; } } public virtual bool CanSet { get { - return setterRegion != null; + return !setterRegion.IsEmpty; } } @@ -111,7 +111,7 @@ namespace ICSharpCode.SharpDevelop.Dom { { } - public DefaultProperty(string name, IReturnType type, ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType, name) + public DefaultProperty(string name, IReturnType type, ModifierEnum m, DomRegion region, DomRegion bodyRegion, IClass declaringType) : base(declaringType, name) { this.ReturnType = type; this.Region = region; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs index 7ade2e6ba0..e37dea54de 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom [Serializable] public class DefaultUsing : MarshalByRefObject, IUsing { - IRegion region; + DomRegion region; IProjectContent projectContent; public DefaultUsing(IProjectContent projectContent) @@ -23,15 +23,15 @@ namespace ICSharpCode.SharpDevelop.Dom this.projectContent = projectContent; } - public DefaultUsing(IProjectContent projectContent, IRegion region) : this(projectContent) + public DefaultUsing(IProjectContent projectContent, DomRegion region) : this(projectContent) { this.region = region; } List usings = new List(); - SortedList aliases = new SortedList(); + SortedList aliases = null; - public IRegion Region { + public DomRegion Region { get { return region; } @@ -49,23 +49,37 @@ namespace ICSharpCode.SharpDevelop.Dom } } + public bool HasAliases { + get { + return aliases != null && aliases.Count > 0; + } + } + + public void AddAlias(string alias, IReturnType type) + { + if (aliases == null) aliases = new SortedList(); + aliases.Add(alias, type); + } + public string SearchNamespace(string partitialNamespaceName) { - foreach (KeyValuePair entry in aliases) { - if (!entry.Value.IsDefaultReturnType) - continue; - string aliasString = entry.Key; - string nsName; - if (projectContent.Language.NameComparer.Equals(partitialNamespaceName, aliasString)) { - nsName = entry.Value.FullyQualifiedName; - if (projectContent.NamespaceExists(nsName)) - return nsName; - } - if (partitialNamespaceName.Length > aliasString.Length) { - if (projectContent.Language.NameComparer.Equals(partitialNamespaceName.Substring(0, aliasString.Length + 1), aliasString + ".")) { - nsName = String.Concat(entry.Value.FullyQualifiedName, partitialNamespaceName.Remove(0, aliasString.Length)); - if (projectContent.NamespaceExists(nsName)) { + if (HasAliases) { + foreach (KeyValuePair entry in aliases) { + if (!entry.Value.IsDefaultReturnType) + continue; + string aliasString = entry.Key; + string nsName; + if (projectContent.Language.NameComparer.Equals(partitialNamespaceName, aliasString)) { + nsName = entry.Value.FullyQualifiedName; + if (projectContent.NamespaceExists(nsName)) return nsName; + } + if (partitialNamespaceName.Length > aliasString.Length) { + if (projectContent.Language.NameComparer.Equals(partitialNamespaceName.Substring(0, aliasString.Length + 1), aliasString + ".")) { + nsName = String.Concat(entry.Value.FullyQualifiedName, partitialNamespaceName.Remove(0, aliasString.Length)); + if (projectContent.NamespaceExists(nsName)) { + return nsName; + } } } } @@ -82,19 +96,21 @@ namespace ICSharpCode.SharpDevelop.Dom public IReturnType SearchType(string partitialTypeName) { - foreach (KeyValuePair entry in aliases) { - string aliasString = entry.Key; - if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) { - if (entry.Value.IsDefaultReturnType && entry.Value.GetUnderlyingClass() == null) - continue; // type not found, maybe entry was a namespace - return entry.Value; - } - if (partitialTypeName.Length > aliasString.Length) { - if (projectContent.Language.NameComparer.Equals(partitialTypeName.Substring(0, aliasString.Length + 1), aliasString + ".")) { - string className = entry.Value.FullyQualifiedName + partitialTypeName.Remove(0, aliasString.Length); - IClass c = projectContent.GetClass(className); - if (c != null) { - return c.DefaultReturnType; + if (HasAliases) { + foreach (KeyValuePair entry in aliases) { + string aliasString = entry.Key; + if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) { + if (entry.Value.IsDefaultReturnType && entry.Value.GetUnderlyingClass() == null) + continue; // type not found, maybe entry was a namespace + return entry.Value; + } + if (partitialTypeName.Length > aliasString.Length) { + if (projectContent.Language.NameComparer.Equals(partitialTypeName.Substring(0, aliasString.Length + 1), aliasString + ".")) { + string className = entry.Value.FullyQualifiedName + partitialTypeName.Remove(0, aliasString.Length); + IClass c = projectContent.GetClass(className); + if (c != null) { + return c.DefaultReturnType; + } } } } @@ -136,11 +152,13 @@ namespace ICSharpCode.SharpDevelop.Dom builder.Append(str); builder.Append(", "); } - foreach (KeyValuePair p in aliases) { - builder.Append(p.Key); - builder.Append("="); - builder.Append(p.Value.ToString()); - builder.Append(", "); + if (HasAliases) { + foreach (KeyValuePair p in aliases) { + builder.Append(p.Key); + builder.Append("="); + builder.Append(p.Value.ToString()); + builder.Append(", "); + } } builder.Length -= 2; // remove last ", " builder.Append("]"); diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs index b4562bdea2..00e05ae1e9 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs @@ -166,7 +166,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver if (u.IsAlias) { IReturnType rt = CreateReturnType(u.Alias); if (rt != null) { - us.Aliases[u.Name] = rt; + us.AddAlias(u.Name, rt); } } else { us.Usings.Add(u.Name); @@ -259,14 +259,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } } - DefaultRegion GetRegion(Point start, Point end) + DomRegion GetRegion(Point start, Point end) { - return new DefaultRegion(start.Y, start.X, end.Y, end.X); + return new DomRegion(start, end); } public override object Visit(AST.TypeDeclaration typeDeclaration, object data) { - DefaultRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation); + DomRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation); DefaultClass c = new DefaultClass(cu, TranslateClassType(typeDeclaration.Type), ConvertModifier(typeDeclaration.Modifier, ModifierEnum.Internal), region, GetCurrentClass()); c.Attributes.AddRange(VisitAttributes(typeDeclaration.Attributes)); c.Documentation = GetDocumentation(region.BeginLine); @@ -340,7 +340,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.DelegateDeclaration delegateDeclaration, object data) { - DefaultRegion region = GetRegion(delegateDeclaration.StartLocation, delegateDeclaration.EndLocation); + DomRegion region = GetRegion(delegateDeclaration.StartLocation, delegateDeclaration.EndLocation); DefaultClass c = new DefaultClass(cu, ClassType.Delegate, ConvertModifier(delegateDeclaration.Modifier, ModifierEnum.Internal), region, GetCurrentClass()); c.Documentation = GetDocumentation(region.BeginLine); c.Attributes.AddRange(VisitAttributes(delegateDeclaration.Attributes)); @@ -359,24 +359,24 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } currentClass.Push(c); // necessary for CreateReturnType ConvertTemplates(delegateDeclaration.Templates, c); - DefaultMethod invokeMethod = new DefaultMethod("Invoke", CreateReturnType(delegateDeclaration.ReturnType), ModifierEnum.Public, null, null, c); + DefaultMethod invokeMethod = new DefaultMethod("Invoke", CreateReturnType(delegateDeclaration.ReturnType), ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, c); if (delegateDeclaration.Parameters != null) { foreach (AST.ParameterDeclarationExpression par in delegateDeclaration.Parameters) { invokeMethod.Parameters.Add(CreateParameter(par)); } } c.Methods.Add(invokeMethod); - invokeMethod = new DefaultMethod("BeginInvoke", CreateReturnType(typeof(IAsyncResult)), ModifierEnum.Public, null, null, c); + invokeMethod = new DefaultMethod("BeginInvoke", CreateReturnType(typeof(IAsyncResult)), ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, c); if (delegateDeclaration.Parameters != null) { foreach (AST.ParameterDeclarationExpression par in delegateDeclaration.Parameters) { invokeMethod.Parameters.Add(CreateParameter(par)); } } - invokeMethod.Parameters.Add(new DefaultParameter("callback", CreateReturnType(typeof(AsyncCallback)), null)); - invokeMethod.Parameters.Add(new DefaultParameter("object", ReflectionReturnType.Object, null)); + invokeMethod.Parameters.Add(new DefaultParameter("callback", CreateReturnType(typeof(AsyncCallback)), DomRegion.Empty)); + invokeMethod.Parameters.Add(new DefaultParameter("object", ReflectionReturnType.Object, DomRegion.Empty)); c.Methods.Add(invokeMethod); - invokeMethod = new DefaultMethod("EndInvoke", CreateReturnType(delegateDeclaration.ReturnType), ModifierEnum.Public, null, null, c); - invokeMethod.Parameters.Add(new DefaultParameter("result", CreateReturnType(typeof(IAsyncResult)), null)); + invokeMethod = new DefaultMethod("EndInvoke", CreateReturnType(delegateDeclaration.ReturnType), ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, c); + invokeMethod.Parameters.Add(new DefaultParameter("result", CreateReturnType(typeof(IAsyncResult)), DomRegion.Empty)); c.Methods.Add(invokeMethod); currentClass.Pop(); return c; @@ -390,15 +390,15 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver IParameter CreateParameter(AST.ParameterDeclarationExpression par, IMethod method) { IReturnType parType = CreateReturnType(par.TypeReference, method); - DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, par.EndLocation)); + DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DomRegion(par.StartLocation, par.EndLocation)); p.Modifiers = (ParameterModifiers)par.ParamModifier; return p; } public override object Visit(AST.MethodDeclaration methodDeclaration, object data) { - DefaultRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1)); + DomRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1)); DefaultClass c = GetCurrentClass(); DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); @@ -418,8 +418,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.OperatorDeclaration operatorDeclaration, object data) { DefaultClass c = GetCurrentClass(); - DefaultRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : new Point(-1, -1)); + DomRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : new Point(-1, -1)); DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.ConvertToType), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c); if(operatorDeclaration.Parameters != null) @@ -434,8 +434,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.ConstructorDeclaration constructorDeclaration, object data) { - DefaultRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1)); + DomRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1)); DefaultClass c = GetCurrentClass(); Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); @@ -452,8 +452,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.DestructorDeclaration destructorDeclaration, object data) { - DefaultRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1)); + DomRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1)); DefaultClass c = GetCurrentClass(); @@ -466,7 +466,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.FieldDeclaration fieldDeclaration, object data) { - DefaultRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation); + DomRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation); DefaultClass c = GetCurrentClass(); string doku = GetDocumentation(region.BeginLine); if (currentClass.Count > 0) { @@ -493,8 +493,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.PropertyDeclaration propertyDeclaration, object data) { - DefaultRegion region = GetRegion(propertyDeclaration.StartLocation, propertyDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd); + DomRegion region = GetRegion(propertyDeclaration.StartLocation, propertyDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd); IReturnType type = CreateReturnType(propertyDeclaration.TypeReference); DefaultClass c = GetCurrentClass(); @@ -514,8 +514,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.EventDeclaration eventDeclaration, object data) { - DefaultRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd); + DomRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd); IReturnType type = CreateReturnType(eventDeclaration.TypeReference); DefaultClass c = GetCurrentClass(); DefaultEvent e = null; @@ -541,8 +541,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.IndexerDeclaration indexerDeclaration, object data) { - DefaultRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation); - DefaultRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd); + DomRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation); + DomRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd); DefaultProperty i = new DefaultProperty("Indexer", CreateReturnType(indexerDeclaration.TypeReference), ConvertModifier(indexerDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); i.IsIndexer = true; i.Documentation = GetDocumentation(region.BeginLine); diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs index e8cfbfae7f..167b7786da 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs @@ -400,10 +400,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver // mode that does not parse the method bodies for the normal run (in the ParserUpdateThread or // SolutionLoadThread). That could improve the parser's speed dramatically. - if (member.Region == null) return null; + if (member.Region.IsEmpty) return null; int startLine = member.Region.BeginLine; if (startLine < 1) return null; - IRegion bodyRegion; + DomRegion bodyRegion; if (member is IMethodOrProperty) { bodyRegion = ((IMethodOrProperty)member).BodyRegion; } else if (member is IEvent) { @@ -411,7 +411,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } else { return null; } - if (bodyRegion == null) return null; + if (bodyRegion.IsEmpty) return null; int endLine = bodyRegion.EndLine; int offset = 0; for (int i = 0; i < startLine - 1; ++i) { // -1 because the startLine must be included @@ -482,7 +482,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver LocalLookupVariable var = SearchVariable(identifier); if (var != null) { IReturnType type = GetVariableType(var); - IField field = new DefaultField(type, identifier, ModifierEnum.None, new DefaultRegion(var.StartPos, var.EndPos), callingClass); + IField field = new DefaultField(type, identifier, ModifierEnum.None, new DomRegion(var.StartPos, var.EndPos), callingClass); return new LocalResolveResult(callingMember, field, false); } IParameter para = SearchMethodParameter(identifier); @@ -492,7 +492,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } if (IsSameName(identifier, "value")) { IProperty property = callingMember as IProperty; - if (property != null && property.SetterRegion != null && property.SetterRegion.IsInside(caretLine, caretColumn)) { + if (property != null && property.SetterRegion.IsInside(caretLine, caretColumn)) { IField field = new DefaultField(property.ReturnType, "value", ModifierEnum.None, property.Region, callingClass); return new LocalResolveResult(callingMember, field, true); } @@ -650,12 +650,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver if (callingClass == null) return null; foreach (IMethod method in callingClass.Methods) { - if (method.BodyRegion != null && method.BodyRegion.IsInside(caretLine, caretColumn)) { + if (method.BodyRegion.IsInside(caretLine, caretColumn)) { return method; } } foreach (IProperty property in callingClass.Properties) { - if (property.BodyRegion != null && property.BodyRegion.IsInside(caretLine, caretColumn)) { + if (property.BodyRegion.IsInside(caretLine, caretColumn)) { return property; } } @@ -939,7 +939,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver foreach (LocalLookupVariable v in pair.Value) { if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) { // convert to a field for display - result.Add(new DefaultField(TypeVisitor.CreateReturnType(v.TypeRef, this), pair.Key, ModifierEnum.None, new DefaultRegion(v.StartPos, v.EndPos), callingClass)); + result.Add(new DefaultField(TypeVisitor.CreateReturnType(v.TypeRef, this), pair.Key, ModifierEnum.None, new DomRegion(v.StartPos, v.EndPos), callingClass)); break; } } @@ -978,8 +978,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } } } - foreach (string alias in u.Aliases.Keys) { - result.Add(alias); + if (u.HasAliases) { + foreach (string alias in u.Aliases.Keys) { + result.Add(alias); + } } } } diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs index 104919ba5c..cce9d7d76d 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs @@ -7,7 +7,6 @@ using System; using System.Collections; -//using System.Xml; using System.Reflection; using System.Collections.Generic; using ICSharpCode.Core; @@ -24,29 +23,47 @@ namespace ICSharpCode.SharpDevelop.Dom BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.Public; - + List innerClasses; - + public override List InnerClasses { get { if (innerClasses == null) { innerClasses = new List(); foreach (Type nestedType in type.GetNestedTypes(flags)) { - innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, this)); + string name = nestedType.FullName.Replace('+', '.'); + innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, name, this)); } } return innerClasses; } } + static Dictionary> fieldCache = new Dictionary>(); + static Dictionary> propertyCache = new Dictionary>(); + static Dictionary> methodCache = new Dictionary>(); + static Dictionary> eventCache = new Dictionary>(); + + public static void ClearMemberCache() + { + fieldCache.Clear(); + propertyCache.Clear(); + methodCache.Clear(); + eventCache.Clear(); + } + public override List Fields { get { - List fields = new List(); - foreach (FieldInfo field in type.GetFields(flags)) { - if (!field.IsPublic && !field.IsFamily) continue; - if (!field.IsSpecialName) { - fields.Add(new ReflectionField(field, this)); + List fields; + if (!fieldCache.TryGetValue(this, out fields)) { + fields = new List(); + foreach (FieldInfo field in type.GetFields(flags)) { + if (!field.IsPublic && !field.IsFamily) continue; + if (!field.IsSpecialName) { + fields.Add(new ReflectionField(field, this)); + } } + fieldCache.Add(this, fields); } return fields; } @@ -54,33 +71,40 @@ namespace ICSharpCode.SharpDevelop.Dom public override List Properties { get { - List properties = new List(); - foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) { - ReflectionProperty prop = new ReflectionProperty(propertyInfo, this); - if (prop.IsPublic || prop.IsProtected) - properties.Add(prop); + List properties; + if (!propertyCache.TryGetValue(this, out properties)) { + properties = new List(); + foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) { + ReflectionProperty prop = new ReflectionProperty(propertyInfo, this); + if (prop.IsPublic || prop.IsProtected) + properties.Add(prop); + } + propertyCache.Add(this, properties); } - return properties; } } public override List Methods { get { - List methods = new List(); - - foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) { - if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue; - IMethod newMethod = new ReflectionMethod(constructorInfo, this); - methods.Add(newMethod); - } - - foreach (MethodInfo methodInfo in type.GetMethods(flags)) { - if (!methodInfo.IsPublic && !methodInfo.IsFamily) continue; - if (!methodInfo.IsSpecialName) { - IMethod newMethod = new ReflectionMethod(methodInfo, this); + List methods; + if (!methodCache.TryGetValue(this, out methods)) { + methods = new List(); + + foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) { + if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue; + IMethod newMethod = new ReflectionMethod(constructorInfo, this); methods.Add(newMethod); } + + foreach (MethodInfo methodInfo in type.GetMethods(flags)) { + if (!methodInfo.IsPublic && !methodInfo.IsFamily) continue; + if (!methodInfo.IsSpecialName) { + IMethod newMethod = new ReflectionMethod(methodInfo, this); + methods.Add(newMethod); + } + } + methodCache.Add(this, methods); } return methods; } @@ -88,10 +112,13 @@ namespace ICSharpCode.SharpDevelop.Dom public override List Events { get { - List events = new List(); - - foreach (EventInfo eventInfo in type.GetEvents(flags)) { - events.Add(new ReflectionEvent(eventInfo, this)); + List events; + if (!eventCache.TryGetValue(this, out events)) { + events = new List(); + foreach (EventInfo eventInfo in type.GetEvents(flags)) { + events.Add(new ReflectionEvent(eventInfo, this)); + } + eventCache.Add(this, events); } return events; } @@ -105,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Dom #region VoidClass / VoidReturnType public class VoidClass : ReflectionClass { - public VoidClass(ICompilationUnit compilationUnit) : base(compilationUnit, typeof(void), null) {} + public VoidClass(ICompilationUnit compilationUnit) : base(compilationUnit, typeof(void), typeof(void).FullName, null) {} protected override IReturnType CreateDefaultReturnType() { return new VoidReturnType(this); @@ -146,14 +173,13 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public ReflectionClass(ICompilationUnit compilationUnit, Type type, IClass declaringType) : base(compilationUnit, declaringType) + public ReflectionClass(ICompilationUnit compilationUnit, Type type, string fullName, IClass declaringType) : base(compilationUnit, declaringType) { this.type = type; - string name = type.FullName.Replace('+', '.'); - if (name.Length > 2 && name[name.Length - 2] == '`') { - FullyQualifiedName = name.Substring(0, name.Length - 2); + if (fullName.Length > 2 && fullName[fullName.Length - 2] == '`') { + FullyQualifiedName = fullName.Substring(0, fullName.Length - 2); } else { - FullyQualifiedName = name; + FullyQualifiedName = fullName; } this.UseInheritanceCache = true; diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs index 644b656a7a..7738418ac1 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs @@ -30,15 +30,11 @@ namespace ICSharpCode.SharpDevelop.Dom // show the abstract layer that we have getter & setters if (propertyInfo.CanRead) { - GetterRegion = new DefaultRegion(0, 0, 0, 0); - } else { - GetterRegion = null; + GetterRegion = new DomRegion(0, 0, 0, 0); } if (propertyInfo.CanWrite) { - SetterRegion = new DefaultRegion(0, 0, 0, 0); - } else { - SetterRegion = null; + SetterRegion = new DomRegion(0, 0, 0, 0); } ParameterInfo[] parameterInfo = propertyInfo.GetIndexParameters(); diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultRegion.cs b/src/Main/Base/Project/Src/Dom/Region.cs similarity index 68% rename from src/Main/Base/Project/Src/Dom/Implementations/DefaultRegion.cs rename to src/Main/Base/Project/Src/Dom/Region.cs index 3a3696961d..a8709af118 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultRegion.cs +++ b/src/Main/Base/Project/Src/Dom/Region.cs @@ -7,67 +7,68 @@ using System; using System.Drawing; -using System.Diagnostics; -namespace ICSharpCode.SharpDevelop.Dom { - +namespace ICSharpCode.SharpDevelop.Dom +{ [Serializable] - public class DefaultRegion : System.MarshalByRefObject, IRegion + public struct DomRegion : IComparable, IComparable { - protected int beginLine = -1; - protected int endLine = -1; - protected int beginColumn = -1; - protected int endColumn = -1; - - public virtual int BeginLine { + readonly int beginLine; + readonly int endLine; + readonly int beginColumn; + readonly int endColumn; + + public readonly static DomRegion Empty = new DomRegion(-1, -1); + + public bool IsEmpty { get { - return beginLine; + return BeginLine <= 0; } } - - public virtual int BeginColumn { + + public int BeginLine { get { - return beginColumn; + return beginLine; } } - + /// - /// if the end column is == -1 the end line is -1 too + /// if the end line is == -1 the end column is -1 too /// this stands for an unknwon end /// - public virtual int EndColumn { + public int EndLine { get { - return endColumn; + return endLine; } - set { - endColumn = value; + } + + public int BeginColumn { + get { + return beginColumn; } } - + /// - /// if the end line is == -1 the end column is -1 too + /// if the end column is == -1 the end line is -1 too /// this stands for an unknwon end /// - public virtual int EndLine { + public int EndColumn { get { - return endLine; - } - set { - endLine = value; + return endColumn; } } - - public DefaultRegion(Point start, Point end) + + public DomRegion(Point start, Point end) : this(start.Y, start.X, end.Y, end.X) { } - public DefaultRegion(Point start) + public DomRegion(Point start) : this(start.Y, start.X) { } - public DefaultRegion(int beginLine, int beginColumn, int endLine, int endColumn) + public DomRegion(int beginLine, int beginColumn, int endLine, int endColumn) { this.beginLine = beginLine; this.beginColumn = beginColumn; @@ -75,10 +76,12 @@ namespace ICSharpCode.SharpDevelop.Dom { this.endColumn = endColumn; } - public DefaultRegion(int beginLine, int beginColumn) + public DomRegion(int beginLine, int beginColumn) { this.beginLine = beginLine; this.beginColumn = beginColumn; + this.endLine = -1; + this.endColumn = -1; } /// @@ -88,9 +91,9 @@ namespace ICSharpCode.SharpDevelop.Dom { public bool IsInside(int row, int column) { return row >= BeginLine && - (row <= EndLine || EndLine == -1) && - (row != BeginLine || column >= BeginColumn) && - (row != EndLine || column <= EndColumn); + (row <= EndLine || EndLine == -1) && + (row != BeginLine || column >= BeginColumn) && + (row != EndLine || column <= EndColumn); } public override string ToString() @@ -102,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.Dom { endColumn); } - public virtual int CompareTo(IRegion value) + public int CompareTo(DomRegion value) { int cmp; if (0 != (cmp = (BeginLine - value.BeginLine))) { @@ -121,7 +124,7 @@ namespace ICSharpCode.SharpDevelop.Dom { } int IComparable.CompareTo(object value) { - return CompareTo((IRegion)value); + return CompareTo((DomRegion)value); } } } diff --git a/src/Main/Base/Project/Src/Dom/ResolveResult.cs b/src/Main/Base/Project/Src/Dom/ResolveResult.cs index e030d8c330..98a6d3e08d 100644 --- a/src/Main/Base/Project/Src/Dom/ResolveResult.cs +++ b/src/Main/Base/Project/Src/Dom/ResolveResult.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -207,11 +207,11 @@ namespace ICSharpCode.SharpDevelop.Dom if (cu.FileName == null || cu.FileName.Length == 0) { return null; } - IRegion reg = field.Region; - if (reg != null) { + DomRegion reg = field.Region; + if (!reg.IsEmpty) { return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); } else { - LoggingService.Warn("GetDefinitionPosition: field.Region is null"); + LoggingService.Warn("GetDefinitionPosition: field.Region is empty"); return new FilePosition(cu.FileName, Point.Empty); } } @@ -318,8 +318,8 @@ namespace ICSharpCode.SharpDevelop.Dom if (cu == null || cu.FileName == null || cu.FileName.Length == 0) { return null; } - IRegion reg = resolvedClass.Region; - if (reg != null) + DomRegion reg = resolvedClass.Region; + if (!reg.IsEmpty) return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); else return new FilePosition(cu.FileName, Point.Empty); @@ -383,8 +383,8 @@ namespace ICSharpCode.SharpDevelop.Dom if (cu.FileName == null || cu.FileName.Length == 0) { return null; } - IRegion reg = resolvedMember.Region; - if (reg != null) + DomRegion reg = resolvedMember.Region; + if (!reg.IsEmpty) return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); else return new FilePosition(cu.FileName, Point.Empty); diff --git a/src/Main/Base/Project/Src/Dom/Tag.cs b/src/Main/Base/Project/Src/Dom/Tag.cs index f9e0140b73..a9c7cafcef 100644 --- a/src/Main/Base/Project/Src/Dom/Tag.cs +++ b/src/Main/Base/Project/Src/Dom/Tag.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -21,7 +21,7 @@ namespace ICSharpCode.SharpDevelop.Dom } string commentString; - IRegion region; + DomRegion region; public string CommentString { get { @@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public IRegion Region { + public DomRegion Region { get { return region; } @@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public Tag(string key, IRegion region) + public Tag(string key, DomRegion region) { this.key = key; this.region = region; diff --git a/src/Main/Base/Project/Src/Dom/XmlDoc.cs b/src/Main/Base/Project/Src/Dom/XmlDoc.cs index 2decfaa575..d6d793bdbc 100644 --- a/src/Main/Base/Project/Src/Dom/XmlDoc.cs +++ b/src/Main/Base/Project/Src/Dom/XmlDoc.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -19,8 +19,32 @@ namespace ICSharpCode.SharpDevelop.Dom /// public class XmlDoc : IDisposable { + struct IndexEntry : IComparable { + public int HashCode; + public int FileLocation; + + public int CompareTo(IndexEntry other) + { + return HashCode.CompareTo(other.HashCode); + } + + public IndexEntry(int HashCode, int FileLocation) + { + this.HashCode = HashCode; + this.FileLocation = FileLocation; + } + } + Dictionary xmlDescription = new Dictionary(); - Dictionary indexDictionary; + IndexEntry[] index; // SORTED array of index entries + Queue keyCacheQueue; + + const int cacheLength = 150; // number of strings to cache when working in file-mode + #if DEBUG + const string tempPathName = "SharpDevelop/DocumentationCacheDebug"; + #else + const string tempPathName = "SharpDevelop/DocumentationCache"; + #endif void ReadMembersSection(XmlTextReader reader) { @@ -45,13 +69,10 @@ namespace ICSharpCode.SharpDevelop.Dom public string GetDocumentation(string key) { lock (xmlDescription) { - if (indexDictionary != null) { - if (!indexDictionary.ContainsKey(key)) - return null; - } - if (xmlDescription.ContainsKey(key)) - return xmlDescription[key]; - if (indexDictionary == null) + string result; + if (xmlDescription.TryGetValue(key, out result)) + return result; + if (index == null) return null; return LoadDocumentation(key); } @@ -60,19 +81,23 @@ namespace ICSharpCode.SharpDevelop.Dom #region Save binary files // FILE FORMAT FOR BINARY DOCUMENTATION // long magic = 0x4244636f446c6d58 (identifies file type = 'XmlDocDB') - // short version = 1 (file version) + const long magic = 0x4244636f446c6d58; + // short version = 2 (file version) + const short version = 2; // long fileDate (last change date of xml file in DateTime ticks) + // int testHashCode = magicTestString.GetHashCode() // (check if hash-code implementation is compatible) + // int entryCount (count of entries) // int indexPointer (points to location where index starts in the file) - // { string docu } (all documentation strings as length-prefixed strings) + // { + // string key (documentation key as length-prefixed string) + // string docu (xml documentation as length-prefixed string) + // } // indexPointer points to the start of the following section: // { - // string key (documentation key as length-prefixed string) + // int hashcode // int index (index where the docu string starts in the file) // } - const long magic = 0x4244636f446c6d58; - const short version = 1; - void Save(string fileName, DateTime fileDate) { using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) { @@ -81,21 +106,26 @@ namespace ICSharpCode.SharpDevelop.Dom w.Write(version); w.Write(fileDate.Ticks); + IndexEntry[] index = new IndexEntry[xmlDescription.Count]; + w.Write(index.Length); + int indexPointerPos = (int)fs.Position; w.Write(0); // skip 4 bytes - int[] indices = new int[xmlDescription.Count]; int i = 0; foreach (KeyValuePair p in xmlDescription) { - indices[i++] = (int)fs.Position; + index[i] = new IndexEntry(p.Key.GetHashCode(), (int)fs.Position); + w.Write(p.Key); w.Write(p.Value.Trim()); + i += 1; } + Array.Sort(index); + int indexStart = (int)fs.Position; - i = 0; - foreach (KeyValuePair p in xmlDescription) { - w.Write(p.Key); - w.Write(indices[i++]); + foreach (IndexEntry entry in index) { + w.Write(entry.HashCode); + w.Write(entry.FileLocation); } w.Seek(indexPointerPos, SeekOrigin.Begin); w.Write(indexStart); @@ -107,12 +137,9 @@ namespace ICSharpCode.SharpDevelop.Dom #region Load binary files BinaryReader loader; FileStream fs; - Queue keyCacheQueue; - const int cacheLength = 150; // number of strings to cache when working in file-mode bool LoadFromBinary(string fileName, DateTime fileDate) { - indexDictionary = new Dictionary(); keyCacheQueue = new Queue(cacheLength); fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); int len = (int)fs.Length; @@ -130,21 +157,18 @@ namespace ICSharpCode.SharpDevelop.Dom LoggingService.Info("Not loading XmlDoc: file changed since cache was created"); return false; } + int count = loader.ReadInt32(); int indexStartPosition = loader.ReadInt32(); // go to start of index if (indexStartPosition >= len) { LoggingService.Error("XmlDoc: Cannot find index, cache invalid!"); return false; } fs.Position = indexStartPosition; - while (fs.Position < len) { - string key = loader.ReadString(); - int pos = loader.ReadInt32(); - indexDictionary.Add(key, pos); - } - if (fs.Position > len) { - LoggingService.Error("XmlDoc: Jumped over end of file, cache invalid!"); - return false; + IndexEntry[] index = new IndexEntry[count]; + for (int i = 0; i < index.Length; i++) { + index[i] = new IndexEntry(loader.ReadInt32(), loader.ReadInt32()); } + this.index = index; return true; } catch (Exception ex) { LoggingService.Error("Cannot load from cache", ex); @@ -157,12 +181,34 @@ namespace ICSharpCode.SharpDevelop.Dom if (keyCacheQueue.Count > cacheLength - 1) { xmlDescription.Remove(keyCacheQueue.Dequeue()); } - int pos = indexDictionary[key]; - fs.Position = pos; - string docu = loader.ReadString(); - xmlDescription.Add(key, docu); - keyCacheQueue.Enqueue(docu); - return docu; + + int hashcode = key.GetHashCode(); + + // use interpolation search to find the item + string resultDocu = null; + + int m = Array.BinarySearch(index, new IndexEntry(hashcode, 0)); + if (m >= 0) { + // correct hash code found. + // possibly there are multiple items with the same hash, so go to the first. + while (--m >= 0 && index[m].HashCode == hashcode); + // go through all items that have the correct hash + while (++m < index.Length && index[m].HashCode == hashcode) { + fs.Position = index[m].FileLocation; + string keyInFile = loader.ReadString(); + if (keyInFile == key) { + resultDocu = loader.ReadString(); + break; + } else { + LoggingService.Warn("Found " + keyInFile + " instead of " + key); + } + } + } + + keyCacheQueue.Enqueue(key); + xmlDescription.Add(key, resultDocu); + + return resultDocu; } public void Dispose() @@ -172,7 +218,7 @@ namespace ICSharpCode.SharpDevelop.Dom fs.Close(); } xmlDescription = null; - indexDictionary = null; + index = null; keyCacheQueue = null; loader = null; fs = null; @@ -198,7 +244,7 @@ namespace ICSharpCode.SharpDevelop.Dom static string MakeTempPath() { - string tempPath = Path.Combine(Path.GetTempPath(), "SharpDevelop/DocumentationCache"); + string tempPath = Path.Combine(Path.GetTempPath(), tempPathName); if (!Directory.Exists(tempPath)) Directory.CreateDirectory(tempPath); return tempPath; diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs index 74624c7277..23d65911aa 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs @@ -54,9 +54,7 @@ namespace ICSharpCode.SharpDevelop.Gui public override void ActivateItem() { if (c.CompilationUnit != null) { - FileService.JumpToFilePosition(c.CompilationUnit.FileName, - c.Region != null ? c.Region.BeginLine - 1 : 0, - c.Region != null ? c.Region.BeginColumn - 1 : 0); + FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs index 8e69d3db2c..39b44e99d3 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs @@ -63,10 +63,8 @@ namespace ICSharpCode.SharpDevelop.Gui this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu"; declaringType = member.DeclaringType; modifiers = member.Modifiers; - if (member.Region != null) { - line = member.Region.BeginLine; - column = member.Region.BeginColumn; - } + line = member.Region.BeginLine; + column = member.Region.BeginColumn; } public static string GetText(IMember member) diff --git a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs index ce1e5a6fc3..a65a092fc3 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs @@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop.Gui static Panel panel = null; static ComboBox comboBox = null; - static PropertyGrid grid = null; + static PropertyGrid grid = new PropertyGrid(); static IDesignerHost host = null; public static PropertyGrid Grid { @@ -85,7 +85,11 @@ namespace ICSharpCode.SharpDevelop.Gui } public static event PropertyValueChangedEventHandler PropertyValueChanged; - public static event EventHandler SelectedObjectChanged; + + public static event EventHandler SelectedObjectChanged { + add { grid.SelectedObjectsChanged += value; } + remove { grid.SelectedObjectsChanged -= value; } + } public override Control Control { get { @@ -95,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Gui static PropertyPad() { - grid = new PropertyGrid(); grid.PropertySort = PropertyService.Get("FormsDesigner.DesignerOptions.PropertyGridSortAlphabetical", false) ? PropertySort.Alphabetical : PropertySort.CategorizedAlphabetical; grid.Dock = DockStyle.Fill; @@ -119,11 +122,11 @@ namespace ICSharpCode.SharpDevelop.Gui { instance = this; panel = new Panel(); - + comboBox.DrawItem += new DrawItemEventHandler(ComboBoxDrawItem); comboBox.MeasureItem += new MeasureItemEventHandler(ComboBoxMeasureItem); comboBox.SelectedIndexChanged += new EventHandler(ComboBoxSelectedIndexChanged); - + panel.Controls.Add(grid); panel.Controls.Add(comboBox); @@ -153,7 +156,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (item is IComponent) { ISite site = ((IComponent)item).Site; - if (site != null) { + if (site != null) { string name = site.Name; Font f = new Font(comboBox.Font, FontStyle.Bold); mea.ItemWidth += (int)mea.Graphics.MeasureString(name + "-", f).Width; @@ -185,7 +188,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (item is IComponent) { ISite site = ((IComponent)item).Site; - if (site != null) { + if (site != null) { string name = site.Name; Font f = new Font(comboBox.Font, FontStyle.Bold); g.DrawString(name, f, stringColor, xPos, dea.Bounds.Y); @@ -205,14 +208,11 @@ namespace ICSharpCode.SharpDevelop.Gui ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService)); if (comboBox.SelectedIndex >= 0) { selectionService.SetSelectedComponents(new object[] {comboBox.Items[comboBox.SelectedIndex] }); - } else { + } else { SetDesignableObject(null); selectionService.SetSelectedComponents(new object[] { }); } } - if (SelectedObjectChanged != null) { - SelectedObjectChanged(this, EventArgs.Empty); - } } } @@ -289,15 +289,15 @@ namespace ICSharpCode.SharpDevelop.Gui if (host != null) { grid.Site = (new IDEContainer(host)).CreateSite(grid); grid.PropertyTabs.AddTabType(typeof(System.Windows.Forms.Design.EventsTab), PropertyTabScope.Document); - + ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService)); if (selectionService != null) { selectionService.SelectionChanging += new EventHandler(SelectionChangingHandler); selectionService.SelectionChanged += new EventHandler(SelectionChangedHandler); } - + host.TransactionClosed += new DesignerTransactionCloseEventHandler(TransactionClose); - + IComponentChangeService componentChangeService = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); if (componentChangeService != null) { componentChangeService.ComponentAdded += new ComponentEventHandler(UpdateSelectedObjects); @@ -338,8 +338,12 @@ namespace ICSharpCode.SharpDevelop.Gui ICSharpCode.SharpDevelop.Dom.IClass c = ProjectContentRegistry.WinForms.GetClass(component.FullName); if (c != null) { foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) { - ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(p); + if (gridItem.PropertyDescriptor.Name == p.Name) { + ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(p); + return; + } } + ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(c); } } } diff --git a/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs b/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs index 73dba166ab..e9b0c03be8 100644 --- a/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs +++ b/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs @@ -89,7 +89,7 @@ namespace ICSharpCode.Core public string Convert(Type type) { - return conv.Convert(new ReflectionClass(null, type, null)); + return conv.Convert(new ReflectionClass(null, type, type.FullName.Replace('+', '.'), null)); } public string Convert(FieldInfo field) diff --git a/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs index 32d94efaeb..540429186b 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs @@ -634,7 +634,7 @@ namespace ICSharpCode.Core { IClass curClass = GetClass(fullMemberName, LanguageProperties.CSharp, false); if (curClass != null) { - return new Position(curClass.CompilationUnit, curClass.Region != null ? curClass.Region.BeginLine : -1, curClass.Region != null ? curClass.Region.BeginColumn : -1); + return new Position(curClass.CompilationUnit, curClass.Region.BeginLine, curClass.Region.BeginColumn); } int pos = fullMemberName.LastIndexOf('.'); if (pos > 0) { @@ -644,7 +644,7 @@ namespace ICSharpCode.Core if (curClass != null) { IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp); if (member != null) { - return new Position(curClass.CompilationUnit, member.Region != null ? member.Region.BeginLine : -1, member.Region != null ? member.Region.BeginColumn : -1); + return new Position(curClass.CompilationUnit, member.Region.BeginLine, member.Region.BeginColumn); } } } diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index bf02c55d2f..25828a6b62 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -185,9 +185,15 @@ namespace ICSharpCode.Core LoggingService.Info("ParserUpdateThread started"); // preload mscorlib, we're going to need it anyway IProjectContent dummyVar = ProjectContentRegistry.Mscorlib; + int counter = 0; while (!abortParserUpdateThread) { try { + if (++counter == 10) { + ReflectionClass.ClearMemberCache(); + counter = 0; + } + ParserUpdateStep(); } catch (Exception e) { ICSharpCode.Core.MessageService.ShowError(e); diff --git a/src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs index aaa4c074fc..cc19c89163 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -35,8 +35,9 @@ namespace ICSharpCode.Core try { foreach (Type type in assembly.GetExportedTypes()) { - if (!type.IsNested) { - AddClassToNamespaceListInternal(new ReflectionClass(assemblyCompilationUnit, type, null)); + string name = type.FullName; + if (name.IndexOf('+') < 0) { // type.IsNested + AddClassToNamespaceListInternal(new ReflectionClass(assemblyCompilationUnit, type, name, null)); } } } catch (Exception ex) { diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs index 0ad3bd3797..c79cd4c6cd 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs @@ -116,12 +116,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring return null; } foreach (IMethod method in callingClass.Methods) { - if (method.BodyRegion != null && method.BodyRegion.IsInside(caretLine, caretColumn)) { + if (method.BodyRegion.IsInside(caretLine, caretColumn)) { return method; } } foreach (IProperty property in callingClass.Properties) { - if (property.BodyRegion != null && property.BodyRegion.IsInside(caretLine, caretColumn)) { + if (property.BodyRegion.IsInside(caretLine, caretColumn)) { return property; } } @@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring return MakeItem(c.FullyQualifiedName, new ClassNode(c.ProjectContent.Project, c), c.CompilationUnit, c.Region); } - ToolStripMenuItem MakeItem(string title, ExtTreeNode classBrowserTreeNode, ICompilationUnit cu, IRegion region) + ToolStripMenuItem MakeItem(string title, ExtTreeNode classBrowserTreeNode, ICompilationUnit cu, DomRegion region) { ToolStripMenuItem item = new ToolStripMenuItem(classBrowserTreeNode.Text, ClassBrowserIconService.ImageList.Images[classBrowserTreeNode.ImageIndex]); @@ -163,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring //item.DropDown.Items.Add(titleItem); //item.DropDown.Items.Add(new ToolStripSeparator()); - if (cu.FileName != null && region != null) { + if (cu.FileName != null && !region.IsEmpty) { ToolStripMenuItem gotoDefinitionItem = new ToolStripMenuItem(StringParser.Parse("${res:ICSharpCode.NAntAddIn.GotoDefinitionMenuLabel}"), ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GotoArrowIndex]); gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter; diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs b/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs index f9654f1978..02d10ea248 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs @@ -105,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands RenameReferences(list, newName); } - void AddDeclarationAsReference(List list, string fileName, IRegion region, string name) + void AddDeclarationAsReference(List list, string fileName, DomRegion region, string name) { if (fileName == null) return; diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs b/src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs index 13f76db0ba..b74833ea3c 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs @@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands if (derivedClass.CompilationUnit == null) continue; if (derivedClass.CompilationUnit.FileName == null) continue; IMember m = RefactoringService.FindSimilarMember(derivedClass, member); - if (m != null && m.Region != null) { + if (!m.Region.IsEmpty) { SearchResult res = new SimpleSearchResult(m.FullyQualifiedName, new Point(m.Region.BeginColumn - 1, m.Region.BeginLine - 1)); res.ProvidedDocumentInformation = GetDocumentInformation(derivedClass.CompilationUnit.FileName); results.Add(res); diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/ParserBookmarkMenuBuilderBase.cs b/src/Main/Base/Project/Src/TextEditor/Commands/ParserBookmarkMenuBuilderBase.cs index ee45725e8e..5d1d604d32 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/ParserBookmarkMenuBuilderBase.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/ParserBookmarkMenuBuilderBase.cs @@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands if (cu != null) { string fileName = cu.FileName; if (fileName != null) { - if (member.Region != null && member.Region.BeginLine > 0) { + if (!member.Region.IsEmpty) { viewContent = FileService.JumpToFilePosition(fileName, member.Region.BeginLine - 1, member.Region.BeginColumn - 1); } else { FileService.OpenFile(fileName); @@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands if (cu != null) { string fileName = cu.FileName; if (fileName != null) { - if (member.Region != null && member.Region.EndLine > 0) { + if (!member.Region.IsEmpty) { viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine, 0); } else { FileService.OpenFile(fileName); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs index fab8495987..3d151e1fce 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs @@ -341,9 +341,9 @@ namespace ICSharpCode.SharpDevelop.Gui Close(); } - void GotoRegion(IRegion region, string fileName) + void GotoRegion(DomRegion region, string fileName) { - if (fileName != null && region != null) { + if (fileName != null && !region.IsEmpty) { FileService.JumpToFilePosition(fileName, region.BeginLine - 1, region.BeginColumn - 1); } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CommentCompletionDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CommentCompletionDataProvider.cs index 6fd4bd55e0..1e3d174f28 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CommentCompletionDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CommentCompletionDataProvider.cs @@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor /// /// Returns true, if the given coordinates (row, column) are in the region. /// - bool IsBetween(int row, int column, IRegion region) + bool IsBetween(int row, int column, DomRegion region) { return row >= region.BeginLine && (row <= region.EndLine || region.EndLine == -1); } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs index 27693f31f0..efccd7a1d3 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor if (c.ClassType == ClassType.Delegate) { return; } - if (c.Region != null && c.Region.BeginLine < c.Region.EndLine) { + if (c.Region.BeginLine < c.Region.EndLine) { FoldMarker newFoldMarker = new FoldMarker(document, c.Region.BeginLine - 1, c.Region.BeginColumn - 1, c.Region.EndLine - 1, c.Region.EndColumn, FoldType.TypeBody); if (newFoldMarker.Length > 0) { @@ -34,22 +34,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } foreach (IMethod m in c.Methods) { - if (m.BodyRegion != null && m.Region.EndLine < m.BodyRegion.EndLine) { + if (m.Region.EndLine < m.BodyRegion.EndLine) { foldMarkers.Add(new FoldMarker(document, m.Region.EndLine - 1, m.Region.EndColumn - 1, m.BodyRegion.EndLine - 1, m.BodyRegion.EndColumn - 1, FoldType.MemberBody)); } } foreach (IProperty p in c.Properties) { - if (p.BodyRegion != null && p.Region.EndLine < p.BodyRegion.EndLine) { + if (p.Region.EndLine < p.BodyRegion.EndLine) { foldMarkers.Add(new FoldMarker(document, p.Region.EndLine - 1, p.Region.EndColumn - 1, p.BodyRegion.EndLine- 1, p.BodyRegion.EndColumn - 1, FoldType.MemberBody)); } } foreach (IEvent evt in c.Events) { - if (evt.BodyRegion != null && evt.Region.EndLine < evt.BodyRegion.EndLine) { - if (evt.BodyRegion != null) { + if (evt.Region.EndLine < evt.BodyRegion.EndLine) { + if (!evt.BodyRegion.IsEmpty) { foldMarkers.Add(new FoldMarker(document, evt.Region.EndLine - 1, evt.Region.EndColumn - 1, evt.BodyRegion.EndLine- 1, evt.BodyRegion.EndColumn - 1, FoldType.MemberBody)); } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs index 85531e4559..31de363784 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs @@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } - public IRegion ItemRegion { + public DomRegion ItemRegion { get { IClass classItem = item as IClass; if (item is IClass) @@ -59,14 +59,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor else if (item is IMember) return ((IMember)item).Region; else - return null; + return DomRegion.Empty; } } public int Line { get { - IRegion r = this.ItemRegion; - if (r == null) + DomRegion r = this.ItemRegion; + if (r.IsEmpty) return 0; else return r.BeginLine - 1; @@ -75,8 +75,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor public int Column { get { - IRegion r = this.ItemRegion; - if (r == null) + DomRegion r = this.ItemRegion; + if (r.IsEmpty) return 0; else return r.BeginColumn - 1; @@ -85,8 +85,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor public int EndLine { get { - IRegion r = this.ItemRegion; - if (r == null) + DomRegion r = this.ItemRegion; + if (r.IsEmpty) return 0; else return r.EndLine - 1; @@ -107,14 +107,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor return false; IClass classItem = item as IClass; if (classItem != null) { - if (classItem.Region == null) + if (classItem.Region.IsEmpty) return false; return classItem.Region.BeginLine - 1 <= lineNumber && classItem.Region.EndLine - 1 >= lineNumber; } IMember member = item as IMember; - if (member == null || member.Region == null) { + if (member == null || member.Region.IsEmpty) { return false; } bool isInside = member.Region.BeginLine - 1 <= lineNumber; diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs index f6c7323a79..d9de20c2d7 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs @@ -465,26 +465,26 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor void AddClassMemberBookmarks(BookmarkManager bm, IClass c) { - if (c.Region != null && c.Region.BeginLine > 0) { + if (!c.Region.IsEmpty) { bm.AddMark(new Bookmarks.ClassBookmark(textAreaControl.Document, c)); } foreach (IClass innerClass in c.InnerClasses) { AddClassMemberBookmarks(bm, innerClass); } foreach (IMethod m in c.Methods) { - if (m.Region == null || m.Region.BeginLine <= 0) continue; + if (m.Region.IsEmpty) continue; bm.AddMark(new Bookmarks.MethodBookmark(textAreaControl.Document, m)); } foreach (IProperty m in c.Properties) { - if (m.Region == null || m.Region.BeginLine <= 0) continue; + if (m.Region.IsEmpty) continue; bm.AddMark(new Bookmarks.PropertyBookmark(textAreaControl.Document, m)); } foreach (IField f in c.Fields) { - if (f.Region == null || f.Region.BeginLine <= 0) continue; + if (f.Region.IsEmpty) continue; bm.AddMark(new Bookmarks.FieldBookmark(textAreaControl.Document, f)); } foreach (IEvent e in c.Events) { - if (e.Region == null || e.Region.BeginLine <= 0) continue; + if (e.Region.IsEmpty) continue; bm.AddMark(new Bookmarks.EventBookmark(textAreaControl.Document, e)); } } diff --git a/src/Main/Base/Test/ReflectionLayerTests.cs b/src/Main/Base/Test/ReflectionLayerTests.cs index 102b6a8bc9..0d4a692838 100644 --- a/src/Main/Base/Test/ReflectionLayerTests.cs +++ b/src/Main/Base/Test/ReflectionLayerTests.cs @@ -1,4 +1,4 @@ -// +// // 2002-2005 AlphaSierraPapa // GNU General Public License // @@ -44,8 +44,8 @@ namespace ICSharpCode.SharpDevelop.Tests [Test] public void ParameterComparisonTest() { - DefaultParameter p1 = new DefaultParameter("a", pc.GetClass("System.String").DefaultReturnType, null); - DefaultParameter p2 = new DefaultParameter("b", new GetClassReturnType(pc, "System.String"), null); + DefaultParameter p1 = new DefaultParameter("a", pc.GetClass("System.String").DefaultReturnType, DomRegion.Empty); + DefaultParameter p2 = new DefaultParameter("b", new GetClassReturnType(pc, "System.String"), DomRegion.Empty); List a1 = new List(); List a2 = new List(); a1.Add(p1);