Browse Source

Fixed a minor bugs in C# to VB and Boo conversion, fixed possible endless loop in VB lexer and a NullReferenceException when using "Go to" in XML files.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@647 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
30f7efb8ea
  1. 3
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/ConvertBuffer.cs
  2. 6
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConverterSettings.cs
  3. 3
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
  4. 48
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  5. 2
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs
  6. 6
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

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

@ -45,7 +45,8 @@ namespace Grunwald.BooBinding @@ -45,7 +45,8 @@ namespace Grunwald.BooBinding
IList<ICSharpCode.NRefactory.Parser.ISpecial> 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) {

6
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConverterSettings.cs

@ -23,7 +23,9 @@ namespace NRefactoryToBooConverter @@ -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 @@ -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";
}
}

3
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

@ -90,6 +90,9 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -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) {

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

@ -973,12 +973,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -973,12 +973,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
#region Statements
public object Visit(BlockStatement blockStatement, object data)
{
foreach (Statement stmt in blockStatement.Children) {
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, data);
nodeTracker.TrackedVisit(stmt, null);
outputFormatter.NewLine();
}
return null;
}
}
public object Visit(AddHandlerStatement addHandlerStatement, object data)
@ -1060,7 +1069,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1060,7 +1069,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (localVariableDeclaration.Modifier != Modifier.None) {
OutputModifier(localVariableDeclaration.Modifier);
}
if ((localVariableDeclaration.Modifier & Modifier.Const) == 0) {
outputFormatter.PrintToken(Tokens.Dim);
}
outputFormatter.Space();
currentVariableType = localVariableDeclaration.TypeReference;
@ -1103,9 +1114,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -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 @@ -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 @@ -1376,7 +1381,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
--outputFormatter.IndentationLevel;
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 @@ -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 @@ -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,7 +2408,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2396,7 +2408,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (i + 1 < list.Count) {
outputFormatter.PrintToken(Tokens.Comma);
outputFormatter.Space();
}
if ((i + 1) % 6 == 0) {
outputFormatter.PrintText("_ ");
outputFormatter.NewLine();
@ -2406,6 +2417,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2406,6 +2417,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
}
}
}
void VisitAttributes(ICollection attributes, object data)
{

2
src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs

@ -11,7 +11,7 @@ using System.Collections; @@ -11,7 +11,7 @@ using System.Collections;
namespace ICSharpCode.NRefactory.Parser.AST
{
public class SwitchStatement : BlockStatement
public class SwitchStatement : Statement
{
Expression switchExpression;
// List<SwitchSection> switchSections;

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

@ -445,9 +445,9 @@ namespace ICSharpCode.Core @@ -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;
}

Loading…
Cancel
Save