Browse Source

Disabled COM registration for MyMeta.

Add logging for text editor's undo stack.
C# parser: fixed [module: ..] attributes
C# code completion: suggest "assembly", "module", etc. when typing an attribute.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2719 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
cf79e8fa40
  1. 1
      src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj
  2. 27
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs
  3. 29
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Undo/UndoStack.cs
  4. 24
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/LoggingService.cs
  5. 2
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs
  6. 2271
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  7. 11
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  8. 19
      src/Libraries/NRefactory/Test/Parser/GlobalScope/AttributeSectionTests.cs
  9. 2
      src/Main/Base/Project/Src/Gui/AbstractPadContent.cs
  10. 8
      src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
  11. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AttributesDataProvider.cs
  12. 3
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
  13. 11
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

1
src/Libraries/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj

@ -91,6 +91,7 @@ @@ -91,6 +91,7 @@
<Compile Include="Src\Document\TextBufferStrategy\ITextBufferStrategy.cs" />
<Compile Include="Src\Document\TextBufferStrategy\StringTextBufferStrategy.cs" />
<Compile Include="Src\Util\AugmentableRedBlackTree.cs" />
<Compile Include="Src\Util\LoggingService.cs" />
<Compile Include="Src\Util\LookupTable.cs" />
<Compile Include="Src\Util\RedBlackTreeIterator.cs" />
<Compile Include="Src\Util\TextUtility.cs" />

27
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs

@ -187,19 +187,22 @@ namespace ICSharpCode.TextEditor @@ -187,19 +187,22 @@ namespace ICSharpCode.TextEditor
string text = (string)data.GetData(DataFormats.UnicodeText);
if (text.Length > 0) {
textArea.Document.UndoStack.StartUndoGroup();
if (textArea.SelectionManager.HasSomethingSelected) {
Delete(sender, e);
try {
if (textArea.SelectionManager.HasSomethingSelected) {
Delete(sender, e);
}
if (fullLine) {
int col = textArea.Caret.Column;
textArea.Caret.Column = 0;
textArea.InsertString(text);
textArea.Caret.Column = col;
}
else {
textArea.InsertString(text);
}
} finally {
textArea.Document.UndoStack.EndUndoGroup();
}
if (fullLine) {
int col = textArea.Caret.Column;
textArea.Caret.Column = 0;
textArea.InsertString(text);
textArea.Caret.Column = col;
}
else {
textArea.InsertString(text);
}
textArea.Document.UndoStack.EndUndoGroup();
}
}
return;

29
src/Libraries/ICSharpCode.TextEditor/Project/Src/Undo/UndoStack.cs

@ -70,15 +70,6 @@ namespace ICSharpCode.TextEditor.Undo @@ -70,15 +70,6 @@ namespace ICSharpCode.TextEditor.Undo
}
}
// /// <summary>
// /// You call this method to pool the last x operations from the undo stack
// /// to make 1 operation from it.
// /// </summary>
// public void CombineLast(int actionCount)
// {
// undostack.Push(new UndoQueue(undostack, actionCount));
// }
int undoGroupDepth;
int actionCountInUndoGroup;
@ -88,6 +79,7 @@ namespace ICSharpCode.TextEditor.Undo @@ -88,6 +79,7 @@ namespace ICSharpCode.TextEditor.Undo
actionCountInUndoGroup = 0;
}
undoGroupDepth++;
Util.LoggingService.Debug("Open undo group (new depth=" + undoGroupDepth + ")");
}
public void EndUndoGroup()
@ -95,19 +87,25 @@ namespace ICSharpCode.TextEditor.Undo @@ -95,19 +87,25 @@ namespace ICSharpCode.TextEditor.Undo
if (undoGroupDepth == 0)
throw new InvalidOperationException("There are no open undo groups");
undoGroupDepth--;
Util.LoggingService.Debug("Close undo group (new depth=" + undoGroupDepth + ")");
if (undoGroupDepth == 0 && actionCountInUndoGroup > 1) {
undostack.Push(new UndoQueue(undostack, actionCountInUndoGroup));
}
}
public void AssertNoUndoGroupOpen()
{
if (undoGroupDepth != 0) {
throw new InvalidOperationException("No undo group should be open at this point");
}
}
/// <summary>
/// Call this method to undo the last operation on the stack
/// </summary>
public void Undo()
{
if (undoGroupDepth != 0) {
throw new InvalidOperationException("cannot perform Undo/Redo while undo group is open");
}
AssertNoUndoGroupOpen();
if (undostack.Count > 0) {
IUndoableOperation uedit = (IUndoableOperation)undostack.Pop();
redostack.Push(uedit);
@ -121,9 +119,7 @@ namespace ICSharpCode.TextEditor.Undo @@ -121,9 +119,7 @@ namespace ICSharpCode.TextEditor.Undo
/// </summary>
public void Redo()
{
if (undoGroupDepth != 0) {
throw new InvalidOperationException("cannot perform Undo/Redo while undo group is open");
}
AssertNoUndoGroupOpen();
if (redostack.Count > 0) {
IUndoableOperation uedit = (IUndoableOperation)redostack.Pop();
undostack.Push(uedit);
@ -139,7 +135,7 @@ namespace ICSharpCode.TextEditor.Undo @@ -139,7 +135,7 @@ namespace ICSharpCode.TextEditor.Undo
public void Push(IUndoableOperation operation)
{
if (operation == null) {
throw new ArgumentNullException("UndoStack.Push(UndoableOperation operation) : operation can't be null");
throw new ArgumentNullException("operation");
}
if (AcceptChanges) {
@ -168,6 +164,7 @@ namespace ICSharpCode.TextEditor.Undo @@ -168,6 +164,7 @@ namespace ICSharpCode.TextEditor.Undo
/// </summary>
public void ClearAll()
{
AssertNoUndoGroupOpen();
undostack.Clear();
redostack.Clear();
actionCountInUndoGroup = 0;

24
src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/LoggingService.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.TextEditor.Util
{
/// <summary>
/// Central location for logging calls in the text editor.
/// </summary>
static class LoggingService
{
public static void Debug(string text)
{
#if DEBUG
Console.WriteLine(text);
#endif
}
}
}

2
src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs

@ -394,7 +394,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -394,7 +394,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
bool IsGlobalAttrTarget () {
Token pt = Peek(1);
return la.kind == Tokens.OpenSquareBracket &&
IsIdentifierToken(pt) && pt.val == "assembly";
IsIdentifierToken(pt) && (pt.val == "assembly" || pt.val == "module");
}
/* True, if "[" is followed by "," or "]" */

2271
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

11
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -210,7 +210,7 @@ UsingDirective @@ -210,7 +210,7 @@ UsingDirective
GlobalAttributeSection
=
"[" (. Location startPos = t.Location; .) Identifier
(. if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected");
(. if (t.val != "assembly" && t.val != "module") Error("global attribute target specifier (assembly or module) expected");
string attributeTarget = t.val;
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
@ -288,11 +288,10 @@ AttributeSection<out AttributeSection section> @@ -288,11 +288,10 @@ AttributeSection<out AttributeSection section>
[ IF (IsLocalAttrTarget())
( "event" (. attributeTarget = "event";.)
| "return" (. attributeTarget = "return";.)
| Identifier (. if (t.val != "field" || t.val != "method" ||
t.val != "module" || t.val != "param" ||
t.val != "property" || t.val != "type")
Error("attribute target specifier (event, return, field," +
"method, module, param, property, or type) expected");
| Identifier (. if (t.val != "field" && t.val != "method" &&
t.val != "param" &&
t.val != "property" && t.val != "type")
Error("attribute target specifier (field, event, method, param, property, return or type) expected");
attributeTarget = t.val;
.)
) ":"

19
src/Libraries/NRefactory/Test/Parser/GlobalScope/AttributeSectionTests.cs

@ -81,6 +81,25 @@ public class Form1 { @@ -81,6 +81,25 @@ public class Form1 {
Assert.AreEqual("assembly", decl.AttributeTarget);
}
[Test]
public void ModuleAttributeCSharp()
{
string program = @"[module: System.Attribute()]";
AttributeSection decl = ParseUtilCSharp.ParseGlobal<AttributeSection>(program);
Assert.AreEqual(new Location(1, 1), decl.StartLocation);
Assert.AreEqual("module", decl.AttributeTarget);
}
[Test]
public void TypeAttributeCSharp()
{
string program = @"[type: System.Attribute()] class Test {}";
TypeDeclaration type = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
AttributeSection decl = type.Attributes[0];
Assert.AreEqual(new Location(1, 1), decl.StartLocation);
Assert.AreEqual("type", decl.AttributeTarget);
}
[Test]
public void AssemblyAttributeVBNet()
{

2
src/Main/Base/Project/Src/Gui/AbstractPadContent.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public bool IsVisible {
get {
return Control.Visible && Control.Width > 0;
return Control.Visible && Control.Width > 0 && Control.Height > 0;
}
}
}

8
src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs

@ -98,6 +98,14 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -98,6 +98,14 @@ namespace ICSharpCode.SharpDevelop.Gui
if (expressionFinder == null) return null;
Caret caret = ctl.ActiveTextAreaControl.Caret;
string content = (e == null) ? ctl.Text : e.Content;
if (caret.Offset >= content.Length) {
#if DEBUG
// the caret offset should not be invalid here - try to find out the when the text editor
// doesn't validate the caret position
System.Diagnostics.Debugger.Break();
#endif
return null;
}
ExpressionResult expr = expressionFinder.FindFullExpression(content, caret.Offset);
if (expr.Expression == null) return null;
return ParserService.Resolve(expr, caret.Line + 1, caret.Column + 1, fileName, content);

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/AttributesDataProvider.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -18,7 +18,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public class AttributesDataProvider : CtrlSpaceCompletionDataProvider
{
public AttributesDataProvider(IProjectContent pc)
: this(ExpressionContext.TypeDerivingFrom(pc.SystemTypes.Attribute, true))
: this(ExpressionContext.Attribute)
{
}

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

@ -71,6 +71,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -71,6 +71,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public bool EnableUndo {
get {
#if DEBUG
textEditorControl.Document.UndoStack.AssertNoUndoGroupOpen();
#endif
return textEditorControl.EnableUndo;
}
}

11
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -1295,6 +1295,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -1295,6 +1295,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
AddCSharpPrimitiveTypes(result);
CtrlSpaceInternal(result, fileContent);
}
} else if (context == ExpressionContext.Attribute) {
CtrlSpaceInternal(result, fileContent);
result.Add("assembly");
result.Add("module");
result.Add("field");
result.Add("event");
result.Add("method");
result.Add("param");
result.Add("property");
result.Add("return");
result.Add("type");
} else if (context == ExpressionContext.Default) {
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.ExpressionStart);
AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.ExpressionContent);

Loading…
Cancel
Save