Browse Source

Adjust SharpDevelop to NRefactory API changes

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
ae406e9c31
  1. 5
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/CSharpSymbolSearch.cs
  2. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
  3. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/RopeTextSource.cs
  4. 17
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  5. 34
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CharRope.cs

5
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/CSharpSymbolSearch.cs

@ -107,13 +107,14 @@ namespace CSharpBinding
if (textSource == null) if (textSource == null)
return; return;
if (searchScope.SearchTerm != null) { if (searchScope.SearchTerm != null) {
// TODO: do a fast check with IndexOf() if (textSource.IndexOf(searchScope.SearchTerm, 0, textSource.TextLength, StringComparison.Ordinal) < 0)
return;
} }
ParseInformation parseInfo = ParserService.Parse(fileName, textSource); ParseInformation parseInfo = ParserService.Parse(fileName, textSource);
if (parseInfo == null) if (parseInfo == null)
return; return;
ParsedFile parsedFile = parseInfo.ParsedFile as ParsedFile; CSharpParsedFile parsedFile = parseInfo.ParsedFile as CSharpParsedFile;
CompilationUnit cu = parseInfo.Annotation<CompilationUnit>(); CompilationUnit cu = parseInfo.Annotation<CompilationUnit>();
if (parsedFile == null || cu == null) if (parsedFile == null || cu == null)
return; return;

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

@ -80,7 +80,7 @@ namespace CSharpBinding.Parser
} }
TypeSystemConvertVisitor cv = new TypeSystemConvertVisitor(projectContent, fileName); TypeSystemConvertVisitor cv = new TypeSystemConvertVisitor(projectContent, fileName);
ParsedFile file = cv.Convert(cu); CSharpParsedFile file = cv.Convert(cu);
ParseInformation info = new ParseInformation(file, fullParseInformationRequested); ParseInformation info = new ParseInformation(file, fullParseInformationRequested);
if (fullParseInformationRequested) if (fullParseInformationRequested)
@ -103,7 +103,7 @@ namespace CSharpBinding.Parser
CompilationUnit cu = parseInfo.Annotation<CompilationUnit>(); CompilationUnit cu = parseInfo.Annotation<CompilationUnit>();
if (cu == null) if (cu == null)
throw new ArgumentException("Parse info does not have CompilationUnit"); throw new ArgumentException("Parse info does not have CompilationUnit");
ParsedFile parsedFile = parseInfo.ParsedFile as ParsedFile; CSharpParsedFile parsedFile = parseInfo.ParsedFile as CSharpParsedFile;
if (parsedFile == null) if (parsedFile == null)
throw new ArgumentException("Parse info does not have a C# ParsedFile"); throw new ArgumentException("Parse info does not have a C# ParsedFile");

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/RopeTextSource.cs

@ -110,5 +110,15 @@ namespace ICSharpCode.AvalonEdit.Document
{ {
return rope.ToString(segment.Offset, segment.Length); return rope.ToString(segment.Offset, segment.Length);
} }
public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
return rope.IndexOf(searchText, startIndex, count, comparisonType);
}
public int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
return rope.LastIndexOf(searchText, startIndex, count, comparisonType);
}
} }
} }

17
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -156,12 +156,27 @@ namespace ICSharpCode.AvalonEdit.Document
return GetText(segment.Offset, segment.Length); return GetText(segment.Offset, segment.Length);
} }
int ITextSource.IndexOfAny(char[] anyOf, int startIndex, int count) /// <inheritdoc/>
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{ {
DebugVerifyAccess(); // frequently called (NewLineFinder), so must be fast in release builds DebugVerifyAccess(); // frequently called (NewLineFinder), so must be fast in release builds
return rope.IndexOfAny(anyOf, startIndex, count); return rope.IndexOfAny(anyOf, startIndex, count);
} }
/// <inheritdoc/>
public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
DebugVerifyAccess();
return rope.IndexOf(searchText, startIndex, count, comparisonType);
}
/// <inheritdoc/>
public int LastIndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
{
DebugVerifyAccess();
return rope.LastIndexOf(searchText, startIndex, count, comparisonType);
}
/// <inheritdoc/> /// <inheritdoc/>
public char GetCharAt(int offset) public char GetCharAt(int offset)
{ {

34
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CharRope.cs

@ -168,5 +168,39 @@ namespace ICSharpCode.AvalonEdit.Utils
} }
return -1; return -1;
} }
/// <summary>
/// Gets the index of the first occurrence of the search text.
/// </summary>
public static int IndexOf(this Rope<char> rope, string searchText, int startIndex, int length, StringComparison comparisonType)
{
if (rope == null)
throw new ArgumentNullException("rope");
if (searchText == null)
throw new ArgumentNullException("searchText");
rope.VerifyRange(startIndex, length);
int pos = rope.ToString(startIndex, length).IndexOf(searchText, startIndex, length, comparisonType);
if (pos < 0)
return -1;
else
return pos + startIndex;
}
/// <summary>
/// Gets the index of the last occurrence of the search text.
/// </summary>
public static int LastIndexOf(this Rope<char> rope, string searchText, int startIndex, int length, StringComparison comparisonType)
{
if (rope == null)
throw new ArgumentNullException("rope");
if (searchText == null)
throw new ArgumentNullException("searchText");
rope.VerifyRange(startIndex, length);
int pos = rope.ToString(startIndex, length).LastIndexOf(searchText, startIndex, length, comparisonType);
if (pos < 0)
return -1;
else
return pos + startIndex;
}
} }
} }

Loading…
Cancel
Save