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

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

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

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

@ -214,19 +214,19 @@ namespace NRefactoryToBooConverter.Tests @@ -214,19 +214,19 @@ namespace NRefactoryToBooConverter.Tests
[Test]
public void CreateEmptyArray()
{
TestExpr("new int[] { }", "(,)");
TestExpr("new int[] { }", "(of System.Int32: ,)");
}
[Test]
public void CreateArrayWithOneElement()
{
TestExpr("new int[] { 1 }", "(1,)");
TestExpr("new int[] { 1 }", "(of System.Int32: 1)");
}
[Test]
public void CreateArrayWithTwoElements()
{
TestExpr("new int[] { 1 , 2 }", "(1, 2)");
TestExpr("new int[] { 1 , 2 }", "(of System.Int32: 1, 2)");
}
[Test]
@ -253,10 +253,10 @@ namespace NRefactoryToBooConverter.Tests @@ -253,10 +253,10 @@ namespace NRefactoryToBooConverter.Tests
TestExpr("a ? b : c", "a ? b : c");
}
[Test, Ignore("ConditionalExpression does not have a boo syntax")]
[Test]
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 @@ -23,17 +23,13 @@ namespace ICSharpCode.Svn.Commands
bool recurse;
Revision revision = null;
/// <summary>
/// Creates a new CheckoutCommand
/// </summary>
public CheckoutCommand()
{
}
void DoCheckoutCommand()
{
try {
SvnClient.Instance.Client.Checkout(from, to, revision, recurse);
} catch (SvnClientException ex) {
MessageService.ShowError(ex.Message);
}
}
/// <summary>

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

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

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

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

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

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

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

@ -124,6 +124,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -124,6 +124,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
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) {
outputFormatter.PrintToken(Tokens.Global);
@ -148,17 +157,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -148,17 +157,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
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);
for (int j = 0; j < typeReference.RankSpecifier[i]; ++j) {
for (int j = 0; j < rankSpecifier[i]; ++j) {
outputFormatter.PrintToken(Tokens.Comma);
}
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
}
return null;
}
public object Visit(InnerClassTypeReference typeReference, object data)
{
@ -283,14 +293,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -283,14 +293,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
case ClassType.Interface:
return Tokens.Interface;
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;
}
default:
return Tokens.Class;
}
}
void PrintTemplates(List<TemplateDefinition> templates)
{
@ -2108,11 +2115,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2108,11 +2115,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
outputFormatter.PrintToken(Tokens.TypeOf);
outputFormatter.Space();
nodeTracker.TrackedVisit(typeOfIsExpression.TypeReference, data);
nodeTracker.TrackedVisit(typeOfIsExpression.Expression, data);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Is);
outputFormatter.Space();
nodeTracker.TrackedVisit(typeOfIsExpression.Expression, data);
nodeTracker.TrackedVisit(typeOfIsExpression.TypeReference, data);
return null;
}
@ -2268,16 +2275,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2268,16 +2275,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
outputFormatter.PrintToken(Tokens.New);
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);
nodeTracker.TrackedVisit((INode)arrayCreateExpression.Arguments[i], data);
AppendCommaSeparatedList(arrayCreateExpression.Arguments);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 1);
} else {
PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 0);
}
if (!arrayCreateExpression.ArrayInitializer.IsNull) {
outputFormatter.Space();
if (arrayCreateExpression.ArrayInitializer.IsNull) {
outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
} else {
nodeTracker.TrackedVisit(arrayCreateExpression.ArrayInitializer, data);
}
return null;
@ -2489,29 +2503,5 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2489,29 +2503,5 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
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 @@ -96,6 +96,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestStatement("Dim a As Object(,,)");
}
[Test]
public void ArrayInitialization()
{
TestStatement("Dim a As Object() = New Object(10) {}");
}
[Test]
public void Assignment()
{
@ -181,6 +187,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -181,6 +187,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestExpression("CStr(a)");
}
[Test]
public void TypeOfIs()
{
TestExpression("TypeOf a Is String");
}
[Test]
public void AbstractProperty()
{

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

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

Loading…
Cancel
Save