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. 32
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
  2. 17
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/CompoundClass.cs

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

@ -42,7 +42,7 @@ namespace ICSharpCode.TextEditor.Document @@ -42,7 +42,7 @@ namespace ICSharpCode.TextEditor.Document
}
}
public void SetContent(string text)
public void SetContent(string text)
{
if (text == null) {
text = String.Empty;
@ -51,15 +51,27 @@ namespace ICSharpCode.TextEditor.Document @@ -51,15 +51,27 @@ namespace ICSharpCode.TextEditor.Document
gapBeginOffset = gapEndOffset = 0;
}
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];
}
public string GetText(int offset, int length)
public string GetText(int offset, int length)
{
#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
int end = offset + length;
@ -90,12 +102,22 @@ namespace ICSharpCode.TextEditor.Document @@ -90,12 +102,22 @@ namespace ICSharpCode.TextEditor.Document
Replace(offset, length, String.Empty);
}
public void Replace(int offset, int length, string text)
public void Replace(int offset, int length, string text)
{
if (text == null) {
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
// the new array has enough space for all old chars
PlaceGap(offset + length, Math.Max(text.Length - length, 0));
@ -103,7 +125,7 @@ namespace ICSharpCode.TextEditor.Document @@ -103,7 +125,7 @@ namespace ICSharpCode.TextEditor.Document
gapBeginOffset += text.Length - length;
}
void PlaceGap(int offset, int length)
void PlaceGap(int offset, int length)
{
int deltaLength = GapLength - length;
// if the gap has the right length, move the chars between offset and gap

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

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

Loading…
Cancel
Save