Browse Source

Fixed a few minor bugs.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@779 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
28dfc752a6
  1. 7
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs
  2. 2
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs
  3. 10
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/ExpressionTests.cs
  4. 12
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/Checkout/CheckoutCommand.cs
  5. 4
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/Export/ExportCommand.cs
  6. 19
      src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/Export/ExportDialog.cs
  7. 5
      src/Libraries/ICSharpCode.TextEditor/Project/Resources/Boo.xshd
  8. 70
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  9. 12
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs
  10. 1
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

7
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs

@ -37,8 +37,6 @@ namespace Grunwald.BooBinding
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null && window.ViewContent is IEditable) { if (window != null && window.ViewContent is IEditable) {
StringBuilder errorBuilder = new StringBuilder();
CompilerErrorCollection errors = new CompilerErrorCollection(); CompilerErrorCollection errors = new CompilerErrorCollection();
CompilerWarningCollection warnings = new CompilerWarningCollection(); CompilerWarningCollection warnings = new CompilerWarningCollection();
Module module; Module module;
@ -48,6 +46,8 @@ namespace Grunwald.BooBinding
string fileName = window.ViewContent.FileName ?? window.ViewContent.UntitledName; string fileName = window.ViewContent.FileName ?? window.ViewContent.UntitledName;
module = Parser.ParseModule(compileUnit, r, ApplySettings(fileName, errors, warnings), out specials); module = Parser.ParseModule(compileUnit, r, ApplySettings(fileName, errors, warnings), out specials);
} }
if (module == null) {
StringBuilder errorBuilder = new StringBuilder();
foreach (CompilerError error in errors) { foreach (CompilerError error in errors) {
errorBuilder.AppendLine(error.ToString()); errorBuilder.AppendLine(error.ToString());
} }
@ -56,6 +56,9 @@ namespace Grunwald.BooBinding
errorBuilder.AppendLine(warning.ToString()); errorBuilder.AppendLine(warning.ToString());
} }
} }
MessageService.ShowError(errorBuilder.ToString());
return;
}
using (StringWriter w = new StringWriter()) { using (StringWriter w = new StringWriter()) {
foreach (CompilerError error in errors) { foreach (CompilerError error in errors) {
w.WriteLine("ERROR: " + error.ToString()); w.WriteLine("ERROR: " + error.ToString());

2
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs

@ -247,6 +247,8 @@ namespace NRefactoryToBooConverter
return B.BinaryOperatorType.Modulus; return B.BinaryOperatorType.Modulus;
case BinaryOperatorType.Multiply: case BinaryOperatorType.Multiply:
return B.BinaryOperatorType.Multiply; return B.BinaryOperatorType.Multiply;
case BinaryOperatorType.NullCoalescing:
return B.BinaryOperatorType.Or;
case BinaryOperatorType.Power: case BinaryOperatorType.Power:
return B.BinaryOperatorType.Exponentiation; return B.BinaryOperatorType.Exponentiation;
case BinaryOperatorType.ReferenceEquality: case BinaryOperatorType.ReferenceEquality:

10
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/ExpressionTests.cs

@ -214,19 +214,19 @@ namespace NRefactoryToBooConverter.Tests
[Test] [Test]
public void CreateEmptyArray() public void CreateEmptyArray()
{ {
TestExpr("new int[] { }", "(,)"); TestExpr("new int[] { }", "(of System.Int32: ,)");
} }
[Test] [Test]
public void CreateArrayWithOneElement() public void CreateArrayWithOneElement()
{ {
TestExpr("new int[] { 1 }", "(1,)"); TestExpr("new int[] { 1 }", "(of System.Int32: 1)");
} }
[Test] [Test]
public void CreateArrayWithTwoElements() public void CreateArrayWithTwoElements()
{ {
TestExpr("new int[] { 1 , 2 }", "(1, 2)"); TestExpr("new int[] { 1 , 2 }", "(of System.Int32: 1, 2)");
} }
[Test] [Test]
@ -253,10 +253,10 @@ namespace NRefactoryToBooConverter.Tests
TestExpr("a ? b : c", "a ? b : c"); TestExpr("a ? b : c", "a ? b : c");
} }
[Test, Ignore("ConditionalExpression does not have a boo syntax")] [Test]
public void NullCoalescing() public void NullCoalescing()
{ {
TestExpr("a ?? b", "(a != null) ? a : b"); TestExpr("a ?? b", "(a or b)");
} }
} }
} }

12
src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/Checkout/CheckoutCommand.cs

@ -23,17 +23,13 @@ namespace ICSharpCode.Svn.Commands
bool recurse; bool recurse;
Revision revision = null; Revision revision = null;
/// <summary>
/// Creates a new CheckoutCommand
/// </summary>
public CheckoutCommand()
{
}
void DoCheckoutCommand() void DoCheckoutCommand()
{ {
try {
SvnClient.Instance.Client.Checkout(from, to, revision, recurse); SvnClient.Instance.Client.Checkout(from, to, revision, recurse);
} catch (SvnClientException ex) {
MessageService.ShowError(ex.Message);
}
} }
/// <summary> /// <summary>

4
src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/Export/ExportCommand.cs

@ -36,7 +36,11 @@ namespace ICSharpCode.Svn.Commands
void DoExportCommand() void DoExportCommand()
{ {
try {
SvnClient.Instance.Client.Export(from, to, revision, false); SvnClient.Instance.Client.Export(from, to, revision, false);
} catch (SvnClientException ex) {
MessageService.ShowError(ex.Message);
}
} }
/// <summary> /// <summary>

19
src/AddIns/Misc/SubversionAddIn/Project/Src/Commands/Export/ExportDialog.cs

@ -48,6 +48,8 @@ namespace ICSharpCode.Svn.Commands
string ConvertPathToURL(string path) string ConvertPathToURL(string path)
{ {
if (path.Length == 0)
return "";
return "file:///" + path.Replace('\\', '/'); return "file:///" + path.Replace('\\', '/');
} }
@ -84,6 +86,16 @@ namespace ICSharpCode.Svn.Commands
ControlDictionary["sourceDirectoryBrowseButton"].Click += new EventHandler(SourceDirectoryBrowseButtonClick); ControlDictionary["sourceDirectoryBrowseButton"].Click += new EventHandler(SourceDirectoryBrowseButtonClick);
ControlDictionary["localDirectoryBrowseButton"].Click += new EventHandler(LocalDirectoryBrowseButtonClick); ControlDictionary["localDirectoryBrowseButton"].Click += new EventHandler(LocalDirectoryBrowseButtonClick);
ControlDictionary["sourceDirectoryTextBox"].TextChanged += UrlChanged;
ControlDictionary["urlTextBox"].TextChanged += UrlChanged;
ControlDictionary["localDirectoryTextBox"].TextChanged += UrlChanged;
UrlChanged(null, null);
}
void UrlChanged(object sender, EventArgs e)
{
Get<Button>("ok").Enabled = Source.Length > 0 && Destination.Length > 0;
} }
void RevisionComboBoxTextChanged(object sender, EventArgs e) void RevisionComboBoxTextChanged(object sender, EventArgs e)
@ -96,11 +108,12 @@ namespace ICSharpCode.Svn.Commands
ControlDictionary["urlTextBox"].Visible = !SourceIsLocalDirectory; ControlDictionary["urlTextBox"].Visible = !SourceIsLocalDirectory;
ControlDictionary["sourceDirectoryTextBox"].Visible = ControlDictionary["sourceDirectoryBrowseButton"].Visible = SourceIsLocalDirectory; ControlDictionary["sourceDirectoryTextBox"].Visible = ControlDictionary["sourceDirectoryBrowseButton"].Visible = SourceIsLocalDirectory;
if (ControlDictionary["urlTextBox"].Visible) { if (SourceIsLocalDirectory) {
ControlDictionary["urlLabel"].Text = "&URL:";
} else {
ControlDictionary["urlLabel"].Text = "&Source directory:"; ControlDictionary["urlLabel"].Text = "&Source directory:";
} else {
ControlDictionary["urlLabel"].Text = "&URL:";
} }
UrlChanged(null, null);
} }
void SourceDirectoryBrowseButtonClick(object sender, EventArgs e) void SourceDirectoryBrowseButtonClick(object sender, EventArgs e)

5
src/Libraries/ICSharpCode.TextEditor/Project/Resources/Boo.xshd

@ -181,10 +181,6 @@
<Key word="void"/> <Key word="void"/>
</KeyWords> </KeyWords>
<KeyWords name="Of" bold="true" italic="false" color="Blue" >
<Key word="of"/>
</KeyWords>
<KeyWords name="ConversionKeyWords" bold="true" italic="false" color="Blue" > <KeyWords name="ConversionKeyWords" bold="true" italic="false" color="Blue" >
<Key word="cast"/> <Key word="cast"/>
<Key word="as"/> <Key word="as"/>
@ -275,6 +271,7 @@
<Key word="mixin"/> <Key word="mixin"/>
<Key word="callable"/> <Key word="callable"/>
<Key word="do" /> <Key word="do" />
<Key word="of" >
</KeyWords> </KeyWords>
</RuleSet> </RuleSet>

70
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs

@ -124,6 +124,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
} }
public object Visit(TypeReference typeReference, object data) public object Visit(TypeReference typeReference, object data)
{
PrintTypeReferenceWithoutArray(typeReference);
if (typeReference.IsArrayType) {
PrintArrayRank(typeReference.RankSpecifier, 0);
}
return null;
}
void PrintTypeReferenceWithoutArray(TypeReference typeReference)
{ {
if (typeReference.IsGlobal) { if (typeReference.IsGlobal) {
outputFormatter.PrintToken(Tokens.Global); outputFormatter.PrintToken(Tokens.Global);
@ -148,17 +157,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
for (int i = 0; i < typeReference.PointerNestingLevel; ++i) { for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
outputFormatter.PrintToken(Tokens.Times); outputFormatter.PrintToken(Tokens.Times);
} }
if (typeReference.IsArrayType) { }
for (int i = 0; i < typeReference.RankSpecifier.Length; ++i) {
void PrintArrayRank(int[] rankSpecifier, int startRank)
{
for (int i = startRank; i < rankSpecifier.Length; ++i) {
outputFormatter.PrintToken(Tokens.OpenParenthesis); outputFormatter.PrintToken(Tokens.OpenParenthesis);
for (int j = 0; j < typeReference.RankSpecifier[i]; ++j) { for (int j = 0; j < rankSpecifier[i]; ++j) {
outputFormatter.PrintToken(Tokens.Comma); outputFormatter.PrintToken(Tokens.Comma);
} }
outputFormatter.PrintToken(Tokens.CloseParenthesis); outputFormatter.PrintToken(Tokens.CloseParenthesis);
} }
} }
return null;
}
public object Visit(InnerClassTypeReference typeReference, object data) public object Visit(InnerClassTypeReference typeReference, object data)
{ {
@ -283,14 +293,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
case ClassType.Interface: case ClassType.Interface:
return Tokens.Interface; return Tokens.Interface;
case ClassType.Struct: case ClassType.Struct:
// FIXME: This should be better in VBNetRefactory class because it is an AST transformation, but currently I'm too lazy
if (TypeHasOnlyStaticMembers(typeDeclaration)) {
goto case ClassType.Class;
}
return Tokens.Structure; return Tokens.Structure;
} default:
return Tokens.Class; return Tokens.Class;
} }
}
void PrintTemplates(List<TemplateDefinition> templates) void PrintTemplates(List<TemplateDefinition> templates)
{ {
@ -2108,11 +2115,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{ {
outputFormatter.PrintToken(Tokens.TypeOf); outputFormatter.PrintToken(Tokens.TypeOf);
outputFormatter.Space(); outputFormatter.Space();
nodeTracker.TrackedVisit(typeOfIsExpression.TypeReference, data); nodeTracker.TrackedVisit(typeOfIsExpression.Expression, data);
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Is); outputFormatter.PrintToken(Tokens.Is);
outputFormatter.Space(); outputFormatter.Space();
nodeTracker.TrackedVisit(typeOfIsExpression.Expression, data); nodeTracker.TrackedVisit(typeOfIsExpression.TypeReference, data);
return null; return null;
} }
@ -2268,16 +2275,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{ {
outputFormatter.PrintToken(Tokens.New); outputFormatter.PrintToken(Tokens.New);
outputFormatter.Space(); outputFormatter.Space();
nodeTracker.TrackedVisit(arrayCreateExpression.CreateType, data); PrintTypeReferenceWithoutArray(arrayCreateExpression.CreateType);
for (int i = 0; i < arrayCreateExpression.Arguments.Count; ++i) { if (arrayCreateExpression.Arguments.Count > 0) {
outputFormatter.PrintToken(Tokens.OpenParenthesis); outputFormatter.PrintToken(Tokens.OpenParenthesis);
nodeTracker.TrackedVisit((INode)arrayCreateExpression.Arguments[i], data); AppendCommaSeparatedList(arrayCreateExpression.Arguments);
outputFormatter.PrintToken(Tokens.CloseParenthesis); outputFormatter.PrintToken(Tokens.CloseParenthesis);
PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 1);
} else {
PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 0);
} }
if (!arrayCreateExpression.ArrayInitializer.IsNull) {
outputFormatter.Space(); outputFormatter.Space();
if (arrayCreateExpression.ArrayInitializer.IsNull) {
outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
} else {
nodeTracker.TrackedVisit(arrayCreateExpression.ArrayInitializer, data); nodeTracker.TrackedVisit(arrayCreateExpression.ArrayInitializer, data);
} }
return null; return null;
@ -2489,29 +2503,5 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return false; return false;
} }
bool TypeHasOnlyStaticMembers(TypeDeclaration typeDeclaration)
{
foreach (object o in typeDeclaration.Children) {
if (o is MethodDeclaration) {
if ((((MethodDeclaration)o).Modifier & Modifier.Static) != Modifier.Static) {
return false;
}
} else if (o is PropertyDeclaration) {
if ((((PropertyDeclaration)o).Modifier & Modifier.Static) != Modifier.Static) {
return false;
}
} else if (o is FieldDeclaration) {
if ((((FieldDeclaration)o).Modifier & Modifier.Static) != Modifier.Static) {
return false;
}
} else if (o is EventDeclaration) {
if ((((EventDeclaration)o).Modifier & Modifier.Static) != Modifier.Static) {
return false;
}
}
}
return true;
}
} }
} }

12
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -96,6 +96,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestStatement("Dim a As Object(,,)"); TestStatement("Dim a As Object(,,)");
} }
[Test]
public void ArrayInitialization()
{
TestStatement("Dim a As Object() = New Object(10) {}");
}
[Test] [Test]
public void Assignment() public void Assignment()
{ {
@ -181,6 +187,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestExpression("CStr(a)"); TestExpression("CStr(a)");
} }
[Test]
public void TypeOfIs()
{
TestExpression("TypeOf a Is String");
}
[Test] [Test]
public void AbstractProperty() public void AbstractProperty()
{ {

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

@ -379,6 +379,7 @@ namespace ICSharpCode.Core
"System.Drawing", "System.Drawing",
"System.Windows.Forms", "System.Windows.Forms",
"System.XML", "System.XML",
"Microsoft.VisualBasic",
}; };
foreach (string defaultReference in defaultReferences) { foreach (string defaultReference in defaultReferences) {
ReferenceProjectItem item = new ReferenceProjectItem(null, defaultReference); ReferenceProjectItem item = new ReferenceProjectItem(null, defaultReference);

Loading…
Cancel
Save