Browse Source

When going to the definition of a CompoundClass, go to the shortest file name. This prevents going to the Designer.cs part instead of the main part.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2436 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
5fcfe9be4e
  1. 22
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
  2. 17
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/CompoundClass.cs

22
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs

@ -53,6 +53,12 @@ namespace ICSharpCode.TextEditor.Document
public char GetCharAt(int offset) public char GetCharAt(int offset)
{ {
#if DEBUG
CheckThread();
if (offset < 0 || offset >= Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset < " + Length.ToString());
}
#endif
return offset < gapBeginOffset ? buffer[offset] : buffer[offset + GapLength]; return offset < gapBeginOffset ? buffer[offset] : buffer[offset + GapLength];
} }
@ -60,6 +66,12 @@ namespace ICSharpCode.TextEditor.Document
{ {
#if DEBUG #if DEBUG
CheckThread(); CheckThread();
if (offset < 0 || offset > Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString());
}
if (length < 0 || offset + length > Length) {
throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset+length <= " + Length.ToString());
}
#endif #endif
int end = offset + length; int end = offset + length;
@ -96,6 +108,16 @@ namespace ICSharpCode.TextEditor.Document
text = String.Empty; text = String.Empty;
} }
#if DEBUG
CheckThread();
if (offset < 0 || offset > Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString());
}
if (length < 0 || offset + length > Length) {
throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset+length <= " + Length.ToString());
}
#endif
// Math.Max is used so that if we need to resize the array // Math.Max is used so that if we need to resize the array
// the new array has enough space for all old chars // the new array has enough space for all old chars
PlaceGap(offset + length, Math.Max(text.Length - length, 0)); PlaceGap(offset + length, Math.Max(text.Length - length, 0));

17
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/CompoundClass.cs

@ -35,8 +35,10 @@ namespace ICSharpCode.SharpDevelop.Dom
/// <summary> /// <summary>
/// Creates a new CompoundClass with the specified class as first part. /// Creates a new CompoundClass with the specified class as first part.
/// </summary> /// </summary>
public CompoundClass(IClass firstPart) : base(firstPart.CompilationUnit, firstPart.FullyQualifiedName) public CompoundClass(IClass firstPart) : base(new DefaultCompilationUnit(firstPart.ProjectContent), firstPart.FullyQualifiedName)
{ {
this.CompilationUnit.Classes.Add(this);
parts.Add(firstPart); parts.Add(firstPart);
UpdateInformationFromParts(); UpdateInformationFromParts();
} }
@ -48,15 +50,23 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
// Common for all parts: // Common for all parts:
this.ClassType = parts[0].ClassType; this.ClassType = parts[0].ClassType;
this.CompilationUnit.FileName = parts[0].CompilationUnit.FileName;
this.Region = parts[0].Region;
ModifierEnum modifier = ModifierEnum.None; ModifierEnum modifier = ModifierEnum.None;
const ModifierEnum defaultClassVisibility = ModifierEnum.Internal; const ModifierEnum defaultClassVisibility = ModifierEnum.Internal;
this.BaseTypes.Clear(); this.BaseTypes.Clear();
this.Attributes.Clear(); this.Attributes.Clear();
string shortestFileName = null;
foreach (IClass part in parts) { foreach (IClass part in parts) {
if (!string.IsNullOrEmpty(part.CompilationUnit.FileName)) {
if (shortestFileName == null || part.CompilationUnit.FileName.Length < shortestFileName.Length) {
shortestFileName = part.CompilationUnit.FileName;
this.Region = part.Region;
}
}
if ((part.Modifiers & ModifierEnum.VisibilityMask) != defaultClassVisibility) { if ((part.Modifiers & ModifierEnum.VisibilityMask) != defaultClassVisibility) {
modifier |= part.Modifiers; modifier |= part.Modifiers;
} else { } else {
@ -71,6 +81,7 @@ namespace ICSharpCode.SharpDevelop.Dom
this.Attributes.Add(attribute); this.Attributes.Add(attribute);
} }
} }
this.CompilationUnit.FileName = shortestFileName;
if ((modifier & ModifierEnum.VisibilityMask) == ModifierEnum.None) { if ((modifier & ModifierEnum.VisibilityMask) == ModifierEnum.None) {
modifier |= defaultClassVisibility; modifier |= defaultClassVisibility;
} }

Loading…
Cancel
Save