Browse Source

Fixed SD2-814: Expanding wildcard search result node throws exception

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1420 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
676a617c3a
  1. 9
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs
  2. 5
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs
  3. 10
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs
  4. 22
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs
  5. 6
      src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs
  6. 4
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/SearchResult.cs
  7. 19
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/WildcardSearchStrategy.cs
  8. 4
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Pad/Nodes/SearchResultNode.cs

9
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs

@ -219,6 +219,15 @@ namespace ICSharpCode.FormsDesigner.Services
} }
} }
AddAssemblyResolver();
try {
asm.GetTypes(); // force loading references etc.
} catch {
// some assemblies cause strange exceptions in Reflection...
} finally {
RemoveAssemblyResolver();
}
lock (designerAssemblies) { lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm)) if (!designerAssemblies.Contains(asm))
designerAssemblies.Insert(0, asm); designerAssemblies.Insert(0, asm);

5
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs

@ -585,7 +585,7 @@ namespace ICSharpCode.TextEditor.Document
// Check for SPAN ENDs // Check for SPAN ENDs
if (inSpan) { if (inSpan) {
if (activeSpan.End != null && !activeSpan.End.Equals("")) { if (activeSpan.End != null && !activeSpan.End.Equals("")) {
if (currentLine.MatchExpr(activeSpan.End, i, document)) { if (currentLine.MatchExpr(activeSpan.End, i, document, activeSpan.IgnoreCase)) {
PushCurWord(document, ref markNext, words); PushCurWord(document, ref markNext, words);
string regex = currentLine.GetRegString(activeSpan.End, i, document); string regex = currentLine.GetRegString(activeSpan.End, i, document);
currentLength += regex.Length; currentLength += regex.Length;
@ -603,7 +603,7 @@ namespace ICSharpCode.TextEditor.Document
// check for SPAN BEGIN // check for SPAN BEGIN
if (activeRuleSet != null) { if (activeRuleSet != null) {
foreach (Span span in activeRuleSet.Spans) { foreach (Span span in activeRuleSet.Spans) {
if (currentLine.MatchExpr(span.Begin, i, document)) { if (currentLine.MatchExpr(span.Begin, i, document, activeRuleSet.IgnoreCase)) {
PushCurWord(document, ref markNext, words); PushCurWord(document, ref markNext, words);
string regex = currentLine.GetRegString(span.Begin, i, document); string regex = currentLine.GetRegString(span.Begin, i, document);
currentLength += regex.Length; currentLength += regex.Length;
@ -616,6 +616,7 @@ namespace ICSharpCode.TextEditor.Document
currentSpanStack = new Stack<Span>(); currentSpanStack = new Stack<Span>();
} }
currentSpanStack.Push(span); currentSpanStack.Push(span);
span.IgnoreCase = activeRuleSet.IgnoreCase;
UpdateSpanStateVariables(); UpdateSpanStateVariables();

10
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs

@ -30,6 +30,7 @@ namespace ICSharpCode.TextEditor.Document
string rule = null; string rule = null;
HighlightRuleSet ruleSet = null; HighlightRuleSet ruleSet = null;
bool noEscapeSequences = false; bool noEscapeSequences = false;
bool ignoreCase = false;
internal HighlightRuleSet RuleSet { internal HighlightRuleSet RuleSet {
get { get {
@ -40,6 +41,15 @@ namespace ICSharpCode.TextEditor.Document
} }
} }
public bool IgnoreCase {
get {
return ignoreCase;
}
set {
ignoreCase = value;
}
}
public bool StopEOL { public bool StopEOL {
get { get {
return stopEOL; return stopEOL;

22
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs

@ -160,7 +160,7 @@ namespace ICSharpCode.TextEditor.Document
/// <summary> /// <summary>
/// returns true, if the get the string s2 at index matches the expression expr /// returns true, if the get the string s2 at index matches the expression expr
/// </summary> /// </summary>
internal bool MatchExpr(char[] expr, int index, IDocument document) internal bool MatchExpr(char[] expr, int index, IDocument document, bool ignoreCase)
{ {
for (int i = 0, j = 0; i < expr.Length; ++i, ++j) { for (int i = 0, j = 0; i < expr.Length; ++i, ++j) {
switch (expr[i]) { switch (expr[i]) {
@ -178,7 +178,9 @@ namespace ICSharpCode.TextEditor.Document
if (this.Offset + index + j + whatmatch.Length < document.TextLength) { if (this.Offset + index + j + whatmatch.Length < document.TextLength) {
int k = 0; int k = 0;
for (; k < whatmatch.Length; ++k) { for (; k < whatmatch.Length; ++k) {
if (document.GetCharAt(this.Offset + index + j + k) != whatmatch[k]) { char docChar = ignoreCase ? Char.ToUpperInvariant(document.GetCharAt(this.Offset + index + j + k)) : document.GetCharAt(this.Offset + index + j + k);
char spanChar = ignoreCase ? Char.ToUpperInvariant(whatmatch[k]) : whatmatch[k];
if (docChar != spanChar) {
break; break;
} }
} }
@ -198,9 +200,12 @@ namespace ICSharpCode.TextEditor.Document
} }
if (index - whatmatch.Length >= 0) { if (index - whatmatch.Length >= 0) {
int k = 0; int k = 0;
for (; k < whatmatch.Length; ++k) for (; k < whatmatch.Length; ++k) {
if (document.GetCharAt(this.Offset + index - whatmatch.Length + k) != whatmatch[k]) char docChar = ignoreCase ? Char.ToUpperInvariant(document.GetCharAt(this.Offset + index - whatmatch.Length + k)) : document.GetCharAt(this.Offset + index - whatmatch.Length + k);
char spanChar = ignoreCase ? Char.ToUpperInvariant(whatmatch[k]) : whatmatch[k];
if (docChar != spanChar)
break; break;
}
if (k >= whatmatch.Length) { if (k >= whatmatch.Length) {
return false; return false;
} }
@ -217,10 +222,17 @@ namespace ICSharpCode.TextEditor.Document
} }
break; break;
default: default:
if (index + j >= this.Length || expr[i] != document.GetCharAt(this.Offset + index + j)) { {
if (index + j >= this.Length) {
return false;
}
char docChar = ignoreCase ? Char.ToUpperInvariant(document.GetCharAt(this.Offset + index + j)) : document.GetCharAt(this.Offset + index + j);
char spanChar = ignoreCase ? Char.ToUpperInvariant(expr[i]) : expr[i];
if (docChar != spanChar) {
return false; return false;
} }
break; break;
}
} }
} }
return true; return true;

6
src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs

@ -151,7 +151,11 @@ namespace ICSharpCode.SharpDevelop.Project.Converter
} }
node = node.Parent; node = node.Parent;
} }
FileService.NewFile("Conversion Results", "Text", conversionLog.ToString()); ICSharpCode.SharpDevelop.Gui.IWorkbenchWindow newFileWindow;
newFileWindow = FileService.NewFile("Conversion Results", "Text", conversionLog.ToString());
if (newFileWindow != null) {
newFileWindow.ViewContent.IsDirty = false;
}
} }
} }

4
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/SearchResult.cs

@ -57,6 +57,10 @@ namespace SearchAndReplace
public SearchResult(int offset, int length) public SearchResult(int offset, int length)
{ {
if (length < 0)
throw new ArgumentOutOfRangeException("length");
if (offset < 0)
throw new ArgumentOutOfRangeException("offset");
this.offset = offset; this.offset = offset;
this.length = length; this.length = length;
} }

19
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/WildcardSearchStrategy.cs

@ -106,6 +106,9 @@ namespace SearchAndReplace
} }
break; break;
case CommandType.AnyZeroOrMore: case CommandType.AnyZeroOrMore:
if (ch == '\n') {
return false;
}
return Match(document, curOffset, ignoreCase, pc + 1) || return Match(document, curOffset, ignoreCase, pc + 1) ||
Match(document, curOffset + 1, ignoreCase, pc); Match(document, curOffset + 1, ignoreCase, pc);
case CommandType.AnySingle: case CommandType.AnySingle:
@ -135,9 +138,11 @@ namespace SearchAndReplace
int InternalFindNext(ITextIterator textIterator) int InternalFindNext(ITextIterator textIterator)
{ {
while (textIterator.MoveAhead(1)) { while (textIterator.MoveAhead(1)) {
if (Match(textIterator.TextBuffer, textIterator.Position, !SearchOptions.MatchCase, 0)) { int position = textIterator.Position;
if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, textIterator.Position, curMatchEndOffset - textIterator.Position)) { if (Match(textIterator.TextBuffer, position, !SearchOptions.MatchCase, 0)) {
return textIterator.Position; if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, position, curMatchEndOffset - position)) {
textIterator.MoveAhead(curMatchEndOffset - position - 1);
return position;
} }
} }
} }
@ -147,10 +152,12 @@ namespace SearchAndReplace
int InternalFindNext(ITextIterator textIterator, int offset, int length) int InternalFindNext(ITextIterator textIterator, int offset, int length)
{ {
while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) {
if (Match(textIterator.TextBuffer, textIterator.Position, !SearchOptions.MatchCase, 0)) { int position = textIterator.Position;
if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, textIterator.Position, curMatchEndOffset - textIterator.Position)) { if (Match(textIterator.TextBuffer, position, !SearchOptions.MatchCase, 0)) {
if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.TextBuffer, position, curMatchEndOffset - position)) {
if (TextSelection.IsInsideRange(curMatchEndOffset - 1, offset, length)) { if (TextSelection.IsInsideRange(curMatchEndOffset - 1, offset, length)) {
return textIterator.Position; textIterator.MoveAhead(curMatchEndOffset - position - 1);
return position;
} else { } else {
return -1; return -1;
} }

4
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Pad/Nodes/SearchResultNode.cs

@ -63,7 +63,9 @@ namespace SearchAndReplace
LineSegment line = document.GetLineSegment(startPosition.Y); LineSegment line = document.GetLineSegment(startPosition.Y);
drawableLine = new DrawableLine(document, line, MonospacedFont, BoldMonospacedFont); drawableLine = new DrawableLine(document, line, MonospacedFont, BoldMonospacedFont);
drawableLine.SetBold(0, drawableLine.LineLength, false); drawableLine.SetBold(0, drawableLine.LineLength, false);
drawableLine.SetBold(startPosition.X, endPosition.X, true); if (startPosition.Y == endPosition.Y) {
drawableLine.SetBold(startPosition.X, endPosition.X, true);
}
specialText = result.DisplayText; specialText = result.DisplayText;
if (specialText != null) { if (specialText != null) {

Loading…
Cancel
Save