16 changed files with 710 additions and 18 deletions
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{9C19E629-C93E-4ACB-9A4B-13072B5AEF9D}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
||||
<OutputType>WinExe</OutputType> |
||||
<RootNamespace>ICSharpCode.NRefactory.Demo</RootNamespace> |
||||
<AssemblyName>ICSharpCode.NRefactory.Demo</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
||||
<PlatformTarget>x86</PlatformTarget> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>bin\Debug\</OutputPath> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>bin\Release\</OutputPath> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="MainForm.cs" /> |
||||
<Compile Include="MainForm.Designer.cs"> |
||||
<DependentUpon>MainForm.cs</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Program.cs" /> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> |
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> |
||||
<Name>ICSharpCode.NRefactory</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<EmbeddedResource Include="MainForm.resx"> |
||||
<DependentUpon>MainForm.cs</DependentUpon> |
||||
</EmbeddedResource> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
||||
@ -0,0 +1,177 @@
@@ -0,0 +1,177 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
namespace ICSharpCode.NRefactory.Demo |
||||
{ |
||||
partial class MainForm |
||||
{ |
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the form.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.tabControl1 = new System.Windows.Forms.TabControl(); |
||||
this.tabPage1 = new System.Windows.Forms.TabPage(); |
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); |
||||
this.csharpCodeTextBox = new System.Windows.Forms.TextBox(); |
||||
this.csharpTreeView = new System.Windows.Forms.TreeView(); |
||||
this.csharpGenerateCodeButton = new System.Windows.Forms.Button(); |
||||
this.csharpParseButton = new System.Windows.Forms.Button(); |
||||
this.tabPage2 = new System.Windows.Forms.TabPage(); |
||||
this.tabControl1.SuspendLayout(); |
||||
this.tabPage1.SuspendLayout(); |
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); |
||||
this.splitContainer1.Panel1.SuspendLayout(); |
||||
this.splitContainer1.Panel2.SuspendLayout(); |
||||
this.splitContainer1.SuspendLayout(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1); |
||||
this.tabControl1.Controls.Add(this.tabPage2); |
||||
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.tabControl1.Location = new System.Drawing.Point(0, 0); |
||||
this.tabControl1.Name = "tabControl1"; |
||||
this.tabControl1.SelectedIndex = 0; |
||||
this.tabControl1.Size = new System.Drawing.Size(515, 484); |
||||
this.tabControl1.TabIndex = 0; |
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.splitContainer1); |
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22); |
||||
this.tabPage1.Name = "tabPage1"; |
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3); |
||||
this.tabPage1.Size = new System.Drawing.Size(507, 458); |
||||
this.tabPage1.TabIndex = 0; |
||||
this.tabPage1.Text = "C#"; |
||||
this.tabPage1.UseVisualStyleBackColor = true; |
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.splitContainer1.Location = new System.Drawing.Point(3, 3); |
||||
this.splitContainer1.Name = "splitContainer1"; |
||||
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; |
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.csharpCodeTextBox); |
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.csharpTreeView); |
||||
this.splitContainer1.Panel2.Controls.Add(this.csharpGenerateCodeButton); |
||||
this.splitContainer1.Panel2.Controls.Add(this.csharpParseButton); |
||||
this.splitContainer1.Size = new System.Drawing.Size(501, 452); |
||||
this.splitContainer1.SplitterDistance = 201; |
||||
this.splitContainer1.TabIndex = 0; |
||||
//
|
||||
// csharpCodeTextBox
|
||||
//
|
||||
this.csharpCodeTextBox.AcceptsReturn = true; |
||||
this.csharpCodeTextBox.AcceptsTab = true; |
||||
this.csharpCodeTextBox.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.csharpCodeTextBox.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); |
||||
this.csharpCodeTextBox.HideSelection = false; |
||||
this.csharpCodeTextBox.Location = new System.Drawing.Point(0, 0); |
||||
this.csharpCodeTextBox.Multiline = true; |
||||
this.csharpCodeTextBox.Name = "csharpCodeTextBox"; |
||||
this.csharpCodeTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; |
||||
this.csharpCodeTextBox.Size = new System.Drawing.Size(501, 201); |
||||
this.csharpCodeTextBox.TabIndex = 0; |
||||
this.csharpCodeTextBox.Text = "using System;\r\nclass Test\r\n{\r\n public void Main(string[] args)\r\n {\r\n " + |
||||
" System.Console.WriteLine(\"Hello, World\");\r\n }\r\n}"; |
||||
this.csharpCodeTextBox.WordWrap = false; |
||||
//
|
||||
// csharpTreeView
|
||||
//
|
||||
this.csharpTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
||||
| System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
this.csharpTreeView.Location = new System.Drawing.Point(3, 28); |
||||
this.csharpTreeView.Name = "csharpTreeView"; |
||||
this.csharpTreeView.Size = new System.Drawing.Size(493, 216); |
||||
this.csharpTreeView.TabIndex = 2; |
||||
this.csharpTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.CSharpTreeViewAfterSelect); |
||||
//
|
||||
// csharpGenerateCodeButton
|
||||
//
|
||||
this.csharpGenerateCodeButton.Anchor = System.Windows.Forms.AnchorStyles.Top; |
||||
this.csharpGenerateCodeButton.Location = new System.Drawing.Point(249, 3); |
||||
this.csharpGenerateCodeButton.Name = "csharpGenerateCodeButton"; |
||||
this.csharpGenerateCodeButton.Size = new System.Drawing.Size(118, 23); |
||||
this.csharpGenerateCodeButton.TabIndex = 1; |
||||
this.csharpGenerateCodeButton.Text = "Generate Code"; |
||||
this.csharpGenerateCodeButton.UseVisualStyleBackColor = true; |
||||
this.csharpGenerateCodeButton.Click += new System.EventHandler(this.CSharpGenerateCodeButtonClick); |
||||
//
|
||||
// csharpParseButton
|
||||
//
|
||||
this.csharpParseButton.Anchor = System.Windows.Forms.AnchorStyles.Top; |
||||
this.csharpParseButton.Location = new System.Drawing.Point(133, 3); |
||||
this.csharpParseButton.Name = "csharpParseButton"; |
||||
this.csharpParseButton.Size = new System.Drawing.Size(110, 23); |
||||
this.csharpParseButton.TabIndex = 0; |
||||
this.csharpParseButton.Text = "Parse Code"; |
||||
this.csharpParseButton.UseVisualStyleBackColor = true; |
||||
this.csharpParseButton.Click += new System.EventHandler(this.CSharpParseButtonClick); |
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22); |
||||
this.tabPage2.Name = "tabPage2"; |
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3); |
||||
this.tabPage2.Size = new System.Drawing.Size(507, 458); |
||||
this.tabPage2.TabIndex = 1; |
||||
this.tabPage2.Text = "VB"; |
||||
this.tabPage2.UseVisualStyleBackColor = true; |
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.ClientSize = new System.Drawing.Size(515, 484); |
||||
this.Controls.Add(this.tabControl1); |
||||
this.Name = "MainForm"; |
||||
this.Text = "NRefactory Demo"; |
||||
this.tabControl1.ResumeLayout(false); |
||||
this.tabPage1.ResumeLayout(false); |
||||
this.splitContainer1.Panel1.ResumeLayout(false); |
||||
this.splitContainer1.Panel1.PerformLayout(); |
||||
this.splitContainer1.Panel2.ResumeLayout(false); |
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); |
||||
this.splitContainer1.ResumeLayout(false); |
||||
this.ResumeLayout(false); |
||||
} |
||||
private System.Windows.Forms.TreeView csharpTreeView; |
||||
private System.Windows.Forms.Button csharpParseButton; |
||||
private System.Windows.Forms.Button csharpGenerateCodeButton; |
||||
private System.Windows.Forms.TextBox csharpCodeTextBox; |
||||
private System.Windows.Forms.SplitContainer splitContainer1; |
||||
private System.Windows.Forms.TabPage tabPage2; |
||||
private System.Windows.Forms.TabPage tabPage1; |
||||
private System.Windows.Forms.TabControl tabControl1; |
||||
} |
||||
} |
||||
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
|
||||
namespace ICSharpCode.NRefactory.Demo |
||||
{ |
||||
/// <summary>
|
||||
/// Description of MainForm.
|
||||
/// </summary>
|
||||
public partial class MainForm : Form |
||||
{ |
||||
public MainForm() |
||||
{ |
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
|
||||
CSharpParseButtonClick(null, null); |
||||
} |
||||
|
||||
void CSharpParseButtonClick(object sender, EventArgs e) |
||||
{ |
||||
CSharpParser parser = new CSharpParser(); |
||||
CompilationUnit cu = parser.Parse(new StringReader(csharpCodeTextBox.Text)); |
||||
csharpTreeView.Nodes.Clear(); |
||||
foreach (var element in cu.Children) { |
||||
csharpTreeView.Nodes.Add(MakeTreeNode(element)); |
||||
} |
||||
} |
||||
|
||||
TreeNode MakeTreeNode(INode node) |
||||
{ |
||||
StringBuilder b = new StringBuilder(); |
||||
b.Append(DecodeRole(node.Role, node.Parent != null ? node.Parent.GetType() : null)); |
||||
b.Append(": "); |
||||
b.Append(node.GetType().Name); |
||||
bool hasProperties = false; |
||||
foreach (PropertyInfo p in node.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { |
||||
if (p.PropertyType == typeof(string) || p.PropertyType.IsEnum) { |
||||
if (!hasProperties) { |
||||
hasProperties = true; |
||||
b.Append(" ("); |
||||
} else { |
||||
b.Append(", "); |
||||
} |
||||
b.Append(p.Name); |
||||
b.Append(" = "); |
||||
try { |
||||
object val = p.GetValue(node, null); |
||||
b.Append(val != null ? val.ToString() : "**null**"); |
||||
} catch (TargetInvocationException ex) { |
||||
b.Append("**" + ex.InnerException.GetType().Name + "**"); |
||||
} |
||||
} |
||||
} |
||||
if (hasProperties) |
||||
b.Append(")"); |
||||
TreeNode t = new TreeNode(b.ToString()); |
||||
t.Tag = node; |
||||
foreach (INode child in node.Children) { |
||||
t.Nodes.Add(MakeTreeNode(child)); |
||||
} |
||||
return t; |
||||
} |
||||
|
||||
string DecodeRole(int role, Type type) |
||||
{ |
||||
if (type != null) { |
||||
foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.Static)) { |
||||
if (field.FieldType == typeof(int) && (int)field.GetValue(null) == role) |
||||
return field.Name; |
||||
} |
||||
} |
||||
foreach (FieldInfo field in typeof(AbstractNode.Roles).GetFields(BindingFlags.Public | BindingFlags.Static)) { |
||||
if (field.FieldType == typeof(int) && (int)field.GetValue(null) == role) |
||||
return field.Name; |
||||
} |
||||
|
||||
return role.ToString(); |
||||
} |
||||
|
||||
void CSharpGenerateCodeButtonClick(object sender, EventArgs e) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
void CSharpTreeViewAfterSelect(object sender, TreeViewEventArgs e) |
||||
{ |
||||
INode node = e.Node.Tag as INode; |
||||
if (node != null) { |
||||
int startOffset = csharpCodeTextBox.GetFirstCharIndexFromLine(node.StartLocation.Line - 1) + node.StartLocation.Column - 1; |
||||
int endOffset = csharpCodeTextBox.GetFirstCharIndexFromLine(node.EndLocation.Line - 1) + node.EndLocation.Column - 1; |
||||
csharpCodeTextBox.Select(startOffset, endOffset - startOffset); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
</root> |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.NRefactory.Demo |
||||
{ |
||||
/// <summary>
|
||||
/// Class with program entry point.
|
||||
/// </summary>
|
||||
internal sealed class Program |
||||
{ |
||||
/// <summary>
|
||||
/// Program entry point.
|
||||
/// </summary>
|
||||
[STAThread] |
||||
private static void Main(string[] args) |
||||
{ |
||||
Application.EnableVisualStyles(); |
||||
Application.SetCompatibleTextRenderingDefault(false); |
||||
Application.Run(new MainForm()); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ICSharpCode.NRefactory.Demo")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("ICSharpCode.NRefactory.Demo")] |
||||
[assembly: AssemblyCopyright("Copyright 2010")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.CSharp.Resolver; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// Produces type and member declarations.
|
||||
/// </summary>
|
||||
public class TypeSystemConvertVisitor : AbstractDomVisitor<object, IEntity> |
||||
{ |
||||
readonly string fileName; |
||||
UsingScope usingScope; |
||||
DefaultTypeDefinition currentTypeDefinition; |
||||
|
||||
public TypeSystemConvertVisitor(IProjectContent pc, string fileName) |
||||
{ |
||||
this.usingScope = new UsingScope(pc); |
||||
this.fileName = fileName; |
||||
} |
||||
|
||||
DomRegion MakeRegion(DomLocation start, DomLocation end) |
||||
{ |
||||
return new DomRegion(fileName, start.Line, start.Column, end.Line, end.Column); |
||||
} |
||||
|
||||
// TODO: extern aliases
|
||||
|
||||
public override IEntity VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override IEntity VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration, object data) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override IEntity VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) |
||||
{ |
||||
UsingScope previousUsingScope = usingScope; |
||||
foreach (Identifier ident in namespaceDeclaration.NameIdentifier.NameParts) { |
||||
usingScope = new UsingScope(usingScope, NamespaceDeclaration.BuildQualifiedName(usingScope.NamespaceName, ident.Name)); |
||||
} |
||||
base.VisitNamespaceDeclaration(namespaceDeclaration, data); |
||||
usingScope = previousUsingScope; |
||||
return null; |
||||
} |
||||
|
||||
// TODO: assembly attributes
|
||||
|
||||
DefaultTypeDefinition CreateTypeDefinition(string name) |
||||
{ |
||||
if (currentTypeDefinition != null) |
||||
return new DefaultTypeDefinition(currentTypeDefinition, name); |
||||
else |
||||
return new DefaultTypeDefinition(usingScope.ProjectContent, usingScope.NamespaceName, name); |
||||
} |
||||
|
||||
public override IEntity VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) |
||||
{ |
||||
var td = currentTypeDefinition = CreateTypeDefinition(typeDeclaration.Name); |
||||
td.ClassType = typeDeclaration.ClassType; |
||||
td.Region = MakeRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation); |
||||
td.BodyRegion = MakeRegion(typeDeclaration.LBrace.StartLocation, typeDeclaration.RBrace.EndLocation); |
||||
td.AddDefaultConstructorIfRequired = true; |
||||
|
||||
ConvertAttributes(td.Attributes, typeDeclaration.Attributes); |
||||
// TODO: modifiers
|
||||
|
||||
//ConvertTypeParameters(td.TypeParameters, typeDeclaration.TypeArguments, typeDeclaration.Constraints, td);
|
||||
|
||||
// TODO: base type references?
|
||||
|
||||
// TODO: members
|
||||
|
||||
currentTypeDefinition = (DefaultTypeDefinition)currentTypeDefinition.DeclaringTypeDefinition; |
||||
return td; |
||||
} |
||||
|
||||
public override IEntity VisitEnumDeclaration(EnumDeclaration enumDeclaration, object data) |
||||
{ |
||||
return VisitTypeDeclaration(enumDeclaration, data); |
||||
} |
||||
|
||||
void ConvertAttributes(IList<IAttribute> outputList, IEnumerable<AttributeSection> attributes) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue