Browse Source

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<string, IReturnType> 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
shortcuts
Daniel Grunwald 21 years ago
parent
commit
0c9ebf6dc2
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpCompletionBinding.cs
  2. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
  3. 6
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
  4. 12
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs
  5. 6
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs
  6. 2
      src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs
  7. 3
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  8. 6
      src/Main/Base/Project/Src/Dom/FoldingRegion.cs
  9. 2
      src/Main/Base/Project/Src/Dom/IClass.cs
  10. 2
      src/Main/Base/Project/Src/Dom/IComment.cs
  11. 2
      src/Main/Base/Project/Src/Dom/IEvent.cs
  12. 2
      src/Main/Base/Project/Src/Dom/IMember.cs
  13. 2
      src/Main/Base/Project/Src/Dom/IMethod.cs
  14. 2
      src/Main/Base/Project/Src/Dom/IParameter.cs
  15. 4
      src/Main/Base/Project/Src/Dom/IProperty.cs
  16. 34
      src/Main/Base/Project/Src/Dom/IRegion.cs
  17. 9
      src/Main/Base/Project/Src/Dom/IUsing.cs
  18. 6
      src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs
  19. 4
      src/Main/Base/Project/Src/Dom/Implementations/ArrayReturnType.cs
  20. 8
      src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs
  21. 6
      src/Main/Base/Project/Src/Dom/Implementations/DefaultComment.cs
  22. 6
      src/Main/Base/Project/Src/Dom/Implementations/DefaultCompilationUnit.cs
  23. 6
      src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs
  24. 2
      src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs
  25. 12
      src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs
  26. 6
      src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs
  27. 18
      src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs
  28. 26
      src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs
  29. 54
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  30. 18
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  31. 54
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs
  32. 8
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs
  33. 61
      src/Main/Base/Project/Src/Dom/Region.cs
  34. 16
      src/Main/Base/Project/Src/Dom/ResolveResult.cs
  35. 8
      src/Main/Base/Project/Src/Dom/Tag.cs
  36. 126
      src/Main/Base/Project/Src/Dom/XmlDoc.cs
  37. 4
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs
  38. 2
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs
  39. 16
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  40. 2
      src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs
  41. 4
      src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs
  42. 6
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  43. 7
      src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs
  44. 8
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs
  45. 2
      src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs
  46. 2
      src/Main/Base/Project/Src/TextEditor/Commands/ClassMemberMenuBuilder.cs
  47. 4
      src/Main/Base/Project/Src/TextEditor/Commands/ParserBookmarkMenuBuilderBase.cs
  48. 4
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs
  49. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CommentCompletionDataProvider.cs
  50. 10
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs
  51. 20
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs
  52. 10
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
  53. 6
      src/Main/Base/Test/ReflectionLayerTests.cs

2
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); ResolveResult resolveResult = ParserService.Resolve(result, editor.ActiveTextAreaControl.Caret.Line, editor.ActiveTextAreaControl.Caret.Column, editor.FileName, documentText);
if (resolveResult != null && resolveResult.ResolvedType != null) { if (resolveResult != null && resolveResult.ResolvedType != null) {
IClass underlyingClass = resolveResult.ResolvedType.GetUnderlyingClass(); 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); EventHandlerCompletitionDataProvider eventHandlerProvider = new EventHandlerCompletitionDataProvider(result.Expression, resolveResult);
eventHandlerProvider.InsertSpace = true; eventHandlerProvider.InsertSpace = true;
editor.ShowCompletionWindow(eventHandlerProvider, ch); editor.ShowCompletionWindow(eventHandlerProvider, ch);

4
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 false;
} }
return region.BeginLine - 2 <= lineNr && lineNr <= region.BeginLine; return region.BeginLine - 2 <= lineNr && lineNr <= region.BeginLine;

6
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Andrea Paatz" email="andrea@icsharpcode.net"/> // <owner name="Andrea Paatz" email="andrea@icsharpcode.net"/>
@ -64,7 +64,7 @@ namespace CSharpBinding.Parser
case "#endregion": case "#endregion":
--deep; --deep;
if (deep == 0) { 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; goto end;
} }
break; break;
@ -111,7 +111,7 @@ namespace CSharpBinding.Parser
void AddCommentTags(ICompilationUnit cu, System.Collections.Generic.List<ICSharpCode.NRefactory.Parser.TagComment> tagComments) void AddCommentTags(ICompilationUnit cu, System.Collections.Generic.List<ICSharpCode.NRefactory.Parser.TagComment> tagComments)
{ {
foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in 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); ICSharpCode.SharpDevelop.Dom.Tag tag = new ICSharpCode.SharpDevelop.Dom.Tag(tagComment.Tag, tagRegion);
tag.CommentString = tagComment.CommentText; tag.CommentString = tagComment.CommentText;
cu.TagComments.Add(tag); cu.TagComments.Add(tag);

12
src/AddIns/BackendBindings/VBNetBinding/Project/Src/MyNamespaceBuilder.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -49,21 +49,21 @@ namespace VBNetBinding
c.Properties.Add(new DefaultProperty("Application", c.Properties.Add(new DefaultProperty("Application",
new GetClassReturnType(pc, myApp.FullyQualifiedName), new GetClassReturnType(pc, myApp.FullyQualifiedName),
ModifierEnum.Public | ModifierEnum.Static, ModifierEnum.Public | ModifierEnum.Static,
null, null, c)); DomRegion.Empty, DomRegion.Empty, c));
c.Properties.Add(new DefaultProperty("Computer", c.Properties.Add(new DefaultProperty("Computer",
new GetClassReturnType(pc, myComp.FullyQualifiedName), new GetClassReturnType(pc, myComp.FullyQualifiedName),
ModifierEnum.Public | ModifierEnum.Static, ModifierEnum.Public | ModifierEnum.Static,
null, null, c)); DomRegion.Empty, DomRegion.Empty, c));
if (myForms != null) { if (myForms != null) {
c.Properties.Add(new DefaultProperty("Forms", c.Properties.Add(new DefaultProperty("Forms",
new GetClassReturnType(pc, myForms.FullyQualifiedName), new GetClassReturnType(pc, myForms.FullyQualifiedName),
ModifierEnum.Public | ModifierEnum.Static, ModifierEnum.Public | ModifierEnum.Static,
null, null, c)); DomRegion.Empty, DomRegion.Empty, c));
} }
c.Properties.Add(new DefaultProperty("User", c.Properties.Add(new DefaultProperty("User",
new GetClassReturnType(pc, "Microsoft.VisualBasic.ApplicationServices.User"), new GetClassReturnType(pc, "Microsoft.VisualBasic.ApplicationServices.User"),
ModifierEnum.Public | ModifierEnum.Static, ModifierEnum.Public | ModifierEnum.Static,
null, null, c)); DomRegion.Empty, DomRegion.Empty, c));
cu.Classes.Add(c); cu.Classes.Add(c);
pc.UpdateCompilationUnit(null, cu, cu.FileName, false); pc.UpdateCompilationUnit(null, cu, cu.FileName, false);
} }
@ -130,7 +130,7 @@ namespace VBNetBinding
properties.Add(new DefaultProperty(c.Name, properties.Add(new DefaultProperty(c.Name,
new GetClassReturnType(this.ProjectContent, c.FullyQualifiedName), new GetClassReturnType(this.ProjectContent, c.FullyQualifiedName),
ModifierEnum.Public | ModifierEnum.Static, ModifierEnum.Public | ModifierEnum.Static,
null, null, c)); DomRegion.Empty, DomRegion.Empty, c));
} }
} }
return properties; return properties;

6
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Parser/Parser.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Andrea Paatz" email="andrea@icsharpcode.net"/> // <owner name="Andrea Paatz" email="andrea@icsharpcode.net"/>
@ -74,7 +74,7 @@ namespace VBNetBinding.Parser
if (nextDirective.Arg.ToLower() == "region") { if (nextDirective.Arg.ToLower() == "region") {
--deep; --deep;
if (deep == 0) { 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; goto end;
} }
} }
@ -134,7 +134,7 @@ namespace VBNetBinding.Parser
{ {
foreach (ICSharpCode.NRefactory.Parser.TagComment tagComment in 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); ICSharpCode.SharpDevelop.Dom.Tag tag = new ICSharpCode.SharpDevelop.Dom.Tag(tagComment.Tag, tagRegion);
tag.CommentString = tagComment.CommentText; tag.CommentString = tagComment.CommentText;
cu.TagComments.Add(tag); cu.TagComments.Add(tag);

2
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 // You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default): // 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 // The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing. // .NET Framework documentation for more information about signing.

3
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -74,7 +74,7 @@
<Compile Include="Src\Services\LanguageBinding\LanguageBindingService.cs" /> <Compile Include="Src\Services\LanguageBinding\LanguageBindingService.cs" />
<Compile Include="Src\Dom\ICompilationUnit.cs" /> <Compile Include="Src\Dom\ICompilationUnit.cs" />
<Compile Include="Src\Dom\IClass.cs" /> <Compile Include="Src\Dom\IClass.cs" />
<Compile Include="Src\Dom\IRegion.cs" /> <Compile Include="Src\Dom\Region.cs" />
<Compile Include="Src\Dom\IField.cs" /> <Compile Include="Src\Dom\IField.cs" />
<Compile Include="Src\Dom\IReturnType.cs" /> <Compile Include="Src\Dom\IReturnType.cs" />
<Compile Include="Src\Dom\IProperty.cs" /> <Compile Include="Src\Dom\IProperty.cs" />
@ -82,7 +82,6 @@
<Compile Include="Src\Dom\IComment.cs" /> <Compile Include="Src\Dom\IComment.cs" />
<Compile Include="Src\Dom\IMethod.cs" /> <Compile Include="Src\Dom\IMethod.cs" />
<Compile Include="Src\Dom\ClassType.cs" /> <Compile Include="Src\Dom\ClassType.cs" />
<Compile Include="Src\Dom\Implementations\DefaultRegion.cs" />
<Compile Include="Src\Dom\Implementations\DefaultClass.cs" /> <Compile Include="Src\Dom\Implementations\DefaultClass.cs" />
<Compile Include="Src\Dom\Implementations\DefaultProperty.cs" /> <Compile Include="Src\Dom\Implementations\DefaultProperty.cs" />
<Compile Include="Src\Dom\Implementations\DefaultField.cs" /> <Compile Include="Src\Dom\Implementations\DefaultField.cs" />

6
src/Main/Base/Project/Src/Dom/FoldingRegion.cs

@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class FoldingRegion public class FoldingRegion
{ {
string name; string name;
IRegion region; DomRegion region;
public string Name { public string Name {
get { get {
@ -23,13 +23,13 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public IRegion Region { public DomRegion Region {
get { get {
return region; return region;
} }
} }
public FoldingRegion(string name, IRegion region) public FoldingRegion(string name, DomRegion region)
{ {
this.name = name; this.name = name;
this.region = region; this.region = region;

2
src/Main/Base/Project/Src/Dom/IClass.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
IRegion Region { DomRegion Region {
get; get;
} }

2
src/Main/Base/Project/Src/Dom/IComment.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
IRegion Region { DomRegion Region {
get; get;
} }
} }

2
src/Main/Base/Project/Src/Dom/IEvent.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public interface IEvent : IMember public interface IEvent : IMember
{ {
IRegion BodyRegion { DomRegion BodyRegion {
get; get;
} }

2
src/Main/Base/Project/Src/Dom/IMember.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
IRegion Region { DomRegion Region {
get; get;
} }

2
src/Main/Base/Project/Src/Dom/IMethod.cs

@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public interface IMethodOrProperty : IMember public interface IMethodOrProperty : IMember
{ {
IRegion BodyRegion { DomRegion BodyRegion {
get; get;
} }

2
src/Main/Base/Project/Src/Dom/IParameter.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
IRegion Region { DomRegion Region {
get; get;
} }

4
src/Main/Base/Project/Src/Dom/IProperty.cs

@ -13,11 +13,11 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public interface IProperty : IMethodOrProperty public interface IProperty : IMethodOrProperty
{ {
IRegion GetterRegion { DomRegion GetterRegion {
get; get;
} }
IRegion SetterRegion { DomRegion SetterRegion {
get; get;
} }

34
src/Main/Base/Project/Src/Dom/IRegion.cs

@ -1,34 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision$</version>
// </file>
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);
}
}

9
src/Main/Base/Project/Src/Dom/IUsing.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public interface IUsing public interface IUsing
{ {
IRegion Region { DomRegion Region {
get; get;
} }
@ -20,6 +20,13 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
bool HasAliases { get; }
void AddAlias(string alias, IReturnType type);
/// <summary>
/// Gets the list of aliases. Can be null when there are no aliases!
/// </summary>
SortedList<string, IReturnType> Aliases { SortedList<string, IReturnType> Aliases {
get; get;
} }

6
src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -13,9 +13,9 @@ namespace ICSharpCode.SharpDevelop.Dom
public abstract class AbstractMember : AbstractNamedEntity, IMember public abstract class AbstractMember : AbstractNamedEntity, IMember
{ {
IReturnType returnType; IReturnType returnType;
IRegion region; DomRegion region;
public virtual IRegion Region { public virtual DomRegion Region {
get { get {
return region; return region;
} }

4
src/Main/Base/Project/Src/Dom/Implementations/ArrayReturnType.cs

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class ArrayIndexer : DefaultProperty public class ArrayIndexer : DefaultProperty
{ {
public ArrayIndexer(IReturnType elementType) 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; IsIndexer = true;
} }
@ -80,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.Dom
List<IProperty> l = base.GetProperties(); List<IProperty> l = base.GetProperties();
ArrayIndexer property = new ArrayIndexer(elementType); ArrayIndexer property = new ArrayIndexer(elementType);
for (int i = 0; i < dimensions; ++i) { 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); l.Add(property);
return l; return l;

8
src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class DefaultClass : AbstractNamedEntity, IClass, IComparable public class DefaultClass : AbstractNamedEntity, IClass, IComparable
{ {
ClassType classType; ClassType classType;
IRegion region; DomRegion region;
ICompilationUnit compilationUnit; ICompilationUnit compilationUnit;
@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Dom
this.compilationUnit = compilationUnit; 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.compilationUnit = compilationUnit;
this.region = region; this.region = region;
@ -102,7 +102,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public IRegion Region { public DomRegion Region {
get { get {
return region; return region;
} }
@ -362,7 +362,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public IClass GetInnermostClass(int caretLine, int caretColumn) public IClass GetInnermostClass(int caretLine, int caretColumn)
{ {
foreach (IClass c in InnerClasses) { 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); return c.GetInnermostClass(caretLine, caretColumn);
} }
} }

6
src/Main/Base/Project/Src/Dom/Implementations/DefaultComment.cs

@ -16,9 +16,9 @@ namespace ICSharpCode.SharpDevelop.Dom {
bool isBlockComment; bool isBlockComment;
string commentTag; string commentTag;
string commentText; 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.isBlockComment = isBlockComment;
this.commentTag = commentTag; this.commentTag = commentTag;
@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
} }
} }
public IRegion Region { public DomRegion Region {
get { get {
return region; return region;
} }

6
src/Main/Base/Project/Src/Dom/Implementations/DefaultCompilationUnit.cs

@ -113,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public IClass GetInnermostClass(int caretLine, int caretColumn) public IClass GetInnermostClass(int caretLine, int caretColumn)
{ {
foreach (IClass c in Classes) { 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); return c.GetInnermostClass(caretLine, caretColumn);
} }
} }
@ -133,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.Dom
List<IClass> classes = new List<IClass>(); List<IClass> classes = new List<IClass>();
IClass innerMostClass = GetInnermostClass(caretLine, caretColumn); IClass innerMostClass = GetInnermostClass(caretLine, caretColumn);
foreach (IClass c in Classes) { 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) { if (c != innerMostClass) {
GetOuterClasses(classes, c, caretLine, caretColumn); GetOuterClasses(classes, c, caretLine, caretColumn);
if (!classes.Contains(c)) { if (!classes.Contains(c)) {
@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (curClass != null && curClass.InnerClasses.Count > 0) { if (curClass != null && curClass.InnerClasses.Count > 0) {
IClass innerMostClass = GetInnermostClass(caretLine, caretColumn); IClass innerMostClass = GetInnermostClass(caretLine, caretColumn);
foreach (IClass c in curClass.InnerClasses) { 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) { if (c != innerMostClass) {
GetOuterClasses(classes, c, caretLine, caretColumn); GetOuterClasses(classes, c, caretLine, caretColumn);
if (!classes.Contains(c)) { if (!classes.Contains(c)) {

6
src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs

@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable] [Serializable]
public class DefaultEvent : AbstractMember, IEvent public class DefaultEvent : AbstractMember, IEvent
{ {
protected IRegion bodyRegion; protected DomRegion bodyRegion;
protected EventAttributes eventAttributes; protected EventAttributes eventAttributes;
protected IMethod addMethod; protected IMethod addMethod;
protected IMethod removeMethod; protected IMethod removeMethod;
@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public virtual IRegion BodyRegion { public virtual DomRegion BodyRegion {
get { get {
return bodyRegion; 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.ReturnType = type;
this.Region = region; this.Region = region;

2
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.ReturnType = type;
this.Region = region; this.Region = region;

12
src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs

@ -15,14 +15,14 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable] [Serializable]
public class Constructor : DefaultMethod 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, : base("#ctor", declaringType.DefaultReturnType,
m, region, bodyRegion, declaringType) m, region, bodyRegion, declaringType)
{ {
} }
public Constructor(ModifierEnum m, IReturnType returnType) 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] [Serializable]
public class Destructor : DefaultMethod 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) : base("#dtor", null, ModifierEnum.None, region, bodyRegion, declaringType)
{ {
} }
@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable] [Serializable]
public class DefaultMethod : AbstractMember, IMethod public class DefaultMethod : AbstractMember, IMethod
{ {
protected IRegion bodyRegion; protected DomRegion bodyRegion;
List<IParameter> parameters = null; List<IParameter> parameters = null;
List<ITypeParameter> typeParameters = null; List<ITypeParameter> typeParameters = null;
@ -100,7 +100,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public virtual IRegion BodyRegion { public virtual DomRegion BodyRegion {
get { get {
return bodyRegion; 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.ReturnType = type;
this.Region = region; this.Region = region;

6
src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.SharpDevelop.Dom
protected IReturnType returnType; protected IReturnType returnType;
protected ParameterModifiers modifier; protected ParameterModifiers modifier;
protected IRegion region; protected DomRegion region;
List<IAttribute> attributes; List<IAttribute> attributes;
protected DefaultParameter(string name) protected DefaultParameter(string name)
@ -38,13 +38,13 @@ namespace ICSharpCode.SharpDevelop.Dom
this.returnType = p.ReturnType; 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; returnType = type;
this.region = region; this.region = region;
} }
public IRegion Region { public DomRegion Region {
get { get {
return region; return region;
} }

18
src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs

@ -14,10 +14,10 @@ namespace ICSharpCode.SharpDevelop.Dom {
[Serializable] [Serializable]
public class DefaultProperty : AbstractMember, IProperty public class DefaultProperty : AbstractMember, IProperty
{ {
protected IRegion bodyRegion; protected DomRegion bodyRegion = DomRegion.Empty;
IRegion getterRegion; DomRegion getterRegion = DomRegion.Empty;
IRegion setterRegion; DomRegion setterRegion = DomRegion.Empty;
protected IMethod getterMethod; protected IMethod getterMethod;
protected IMethod setterMethod; protected IMethod setterMethod;
@ -39,7 +39,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
} }
} }
public virtual IRegion BodyRegion { public virtual DomRegion BodyRegion {
get { get {
return bodyRegion; return bodyRegion;
} }
@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
} }
} }
public IRegion GetterRegion { public DomRegion GetterRegion {
get { get {
return getterRegion; return getterRegion;
} }
@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
} }
} }
public IRegion SetterRegion { public DomRegion SetterRegion {
get { get {
return setterRegion; return setterRegion;
} }
@ -97,13 +97,13 @@ namespace ICSharpCode.SharpDevelop.Dom {
public virtual bool CanGet { public virtual bool CanGet {
get { get {
return getterRegion != null; return !getterRegion.IsEmpty;
} }
} }
public virtual bool CanSet { public virtual bool CanSet {
get { 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.ReturnType = type;
this.Region = region; this.Region = region;

26
src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs

@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable] [Serializable]
public class DefaultUsing : MarshalByRefObject, IUsing public class DefaultUsing : MarshalByRefObject, IUsing
{ {
IRegion region; DomRegion region;
IProjectContent projectContent; IProjectContent projectContent;
public DefaultUsing(IProjectContent projectContent) public DefaultUsing(IProjectContent projectContent)
@ -23,15 +23,15 @@ namespace ICSharpCode.SharpDevelop.Dom
this.projectContent = projectContent; this.projectContent = projectContent;
} }
public DefaultUsing(IProjectContent projectContent, IRegion region) : this(projectContent) public DefaultUsing(IProjectContent projectContent, DomRegion region) : this(projectContent)
{ {
this.region = region; this.region = region;
} }
List<string> usings = new List<string>(); List<string> usings = new List<string>();
SortedList<string, IReturnType> aliases = new SortedList<string, IReturnType>(); SortedList<string, IReturnType> aliases = null;
public IRegion Region { public DomRegion Region {
get { get {
return region; return region;
} }
@ -49,8 +49,21 @@ 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<string, IReturnType>();
aliases.Add(alias, type);
}
public string SearchNamespace(string partitialNamespaceName) public string SearchNamespace(string partitialNamespaceName)
{ {
if (HasAliases) {
foreach (KeyValuePair<string, IReturnType> entry in aliases) { foreach (KeyValuePair<string, IReturnType> entry in aliases) {
if (!entry.Value.IsDefaultReturnType) if (!entry.Value.IsDefaultReturnType)
continue; continue;
@ -70,6 +83,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
} }
}
if (projectContent.Language.ImportNamespaces) { if (projectContent.Language.ImportNamespaces) {
foreach (string str in usings) { foreach (string str in usings) {
string possibleNamespace = String.Concat(str, ".", partitialNamespaceName); string possibleNamespace = String.Concat(str, ".", partitialNamespaceName);
@ -82,6 +96,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public IReturnType SearchType(string partitialTypeName) public IReturnType SearchType(string partitialTypeName)
{ {
if (HasAliases) {
foreach (KeyValuePair<string, IReturnType> entry in aliases) { foreach (KeyValuePair<string, IReturnType> entry in aliases) {
string aliasString = entry.Key; string aliasString = entry.Key;
if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) { if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) {
@ -99,6 +114,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
} }
}
if (projectContent.Language.ImportNamespaces) { if (projectContent.Language.ImportNamespaces) {
foreach (string str in usings) { foreach (string str in usings) {
IClass c = projectContent.GetClass(str + "." + partitialTypeName); IClass c = projectContent.GetClass(str + "." + partitialTypeName);
@ -136,12 +152,14 @@ namespace ICSharpCode.SharpDevelop.Dom
builder.Append(str); builder.Append(str);
builder.Append(", "); builder.Append(", ");
} }
if (HasAliases) {
foreach (KeyValuePair<string, IReturnType> p in aliases) { foreach (KeyValuePair<string, IReturnType> p in aliases) {
builder.Append(p.Key); builder.Append(p.Key);
builder.Append("="); builder.Append("=");
builder.Append(p.Value.ToString()); builder.Append(p.Value.ToString());
builder.Append(", "); builder.Append(", ");
} }
}
builder.Length -= 2; // remove last ", " builder.Length -= 2; // remove last ", "
builder.Append("]"); builder.Append("]");
return builder.ToString(); return builder.ToString();

54
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs

@ -166,7 +166,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (u.IsAlias) { if (u.IsAlias) {
IReturnType rt = CreateReturnType(u.Alias); IReturnType rt = CreateReturnType(u.Alias);
if (rt != null) { if (rt != null) {
us.Aliases[u.Name] = rt; us.AddAlias(u.Name, rt);
} }
} else { } else {
us.Usings.Add(u.Name); 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) 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()); DefaultClass c = new DefaultClass(cu, TranslateClassType(typeDeclaration.Type), ConvertModifier(typeDeclaration.Modifier, ModifierEnum.Internal), region, GetCurrentClass());
c.Attributes.AddRange(VisitAttributes(typeDeclaration.Attributes)); c.Attributes.AddRange(VisitAttributes(typeDeclaration.Attributes));
c.Documentation = GetDocumentation(region.BeginLine); c.Documentation = GetDocumentation(region.BeginLine);
@ -340,7 +340,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.DelegateDeclaration delegateDeclaration, object data) 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()); DefaultClass c = new DefaultClass(cu, ClassType.Delegate, ConvertModifier(delegateDeclaration.Modifier, ModifierEnum.Internal), region, GetCurrentClass());
c.Documentation = GetDocumentation(region.BeginLine); c.Documentation = GetDocumentation(region.BeginLine);
c.Attributes.AddRange(VisitAttributes(delegateDeclaration.Attributes)); c.Attributes.AddRange(VisitAttributes(delegateDeclaration.Attributes));
@ -359,24 +359,24 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
currentClass.Push(c); // necessary for CreateReturnType currentClass.Push(c); // necessary for CreateReturnType
ConvertTemplates(delegateDeclaration.Templates, c); 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) { if (delegateDeclaration.Parameters != null) {
foreach (AST.ParameterDeclarationExpression par in delegateDeclaration.Parameters) { foreach (AST.ParameterDeclarationExpression par in delegateDeclaration.Parameters) {
invokeMethod.Parameters.Add(CreateParameter(par)); invokeMethod.Parameters.Add(CreateParameter(par));
} }
} }
c.Methods.Add(invokeMethod); 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) { if (delegateDeclaration.Parameters != null) {
foreach (AST.ParameterDeclarationExpression par in delegateDeclaration.Parameters) { foreach (AST.ParameterDeclarationExpression par in delegateDeclaration.Parameters) {
invokeMethod.Parameters.Add(CreateParameter(par)); invokeMethod.Parameters.Add(CreateParameter(par));
} }
} }
invokeMethod.Parameters.Add(new DefaultParameter("callback", CreateReturnType(typeof(AsyncCallback)), null)); invokeMethod.Parameters.Add(new DefaultParameter("callback", CreateReturnType(typeof(AsyncCallback)), DomRegion.Empty));
invokeMethod.Parameters.Add(new DefaultParameter("object", ReflectionReturnType.Object, null)); invokeMethod.Parameters.Add(new DefaultParameter("object", ReflectionReturnType.Object, DomRegion.Empty));
c.Methods.Add(invokeMethod); c.Methods.Add(invokeMethod);
invokeMethod = new DefaultMethod("EndInvoke", CreateReturnType(delegateDeclaration.ReturnType), ModifierEnum.Public, null, null, c); invokeMethod = new DefaultMethod("EndInvoke", CreateReturnType(delegateDeclaration.ReturnType), ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, c);
invokeMethod.Parameters.Add(new DefaultParameter("result", CreateReturnType(typeof(IAsyncResult)), null)); invokeMethod.Parameters.Add(new DefaultParameter("result", CreateReturnType(typeof(IAsyncResult)), DomRegion.Empty));
c.Methods.Add(invokeMethod); c.Methods.Add(invokeMethod);
currentClass.Pop(); currentClass.Pop();
return c; return c;
@ -390,15 +390,15 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IParameter CreateParameter(AST.ParameterDeclarationExpression par, IMethod method) IParameter CreateParameter(AST.ParameterDeclarationExpression par, IMethod method)
{ {
IReturnType parType = CreateReturnType(par.TypeReference, 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; p.Modifiers = (ParameterModifiers)par.ParamModifier;
return p; return p;
} }
public override object Visit(AST.MethodDeclaration methodDeclaration, object data) public override object Visit(AST.MethodDeclaration methodDeclaration, object data)
{ {
DefaultRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation); DomRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1));
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultMethod method = new DefaultMethod(methodDeclaration.Name, null, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, 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) public override object Visit(AST.OperatorDeclaration operatorDeclaration, object data)
{ {
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation); DomRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : new Point(-1, -1)); 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); DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.ConvertToType), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c);
if(operatorDeclaration.Parameters != null) if(operatorDeclaration.Parameters != null)
@ -434,8 +434,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.ConstructorDeclaration constructorDeclaration, object data) public override object Visit(AST.ConstructorDeclaration constructorDeclaration, object data)
{ {
DefaultRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation); DomRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1));
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, 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) public override object Visit(AST.DestructorDeclaration destructorDeclaration, object data)
{ {
DefaultRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation); DomRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1)); DomRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1));
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
@ -466,7 +466,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.FieldDeclaration fieldDeclaration, object data) 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(); DefaultClass c = GetCurrentClass();
string doku = GetDocumentation(region.BeginLine); string doku = GetDocumentation(region.BeginLine);
if (currentClass.Count > 0) { if (currentClass.Count > 0) {
@ -493,8 +493,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.PropertyDeclaration propertyDeclaration, object data) public override object Visit(AST.PropertyDeclaration propertyDeclaration, object data)
{ {
DefaultRegion region = GetRegion(propertyDeclaration.StartLocation, propertyDeclaration.EndLocation); DomRegion region = GetRegion(propertyDeclaration.StartLocation, propertyDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd); DomRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd);
IReturnType type = CreateReturnType(propertyDeclaration.TypeReference); IReturnType type = CreateReturnType(propertyDeclaration.TypeReference);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
@ -514,8 +514,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.EventDeclaration eventDeclaration, object data) public override object Visit(AST.EventDeclaration eventDeclaration, object data)
{ {
DefaultRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation); DomRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd); DomRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd);
IReturnType type = CreateReturnType(eventDeclaration.TypeReference); IReturnType type = CreateReturnType(eventDeclaration.TypeReference);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultEvent e = null; DefaultEvent e = null;
@ -541,8 +541,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.IndexerDeclaration indexerDeclaration, object data) public override object Visit(AST.IndexerDeclaration indexerDeclaration, object data)
{ {
DefaultRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation); DomRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd); DomRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd);
DefaultProperty i = new DefaultProperty("Indexer", CreateReturnType(indexerDeclaration.TypeReference), ConvertModifier(indexerDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); DefaultProperty i = new DefaultProperty("Indexer", CreateReturnType(indexerDeclaration.TypeReference), ConvertModifier(indexerDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
i.IsIndexer = true; i.IsIndexer = true;
i.Documentation = GetDocumentation(region.BeginLine); i.Documentation = GetDocumentation(region.BeginLine);

18
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 // 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. // 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; int startLine = member.Region.BeginLine;
if (startLine < 1) return null; if (startLine < 1) return null;
IRegion bodyRegion; DomRegion bodyRegion;
if (member is IMethodOrProperty) { if (member is IMethodOrProperty) {
bodyRegion = ((IMethodOrProperty)member).BodyRegion; bodyRegion = ((IMethodOrProperty)member).BodyRegion;
} else if (member is IEvent) { } else if (member is IEvent) {
@ -411,7 +411,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} else { } else {
return null; return null;
} }
if (bodyRegion == null) return null; if (bodyRegion.IsEmpty) return null;
int endLine = bodyRegion.EndLine; int endLine = bodyRegion.EndLine;
int offset = 0; int offset = 0;
for (int i = 0; i < startLine - 1; ++i) { // -1 because the startLine must be included 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); LocalLookupVariable var = SearchVariable(identifier);
if (var != null) { if (var != null) {
IReturnType type = GetVariableType(var); 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); return new LocalResolveResult(callingMember, field, false);
} }
IParameter para = SearchMethodParameter(identifier); IParameter para = SearchMethodParameter(identifier);
@ -492,7 +492,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
if (IsSameName(identifier, "value")) { if (IsSameName(identifier, "value")) {
IProperty property = callingMember as IProperty; 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); IField field = new DefaultField(property.ReturnType, "value", ModifierEnum.None, property.Region, callingClass);
return new LocalResolveResult(callingMember, field, true); return new LocalResolveResult(callingMember, field, true);
} }
@ -650,12 +650,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (callingClass == null) if (callingClass == null)
return null; return null;
foreach (IMethod method in callingClass.Methods) { foreach (IMethod method in callingClass.Methods) {
if (method.BodyRegion != null && method.BodyRegion.IsInside(caretLine, caretColumn)) { if (method.BodyRegion.IsInside(caretLine, caretColumn)) {
return method; return method;
} }
} }
foreach (IProperty property in callingClass.Properties) { foreach (IProperty property in callingClass.Properties) {
if (property.BodyRegion != null && property.BodyRegion.IsInside(caretLine, caretColumn)) { if (property.BodyRegion.IsInside(caretLine, caretColumn)) {
return property; return property;
} }
} }
@ -939,7 +939,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
foreach (LocalLookupVariable v in pair.Value) { foreach (LocalLookupVariable v in pair.Value) {
if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) { if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) {
// convert to a field for display // 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; break;
} }
} }
@ -978,9 +978,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
} }
} }
if (u.HasAliases) {
foreach (string alias in u.Aliases.Keys) { foreach (string alias in u.Aliases.Keys) {
result.Add(alias); result.Add(alias);
} }
} }
} }
} }
}

54
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Collections; using System.Collections;
//using System.Xml;
using System.Reflection; using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -32,42 +31,65 @@ namespace ICSharpCode.SharpDevelop.Dom
if (innerClasses == null) { if (innerClasses == null) {
innerClasses = new List<IClass>(); innerClasses = new List<IClass>();
foreach (Type nestedType in type.GetNestedTypes(flags)) { 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; return innerClasses;
} }
} }
static Dictionary<ReflectionClass, List<IField>> fieldCache = new Dictionary<ReflectionClass, List<IField>>();
static Dictionary<ReflectionClass, List<IProperty>> propertyCache = new Dictionary<ReflectionClass, List<IProperty>>();
static Dictionary<ReflectionClass, List<IMethod>> methodCache = new Dictionary<ReflectionClass, List<IMethod>>();
static Dictionary<ReflectionClass, List<IEvent>> eventCache = new Dictionary<ReflectionClass, List<IEvent>>();
public static void ClearMemberCache()
{
fieldCache.Clear();
propertyCache.Clear();
methodCache.Clear();
eventCache.Clear();
}
public override List<IField> Fields { public override List<IField> Fields {
get { get {
List<IField> fields = new List<IField>(); List<IField> fields;
if (!fieldCache.TryGetValue(this, out fields)) {
fields = new List<IField>();
foreach (FieldInfo field in type.GetFields(flags)) { foreach (FieldInfo field in type.GetFields(flags)) {
if (!field.IsPublic && !field.IsFamily) continue; if (!field.IsPublic && !field.IsFamily) continue;
if (!field.IsSpecialName) { if (!field.IsSpecialName) {
fields.Add(new ReflectionField(field, this)); fields.Add(new ReflectionField(field, this));
} }
} }
fieldCache.Add(this, fields);
}
return fields; return fields;
} }
} }
public override List<IProperty> Properties { public override List<IProperty> Properties {
get { get {
List<IProperty> properties = new List<IProperty>(); List<IProperty> properties;
if (!propertyCache.TryGetValue(this, out properties)) {
properties = new List<IProperty>();
foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) { foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) {
ReflectionProperty prop = new ReflectionProperty(propertyInfo, this); ReflectionProperty prop = new ReflectionProperty(propertyInfo, this);
if (prop.IsPublic || prop.IsProtected) if (prop.IsPublic || prop.IsProtected)
properties.Add(prop); properties.Add(prop);
} }
propertyCache.Add(this, properties);
}
return properties; return properties;
} }
} }
public override List<IMethod> Methods { public override List<IMethod> Methods {
get { get {
List<IMethod> methods = new List<IMethod>(); List<IMethod> methods;
if (!methodCache.TryGetValue(this, out methods)) {
methods = new List<IMethod>();
foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) { foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) {
if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue; if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue;
@ -82,17 +104,22 @@ namespace ICSharpCode.SharpDevelop.Dom
methods.Add(newMethod); methods.Add(newMethod);
} }
} }
methodCache.Add(this, methods);
}
return methods; return methods;
} }
} }
public override List<IEvent> Events { public override List<IEvent> Events {
get { get {
List<IEvent> events = new List<IEvent>(); List<IEvent> events;
if (!eventCache.TryGetValue(this, out events)) {
events = new List<IEvent>();
foreach (EventInfo eventInfo in type.GetEvents(flags)) { foreach (EventInfo eventInfo in type.GetEvents(flags)) {
events.Add(new ReflectionEvent(eventInfo, this)); events.Add(new ReflectionEvent(eventInfo, this));
} }
eventCache.Add(this, events);
}
return events; return events;
} }
} }
@ -105,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Dom
#region VoidClass / VoidReturnType #region VoidClass / VoidReturnType
public class VoidClass : ReflectionClass 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() { protected override IReturnType CreateDefaultReturnType() {
return new VoidReturnType(this); 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; this.type = type;
string name = type.FullName.Replace('+', '.'); if (fullName.Length > 2 && fullName[fullName.Length - 2] == '`') {
if (name.Length > 2 && name[name.Length - 2] == '`') { FullyQualifiedName = fullName.Substring(0, fullName.Length - 2);
FullyQualifiedName = name.Substring(0, name.Length - 2);
} else { } else {
FullyQualifiedName = name; FullyQualifiedName = fullName;
} }
this.UseInheritanceCache = true; this.UseInheritanceCache = true;

8
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 // show the abstract layer that we have getter & setters
if (propertyInfo.CanRead) { if (propertyInfo.CanRead) {
GetterRegion = new DefaultRegion(0, 0, 0, 0); GetterRegion = new DomRegion(0, 0, 0, 0);
} else {
GetterRegion = null;
} }
if (propertyInfo.CanWrite) { if (propertyInfo.CanWrite) {
SetterRegion = new DefaultRegion(0, 0, 0, 0); SetterRegion = new DomRegion(0, 0, 0, 0);
} else {
SetterRegion = null;
} }
ParameterInfo[] parameterInfo = propertyInfo.GetIndexParameters(); ParameterInfo[] parameterInfo = propertyInfo.GetIndexParameters();

61
src/Main/Base/Project/Src/Dom/Implementations/DefaultRegion.cs → src/Main/Base/Project/Src/Dom/Region.cs

@ -7,67 +7,68 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Diagnostics;
namespace ICSharpCode.SharpDevelop.Dom {
namespace ICSharpCode.SharpDevelop.Dom
{
[Serializable] [Serializable]
public class DefaultRegion : System.MarshalByRefObject, IRegion public struct DomRegion : IComparable, IComparable<DomRegion>
{ {
protected int beginLine = -1; readonly int beginLine;
protected int endLine = -1; readonly int endLine;
protected int beginColumn = -1; readonly int beginColumn;
protected int endColumn = -1; readonly int endColumn;
public readonly static DomRegion Empty = new DomRegion(-1, -1);
public virtual int BeginLine { public bool IsEmpty {
get { get {
return beginLine; return BeginLine <= 0;
} }
} }
public virtual int BeginColumn { public int BeginLine {
get { get {
return beginColumn; return beginLine;
} }
} }
/// <value> /// <value>
/// 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 /// this stands for an unknwon end
/// </value> /// </value>
public virtual int EndColumn { public int EndLine {
get { get {
return endColumn; return endLine;
} }
set { }
endColumn = value;
public int BeginColumn {
get {
return beginColumn;
} }
} }
/// <value> /// <value>
/// 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 /// this stands for an unknwon end
/// </value> /// </value>
public virtual int EndLine { public int EndColumn {
get { get {
return endLine; return endColumn;
}
set {
endLine = value;
} }
} }
public DefaultRegion(Point start, Point end) public DomRegion(Point start, Point end)
: this(start.Y, start.X, end.Y, end.X) : this(start.Y, start.X, end.Y, end.X)
{ {
} }
public DefaultRegion(Point start) public DomRegion(Point start)
: this(start.Y, start.X) : 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.beginLine = beginLine;
this.beginColumn = beginColumn; this.beginColumn = beginColumn;
@ -75,10 +76,12 @@ namespace ICSharpCode.SharpDevelop.Dom {
this.endColumn = endColumn; this.endColumn = endColumn;
} }
public DefaultRegion(int beginLine, int beginColumn) public DomRegion(int beginLine, int beginColumn)
{ {
this.beginLine = beginLine; this.beginLine = beginLine;
this.beginColumn = beginColumn; this.beginColumn = beginColumn;
this.endLine = -1;
this.endColumn = -1;
} }
/// <remarks> /// <remarks>
@ -102,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
endColumn); endColumn);
} }
public virtual int CompareTo(IRegion value) public int CompareTo(DomRegion value)
{ {
int cmp; int cmp;
if (0 != (cmp = (BeginLine - value.BeginLine))) { if (0 != (cmp = (BeginLine - value.BeginLine))) {
@ -121,7 +124,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
} }
int IComparable.CompareTo(object value) { int IComparable.CompareTo(object value) {
return CompareTo((IRegion)value); return CompareTo((DomRegion)value);
} }
} }
} }

16
src/Main/Base/Project/Src/Dom/ResolveResult.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -207,11 +207,11 @@ namespace ICSharpCode.SharpDevelop.Dom
if (cu.FileName == null || cu.FileName.Length == 0) { if (cu.FileName == null || cu.FileName.Length == 0) {
return null; return null;
} }
IRegion reg = field.Region; DomRegion reg = field.Region;
if (reg != null) { if (!reg.IsEmpty) {
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
} else { } else {
LoggingService.Warn("GetDefinitionPosition: field.Region is null"); LoggingService.Warn("GetDefinitionPosition: field.Region is empty");
return new FilePosition(cu.FileName, Point.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) { if (cu == null || cu.FileName == null || cu.FileName.Length == 0) {
return null; return null;
} }
IRegion reg = resolvedClass.Region; DomRegion reg = resolvedClass.Region;
if (reg != null) if (!reg.IsEmpty)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else else
return new FilePosition(cu.FileName, Point.Empty); return new FilePosition(cu.FileName, Point.Empty);
@ -383,8 +383,8 @@ namespace ICSharpCode.SharpDevelop.Dom
if (cu.FileName == null || cu.FileName.Length == 0) { if (cu.FileName == null || cu.FileName.Length == 0) {
return null; return null;
} }
IRegion reg = resolvedMember.Region; DomRegion reg = resolvedMember.Region;
if (reg != null) if (!reg.IsEmpty)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn)); return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else else
return new FilePosition(cu.FileName, Point.Empty); return new FilePosition(cu.FileName, Point.Empty);

8
src/Main/Base/Project/Src/Dom/Tag.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Andrea Paatz" email="andrea@icsharpcode.net"/> // <owner name="Andrea Paatz" email="andrea@icsharpcode.net"/>
@ -21,7 +21,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
string commentString; string commentString;
IRegion region; DomRegion region;
public string CommentString { public string CommentString {
get { get {
@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public IRegion Region { public DomRegion Region {
get { get {
return region; 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.key = key;
this.region = region; this.region = region;

126
src/Main/Base/Project/Src/Dom/XmlDoc.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -19,8 +19,32 @@ namespace ICSharpCode.SharpDevelop.Dom
/// </summary> /// </summary>
public class XmlDoc : IDisposable public class XmlDoc : IDisposable
{ {
struct IndexEntry : IComparable<IndexEntry> {
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<string, string> xmlDescription = new Dictionary<string, string>(); Dictionary<string, string> xmlDescription = new Dictionary<string, string>();
Dictionary<string, int> indexDictionary; IndexEntry[] index; // SORTED array of index entries
Queue<string> 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) void ReadMembersSection(XmlTextReader reader)
{ {
@ -45,13 +69,10 @@ namespace ICSharpCode.SharpDevelop.Dom
public string GetDocumentation(string key) public string GetDocumentation(string key)
{ {
lock (xmlDescription) { lock (xmlDescription) {
if (indexDictionary != null) { string result;
if (!indexDictionary.ContainsKey(key)) if (xmlDescription.TryGetValue(key, out result))
return null; return result;
} if (index == null)
if (xmlDescription.ContainsKey(key))
return xmlDescription[key];
if (indexDictionary == null)
return null; return null;
return LoadDocumentation(key); return LoadDocumentation(key);
} }
@ -60,19 +81,23 @@ namespace ICSharpCode.SharpDevelop.Dom
#region Save binary files #region Save binary files
// FILE FORMAT FOR BINARY DOCUMENTATION // FILE FORMAT FOR BINARY DOCUMENTATION
// long magic = 0x4244636f446c6d58 (identifies file type = 'XmlDocDB') // 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) // 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) // int indexPointer (points to location where index starts in the file)
// { string docu } (all documentation strings as length-prefixed strings)
// indexPointer points to the start of the following section:
// { // {
// string key (documentation key as length-prefixed string) // 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:
// {
// int hashcode
// int index (index where the docu string starts in the file) // 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) void Save(string fileName, DateTime fileDate)
{ {
using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) { 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(version);
w.Write(fileDate.Ticks); w.Write(fileDate.Ticks);
IndexEntry[] index = new IndexEntry[xmlDescription.Count];
w.Write(index.Length);
int indexPointerPos = (int)fs.Position; int indexPointerPos = (int)fs.Position;
w.Write(0); // skip 4 bytes w.Write(0); // skip 4 bytes
int[] indices = new int[xmlDescription.Count];
int i = 0; int i = 0;
foreach (KeyValuePair<string, string> p in xmlDescription) { foreach (KeyValuePair<string, string> 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()); w.Write(p.Value.Trim());
i += 1;
} }
Array.Sort(index);
int indexStart = (int)fs.Position; int indexStart = (int)fs.Position;
i = 0; foreach (IndexEntry entry in index) {
foreach (KeyValuePair<string, string> p in xmlDescription) { w.Write(entry.HashCode);
w.Write(p.Key); w.Write(entry.FileLocation);
w.Write(indices[i++]);
} }
w.Seek(indexPointerPos, SeekOrigin.Begin); w.Seek(indexPointerPos, SeekOrigin.Begin);
w.Write(indexStart); w.Write(indexStart);
@ -107,12 +137,9 @@ namespace ICSharpCode.SharpDevelop.Dom
#region Load binary files #region Load binary files
BinaryReader loader; BinaryReader loader;
FileStream fs; FileStream fs;
Queue<string> keyCacheQueue;
const int cacheLength = 150; // number of strings to cache when working in file-mode
bool LoadFromBinary(string fileName, DateTime fileDate) bool LoadFromBinary(string fileName, DateTime fileDate)
{ {
indexDictionary = new Dictionary<string, int>();
keyCacheQueue = new Queue<string>(cacheLength); keyCacheQueue = new Queue<string>(cacheLength);
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
int len = (int)fs.Length; int len = (int)fs.Length;
@ -130,21 +157,18 @@ namespace ICSharpCode.SharpDevelop.Dom
LoggingService.Info("Not loading XmlDoc: file changed since cache was created"); LoggingService.Info("Not loading XmlDoc: file changed since cache was created");
return false; return false;
} }
int count = loader.ReadInt32();
int indexStartPosition = loader.ReadInt32(); // go to start of index int indexStartPosition = loader.ReadInt32(); // go to start of index
if (indexStartPosition >= len) { if (indexStartPosition >= len) {
LoggingService.Error("XmlDoc: Cannot find index, cache invalid!"); LoggingService.Error("XmlDoc: Cannot find index, cache invalid!");
return false; return false;
} }
fs.Position = indexStartPosition; fs.Position = indexStartPosition;
while (fs.Position < len) { IndexEntry[] index = new IndexEntry[count];
string key = loader.ReadString(); for (int i = 0; i < index.Length; i++) {
int pos = loader.ReadInt32(); index[i] = new IndexEntry(loader.ReadInt32(), loader.ReadInt32());
indexDictionary.Add(key, pos);
}
if (fs.Position > len) {
LoggingService.Error("XmlDoc: Jumped over end of file, cache invalid!");
return false;
} }
this.index = index;
return true; return true;
} catch (Exception ex) { } catch (Exception ex) {
LoggingService.Error("Cannot load from cache", ex); LoggingService.Error("Cannot load from cache", ex);
@ -157,12 +181,34 @@ namespace ICSharpCode.SharpDevelop.Dom
if (keyCacheQueue.Count > cacheLength - 1) { if (keyCacheQueue.Count > cacheLength - 1) {
xmlDescription.Remove(keyCacheQueue.Dequeue()); xmlDescription.Remove(keyCacheQueue.Dequeue());
} }
int pos = indexDictionary[key];
fs.Position = pos; int hashcode = key.GetHashCode();
string docu = loader.ReadString();
xmlDescription.Add(key, docu); // use interpolation search to find the item
keyCacheQueue.Enqueue(docu); string resultDocu = null;
return docu;
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() public void Dispose()
@ -172,7 +218,7 @@ namespace ICSharpCode.SharpDevelop.Dom
fs.Close(); fs.Close();
} }
xmlDescription = null; xmlDescription = null;
indexDictionary = null; index = null;
keyCacheQueue = null; keyCacheQueue = null;
loader = null; loader = null;
fs = null; fs = null;
@ -198,7 +244,7 @@ namespace ICSharpCode.SharpDevelop.Dom
static string MakeTempPath() static string MakeTempPath()
{ {
string tempPath = Path.Combine(Path.GetTempPath(), "SharpDevelop/DocumentationCache"); string tempPath = Path.Combine(Path.GetTempPath(), tempPathName);
if (!Directory.Exists(tempPath)) if (!Directory.Exists(tempPath))
Directory.CreateDirectory(tempPath); Directory.CreateDirectory(tempPath);
return tempPath; return tempPath;

4
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs

@ -54,9 +54,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public override void ActivateItem() public override void ActivateItem()
{ {
if (c.CompilationUnit != null) { if (c.CompilationUnit != null) {
FileService.JumpToFilePosition(c.CompilationUnit.FileName, FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1);
c.Region != null ? c.Region.BeginLine - 1 : 0,
c.Region != null ? c.Region.BeginColumn - 1 : 0);
} }
} }

2
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs

@ -63,11 +63,9 @@ namespace ICSharpCode.SharpDevelop.Gui
this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu"; this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu";
declaringType = member.DeclaringType; declaringType = member.DeclaringType;
modifiers = member.Modifiers; modifiers = member.Modifiers;
if (member.Region != null) {
line = member.Region.BeginLine; line = member.Region.BeginLine;
column = member.Region.BeginColumn; column = member.Region.BeginColumn;
} }
}
public static string GetText(IMember member) public static string GetText(IMember member)
{ {

16
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop.Gui
static Panel panel = null; static Panel panel = null;
static ComboBox comboBox = null; static ComboBox comboBox = null;
static PropertyGrid grid = null; static PropertyGrid grid = new PropertyGrid();
static IDesignerHost host = null; static IDesignerHost host = null;
public static PropertyGrid Grid { public static PropertyGrid Grid {
@ -85,7 +85,11 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
public static event PropertyValueChangedEventHandler PropertyValueChanged; 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 { public override Control Control {
get { get {
@ -95,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Gui
static PropertyPad() static PropertyPad()
{ {
grid = new PropertyGrid();
grid.PropertySort = PropertyService.Get("FormsDesigner.DesignerOptions.PropertyGridSortAlphabetical", false) ? PropertySort.Alphabetical : PropertySort.CategorizedAlphabetical; grid.PropertySort = PropertyService.Get("FormsDesigner.DesignerOptions.PropertyGridSortAlphabetical", false) ? PropertySort.Alphabetical : PropertySort.CategorizedAlphabetical;
grid.Dock = DockStyle.Fill; grid.Dock = DockStyle.Fill;
@ -210,9 +213,6 @@ namespace ICSharpCode.SharpDevelop.Gui
selectionService.SetSelectedComponents(new object[] { }); selectionService.SetSelectedComponents(new object[] { });
} }
} }
if (SelectedObjectChanged != null) {
SelectedObjectChanged(this, EventArgs.Empty);
}
} }
} }
@ -338,8 +338,12 @@ namespace ICSharpCode.SharpDevelop.Gui
ICSharpCode.SharpDevelop.Dom.IClass c = ProjectContentRegistry.WinForms.GetClass(component.FullName); ICSharpCode.SharpDevelop.Dom.IClass c = ProjectContentRegistry.WinForms.GetClass(component.FullName);
if (c != null) { if (c != null) {
foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) { foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) {
if (gridItem.PropertyDescriptor.Name == p.Name) {
ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(p); ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(p);
return;
}
} }
ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(c);
} }
} }
} }

2
src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs

@ -89,7 +89,7 @@ namespace ICSharpCode.Core
public string Convert(Type type) 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) public string Convert(FieldInfo field)

4
src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

@ -634,7 +634,7 @@ namespace ICSharpCode.Core
{ {
IClass curClass = GetClass(fullMemberName, LanguageProperties.CSharp, false); IClass curClass = GetClass(fullMemberName, LanguageProperties.CSharp, false);
if (curClass != null) { 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('.'); int pos = fullMemberName.LastIndexOf('.');
if (pos > 0) { if (pos > 0) {
@ -644,7 +644,7 @@ namespace ICSharpCode.Core
if (curClass != null) { if (curClass != null) {
IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp); IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp);
if (member != null) { 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);
} }
} }
} }

6
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -185,9 +185,15 @@ namespace ICSharpCode.Core
LoggingService.Info("ParserUpdateThread started"); LoggingService.Info("ParserUpdateThread started");
// preload mscorlib, we're going to need it anyway // preload mscorlib, we're going to need it anyway
IProjectContent dummyVar = ProjectContentRegistry.Mscorlib; IProjectContent dummyVar = ProjectContentRegistry.Mscorlib;
int counter = 0;
while (!abortParserUpdateThread) { while (!abortParserUpdateThread) {
try { try {
if (++counter == 10) {
ReflectionClass.ClearMemberCache();
counter = 0;
}
ParserUpdateStep(); ParserUpdateStep();
} catch (Exception e) { } catch (Exception e) {
ICSharpCode.Core.MessageService.ShowError(e); ICSharpCode.Core.MessageService.ShowError(e);

7
src/Main/Base/Project/Src/Services/ParserService/ReflectionProjectContent.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -35,8 +35,9 @@ namespace ICSharpCode.Core
try { try {
foreach (Type type in assembly.GetExportedTypes()) { foreach (Type type in assembly.GetExportedTypes()) {
if (!type.IsNested) { string name = type.FullName;
AddClassToNamespaceListInternal(new ReflectionClass(assemblyCompilationUnit, type, null)); if (name.IndexOf('+') < 0) { // type.IsNested
AddClassToNamespaceListInternal(new ReflectionClass(assemblyCompilationUnit, type, name, null));
} }
} }
} catch (Exception ex) { } catch (Exception ex) {

8
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs

@ -116,12 +116,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return null; return null;
} }
foreach (IMethod method in callingClass.Methods) { foreach (IMethod method in callingClass.Methods) {
if (method.BodyRegion != null && method.BodyRegion.IsInside(caretLine, caretColumn)) { if (method.BodyRegion.IsInside(caretLine, caretColumn)) {
return method; return method;
} }
} }
foreach (IProperty property in callingClass.Properties) { foreach (IProperty property in callingClass.Properties) {
if (property.BodyRegion != null && property.BodyRegion.IsInside(caretLine, caretColumn)) { if (property.BodyRegion.IsInside(caretLine, caretColumn)) {
return property; return property;
} }
} }
@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return MakeItem(c.FullyQualifiedName, new ClassNode(c.ProjectContent.Project, c), c.CompilationUnit, c.Region); 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]); 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(titleItem);
//item.DropDown.Items.Add(new ToolStripSeparator()); //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}"), ToolStripMenuItem gotoDefinitionItem = new ToolStripMenuItem(StringParser.Parse("${res:ICSharpCode.NAntAddIn.GotoDefinitionMenuLabel}"),
ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GotoArrowIndex]); ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GotoArrowIndex]);
gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter; gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter;

2
src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs

@ -105,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
RenameReferences(list, newName); RenameReferences(list, newName);
} }
void AddDeclarationAsReference(List<Reference> list, string fileName, IRegion region, string name) void AddDeclarationAsReference(List<Reference> list, string fileName, DomRegion region, string name)
{ {
if (fileName == null) if (fileName == null)
return; return;

2
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 == null) continue;
if (derivedClass.CompilationUnit.FileName == null) continue; if (derivedClass.CompilationUnit.FileName == null) continue;
IMember m = RefactoringService.FindSimilarMember(derivedClass, member); 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)); SearchResult res = new SimpleSearchResult(m.FullyQualifiedName, new Point(m.Region.BeginColumn - 1, m.Region.BeginLine - 1));
res.ProvidedDocumentInformation = GetDocumentInformation(derivedClass.CompilationUnit.FileName); res.ProvidedDocumentInformation = GetDocumentInformation(derivedClass.CompilationUnit.FileName);
results.Add(res); results.Add(res);

4
src/Main/Base/Project/Src/TextEditor/Commands/ParserBookmarkMenuBuilderBase.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
if (cu != null) { if (cu != null) {
string fileName = cu.FileName; string fileName = cu.FileName;
if (fileName != null) { 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); viewContent = FileService.JumpToFilePosition(fileName, member.Region.BeginLine - 1, member.Region.BeginColumn - 1);
} else { } else {
FileService.OpenFile(fileName); FileService.OpenFile(fileName);
@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
if (cu != null) { if (cu != null) {
string fileName = cu.FileName; string fileName = cu.FileName;
if (fileName != null) { if (fileName != null) {
if (member.Region != null && member.Region.EndLine > 0) { if (!member.Region.IsEmpty) {
viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine, 0); viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine, 0);
} else { } else {
FileService.OpenFile(fileName); FileService.OpenFile(fileName);

4
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs

@ -341,9 +341,9 @@ namespace ICSharpCode.SharpDevelop.Gui
Close(); 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); FileService.JumpToFilePosition(fileName, region.BeginLine - 1, region.BeginColumn - 1);
} }
} }

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CommentCompletionDataProvider.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
/// <remarks> /// <remarks>
/// Returns true, if the given coordinates (row, column) are in the region. /// Returns true, if the given coordinates (row, column) are in the region.
/// </remarks> /// </remarks>
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); return row >= region.BeginLine && (row <= region.EndLine || region.EndLine == -1);
} }

10
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) { if (c.ClassType == ClassType.Delegate) {
return; 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, FoldMarker newFoldMarker = new FoldMarker(document, c.Region.BeginLine - 1, c.Region.BeginColumn - 1,
c.Region.EndLine - 1, c.Region.EndColumn, FoldType.TypeBody); c.Region.EndLine - 1, c.Region.EndColumn, FoldType.TypeBody);
if (newFoldMarker.Length > 0) { if (newFoldMarker.Length > 0) {
@ -34,22 +34,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
foreach (IMethod m in c.Methods) { 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, foldMarkers.Add(new FoldMarker(document, m.Region.EndLine - 1, m.Region.EndColumn - 1,
m.BodyRegion.EndLine - 1, m.BodyRegion.EndColumn - 1, FoldType.MemberBody)); m.BodyRegion.EndLine - 1, m.BodyRegion.EndColumn - 1, FoldType.MemberBody));
} }
} }
foreach (IProperty p in c.Properties) { 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, foldMarkers.Add(new FoldMarker(document, p.Region.EndLine - 1, p.Region.EndColumn - 1,
p.BodyRegion.EndLine- 1, p.BodyRegion.EndColumn - 1, FoldType.MemberBody)); p.BodyRegion.EndLine- 1, p.BodyRegion.EndColumn - 1, FoldType.MemberBody));
} }
} }
foreach (IEvent evt in c.Events) { foreach (IEvent evt in c.Events) {
if (evt.BodyRegion != null && evt.Region.EndLine < evt.BodyRegion.EndLine) { if (evt.Region.EndLine < evt.BodyRegion.EndLine) {
if (evt.BodyRegion != null) { if (!evt.BodyRegion.IsEmpty) {
foldMarkers.Add(new FoldMarker(document, evt.Region.EndLine - 1, evt.Region.EndColumn - 1, foldMarkers.Add(new FoldMarker(document, evt.Region.EndLine - 1, evt.Region.EndColumn - 1,
evt.BodyRegion.EndLine- 1, evt.BodyRegion.EndColumn - 1, FoldType.MemberBody)); evt.BodyRegion.EndLine- 1, evt.BodyRegion.EndColumn - 1, FoldType.MemberBody));
} }

20
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 { get {
IClass classItem = item as IClass; IClass classItem = item as IClass;
if (item is IClass) if (item is IClass)
@ -59,14 +59,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
else if (item is IMember) else if (item is IMember)
return ((IMember)item).Region; return ((IMember)item).Region;
else else
return null; return DomRegion.Empty;
} }
} }
public int Line { public int Line {
get { get {
IRegion r = this.ItemRegion; DomRegion r = this.ItemRegion;
if (r == null) if (r.IsEmpty)
return 0; return 0;
else else
return r.BeginLine - 1; return r.BeginLine - 1;
@ -75,8 +75,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public int Column { public int Column {
get { get {
IRegion r = this.ItemRegion; DomRegion r = this.ItemRegion;
if (r == null) if (r.IsEmpty)
return 0; return 0;
else else
return r.BeginColumn - 1; return r.BeginColumn - 1;
@ -85,8 +85,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public int EndLine { public int EndLine {
get { get {
IRegion r = this.ItemRegion; DomRegion r = this.ItemRegion;
if (r == null) if (r.IsEmpty)
return 0; return 0;
else else
return r.EndLine - 1; return r.EndLine - 1;
@ -107,14 +107,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
return false; return false;
IClass classItem = item as IClass; IClass classItem = item as IClass;
if (classItem != null) { if (classItem != null) {
if (classItem.Region == null) if (classItem.Region.IsEmpty)
return false; return false;
return classItem.Region.BeginLine - 1 <= lineNumber && return classItem.Region.BeginLine - 1 <= lineNumber &&
classItem.Region.EndLine - 1 >= lineNumber; classItem.Region.EndLine - 1 >= lineNumber;
} }
IMember member = item as IMember; IMember member = item as IMember;
if (member == null || member.Region == null) { if (member == null || member.Region.IsEmpty) {
return false; return false;
} }
bool isInside = member.Region.BeginLine - 1 <= lineNumber; bool isInside = member.Region.BeginLine - 1 <= lineNumber;

10
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) 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)); bm.AddMark(new Bookmarks.ClassBookmark(textAreaControl.Document, c));
} }
foreach (IClass innerClass in c.InnerClasses) { foreach (IClass innerClass in c.InnerClasses) {
AddClassMemberBookmarks(bm, innerClass); AddClassMemberBookmarks(bm, innerClass);
} }
foreach (IMethod m in c.Methods) { 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)); bm.AddMark(new Bookmarks.MethodBookmark(textAreaControl.Document, m));
} }
foreach (IProperty m in c.Properties) { 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)); bm.AddMark(new Bookmarks.PropertyBookmark(textAreaControl.Document, m));
} }
foreach (IField f in c.Fields) { 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)); bm.AddMark(new Bookmarks.FieldBookmark(textAreaControl.Document, f));
} }
foreach (IEvent e in c.Events) { 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)); bm.AddMark(new Bookmarks.EventBookmark(textAreaControl.Document, e));
} }
} }

6
src/Main/Base/Test/ReflectionLayerTests.cs

@ -1,4 +1,4 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -44,8 +44,8 @@ namespace ICSharpCode.SharpDevelop.Tests
[Test] [Test]
public void ParameterComparisonTest() public void ParameterComparisonTest()
{ {
DefaultParameter p1 = new DefaultParameter("a", pc.GetClass("System.String").DefaultReturnType, null); DefaultParameter p1 = new DefaultParameter("a", pc.GetClass("System.String").DefaultReturnType, DomRegion.Empty);
DefaultParameter p2 = new DefaultParameter("b", new GetClassReturnType(pc, "System.String"), null); DefaultParameter p2 = new DefaultParameter("b", new GetClassReturnType(pc, "System.String"), DomRegion.Empty);
List<IParameter> a1 = new List<IParameter>(); List<IParameter> a1 = new List<IParameter>();
List<IParameter> a2 = new List<IParameter>(); List<IParameter> a2 = new List<IParameter>();
a1.Add(p1); a1.Add(p1);

Loading…
Cancel
Save