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. 90
      src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs
  29. 54
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  30. 22
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  31. 94
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs
  32. 8
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs
  33. 67
      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. 6
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs
  39. 20
      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 @@ -106,7 +106,7 @@ namespace CSharpBinding
ResolveResult resolveResult = ParserService.Resolve(result, editor.ActiveTextAreaControl.Caret.Line, editor.ActiveTextAreaControl.Caret.Column, editor.FileName, documentText);
if (resolveResult != null && resolveResult.ResolvedType != null) {
IClass underlyingClass = resolveResult.ResolvedType.GetUnderlyingClass();
if (underlyingClass.IsTypeInInheritanceTree(ProjectContentRegistry.Mscorlib.GetClass("System.MulticastDelegate"))) {
if (underlyingClass != null && underlyingClass.IsTypeInInheritanceTree(ProjectContentRegistry.Mscorlib.GetClass("System.MulticastDelegate"))) {
EventHandlerCompletitionDataProvider eventHandlerProvider = new EventHandlerCompletitionDataProvider(result.Expression, resolveResult);
eventHandlerProvider.InsertSpace = true;
editor.ShowCompletionWindow(eventHandlerProvider, ch);

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -233,9 +233,9 @@ namespace CSharpBinding.FormattingStrategy @@ -233,9 +233,9 @@ namespace CSharpBinding.FormattingStrategy
bool IsBeforeRegion(TextArea textArea, IRegion region, int lineNr)
bool IsBeforeRegion(TextArea textArea, DomRegion region, int lineNr)
{
if (region == null) {
if (region.IsEmpty) {
return false;
}
return region.BeginLine - 2 <= lineNr && lineNr <= region.BeginLine;

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

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

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

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

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

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

2
src/AddIns/Misc/HtmlHelp2/Project/Configuration/AssemblyInfo.cs

@ -31,7 +31,7 @@ using System.Runtime.CompilerServices; @@ -31,7 +31,7 @@ using System.Runtime.CompilerServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.3")]
[assembly: AssemblyVersion("2.0.0.1")]
// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.

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

@ -74,7 +74,7 @@ @@ -74,7 +74,7 @@
<Compile Include="Src\Services\LanguageBinding\LanguageBindingService.cs" />
<Compile Include="Src\Dom\ICompilationUnit.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\IReturnType.cs" />
<Compile Include="Src\Dom\IProperty.cs" />
@ -82,7 +82,6 @@ @@ -82,7 +82,6 @@
<Compile Include="Src\Dom\IComment.cs" />
<Compile Include="Src\Dom\IMethod.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\DefaultProperty.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 @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class FoldingRegion
{
string name;
IRegion region;
DomRegion region;
public string Name {
get {
@ -23,13 +23,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -23,13 +23,13 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public IRegion Region {
public DomRegion Region {
get {
return region;
}
}
public FoldingRegion(string name, IRegion region)
public FoldingRegion(string name, DomRegion region)
{
this.name = name;
this.region = region;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,34 +0,0 @@ @@ -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 @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
public interface IUsing
{
IRegion Region {
DomRegion Region {
get;
}
@ -20,6 +20,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -20,6 +20,13 @@ namespace ICSharpCode.SharpDevelop.Dom
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 {
get;
}

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

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

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

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class ArrayIndexer : DefaultProperty
{
public ArrayIndexer(IReturnType elementType)
: base("Indexer", elementType, ModifierEnum.Public, null, null, ReflectionReturnType.Array.GetUnderlyingClass())
: base("Indexer", elementType, ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, ReflectionReturnType.Array.GetUnderlyingClass())
{
IsIndexer = true;
}
@ -80,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -80,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.Dom
List<IProperty> l = base.GetProperties();
ArrayIndexer property = new ArrayIndexer(elementType);
for (int i = 0; i < dimensions; ++i) {
property.Parameters.Add(new DefaultParameter("index", ReflectionReturnType.Int, null));
property.Parameters.Add(new DefaultParameter("index", ReflectionReturnType.Int, DomRegion.Empty));
}
l.Add(property);
return l;

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

@ -19,7 +19,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -19,7 +19,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class DefaultClass : AbstractNamedEntity, IClass, IComparable
{
ClassType classType;
IRegion region;
DomRegion region;
ICompilationUnit compilationUnit;
@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Dom
this.compilationUnit = compilationUnit;
}
public DefaultClass(ICompilationUnit compilationUnit, ClassType classType, ModifierEnum modifiers, IRegion region, IClass declaringType) : base(declaringType)
public DefaultClass(ICompilationUnit compilationUnit, ClassType classType, ModifierEnum modifiers, DomRegion region, IClass declaringType) : base(declaringType)
{
this.compilationUnit = compilationUnit;
this.region = region;
@ -102,7 +102,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -102,7 +102,7 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public IRegion Region {
public DomRegion Region {
get {
return region;
}
@ -362,7 +362,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -362,7 +362,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public IClass GetInnermostClass(int caretLine, int caretColumn)
{
foreach (IClass c in InnerClasses) {
if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) {
if (c != null && c.Region.IsInside(caretLine, caretColumn)) {
return c.GetInnermostClass(caretLine, caretColumn);
}
}

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

@ -16,9 +16,9 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -16,9 +16,9 @@ namespace ICSharpCode.SharpDevelop.Dom {
bool isBlockComment;
string commentTag;
string commentText;
IRegion region;
DomRegion region;
public DefaultComment(bool isBlockComment, string commentTag, string commentText, IRegion region)
public DefaultComment(bool isBlockComment, string commentTag, string commentText, DomRegion region)
{
this.isBlockComment = isBlockComment;
this.commentTag = commentTag;
@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
}
}
public IRegion Region {
public DomRegion Region {
get {
return region;
}

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

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

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

@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable]
public class DefaultEvent : AbstractMember, IEvent
{
protected IRegion bodyRegion;
protected DomRegion bodyRegion;
protected EventAttributes eventAttributes;
protected IMethod addMethod;
protected IMethod removeMethod;
@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -25,7 +25,7 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public virtual IRegion BodyRegion {
public virtual DomRegion BodyRegion {
get {
return bodyRegion;
}
@ -46,7 +46,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -46,7 +46,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
}
public DefaultEvent(string name, IReturnType type, ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType, name)
public DefaultEvent(string name, IReturnType type, ModifierEnum m, DomRegion region, DomRegion bodyRegion, IClass declaringType) : base(declaringType, name)
{
this.ReturnType = type;
this.Region = region;

2
src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
}
public DefaultField(IReturnType type, string name, ModifierEnum m, IRegion region, IClass declaringType) : base(declaringType, name)
public DefaultField(IReturnType type, string name, ModifierEnum m, DomRegion region, IClass declaringType) : base(declaringType, name)
{
this.ReturnType = type;
this.Region = region;

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

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

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

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

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

@ -14,10 +14,10 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -14,10 +14,10 @@ namespace ICSharpCode.SharpDevelop.Dom {
[Serializable]
public class DefaultProperty : AbstractMember, IProperty
{
protected IRegion bodyRegion;
protected DomRegion bodyRegion = DomRegion.Empty;
IRegion getterRegion;
IRegion setterRegion;
DomRegion getterRegion = DomRegion.Empty;
DomRegion setterRegion = DomRegion.Empty;
protected IMethod getterMethod;
protected IMethod setterMethod;
@ -39,7 +39,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -39,7 +39,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
}
}
public virtual IRegion BodyRegion {
public virtual DomRegion BodyRegion {
get {
return bodyRegion;
}
@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
}
}
public IRegion GetterRegion {
public DomRegion GetterRegion {
get {
return getterRegion;
}
@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
}
}
public IRegion SetterRegion {
public DomRegion SetterRegion {
get {
return setterRegion;
}
@ -97,13 +97,13 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -97,13 +97,13 @@ namespace ICSharpCode.SharpDevelop.Dom {
public virtual bool CanGet {
get {
return getterRegion != null;
return !getterRegion.IsEmpty;
}
}
public virtual bool CanSet {
get {
return setterRegion != null;
return !setterRegion.IsEmpty;
}
}
@ -111,7 +111,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -111,7 +111,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
{
}
public DefaultProperty(string name, IReturnType type, ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType, name)
public DefaultProperty(string name, IReturnType type, ModifierEnum m, DomRegion region, DomRegion bodyRegion, IClass declaringType) : base(declaringType, name)
{
this.ReturnType = type;
this.Region = region;

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

@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable]
public class DefaultUsing : MarshalByRefObject, IUsing
{
IRegion region;
DomRegion region;
IProjectContent projectContent;
public DefaultUsing(IProjectContent projectContent)
@ -23,15 +23,15 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -23,15 +23,15 @@ namespace ICSharpCode.SharpDevelop.Dom
this.projectContent = projectContent;
}
public DefaultUsing(IProjectContent projectContent, IRegion region) : this(projectContent)
public DefaultUsing(IProjectContent projectContent, DomRegion region) : this(projectContent)
{
this.region = region;
}
List<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 {
return region;
}
@ -49,23 +49,37 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -49,23 +49,37 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public bool HasAliases {
get {
return aliases != null && aliases.Count > 0;
}
}
public void AddAlias(string alias, IReturnType type)
{
if (aliases == null) aliases = new SortedList<string, IReturnType>();
aliases.Add(alias, type);
}
public string SearchNamespace(string partitialNamespaceName)
{
foreach (KeyValuePair<string, IReturnType> entry in aliases) {
if (!entry.Value.IsDefaultReturnType)
continue;
string aliasString = entry.Key;
string nsName;
if (projectContent.Language.NameComparer.Equals(partitialNamespaceName, aliasString)) {
nsName = entry.Value.FullyQualifiedName;
if (projectContent.NamespaceExists(nsName))
return nsName;
}
if (partitialNamespaceName.Length > aliasString.Length) {
if (projectContent.Language.NameComparer.Equals(partitialNamespaceName.Substring(0, aliasString.Length + 1), aliasString + ".")) {
nsName = String.Concat(entry.Value.FullyQualifiedName, partitialNamespaceName.Remove(0, aliasString.Length));
if (projectContent.NamespaceExists(nsName)) {
if (HasAliases) {
foreach (KeyValuePair<string, IReturnType> entry in aliases) {
if (!entry.Value.IsDefaultReturnType)
continue;
string aliasString = entry.Key;
string nsName;
if (projectContent.Language.NameComparer.Equals(partitialNamespaceName, aliasString)) {
nsName = entry.Value.FullyQualifiedName;
if (projectContent.NamespaceExists(nsName))
return nsName;
}
if (partitialNamespaceName.Length > aliasString.Length) {
if (projectContent.Language.NameComparer.Equals(partitialNamespaceName.Substring(0, aliasString.Length + 1), aliasString + ".")) {
nsName = String.Concat(entry.Value.FullyQualifiedName, partitialNamespaceName.Remove(0, aliasString.Length));
if (projectContent.NamespaceExists(nsName)) {
return nsName;
}
}
}
}
@ -82,19 +96,21 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -82,19 +96,21 @@ namespace ICSharpCode.SharpDevelop.Dom
public IReturnType SearchType(string partitialTypeName)
{
foreach (KeyValuePair<string, IReturnType> entry in aliases) {
string aliasString = entry.Key;
if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) {
if (entry.Value.IsDefaultReturnType && entry.Value.GetUnderlyingClass() == null)
continue; // type not found, maybe entry was a namespace
return entry.Value;
}
if (partitialTypeName.Length > aliasString.Length) {
if (projectContent.Language.NameComparer.Equals(partitialTypeName.Substring(0, aliasString.Length + 1), aliasString + ".")) {
string className = entry.Value.FullyQualifiedName + partitialTypeName.Remove(0, aliasString.Length);
IClass c = projectContent.GetClass(className);
if (c != null) {
return c.DefaultReturnType;
if (HasAliases) {
foreach (KeyValuePair<string, IReturnType> entry in aliases) {
string aliasString = entry.Key;
if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) {
if (entry.Value.IsDefaultReturnType && entry.Value.GetUnderlyingClass() == null)
continue; // type not found, maybe entry was a namespace
return entry.Value;
}
if (partitialTypeName.Length > aliasString.Length) {
if (projectContent.Language.NameComparer.Equals(partitialTypeName.Substring(0, aliasString.Length + 1), aliasString + ".")) {
string className = entry.Value.FullyQualifiedName + partitialTypeName.Remove(0, aliasString.Length);
IClass c = projectContent.GetClass(className);
if (c != null) {
return c.DefaultReturnType;
}
}
}
}
@ -136,11 +152,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -136,11 +152,13 @@ namespace ICSharpCode.SharpDevelop.Dom
builder.Append(str);
builder.Append(", ");
}
foreach (KeyValuePair<string, IReturnType> p in aliases) {
builder.Append(p.Key);
builder.Append("=");
builder.Append(p.Value.ToString());
builder.Append(", ");
if (HasAliases) {
foreach (KeyValuePair<string, IReturnType> p in aliases) {
builder.Append(p.Key);
builder.Append("=");
builder.Append(p.Value.ToString());
builder.Append(", ");
}
}
builder.Length -= 2; // remove last ", "
builder.Append("]");

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

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

22
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs

@ -400,10 +400,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -400,10 +400,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
// mode that does not parse the method bodies for the normal run (in the ParserUpdateThread or
// SolutionLoadThread). That could improve the parser's speed dramatically.
if (member.Region == null) return null;
if (member.Region.IsEmpty) return null;
int startLine = member.Region.BeginLine;
if (startLine < 1) return null;
IRegion bodyRegion;
DomRegion bodyRegion;
if (member is IMethodOrProperty) {
bodyRegion = ((IMethodOrProperty)member).BodyRegion;
} else if (member is IEvent) {
@ -411,7 +411,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -411,7 +411,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} else {
return null;
}
if (bodyRegion == null) return null;
if (bodyRegion.IsEmpty) return null;
int endLine = bodyRegion.EndLine;
int offset = 0;
for (int i = 0; i < startLine - 1; ++i) { // -1 because the startLine must be included
@ -482,7 +482,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -482,7 +482,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
LocalLookupVariable var = SearchVariable(identifier);
if (var != null) {
IReturnType type = GetVariableType(var);
IField field = new DefaultField(type, identifier, ModifierEnum.None, new DefaultRegion(var.StartPos, var.EndPos), callingClass);
IField field = new DefaultField(type, identifier, ModifierEnum.None, new DomRegion(var.StartPos, var.EndPos), callingClass);
return new LocalResolveResult(callingMember, field, false);
}
IParameter para = SearchMethodParameter(identifier);
@ -492,7 +492,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -492,7 +492,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
if (IsSameName(identifier, "value")) {
IProperty property = callingMember as IProperty;
if (property != null && property.SetterRegion != null && property.SetterRegion.IsInside(caretLine, caretColumn)) {
if (property != null && property.SetterRegion.IsInside(caretLine, caretColumn)) {
IField field = new DefaultField(property.ReturnType, "value", ModifierEnum.None, property.Region, callingClass);
return new LocalResolveResult(callingMember, field, true);
}
@ -650,12 +650,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -650,12 +650,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (callingClass == null)
return null;
foreach (IMethod method in callingClass.Methods) {
if (method.BodyRegion != null && method.BodyRegion.IsInside(caretLine, caretColumn)) {
if (method.BodyRegion.IsInside(caretLine, caretColumn)) {
return method;
}
}
foreach (IProperty property in callingClass.Properties) {
if (property.BodyRegion != null && property.BodyRegion.IsInside(caretLine, caretColumn)) {
if (property.BodyRegion.IsInside(caretLine, caretColumn)) {
return property;
}
}
@ -939,7 +939,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -939,7 +939,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
foreach (LocalLookupVariable v in pair.Value) {
if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) {
// convert to a field for display
result.Add(new DefaultField(TypeVisitor.CreateReturnType(v.TypeRef, this), pair.Key, ModifierEnum.None, new DefaultRegion(v.StartPos, v.EndPos), callingClass));
result.Add(new DefaultField(TypeVisitor.CreateReturnType(v.TypeRef, this), pair.Key, ModifierEnum.None, new DomRegion(v.StartPos, v.EndPos), callingClass));
break;
}
}
@ -978,8 +978,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -978,8 +978,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
}
}
foreach (string alias in u.Aliases.Keys) {
result.Add(alias);
if (u.HasAliases) {
foreach (string alias in u.Aliases.Keys) {
result.Add(alias);
}
}
}
}

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

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using System.Collections;
//using System.Xml;
using System.Reflection;
using System.Collections.Generic;
using ICSharpCode.Core;
@ -32,21 +31,39 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -32,21 +31,39 @@ namespace ICSharpCode.SharpDevelop.Dom
if (innerClasses == null) {
innerClasses = new List<IClass>();
foreach (Type nestedType in type.GetNestedTypes(flags)) {
innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, this));
string name = nestedType.FullName.Replace('+', '.');
innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, name, this));
}
}
return innerClasses;
}
}
static Dictionary<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 {
get {
List<IField> fields = new List<IField>();
foreach (FieldInfo field in type.GetFields(flags)) {
if (!field.IsPublic && !field.IsFamily) continue;
if (!field.IsSpecialName) {
fields.Add(new ReflectionField(field, this));
List<IField> fields;
if (!fieldCache.TryGetValue(this, out fields)) {
fields = new List<IField>();
foreach (FieldInfo field in type.GetFields(flags)) {
if (!field.IsPublic && !field.IsFamily) continue;
if (!field.IsSpecialName) {
fields.Add(new ReflectionField(field, this));
}
}
fieldCache.Add(this, fields);
}
return fields;
}
@ -54,33 +71,40 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -54,33 +71,40 @@ namespace ICSharpCode.SharpDevelop.Dom
public override List<IProperty> Properties {
get {
List<IProperty> properties = new List<IProperty>();
foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) {
ReflectionProperty prop = new ReflectionProperty(propertyInfo, this);
if (prop.IsPublic || prop.IsProtected)
properties.Add(prop);
List<IProperty> properties;
if (!propertyCache.TryGetValue(this, out properties)) {
properties = new List<IProperty>();
foreach (PropertyInfo propertyInfo in type.GetProperties(flags)) {
ReflectionProperty prop = new ReflectionProperty(propertyInfo, this);
if (prop.IsPublic || prop.IsProtected)
properties.Add(prop);
}
propertyCache.Add(this, properties);
}
return properties;
}
}
public override List<IMethod> Methods {
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)) {
if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue;
IMethod newMethod = new ReflectionMethod(constructorInfo, this);
methods.Add(newMethod);
}
foreach (MethodInfo methodInfo in type.GetMethods(flags)) {
if (!methodInfo.IsPublic && !methodInfo.IsFamily) continue;
if (!methodInfo.IsSpecialName) {
IMethod newMethod = new ReflectionMethod(methodInfo, this);
foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) {
if (!constructorInfo.IsPublic && !constructorInfo.IsFamily) continue;
IMethod newMethod = new ReflectionMethod(constructorInfo, this);
methods.Add(newMethod);
}
foreach (MethodInfo methodInfo in type.GetMethods(flags)) {
if (!methodInfo.IsPublic && !methodInfo.IsFamily) continue;
if (!methodInfo.IsSpecialName) {
IMethod newMethod = new ReflectionMethod(methodInfo, this);
methods.Add(newMethod);
}
}
methodCache.Add(this, methods);
}
return methods;
}
@ -88,10 +112,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -88,10 +112,13 @@ namespace ICSharpCode.SharpDevelop.Dom
public override List<IEvent> Events {
get {
List<IEvent> events = new List<IEvent>();
foreach (EventInfo eventInfo in type.GetEvents(flags)) {
events.Add(new ReflectionEvent(eventInfo, this));
List<IEvent> events;
if (!eventCache.TryGetValue(this, out events)) {
events = new List<IEvent>();
foreach (EventInfo eventInfo in type.GetEvents(flags)) {
events.Add(new ReflectionEvent(eventInfo, this));
}
eventCache.Add(this, events);
}
return events;
}
@ -105,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -105,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Dom
#region VoidClass / VoidReturnType
public class VoidClass : ReflectionClass
{
public VoidClass(ICompilationUnit compilationUnit) : base(compilationUnit, typeof(void), null) {}
public VoidClass(ICompilationUnit compilationUnit) : base(compilationUnit, typeof(void), typeof(void).FullName, null) {}
protected override IReturnType CreateDefaultReturnType() {
return new VoidReturnType(this);
@ -146,14 +173,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -146,14 +173,13 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public ReflectionClass(ICompilationUnit compilationUnit, Type type, IClass declaringType) : base(compilationUnit, declaringType)
public ReflectionClass(ICompilationUnit compilationUnit, Type type, string fullName, IClass declaringType) : base(compilationUnit, declaringType)
{
this.type = type;
string name = type.FullName.Replace('+', '.');
if (name.Length > 2 && name[name.Length - 2] == '`') {
FullyQualifiedName = name.Substring(0, name.Length - 2);
if (fullName.Length > 2 && fullName[fullName.Length - 2] == '`') {
FullyQualifiedName = fullName.Substring(0, fullName.Length - 2);
} else {
FullyQualifiedName = name;
FullyQualifiedName = fullName;
}
this.UseInheritanceCache = true;

8
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs

@ -30,15 +30,11 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -30,15 +30,11 @@ namespace ICSharpCode.SharpDevelop.Dom
// show the abstract layer that we have getter & setters
if (propertyInfo.CanRead) {
GetterRegion = new DefaultRegion(0, 0, 0, 0);
} else {
GetterRegion = null;
GetterRegion = new DomRegion(0, 0, 0, 0);
}
if (propertyInfo.CanWrite) {
SetterRegion = new DefaultRegion(0, 0, 0, 0);
} else {
SetterRegion = null;
SetterRegion = new DomRegion(0, 0, 0, 0);
}
ParameterInfo[] parameterInfo = propertyInfo.GetIndexParameters();

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

@ -7,67 +7,68 @@ @@ -7,67 +7,68 @@
using System;
using System.Drawing;
using System.Diagnostics;
namespace ICSharpCode.SharpDevelop.Dom {
namespace ICSharpCode.SharpDevelop.Dom
{
[Serializable]
public class DefaultRegion : System.MarshalByRefObject, IRegion
public struct DomRegion : IComparable, IComparable<DomRegion>
{
protected int beginLine = -1;
protected int endLine = -1;
protected int beginColumn = -1;
protected int endColumn = -1;
readonly int beginLine;
readonly int endLine;
readonly int beginColumn;
readonly int endColumn;
public readonly static DomRegion Empty = new DomRegion(-1, -1);
public virtual int BeginLine {
public bool IsEmpty {
get {
return beginLine;
return BeginLine <= 0;
}
}
public virtual int BeginColumn {
public int BeginLine {
get {
return beginColumn;
return beginLine;
}
}
/// <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
/// </value>
public virtual int EndColumn {
public int EndLine {
get {
return endColumn;
return endLine;
}
set {
endColumn = value;
}
public int BeginColumn {
get {
return beginColumn;
}
}
/// <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
/// </value>
public virtual int EndLine {
public int EndColumn {
get {
return endLine;
}
set {
endLine = value;
return endColumn;
}
}
public DefaultRegion(Point start, Point end)
public DomRegion(Point start, Point end)
: this(start.Y, start.X, end.Y, end.X)
{
}
public DefaultRegion(Point start)
public DomRegion(Point start)
: this(start.Y, start.X)
{
}
public DefaultRegion(int beginLine, int beginColumn, int endLine, int endColumn)
public DomRegion(int beginLine, int beginColumn, int endLine, int endColumn)
{
this.beginLine = beginLine;
this.beginColumn = beginColumn;
@ -75,10 +76,12 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -75,10 +76,12 @@ namespace ICSharpCode.SharpDevelop.Dom {
this.endColumn = endColumn;
}
public DefaultRegion(int beginLine, int beginColumn)
public DomRegion(int beginLine, int beginColumn)
{
this.beginLine = beginLine;
this.beginColumn = beginColumn;
this.endLine = -1;
this.endColumn = -1;
}
/// <remarks>
@ -88,9 +91,9 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -88,9 +91,9 @@ namespace ICSharpCode.SharpDevelop.Dom {
public bool IsInside(int row, int column)
{
return row >= BeginLine &&
(row <= EndLine || EndLine == -1) &&
(row != BeginLine || column >= BeginColumn) &&
(row != EndLine || column <= EndColumn);
(row <= EndLine || EndLine == -1) &&
(row != BeginLine || column >= BeginColumn) &&
(row != EndLine || column <= EndColumn);
}
public override string ToString()
@ -102,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -102,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
endColumn);
}
public virtual int CompareTo(IRegion value)
public int CompareTo(DomRegion value)
{
int cmp;
if (0 != (cmp = (BeginLine - value.BeginLine))) {
@ -121,7 +124,7 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -121,7 +124,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
}
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 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -207,11 +207,11 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -207,11 +207,11 @@ namespace ICSharpCode.SharpDevelop.Dom
if (cu.FileName == null || cu.FileName.Length == 0) {
return null;
}
IRegion reg = field.Region;
if (reg != null) {
DomRegion reg = field.Region;
if (!reg.IsEmpty) {
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
} else {
LoggingService.Warn("GetDefinitionPosition: field.Region is null");
LoggingService.Warn("GetDefinitionPosition: field.Region is empty");
return new FilePosition(cu.FileName, Point.Empty);
}
}
@ -318,8 +318,8 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -318,8 +318,8 @@ namespace ICSharpCode.SharpDevelop.Dom
if (cu == null || cu.FileName == null || cu.FileName.Length == 0) {
return null;
}
IRegion reg = resolvedClass.Region;
if (reg != null)
DomRegion reg = resolvedClass.Region;
if (!reg.IsEmpty)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else
return new FilePosition(cu.FileName, Point.Empty);
@ -383,8 +383,8 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -383,8 +383,8 @@ namespace ICSharpCode.SharpDevelop.Dom
if (cu.FileName == null || cu.FileName.Length == 0) {
return null;
}
IRegion reg = resolvedMember.Region;
if (reg != null)
DomRegion reg = resolvedMember.Region;
if (!reg.IsEmpty)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else
return new FilePosition(cu.FileName, Point.Empty);

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

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

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

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

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

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

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

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

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

@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop.Gui
static Panel panel = null;
static ComboBox comboBox = null;
static PropertyGrid grid = null;
static PropertyGrid grid = new PropertyGrid();
static IDesignerHost host = null;
public static PropertyGrid Grid {
@ -85,7 +85,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -85,7 +85,11 @@ namespace ICSharpCode.SharpDevelop.Gui
}
public static event PropertyValueChangedEventHandler PropertyValueChanged;
public static event EventHandler SelectedObjectChanged;
public static event EventHandler SelectedObjectChanged {
add { grid.SelectedObjectsChanged += value; }
remove { grid.SelectedObjectsChanged -= value; }
}
public override Control Control {
get {
@ -95,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -95,7 +99,6 @@ namespace ICSharpCode.SharpDevelop.Gui
static PropertyPad()
{
grid = new PropertyGrid();
grid.PropertySort = PropertyService.Get("FormsDesigner.DesignerOptions.PropertyGridSortAlphabetical", false) ? PropertySort.Alphabetical : PropertySort.CategorizedAlphabetical;
grid.Dock = DockStyle.Fill;
@ -205,14 +208,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -205,14 +208,11 @@ namespace ICSharpCode.SharpDevelop.Gui
ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService));
if (comboBox.SelectedIndex >= 0) {
selectionService.SetSelectedComponents(new object[] {comboBox.Items[comboBox.SelectedIndex] });
} else {
} else {
SetDesignableObject(null);
selectionService.SetSelectedComponents(new object[] { });
}
}
if (SelectedObjectChanged != null) {
SelectedObjectChanged(this, EventArgs.Empty);
}
}
}
@ -338,8 +338,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -338,8 +338,12 @@ namespace ICSharpCode.SharpDevelop.Gui
ICSharpCode.SharpDevelop.Dom.IClass c = ProjectContentRegistry.WinForms.GetClass(component.FullName);
if (c != null) {
foreach (ICSharpCode.SharpDevelop.Dom.IProperty p in c.DefaultReturnType.GetProperties()) {
ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(p);
if (gridItem.PropertyDescriptor.Name == p.Name) {
ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(p);
return;
}
}
ICSharpCode.SharpDevelop.Dom.HelpProvider.ShowHelp(c);
}
}
}

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

@ -89,7 +89,7 @@ namespace ICSharpCode.Core @@ -89,7 +89,7 @@ namespace ICSharpCode.Core
public string Convert(Type type)
{
return conv.Convert(new ReflectionClass(null, type, null));
return conv.Convert(new ReflectionClass(null, type, type.FullName.Replace('+', '.'), null));
}
public string Convert(FieldInfo field)

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

@ -634,7 +634,7 @@ namespace ICSharpCode.Core @@ -634,7 +634,7 @@ namespace ICSharpCode.Core
{
IClass curClass = GetClass(fullMemberName, LanguageProperties.CSharp, false);
if (curClass != null) {
return new Position(curClass.CompilationUnit, curClass.Region != null ? curClass.Region.BeginLine : -1, curClass.Region != null ? curClass.Region.BeginColumn : -1);
return new Position(curClass.CompilationUnit, curClass.Region.BeginLine, curClass.Region.BeginColumn);
}
int pos = fullMemberName.LastIndexOf('.');
if (pos > 0) {
@ -644,7 +644,7 @@ namespace ICSharpCode.Core @@ -644,7 +644,7 @@ namespace ICSharpCode.Core
if (curClass != null) {
IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp);
if (member != null) {
return new Position(curClass.CompilationUnit, member.Region != null ? member.Region.BeginLine : -1, member.Region != null ? member.Region.BeginColumn : -1);
return new Position(curClass.CompilationUnit, member.Region.BeginLine, member.Region.BeginColumn);
}
}
}

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

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

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

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

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

@ -116,12 +116,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -116,12 +116,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return null;
}
foreach (IMethod method in callingClass.Methods) {
if (method.BodyRegion != null && method.BodyRegion.IsInside(caretLine, caretColumn)) {
if (method.BodyRegion.IsInside(caretLine, caretColumn)) {
return method;
}
}
foreach (IProperty property in callingClass.Properties) {
if (property.BodyRegion != null && property.BodyRegion.IsInside(caretLine, caretColumn)) {
if (property.BodyRegion.IsInside(caretLine, caretColumn)) {
return property;
}
}
@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -154,7 +154,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return MakeItem(c.FullyQualifiedName, new ClassNode(c.ProjectContent.Project, c), c.CompilationUnit, c.Region);
}
ToolStripMenuItem MakeItem(string title, ExtTreeNode classBrowserTreeNode, ICompilationUnit cu, IRegion region)
ToolStripMenuItem MakeItem(string title, ExtTreeNode classBrowserTreeNode, ICompilationUnit cu, DomRegion region)
{
ToolStripMenuItem item = new ToolStripMenuItem(classBrowserTreeNode.Text, ClassBrowserIconService.ImageList.Images[classBrowserTreeNode.ImageIndex]);
@ -163,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -163,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
//item.DropDown.Items.Add(titleItem);
//item.DropDown.Items.Add(new ToolStripSeparator());
if (cu.FileName != null && region != null) {
if (cu.FileName != null && !region.IsEmpty) {
ToolStripMenuItem gotoDefinitionItem = new ToolStripMenuItem(StringParser.Parse("${res:ICSharpCode.NAntAddIn.GotoDefinitionMenuLabel}"),
ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GotoArrowIndex]);
gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter;

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

@ -105,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -105,7 +105,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
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)
return;

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

@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
if (derivedClass.CompilationUnit == null) continue;
if (derivedClass.CompilationUnit.FileName == null) continue;
IMember m = RefactoringService.FindSimilarMember(derivedClass, member);
if (m != null && m.Region != null) {
if (!m.Region.IsEmpty) {
SearchResult res = new SimpleSearchResult(m.FullyQualifiedName, new Point(m.Region.BeginColumn - 1, m.Region.BeginLine - 1));
res.ProvidedDocumentInformation = GetDocumentInformation(derivedClass.CompilationUnit.FileName);
results.Add(res);

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

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

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

@ -341,9 +341,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -341,9 +341,9 @@ namespace ICSharpCode.SharpDevelop.Gui
Close();
}
void GotoRegion(IRegion region, string fileName)
void GotoRegion(DomRegion region, string fileName)
{
if (fileName != null && region != null) {
if (fileName != null && !region.IsEmpty) {
FileService.JumpToFilePosition(fileName, region.BeginLine - 1, region.BeginColumn - 1);
}
}

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

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

10
src/Main/Base/Project/Src/TextEditor/Gui/Editor/ParserFoldingStrategy.cs

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

20
src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs

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

10
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -465,26 +465,26 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -465,26 +465,26 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
void AddClassMemberBookmarks(BookmarkManager bm, IClass c)
{
if (c.Region != null && c.Region.BeginLine > 0) {
if (!c.Region.IsEmpty) {
bm.AddMark(new Bookmarks.ClassBookmark(textAreaControl.Document, c));
}
foreach (IClass innerClass in c.InnerClasses) {
AddClassMemberBookmarks(bm, innerClass);
}
foreach (IMethod m in c.Methods) {
if (m.Region == null || m.Region.BeginLine <= 0) continue;
if (m.Region.IsEmpty) continue;
bm.AddMark(new Bookmarks.MethodBookmark(textAreaControl.Document, m));
}
foreach (IProperty m in c.Properties) {
if (m.Region == null || m.Region.BeginLine <= 0) continue;
if (m.Region.IsEmpty) continue;
bm.AddMark(new Bookmarks.PropertyBookmark(textAreaControl.Document, m));
}
foreach (IField f in c.Fields) {
if (f.Region == null || f.Region.BeginLine <= 0) continue;
if (f.Region.IsEmpty) continue;
bm.AddMark(new Bookmarks.FieldBookmark(textAreaControl.Document, f));
}
foreach (IEvent e in c.Events) {
if (e.Region == null || e.Region.BeginLine <= 0) continue;
if (e.Region.IsEmpty) continue;
bm.AddMark(new Bookmarks.EventBookmark(textAreaControl.Document, e));
}
}

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

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

Loading…
Cancel
Save