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 @@ -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) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Insert(0, asm);

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

@ -585,7 +585,7 @@ namespace ICSharpCode.TextEditor.Document @@ -585,7 +585,7 @@ namespace ICSharpCode.TextEditor.Document
// Check for SPAN ENDs
if (inSpan) {
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);
string regex = currentLine.GetRegString(activeSpan.End, i, document);
currentLength += regex.Length;
@ -603,7 +603,7 @@ namespace ICSharpCode.TextEditor.Document @@ -603,7 +603,7 @@ namespace ICSharpCode.TextEditor.Document
// check for SPAN BEGIN
if (activeRuleSet != null) {
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);
string regex = currentLine.GetRegString(span.Begin, i, document);
currentLength += regex.Length;
@ -616,6 +616,7 @@ namespace ICSharpCode.TextEditor.Document @@ -616,6 +616,7 @@ namespace ICSharpCode.TextEditor.Document
currentSpanStack = new Stack<Span>();
}
currentSpanStack.Push(span);
span.IgnoreCase = activeRuleSet.IgnoreCase;
UpdateSpanStateVariables();

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

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

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

@ -160,7 +160,7 @@ namespace ICSharpCode.TextEditor.Document @@ -160,7 +160,7 @@ namespace ICSharpCode.TextEditor.Document
/// <summary>
/// returns true, if the get the string s2 at index matches the expression expr
/// </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) {
switch (expr[i]) {
@ -178,7 +178,9 @@ namespace ICSharpCode.TextEditor.Document @@ -178,7 +178,9 @@ namespace ICSharpCode.TextEditor.Document
if (this.Offset + index + j + whatmatch.Length < document.TextLength) {
int k = 0;
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;
}
}
@ -198,9 +200,12 @@ namespace ICSharpCode.TextEditor.Document @@ -198,9 +200,12 @@ namespace ICSharpCode.TextEditor.Document
}
if (index - whatmatch.Length >= 0) {
int k = 0;
for (; k < whatmatch.Length; ++k)
if (document.GetCharAt(this.Offset + index - whatmatch.Length + k) != whatmatch[k])
for (; k < whatmatch.Length; ++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;
}
if (k >= whatmatch.Length) {
return false;
}
@ -217,10 +222,17 @@ namespace ICSharpCode.TextEditor.Document @@ -217,10 +222,17 @@ namespace ICSharpCode.TextEditor.Document
}
break;
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;
}
break;
}
}
}
return true;

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

@ -151,7 +151,11 @@ namespace ICSharpCode.SharpDevelop.Project.Converter @@ -151,7 +151,11 @@ namespace ICSharpCode.SharpDevelop.Project.Converter
}
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 @@ -57,6 +57,10 @@ namespace SearchAndReplace
public SearchResult(int offset, int length)
{
if (length < 0)
throw new ArgumentOutOfRangeException("length");
if (offset < 0)
throw new ArgumentOutOfRangeException("offset");
this.offset = offset;
this.length = length;
}

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

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

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

@ -63,7 +63,9 @@ namespace SearchAndReplace @@ -63,7 +63,9 @@ namespace SearchAndReplace
LineSegment line = document.GetLineSegment(startPosition.Y);
drawableLine = new DrawableLine(document, line, MonospacedFont, BoldMonospacedFont);
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;
if (specialText != null) {

Loading…
Cancel
Save