Browse Source

Fixed some C# <-> VB conversion bugs.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@182 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
69dd3ca12d
  1. 6
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/FoldMarker.cs
  2. 23
      src/Libraries/NRefactory/NRefactory.sln
  3. 4
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  4. 54
      src/Libraries/NRefactory/Project/Src/Lexer/Special/PreProcessingDirective.cs
  5. 51
      src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs
  6. 16
      src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs
  7. 4
      src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs
  8. 4
      src/Libraries/NRefactory/Project/Src/Output/NodeInformVisitor.cs
  9. 6
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputFormatter.cs
  10. 4
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  11. 844
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  12. 44
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  13. 4683
      src/Libraries/NRefactory/Project/Src/Parser/Frames/trace.txt
  14. 892
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  15. 26
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  16. 110
      src/Libraries/NRefactory/Test/Main.cs
  17. 16
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj
  18. 11
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj.user
  19. 33
      src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs
  20. 3
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  21. 8
      src/Main/Base/Project/Src/Commands/VBConverter/CSharpConvertBuffer.cs
  22. 8
      src/Main/Base/Project/Src/Commands/VBConverter/ConvertBuffer.cs
  23. 19
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  24. 4
      src/Main/Core/Project/Src/Services/PropertyService/Properties.cs

6
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/FoldMarker.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
@ -123,8 +123,8 @@ namespace ICSharpCode.TextEditor.Document @@ -123,8 +123,8 @@ namespace ICSharpCode.TextEditor.Document
this.FoldType = foldType;
this.foldText = foldText;
this.offset = startLineSegment.Offset + startColumn;
this.length = (endLineSegment.Offset + endColumn) - this.offset;
this.offset = startLineSegment.Offset + Math.Min(startColumn, startLineSegment.Length);
this.length = (endLineSegment.Offset + Math.Min(endColumn, endLineSegment.Length)) - this.offset;
this.isFolded = isFolded;
}

23
src/Libraries/NRefactory/NRefactory.sln

@ -1,8 +1,25 @@ @@ -1,8 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "Project\NRefactory.csproj", "{3a9ae6aa-bc07-4a2f-972c-581e3ae2f195}"
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Tests", "Test\NRefactoryTests.csproj", "{870115dd-960a-4406-a6b9-600bcdc36a03}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{870115DD-960A-4406-A6B9-600BCDC36A03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{870115DD-960A-4406-A6B9-600BCDC36A03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{870115DD-960A-4406-A6B9-600BCDC36A03}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

4
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
if (Char.IsLetter(ch) || ch == '_') {
int x = col;
int x = col - 1; // col was incremented above, but we want the start of the identifier
int y = line;
string s = ReadIdent(ch);
int keyWordToken = Keywords.GetToken(s);
@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
Point start = new Point(col - 1, line);
string directive = ReadIdent('#');
string argument = ReadToEOL();
this.specialTracker.AddPreProcessingDirective(directive, argument, start, new Point(start.X + directive.Length + argument.Length, start.Y));
this.specialTracker.AddPreProcessingDirective(directive, argument.Trim(), start, new Point(start.X + directive.Length + argument.Length, start.Y));
continue;
case '"':
return ReadString();

54
src/Libraries/NRefactory/Project/Src/Lexer/Special/PreProcessingDirective.cs

@ -1,13 +1,61 @@ @@ -1,13 +1,61 @@
using System;
using System.Drawing;
using System.Text;
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.Parser
{
public class PreProcessingDirective : AbstractSpecial
{
public static void VBToCSharp(List<ISpecial> list)
{
for (int i = 0; i < list.Count; ++i) {
if (list[i] is PreProcessingDirective)
list[i] = VBToCSharp((PreProcessingDirective)list[i]);
}
}
public static PreProcessingDirective VBToCSharp(PreProcessingDirective dir)
{
string cmd = dir.Cmd.ToLower();
string arg = dir.Arg;
switch (cmd) {
case "#end":
if (arg.ToLower().StartsWith("region")) {
cmd = "#endregion";
arg = "";
}
break;
}
return new PreProcessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition);
}
public static void CSharpToVB(List<ISpecial> list)
{
for (int i = 0; i < list.Count; ++i) {
if (list[i] is PreProcessingDirective)
list[i] = CSharpToVB((PreProcessingDirective)list[i]);
}
}
public static PreProcessingDirective CSharpToVB(PreProcessingDirective dir)
{
string cmd = dir.Cmd;
string arg = dir.Arg;
switch (cmd) {
case "#region":
cmd = "#Region";
if (!arg.StartsWith("\"")) {
arg = "\"" + arg.Trim() + "\"";
}
break;
case "#endregion":
cmd = "#End";
arg = "Region";
break;
}
return new PreProcessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition);
}
string cmd;
string arg;

51
src/Libraries/NRefactory/Project/Src/Output/AbstractOutputFormatter.cs

@ -69,8 +69,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -69,8 +69,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
this.prettyPrintOptions = prettyPrintOptions;
}
bool isIndented = false;
public void Indent()
{
if (DoIndent) {
@ -87,7 +85,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -87,7 +85,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
++indent;
}
}
isIndented = true;
}
}
@ -96,54 +93,38 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -96,54 +93,38 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
text.Append(' ');
}
bool gotBlankLine = true;
ArrayList specialsText = new ArrayList();
int lastLineStart = 0;
public virtual void NewLine()
{
if (DoNewLine) {
text.Append(Environment.NewLine);
gotBlankLine = true;
isIndented = false;
WriteSpecials();
text.AppendLine();
lastLineStart = text.Length;
}
}
public virtual void EndFile()
{
WriteSpecials();
}
protected void WriteInNextNewLine(string text)
protected void WriteInPreviousLine(string txt)
{
specialsText.Add(text);
if (gotBlankLine) {
WriteSpecials();
}
}
void WriteSpecials()
{
if (isIndented) {
foreach (string txt in specialsText) {
text.Append(txt);
text.Append(Environment.NewLine);
Indent();
}
if (text.Length == lastLineStart) {
Indent();
text.AppendLine(txt);
lastLineStart = text.Length;
} else {
foreach (string txt in specialsText) {
Indent();
text.Append(txt);
text.Append(Environment.NewLine);
}
isIndented = false;
string lastLine = text.ToString(lastLineStart, text.Length - lastLineStart);
text.Remove(lastLineStart, text.Length - lastLineStart);
Indent();
text.AppendLine(txt);
lastLineStart = text.Length;
text.Append(lastLine);
}
specialsText.Clear();
}
public void PrintTokenList(ArrayList tokenList)
{
gotBlankLine = false;
foreach (int token in tokenList) {
PrintToken(token);
Space();
@ -154,20 +135,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -154,20 +135,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public virtual void PrintPreProcessingDirective(PreProcessingDirective directive)
{
WriteInNextNewLine(directive.Cmd + directive.Arg);
WriteInPreviousLine(directive.Cmd + " " + directive.Arg);
}
public abstract void PrintToken(int token);
protected void PrintToken(string text)
{
gotBlankLine = false;
this.text.Append(text);
}
public void PrintIdentifier(string identifier)
{
gotBlankLine = false;
text.Append(identifier);
}
}

16
src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs

@ -295,6 +295,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -295,6 +295,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
}
TypeDeclaration currentType = null;
public object Visit(TypeDeclaration typeDeclaration, object data)
{
VisitAttributes(typeDeclaration.Attributes, data);
@ -347,11 +349,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -347,11 +349,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
break;
}
TypeDeclaration oldType = currentType;
currentType = typeDeclaration;
if (typeDeclaration.Type == Types.Enum) {
OutputEnumMembers(typeDeclaration, data);
} else {
nodeTracker.TrackedVisitChildren(typeDeclaration, data);
}
currentType = oldType;
outputFormatter.EndBrace();
return null;
@ -549,7 +554,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -549,7 +554,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(constructorDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(constructorDeclaration.Modifier);
outputFormatter.PrintIdentifier(constructorDeclaration.Name);
if (currentType != null) {
outputFormatter.PrintIdentifier(currentType.Name);
} else {
outputFormatter.PrintIdentifier(constructorDeclaration.Name);
}
if (prettyPrintOptions.BeforeConstructorDeclarationParentheses) {
outputFormatter.Space();
}
@ -736,8 +745,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -736,8 +745,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
void OutputBlock(BlockStatement blockStatement, BraceStyle braceStyle)
{
nodeTracker.BeginNode(blockStatement);
if (blockStatement.IsNull) {
outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.NewLine();
nodeTracker.EndNode(blockStatement);
} else {
outputFormatter.BeginBrace(braceStyle);
foreach (Statement stmt in blockStatement.Children) {
@ -745,9 +757,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -745,9 +757,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
nodeTracker.TrackedVisit(stmt, null);
outputFormatter.NewLine();
}
nodeTracker.EndNode(blockStatement);
outputFormatter.EndBrace();
}
outputFormatter.NewLine();
}
public object Visit(BlockStatement blockStatement, object data)

4
src/Libraries/NRefactory/Project/Src/Output/CSharp/OutputFormatter.cs

@ -127,10 +127,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -127,10 +127,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
PrintToken("*/");
break;
case CommentType.Documentation:
WriteInNextNewLine("///" + comment.CommentText);
WriteInPreviousLine("///" + comment.CommentText);
break;
default:
WriteInNextNewLine("//" + comment.CommentText);
WriteInPreviousLine("//" + comment.CommentText);
break;
}
}

4
src/Libraries/NRefactory/Project/Src/Output/NodeInformVisitor.cs

@ -62,10 +62,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -62,10 +62,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
foreach (INode child in node.Children) {
TrackedVisit(child, data);
}
if (NodeChildrenVisited != null) {
NodeChildrenVisited(node);
}
return data;
}
public event InformNode NodeVisiting;
public event InformNode NodeChildrenVisited;
public event InformNode NodeVisited;
}
}

6
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputFormatter.cs

@ -36,13 +36,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -36,13 +36,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
switch (comment.CommentType) {
case CommentType.Block:
WriteInNextNewLine("'" + comment.CommentText.Replace("\n", "\n'"));
WriteInPreviousLine("'" + comment.CommentText.Replace("\n", "\n'"));
break;
case CommentType.Documentation:
WriteInNextNewLine("'''" + comment.CommentText);
WriteInPreviousLine("'''" + comment.CommentText);
break;
default:
WriteInNextNewLine("'" + comment.CommentText);
WriteInPreviousLine("'" + comment.CommentText);
break;
}
}

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

@ -268,7 +268,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -268,7 +268,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(TypeDeclaration typeDeclaration, object data)
{
outputFormatter.NewLine();
VisitAttributes(typeDeclaration.Attributes, data);
outputFormatter.Indent();
@ -298,7 +297,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -298,7 +297,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
foreach (TemplateDefinition templateDefinition in typeDeclaration.Templates) {
templateDefinition.AcceptVisitor(this, data);
nodeTracker.TrackedVisit(templateDefinition, data);
}
++outputFormatter.IndentationLevel;
@ -327,7 +326,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -327,7 +326,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public object Visit(DelegateDeclaration delegateDeclaration, object data)
{
outputFormatter.NewLine();
VisitAttributes(delegateDeclaration.Attributes, data);
OutputModifier(delegateDeclaration.Modifier);
outputFormatter.PrintToken(Tokens.Delegate);

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

File diff suppressed because it is too large Load Diff

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

@ -1621,30 +1621,32 @@ Statement @@ -1621,30 +1621,32 @@ Statement
(.
TypeReference type;
Expression expr;
Statement stmt;
Statement stmt = null;
Point startPos = la.Location;
.)
=
/*--- labeled statement: */
IF (IsLabel()) ident (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
":" Statement
/*--- local constant declaration: */
| "const" Type<out type> (. LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; .)
ident (. ident = t.val; .)
"=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .)
{ "," ident (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) }
";" (. compilationUnit.AddChild(var); .)
/*--- local variable declaration: */
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
/* LL(1) confict: LocalVariableDecl *
* <-> StatementExpr *
* ident {"." ident} { "[" Expr ... */
(. if (stmt != null) {
stmt.StartLocation = startPos;
stmt.EndLocation = t.EndLocation;
}
(
/*--- labeled statement: */
IF (IsLabel()) ident (. compilationUnit.AddChild(new LabelStatement(t.val)); .)
":" Statement
/*--- local constant declaration: */
| "const" Type<out type> (. LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; .)
ident (. ident = t.val; .)
"=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .)
{ "," ident (. ident = t.val; .) "=" Expr<out expr> (. var.Variables.Add(new VariableDeclaration(ident, expr)); .) }
";" (. compilationUnit.AddChild(var); .)
/*--- local variable declaration: */
| IF (IsLocalVarDecl()) LocalVariableDecl<out stmt> ";" (. compilationUnit.AddChild(stmt); .)
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
/* LL(1) confict: LocalVariableDecl *
* <-> StatementExpr *
* ident {"." ident} { "[" Expr ... */
)
(.
if (stmt != null) {
stmt.StartLocation = startPos;
stmt.EndLocation = t.EndLocation;
}
.)
.

4683
src/Libraries/NRefactory/Project/Src/Parser/Frames/trace.txt

File diff suppressed because it is too large Load Diff

892
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

26
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -1904,18 +1904,26 @@ Block<out Statement stmt> @@ -1904,18 +1904,26 @@ Block<out Statement stmt>
Statement
(.
Statement stmt;
Statement stmt = null;
Point startPos = la.Location;
string label = String.Empty;
.) =
| IF (IsLabel()) LabelName<out label>
(.
compilationUnit.AddChild(new LabelStatement(t.val));
.)
":" Statement
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
| LocalDeclarationStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
(
| IF (IsLabel()) LabelName<out label>
(.
compilationUnit.AddChild(new LabelStatement(t.val));
.)
":" Statement
| EmbeddedStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
| LocalDeclarationStatement<out stmt> (. compilationUnit.AddChild(stmt); .)
)
(.
if (stmt != null) {
stmt.StartLocation = startPos;
stmt.EndLocation = t.Location;
}
.)
.
/* 10.2 */

110
src/Libraries/NRefactory/Test/Main.cs

@ -1,110 +0,0 @@ @@ -1,110 +0,0 @@
/*
* Created by SharpDevelop.
* User: Omnibrain
* Date: 08.09.2004
* Time: 22:57
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using System.Collections.Specialized;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
namespace ICSharpCode.NRefactory
{
/// <summary>
/// Description of Main.
/// </summary>
public class MainClass
{
public static ArrayList SearchDirectory(string directory, string filemask)
{
return SearchDirectory(directory, filemask, true);
}
public static ArrayList SearchDirectory(string directory, string filemask, bool searchSubdirectories)
{
ArrayList collection = new ArrayList();
SearchDirectory(directory, filemask, collection, searchSubdirectories);
return collection;
}
/// <summary>
/// Finds all files which are valid to the mask <code>filemask</code> in the path
/// <code>directory</code> and all subdirectories (if searchSubdirectories
/// is true. The found files are added to the ArrayList
/// <code>collection</code>.
/// </summary>
static void SearchDirectory(string directory, string filemask, ArrayList collection, bool searchSubdirectories)
{
try {
string[] file = Directory.GetFiles(directory, filemask);
foreach (string f in file) {
collection.Add(f);
}
if (searchSubdirectories) {
string[] dir = Directory.GetDirectories(directory);
foreach (string d in dir) {
try {
SearchDirectory(d, filemask, collection, searchSubdirectories);
} catch (Exception) {}
}
}
} catch (Exception) {
}
}
public static void Main(string[] args)
{
// new ICSharpCode.NRefactory.Tests.AST.ReDimStatementTests().VBNetReDimStatementTest();
// string program = @"
//Public Class IMyIntern
// Public Shared Sub Main()
// End
// End Sub
//End Class
//";
// string program = @"
//class MyTestClass
//{
// public static void A()
// {
// int**** xPtr = new int****[5];
// }
//}
//";
//
// IParser parser = ParserFactory.CreateParser(SupportedLanguages.VBNet, new StringReader(program));
// parser.Parse();
// Console.WriteLine(parser.CompilationUnit.Children[0].Children[0]);
// if (parser.Errors.ErrorOutput.Length > 0) {
// Console.WriteLine(parser.Errors.ErrorOutput);
// Console.ReadLine();
// }
//
// string searchPath = @"C:\Programme\Microsoft.NET\SDK\v1.1"; //Path.GetFullPath(Application.StartupPath + @"\..\..\..\..");
// ArrayList files = SearchDirectory(searchPath, "*.vb", true);
// ArrayList defs = new ArrayList();
// long oldSet = Environment.WorkingSet;
//
// DateTime start = DateTime.Now;
// foreach (string str in files) {
// IParser parser = ParserFactory.CreateParser(str);
// parser.Parse();
// if (parser.Errors.ErrorOutput.Length > 0) {
// Console.WriteLine(str);
// Console.WriteLine(parser.Errors.ErrorOutput);
// }
// }
// Console.WriteLine("Time: " + (DateTime.Now - start) + " memory : " + (Environment.WorkingSet - oldSet));
new ICSharpCode.NRefactory.Tests.AST.ReDimStatementTests().VBNetReDimStatementTest();
}
}
}

16
src/Libraries/NRefactory/Test/NRefactoryTests.csproj

@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.40607</ProductVersion>
<ProductVersion>8.0.50215</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{870115dd-960a-4406-a6b9-600bcdc36a03}</ProjectGuid>
<ProjectGuid>{870115DD-960A-4406-A6B9-600BCDC36A03}</ProjectGuid>
<RootNamespace>ICSharpCode.NRefactory.Tests</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory.Tests</AssemblyName>
<OutputTarget>Library</OutputTarget>
@ -12,6 +12,9 @@ @@ -12,6 +12,9 @@
<NoStdLib>False</NoStdLib>
<NoConfig>False</NoConfig>
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<OutputType>Library</OutputType>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@ -36,7 +39,6 @@ @@ -36,7 +39,6 @@
<Reference Include="nunit.framework, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Lexer\CSharp\LexerTest.cs" />
<Compile Include="General\UnitTest.cs" />
@ -127,14 +129,6 @@ @@ -127,14 +129,6 @@
<Compile Include="Output\CodeDOM\InvocationExpressionTest.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="General\" />
<Folder Include="Lexer\" />
<Folder Include="Lexer\CSharp\" />
<Folder Include="Lexer\VBNet\" />
<Folder Include="Parser\" />
<Folder Include="Output\" />
<Folder Include="Output\CSharp\" />
<Folder Include="Output\CodeDOM\" />
<ProjectReference Include="..\Project\NRefactory.csproj">
<Project>{3a9ae6aa-bc07-4a2f-972c-581e3ae2f195}</Project>
<Name>ICSharpCode.NRefactory</Name>

11
src/Libraries/NRefactory/Test/NRefactoryTests.csproj.user

@ -1,4 +1,13 @@ @@ -1,4 +1,13 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartAction>Program</StartAction>
<StartProgram>D:\Corsavy\SharpDevelop\bin\SharpDevelop.exe</StartProgram>
<StartArguments>D:\Corsavy\SharpDevelop\src\Libraries\NRefactory\NRefactory.sln</StartArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<PropertyGroup>
<LastOpenVersion>8.0.50215</LastOpenVersion>
</PropertyGroup>
</Project>

33
src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs

@ -29,6 +29,39 @@ namespace ICSharpCode.NRefactory.Tests.AST @@ -29,6 +29,39 @@ namespace ICSharpCode.NRefactory.Tests.AST
Assert.AreEqual(0, md.Parameters.Count);
}
[Test]
public void CSharpSimpleMethodRegionTest()
{
const string program = @"
void MyMethod()
{
OtherMethod();
}
";
MethodDeclaration md = (MethodDeclaration)ParseUtilCSharp.ParseTypeMember(program, typeof(MethodDeclaration));
Assert.AreEqual(2, md.StartLocation.Y, "StartLocation.Y");
Assert.AreEqual(2, md.EndLocation.Y, "EndLocation.Y");
Assert.AreEqual(3, md.StartLocation.X, "StartLocation.X");
// endLocation.X is currently 20. It should be 18, but that error is not critical
//Assert.AreEqual(18, md.EndLocation.X, "EndLocation.X");
}
[Test]
public void CSharpMethodWithModifiersRegionTest()
{
const string program = @"
public static void MyMethod()
{
OtherMethod();
}
";
MethodDeclaration md = (MethodDeclaration)ParseUtilCSharp.ParseTypeMember(program, typeof(MethodDeclaration));
Assert.AreEqual(2, md.StartLocation.Y, "StartLocation.Y");
Assert.AreEqual(2, md.EndLocation.Y, "EndLocation.Y");
Assert.AreEqual(3, md.StartLocation.X, "StartLocation.X");
}
[Test]
public void CSharpMethodWithUnnamedParameterDeclarationTest()
{

3
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -669,8 +669,7 @@ @@ -669,8 +669,7 @@
<Compile Include="Src\Services\ProjectService\ParseableFileContentEnumerator.cs" />
<Compile Include="Src\Services\ParserService\ParseProjectContent.cs" />
<Compile Include="Src\Services\ParserService\ReflectionProjectContent.cs" />
<Compile Include="Src\Dom\IMethod.cs" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">
<Project>{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}</Project>

8
src/Main/Base/Project/Src/Commands/VBConverter/CSharpConvertBuffer.cs

@ -9,8 +9,7 @@ using System; @@ -9,8 +9,7 @@ using System;
using System.IO;
using System.Threading;
using System.Drawing;
using System.Drawing.Printing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
@ -42,10 +41,13 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -42,10 +41,13 @@ namespace ICSharpCode.SharpDevelop.Commands
return;
}
ICSharpCode.NRefactory.PrettyPrinter.CSharpOutputVisitor vbv = new ICSharpCode.NRefactory.PrettyPrinter.CSharpOutputVisitor();
SpecialNodesInserter sni = new SpecialNodesInserter(p.Lexer.SpecialTracker.CurrentSpecials,
List<ISpecial> specials = p.Lexer.SpecialTracker.CurrentSpecials;
PreProcessingDirective.VBToCSharp(specials);
SpecialNodesInserter sni = new SpecialNodesInserter(specials,
new SpecialOutputVisitor(vbv.OutputFormatter));
vbv.NodeTracker.NodeVisiting += sni.AcceptNodeStart;
vbv.NodeTracker.NodeVisited += sni.AcceptNodeEnd;
vbv.NodeTracker.NodeChildrenVisited += sni.AcceptNodeEnd;
vbv.Visit(p.CompilationUnit, null);
sni.Finish();

8
src/Main/Base/Project/Src/Commands/VBConverter/ConvertBuffer.cs

@ -9,8 +9,7 @@ using System; @@ -9,8 +9,7 @@ using System;
using System.IO;
using System.Threading;
using System.Drawing;
using System.Drawing.Printing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
@ -44,10 +43,13 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -44,10 +43,13 @@ namespace ICSharpCode.SharpDevelop.Commands
ICSharpCode.NRefactory.PrettyPrinter.VBNetOutputVisitor vbv = new ICSharpCode.NRefactory.PrettyPrinter.VBNetOutputVisitor();
SpecialNodesInserter sni = new SpecialNodesInserter(p.Lexer.SpecialTracker.CurrentSpecials,
List<ISpecial> specials = p.Lexer.SpecialTracker.CurrentSpecials;
PreProcessingDirective.CSharpToVB(specials);
SpecialNodesInserter sni = new SpecialNodesInserter(specials,
new SpecialOutputVisitor(vbv.OutputFormatter));
vbv.NodeTracker.NodeVisiting += sni.AcceptNodeStart;
vbv.NodeTracker.NodeVisited += sni.AcceptNodeEnd;
vbv.NodeTracker.NodeChildrenVisited += sni.AcceptNodeEnd;
vbv.Visit(p.CompilationUnit, null);
sni.Finish();

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

@ -444,23 +444,4 @@ namespace ICSharpCode.Core @@ -444,23 +444,4 @@ namespace ICSharpCode.Core
public static event ParseInformationEventHandler ParseInformationUpdated;
}
// [Serializable]
// public class DummyCompilationUnit : AbstractCompilationUnit
// {
// List<IComment> miscComments = new List<IComment>();
// List<IComment> dokuComments = new List<IComment>();
//
// public override List<IComment> MiscComments {
// get {
// return miscComments;
// }
// }
//
// public override List<IComment> DokuComments {
// get {
// return dokuComments;
// }
// }
// }
}

4
src/Main/Core/Project/Src/Services/PropertyService/Properties.cs

@ -163,10 +163,10 @@ namespace ICSharpCode.Core @@ -163,10 +163,10 @@ namespace ICSharpCode.Core
writer.WriteAttributeString("name", entry.Key);
((Properties)val).WriteProperties(writer);
writer.WriteEndElement();
} else if (val is Array) {
} else if (val is Array || val is ArrayList) {
writer.WriteStartElement("Array");
writer.WriteAttributeString("name", entry.Key);
foreach (object o in (Array)val) {
foreach (object o in (IEnumerable)val) {
writer.WriteStartElement("Element");
WriteValue(writer, o);
writer.WriteEndElement();

Loading…
Cancel
Save