diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs index 5fb43a9e9f..640d40b6d5 100644 --- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs +++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs @@ -45,7 +45,8 @@ namespace Grunwald.BooBinding IList specials; CompileUnit compileUnit = new CompileUnit(); using (StringReader r = new StringReader(((IEditable)window.ViewContent).Text)) { - module = Parser.ParseModule(compileUnit, r, ApplySettings(window.ViewContent.FileName, errors, warnings), out specials); + string fileName = window.ViewContent.FileName ?? window.ViewContent.UntitledName; + module = Parser.ParseModule(compileUnit, r, ApplySettings(fileName, errors, warnings), out specials); } if (errors.Count > 0) { foreach (CompilerError error in errors) { diff --git a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConverterSettings.cs b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConverterSettings.cs index 29b3400305..4a5acf83f3 100644 --- a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConverterSettings.cs +++ b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConverterSettings.cs @@ -23,7 +23,9 @@ namespace NRefactoryToBooConverter static StringComparer GetComparer(string fileName) { - if (System.IO.Path.GetExtension(fileName).ToLower() == ".vb") + if (fileName == null) + throw new ArgumentNullException("fileName"); + if (System.IO.Path.GetExtension(fileName).ToLowerInvariant() == ".vb") return StringComparer.InvariantCultureIgnoreCase; else return StringComparer.InvariantCulture; @@ -31,7 +33,7 @@ namespace NRefactoryToBooConverter public bool IsVisualBasic { get { - return System.IO.Path.GetExtension(fileName).ToLower() == ".vb"; + return System.IO.Path.GetExtension(fileName).ToLowerInvariant() == ".vb"; } } diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs index 72cdc5d617..6da6d08434 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs @@ -90,6 +90,9 @@ namespace ICSharpCode.NRefactory.Parser.VB } if (ReaderPeek() != -1) { ch = (char)ReaderRead(); + } else { + errors.Error(Line, Col, String.Format("No EOF expected after _")); + return new Token(Tokens.EOF); } } if (!lineEnd) { diff --git a/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs index 27e733c358..7e48ac6b72 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs @@ -973,14 +973,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter #region Statements public object Visit(BlockStatement blockStatement, object data) { - foreach (Statement stmt in blockStatement.Children) { - outputFormatter.Indent(); - nodeTracker.TrackedVisit(stmt, data); - outputFormatter.NewLine(); - } + OnBlock(blockStatement.Children); return null; } + void OnBlock(ArrayList statements) + { + foreach (Statement stmt in statements) { + if (stmt is BlockStatement) { + nodeTracker.TrackedVisit(stmt, null); + } else { + outputFormatter.Indent(); + nodeTracker.TrackedVisit(stmt, null); + outputFormatter.NewLine(); + } + } + } + public object Visit(AddHandlerStatement addHandlerStatement, object data) { outputFormatter.PrintToken(Tokens.AddHandler); @@ -1060,7 +1069,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter if (localVariableDeclaration.Modifier != Modifier.None) { OutputModifier(localVariableDeclaration.Modifier); } - outputFormatter.PrintToken(Tokens.Dim); + if ((localVariableDeclaration.Modifier & Modifier.Const) == 0) { + outputFormatter.PrintToken(Tokens.Dim); + } outputFormatter.Space(); currentVariableType = localVariableDeclaration.TypeReference; @@ -1103,9 +1114,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.PrintToken(Tokens.Then); outputFormatter.NewLine(); ++outputFormatter.IndentationLevel; - foreach (Statement stmt in ifElseStatement.TrueStatement) { - nodeTracker.TrackedVisit(stmt, data); - } + OnBlock(ifElseStatement.TrueStatement); --outputFormatter.IndentationLevel; foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) { @@ -1117,11 +1126,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.PrintToken(Tokens.Else); outputFormatter.NewLine(); ++outputFormatter.IndentationLevel; - foreach (Statement stmt in ifElseStatement.FalseStatement) { - outputFormatter.Indent(); - nodeTracker.TrackedVisit(stmt, data); - outputFormatter.NewLine(); - } + OnBlock(ifElseStatement.FalseStatement); --outputFormatter.IndentationLevel; } @@ -1376,7 +1381,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } --outputFormatter.IndentationLevel; - outputFormatter.PrintToken(Tokens.Loop); + outputFormatter.Indent(); + if (doLoopStatement.ConditionType == ConditionType.While) { + outputFormatter.PrintToken(Tokens.End); + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.While); + } else { + outputFormatter.PrintToken(Tokens.Loop); + } if (doLoopStatement.ConditionPosition == ConditionPosition.End) { outputFormatter.Space(); @@ -1562,25 +1574,25 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public object Visit(FixedStatement fixedStatement, object data) { errors.Error(-1, -1, String.Format("FixedStatement is unsupported")); - return null; + return nodeTracker.TrackedVisit(fixedStatement.EmbeddedStatement, data); } public object Visit(UnsafeStatement unsafeStatement, object data) { errors.Error(-1, -1, String.Format("UnsafeStatement is unsupported")); - return null; + return nodeTracker.TrackedVisit(unsafeStatement.Block, data); } public object Visit(CheckedStatement checkedStatement, object data) { errors.Error(-1, -1, String.Format("CheckedStatement is unsupported")); - return null; + return nodeTracker.TrackedVisit(checkedStatement.Block, data); } public object Visit(UncheckedStatement uncheckedStatement, object data) { errors.Error(-1, -1, String.Format("UncheckedStatement is unsupported")); - return null; + return nodeTracker.TrackedVisit(uncheckedStatement.Block, data); } public object Visit(ExitStatement exitStatement, object data) @@ -2091,13 +2103,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public object Visit(CheckedExpression checkedExpression, object data) { errors.Error(-1, -1, String.Format("CheckedExpression is unsupported")); - return null; + return nodeTracker.TrackedVisit(checkedExpression.Expression, data); } public object Visit(UncheckedExpression uncheckedExpression, object data) { errors.Error(-1, -1, String.Format("UncheckedExpression is unsupported")); - return null; + return nodeTracker.TrackedVisit(uncheckedExpression.Expression, data); } public object Visit(PointerReferenceExpression pointerReferenceExpression, object data) @@ -2396,12 +2408,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter if (i + 1 < list.Count) { outputFormatter.PrintToken(Tokens.Comma); outputFormatter.Space(); - } - if ((i + 1) % 6 == 0) { - outputFormatter.PrintText("_ "); - outputFormatter.NewLine(); - outputFormatter.Indent(); - outputFormatter.PrintText("\t"); + if ((i + 1) % 6 == 0) { + outputFormatter.PrintText("_ "); + outputFormatter.NewLine(); + outputFormatter.Indent(); + outputFormatter.PrintText("\t"); + } } } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs index 6cc39b93fa..0d8d7c9dde 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs @@ -11,7 +11,7 @@ using System.Collections; namespace ICSharpCode.NRefactory.Parser.AST { - public class SwitchStatement : BlockStatement + public class SwitchStatement : Statement { Expression switchExpression; // List switchSections; diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index 9401f6228a..7945b89823 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -445,9 +445,9 @@ namespace ICSharpCode.Core public static ArrayList CtrlSpace(int caretLine, int caretColumn, string fileName, string fileContent, ExpressionContext context) { - IParser parser = GetParser(fileName); - if (parser != null) { - return parser.CreateResolver().CtrlSpace(caretLine, caretColumn, fileName, fileContent, context); + IResolver resolver = CreateResolver(fileName); + if (resolver != null) { + return resolver.CtrlSpace(caretLine, caretColumn, fileName, fileContent, context); } return null; }