Browse Source

Fixed bugs in ParserUpdateThread.

Fixed bug in InsightDataProviders.
Added unit test for CC lookup of a method with multiple overloads.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@83 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
ea1e8a047a
  1. 5
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  2. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/IndexerInsightDataProvider.cs
  3. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs
  4. 50
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
  5. 25
      src/Main/Base/Test/NRefactoryResolverTests.cs

5
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -134,10 +134,7 @@ namespace ICSharpCode.Core @@ -134,10 +134,7 @@ namespace ICSharpCode.Core
text = editable.Text;
}
int hash = text.Length;
if (!lastUpdateSize.ContainsKey(fileName)) {
lastUpdateSize[fileName] = 0;
}
if (lastUpdateSize[fileName] == null || (int)lastUpdateSize[fileName] != hash) {
if (!lastUpdateSize.ContainsKey(fileName) || (int)lastUpdateSize[fileName] != hash) {
parseInformation = ParseFile(fileName, text, !viewContent.IsUntitled, true);
lastUpdateSize[fileName] = hash;
updated = true;

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/IndexerInsightDataProvider.cs

@ -57,6 +57,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -57,6 +57,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(fileName);
string word = expressionFinder == null ? TextUtilities.GetExpressionBeforeOffset(textArea, textArea.Caret.Offset) : expressionFinder.FindExpression(textArea.Document.TextContent, textArea.Caret.Offset - 1);
if (word == null) // word can be null when cursor is in string/comment
return;
word = word.Trim();
// the parser works with 1 based coordinates

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs

@ -58,6 +58,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -58,6 +58,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(fileName);
string word = expressionFinder == null ? TextUtilities.GetExpressionBeforeOffset(textArea, textArea.Caret.Offset) : expressionFinder.FindExpression(textArea.Document.TextContent, textArea.Caret.Offset - 1);
if (word == null) // word can be null when cursor is in string/comment
return;
word = word.Trim();
// the parser works with 1 based coordinates

50
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -24,7 +24,7 @@ using ICSharpCode.Core; @@ -24,7 +24,7 @@ using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{
public class TextEditorDisplayBinding : IDisplayBinding
{
{
// load #D-specific syntax highlighting files here
// don't know if this could be solved better by new codons,
// but this will do
@ -75,13 +75,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -75,13 +75,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
b2.ForceFoldingUpdate(language);
b2.textAreaControl.ActivateQuickClassBrowserOnDemand();
return b2;
}
}
}
public class TextEditorDisplayBindingWrapper : AbstractViewContent, IMementoCapable, IPrintable, IEditable, IUndoHandler, IPositionable, ITextEditorControlProvider, IParseInformationListener, IClipboardHandler, IHelpProvider
{
public SharpDevelopTextAreaControl textAreaControl = null;
public TextEditorControl TextEditorControl {
get {
return textAreaControl;
@ -103,18 +103,40 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -103,18 +103,40 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
return textAreaControl.EnableRedo;
}
}
// ParserUpdateThread uses the text property via IEditable, I had an exception
// because multiple threads were accessing the GapBufferStrategy at the same time.
private delegate string GetTextDelegate();
private delegate void SetTextDelegate(string value);
string GetText()
{
return textAreaControl.Document.TextContent;
}
void SetText(string value)
{
textAreaControl.Document.TextContent = value;
}
public string Text {
get {
return textAreaControl.Document.TextContent;
if (textAreaControl.InvokeRequired)
return (string)textAreaControl.Invoke(new GetTextDelegate(GetText));
else
return GetText();
}
set {
textAreaControl.Document.TextContent = value;
if (textAreaControl.InvokeRequired)
textAreaControl.Invoke(new SetTextDelegate(SetText));
else
SetText(value);
}
}
public PrintDocument PrintDocument {
get {
get {
return textAreaControl.PrintDocument;
}
}
@ -162,7 +184,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -162,7 +184,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{
return new SharpDevelopTextAreaControl();
}
public TextEditorDisplayBindingWrapper()
{
textAreaControl = CreateSharpDevelopTextAreaControl();
@ -226,7 +248,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -226,7 +248,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
StringParser.Parse("${res:MainWindow.DialogName}"),
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes) {
Load(textAreaControl.FileName);
Load(textAreaControl.FileName);
} else {
IsDirty = true;
}
@ -245,9 +267,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -245,9 +267,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
}
// KSL End
void TextAreaChangedEvent(object sender, DocumentEventArgs e)
{
IsDirty = true;
@ -319,7 +341,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -319,7 +341,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
Properties properties = (Properties)memento;
textAreaControl.ActiveTextAreaControl.Caret.Position = textAreaControl.Document.OffsetToPosition(Math.Min(textAreaControl.Document.TextLength, Math.Max(0, properties.Get("CaretOffset", textAreaControl.ActiveTextAreaControl.Caret.Offset))));
// textAreaControl.SetDesiredColumn();
if (textAreaControl.Document.HighlightingStrategy.Name != properties.Get("HighlightingLanguage", textAreaControl.Document.HighlightingStrategy.Name)) {
IHighlightingStrategy highlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(properties.Get("HighlightingLanguage", textAreaControl.Document.HighlightingStrategy.Name));
if (highlightingStrategy != null) {
@ -357,7 +379,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -357,7 +379,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
StatusBarService.SetInsertMode(textAreaControl.ActiveTextAreaControl.Caret.CaretMode == CaretMode.InsertMode);
}
public override string FileName {
set {
if (Path.GetExtension(FileName) != Path.GetExtension(value)) {
@ -403,7 +425,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -403,7 +425,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
#region ICSharpCode.SharpDevelop.Gui.IClipboardHandler interface implementation
public bool EnableCut {
get {

25
src/Main/Base/Test/NRefactoryResolverTests.cs

@ -6,7 +6,7 @@ using ICSharpCode.Core; @@ -6,7 +6,7 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
namespace DefaultNamespace.Tests
namespace ICSharpCode.SharpDevelop.Tests
{
[TestFixture]
public class NRefactoryResolverTests
@ -263,5 +263,28 @@ interface IInterface2 { @@ -263,5 +263,28 @@ interface IInterface2 {
ResolveResult result = Resolve(program, "new ThisClassDoesNotExist()", 3, 24);
Assert.IsNull(result);
}
[Test]
public void OverloadLookupTest()
{
string program = @"class A {
void Method() {
}
int Multiply(int a, int b) { return a * b; }
double Multiply(double a, double b) { return a * b; }
}
";
ResolveResult result = Resolve(program, "Multiply(1, 1)", 3, 24);
Assert.IsNotNull(result);
Assert.IsTrue(result is MethodResolveResult, "'Multiply(1,1)' is MethodResolveResult");
Assert.AreEqual("System.Int32", result.ResolvedType.FullyQualifiedName, "'Multiply(1,1)'");
result = Resolve(program, "Multiply(1.0, 1.0)", 3, 24);
Assert.IsNotNull(result);
Assert.IsTrue(result is MethodResolveResult, "'Multiply(1.0,1.0)' is MethodResolveResult");
Assert.AreEqual("System.Double", result.ResolvedType.FullyQualifiedName, "'Multiply(1.0,1.0)'");
}
}
}

Loading…
Cancel
Save