mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Remove NRefactory sourcecode and use the NuGet package instead.
This commit is contained in:
@@ -42,6 +42,12 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.NRefactory">
|
||||
<HintPath>..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.NRefactory.CSharp">
|
||||
<HintPath>..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
@@ -124,6 +130,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReferenceResolvingException.cs" />
|
||||
<Compile Include="TextOutputWriter.cs" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\AssemblyInfo.template.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -131,14 +138,6 @@
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
<Name>Mono.Cecil</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
|
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
|
||||
<Name>ICSharpCode.NRefactory.CSharp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
|
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
|
||||
<Name>ICSharpCode.NRefactory</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||
|
||||
@@ -49,6 +49,12 @@
|
||||
<Reference Include="DiffLib">
|
||||
<HintPath>..\..\packages\DiffLib.1.0.0.55\lib\net35-Client\DiffLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.NRefactory">
|
||||
<HintPath>..\..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.NRefactory.CSharp">
|
||||
<HintPath>..\..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\nunit.framework.dll</HintPath>
|
||||
@@ -115,14 +121,6 @@
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
<Name>Mono.Cecil</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
|
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
|
||||
<Name>ICSharpCode.NRefactory.CSharp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
|
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
|
||||
<Name>ICSharpCode.NRefactory</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ICSharpCode.Decompiler.csproj">
|
||||
<Project>{984CC812-9470-4A13-AFF9-CC44068D666C}</Project>
|
||||
<Name>ICSharpCode.Decompiler</Name>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DiffLib" version="1.0.0.55" />
|
||||
<package id="ICSharpCode.NRefactory" version="5.5.1" targetFramework="net45" />
|
||||
<package id="Mono.Cecil" version="0.9.5.4" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ICSharpCode.NRefactory" version="5.5.1" targetFramework="net40-Client" />
|
||||
<package id="Mono.Cecil" version="0.9.5.4" targetFramework="net40-Client" />
|
||||
</packages>
|
||||
@@ -57,6 +57,12 @@
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.NRefactory">
|
||||
<HintPath>..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.NRefactory.CSharp">
|
||||
<HintPath>..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<Private>False</Private>
|
||||
@@ -214,18 +220,10 @@
|
||||
<Project>{63e6915c-7ea4-4d76-ab28-0d7191eea626}</Project>
|
||||
<Name>Mono.Cecil.Pdb</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
|
||||
<Project>{53dca265-3c3c-42f9-b647-f72ba678122b}</Project>
|
||||
<Name>ICSharpCode.NRefactory.CSharp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.VB\ICSharpCode.NRefactory.VB.csproj">
|
||||
<Project>{7b82b671-419f-45f4-b778-d9286f996efa}</Project>
|
||||
<Name>ICSharpCode.NRefactory.VB</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
|
||||
<Project>{3b2a5653-ec97-4001-bb9b-d90f1af2c371}</Project>
|
||||
<Name>ICSharpCode.NRefactory</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SharpTreeView\ICSharpCode.TreeView.csproj">
|
||||
<Project>{dde2a481-8271-4eac-a330-8fa6a38d13d1}</Project>
|
||||
<Name>ICSharpCode.TreeView</Name>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ICSharpCode.NRefactory" version="5.5.1" targetFramework="net40" />
|
||||
<package id="Mono.Cecil" version="0.9.5.4" targetFramework="net40" />
|
||||
<package id="VSSDK.DTE" version="7.0.3" targetFramework="net45" />
|
||||
<package id="VSSDK.IDE" version="7.0.3" targetFramework="net45" />
|
||||
<package id="VSSDK.IDE.10" version="10.0.3" targetFramework="net45" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
# Visual Studio 2012
|
||||
# SharpDevelop 5.1
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{F45DB999-7E72-4000-B5AD-3A7B485A0896}"
|
||||
@@ -18,8 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "A
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Decompiler", "ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj", "{984CC812-9470-4A13-AFF9-CC44068D666C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Decompiler.Tests", "ICSharpCode.Decompiler\Tests\ICSharpCode.Decompiler.Tests.csproj", "{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPlugin", "TestPlugin\TestPlugin.csproj", "{F32EBCC8-0E53-4421-867E-05B3D6E10C70}"
|
||||
@@ -32,8 +31,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.BamlDecompiler", "ILS
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.BamlDecompiler.Tests", "ILSpy.BamlDecompiler\Tests\ILSpy.BamlDecompiler.Tests.csproj", "{1169E6D1-1899-43D4-A500-07CE4235B388}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.CSharp", "NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj", "{53DCA265-3C3C-42F9-B647-F72BA678122B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.AddIn", "ILSpy.AddIn\ILSpy.AddIn.csproj", "{9D7BE6C0-B7B3-4A50-A54E-18A2D84A3384}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0A344E19-D1FC-4F4C-8883-0844AC669113}"
|
||||
@@ -89,14 +86,6 @@ Global
|
||||
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|x86.Build.0 = Release|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|x86.Build.0 = Release|Any CPU
|
||||
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}.Debug|x86.ActiveCfg = Debug|x86
|
||||
@@ -145,14 +134,6 @@ Global
|
||||
{1169E6D1-1899-43D4-A500-07CE4235B388}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1169E6D1-1899-43D4-A500-07CE4235B388}.Release|x86.ActiveCfg = Release|x86
|
||||
{1169E6D1-1899-43D4-A500-07CE4235B388}.Release|x86.Build.0 = Release|x86
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|x86.Build.0 = Release|Any CPU
|
||||
{9D7BE6C0-B7B3-4A50-A54E-18A2D84A3384}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9D7BE6C0-B7B3-4A50-A54E-18A2D84A3384}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9D7BE6C0-B7B3-4A50-A54E-18A2D84A3384}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
|
||||
+7
-8
@@ -55,6 +55,12 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.NRefactory">
|
||||
<HintPath>..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.NRefactory.CSharp">
|
||||
<HintPath>..\packages\ICSharpCode.NRefactory.5.5.1\lib\Net40\ICSharpCode.NRefactory.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
@@ -253,6 +259,7 @@
|
||||
<Resource Include="Images\CurrentLine.png" />
|
||||
<Resource Include="Images\DisabledBreakpoint.png" />
|
||||
<None Include="Images\ResourceXsl.png" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\app.config.template" />
|
||||
<None Include="Properties\AssemblyInfo.template.cs" />
|
||||
<Compile Include="Properties\WPFAssemblyInfo.cs" />
|
||||
@@ -382,18 +389,10 @@
|
||||
<Project>{63E6915C-7EA4-4D76-AB28-0D7191EEA626}</Project>
|
||||
<Name>Mono.Cecil.Pdb</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
|
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
|
||||
<Name>ICSharpCode.NRefactory.CSharp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory.VB\ICSharpCode.NRefactory.VB.csproj">
|
||||
<Project>{7B82B671-419F-45F4-B778-D9286F996EFA}</Project>
|
||||
<Name>ICSharpCode.NRefactory.VB</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
|
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
|
||||
<Name>ICSharpCode.NRefactory</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\SharpTreeView\ICSharpCode.TreeView.csproj">
|
||||
<Project>{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}</Project>
|
||||
<Name>ICSharpCode.TreeView</Name>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ICSharpCode.NRefactory" version="5.5.1" targetFramework="net40-Client" />
|
||||
<package id="Mono.Cecil" version="0.9.5.4" targetFramework="net40-Client" />
|
||||
</packages>
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp.AstVerifier")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("mike")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{961DADFA-7CE6-429F-BC22-47630D6DB826}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ICSharpCode.NRefactory.CSharp.AstVerifier</RootNamespace>
|
||||
<AssemblyName>AstVerifier</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_5_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_5_Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
|
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
|
||||
<Name>ICSharpCode.NRefactory.CSharp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
|
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
|
||||
<Name>ICSharpCode.NRefactory</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.AstVerifier
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
static bool IsMatch (string src1, string src2, out int i, out int j)
|
||||
{
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < src1.Length && j < src2.Length) {
|
||||
char c1 = src1 [i];
|
||||
char c2 = src2 [j];
|
||||
if (char.IsWhiteSpace (c1)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (char.IsWhiteSpace (c2)) {
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
if (c1 != c2)
|
||||
return false;
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
while (i < src1.Length && char.IsWhiteSpace (src1[i])) {
|
||||
i++;
|
||||
}
|
||||
while (j < src2.Length && char.IsWhiteSpace (src2[j])) {
|
||||
j++;
|
||||
}
|
||||
|
||||
return i == src1.Length && j == src2.Length;
|
||||
}
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
if (args.Length == 0) {
|
||||
Console.WriteLine ("Usage: AstVerifier [-v|-verbose] [Directory]");
|
||||
return;
|
||||
}
|
||||
string directory = args[args.Length - 1];
|
||||
bool verboseOutput = args.Length > 1 && (args[0] == "-v" || args[0] == "-verbose");
|
||||
|
||||
try {
|
||||
if (!Directory.Exists (directory)) {
|
||||
Console.WriteLine ("Directory not found.");
|
||||
return;
|
||||
}
|
||||
} catch (IOException) {
|
||||
Console.WriteLine ("Exception while trying to access the directory.");
|
||||
return;
|
||||
}
|
||||
int failed = 0, passed = 0;
|
||||
Console.WriteLine ("search in " + directory);
|
||||
foreach (var file in Directory.GetFileSystemEntries (directory, "*", SearchOption.AllDirectories)) {
|
||||
if (!file.EndsWith (".cs"))
|
||||
continue;
|
||||
string text = File.ReadAllText (file);
|
||||
var unit = SyntaxTree.Parse (text, file);
|
||||
if (unit == null)
|
||||
continue;
|
||||
string generated = unit.GetText ();
|
||||
int i, j;
|
||||
if (!IsMatch (text, generated, out i, out j)) {
|
||||
if (i > 0 && j > 0 && verboseOutput) {
|
||||
Console.WriteLine ("fail :" + file + "----original:");
|
||||
Console.WriteLine (text.Substring (0, Math.Min (text.Length, i + 1)));
|
||||
Console.WriteLine ("----generated:");
|
||||
Console.WriteLine (generated.Substring (0, Math.Min (generated.Length, j + 1)));
|
||||
}
|
||||
failed++;
|
||||
} else {
|
||||
passed++;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine ("{0} passed, {1} failed", passed, failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,747 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using ICSharpCode.NRefactory.CSharp.Resolver;
|
||||
using ICSharpCode.NRefactory.CSharp.TypeSystem;
|
||||
using ICSharpCode.NRefactory.Semantics;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Analysis
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a node in the control flow graph of a C# method.
|
||||
/// </summary>
|
||||
public class ControlFlowNode
|
||||
{
|
||||
public readonly Statement PreviousStatement;
|
||||
public readonly Statement NextStatement;
|
||||
|
||||
public readonly ControlFlowNodeType Type;
|
||||
|
||||
public readonly List<ControlFlowEdge> Outgoing = new List<ControlFlowEdge>();
|
||||
public readonly List<ControlFlowEdge> Incoming = new List<ControlFlowEdge>();
|
||||
|
||||
public ControlFlowNode(Statement previousStatement, Statement nextStatement, ControlFlowNodeType type)
|
||||
{
|
||||
if (previousStatement == null && nextStatement == null)
|
||||
throw new ArgumentException("previousStatement and nextStatement must not be both null");
|
||||
this.PreviousStatement = previousStatement;
|
||||
this.NextStatement = nextStatement;
|
||||
this.Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ControlFlowNodeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown node type
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// Node in front of a statement
|
||||
/// </summary>
|
||||
StartNode,
|
||||
/// <summary>
|
||||
/// Node between two statements
|
||||
/// </summary>
|
||||
BetweenStatements,
|
||||
/// <summary>
|
||||
/// Node at the end of a statement list
|
||||
/// </summary>
|
||||
EndNode,
|
||||
/// <summary>
|
||||
/// Node representing the position before evaluating the condition of a loop.
|
||||
/// </summary>
|
||||
LoopCondition
|
||||
}
|
||||
|
||||
public class ControlFlowEdge
|
||||
{
|
||||
public readonly ControlFlowNode From;
|
||||
public readonly ControlFlowNode To;
|
||||
public readonly ControlFlowEdgeType Type;
|
||||
|
||||
List<TryCatchStatement> jumpOutOfTryFinally;
|
||||
|
||||
public ControlFlowEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type)
|
||||
{
|
||||
if (from == null)
|
||||
throw new ArgumentNullException("from");
|
||||
if (to == null)
|
||||
throw new ArgumentNullException("to");
|
||||
this.From = from;
|
||||
this.To = to;
|
||||
this.Type = type;
|
||||
}
|
||||
|
||||
internal void AddJumpOutOfTryFinally(TryCatchStatement tryFinally)
|
||||
{
|
||||
if (jumpOutOfTryFinally == null)
|
||||
jumpOutOfTryFinally = new List<TryCatchStatement>();
|
||||
jumpOutOfTryFinally.Add(tryFinally);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this control flow edge is leaving any try-finally statements.
|
||||
/// </summary>
|
||||
public bool IsLeavingTryFinally {
|
||||
get { return jumpOutOfTryFinally != null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the try-finally statements that this control flow edge is leaving.
|
||||
/// </summary>
|
||||
public IEnumerable<TryCatchStatement> TryFinallyStatements {
|
||||
get { return jumpOutOfTryFinally ?? Enumerable.Empty<TryCatchStatement>(); }
|
||||
}
|
||||
}
|
||||
|
||||
public enum ControlFlowEdgeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Regular control flow.
|
||||
/// </summary>
|
||||
Normal,
|
||||
/// <summary>
|
||||
/// Conditional control flow (edge taken if condition is true)
|
||||
/// </summary>
|
||||
ConditionTrue,
|
||||
/// <summary>
|
||||
/// Conditional control flow (edge taken if condition is false)
|
||||
/// </summary>
|
||||
ConditionFalse,
|
||||
/// <summary>
|
||||
/// A jump statement (goto, goto case, break or continue)
|
||||
/// </summary>
|
||||
Jump
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs the control flow graph for C# statements.
|
||||
/// </summary>
|
||||
public class ControlFlowGraphBuilder
|
||||
{
|
||||
// Written according to the reachability rules in the C# spec (§8.1 End points and reachability)
|
||||
|
||||
protected virtual ControlFlowNode CreateNode(Statement previousStatement, Statement nextStatement, ControlFlowNodeType type)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new ControlFlowNode(previousStatement, nextStatement, type);
|
||||
}
|
||||
|
||||
protected virtual ControlFlowEdge CreateEdge(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return new ControlFlowEdge(from, to, type);
|
||||
}
|
||||
|
||||
Statement rootStatement;
|
||||
CSharpTypeResolveContext typeResolveContext;
|
||||
Func<AstNode, CancellationToken, ResolveResult> resolver;
|
||||
List<ControlFlowNode> nodes;
|
||||
Dictionary<string, ControlFlowNode> labels;
|
||||
List<ControlFlowNode> gotoStatements;
|
||||
CancellationToken cancellationToken;
|
||||
|
||||
public IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (statement == null)
|
||||
throw new ArgumentNullException("statement");
|
||||
CSharpResolver r = new CSharpResolver(MinimalCorlib.Instance.CreateCompilation());
|
||||
return BuildControlFlowGraph(statement, new CSharpAstResolver(r, statement), cancellationToken);
|
||||
}
|
||||
|
||||
public IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, CSharpAstResolver resolver, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (statement == null)
|
||||
throw new ArgumentNullException("statement");
|
||||
if (resolver == null)
|
||||
throw new ArgumentNullException("resolver");
|
||||
return BuildControlFlowGraph(statement, resolver.Resolve, resolver.TypeResolveContext, cancellationToken);
|
||||
}
|
||||
|
||||
internal IList<ControlFlowNode> BuildControlFlowGraph(Statement statement, Func<AstNode, CancellationToken, ResolveResult> resolver, CSharpTypeResolveContext typeResolveContext, CancellationToken cancellationToken)
|
||||
{
|
||||
NodeCreationVisitor nodeCreationVisitor = new NodeCreationVisitor();
|
||||
nodeCreationVisitor.builder = this;
|
||||
try {
|
||||
this.nodes = new List<ControlFlowNode>();
|
||||
this.labels = new Dictionary<string, ControlFlowNode>();
|
||||
this.gotoStatements = new List<ControlFlowNode>();
|
||||
this.rootStatement = statement;
|
||||
this.resolver = resolver;
|
||||
this.typeResolveContext = typeResolveContext;
|
||||
this.cancellationToken = cancellationToken;
|
||||
|
||||
ControlFlowNode entryPoint = CreateStartNode(statement);
|
||||
statement.AcceptVisitor(nodeCreationVisitor, entryPoint);
|
||||
|
||||
// Resolve goto statements:
|
||||
foreach (ControlFlowNode gotoStmt in gotoStatements) {
|
||||
string label = ((GotoStatement)gotoStmt.NextStatement).Label;
|
||||
ControlFlowNode labelNode;
|
||||
if (labels.TryGetValue(label, out labelNode))
|
||||
nodeCreationVisitor.Connect(gotoStmt, labelNode, ControlFlowEdgeType.Jump);
|
||||
}
|
||||
|
||||
AnnotateLeaveEdgesWithTryFinallyBlocks();
|
||||
|
||||
return nodes;
|
||||
} finally {
|
||||
this.nodes = null;
|
||||
this.labels = null;
|
||||
this.gotoStatements = null;
|
||||
this.rootStatement = null;
|
||||
this.resolver = null;
|
||||
this.typeResolveContext = null;
|
||||
this.cancellationToken = CancellationToken.None;
|
||||
}
|
||||
}
|
||||
|
||||
void AnnotateLeaveEdgesWithTryFinallyBlocks()
|
||||
{
|
||||
foreach (ControlFlowEdge edge in nodes.SelectMany(n => n.Outgoing)) {
|
||||
if (edge.Type != ControlFlowEdgeType.Jump) {
|
||||
// Only jumps are potential candidates for leaving try-finally blocks.
|
||||
// Note that the regular edges leaving try or catch blocks are already annotated by the visitor.
|
||||
continue;
|
||||
}
|
||||
Statement gotoStatement = edge.From.NextStatement;
|
||||
Debug.Assert(gotoStatement is GotoStatement || gotoStatement is GotoDefaultStatement || gotoStatement is GotoCaseStatement || gotoStatement is BreakStatement || gotoStatement is ContinueStatement);
|
||||
Statement targetStatement = edge.To.PreviousStatement ?? edge.To.NextStatement;
|
||||
if (gotoStatement.Parent == targetStatement.Parent)
|
||||
continue;
|
||||
HashSet<TryCatchStatement> targetParentTryCatch = new HashSet<TryCatchStatement>(targetStatement.Ancestors.OfType<TryCatchStatement>());
|
||||
for (AstNode node = gotoStatement.Parent; node != null; node = node.Parent) {
|
||||
TryCatchStatement leftTryCatch = node as TryCatchStatement;
|
||||
if (leftTryCatch != null) {
|
||||
if (targetParentTryCatch.Contains(leftTryCatch))
|
||||
break;
|
||||
if (!leftTryCatch.FinallyBlock.IsNull)
|
||||
edge.AddJumpOutOfTryFinally(leftTryCatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Create*Node
|
||||
ControlFlowNode CreateStartNode(Statement statement)
|
||||
{
|
||||
ControlFlowNode node = CreateNode(null, statement, ControlFlowNodeType.StartNode);
|
||||
nodes.Add(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
ControlFlowNode CreateSpecialNode(Statement statement, ControlFlowNodeType type, bool addToNodeList = true)
|
||||
{
|
||||
ControlFlowNode node = CreateNode(null, statement, type);
|
||||
if (addToNodeList)
|
||||
nodes.Add(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
ControlFlowNode CreateEndNode(Statement statement, bool addToNodeList = true)
|
||||
{
|
||||
Statement nextStatement;
|
||||
if (statement == rootStatement) {
|
||||
nextStatement = null;
|
||||
} else {
|
||||
// Find the next statement in the same role:
|
||||
AstNode next = statement;
|
||||
do {
|
||||
next = next.NextSibling;
|
||||
} while (next != null && next.Role != statement.Role);
|
||||
nextStatement = next as Statement;
|
||||
}
|
||||
ControlFlowNodeType type = nextStatement != null ? ControlFlowNodeType.BetweenStatements : ControlFlowNodeType.EndNode;
|
||||
ControlFlowNode node = CreateNode(statement, nextStatement, type);
|
||||
if (addToNodeList)
|
||||
nodes.Add(node);
|
||||
return node;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constant evaluation
|
||||
/// <summary>
|
||||
/// Gets/Sets whether to handle only primitive expressions as constants (no complex expressions like "a + b").
|
||||
/// </summary>
|
||||
public bool EvaluateOnlyPrimitiveConstants { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates an expression.
|
||||
/// </summary>
|
||||
/// <returns>The constant value of the expression; or null if the expression is not a constant.</returns>
|
||||
ResolveResult EvaluateConstant(Expression expr)
|
||||
{
|
||||
if (EvaluateOnlyPrimitiveConstants) {
|
||||
if (!(expr is PrimitiveExpression || expr is NullReferenceExpression))
|
||||
return null;
|
||||
}
|
||||
return resolver(expr, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates an expression.
|
||||
/// </summary>
|
||||
/// <returns>The value of the constant boolean expression; or null if the value is not a constant boolean expression.</returns>
|
||||
bool? EvaluateCondition(Expression expr)
|
||||
{
|
||||
ResolveResult rr = EvaluateConstant(expr);
|
||||
if (rr != null && rr.IsCompileTimeConstant)
|
||||
return rr.ConstantValue as bool?;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
bool AreEqualConstants(ResolveResult c1, ResolveResult c2)
|
||||
{
|
||||
if (c1 == null || c2 == null || !c1.IsCompileTimeConstant || !c2.IsCompileTimeConstant)
|
||||
return false;
|
||||
CSharpResolver r = new CSharpResolver(typeResolveContext);
|
||||
ResolveResult c = r.ResolveBinaryOperator(BinaryOperatorType.Equality, c1, c2);
|
||||
return c.IsCompileTimeConstant && (c.ConstantValue as bool?) == true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
sealed class NodeCreationVisitor : DepthFirstAstVisitor<ControlFlowNode, ControlFlowNode>
|
||||
{
|
||||
// 'data' parameter: input control flow node (start of statement being visited)
|
||||
// Return value: result control flow node (end of statement being visited)
|
||||
|
||||
internal ControlFlowGraphBuilder builder;
|
||||
Stack<ControlFlowNode> breakTargets = new Stack<ControlFlowNode>();
|
||||
Stack<ControlFlowNode> continueTargets = new Stack<ControlFlowNode>();
|
||||
List<ControlFlowNode> gotoCaseOrDefault = new List<ControlFlowNode>();
|
||||
|
||||
internal ControlFlowEdge Connect(ControlFlowNode from, ControlFlowNode to, ControlFlowEdgeType type = ControlFlowEdgeType.Normal)
|
||||
{
|
||||
ControlFlowEdge edge = builder.CreateEdge(from, to, type);
|
||||
from.Outgoing.Add(edge);
|
||||
to.Incoming.Add(edge);
|
||||
return edge;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an end node for <c>stmt</c> and connects <c>from</c> with the new node.
|
||||
/// </summary>
|
||||
ControlFlowNode CreateConnectedEndNode(Statement stmt, ControlFlowNode from)
|
||||
{
|
||||
ControlFlowNode newNode = builder.CreateEndNode(stmt);
|
||||
Connect(from, newNode);
|
||||
return newNode;
|
||||
}
|
||||
|
||||
protected override ControlFlowNode VisitChildren(AstNode node, ControlFlowNode data)
|
||||
{
|
||||
// We have overrides for all possible expressions and should visit expressions only.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitBlockStatement(BlockStatement blockStatement, ControlFlowNode data)
|
||||
{
|
||||
// C# 4.0 spec: §8.2 Blocks
|
||||
ControlFlowNode childNode = HandleStatementList(blockStatement.Statements, data);
|
||||
return CreateConnectedEndNode(blockStatement, childNode);
|
||||
}
|
||||
|
||||
ControlFlowNode HandleStatementList(AstNodeCollection<Statement> statements, ControlFlowNode source)
|
||||
{
|
||||
ControlFlowNode childNode = null;
|
||||
foreach (Statement stmt in statements) {
|
||||
if (childNode == null) {
|
||||
childNode = builder.CreateStartNode(stmt);
|
||||
if (source != null)
|
||||
Connect(source, childNode);
|
||||
}
|
||||
Debug.Assert(childNode.NextStatement == stmt);
|
||||
childNode = stmt.AcceptVisitor(this, childNode);
|
||||
Debug.Assert(childNode.PreviousStatement == stmt);
|
||||
}
|
||||
return childNode ?? source;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitEmptyStatement(EmptyStatement emptyStatement, ControlFlowNode data)
|
||||
{
|
||||
return CreateConnectedEndNode(emptyStatement, data);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitLabelStatement(LabelStatement labelStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode end = CreateConnectedEndNode(labelStatement, data);
|
||||
builder.labels[labelStatement.Label] = end;
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, ControlFlowNode data)
|
||||
{
|
||||
return CreateConnectedEndNode(variableDeclarationStatement, data);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitExpressionStatement(ExpressionStatement expressionStatement, ControlFlowNode data)
|
||||
{
|
||||
return CreateConnectedEndNode(expressionStatement, data);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitIfElseStatement(IfElseStatement ifElseStatement, ControlFlowNode data)
|
||||
{
|
||||
bool? cond = builder.EvaluateCondition(ifElseStatement.Condition);
|
||||
ControlFlowNode trueBegin = builder.CreateStartNode(ifElseStatement.TrueStatement);
|
||||
if (cond != false)
|
||||
Connect(data, trueBegin, ControlFlowEdgeType.ConditionTrue);
|
||||
ControlFlowNode trueEnd = ifElseStatement.TrueStatement.AcceptVisitor(this, trueBegin);
|
||||
ControlFlowNode falseEnd;
|
||||
if (ifElseStatement.FalseStatement.IsNull) {
|
||||
falseEnd = null;
|
||||
} else {
|
||||
ControlFlowNode falseBegin = builder.CreateStartNode(ifElseStatement.FalseStatement);
|
||||
if (cond != true)
|
||||
Connect(data, falseBegin, ControlFlowEdgeType.ConditionFalse);
|
||||
falseEnd = ifElseStatement.FalseStatement.AcceptVisitor(this, falseBegin);
|
||||
}
|
||||
ControlFlowNode end = builder.CreateEndNode(ifElseStatement);
|
||||
if (trueEnd != null)
|
||||
Connect(trueEnd, end);
|
||||
if (falseEnd != null) {
|
||||
Connect(falseEnd, end);
|
||||
} else if (cond != true) {
|
||||
Connect(data, end, ControlFlowEdgeType.ConditionFalse);
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitSwitchStatement(SwitchStatement switchStatement, ControlFlowNode data)
|
||||
{
|
||||
// First, figure out which switch section will get called (if the expression is constant):
|
||||
ResolveResult constant = builder.EvaluateConstant(switchStatement.Expression);
|
||||
SwitchSection defaultSection = null;
|
||||
SwitchSection sectionMatchedByConstant = null;
|
||||
foreach (SwitchSection section in switchStatement.SwitchSections) {
|
||||
foreach (CaseLabel label in section.CaseLabels) {
|
||||
if (label.Expression.IsNull) {
|
||||
defaultSection = section;
|
||||
} else if (constant != null && constant.IsCompileTimeConstant) {
|
||||
ResolveResult labelConstant = builder.EvaluateConstant(label.Expression);
|
||||
if (builder.AreEqualConstants(constant, labelConstant))
|
||||
sectionMatchedByConstant = section;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (constant != null && constant.IsCompileTimeConstant && sectionMatchedByConstant == null)
|
||||
sectionMatchedByConstant = defaultSection;
|
||||
|
||||
int gotoCaseOrDefaultInOuterScope = gotoCaseOrDefault.Count;
|
||||
List<ControlFlowNode> sectionStartNodes = new List<ControlFlowNode>();
|
||||
|
||||
ControlFlowNode end = builder.CreateEndNode(switchStatement, addToNodeList: false);
|
||||
breakTargets.Push(end);
|
||||
foreach (SwitchSection section in switchStatement.SwitchSections) {
|
||||
int sectionStartNodeID = builder.nodes.Count;
|
||||
if (constant == null || !constant.IsCompileTimeConstant || section == sectionMatchedByConstant) {
|
||||
HandleStatementList(section.Statements, data);
|
||||
} else {
|
||||
// This section is unreachable: pass null to HandleStatementList.
|
||||
HandleStatementList(section.Statements, null);
|
||||
}
|
||||
// Don't bother connecting the ends of the sections: the 'break' statement takes care of that.
|
||||
|
||||
// Store the section start node for 'goto case' statements.
|
||||
sectionStartNodes.Add(sectionStartNodeID < builder.nodes.Count ? builder.nodes[sectionStartNodeID] : null);
|
||||
}
|
||||
breakTargets.Pop();
|
||||
if (defaultSection == null && sectionMatchedByConstant == null) {
|
||||
Connect(data, end);
|
||||
}
|
||||
|
||||
if (gotoCaseOrDefault.Count > gotoCaseOrDefaultInOuterScope) {
|
||||
// Resolve 'goto case' statements:
|
||||
for (int i = gotoCaseOrDefaultInOuterScope; i < gotoCaseOrDefault.Count; i++) {
|
||||
ControlFlowNode gotoCaseNode = gotoCaseOrDefault[i];
|
||||
GotoCaseStatement gotoCaseStatement = gotoCaseNode.NextStatement as GotoCaseStatement;
|
||||
ResolveResult gotoCaseConstant = null;
|
||||
if (gotoCaseStatement != null) {
|
||||
gotoCaseConstant = builder.EvaluateConstant(gotoCaseStatement.LabelExpression);
|
||||
}
|
||||
int targetSectionIndex = -1;
|
||||
int currentSectionIndex = 0;
|
||||
foreach (SwitchSection section in switchStatement.SwitchSections) {
|
||||
foreach (CaseLabel label in section.CaseLabels) {
|
||||
if (gotoCaseStatement != null) {
|
||||
// goto case
|
||||
if (!label.Expression.IsNull) {
|
||||
ResolveResult labelConstant = builder.EvaluateConstant(label.Expression);
|
||||
if (builder.AreEqualConstants(gotoCaseConstant, labelConstant))
|
||||
targetSectionIndex = currentSectionIndex;
|
||||
}
|
||||
} else {
|
||||
// goto default
|
||||
if (label.Expression.IsNull)
|
||||
targetSectionIndex = currentSectionIndex;
|
||||
}
|
||||
}
|
||||
currentSectionIndex++;
|
||||
}
|
||||
if (targetSectionIndex >= 0 && sectionStartNodes[targetSectionIndex] != null)
|
||||
Connect(gotoCaseNode, sectionStartNodes[targetSectionIndex], ControlFlowEdgeType.Jump);
|
||||
else
|
||||
Connect(gotoCaseNode, end, ControlFlowEdgeType.Jump);
|
||||
}
|
||||
gotoCaseOrDefault.RemoveRange(gotoCaseOrDefaultInOuterScope, gotoCaseOrDefault.Count - gotoCaseOrDefaultInOuterScope);
|
||||
}
|
||||
|
||||
builder.nodes.Add(end);
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, ControlFlowNode data)
|
||||
{
|
||||
gotoCaseOrDefault.Add(data);
|
||||
return builder.CreateEndNode(gotoCaseStatement);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, ControlFlowNode data)
|
||||
{
|
||||
gotoCaseOrDefault.Add(data);
|
||||
return builder.CreateEndNode(gotoDefaultStatement);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitWhileStatement(WhileStatement whileStatement, ControlFlowNode data)
|
||||
{
|
||||
// <data> <condition> while (cond) { <bodyStart> embeddedStmt; <bodyEnd> } <end>
|
||||
ControlFlowNode end = builder.CreateEndNode(whileStatement, addToNodeList: false);
|
||||
ControlFlowNode conditionNode = builder.CreateSpecialNode(whileStatement, ControlFlowNodeType.LoopCondition);
|
||||
breakTargets.Push(end);
|
||||
continueTargets.Push(conditionNode);
|
||||
|
||||
Connect(data, conditionNode);
|
||||
|
||||
bool? cond = builder.EvaluateCondition(whileStatement.Condition);
|
||||
ControlFlowNode bodyStart = builder.CreateStartNode(whileStatement.EmbeddedStatement);
|
||||
if (cond != false)
|
||||
Connect(conditionNode, bodyStart, ControlFlowEdgeType.ConditionTrue);
|
||||
ControlFlowNode bodyEnd = whileStatement.EmbeddedStatement.AcceptVisitor(this, bodyStart);
|
||||
Connect(bodyEnd, conditionNode);
|
||||
if (cond != true)
|
||||
Connect(conditionNode, end, ControlFlowEdgeType.ConditionFalse);
|
||||
|
||||
breakTargets.Pop();
|
||||
continueTargets.Pop();
|
||||
builder.nodes.Add(end);
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitDoWhileStatement(DoWhileStatement doWhileStatement, ControlFlowNode data)
|
||||
{
|
||||
// <data> do { <bodyStart> embeddedStmt; <bodyEnd>} <condition> while(cond); <end>
|
||||
ControlFlowNode end = builder.CreateEndNode(doWhileStatement, addToNodeList: false);
|
||||
ControlFlowNode conditionNode = builder.CreateSpecialNode(doWhileStatement, ControlFlowNodeType.LoopCondition, addToNodeList: false);
|
||||
breakTargets.Push(end);
|
||||
continueTargets.Push(conditionNode);
|
||||
|
||||
ControlFlowNode bodyStart = builder.CreateStartNode(doWhileStatement.EmbeddedStatement);
|
||||
Connect(data, bodyStart);
|
||||
ControlFlowNode bodyEnd = doWhileStatement.EmbeddedStatement.AcceptVisitor(this, bodyStart);
|
||||
Connect(bodyEnd, conditionNode);
|
||||
|
||||
bool? cond = builder.EvaluateCondition(doWhileStatement.Condition);
|
||||
if (cond != false)
|
||||
Connect(conditionNode, bodyStart, ControlFlowEdgeType.ConditionTrue);
|
||||
if (cond != true)
|
||||
Connect(conditionNode, end, ControlFlowEdgeType.ConditionFalse);
|
||||
|
||||
breakTargets.Pop();
|
||||
continueTargets.Pop();
|
||||
builder.nodes.Add(conditionNode);
|
||||
builder.nodes.Add(end);
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitForStatement(ForStatement forStatement, ControlFlowNode data)
|
||||
{
|
||||
data = HandleStatementList(forStatement.Initializers, data);
|
||||
// for (initializers <data>; <condition>cond; <iteratorStart>iterators<iteratorEnd>) { <bodyStart> embeddedStmt; <bodyEnd> } <end>
|
||||
ControlFlowNode end = builder.CreateEndNode(forStatement, addToNodeList: false);
|
||||
ControlFlowNode conditionNode = builder.CreateSpecialNode(forStatement, ControlFlowNodeType.LoopCondition);
|
||||
Connect(data, conditionNode);
|
||||
|
||||
int iteratorStartNodeID = builder.nodes.Count;
|
||||
ControlFlowNode iteratorEnd = HandleStatementList(forStatement.Iterators, null);
|
||||
ControlFlowNode iteratorStart;
|
||||
if (iteratorEnd != null) {
|
||||
iteratorStart = builder.nodes[iteratorStartNodeID];
|
||||
Connect(iteratorEnd, conditionNode);
|
||||
} else {
|
||||
iteratorStart = conditionNode;
|
||||
}
|
||||
|
||||
breakTargets.Push(end);
|
||||
continueTargets.Push(iteratorStart);
|
||||
|
||||
ControlFlowNode bodyStart = builder.CreateStartNode(forStatement.EmbeddedStatement);
|
||||
ControlFlowNode bodyEnd = forStatement.EmbeddedStatement.AcceptVisitor(this, bodyStart);
|
||||
if (bodyEnd != null)
|
||||
Connect(bodyEnd, iteratorStart);
|
||||
|
||||
breakTargets.Pop();
|
||||
continueTargets.Pop();
|
||||
|
||||
bool? cond = forStatement.Condition.IsNull ? true : builder.EvaluateCondition(forStatement.Condition);
|
||||
if (cond != false)
|
||||
Connect(conditionNode, bodyStart, ControlFlowEdgeType.ConditionTrue);
|
||||
if (cond != true)
|
||||
Connect(conditionNode, end, ControlFlowEdgeType.ConditionFalse);
|
||||
|
||||
builder.nodes.Add(end);
|
||||
return end;
|
||||
}
|
||||
|
||||
ControlFlowNode HandleEmbeddedStatement(Statement embeddedStatement, ControlFlowNode source)
|
||||
{
|
||||
if (embeddedStatement == null || embeddedStatement.IsNull)
|
||||
return source;
|
||||
ControlFlowNode bodyStart = builder.CreateStartNode(embeddedStatement);
|
||||
if (source != null)
|
||||
Connect(source, bodyStart);
|
||||
return embeddedStatement.AcceptVisitor(this, bodyStart);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitForeachStatement(ForeachStatement foreachStatement, ControlFlowNode data)
|
||||
{
|
||||
// <data> foreach (<condition>...) { <bodyStart>embeddedStmt<bodyEnd> } <end>
|
||||
ControlFlowNode end = builder.CreateEndNode(foreachStatement, addToNodeList: false);
|
||||
ControlFlowNode conditionNode = builder.CreateSpecialNode(foreachStatement, ControlFlowNodeType.LoopCondition);
|
||||
Connect(data, conditionNode);
|
||||
|
||||
breakTargets.Push(end);
|
||||
continueTargets.Push(conditionNode);
|
||||
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(foreachStatement.EmbeddedStatement, conditionNode);
|
||||
Connect(bodyEnd, conditionNode);
|
||||
|
||||
breakTargets.Pop();
|
||||
continueTargets.Pop();
|
||||
|
||||
Connect(conditionNode, end);
|
||||
builder.nodes.Add(end);
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitBreakStatement(BreakStatement breakStatement, ControlFlowNode data)
|
||||
{
|
||||
if (breakTargets.Count > 0)
|
||||
Connect(data, breakTargets.Peek(), ControlFlowEdgeType.Jump);
|
||||
return builder.CreateEndNode(breakStatement);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitContinueStatement(ContinueStatement continueStatement, ControlFlowNode data)
|
||||
{
|
||||
if (continueTargets.Count > 0)
|
||||
Connect(data, continueTargets.Peek(), ControlFlowEdgeType.Jump);
|
||||
return builder.CreateEndNode(continueStatement);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitGotoStatement(GotoStatement gotoStatement, ControlFlowNode data)
|
||||
{
|
||||
builder.gotoStatements.Add(data);
|
||||
return builder.CreateEndNode(gotoStatement);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitReturnStatement(ReturnStatement returnStatement, ControlFlowNode data)
|
||||
{
|
||||
return builder.CreateEndNode(returnStatement); // end not connected with data
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitThrowStatement(ThrowStatement throwStatement, ControlFlowNode data)
|
||||
{
|
||||
return builder.CreateEndNode(throwStatement); // end not connected with data
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitTryCatchStatement(TryCatchStatement tryCatchStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode end = builder.CreateEndNode(tryCatchStatement, addToNodeList: false);
|
||||
var edge = Connect(HandleEmbeddedStatement(tryCatchStatement.TryBlock, data), end);
|
||||
if (!tryCatchStatement.FinallyBlock.IsNull)
|
||||
edge.AddJumpOutOfTryFinally(tryCatchStatement);
|
||||
foreach (CatchClause cc in tryCatchStatement.CatchClauses) {
|
||||
edge = Connect(HandleEmbeddedStatement(cc.Body, data), end);
|
||||
if (!tryCatchStatement.FinallyBlock.IsNull)
|
||||
edge.AddJumpOutOfTryFinally(tryCatchStatement);
|
||||
}
|
||||
if (!tryCatchStatement.FinallyBlock.IsNull) {
|
||||
// Don't connect the end of the try-finally block to anything.
|
||||
// Consumers of the CFG will have to special-case try-finally.
|
||||
HandleEmbeddedStatement(tryCatchStatement.FinallyBlock, data);
|
||||
}
|
||||
builder.nodes.Add(end);
|
||||
return end;
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitCheckedStatement(CheckedStatement checkedStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(checkedStatement.Body, data);
|
||||
return CreateConnectedEndNode(checkedStatement, bodyEnd);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitUncheckedStatement(UncheckedStatement uncheckedStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(uncheckedStatement.Body, data);
|
||||
return CreateConnectedEndNode(uncheckedStatement, bodyEnd);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitLockStatement(LockStatement lockStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(lockStatement.EmbeddedStatement, data);
|
||||
return CreateConnectedEndNode(lockStatement, bodyEnd);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitUsingStatement(UsingStatement usingStatement, ControlFlowNode data)
|
||||
{
|
||||
data = HandleEmbeddedStatement(usingStatement.ResourceAcquisition as Statement, data);
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(usingStatement.EmbeddedStatement, data);
|
||||
return CreateConnectedEndNode(usingStatement, bodyEnd);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitYieldReturnStatement(YieldReturnStatement yieldStatement, ControlFlowNode data)
|
||||
{
|
||||
return CreateConnectedEndNode(yieldStatement, data);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, ControlFlowNode data)
|
||||
{
|
||||
return builder.CreateEndNode(yieldBreakStatement); // end not connected with data
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitUnsafeStatement(UnsafeStatement unsafeStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(unsafeStatement.Body, data);
|
||||
return CreateConnectedEndNode(unsafeStatement, bodyEnd);
|
||||
}
|
||||
|
||||
public override ControlFlowNode VisitFixedStatement(FixedStatement fixedStatement, ControlFlowNode data)
|
||||
{
|
||||
ControlFlowNode bodyEnd = HandleEmbeddedStatement(fixedStatement.EmbeddedStatement, data);
|
||||
return CreateConnectedEndNode(fixedStatement, bodyEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,759 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
using ICSharpCode.NRefactory.CSharp.Resolver;
|
||||
using ICSharpCode.NRefactory.Semantics;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation;
|
||||
using ICSharpCode.NRefactory.Utils;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Analysis
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the definite assignment status of a variable at a specific location.
|
||||
/// </summary>
|
||||
public enum DefiniteAssignmentStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The variable might be assigned or unassigned.
|
||||
/// </summary>
|
||||
PotentiallyAssigned,
|
||||
/// <summary>
|
||||
/// The variable is definitely assigned.
|
||||
/// </summary>
|
||||
DefinitelyAssigned,
|
||||
/// <summary>
|
||||
/// The variable is definitely assigned iff the expression results in the value 'true'.
|
||||
/// </summary>
|
||||
AssignedAfterTrueExpression,
|
||||
/// <summary>
|
||||
/// The variable is definitely assigned iff the expression results in the value 'false'.
|
||||
/// </summary>
|
||||
AssignedAfterFalseExpression,
|
||||
/// <summary>
|
||||
/// The code is unreachable.
|
||||
/// </summary>
|
||||
CodeUnreachable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements the C# definite assignment analysis (C# 4.0 Spec: §5.3 Definite assignment)
|
||||
/// </summary>
|
||||
public class DefiniteAssignmentAnalysis
|
||||
{
|
||||
sealed class DefiniteAssignmentNode : ControlFlowNode
|
||||
{
|
||||
public int Index;
|
||||
public DefiniteAssignmentStatus NodeStatus;
|
||||
|
||||
public DefiniteAssignmentNode(Statement previousStatement, Statement nextStatement, ControlFlowNodeType type)
|
||||
: base(previousStatement, nextStatement, type)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
sealed class DerivedControlFlowGraphBuilder : ControlFlowGraphBuilder
|
||||
{
|
||||
protected override ControlFlowNode CreateNode(Statement previousStatement, Statement nextStatement, ControlFlowNodeType type)
|
||||
{
|
||||
return new DefiniteAssignmentNode(previousStatement, nextStatement, type);
|
||||
}
|
||||
}
|
||||
|
||||
readonly DefiniteAssignmentVisitor visitor = new DefiniteAssignmentVisitor();
|
||||
readonly List<DefiniteAssignmentNode> allNodes = new List<DefiniteAssignmentNode>();
|
||||
readonly Dictionary<Statement, DefiniteAssignmentNode> beginNodeDict = new Dictionary<Statement, DefiniteAssignmentNode>();
|
||||
readonly Dictionary<Statement, DefiniteAssignmentNode> endNodeDict = new Dictionary<Statement, DefiniteAssignmentNode>();
|
||||
readonly Dictionary<Statement, DefiniteAssignmentNode> conditionNodeDict = new Dictionary<Statement, DefiniteAssignmentNode>();
|
||||
readonly CSharpAstResolver resolver;
|
||||
Dictionary<ControlFlowEdge, DefiniteAssignmentStatus> edgeStatus = new Dictionary<ControlFlowEdge, DefiniteAssignmentStatus>();
|
||||
|
||||
string variableName;
|
||||
List<IdentifierExpression> unassignedVariableUses = new List<IdentifierExpression>();
|
||||
int analyzedRangeStart, analyzedRangeEnd;
|
||||
CancellationToken analysisCancellationToken;
|
||||
|
||||
Queue<DefiniteAssignmentNode> nodesWithModifiedInput = new Queue<DefiniteAssignmentNode>();
|
||||
|
||||
public DefiniteAssignmentAnalysis(Statement rootStatement, CancellationToken cancellationToken)
|
||||
: this(rootStatement,
|
||||
new CSharpAstResolver(new CSharpResolver(MinimalCorlib.Instance.CreateCompilation()), rootStatement),
|
||||
cancellationToken)
|
||||
{
|
||||
}
|
||||
|
||||
public DefiniteAssignmentAnalysis(Statement rootStatement, CSharpAstResolver resolver, CancellationToken cancellationToken)
|
||||
{
|
||||
if (rootStatement == null)
|
||||
throw new ArgumentNullException("rootStatement");
|
||||
if (resolver == null)
|
||||
throw new ArgumentNullException("resolver");
|
||||
this.resolver = resolver;
|
||||
|
||||
visitor.analysis = this;
|
||||
DerivedControlFlowGraphBuilder cfgBuilder = new DerivedControlFlowGraphBuilder();
|
||||
if (resolver.TypeResolveContext.Compilation.MainAssembly.UnresolvedAssembly is MinimalCorlib) {
|
||||
cfgBuilder.EvaluateOnlyPrimitiveConstants = true;
|
||||
}
|
||||
allNodes.AddRange(cfgBuilder.BuildControlFlowGraph(rootStatement, resolver, cancellationToken).Cast<DefiniteAssignmentNode>());
|
||||
for (int i = 0; i < allNodes.Count; i++) {
|
||||
DefiniteAssignmentNode node = allNodes[i];
|
||||
node.Index = i; // assign numbers to the nodes
|
||||
if (node.Type == ControlFlowNodeType.StartNode || node.Type == ControlFlowNodeType.BetweenStatements) {
|
||||
// Anonymous methods have separate control flow graphs, but we also need to analyze those.
|
||||
// Iterate backwards so that anonymous methods are inserted in the correct order
|
||||
for (AstNode child = node.NextStatement.LastChild; child != null; child = child.PrevSibling) {
|
||||
InsertAnonymousMethods(i + 1, child, cfgBuilder, cancellationToken);
|
||||
}
|
||||
}
|
||||
// Now register the node in the dictionaries:
|
||||
if (node.Type == ControlFlowNodeType.StartNode || node.Type == ControlFlowNodeType.BetweenStatements)
|
||||
beginNodeDict.Add(node.NextStatement, node);
|
||||
if (node.Type == ControlFlowNodeType.BetweenStatements || node.Type == ControlFlowNodeType.EndNode)
|
||||
endNodeDict.Add(node.PreviousStatement, node);
|
||||
if (node.Type == ControlFlowNodeType.LoopCondition)
|
||||
conditionNodeDict.Add(node.NextStatement, node);
|
||||
}
|
||||
// Verify that we created nodes for all statements:
|
||||
Debug.Assert(!rootStatement.DescendantsAndSelf.OfType<Statement>().Except(allNodes.Select(n => n.NextStatement)).Any());
|
||||
// Verify that we put all nodes into the dictionaries:
|
||||
Debug.Assert(rootStatement.DescendantsAndSelf.OfType<Statement>().All(stmt => beginNodeDict.ContainsKey(stmt)));
|
||||
Debug.Assert(rootStatement.DescendantsAndSelf.OfType<Statement>().All(stmt => endNodeDict.ContainsKey(stmt)));
|
||||
|
||||
this.analyzedRangeStart = 0;
|
||||
this.analyzedRangeEnd = allNodes.Count - 1;
|
||||
}
|
||||
|
||||
void InsertAnonymousMethods(int insertPos, AstNode node, ControlFlowGraphBuilder cfgBuilder, CancellationToken cancellationToken)
|
||||
{
|
||||
// Ignore any statements, as those have their own ControlFlowNode and get handled separately
|
||||
if (node is Statement)
|
||||
return;
|
||||
AnonymousMethodExpression ame = node as AnonymousMethodExpression;
|
||||
if (ame != null) {
|
||||
allNodes.InsertRange(insertPos, cfgBuilder.BuildControlFlowGraph(ame.Body, resolver, cancellationToken).Cast<DefiniteAssignmentNode>());
|
||||
return;
|
||||
}
|
||||
LambdaExpression lambda = node as LambdaExpression;
|
||||
if (lambda != null && lambda.Body is Statement) {
|
||||
allNodes.InsertRange(insertPos, cfgBuilder.BuildControlFlowGraph((Statement)lambda.Body, resolver, cancellationToken).Cast<DefiniteAssignmentNode>());
|
||||
return;
|
||||
}
|
||||
// Descend into child expressions
|
||||
// Iterate backwards so that anonymous methods are inserted in the correct order
|
||||
for (AstNode child = node.LastChild; child != null; child = child.PrevSibling) {
|
||||
InsertAnonymousMethods(insertPos, child, cfgBuilder, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unassigned usages of the previously analyzed variable.
|
||||
/// </summary>
|
||||
public IList<IdentifierExpression> UnassignedVariableUses {
|
||||
get {
|
||||
return unassignedVariableUses.AsReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the range of statements to be analyzed.
|
||||
/// This method can be used to restrict the analysis to only a part of the method.
|
||||
/// Only the control flow paths that are fully contained within the selected part will be analyzed.
|
||||
/// </summary>
|
||||
/// <remarks>By default, both 'start' and 'end' are inclusive.</remarks>
|
||||
public void SetAnalyzedRange(Statement start, Statement end, bool startInclusive = true, bool endInclusive = true)
|
||||
{
|
||||
var dictForStart = startInclusive ? beginNodeDict : endNodeDict;
|
||||
var dictForEnd = endInclusive ? endNodeDict : beginNodeDict;
|
||||
Debug.Assert(dictForStart.ContainsKey(start) && dictForEnd.ContainsKey(end));
|
||||
int startIndex = dictForStart[start].Index;
|
||||
int endIndex = dictForEnd[end].Index;
|
||||
if (startIndex > endIndex)
|
||||
throw new ArgumentException("The start statement must be lexically preceding the end statement");
|
||||
this.analyzedRangeStart = startIndex;
|
||||
this.analyzedRangeEnd = endIndex;
|
||||
}
|
||||
|
||||
public void Analyze(string variable, DefiniteAssignmentStatus initialStatus = DefiniteAssignmentStatus.PotentiallyAssigned, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
this.analysisCancellationToken = cancellationToken;
|
||||
this.variableName = variable;
|
||||
try {
|
||||
// Reset the status:
|
||||
unassignedVariableUses.Clear();
|
||||
foreach (DefiniteAssignmentNode node in allNodes) {
|
||||
node.NodeStatus = DefiniteAssignmentStatus.CodeUnreachable;
|
||||
foreach (ControlFlowEdge edge in node.Outgoing)
|
||||
edgeStatus[edge] = DefiniteAssignmentStatus.CodeUnreachable;
|
||||
}
|
||||
|
||||
ChangeNodeStatus(allNodes[analyzedRangeStart], initialStatus);
|
||||
// Iterate as long as the input status of some nodes is changing:
|
||||
while (nodesWithModifiedInput.Count > 0) {
|
||||
DefiniteAssignmentNode node = nodesWithModifiedInput.Dequeue();
|
||||
DefiniteAssignmentStatus inputStatus = DefiniteAssignmentStatus.CodeUnreachable;
|
||||
foreach (ControlFlowEdge edge in node.Incoming) {
|
||||
inputStatus = MergeStatus(inputStatus, edgeStatus[edge]);
|
||||
}
|
||||
ChangeNodeStatus(node, inputStatus);
|
||||
}
|
||||
} finally {
|
||||
this.analysisCancellationToken = CancellationToken.None;
|
||||
this.variableName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public DefiniteAssignmentStatus GetStatusBefore(Statement statement)
|
||||
{
|
||||
return beginNodeDict[statement].NodeStatus;
|
||||
}
|
||||
|
||||
public DefiniteAssignmentStatus GetStatusAfter(Statement statement)
|
||||
{
|
||||
return endNodeDict[statement].NodeStatus;
|
||||
}
|
||||
|
||||
public DefiniteAssignmentStatus GetStatusBeforeLoopCondition(Statement statement)
|
||||
{
|
||||
return conditionNodeDict[statement].NodeStatus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exports the CFG. This method is intended to help debugging issues related to definite assignment.
|
||||
/// </summary>
|
||||
public GraphVizGraph ExportGraph()
|
||||
{
|
||||
GraphVizGraph g = new GraphVizGraph();
|
||||
g.Title = "DefiniteAssignment - " + variableName;
|
||||
for (int i = 0; i < allNodes.Count; i++) {
|
||||
string name = "#" + i + " = " + allNodes[i].NodeStatus.ToString() + Environment.NewLine;
|
||||
switch (allNodes[i].Type) {
|
||||
case ControlFlowNodeType.StartNode:
|
||||
case ControlFlowNodeType.BetweenStatements:
|
||||
name += allNodes[i].NextStatement.ToString();
|
||||
break;
|
||||
case ControlFlowNodeType.EndNode:
|
||||
name += "End of " + allNodes[i].PreviousStatement.ToString();
|
||||
break;
|
||||
case ControlFlowNodeType.LoopCondition:
|
||||
name += "Condition in " + allNodes[i].NextStatement.ToString();
|
||||
break;
|
||||
default:
|
||||
name += allNodes[i].Type.ToString();
|
||||
break;
|
||||
}
|
||||
g.AddNode(new GraphVizNode(i) { label = name });
|
||||
foreach (ControlFlowEdge edge in allNodes[i].Outgoing) {
|
||||
GraphVizEdge ge = new GraphVizEdge(i, ((DefiniteAssignmentNode)edge.To).Index);
|
||||
if (edgeStatus.Count > 0)
|
||||
ge.label = edgeStatus[edge].ToString();
|
||||
if (edge.IsLeavingTryFinally)
|
||||
ge.style = "dashed";
|
||||
switch (edge.Type) {
|
||||
case ControlFlowEdgeType.ConditionTrue:
|
||||
ge.color = "green";
|
||||
break;
|
||||
case ControlFlowEdgeType.ConditionFalse:
|
||||
ge.color = "red";
|
||||
break;
|
||||
case ControlFlowEdgeType.Jump:
|
||||
ge.color = "blue";
|
||||
break;
|
||||
}
|
||||
g.AddEdge(ge);
|
||||
}
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
static DefiniteAssignmentStatus MergeStatus(DefiniteAssignmentStatus a, DefiniteAssignmentStatus b)
|
||||
{
|
||||
// The result will be DefinitelyAssigned if at least one incoming edge is DefinitelyAssigned and all others are unreachable.
|
||||
// The result will be DefinitelyUnassigned if at least one incoming edge is DefinitelyUnassigned and all others are unreachable.
|
||||
// The result will be Unreachable if all incoming edges are unreachable.
|
||||
// Otherwise, the result will be PotentiallyAssigned.
|
||||
|
||||
if (a == b)
|
||||
return a;
|
||||
else if (a == DefiniteAssignmentStatus.CodeUnreachable)
|
||||
return b;
|
||||
else if (b == DefiniteAssignmentStatus.CodeUnreachable)
|
||||
return a;
|
||||
else
|
||||
return DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
}
|
||||
|
||||
void ChangeNodeStatus (DefiniteAssignmentNode node, DefiniteAssignmentStatus inputStatus)
|
||||
{
|
||||
if (node.NodeStatus == inputStatus)
|
||||
return;
|
||||
node.NodeStatus = inputStatus;
|
||||
DefiniteAssignmentStatus outputStatus;
|
||||
switch (node.Type) {
|
||||
case ControlFlowNodeType.StartNode:
|
||||
case ControlFlowNodeType.BetweenStatements:
|
||||
if (node.NextStatement is IfElseStatement) {
|
||||
// Handle if-else as a condition node
|
||||
goto case ControlFlowNodeType.LoopCondition;
|
||||
}
|
||||
if (inputStatus == DefiniteAssignmentStatus.DefinitelyAssigned) {
|
||||
// There isn't any way to un-assign variables, so we don't have to check the expression
|
||||
// if the status already is definitely assigned.
|
||||
outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
} else {
|
||||
outputStatus = CleanSpecialValues (node.NextStatement.AcceptVisitor (visitor, inputStatus));
|
||||
}
|
||||
break;
|
||||
case ControlFlowNodeType.EndNode:
|
||||
outputStatus = inputStatus;
|
||||
if (node.PreviousStatement.Role == TryCatchStatement.FinallyBlockRole
|
||||
&& (outputStatus == DefiniteAssignmentStatus.DefinitelyAssigned || outputStatus == DefiniteAssignmentStatus.PotentiallyAssigned)) {
|
||||
TryCatchStatement tryFinally = (TryCatchStatement)node.PreviousStatement.Parent;
|
||||
// Changing the status on a finally block potentially changes the status of all edges leaving that finally block:
|
||||
foreach (ControlFlowEdge edge in allNodes.SelectMany(n => n.Outgoing)) {
|
||||
if (edge.IsLeavingTryFinally && edge.TryFinallyStatements.Contains (tryFinally)) {
|
||||
DefiniteAssignmentStatus s = edgeStatus [edge];
|
||||
if (s == DefiniteAssignmentStatus.PotentiallyAssigned) {
|
||||
ChangeEdgeStatus (edge, outputStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ControlFlowNodeType.LoopCondition:
|
||||
ForeachStatement foreachStmt = node.NextStatement as ForeachStatement;
|
||||
if (foreachStmt != null) {
|
||||
outputStatus = CleanSpecialValues (foreachStmt.InExpression.AcceptVisitor (visitor, inputStatus));
|
||||
if (foreachStmt.VariableName == this.variableName)
|
||||
outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
break;
|
||||
} else {
|
||||
Debug.Assert (node.NextStatement is IfElseStatement || node.NextStatement is WhileStatement || node.NextStatement is ForStatement || node.NextStatement is DoWhileStatement);
|
||||
Expression condition = node.NextStatement.GetChildByRole (Roles.Condition);
|
||||
if (condition.IsNull)
|
||||
outputStatus = inputStatus;
|
||||
else
|
||||
outputStatus = condition.AcceptVisitor(visitor, inputStatus);
|
||||
foreach (ControlFlowEdge edge in node.Outgoing) {
|
||||
if (edge.Type == ControlFlowEdgeType.ConditionTrue && outputStatus == DefiniteAssignmentStatus.AssignedAfterTrueExpression) {
|
||||
ChangeEdgeStatus(edge, DefiniteAssignmentStatus.DefinitelyAssigned);
|
||||
} else if (edge.Type == ControlFlowEdgeType.ConditionFalse && outputStatus == DefiniteAssignmentStatus.AssignedAfterFalseExpression) {
|
||||
ChangeEdgeStatus(edge, DefiniteAssignmentStatus.DefinitelyAssigned);
|
||||
} else {
|
||||
ChangeEdgeStatus(edge, CleanSpecialValues(outputStatus));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
foreach (ControlFlowEdge edge in node.Outgoing) {
|
||||
ChangeEdgeStatus(edge, outputStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeEdgeStatus(ControlFlowEdge edge, DefiniteAssignmentStatus newStatus)
|
||||
{
|
||||
DefiniteAssignmentStatus oldStatus = edgeStatus[edge];
|
||||
if (oldStatus == newStatus)
|
||||
return;
|
||||
// Ensure that status can cannot change back to CodeUnreachable after it once was reachable.
|
||||
// Also, don't ever use AssignedAfter... for statements.
|
||||
if (newStatus == DefiniteAssignmentStatus.CodeUnreachable
|
||||
|| newStatus == DefiniteAssignmentStatus.AssignedAfterFalseExpression
|
||||
|| newStatus == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
// Note that the status can change from DefinitelyAssigned
|
||||
// back to PotentiallyAssigned as unreachable input edges are
|
||||
// discovered to be reachable.
|
||||
|
||||
edgeStatus[edge] = newStatus;
|
||||
DefiniteAssignmentNode targetNode = (DefiniteAssignmentNode)edge.To;
|
||||
if (analyzedRangeStart <= targetNode.Index && targetNode.Index <= analyzedRangeEnd) {
|
||||
// TODO: potential optimization: visit previously unreachable nodes with higher priority
|
||||
// (e.g. use Deque and enqueue previously unreachable nodes at the front, but
|
||||
// other nodes at the end)
|
||||
nodesWithModifiedInput.Enqueue(targetNode);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates an expression.
|
||||
/// </summary>
|
||||
/// <returns>The constant value of the expression; or null if the expression is not a constant.</returns>
|
||||
ResolveResult EvaluateConstant(Expression expr)
|
||||
{
|
||||
return resolver.Resolve(expr, analysisCancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates an expression.
|
||||
/// </summary>
|
||||
/// <returns>The value of the constant boolean expression; or null if the value is not a constant boolean expression.</returns>
|
||||
bool? EvaluateCondition(Expression expr)
|
||||
{
|
||||
ResolveResult rr = EvaluateConstant(expr);
|
||||
if (rr != null && rr.IsCompileTimeConstant)
|
||||
return rr.ConstantValue as bool?;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
static DefiniteAssignmentStatus CleanSpecialValues(DefiniteAssignmentStatus status)
|
||||
{
|
||||
if (status == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
return DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
else if (status == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
return DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
else
|
||||
return status;
|
||||
}
|
||||
|
||||
sealed class DefiniteAssignmentVisitor : DepthFirstAstVisitor<DefiniteAssignmentStatus, DefiniteAssignmentStatus>
|
||||
{
|
||||
internal DefiniteAssignmentAnalysis analysis;
|
||||
|
||||
// The general approach for unknown nodes is to pass the status through all child nodes in order
|
||||
protected override DefiniteAssignmentStatus VisitChildren(AstNode node, DefiniteAssignmentStatus data)
|
||||
{
|
||||
// the special values are valid as output only, not as input
|
||||
Debug.Assert(data == CleanSpecialValues(data));
|
||||
DefiniteAssignmentStatus status = data;
|
||||
for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) {
|
||||
analysis.analysisCancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Debug.Assert(!(child is Statement)); // statements are visited with the CFG, not with the visitor pattern
|
||||
status = child.AcceptVisitor(this, status);
|
||||
status = CleanSpecialValues(status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#region Statements
|
||||
// For statements, the visitor only describes the effect of the statement itself;
|
||||
// we do not consider the effect of any nested statements.
|
||||
// This is done because the nested statements will be reached using the control flow graph.
|
||||
|
||||
// In fact, these methods are present so that the default logic in VisitChildren does not try to visit the nested statements.
|
||||
|
||||
public override DefiniteAssignmentStatus VisitBlockStatement(BlockStatement blockStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitCheckedStatement(CheckedStatement checkedStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitUncheckedStatement(UncheckedStatement uncheckedStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
// ExpressionStatement handled by default logic
|
||||
// VariableDeclarationStatement handled by default logic
|
||||
|
||||
public override DefiniteAssignmentStatus VisitVariableInitializer(VariableInitializer variableInitializer, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (variableInitializer.Initializer.IsNull) {
|
||||
return data;
|
||||
} else {
|
||||
DefiniteAssignmentStatus status = variableInitializer.Initializer.AcceptVisitor(this, data);
|
||||
if (variableInitializer.Name == analysis.variableName)
|
||||
return DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// IfStatement not handled by visitor, but special-cased in the code consuming the control flow graph
|
||||
|
||||
public override DefiniteAssignmentStatus VisitSwitchStatement(SwitchStatement switchStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return switchStatement.Expression.AcceptVisitor(this, data);
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitWhileStatement(WhileStatement whileStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data; // condition is handled by special condition CFG node
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitDoWhileStatement(DoWhileStatement doWhileStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data; // condition is handled by special condition CFG node
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitForStatement(ForStatement forStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data; // condition is handled by special condition CFG node; initializer and iterator statements are handled by CFG
|
||||
}
|
||||
|
||||
// Break/Continue/Goto: handled by default logic
|
||||
|
||||
// ThrowStatement: handled by default logic (just visit the expression)
|
||||
// ReturnStatement: handled by default logic (just visit the expression)
|
||||
|
||||
public override DefiniteAssignmentStatus VisitTryCatchStatement(TryCatchStatement tryCatchStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data; // no special logic when entering the try-catch-finally statement
|
||||
// TODO: where to put the special logic when exiting the try-finally statement?
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitForeachStatement(ForeachStatement foreachStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data; // assignment of the foreach loop variable is done when handling the condition node
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitUsingStatement(UsingStatement usingStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (usingStatement.ResourceAcquisition is Expression)
|
||||
return usingStatement.ResourceAcquisition.AcceptVisitor(this, data);
|
||||
else
|
||||
return data; // don't handle resource acquisition statements, as those are connected in the control flow graph
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitLockStatement(LockStatement lockStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return lockStatement.Expression.AcceptVisitor(this, data);
|
||||
}
|
||||
|
||||
// Yield statements use the default logic
|
||||
|
||||
public override DefiniteAssignmentStatus VisitUnsafeStatement(UnsafeStatement unsafeStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitFixedStatement(FixedStatement fixedStatement, DefiniteAssignmentStatus data)
|
||||
{
|
||||
DefiniteAssignmentStatus status = data;
|
||||
foreach (var variable in fixedStatement.Variables)
|
||||
status = variable.AcceptVisitor(this, status);
|
||||
return status;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Expressions
|
||||
public override DefiniteAssignmentStatus VisitDirectionExpression(DirectionExpression directionExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (directionExpression.FieldDirection == FieldDirection.Out) {
|
||||
return HandleAssignment(directionExpression.Expression, null, data);
|
||||
} else {
|
||||
// use default logic for 'ref'
|
||||
return VisitChildren(directionExpression, data);
|
||||
}
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitAssignmentExpression(AssignmentExpression assignmentExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (assignmentExpression.Operator == AssignmentOperatorType.Assign) {
|
||||
return HandleAssignment(assignmentExpression.Left, assignmentExpression.Right, data);
|
||||
} else {
|
||||
// use default logic for compound assignment operators
|
||||
return VisitChildren(assignmentExpression, data);
|
||||
}
|
||||
}
|
||||
|
||||
DefiniteAssignmentStatus HandleAssignment(Expression left, Expression right, DefiniteAssignmentStatus initialStatus)
|
||||
{
|
||||
IdentifierExpression ident = left as IdentifierExpression;
|
||||
if (ident != null && ident.Identifier == analysis.variableName) {
|
||||
// right==null is special case when handling 'out' expressions
|
||||
if (right != null)
|
||||
right.AcceptVisitor(this, initialStatus);
|
||||
return DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
} else {
|
||||
DefiniteAssignmentStatus status = left.AcceptVisitor(this, initialStatus);
|
||||
if (right != null)
|
||||
status = right.AcceptVisitor(this, CleanSpecialValues(status));
|
||||
return CleanSpecialValues(status);
|
||||
}
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
// Don't use the default logic here because we don't want to clean up the special values.
|
||||
return parenthesizedExpression.Expression.AcceptVisitor(this, data);
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitCheckedExpression(CheckedExpression checkedExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return checkedExpression.Expression.AcceptVisitor(this, data);
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitUncheckedExpression(UncheckedExpression uncheckedExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
return uncheckedExpression.Expression.AcceptVisitor(this, data);
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (binaryOperatorExpression.Operator == BinaryOperatorType.ConditionalAnd) {
|
||||
// Handle constant left side of && expressions (not in the C# spec, but done by the MS compiler)
|
||||
bool? cond = analysis.EvaluateCondition(binaryOperatorExpression.Left);
|
||||
if (cond == true)
|
||||
return binaryOperatorExpression.Right.AcceptVisitor(this, data); // right operand gets evaluated unconditionally
|
||||
else if (cond == false)
|
||||
return data; // right operand never gets evaluated
|
||||
// C# 4.0 spec: §5.3.3.24 Definite Assignment for && expressions
|
||||
DefiniteAssignmentStatus afterLeft = binaryOperatorExpression.Left.AcceptVisitor(this, data);
|
||||
DefiniteAssignmentStatus beforeRight;
|
||||
if (afterLeft == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
beforeRight = DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else if (afterLeft == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
beforeRight = DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
else
|
||||
beforeRight = afterLeft;
|
||||
DefiniteAssignmentStatus afterRight = binaryOperatorExpression.Right.AcceptVisitor(this, beforeRight);
|
||||
if (afterLeft == DefiniteAssignmentStatus.DefinitelyAssigned)
|
||||
return DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else if (afterRight == DefiniteAssignmentStatus.DefinitelyAssigned && afterLeft == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
return DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else if (afterRight == DefiniteAssignmentStatus.DefinitelyAssigned || afterRight == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
return DefiniteAssignmentStatus.AssignedAfterTrueExpression;
|
||||
else if (afterLeft == DefiniteAssignmentStatus.AssignedAfterFalseExpression && afterRight == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
return DefiniteAssignmentStatus.AssignedAfterFalseExpression;
|
||||
else
|
||||
return DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
} else if (binaryOperatorExpression.Operator == BinaryOperatorType.ConditionalOr) {
|
||||
// C# 4.0 spec: §5.3.3.25 Definite Assignment for || expressions
|
||||
bool? cond = analysis.EvaluateCondition(binaryOperatorExpression.Left);
|
||||
if (cond == false)
|
||||
return binaryOperatorExpression.Right.AcceptVisitor(this, data); // right operand gets evaluated unconditionally
|
||||
else if (cond == true)
|
||||
return data; // right operand never gets evaluated
|
||||
DefiniteAssignmentStatus afterLeft = binaryOperatorExpression.Left.AcceptVisitor(this, data);
|
||||
DefiniteAssignmentStatus beforeRight;
|
||||
if (afterLeft == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
beforeRight = DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
else if (afterLeft == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
beforeRight = DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else
|
||||
beforeRight = afterLeft;
|
||||
DefiniteAssignmentStatus afterRight = binaryOperatorExpression.Right.AcceptVisitor(this, beforeRight);
|
||||
if (afterLeft == DefiniteAssignmentStatus.DefinitelyAssigned)
|
||||
return DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else if (afterRight == DefiniteAssignmentStatus.DefinitelyAssigned && afterLeft == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
return DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
else if (afterRight == DefiniteAssignmentStatus.DefinitelyAssigned || afterRight == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
return DefiniteAssignmentStatus.AssignedAfterFalseExpression;
|
||||
else if (afterLeft == DefiniteAssignmentStatus.AssignedAfterTrueExpression && afterRight == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
return DefiniteAssignmentStatus.AssignedAfterTrueExpression;
|
||||
else
|
||||
return DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
} else if (binaryOperatorExpression.Operator == BinaryOperatorType.NullCoalescing) {
|
||||
// C# 4.0 spec: §5.3.3.27 Definite assignment for ?? expressions
|
||||
ResolveResult crr = analysis.EvaluateConstant(binaryOperatorExpression.Left);
|
||||
if (crr != null && crr.IsCompileTimeConstant && crr.ConstantValue == null)
|
||||
return binaryOperatorExpression.Right.AcceptVisitor(this, data);
|
||||
DefiniteAssignmentStatus status = CleanSpecialValues(binaryOperatorExpression.Left.AcceptVisitor(this, data));
|
||||
binaryOperatorExpression.Right.AcceptVisitor(this, status);
|
||||
return status;
|
||||
} else {
|
||||
// use default logic for other operators
|
||||
return VisitChildren(binaryOperatorExpression, data);
|
||||
}
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (unaryOperatorExpression.Operator == UnaryOperatorType.Not) {
|
||||
// C# 4.0 spec: §5.3.3.26 Definite assignment for ! expressions
|
||||
DefiniteAssignmentStatus status = unaryOperatorExpression.Expression.AcceptVisitor(this, data);
|
||||
if (status == DefiniteAssignmentStatus.AssignedAfterFalseExpression)
|
||||
return DefiniteAssignmentStatus.AssignedAfterTrueExpression;
|
||||
else if (status == DefiniteAssignmentStatus.AssignedAfterTrueExpression)
|
||||
return DefiniteAssignmentStatus.AssignedAfterFalseExpression;
|
||||
else
|
||||
return status;
|
||||
} else {
|
||||
// use default logic for other operators
|
||||
return VisitChildren(unaryOperatorExpression, data);
|
||||
}
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitConditionalExpression(ConditionalExpression conditionalExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
// C# 4.0 spec: §5.3.3.28 Definite assignment for ?: expressions
|
||||
bool? cond = analysis.EvaluateCondition(conditionalExpression.Condition);
|
||||
if (cond == true) {
|
||||
return conditionalExpression.TrueExpression.AcceptVisitor(this, data);
|
||||
} else if (cond == false) {
|
||||
return conditionalExpression.FalseExpression.AcceptVisitor(this, data);
|
||||
} else {
|
||||
DefiniteAssignmentStatus afterCondition = conditionalExpression.Condition.AcceptVisitor(this, data);
|
||||
|
||||
DefiniteAssignmentStatus beforeTrue, beforeFalse;
|
||||
if (afterCondition == DefiniteAssignmentStatus.AssignedAfterTrueExpression) {
|
||||
beforeTrue = DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
beforeFalse = DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
} else if (afterCondition == DefiniteAssignmentStatus.AssignedAfterFalseExpression) {
|
||||
beforeTrue = DefiniteAssignmentStatus.PotentiallyAssigned;
|
||||
beforeFalse = DefiniteAssignmentStatus.DefinitelyAssigned;
|
||||
} else {
|
||||
beforeTrue = afterCondition;
|
||||
beforeFalse = afterCondition;
|
||||
}
|
||||
|
||||
DefiniteAssignmentStatus afterTrue = conditionalExpression.TrueExpression.AcceptVisitor(this, beforeTrue);
|
||||
DefiniteAssignmentStatus afterFalse = conditionalExpression.FalseExpression.AcceptVisitor(this, beforeFalse);
|
||||
return MergeStatus(CleanSpecialValues(afterTrue), CleanSpecialValues(afterFalse));
|
||||
}
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
BlockStatement body = anonymousMethodExpression.Body;
|
||||
analysis.ChangeNodeStatus(analysis.beginNodeDict[body], data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitLambdaExpression(LambdaExpression lambdaExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
Statement body = lambdaExpression.Body as Statement;
|
||||
if (body != null) {
|
||||
analysis.ChangeNodeStatus(analysis.beginNodeDict[body], data);
|
||||
} else {
|
||||
lambdaExpression.Body.AcceptVisitor(this, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public override DefiniteAssignmentStatus VisitIdentifierExpression(IdentifierExpression identifierExpression, DefiniteAssignmentStatus data)
|
||||
{
|
||||
if (data != DefiniteAssignmentStatus.DefinitelyAssigned
|
||||
&& identifierExpression.Identifier == analysis.variableName && identifierExpression.TypeArguments.Count == 0)
|
||||
{
|
||||
analysis.unassignedVariableUses.Add(identifierExpression);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using ICSharpCode.NRefactory.CSharp.Resolver;
|
||||
using ICSharpCode.NRefactory.CSharp.TypeSystem;
|
||||
using ICSharpCode.NRefactory.Semantics;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.Analysis
|
||||
{
|
||||
/// <summary>
|
||||
/// Statement reachability analysis.
|
||||
/// </summary>
|
||||
public sealed class ReachabilityAnalysis
|
||||
{
|
||||
HashSet<Statement> reachableStatements = new HashSet<Statement>();
|
||||
HashSet<Statement> reachableEndPoints = new HashSet<Statement>();
|
||||
HashSet<ControlFlowNode> visitedNodes = new HashSet<ControlFlowNode>();
|
||||
Stack<ControlFlowNode> stack = new Stack<ControlFlowNode>();
|
||||
|
||||
private ReachabilityAnalysis() {}
|
||||
|
||||
public static ReachabilityAnalysis Create(Statement statement, CSharpAstResolver resolver = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var cfgBuilder = new ControlFlowGraphBuilder();
|
||||
var cfg = cfgBuilder.BuildControlFlowGraph(statement, resolver, cancellationToken);
|
||||
return Create(cfg, cancellationToken);
|
||||
}
|
||||
|
||||
internal static ReachabilityAnalysis Create(Statement statement, Func<AstNode, CancellationToken, ResolveResult> resolver, CSharpTypeResolveContext typeResolveContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var cfgBuilder = new ControlFlowGraphBuilder();
|
||||
var cfg = cfgBuilder.BuildControlFlowGraph(statement, resolver, typeResolveContext, cancellationToken);
|
||||
return Create(cfg, cancellationToken);
|
||||
}
|
||||
|
||||
public static ReachabilityAnalysis Create(IList<ControlFlowNode> controlFlowGraph, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (controlFlowGraph == null)
|
||||
throw new ArgumentNullException("controlFlowGraph");
|
||||
ReachabilityAnalysis ra = new ReachabilityAnalysis();
|
||||
ra.stack.Push(controlFlowGraph[0]);
|
||||
while (ra.stack.Count > 0) {
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ra.MarkReachable(ra.stack.Pop());
|
||||
}
|
||||
ra.stack = null;
|
||||
ra.visitedNodes = null;
|
||||
return ra;
|
||||
}
|
||||
|
||||
void MarkReachable(ControlFlowNode node)
|
||||
{
|
||||
if (node.PreviousStatement != null)
|
||||
reachableEndPoints.Add(node.PreviousStatement);
|
||||
if (node.NextStatement != null)
|
||||
reachableStatements.Add(node.NextStatement);
|
||||
foreach (var edge in node.Outgoing) {
|
||||
if (visitedNodes.Add(edge.To))
|
||||
stack.Push(edge.To);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReachable(Statement statement)
|
||||
{
|
||||
return reachableStatements.Contains(statement);
|
||||
}
|
||||
|
||||
public bool IsEndpointReachable(Statement statement)
|
||||
{
|
||||
return reachableEndPoints.Contains(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,908 +0,0 @@
|
||||
//
|
||||
// AstNode.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public abstract class AstNode : AbstractAnnotatable, ICSharpCode.NRefactory.TypeSystem.IFreezable, PatternMatching.INode
|
||||
{
|
||||
// the Root role must be available when creating the null nodes, so we can't put it in the Roles class
|
||||
internal static readonly Role<AstNode> RootRole = new Role<AstNode> ("Root");
|
||||
|
||||
#region Null
|
||||
public static readonly AstNode Null = new NullAstNode ();
|
||||
|
||||
sealed class NullAstNode : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PatternPlaceholder
|
||||
public static implicit operator AstNode (PatternMatching.Pattern pattern)
|
||||
{
|
||||
return pattern != null ? new PatternPlaceholder (pattern) : null;
|
||||
}
|
||||
|
||||
sealed class PatternPlaceholder : AstNode, PatternMatching.INode
|
||||
{
|
||||
readonly PatternMatching.Pattern child;
|
||||
|
||||
public PatternPlaceholder (PatternMatching.Pattern child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Pattern; }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPatternPlaceholder (this, child);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder (this, child);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder (this, child, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return child.DoMatch (other, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
return child.DoMatchCollection (role, pos, match, backtrackingInfo);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
AstNode parent;
|
||||
AstNode prevSibling;
|
||||
AstNode nextSibling;
|
||||
AstNode firstChild;
|
||||
AstNode lastChild;
|
||||
|
||||
// Flags, from least significant to most significant bits:
|
||||
// - Role.RoleIndexBits: role index
|
||||
// - 1 bit: IsFrozen
|
||||
protected uint flags = RootRole.Index;
|
||||
// Derived classes may also use a few bits,
|
||||
// for example Identifier uses 1 bit for IsVerbatim
|
||||
|
||||
const uint roleIndexMask = (1u << Role.RoleIndexBits) - 1;
|
||||
const uint frozenBit = 1u << Role.RoleIndexBits;
|
||||
protected const int AstNodeFlagsUsedBits = Role.RoleIndexBits + 1;
|
||||
|
||||
protected AstNode()
|
||||
{
|
||||
if (IsNull)
|
||||
Freeze();
|
||||
}
|
||||
|
||||
public bool IsFrozen {
|
||||
get { return (flags & frozenBit) != 0; }
|
||||
}
|
||||
|
||||
public void Freeze()
|
||||
{
|
||||
if (!IsFrozen) {
|
||||
for (AstNode child = firstChild; child != null; child = child.nextSibling)
|
||||
child.Freeze();
|
||||
flags |= frozenBit;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ThrowIfFrozen()
|
||||
{
|
||||
if (IsFrozen)
|
||||
throw new InvalidOperationException("Cannot mutate frozen " + GetType().Name);
|
||||
}
|
||||
|
||||
public abstract NodeType NodeType {
|
||||
get;
|
||||
}
|
||||
|
||||
public virtual bool IsNull {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual TextLocation StartLocation {
|
||||
get {
|
||||
var child = firstChild;
|
||||
if (child == null)
|
||||
return TextLocation.Empty;
|
||||
return child.StartLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual TextLocation EndLocation {
|
||||
get {
|
||||
var child = lastChild;
|
||||
if (child == null)
|
||||
return TextLocation.Empty;
|
||||
return child.EndLocation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the region from StartLocation to EndLocation for this node.
|
||||
/// The file name of the region is set based on the parent SyntaxTree's file name.
|
||||
/// If this node is not connected to a whole compilation, the file name will be null.
|
||||
/// </summary>
|
||||
public ICSharpCode.NRefactory.TypeSystem.DomRegion GetRegion()
|
||||
{
|
||||
var syntaxTree = (this.Ancestors.LastOrDefault() ?? this) as SyntaxTree;
|
||||
string fileName = (syntaxTree != null ? syntaxTree.FileName : null);
|
||||
return new ICSharpCode.NRefactory.TypeSystem.DomRegion(fileName, this.StartLocation, this.EndLocation);
|
||||
}
|
||||
|
||||
public AstNode Parent {
|
||||
get { return parent; }
|
||||
}
|
||||
|
||||
public Role Role {
|
||||
get {
|
||||
return Role.GetByIndex(flags & roleIndexMask);
|
||||
}
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
if (!value.IsValid(this))
|
||||
throw new ArgumentException("This node is not valid in the new role.");
|
||||
ThrowIfFrozen();
|
||||
SetRole(value);
|
||||
}
|
||||
}
|
||||
|
||||
void SetRole(Role role)
|
||||
{
|
||||
flags = (flags & ~roleIndexMask) | role.Index;
|
||||
}
|
||||
|
||||
public AstNode NextSibling {
|
||||
get { return nextSibling; }
|
||||
}
|
||||
|
||||
public AstNode PrevSibling {
|
||||
get { return prevSibling; }
|
||||
}
|
||||
|
||||
public AstNode FirstChild {
|
||||
get { return firstChild; }
|
||||
}
|
||||
|
||||
public AstNode LastChild {
|
||||
get { return lastChild; }
|
||||
}
|
||||
|
||||
public bool HasChildren {
|
||||
get {
|
||||
return firstChild != null;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<AstNode> Children {
|
||||
get {
|
||||
AstNode next;
|
||||
for (AstNode cur = firstChild; cur != null; cur = next) {
|
||||
Debug.Assert (cur.parent == this);
|
||||
// Remember next before yielding cur.
|
||||
// This allows removing/replacing nodes while iterating through the list.
|
||||
next = cur.nextSibling;
|
||||
yield return cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ancestors of this node (excluding this node itself)
|
||||
/// </summary>
|
||||
public IEnumerable<AstNode> Ancestors {
|
||||
get {
|
||||
for (AstNode cur = parent; cur != null; cur = cur.parent) {
|
||||
yield return cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ancestors of this node (including this node itself)
|
||||
/// </summary>
|
||||
public IEnumerable<AstNode> AncestorsAndSelf {
|
||||
get {
|
||||
for (AstNode cur = this; cur != null; cur = cur.parent) {
|
||||
yield return cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all descendants of this node (excluding this node itself).
|
||||
/// </summary>
|
||||
public IEnumerable<AstNode> Descendants {
|
||||
get { return GetDescendants(false); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all descendants of this node (including this node itself).
|
||||
/// </summary>
|
||||
public IEnumerable<AstNode> DescendantsAndSelf {
|
||||
get { return GetDescendants(true); }
|
||||
}
|
||||
|
||||
IEnumerable<AstNode> GetDescendants(bool includeSelf)
|
||||
{
|
||||
if (includeSelf)
|
||||
yield return this;
|
||||
Stack<AstNode> nextStack = new Stack<AstNode>();
|
||||
nextStack.Push(null);
|
||||
AstNode pos = firstChild;
|
||||
while (pos != null) {
|
||||
if (pos.nextSibling != null)
|
||||
nextStack.Push(pos.nextSibling);
|
||||
yield return pos;
|
||||
if (pos.firstChild != null)
|
||||
pos = pos.firstChild;
|
||||
else
|
||||
pos = nextStack.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first child with the specified role.
|
||||
/// Returns the role's null object if the child is not found.
|
||||
/// </summary>
|
||||
public T GetChildByRole<T>(Role<T> role) where T : AstNode
|
||||
{
|
||||
if (role == null)
|
||||
throw new ArgumentNullException ("role");
|
||||
uint roleIndex = role.Index;
|
||||
for (var cur = firstChild; cur != null; cur = cur.nextSibling) {
|
||||
if ((cur.flags & roleIndexMask) == roleIndex)
|
||||
return (T)cur;
|
||||
}
|
||||
return role.NullObject;
|
||||
}
|
||||
|
||||
public T GetParent<T>() where T : AstNode
|
||||
{
|
||||
return Ancestors.OfType<T>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public AstNodeCollection<T> GetChildrenByRole<T> (Role<T> role) where T : AstNode
|
||||
{
|
||||
return new AstNodeCollection<T> (this, role);
|
||||
}
|
||||
|
||||
protected void SetChildByRole<T> (Role<T> role, T newChild) where T : AstNode
|
||||
{
|
||||
AstNode oldChild = GetChildByRole (role);
|
||||
if (oldChild.IsNull)
|
||||
AddChild (newChild, role);
|
||||
else
|
||||
oldChild.ReplaceWith (newChild);
|
||||
}
|
||||
|
||||
public void AddChild<T> (T child, Role<T> role) where T : AstNode
|
||||
{
|
||||
if (role == null)
|
||||
throw new ArgumentNullException ("role");
|
||||
if (child == null || child.IsNull)
|
||||
return;
|
||||
ThrowIfFrozen();
|
||||
if (child.parent != null)
|
||||
throw new ArgumentException ("Node is already used in another tree.", "child");
|
||||
if (child.IsFrozen)
|
||||
throw new ArgumentException ("Cannot add a frozen node.", "child");
|
||||
AddChildUnsafe (child, role);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a child without performing any safety checks.
|
||||
/// </summary>
|
||||
void AddChildUnsafe (AstNode child, Role role)
|
||||
{
|
||||
child.parent = this;
|
||||
child.SetRole(role);
|
||||
if (firstChild == null) {
|
||||
lastChild = firstChild = child;
|
||||
} else {
|
||||
lastChild.nextSibling = child;
|
||||
child.prevSibling = lastChild;
|
||||
lastChild = child;
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertChildBefore<T> (AstNode nextSibling, T child, Role<T> role) where T : AstNode
|
||||
{
|
||||
if (role == null)
|
||||
throw new ArgumentNullException ("role");
|
||||
if (nextSibling == null || nextSibling.IsNull) {
|
||||
AddChild (child, role);
|
||||
return;
|
||||
}
|
||||
|
||||
if (child == null || child.IsNull)
|
||||
return;
|
||||
ThrowIfFrozen();
|
||||
if (child.parent != null)
|
||||
throw new ArgumentException ("Node is already used in another tree.", "child");
|
||||
if (child.IsFrozen)
|
||||
throw new ArgumentException ("Cannot add a frozen node.", "child");
|
||||
if (nextSibling.parent != this)
|
||||
throw new ArgumentException ("NextSibling is not a child of this node.", "nextSibling");
|
||||
// No need to test for "Cannot add children to null nodes",
|
||||
// as there isn't any valid nextSibling in null nodes.
|
||||
InsertChildBeforeUnsafe (nextSibling, child, role);
|
||||
}
|
||||
|
||||
void InsertChildBeforeUnsafe (AstNode nextSibling, AstNode child, Role role)
|
||||
{
|
||||
child.parent = this;
|
||||
child.SetRole(role);
|
||||
child.nextSibling = nextSibling;
|
||||
child.prevSibling = nextSibling.prevSibling;
|
||||
|
||||
if (nextSibling.prevSibling != null) {
|
||||
Debug.Assert (nextSibling.prevSibling.nextSibling == nextSibling);
|
||||
nextSibling.prevSibling.nextSibling = child;
|
||||
} else {
|
||||
Debug.Assert (firstChild == nextSibling);
|
||||
firstChild = child;
|
||||
}
|
||||
nextSibling.prevSibling = child;
|
||||
}
|
||||
|
||||
public void InsertChildAfter<T> (AstNode prevSibling, T child, Role<T> role) where T : AstNode
|
||||
{
|
||||
InsertChildBefore ((prevSibling == null || prevSibling.IsNull) ? firstChild : prevSibling.nextSibling, child, role);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes this node from its parent.
|
||||
/// </summary>
|
||||
public void Remove ()
|
||||
{
|
||||
if (parent != null) {
|
||||
ThrowIfFrozen();
|
||||
if (prevSibling != null) {
|
||||
Debug.Assert (prevSibling.nextSibling == this);
|
||||
prevSibling.nextSibling = nextSibling;
|
||||
} else {
|
||||
Debug.Assert (parent.firstChild == this);
|
||||
parent.firstChild = nextSibling;
|
||||
}
|
||||
if (nextSibling != null) {
|
||||
Debug.Assert (nextSibling.prevSibling == this);
|
||||
nextSibling.prevSibling = prevSibling;
|
||||
} else {
|
||||
Debug.Assert (parent.lastChild == this);
|
||||
parent.lastChild = prevSibling;
|
||||
}
|
||||
parent = null;
|
||||
prevSibling = null;
|
||||
nextSibling = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces this node with the new node.
|
||||
/// </summary>
|
||||
public void ReplaceWith (AstNode newNode)
|
||||
{
|
||||
if (newNode == null || newNode.IsNull) {
|
||||
Remove ();
|
||||
return;
|
||||
}
|
||||
if (newNode == this)
|
||||
return; // nothing to do...
|
||||
if (parent == null) {
|
||||
throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
|
||||
}
|
||||
ThrowIfFrozen();
|
||||
// Because this method doesn't statically check the new node's type with the role,
|
||||
// we perform a runtime test:
|
||||
if (!this.Role.IsValid (newNode)) {
|
||||
throw new ArgumentException (string.Format ("The new node '{0}' is not valid in the role {1}", newNode.GetType ().Name, this.Role.ToString ()), "newNode");
|
||||
}
|
||||
if (newNode.parent != null) {
|
||||
// newNode is used within this tree?
|
||||
if (newNode.Ancestors.Contains (this)) {
|
||||
// e.g. "parenthesizedExpr.ReplaceWith(parenthesizedExpr.Expression);"
|
||||
// enable automatic removal
|
||||
newNode.Remove ();
|
||||
} else {
|
||||
throw new ArgumentException ("Node is already used in another tree.", "newNode");
|
||||
}
|
||||
}
|
||||
if (newNode.IsFrozen)
|
||||
throw new ArgumentException ("Cannot add a frozen node.", "newNode");
|
||||
|
||||
newNode.parent = parent;
|
||||
newNode.SetRole(this.Role);
|
||||
newNode.prevSibling = prevSibling;
|
||||
newNode.nextSibling = nextSibling;
|
||||
|
||||
if (prevSibling != null) {
|
||||
Debug.Assert (prevSibling.nextSibling == this);
|
||||
prevSibling.nextSibling = newNode;
|
||||
} else {
|
||||
Debug.Assert (parent.firstChild == this);
|
||||
parent.firstChild = newNode;
|
||||
}
|
||||
if (nextSibling != null) {
|
||||
Debug.Assert (nextSibling.prevSibling == this);
|
||||
nextSibling.prevSibling = newNode;
|
||||
} else {
|
||||
Debug.Assert (parent.lastChild == this);
|
||||
parent.lastChild = newNode;
|
||||
}
|
||||
parent = null;
|
||||
prevSibling = null;
|
||||
nextSibling = null;
|
||||
}
|
||||
|
||||
public AstNode ReplaceWith (Func<AstNode, AstNode> replaceFunction)
|
||||
{
|
||||
if (replaceFunction == null)
|
||||
throw new ArgumentNullException ("replaceFunction");
|
||||
if (parent == null) {
|
||||
throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node");
|
||||
}
|
||||
AstNode oldParent = parent;
|
||||
AstNode oldSuccessor = nextSibling;
|
||||
Role oldRole = this.Role;
|
||||
Remove ();
|
||||
AstNode replacement = replaceFunction (this);
|
||||
if (oldSuccessor != null && oldSuccessor.parent != oldParent)
|
||||
throw new InvalidOperationException ("replace function changed nextSibling of node being replaced?");
|
||||
if (!(replacement == null || replacement.IsNull)) {
|
||||
if (replacement.parent != null)
|
||||
throw new InvalidOperationException ("replace function must return the root of a tree");
|
||||
if (!oldRole.IsValid (replacement)) {
|
||||
throw new InvalidOperationException (string.Format ("The new node '{0}' is not valid in the role {1}", replacement.GetType ().Name, oldRole.ToString ()));
|
||||
}
|
||||
|
||||
if (oldSuccessor != null)
|
||||
oldParent.InsertChildBeforeUnsafe (oldSuccessor, replacement, oldRole);
|
||||
else
|
||||
oldParent.AddChildUnsafe (replacement, oldRole);
|
||||
}
|
||||
return replacement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clones the whole subtree starting at this AST node.
|
||||
/// </summary>
|
||||
/// <remarks>Annotations are copied over to the new nodes; and any annotations implementing ICloneable will be cloned.</remarks>
|
||||
public AstNode Clone ()
|
||||
{
|
||||
AstNode copy = (AstNode)MemberwiseClone ();
|
||||
// First, reset the shallow pointer copies
|
||||
copy.parent = null;
|
||||
copy.firstChild = null;
|
||||
copy.lastChild = null;
|
||||
copy.prevSibling = null;
|
||||
copy.nextSibling = null;
|
||||
copy.flags &= ~frozenBit; // unfreeze the copy
|
||||
|
||||
// Then perform a deep copy:
|
||||
for (AstNode cur = firstChild; cur != null; cur = cur.nextSibling) {
|
||||
copy.AddChildUnsafe (cur.Clone (), cur.Role);
|
||||
}
|
||||
|
||||
// Finally, clone the annotation, if necessary
|
||||
copy.CloneAnnotations();
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
public abstract void AcceptVisitor (IAstVisitor visitor);
|
||||
|
||||
public abstract T AcceptVisitor<T> (IAstVisitor<T> visitor);
|
||||
|
||||
public abstract S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data);
|
||||
|
||||
#region Pattern Matching
|
||||
protected static bool MatchString (string pattern, string text)
|
||||
{
|
||||
return PatternMatching.Pattern.MatchString(pattern, text);
|
||||
}
|
||||
|
||||
protected internal abstract bool DoMatch (AstNode other, PatternMatching.Match match);
|
||||
|
||||
bool PatternMatching.INode.DoMatch (PatternMatching.INode other, PatternMatching.Match match)
|
||||
{
|
||||
AstNode o = other as AstNode;
|
||||
// try matching if other is null, or if other is an AstNode
|
||||
return (other == null || o != null) && DoMatch (o, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection (Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
AstNode o = pos as AstNode;
|
||||
return (pos == null || o != null) && DoMatch (o, match);
|
||||
}
|
||||
|
||||
PatternMatching.INode PatternMatching.INode.NextSibling {
|
||||
get { return nextSibling; }
|
||||
}
|
||||
|
||||
PatternMatching.INode PatternMatching.INode.FirstChild {
|
||||
get { return firstChild; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public AstNode GetNextNode ()
|
||||
{
|
||||
if (NextSibling != null)
|
||||
return NextSibling;
|
||||
if (Parent != null)
|
||||
return Parent.GetNextNode ();
|
||||
return null;
|
||||
}
|
||||
|
||||
public AstNode GetPrevNode ()
|
||||
{
|
||||
if (PrevSibling != null)
|
||||
return PrevSibling;
|
||||
if (Parent != null)
|
||||
return Parent.GetPrevNode ();
|
||||
return null;
|
||||
}
|
||||
// filters all non c# nodes (comments, white spaces or pre processor directives)
|
||||
public AstNode GetCSharpNodeBefore (AstNode node)
|
||||
{
|
||||
var n = node.PrevSibling;
|
||||
while (n != null) {
|
||||
if (n.Role != Roles.Comment)
|
||||
return n;
|
||||
n = n.GetPrevNode ();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#region GetNodeAt
|
||||
/// <summary>
|
||||
/// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End exclusive)
|
||||
/// </summary>
|
||||
public AstNode GetNodeAt (int line, int column, Predicate<AstNode> pred = null)
|
||||
{
|
||||
return GetNodeAt (new TextLocation (line, column), pred);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node specified by pred at location. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End exclusive)
|
||||
/// </summary>
|
||||
public AstNode GetNodeAt (TextLocation location, Predicate<AstNode> pred = null)
|
||||
{
|
||||
AstNode result = null;
|
||||
AstNode node = this;
|
||||
while (node.FirstChild != null) {
|
||||
var child = node.FirstChild;
|
||||
while (child != null) {
|
||||
if (child.StartLocation <= location && location < child.EndLocation) {
|
||||
if (pred == null || pred (child))
|
||||
result = child;
|
||||
node = child;
|
||||
break;
|
||||
}
|
||||
child = child.NextSibling;
|
||||
}
|
||||
// found no better child node - therefore the parent is the right one.
|
||||
if (child == null)
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End exclusive)
|
||||
/// </summary>
|
||||
public T GetNodeAt<T> (int line, int column) where T : AstNode
|
||||
{
|
||||
return GetNodeAt<T> (new TextLocation (line, column));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End exclusive)
|
||||
/// </summary>
|
||||
public T GetNodeAt<T> (TextLocation location) where T : AstNode
|
||||
{
|
||||
T result = null;
|
||||
AstNode node = this;
|
||||
while (node.FirstChild != null) {
|
||||
var child = node.FirstChild;
|
||||
while (child != null) {
|
||||
if (child.StartLocation <= location && location < child.EndLocation) {
|
||||
if (child is T)
|
||||
result = (T)child;
|
||||
node = child;
|
||||
break;
|
||||
}
|
||||
child = child.NextSibling;
|
||||
}
|
||||
// found no better child node - therefore the parent is the right one.
|
||||
if (child == null)
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetAdjacentNodeAt
|
||||
/// <summary>
|
||||
/// Gets the node specified by pred at the location line, column. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End inclusive)
|
||||
/// </summary>
|
||||
public AstNode GetAdjacentNodeAt(int line, int column, Predicate<AstNode> pred = null)
|
||||
{
|
||||
return GetAdjacentNodeAt (new TextLocation (line, column), pred);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node specified by pred at location. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End inclusive)
|
||||
/// </summary>
|
||||
public AstNode GetAdjacentNodeAt (TextLocation location, Predicate<AstNode> pred = null)
|
||||
{
|
||||
AstNode result = null;
|
||||
AstNode node = this;
|
||||
while (node.FirstChild != null) {
|
||||
var child = node.FirstChild;
|
||||
while (child != null) {
|
||||
if (child.StartLocation <= location && location <= child.EndLocation) {
|
||||
if (pred == null || pred (child))
|
||||
result = child;
|
||||
node = child;
|
||||
break;
|
||||
}
|
||||
child = child.NextSibling;
|
||||
}
|
||||
// found no better child node - therefore the parent is the right one.
|
||||
if (child == null)
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End inclusive)
|
||||
/// </summary>
|
||||
public T GetAdjacentNodeAt<T>(int line, int column) where T : AstNode
|
||||
{
|
||||
return GetAdjacentNodeAt<T> (new TextLocation (line, column));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node specified by T at location. This is useful for getting a specific node from the tree. For example searching
|
||||
/// the current method declaration.
|
||||
/// (End inclusive)
|
||||
/// </summary>
|
||||
public T GetAdjacentNodeAt<T> (TextLocation location) where T : AstNode
|
||||
{
|
||||
T result = null;
|
||||
AstNode node = this;
|
||||
while (node.FirstChild != null) {
|
||||
var child = node.FirstChild;
|
||||
while (child != null) {
|
||||
if (child.StartLocation <= location && location < child.EndLocation) {
|
||||
if (child is T)
|
||||
result = (T)child;
|
||||
node = child;
|
||||
break;
|
||||
}
|
||||
child = child.NextSibling;
|
||||
}
|
||||
// found no better child node - therefore the parent is the right one.
|
||||
if (child == null)
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node that fully contains the range from startLocation to endLocation.
|
||||
/// </summary>
|
||||
public AstNode GetNodeContaining(TextLocation startLocation, TextLocation endLocation)
|
||||
{
|
||||
for (AstNode child = firstChild; child != null; child = child.nextSibling) {
|
||||
if (child.StartLocation <= startLocation && endLocation <= child.EndLocation)
|
||||
return child.GetNodeContaining(startLocation, endLocation);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public IEnumerable<AstNode> GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn)
|
||||
{
|
||||
return GetNodesBetween (new TextLocation (startLine, startColumn), new TextLocation (endLine, endColumn));
|
||||
}
|
||||
|
||||
public IEnumerable<AstNode> GetNodesBetween (TextLocation start, TextLocation end)
|
||||
{
|
||||
AstNode node = this;
|
||||
while (node != null) {
|
||||
AstNode next;
|
||||
if (start <= node.StartLocation && node.EndLocation <= end) {
|
||||
// Remember next before yielding node.
|
||||
// This allows iteration to continue when the caller removes/replaces the node.
|
||||
next = node.NextSibling;
|
||||
yield return node;
|
||||
} else {
|
||||
if (node.EndLocation <= start) {
|
||||
next = node.NextSibling;
|
||||
} else {
|
||||
next = node.FirstChild;
|
||||
}
|
||||
}
|
||||
|
||||
if (next != null && next.StartLocation > end)
|
||||
yield break;
|
||||
node = next;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the node as formatted C# output.
|
||||
/// </summary>
|
||||
/// <param name='formattingOptions'>
|
||||
/// Formatting options.
|
||||
/// </param>
|
||||
public virtual string GetText (CSharpFormattingOptions formattingOptions = null)
|
||||
{
|
||||
if (IsNull)
|
||||
return "";
|
||||
var w = new StringWriter ();
|
||||
AcceptVisitor (new CSharpOutputVisitor (w, formattingOptions ?? FormattingOptionsFactory.CreateMono ()));
|
||||
return w.ToString ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the given coordinates (line, column) are in the node.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True, if the given coordinates are between StartLocation and EndLocation (exclusive); otherwise, false.
|
||||
/// </returns>
|
||||
public bool Contains (int line, int column)
|
||||
{
|
||||
return Contains (new TextLocation (line, column));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the given coordinates are in the node.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True, if location is between StartLocation and EndLocation (exclusive); otherwise, false.
|
||||
/// </returns>
|
||||
public bool Contains (TextLocation location)
|
||||
{
|
||||
return this.StartLocation <= location && location < this.EndLocation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the given coordinates (line, column) are in the node.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True, if the given coordinates are between StartLocation and EndLocation (inclusive); otherwise, false.
|
||||
/// </returns>
|
||||
public bool IsInside (int line, int column)
|
||||
{
|
||||
return IsInside (new TextLocation (line, column));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true, if the given coordinates are in the node.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True, if location is between StartLocation and EndLocation (inclusive); otherwise, false.
|
||||
/// </returns>
|
||||
public bool IsInside (TextLocation location)
|
||||
{
|
||||
return this.StartLocation <= location && location <= this.EndLocation;
|
||||
}
|
||||
|
||||
public override void AddAnnotation (object annotation)
|
||||
{
|
||||
if (this.IsNull)
|
||||
throw new InvalidOperationException ("Cannot add annotations to the null node");
|
||||
base.AddAnnotation (annotation);
|
||||
}
|
||||
|
||||
internal string DebugToString()
|
||||
{
|
||||
if (IsNull)
|
||||
return "Null";
|
||||
string text = GetText();
|
||||
text = text.TrimEnd().Replace("\t", "").Replace(Environment.NewLine, " ");
|
||||
if (text.Length > 100)
|
||||
return text.Substring(0, 97) + "...";
|
||||
else
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using ICSharpCode.NRefactory.PatternMatching;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the children of an AstNode that have a specific role.
|
||||
/// </summary>
|
||||
public class AstNodeCollection<T> : ICollection<T> where T : AstNode
|
||||
{
|
||||
readonly AstNode node;
|
||||
readonly Role<T> role;
|
||||
|
||||
public AstNodeCollection(AstNode node, Role<T> role)
|
||||
{
|
||||
if (node == null)
|
||||
throw new ArgumentNullException("node");
|
||||
if (role == null)
|
||||
throw new ArgumentNullException("role");
|
||||
this.node = node;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
int count = 0;
|
||||
for (AstNode cur = node.FirstChild; cur != null; cur = cur.NextSibling) {
|
||||
if (cur.Role == role)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(T element)
|
||||
{
|
||||
node.AddChild(element, role);
|
||||
}
|
||||
|
||||
public void AddRange(IEnumerable<T> nodes)
|
||||
{
|
||||
// Evaluate 'nodes' first, since it might change when we add the new children
|
||||
// Example: collection.AddRange(collection);
|
||||
if (nodes != null) {
|
||||
foreach (T node in nodes.ToList())
|
||||
Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRange(T[] nodes)
|
||||
{
|
||||
// Fast overload for arrays - we don't need to create a copy
|
||||
if (nodes != null) {
|
||||
foreach (T node in nodes)
|
||||
Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReplaceWith(IEnumerable<T> nodes)
|
||||
{
|
||||
// Evaluate 'nodes' first, since it might change when we call Clear()
|
||||
// Example: collection.ReplaceWith(collection);
|
||||
if (nodes != null)
|
||||
nodes = nodes.ToList();
|
||||
Clear();
|
||||
if (nodes != null) {
|
||||
foreach (T node in nodes)
|
||||
Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveTo(ICollection<T> targetCollection)
|
||||
{
|
||||
if (targetCollection == null)
|
||||
throw new ArgumentNullException("targetCollection");
|
||||
foreach (T node in this) {
|
||||
node.Remove();
|
||||
targetCollection.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(T element)
|
||||
{
|
||||
return element != null && element.Parent == node && element.Role == role;
|
||||
}
|
||||
|
||||
public bool Remove(T element)
|
||||
{
|
||||
if (Contains(element)) {
|
||||
element.Remove();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
foreach (T item in this)
|
||||
array[arrayIndex++] = item;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (T item in this)
|
||||
item.Remove();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the first element for which the predicate returns true,
|
||||
/// or the null node (AstNode with IsNull=true) if no such object is found.
|
||||
/// </summary>
|
||||
public T FirstOrNullObject(Func<T, bool> predicate = null)
|
||||
{
|
||||
foreach (T item in this)
|
||||
if (predicate == null || predicate(item))
|
||||
return item;
|
||||
return role.NullObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last element for which the predicate returns true,
|
||||
/// or the null node (AstNode with IsNull=true) if no such object is found.
|
||||
/// </summary>
|
||||
public T LastOrNullObject(Func<T, bool> predicate = null)
|
||||
{
|
||||
T result = role.NullObject;
|
||||
foreach (T item in this)
|
||||
if (predicate == null || predicate(item))
|
||||
result = item;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ICollection<T>.IsReadOnly {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
AstNode next;
|
||||
for (AstNode cur = node.FirstChild; cur != null; cur = next) {
|
||||
Debug.Assert(cur.Parent == node);
|
||||
// Remember next before yielding cur.
|
||||
// This allows removing/replacing nodes while iterating through the list.
|
||||
next = cur.NextSibling;
|
||||
if (cur.Role == role)
|
||||
yield return (T)cur;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#region Equals and GetHashCode implementation
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return node.GetHashCode() ^ role.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
AstNodeCollection<T> other = obj as AstNodeCollection<T>;
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.node == other.node && this.role == other.role;
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal bool DoMatch(AstNodeCollection<T> other, Match match)
|
||||
{
|
||||
return Pattern.DoMatchCollection(role, node.FirstChild, other.node.FirstChild, match);
|
||||
}
|
||||
|
||||
public void InsertAfter(T existingItem, T newItem)
|
||||
{
|
||||
node.InsertChildAfter(existingItem, newItem, role);
|
||||
}
|
||||
|
||||
public void InsertBefore(T existingItem, T newItem)
|
||||
{
|
||||
node.InsertChildBefore(existingItem, newItem, role);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the <paramref name="visitor"/> to all nodes in this collection.
|
||||
/// </summary>
|
||||
public void AcceptVisitor(IAstVisitor visitor)
|
||||
{
|
||||
AstNode next;
|
||||
for (AstNode cur = node.FirstChild; cur != null; cur = next) {
|
||||
Debug.Assert(cur.Parent == node);
|
||||
// Remember next before yielding cur.
|
||||
// This allows removing/replacing nodes while iterating through the list.
|
||||
next = cur.NextSibling;
|
||||
if (cur.Role == role)
|
||||
cur.AcceptVisitor(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ICSharpCode.NRefactory.CSharp.Resolver;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A type reference in the C# AST.
|
||||
/// </summary>
|
||||
public abstract class AstType : AstNode
|
||||
{
|
||||
#region Null
|
||||
public new static readonly AstType Null = new NullAstType ();
|
||||
|
||||
sealed class NullAstType : AstType
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode)
|
||||
{
|
||||
return SpecialType.UnknownType;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PatternPlaceholder
|
||||
public static implicit operator AstType(PatternMatching.Pattern pattern)
|
||||
{
|
||||
return pattern != null ? new PatternPlaceholder(pattern) : null;
|
||||
}
|
||||
|
||||
sealed class PatternPlaceholder : AstType, PatternMatching.INode
|
||||
{
|
||||
readonly PatternMatching.Pattern child;
|
||||
|
||||
public PatternPlaceholder(PatternMatching.Pattern child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Pattern; }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPatternPlaceholder (this, child);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder (this, child);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder (this, child, data);
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return child.DoMatch(other, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.TypeReference; }
|
||||
}
|
||||
|
||||
public new AstType Clone()
|
||||
{
|
||||
return (AstType)base.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an ITypeReference for this AstType.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The resulting type reference will read the context information from the
|
||||
/// <see cref="ITypeResolveContext"/>:
|
||||
/// For resolving type parameters, the CurrentTypeDefinition/CurrentMember is used.
|
||||
/// For resolving simple names, the current namespace and usings from the CurrentUsingScope
|
||||
/// (on CSharpTypeResolveContext only) is used.
|
||||
/// </remarks>
|
||||
public abstract ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a pointer type from this type by nesting it in a <see cref="ComposedType"/>.
|
||||
/// If this type already is a pointer type, this method just increases the PointerRank of the existing pointer type.
|
||||
/// </summary>
|
||||
public virtual AstType MakePointerType()
|
||||
{
|
||||
return new ComposedType { BaseType = this }.MakePointerType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an array type from this type by nesting it in a <see cref="ComposedType"/>.
|
||||
/// If this type already is an array type, the additional rank is prepended to the existing array specifier list.
|
||||
/// Thus, <c>new SimpleType("T").MakeArrayType(1).MakeArrayType(2)</c> will result in "T[,][]".
|
||||
/// </summary>
|
||||
public virtual AstType MakeArrayType(int rank = 1)
|
||||
{
|
||||
return new ComposedType { BaseType = this }.MakeArrayType(rank);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a nullable type from this type by nesting it in a <see cref="ComposedType"/>.
|
||||
/// </summary>
|
||||
public AstType MakeNullableType()
|
||||
{
|
||||
return new ComposedType { BaseType = this, HasNullableSpecifier = true };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an expression that can be used to access a static member on this type.
|
||||
/// </summary>
|
||||
public MemberReferenceExpression Member(string memberName)
|
||||
{
|
||||
return new TypeReferenceExpression { Type = this }.Member(memberName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an expression that can be used to access a static member on this type.
|
||||
/// </summary>
|
||||
public MemberType MemberType(string memberName, params AstType[] typeArguments)
|
||||
{
|
||||
var memberType = new MemberType(this, memberName);
|
||||
memberType.TypeArguments.AddRange(typeArguments);
|
||||
return memberType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an expression that can be used to access a static member on this type.
|
||||
/// </summary>
|
||||
public MemberType MemberType(string memberName, IEnumerable<AstType> typeArguments)
|
||||
{
|
||||
var memberType = new MemberType(this, memberName);
|
||||
memberType.TypeArguments.AddRange(typeArguments);
|
||||
return memberType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this type as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(string methodName, IEnumerable<Expression> arguments)
|
||||
{
|
||||
return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this type as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(string methodName, params Expression[] arguments)
|
||||
{
|
||||
return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this type as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(string methodName, IEnumerable<AstType> typeArguments, IEnumerable<Expression> arguments)
|
||||
{
|
||||
return new TypeReferenceExpression { Type = this }.Invoke(methodName, typeArguments, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
//
|
||||
// CSharpModifierToken.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class CSharpModifierToken : CSharpTokenNode
|
||||
{
|
||||
Modifiers modifier;
|
||||
|
||||
public Modifiers Modifier {
|
||||
get { return modifier; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
this.modifier = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override int TokenLength {
|
||||
get {
|
||||
return GetModifierName (modifier).Length;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetText (CSharpFormattingOptions formattingOptions = null)
|
||||
{
|
||||
return GetModifierName (Modifier);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
CSharpModifierToken o = other as CSharpModifierToken;
|
||||
return o != null && this.modifier == o.modifier;
|
||||
}
|
||||
|
||||
// Not worth using a dictionary for such few elements.
|
||||
// This table is sorted in the order that modifiers should be output when generating code.
|
||||
static readonly Modifiers[] allModifiers = {
|
||||
Modifiers.Public, Modifiers.Protected, Modifiers.Private, Modifiers.Internal,
|
||||
Modifiers.New,
|
||||
Modifiers.Unsafe,
|
||||
Modifiers.Abstract, Modifiers.Virtual, Modifiers.Sealed, Modifiers.Static, Modifiers.Override,
|
||||
Modifiers.Readonly, Modifiers.Volatile,
|
||||
Modifiers.Extern, Modifiers.Partial, Modifiers.Const,
|
||||
Modifiers.Async,
|
||||
Modifiers.Any
|
||||
};
|
||||
|
||||
public static IEnumerable<Modifiers> AllModifiers {
|
||||
get { return allModifiers; }
|
||||
}
|
||||
|
||||
public CSharpModifierToken (TextLocation location, Modifiers modifier) : base (location)
|
||||
{
|
||||
this.Modifier = modifier;
|
||||
}
|
||||
|
||||
public static string GetModifierName(Modifiers modifier)
|
||||
{
|
||||
switch (modifier) {
|
||||
case Modifiers.Private:
|
||||
return "private";
|
||||
case Modifiers.Internal:
|
||||
return "internal";
|
||||
case Modifiers.Protected:
|
||||
return "protected";
|
||||
case Modifiers.Public:
|
||||
return "public";
|
||||
case Modifiers.Abstract:
|
||||
return "abstract";
|
||||
case Modifiers.Virtual:
|
||||
return "virtual";
|
||||
case Modifiers.Sealed:
|
||||
return "sealed";
|
||||
case Modifiers.Static:
|
||||
return "static";
|
||||
case Modifiers.Override:
|
||||
return "override";
|
||||
case Modifiers.Readonly:
|
||||
return "readonly";
|
||||
case Modifiers.Const:
|
||||
return "const";
|
||||
case Modifiers.New:
|
||||
return "new";
|
||||
case Modifiers.Partial:
|
||||
return "partial";
|
||||
case Modifiers.Extern:
|
||||
return "extern";
|
||||
case Modifiers.Volatile:
|
||||
return "volatile";
|
||||
case Modifiers.Unsafe:
|
||||
return "unsafe";
|
||||
case Modifiers.Async:
|
||||
return "async";
|
||||
case Modifiers.Any:
|
||||
// even though it's used for pattern matching only, 'any' needs to be in this list to be usable in the AST
|
||||
return "any";
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for Modifiers");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
//
|
||||
// TokenNode.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a token in C#. Note that the type of the token is defined through the TokenRole.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole.
|
||||
/// </remarks>
|
||||
public class CSharpTokenNode : AstNode
|
||||
{
|
||||
public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode ();
|
||||
class NullCSharpTokenNode : CSharpTokenNode
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public NullCSharpTokenNode () : base (TextLocation.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Token;
|
||||
}
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual int TokenLength {
|
||||
get {
|
||||
if (!(Role is TokenRole))
|
||||
return 0;
|
||||
return ((TokenRole)Role).Length;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (StartLocation.Line, StartLocation.Column + TokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode (TextLocation location)
|
||||
{
|
||||
this.startLocation = location;
|
||||
}
|
||||
|
||||
public override string GetText (CSharpFormattingOptions formattingOptions = null)
|
||||
{
|
||||
if (!(Role is TokenRole))
|
||||
return null;
|
||||
return ((TokenRole)Role).Token;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitCSharpTokenNode (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitCSharpTokenNode (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitCSharpTokenNode (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
CSharpTokenNode o = other as CSharpTokenNode;
|
||||
return o != null && !o.IsNull && !(o is CSharpModifierToken);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("[CSharpTokenNode: StartLocation={0}, EndLocation={1}, Role={2}]", StartLocation, EndLocation, Role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
//
|
||||
// CSharpUtil.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
using ICSharpCode.NRefactory.CSharp;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public static class CSharpUtil
|
||||
{
|
||||
public static Expression InvertCondition (Expression condition)
|
||||
{
|
||||
return InvertConditionInternal (condition.Clone ());
|
||||
}
|
||||
|
||||
static Expression InvertConditionInternal (Expression condition)
|
||||
{
|
||||
if (condition is ParenthesizedExpression) {
|
||||
((ParenthesizedExpression)condition).Expression = InvertCondition (((ParenthesizedExpression)condition).Expression);
|
||||
return condition;
|
||||
}
|
||||
|
||||
if (condition is UnaryOperatorExpression) {
|
||||
var uOp = (UnaryOperatorExpression)condition;
|
||||
if (uOp.Operator == UnaryOperatorType.Not)
|
||||
return uOp.Expression;
|
||||
return new UnaryOperatorExpression (UnaryOperatorType.Not, uOp);
|
||||
}
|
||||
|
||||
if (condition is BinaryOperatorExpression) {
|
||||
var bOp = (BinaryOperatorExpression)condition;
|
||||
var negatedOp = NegateRelationalOperator (bOp.Operator);
|
||||
if (negatedOp == BinaryOperatorType.Any)
|
||||
return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition));
|
||||
bOp.Operator = negatedOp;
|
||||
return bOp;
|
||||
}
|
||||
if (condition is ConditionalExpression) {
|
||||
var cEx = condition as ConditionalExpression;
|
||||
cEx.Condition = InvertCondition (cEx.Condition);
|
||||
return cEx;
|
||||
}
|
||||
if (condition is PrimitiveExpression) {
|
||||
var pex = condition as PrimitiveExpression;
|
||||
if (pex.Value is bool) {
|
||||
return new PrimitiveExpression (!((bool)pex.Value));
|
||||
}
|
||||
}
|
||||
|
||||
return new UnaryOperatorExpression (UnaryOperatorType.Not, condition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get negation of the specified relational operator
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// negation of the specified relational operator, or BinaryOperatorType.Any if it's not a relational operator
|
||||
/// </returns>
|
||||
public static BinaryOperatorType NegateRelationalOperator (BinaryOperatorType op)
|
||||
{
|
||||
switch (op) {
|
||||
case BinaryOperatorType.GreaterThan:
|
||||
return BinaryOperatorType.LessThanOrEqual;
|
||||
case BinaryOperatorType.GreaterThanOrEqual:
|
||||
return BinaryOperatorType.LessThan;
|
||||
case BinaryOperatorType.Equality:
|
||||
return BinaryOperatorType.InEquality;
|
||||
case BinaryOperatorType.InEquality:
|
||||
return BinaryOperatorType.Equality;
|
||||
case BinaryOperatorType.LessThan:
|
||||
return BinaryOperatorType.GreaterThanOrEqual;
|
||||
case BinaryOperatorType.LessThanOrEqual:
|
||||
return BinaryOperatorType.GreaterThan;
|
||||
}
|
||||
return BinaryOperatorType.Any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
//
|
||||
// ComposedType.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class ComposedType : AstType
|
||||
{
|
||||
public static readonly TokenRole NullableRole = new TokenRole("?");
|
||||
public static readonly TokenRole PointerRole = new TokenRole("*");
|
||||
public static readonly Role<ArraySpecifier> ArraySpecifierRole = new Role<ArraySpecifier>("ArraySpecifier");
|
||||
|
||||
public AstType BaseType {
|
||||
get { return GetChildByRole(Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public bool HasNullableSpecifier {
|
||||
get {
|
||||
return !GetChildByRole(NullableRole).IsNull;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(NullableRole, value ? new CSharpTokenNode(TextLocation.Empty) : null);
|
||||
}
|
||||
}
|
||||
|
||||
public int PointerRank {
|
||||
get {
|
||||
return GetChildrenByRole(PointerRole).Count;
|
||||
}
|
||||
set {
|
||||
if (value < 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
int d = this.PointerRank;
|
||||
while (d > value) {
|
||||
GetChildByRole(PointerRole).Remove();
|
||||
d--;
|
||||
}
|
||||
while (d < value) {
|
||||
InsertChildBefore(GetChildByRole(PointerRole), new CSharpTokenNode(TextLocation.Empty), PointerRole);
|
||||
d++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<ArraySpecifier> ArraySpecifiers {
|
||||
get { return GetChildrenByRole (ArraySpecifierRole); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitComposedType (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitComposedType (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitComposedType (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ComposedType o = other as ComposedType;
|
||||
return o != null && this.HasNullableSpecifier == o.HasNullableSpecifier && this.PointerRank == o.PointerRank && this.ArraySpecifiers.DoMatch(o.ArraySpecifiers, match);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.Append(this.BaseType.ToString());
|
||||
if (this.HasNullableSpecifier)
|
||||
b.Append('?');
|
||||
b.Append('*', this.PointerRank);
|
||||
foreach (var arraySpecifier in this.ArraySpecifiers) {
|
||||
b.Append('[');
|
||||
b.Append(',', arraySpecifier.Dimensions - 1);
|
||||
b.Append(']');
|
||||
}
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
public override AstType MakePointerType()
|
||||
{
|
||||
if (ArraySpecifiers.Any()) {
|
||||
return base.MakePointerType();
|
||||
} else {
|
||||
this.PointerRank++;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public override AstType MakeArrayType(int dimensions)
|
||||
{
|
||||
InsertChildBefore(this.ArraySpecifiers.FirstOrDefault(), new ArraySpecifier(dimensions), ArraySpecifierRole);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type)
|
||||
{
|
||||
ITypeReference t = this.BaseType.ToTypeReference(lookupMode);
|
||||
if (this.HasNullableSpecifier) {
|
||||
t = NullableType.Create(t);
|
||||
}
|
||||
int pointerRank = this.PointerRank;
|
||||
for (int i = 0; i < pointerRank; i++) {
|
||||
t = new PointerTypeReference(t);
|
||||
}
|
||||
foreach (var a in this.ArraySpecifiers.Reverse()) {
|
||||
t = new ArrayTypeReference(t, a.Dimensions);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [,,,]
|
||||
/// </summary>
|
||||
public class ArraySpecifier : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public ArraySpecifier()
|
||||
{
|
||||
}
|
||||
|
||||
public ArraySpecifier(int dimensions)
|
||||
{
|
||||
this.Dimensions = dimensions;
|
||||
}
|
||||
|
||||
public CSharpTokenNode LBracketToken {
|
||||
get { return GetChildByRole (Roles.LBracket); }
|
||||
}
|
||||
|
||||
public int Dimensions {
|
||||
get { return 1 + GetChildrenByRole(Roles.Comma).Count; }
|
||||
set {
|
||||
int d = this.Dimensions;
|
||||
while (d > value) {
|
||||
GetChildByRole(Roles.Comma).Remove();
|
||||
d--;
|
||||
}
|
||||
while (d < value) {
|
||||
InsertChildBefore(GetChildByRole(Roles.Comma), new CSharpTokenNode(TextLocation.Empty), Roles.Comma);
|
||||
d++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBracketToken {
|
||||
get { return GetChildByRole (Roles.RBracket); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitArraySpecifier (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitArraySpecifier (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitArraySpecifier(this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ArraySpecifier o = other as ArraySpecifier;
|
||||
return o != null && this.Dimensions == o.Dimensions;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[" + new string(',', this.Dimensions - 1) + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,149 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 'cref' reference in XML documentation.
|
||||
/// </summary>
|
||||
public class DocumentationReference : AstNode
|
||||
{
|
||||
public static readonly Role<AstType> DeclaringTypeRole = new Role<AstType>("DeclaringType", AstType.Null);
|
||||
public static readonly Role<AstType> ConversionOperatorReturnTypeRole = new Role<AstType>("ConversionOperatorReturnType", AstType.Null);
|
||||
|
||||
EntityType entityType;
|
||||
OperatorType operatorType;
|
||||
bool hasParameterList;
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the entity type.
|
||||
/// Possible values are:
|
||||
/// <c>EntityType.Operator</c> for operators,
|
||||
/// <c>EntityType.Indexer</c> for indexers,
|
||||
/// <c>EntityType.TypeDefinition</c> for references to primitive types,
|
||||
/// and <c>EntityType.None</c> for everything else.
|
||||
/// </summary>
|
||||
public EntityType EntityType {
|
||||
get { return entityType; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
entityType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the operator type.
|
||||
/// This property is only used when EntityType==Operator.
|
||||
/// </summary>
|
||||
public OperatorType OperatorType {
|
||||
get { return operatorType; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
operatorType = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets whether a parameter list was provided.
|
||||
/// </summary>
|
||||
public bool HasParameterList {
|
||||
get { return hasParameterList; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
hasParameterList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Unknown; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the declaring type.
|
||||
/// </summary>
|
||||
public AstType DeclaringType {
|
||||
get { return GetChildByRole(DeclaringTypeRole); }
|
||||
set { SetChildByRole(DeclaringTypeRole, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the member name.
|
||||
/// This property is only used when EntityType==None.
|
||||
/// </summary>
|
||||
public string MemberName {
|
||||
get { return GetChildByRole(Roles.Identifier).Name; }
|
||||
set { SetChildByRole(Roles.Identifier, Identifier.Create(value)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the return type of conversion operators.
|
||||
/// This property is only used when EntityType==Operator and OperatorType is explicit or implicit.
|
||||
/// </summary>
|
||||
public AstType ConversionOperatorReturnType {
|
||||
get { return GetChildByRole(ConversionOperatorReturnTypeRole); }
|
||||
set { SetChildByRole(ConversionOperatorReturnTypeRole, value); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> TypeArguments {
|
||||
get { return GetChildrenByRole (Roles.TypeArgument); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<ParameterDeclaration> Parameters {
|
||||
get { return GetChildrenByRole (Roles.Parameter); }
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
|
||||
{
|
||||
DocumentationReference o = other as DocumentationReference;
|
||||
if (!(o != null && this.EntityType == o.EntityType && this.HasParameterList == o.HasParameterList))
|
||||
return false;
|
||||
if (this.EntityType == EntityType.Operator) {
|
||||
if (this.OperatorType != o.OperatorType)
|
||||
return false;
|
||||
if (this.OperatorType == OperatorType.Implicit || this.OperatorType == OperatorType.Explicit) {
|
||||
if (!this.ConversionOperatorReturnType.DoMatch(o.ConversionOperatorReturnType, match))
|
||||
return false;
|
||||
}
|
||||
} else if (this.EntityType == EntityType.None) {
|
||||
if (!MatchString(this.MemberName, o.MemberName))
|
||||
return false;
|
||||
if (!this.TypeArguments.DoMatch(o.TypeArguments, match))
|
||||
return false;
|
||||
}
|
||||
return this.Parameters.DoMatch(o.Parameters, match);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitDocumentationReference (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitDocumentationReference (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitDocumentationReference (this, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// ErrorNode.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Xamarin (http://www.xamarin.com);
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a parsing error in the ast. At the moment it only represents missing closing bracket.
|
||||
/// This closing bracket is replaced by a node at the highest possible position.
|
||||
/// (To make GetAstNodeAt (line, col) working).
|
||||
/// </summary>
|
||||
public class ErrorNode : AstNode
|
||||
{
|
||||
static TextLocation maxLoc = new TextLocation (int.MaxValue, int.MaxValue);
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return maxLoc;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return maxLoc;
|
||||
}
|
||||
}
|
||||
|
||||
public ErrorNode ()
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
// nothing
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as ErrorNode;
|
||||
return o != null;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return "[ErrorNode]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
//
|
||||
// AnonymousMethodExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// [async] delegate(Parameters) {Body}
|
||||
/// </summary>
|
||||
public class AnonymousMethodExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole DelegateKeywordRole = new TokenRole ("delegate");
|
||||
public readonly static TokenRole AsyncModifierRole = LambdaExpression.AsyncModifierRole;
|
||||
|
||||
bool isAsync;
|
||||
|
||||
public bool IsAsync {
|
||||
get { return isAsync; }
|
||||
set { ThrowIfFrozen(); isAsync = value; }
|
||||
}
|
||||
|
||||
// used to tell the difference between delegate {} and delegate () {}
|
||||
bool hasParameterList;
|
||||
|
||||
public bool HasParameterList {
|
||||
get { return hasParameterList; }
|
||||
set { ThrowIfFrozen(); hasParameterList = value; }
|
||||
}
|
||||
|
||||
public CSharpTokenNode DelegateToken {
|
||||
get { return GetChildByRole (DelegateKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<ParameterDeclaration> Parameters {
|
||||
get { return GetChildrenByRole (Roles.Parameter); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public BlockStatement Body {
|
||||
get { return GetChildByRole (Roles.Body); }
|
||||
set { SetChildByRole (Roles.Body, value); }
|
||||
}
|
||||
|
||||
public AnonymousMethodExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public AnonymousMethodExpression (BlockStatement body, IEnumerable<ParameterDeclaration> parameters = null)
|
||||
{
|
||||
if (parameters != null) {
|
||||
foreach (var parameter in parameters) {
|
||||
AddChild (parameter, Roles.Parameter);
|
||||
}
|
||||
}
|
||||
AddChild (body, Roles.Body);
|
||||
}
|
||||
|
||||
public AnonymousMethodExpression (BlockStatement body, params ParameterDeclaration[] parameters) : this (body, (IEnumerable<ParameterDeclaration>)parameters)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitAnonymousMethodExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitAnonymousMethodExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitAnonymousMethodExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
AnonymousMethodExpression o = other as AnonymousMethodExpression;
|
||||
return o != null && this.IsAsync == o.IsAsync && this.HasParameterList == o.HasParameterList
|
||||
&& this.Parameters.DoMatch(o.Parameters, match) && this.Body.DoMatch(o.Body, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
//
|
||||
// AnonymousTypeCreateExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// new { [ExpressionList] }
|
||||
/// </summary>
|
||||
public class AnonymousTypeCreateExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole NewKeywordRole = new TokenRole ("new");
|
||||
|
||||
public CSharpTokenNode NewToken {
|
||||
get { return GetChildByRole (NewKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Initializers {
|
||||
get { return GetChildrenByRole (Roles.Expression); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public AnonymousTypeCreateExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public AnonymousTypeCreateExpression (IEnumerable<Expression> initializers)
|
||||
{
|
||||
foreach (var ini in initializers) {
|
||||
AddChild (ini, Roles.Expression);
|
||||
}
|
||||
}
|
||||
|
||||
public AnonymousTypeCreateExpression (params Expression[] initializer) : this ((IEnumerable<Expression>)initializer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitAnonymousTypeCreateExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitAnonymousTypeCreateExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitAnonymousTypeCreateExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as AnonymousTypeCreateExpression;
|
||||
return o != null && this.Initializers.DoMatch(o.Initializers, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// new Type[Dimensions]
|
||||
/// </summary>
|
||||
public class ArrayCreateExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole NewKeywordRole = new TokenRole ("new");
|
||||
public readonly static Role<ArraySpecifier> AdditionalArraySpecifierRole = new Role<ArraySpecifier>("AdditionalArraySpecifier");
|
||||
public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null);
|
||||
|
||||
public CSharpTokenNode NewToken {
|
||||
get { return GetChildByRole (NewKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Arguments {
|
||||
get { return GetChildrenByRole (Roles.Argument); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets additional array ranks (those without size info).
|
||||
/// Empty for "new int[5,1]"; will contain a single element for "new int[5][]".
|
||||
/// </summary>
|
||||
public AstNodeCollection<ArraySpecifier> AdditionalArraySpecifiers {
|
||||
get { return GetChildrenByRole(AdditionalArraySpecifierRole); }
|
||||
}
|
||||
|
||||
public ArrayInitializerExpression Initializer {
|
||||
get { return GetChildByRole (InitializerRole); }
|
||||
set { SetChildByRole (InitializerRole, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitArrayCreateExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitArrayCreateExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitArrayCreateExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ArrayCreateExpression o = other as ArrayCreateExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.AdditionalArraySpecifiers.DoMatch(o.AdditionalArraySpecifiers, match) && this.Initializer.DoMatch(o.Initializer, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
-191
@@ -1,191 +0,0 @@
|
||||
//
|
||||
// ArrayInitializerExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// { Elements }
|
||||
/// </summary>
|
||||
public class ArrayInitializerExpression : Expression
|
||||
{
|
||||
/// <summary>
|
||||
/// For ease of use purposes in the resolver the ast representation
|
||||
/// of { a, b, c } is { {a}, {b}, {c} }.
|
||||
/// If IsSingleElement is true then this array initializer expression is a generated one.
|
||||
/// That has no meaning in the source code (and contains no brace tokens).
|
||||
/// </summary>
|
||||
public virtual bool IsSingleElement {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayInitializerExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public ArrayInitializerExpression(IEnumerable<Expression> elements)
|
||||
{
|
||||
this.Elements.AddRange(elements);
|
||||
}
|
||||
|
||||
public ArrayInitializerExpression(params Expression[] elements)
|
||||
{
|
||||
this.Elements.AddRange(elements);
|
||||
}
|
||||
|
||||
#region Null
|
||||
public new static readonly ArrayInitializerExpression Null = new NullArrayInitializerExpression ();
|
||||
|
||||
sealed class NullArrayInitializerExpression : ArrayInitializerExpression
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public CSharpTokenNode LBraceToken {
|
||||
get { return GetChildByRole (Roles.LBrace); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Elements {
|
||||
get { return GetChildrenByRole(Roles.Expression); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBraceToken {
|
||||
get { return GetChildByRole (Roles.RBrace); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitArrayInitializerExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitArrayInitializerExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitArrayInitializerExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ArrayInitializerExpression o = other as ArrayInitializerExpression;
|
||||
return o != null && this.Elements.DoMatch(o.Elements, match);
|
||||
}
|
||||
|
||||
public static ArrayInitializerExpression CreateSingleElementInitializer ()
|
||||
{
|
||||
return new SingleArrayInitializerExpression();
|
||||
}
|
||||
/// <summary>
|
||||
/// Single elements in array initializers are represented with this special class.
|
||||
/// </summary>
|
||||
class SingleArrayInitializerExpression : ArrayInitializerExpression
|
||||
{
|
||||
public override bool IsSingleElement {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region PatternPlaceholder
|
||||
public static implicit operator ArrayInitializerExpression(PatternMatching.Pattern pattern)
|
||||
{
|
||||
return pattern != null ? new PatternPlaceholder(pattern) : null;
|
||||
}
|
||||
|
||||
sealed class PatternPlaceholder : ArrayInitializerExpression, PatternMatching.INode
|
||||
{
|
||||
readonly PatternMatching.Pattern child;
|
||||
|
||||
public PatternPlaceholder(PatternMatching.Pattern child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Pattern; }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPatternPlaceholder(this, child);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return child.DoMatch(other, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
//
|
||||
// AsExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Expression as TypeReference
|
||||
/// </summary>
|
||||
public class AsExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole AsKeywordRole = new TokenRole ("as");
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole(Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode AsToken {
|
||||
get { return GetChildByRole (AsKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public AsExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public AsExpression (Expression expression, AstType type)
|
||||
{
|
||||
AddChild (expression, Roles.Expression);
|
||||
AddChild (type, Roles.Type);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitAsExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitAsExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitAsExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
AsExpression o = other as AsExpression;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match) && this.Type.DoMatch(o.Type, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
//
|
||||
// AssignmentExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Left Operator= Right
|
||||
/// </summary>
|
||||
public class AssignmentExpression : Expression
|
||||
{
|
||||
// reuse roles from BinaryOperatorExpression
|
||||
public readonly static Role<Expression> LeftRole = BinaryOperatorExpression.LeftRole;
|
||||
public readonly static Role<Expression> RightRole = BinaryOperatorExpression.RightRole;
|
||||
|
||||
public readonly static TokenRole AssignRole = new TokenRole ("=");
|
||||
public readonly static TokenRole AddRole = new TokenRole ("+=");
|
||||
public readonly static TokenRole SubtractRole = new TokenRole ("-=");
|
||||
public readonly static TokenRole MultiplyRole = new TokenRole ("*=");
|
||||
public readonly static TokenRole DivideRole = new TokenRole ("/=");
|
||||
public readonly static TokenRole ModulusRole = new TokenRole ("%=");
|
||||
public readonly static TokenRole ShiftLeftRole = new TokenRole ("<<=");
|
||||
public readonly static TokenRole ShiftRightRole = new TokenRole (">>=");
|
||||
public readonly static TokenRole BitwiseAndRole = new TokenRole ("&=");
|
||||
public readonly static TokenRole BitwiseOrRole = new TokenRole ("|=");
|
||||
public readonly static TokenRole ExclusiveOrRole = new TokenRole ("^=");
|
||||
|
||||
public AssignmentExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public AssignmentExpression(Expression left, Expression right)
|
||||
{
|
||||
this.Left = left;
|
||||
this.Right = right;
|
||||
}
|
||||
|
||||
public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right)
|
||||
{
|
||||
this.Left = left;
|
||||
this.Operator = op;
|
||||
this.Right = right;
|
||||
}
|
||||
|
||||
public AssignmentOperatorType Operator {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Expression Left {
|
||||
get { return GetChildByRole (LeftRole); }
|
||||
set { SetChildByRole(LeftRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode OperatorToken {
|
||||
get { return GetChildByRole (GetOperatorRole(Operator)); }
|
||||
}
|
||||
|
||||
public Expression Right {
|
||||
get { return GetChildByRole (RightRole); }
|
||||
set { SetChildByRole(RightRole, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitAssignmentExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitAssignmentExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitAssignmentExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
AssignmentExpression o = other as AssignmentExpression;
|
||||
return o != null && (this.Operator == AssignmentOperatorType.Any || this.Operator == o.Operator)
|
||||
&& this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match);
|
||||
}
|
||||
|
||||
public static TokenRole GetOperatorRole(AssignmentOperatorType op)
|
||||
{
|
||||
switch (op) {
|
||||
case AssignmentOperatorType.Assign:
|
||||
return AssignRole;
|
||||
case AssignmentOperatorType.Add:
|
||||
return AddRole;
|
||||
case AssignmentOperatorType.Subtract:
|
||||
return SubtractRole;
|
||||
case AssignmentOperatorType.Multiply:
|
||||
return MultiplyRole;
|
||||
case AssignmentOperatorType.Divide:
|
||||
return DivideRole;
|
||||
case AssignmentOperatorType.Modulus:
|
||||
return ModulusRole;
|
||||
case AssignmentOperatorType.ShiftLeft:
|
||||
return ShiftLeftRole;
|
||||
case AssignmentOperatorType.ShiftRight:
|
||||
return ShiftRightRole;
|
||||
case AssignmentOperatorType.BitwiseAnd:
|
||||
return BitwiseAndRole;
|
||||
case AssignmentOperatorType.BitwiseOr:
|
||||
return BitwiseOrRole;
|
||||
case AssignmentOperatorType.ExclusiveOr:
|
||||
return ExclusiveOrRole;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for AssignmentOperatorType");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the binary operator for the specified compound assignment operator.
|
||||
/// Returns null if 'op' is not a compound assignment.
|
||||
/// </summary>
|
||||
public static BinaryOperatorType? GetCorrespondingBinaryOperator(AssignmentOperatorType op)
|
||||
{
|
||||
switch (op) {
|
||||
case AssignmentOperatorType.Assign:
|
||||
return null;
|
||||
case AssignmentOperatorType.Add:
|
||||
return BinaryOperatorType.Add;
|
||||
case AssignmentOperatorType.Subtract:
|
||||
return BinaryOperatorType.Subtract;
|
||||
case AssignmentOperatorType.Multiply:
|
||||
return BinaryOperatorType.Multiply;
|
||||
case AssignmentOperatorType.Divide:
|
||||
return BinaryOperatorType.Divide;
|
||||
case AssignmentOperatorType.Modulus:
|
||||
return BinaryOperatorType.Modulus;
|
||||
case AssignmentOperatorType.ShiftLeft:
|
||||
return BinaryOperatorType.ShiftLeft;
|
||||
case AssignmentOperatorType.ShiftRight:
|
||||
return BinaryOperatorType.ShiftRight;
|
||||
case AssignmentOperatorType.BitwiseAnd:
|
||||
return BinaryOperatorType.BitwiseAnd;
|
||||
case AssignmentOperatorType.BitwiseOr:
|
||||
return BinaryOperatorType.BitwiseOr;
|
||||
case AssignmentOperatorType.ExclusiveOr:
|
||||
return BinaryOperatorType.ExclusiveOr;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for AssignmentOperatorType");
|
||||
}
|
||||
}
|
||||
|
||||
public static ExpressionType GetLinqNodeType(AssignmentOperatorType op, bool checkForOverflow)
|
||||
{
|
||||
switch (op) {
|
||||
case AssignmentOperatorType.Assign:
|
||||
return ExpressionType.Assign;
|
||||
case AssignmentOperatorType.Add:
|
||||
return checkForOverflow ? ExpressionType.AddAssignChecked : ExpressionType.AddAssign;
|
||||
case AssignmentOperatorType.Subtract:
|
||||
return checkForOverflow ? ExpressionType.SubtractAssignChecked : ExpressionType.SubtractAssign;
|
||||
case AssignmentOperatorType.Multiply:
|
||||
return checkForOverflow ? ExpressionType.MultiplyAssignChecked : ExpressionType.MultiplyAssign;
|
||||
case AssignmentOperatorType.Divide:
|
||||
return ExpressionType.DivideAssign;
|
||||
case AssignmentOperatorType.Modulus:
|
||||
return ExpressionType.ModuloAssign;
|
||||
case AssignmentOperatorType.ShiftLeft:
|
||||
return ExpressionType.LeftShiftAssign;
|
||||
case AssignmentOperatorType.ShiftRight:
|
||||
return ExpressionType.RightShiftAssign;
|
||||
case AssignmentOperatorType.BitwiseAnd:
|
||||
return ExpressionType.AndAssign;
|
||||
case AssignmentOperatorType.BitwiseOr:
|
||||
return ExpressionType.OrAssign;
|
||||
case AssignmentOperatorType.ExclusiveOr:
|
||||
return ExpressionType.ExclusiveOrAssign;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for AssignmentOperatorType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum AssignmentOperatorType
|
||||
{
|
||||
/// <summary>left = right</summary>
|
||||
Assign,
|
||||
|
||||
/// <summary>left += right</summary>
|
||||
Add,
|
||||
/// <summary>left -= right</summary>
|
||||
Subtract,
|
||||
/// <summary>left *= right</summary>
|
||||
Multiply,
|
||||
/// <summary>left /= right</summary>
|
||||
Divide,
|
||||
/// <summary>left %= right</summary>
|
||||
Modulus,
|
||||
|
||||
/// <summary>left <<= right</summary>
|
||||
ShiftLeft,
|
||||
/// <summary>left >>= right</summary>
|
||||
ShiftRight,
|
||||
|
||||
/// <summary>left &= right</summary>
|
||||
BitwiseAnd,
|
||||
/// <summary>left |= right</summary>
|
||||
BitwiseOr,
|
||||
/// <summary>left ^= right</summary>
|
||||
ExclusiveOr,
|
||||
|
||||
/// <summary>Any operator (for pattern matching)</summary>
|
||||
Any
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
//
|
||||
// BaseReferenceExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// base
|
||||
/// </summary>
|
||||
public class BaseReferenceExpression : Expression
|
||||
{
|
||||
public TextLocation Location {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return Location;
|
||||
}
|
||||
}
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (Location.Line, Location.Column + "base".Length);
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitBaseReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitBaseReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitBaseReferenceExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
BaseReferenceExpression o = other as BaseReferenceExpression;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
//
|
||||
// BinaryOperatorExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Left Operator Right
|
||||
/// </summary>
|
||||
public class BinaryOperatorExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole BitwiseAndRole = new TokenRole ("&");
|
||||
public readonly static TokenRole BitwiseOrRole = new TokenRole ("|");
|
||||
public readonly static TokenRole ConditionalAndRole = new TokenRole ("&&");
|
||||
public readonly static TokenRole ConditionalOrRole = new TokenRole ("||");
|
||||
public readonly static TokenRole ExclusiveOrRole = new TokenRole ("^");
|
||||
public readonly static TokenRole GreaterThanRole = new TokenRole (">");
|
||||
public readonly static TokenRole GreaterThanOrEqualRole = new TokenRole (">=");
|
||||
public readonly static TokenRole EqualityRole = new TokenRole ("==");
|
||||
public readonly static TokenRole InEqualityRole = new TokenRole ("!=");
|
||||
public readonly static TokenRole LessThanRole = new TokenRole ("<");
|
||||
public readonly static TokenRole LessThanOrEqualRole = new TokenRole ("<=");
|
||||
public readonly static TokenRole AddRole = new TokenRole ("+");
|
||||
public readonly static TokenRole SubtractRole = new TokenRole ("-");
|
||||
public readonly static TokenRole MultiplyRole = new TokenRole ("*");
|
||||
public readonly static TokenRole DivideRole = new TokenRole ("/");
|
||||
public readonly static TokenRole ModulusRole = new TokenRole ("%");
|
||||
public readonly static TokenRole ShiftLeftRole = new TokenRole ("<<");
|
||||
public readonly static TokenRole ShiftRightRole = new TokenRole (">>");
|
||||
public readonly static TokenRole NullCoalescingRole = new TokenRole ("??");
|
||||
|
||||
public readonly static Role<Expression> LeftRole = new Role<Expression>("Left", Expression.Null);
|
||||
public readonly static Role<Expression> RightRole = new Role<Expression>("Right", Expression.Null);
|
||||
|
||||
public BinaryOperatorExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right)
|
||||
{
|
||||
this.Left = left;
|
||||
this.Operator = op;
|
||||
this.Right = right;
|
||||
}
|
||||
|
||||
public BinaryOperatorType Operator {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Expression Left {
|
||||
get { return GetChildByRole (LeftRole); }
|
||||
set { SetChildByRole(LeftRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode OperatorToken {
|
||||
get { return GetChildByRole (GetOperatorRole (Operator)); }
|
||||
}
|
||||
|
||||
public Expression Right {
|
||||
get { return GetChildByRole (RightRole); }
|
||||
set { SetChildByRole (RightRole, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitBinaryOperatorExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitBinaryOperatorExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitBinaryOperatorExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
BinaryOperatorExpression o = other as BinaryOperatorExpression;
|
||||
return o != null && (this.Operator == BinaryOperatorType.Any || this.Operator == o.Operator)
|
||||
&& this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match);
|
||||
}
|
||||
|
||||
public static TokenRole GetOperatorRole (BinaryOperatorType op)
|
||||
{
|
||||
switch (op) {
|
||||
case BinaryOperatorType.BitwiseAnd:
|
||||
return BitwiseAndRole;
|
||||
case BinaryOperatorType.BitwiseOr:
|
||||
return BitwiseOrRole;
|
||||
case BinaryOperatorType.ConditionalAnd:
|
||||
return ConditionalAndRole;
|
||||
case BinaryOperatorType.ConditionalOr:
|
||||
return ConditionalOrRole;
|
||||
case BinaryOperatorType.ExclusiveOr:
|
||||
return ExclusiveOrRole;
|
||||
case BinaryOperatorType.GreaterThan:
|
||||
return GreaterThanRole;
|
||||
case BinaryOperatorType.GreaterThanOrEqual:
|
||||
return GreaterThanOrEqualRole;
|
||||
case BinaryOperatorType.Equality:
|
||||
return EqualityRole;
|
||||
case BinaryOperatorType.InEquality:
|
||||
return InEqualityRole;
|
||||
case BinaryOperatorType.LessThan:
|
||||
return LessThanRole;
|
||||
case BinaryOperatorType.LessThanOrEqual:
|
||||
return LessThanOrEqualRole;
|
||||
case BinaryOperatorType.Add:
|
||||
return AddRole;
|
||||
case BinaryOperatorType.Subtract:
|
||||
return SubtractRole;
|
||||
case BinaryOperatorType.Multiply:
|
||||
return MultiplyRole;
|
||||
case BinaryOperatorType.Divide:
|
||||
return DivideRole;
|
||||
case BinaryOperatorType.Modulus:
|
||||
return ModulusRole;
|
||||
case BinaryOperatorType.ShiftLeft:
|
||||
return ShiftLeftRole;
|
||||
case BinaryOperatorType.ShiftRight:
|
||||
return ShiftRightRole;
|
||||
case BinaryOperatorType.NullCoalescing:
|
||||
return NullCoalescingRole;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for BinaryOperatorType");
|
||||
}
|
||||
}
|
||||
|
||||
public static ExpressionType GetLinqNodeType(BinaryOperatorType op, bool checkForOverflow)
|
||||
{
|
||||
switch (op) {
|
||||
case BinaryOperatorType.BitwiseAnd:
|
||||
return ExpressionType.And;
|
||||
case BinaryOperatorType.BitwiseOr:
|
||||
return ExpressionType.Or;
|
||||
case BinaryOperatorType.ConditionalAnd:
|
||||
return ExpressionType.AndAlso;
|
||||
case BinaryOperatorType.ConditionalOr:
|
||||
return ExpressionType.OrElse;
|
||||
case BinaryOperatorType.ExclusiveOr:
|
||||
return ExpressionType.ExclusiveOr;
|
||||
case BinaryOperatorType.GreaterThan:
|
||||
return ExpressionType.GreaterThan;
|
||||
case BinaryOperatorType.GreaterThanOrEqual:
|
||||
return ExpressionType.GreaterThanOrEqual;
|
||||
case BinaryOperatorType.Equality:
|
||||
return ExpressionType.Equal;
|
||||
case BinaryOperatorType.InEquality:
|
||||
return ExpressionType.NotEqual;
|
||||
case BinaryOperatorType.LessThan:
|
||||
return ExpressionType.LessThan;
|
||||
case BinaryOperatorType.LessThanOrEqual:
|
||||
return ExpressionType.LessThanOrEqual;
|
||||
case BinaryOperatorType.Add:
|
||||
return checkForOverflow ? ExpressionType.AddChecked : ExpressionType.Add;
|
||||
case BinaryOperatorType.Subtract:
|
||||
return checkForOverflow ? ExpressionType.SubtractChecked : ExpressionType.Subtract;
|
||||
case BinaryOperatorType.Multiply:
|
||||
return checkForOverflow ? ExpressionType.MultiplyChecked : ExpressionType.Multiply;
|
||||
case BinaryOperatorType.Divide:
|
||||
return ExpressionType.Divide;
|
||||
case BinaryOperatorType.Modulus:
|
||||
return ExpressionType.Modulo;
|
||||
case BinaryOperatorType.ShiftLeft:
|
||||
return ExpressionType.LeftShift;
|
||||
case BinaryOperatorType.ShiftRight:
|
||||
return ExpressionType.RightShift;
|
||||
case BinaryOperatorType.NullCoalescing:
|
||||
return ExpressionType.Coalesce;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for BinaryOperatorType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum BinaryOperatorType
|
||||
{
|
||||
/// <summary>
|
||||
/// Any binary operator (used in pattern matching)
|
||||
/// </summary>
|
||||
Any,
|
||||
|
||||
// We avoid 'logical or' on purpose, because it's not clear if that refers to the bitwise
|
||||
// or to the short-circuiting (conditional) operator:
|
||||
// MCS and old NRefactory used bitwise='|', logical='||'
|
||||
// but the C# spec uses logical='|', conditional='||'
|
||||
/// <summary>left & right</summary>
|
||||
BitwiseAnd,
|
||||
/// <summary>left | right</summary>
|
||||
BitwiseOr,
|
||||
/// <summary>left && right</summary>
|
||||
ConditionalAnd,
|
||||
/// <summary>left || right</summary>
|
||||
ConditionalOr,
|
||||
/// <summary>left ^ right</summary>
|
||||
ExclusiveOr,
|
||||
|
||||
/// <summary>left > right</summary>
|
||||
GreaterThan,
|
||||
/// <summary>left >= right</summary>
|
||||
GreaterThanOrEqual,
|
||||
/// <summary>left == right</summary>
|
||||
Equality,
|
||||
/// <summary>left != right</summary>
|
||||
InEquality,
|
||||
/// <summary>left < right</summary>
|
||||
LessThan,
|
||||
/// <summary>left <= right</summary>
|
||||
LessThanOrEqual,
|
||||
|
||||
/// <summary>left + right</summary>
|
||||
Add,
|
||||
/// <summary>left - right</summary>
|
||||
Subtract,
|
||||
/// <summary>left * right</summary>
|
||||
Multiply,
|
||||
/// <summary>left / right</summary>
|
||||
Divide,
|
||||
/// <summary>left % right</summary>
|
||||
Modulus,
|
||||
|
||||
/// <summary>left << right</summary>
|
||||
ShiftLeft,
|
||||
/// <summary>left >> right</summary>
|
||||
ShiftRight,
|
||||
|
||||
/// <summary>left ?? right</summary>
|
||||
NullCoalescing
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
//
|
||||
// CastExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// (CastTo)Expression
|
||||
/// </summary>
|
||||
public class CastExpression : Expression
|
||||
{
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CastExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public CastExpression (AstType castToType, Expression expression)
|
||||
{
|
||||
AddChild (castToType, Roles.Type);
|
||||
AddChild (expression, Roles.Expression);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitCastExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitCastExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitCastExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
CastExpression o = other as CastExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// CheckedExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// checked(Expression)
|
||||
/// </summary>
|
||||
public class CheckedExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole CheckedKeywordRole = new TokenRole ("checked");
|
||||
|
||||
public CSharpTokenNode CheckedToken {
|
||||
get { return GetChildByRole (CheckedKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole(Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public CheckedExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public CheckedExpression (Expression expression)
|
||||
{
|
||||
AddChild (expression, Roles.Expression);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitCheckedExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitCheckedExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitCheckedExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
CheckedExpression o = other as CheckedExpression;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
//
|
||||
// ConditionalExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition ? TrueExpression : FalseExpression
|
||||
/// </summary>
|
||||
public class ConditionalExpression : Expression
|
||||
{
|
||||
public readonly static Role<Expression> ConditionRole = Roles.Condition;
|
||||
public readonly static TokenRole QuestionMarkRole = new TokenRole("?");
|
||||
public readonly static Role<Expression> TrueRole = new Role<Expression>("True", Expression.Null);
|
||||
public readonly static TokenRole ColonRole = Roles.Colon;
|
||||
public readonly static Role<Expression> FalseRole = new Role<Expression>("False", Expression.Null);
|
||||
|
||||
public Expression Condition {
|
||||
get { return GetChildByRole(ConditionRole); }
|
||||
set { SetChildByRole(ConditionRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode QuestionMarkToken {
|
||||
get { return GetChildByRole (QuestionMarkRole); }
|
||||
}
|
||||
|
||||
public Expression TrueExpression {
|
||||
get { return GetChildByRole(TrueRole); }
|
||||
set { SetChildByRole(TrueRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode ColonToken {
|
||||
get { return GetChildByRole (ColonRole); }
|
||||
}
|
||||
|
||||
public Expression FalseExpression {
|
||||
get { return GetChildByRole(FalseRole); }
|
||||
set { SetChildByRole(FalseRole, value); }
|
||||
}
|
||||
|
||||
public ConditionalExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public ConditionalExpression (Expression condition, Expression trueExpression, Expression falseExpression)
|
||||
{
|
||||
AddChild (condition, ConditionRole);
|
||||
AddChild (trueExpression, TrueRole);
|
||||
AddChild (falseExpression, FalseRole);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitConditionalExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitConditionalExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitConditionalExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ConditionalExpression o = other as ConditionalExpression;
|
||||
return o != null && this.Condition.DoMatch(o.Condition, match) && this.TrueExpression.DoMatch(o.TrueExpression, match) && this.FalseExpression.DoMatch(o.FalseExpression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
//
|
||||
// DefaultValueExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// default(Type)
|
||||
/// </summary>
|
||||
public class DefaultValueExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole DefaultKeywordRole = new TokenRole ("default");
|
||||
|
||||
public CSharpTokenNode DefaultToken {
|
||||
get { return GetChildByRole (DefaultKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public DefaultValueExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultValueExpression (AstType type)
|
||||
{
|
||||
AddChild (type, Roles.Type);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitDefaultValueExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitDefaultValueExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitDefaultValueExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
DefaultValueExpression o = other as DefaultValueExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
//
|
||||
// DirectionExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum FieldDirection
|
||||
{
|
||||
None,
|
||||
Out,
|
||||
Ref
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ref Expression
|
||||
/// </summary>
|
||||
public class DirectionExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole RefKeywordRole = new TokenRole ("ref");
|
||||
public readonly static TokenRole OutKeywordRole = new TokenRole ("out");
|
||||
|
||||
public FieldDirection FieldDirection {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CSharpTokenNode FieldDirectionToken {
|
||||
get { return FieldDirection == ICSharpCode.NRefactory.CSharp.FieldDirection.Ref ? GetChildByRole (RefKeywordRole) : GetChildByRole (OutKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public DirectionExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public DirectionExpression (FieldDirection direction, Expression expression)
|
||||
{
|
||||
this.FieldDirection = direction;
|
||||
AddChild (expression, Roles.Expression);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitDirectionExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitDirectionExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitDirectionExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
DirectionExpression o = other as DirectionExpression;
|
||||
return o != null && this.FieldDirection == o.FieldDirection && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// EmptyExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Type<[EMPTY]>
|
||||
/// </summary>
|
||||
public class EmptyExpression : Expression
|
||||
{
|
||||
TextLocation location;
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
public EmptyExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public EmptyExpression (TextLocation location)
|
||||
{
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitEmptyExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitEmptyExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitEmptyExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as EmptyExpression;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// ErrorExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Xamarin Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class ErrorExpression : Expression
|
||||
{
|
||||
TextLocation location;
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
public ErrorExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public ErrorExpression (TextLocation location)
|
||||
{
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
// nothing
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
// nothing
|
||||
return default(S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as ErrorExpression;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for expressions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is useful even though it doesn't provide any additional functionality:
|
||||
/// It can be used to communicate more information in APIs, e.g. "this subnode will always be an expression"
|
||||
/// </remarks>
|
||||
public abstract class Expression : AstNode
|
||||
{
|
||||
#region Null
|
||||
public new static readonly Expression Null = new NullExpression ();
|
||||
|
||||
sealed class NullExpression : Expression
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PatternPlaceholder
|
||||
public static implicit operator Expression(PatternMatching.Pattern pattern)
|
||||
{
|
||||
return pattern != null ? new PatternPlaceholder(pattern) : null;
|
||||
}
|
||||
|
||||
sealed class PatternPlaceholder : Expression, PatternMatching.INode
|
||||
{
|
||||
readonly PatternMatching.Pattern child;
|
||||
|
||||
public PatternPlaceholder(PatternMatching.Pattern child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Pattern; }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPatternPlaceholder(this, child);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return child.DoMatch(other, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Expression;
|
||||
}
|
||||
}
|
||||
|
||||
public new Expression Clone()
|
||||
{
|
||||
return (Expression)base.Clone();
|
||||
}
|
||||
|
||||
// Make debugging easier by giving Expressions a ToString() implementation
|
||||
public override string ToString()
|
||||
{
|
||||
return DebugToString();
|
||||
}
|
||||
|
||||
public Expression ReplaceWith(Func<Expression, Expression> replaceFunction)
|
||||
{
|
||||
if (replaceFunction == null)
|
||||
throw new ArgumentNullException("replaceFunction");
|
||||
return (Expression)base.ReplaceWith(node => replaceFunction((Expression)node));
|
||||
}
|
||||
|
||||
#region Builder methods
|
||||
/// <summary>
|
||||
/// Builds an member reference expression using this expression as target.
|
||||
/// </summary>
|
||||
public MemberReferenceExpression Member(string memberName)
|
||||
{
|
||||
return new MemberReferenceExpression { Target = this, MemberName = memberName };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an indexer expression using this expression as target.
|
||||
/// </summary>
|
||||
public IndexerExpression Indexer(IEnumerable<Expression> arguments)
|
||||
{
|
||||
IndexerExpression expr = new IndexerExpression();
|
||||
expr.Target = this;
|
||||
expr.Arguments.AddRange(arguments);
|
||||
return expr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an indexer expression using this expression as target.
|
||||
/// </summary>
|
||||
public IndexerExpression Indexer(params Expression[] arguments)
|
||||
{
|
||||
IndexerExpression expr = new IndexerExpression();
|
||||
expr.Target = this;
|
||||
expr.Arguments.AddRange(arguments);
|
||||
return expr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this expression as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(string methodName, IEnumerable<Expression> arguments)
|
||||
{
|
||||
return Invoke(methodName, null, arguments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this expression as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(string methodName, params Expression[] arguments)
|
||||
{
|
||||
return Invoke(methodName, null, arguments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this expression as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(string methodName, IEnumerable<AstType> typeArguments, IEnumerable<Expression> arguments)
|
||||
{
|
||||
InvocationExpression ie = new InvocationExpression();
|
||||
MemberReferenceExpression mre = new MemberReferenceExpression();
|
||||
mre.Target = this;
|
||||
mre.MemberName = methodName;
|
||||
mre.TypeArguments.AddRange(typeArguments);
|
||||
ie.Target = mre;
|
||||
ie.Arguments.AddRange(arguments);
|
||||
return ie;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this expression as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(IEnumerable<Expression> arguments)
|
||||
{
|
||||
InvocationExpression ie = new InvocationExpression();
|
||||
ie.Target = this;
|
||||
ie.Arguments.AddRange(arguments);
|
||||
return ie;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds an invocation expression using this expression as target.
|
||||
/// </summary>
|
||||
public InvocationExpression Invoke(params Expression[] arguments)
|
||||
{
|
||||
InvocationExpression ie = new InvocationExpression();
|
||||
ie.Target = this;
|
||||
ie.Arguments.AddRange(arguments);
|
||||
return ie;
|
||||
}
|
||||
|
||||
public CastExpression CastTo(AstType type)
|
||||
{
|
||||
return new CastExpression { Type = type, Expression = this };
|
||||
}
|
||||
|
||||
public AsExpression CastAs(AstType type)
|
||||
{
|
||||
return new AsExpression { Type = type, Expression = this };
|
||||
}
|
||||
|
||||
public IsExpression IsType(AstType type)
|
||||
{
|
||||
return new IsExpression { Type = type, Expression = this };
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
//
|
||||
// IdentifierExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class IdentifierExpression : Expression
|
||||
{
|
||||
public IdentifierExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public IdentifierExpression(string identifier)
|
||||
{
|
||||
this.Identifier = identifier;
|
||||
}
|
||||
|
||||
public IdentifierExpression(string identifier, TextLocation location)
|
||||
{
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (identifier, location));
|
||||
}
|
||||
|
||||
// public Identifier IdentifierToken {
|
||||
// get { return GetChildByRole (Roles.Identifier); }
|
||||
// }
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier IdentifierToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> TypeArguments {
|
||||
get { return GetChildrenByRole (Roles.TypeArgument); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitIdentifierExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitIdentifierExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitIdentifierExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
IdentifierExpression o = other as IdentifierExpression;
|
||||
return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// IndexerExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Target[Arguments]
|
||||
/// </summary>
|
||||
public class IndexerExpression : Expression
|
||||
{
|
||||
public Expression Target {
|
||||
get { return GetChildByRole (Roles.TargetExpression); }
|
||||
set { SetChildByRole(Roles.TargetExpression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LBracketToken {
|
||||
get { return GetChildByRole (Roles.LBracket); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Arguments {
|
||||
get { return GetChildrenByRole<Expression>(Roles.Argument); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBracketToken {
|
||||
get { return GetChildByRole (Roles.RBracket); }
|
||||
}
|
||||
|
||||
public IndexerExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public IndexerExpression (Expression target, IEnumerable<Expression> arguments)
|
||||
{
|
||||
AddChild (target, Roles.TargetExpression);
|
||||
if (arguments != null) {
|
||||
foreach (var arg in arguments) {
|
||||
AddChild (arg, Roles.Argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IndexerExpression (Expression target, params Expression[] arguments) : this (target, (IEnumerable<Expression>)arguments)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitIndexerExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitIndexerExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitIndexerExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
IndexerExpression o = other as IndexerExpression;
|
||||
return o != null && this.Target.DoMatch(o.Target, match) && this.Arguments.DoMatch(o.Arguments, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// InvocationExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Target(Arguments)
|
||||
/// </summary>
|
||||
public class InvocationExpression : Expression
|
||||
{
|
||||
public Expression Target {
|
||||
get { return GetChildByRole (Roles.TargetExpression); }
|
||||
set { SetChildByRole(Roles.TargetExpression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Arguments {
|
||||
get { return GetChildrenByRole<Expression>(Roles.Argument); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitInvocationExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitInvocationExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitInvocationExpression (this, data);
|
||||
}
|
||||
|
||||
public InvocationExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public InvocationExpression (Expression target, IEnumerable<Expression> arguments)
|
||||
{
|
||||
AddChild (target, Roles.TargetExpression);
|
||||
if (arguments != null) {
|
||||
foreach (var arg in arguments) {
|
||||
AddChild (arg, Roles.Argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InvocationExpression (Expression target, params Expression[] arguments) : this (target, (IEnumerable<Expression>)arguments)
|
||||
{
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
InvocationExpression o = other as InvocationExpression;
|
||||
return o != null && this.Target.DoMatch(o.Target, match) && this.Arguments.DoMatch(o.Arguments, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
//
|
||||
// TypeOfIsExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Expression is Type
|
||||
/// </summary>
|
||||
public class IsExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole IsKeywordRole = new TokenRole ("is");
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole(Roles.Expression); }
|
||||
set { SetChildByRole(Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode IsToken {
|
||||
get { return GetChildByRole (IsKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole(Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitIsExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitIsExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitIsExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
IsExpression o = other as IsExpression;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match) && this.Type.DoMatch(o.Type, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
//
|
||||
// LambdaExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// [async] Parameters => Body
|
||||
/// </summary>
|
||||
public class LambdaExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole AsyncModifierRole = new TokenRole ("async");
|
||||
public readonly static TokenRole ArrowRole = new TokenRole ("=>");
|
||||
public static readonly Role<AstNode> BodyRole = new Role<AstNode>("Body", AstNode.Null);
|
||||
|
||||
bool isAsync;
|
||||
|
||||
public bool IsAsync {
|
||||
get { return isAsync; }
|
||||
set { ThrowIfFrozen(); isAsync = value; }
|
||||
}
|
||||
|
||||
public AstNodeCollection<ParameterDeclaration> Parameters {
|
||||
get { return GetChildrenByRole (Roles.Parameter); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode ArrowToken {
|
||||
get { return GetChildByRole (ArrowRole); }
|
||||
}
|
||||
|
||||
public AstNode Body {
|
||||
get { return GetChildByRole (BodyRole); }
|
||||
set { SetChildByRole (BodyRole, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitLambdaExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitLambdaExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitLambdaExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
LambdaExpression o = other as LambdaExpression;
|
||||
return o != null && this.IsAsync == o.IsAsync && this.Parameters.DoMatch(o.Parameters, match) && this.Body.DoMatch(o.Body, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
//
|
||||
// MemberReferenceExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Target.MemberName
|
||||
/// </summary>
|
||||
public class MemberReferenceExpression : Expression
|
||||
{
|
||||
public Expression Target {
|
||||
get {
|
||||
return GetChildByRole(Roles.TargetExpression);
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.TargetExpression, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode DotToken {
|
||||
get { return GetChildByRole (Roles.Dot); }
|
||||
}
|
||||
|
||||
public string MemberName {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier MemberNameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode LChevronToken {
|
||||
get { return GetChildByRole (Roles.LChevron); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> TypeArguments {
|
||||
get { return GetChildrenByRole (Roles.TypeArgument); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RChevronToken {
|
||||
get { return GetChildByRole (Roles.RChevron); }
|
||||
}
|
||||
|
||||
public MemberReferenceExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public MemberReferenceExpression (Expression target, string memberName, IEnumerable<AstType> arguments = null)
|
||||
{
|
||||
AddChild (target, Roles.TargetExpression);
|
||||
MemberName = memberName;
|
||||
if (arguments != null) {
|
||||
foreach (var arg in arguments) {
|
||||
AddChild (arg, Roles.TypeArgument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MemberReferenceExpression (Expression target, string memberName, params AstType[] arguments) : this (target, memberName, (IEnumerable<AstType>)arguments)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitMemberReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitMemberReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitMemberReferenceExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
MemberReferenceExpression o = other as MemberReferenceExpression;
|
||||
return o != null && this.Target.DoMatch(o.Target, match) && MatchString(this.MemberName, o.MemberName) && this.TypeArguments.DoMatch(o.TypeArguments, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a named argument passed to a method or attribute.
|
||||
/// name: expression
|
||||
/// </summary>
|
||||
public class NamedArgumentExpression : Expression
|
||||
{
|
||||
public NamedArgumentExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public NamedArgumentExpression(string name, Expression expression)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Expression = expression;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier NameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode ColonToken {
|
||||
get { return GetChildByRole (Roles.Colon); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitNamedArgumentExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitNamedArgumentExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitNamedArgumentExpression(this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
NamedArgumentExpression o = other as NamedArgumentExpression;
|
||||
return o != null && MatchString(this.Name, o.Name) && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
//
|
||||
// NamedExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Xamarin
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// name = expression
|
||||
/// This isn't the same as 'assign' even though it has the same syntax.
|
||||
/// This expression is used in object initializers and for named attribute arguments [Attr(FieldName = value)].
|
||||
/// </summary>
|
||||
public class NamedExpression : Expression
|
||||
{
|
||||
public NamedExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public NamedExpression (string name, Expression expression)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Expression = expression;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier NameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode AssignToken {
|
||||
get { return GetChildByRole (Roles.Assign); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitNamedExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitNamedExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitNamedExpression(this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as NamedExpression;
|
||||
return o != null && MatchString(this.Name, o.Name) && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//
|
||||
// NullReferenceExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// null
|
||||
/// </summary>
|
||||
public class NullReferenceExpression : Expression
|
||||
{
|
||||
TextLocation location;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (location.Line, location.Column + "null".Length);
|
||||
}
|
||||
}
|
||||
|
||||
public NullReferenceExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public NullReferenceExpression (TextLocation location)
|
||||
{
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitNullReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitNullReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitNullReferenceExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
NullReferenceExpression o = other as NullReferenceExpression;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
//
|
||||
// ObjectCreateExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// new Type(Arguments) { Initializer }
|
||||
/// </summary>
|
||||
public class ObjectCreateExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole NewKeywordRole = new TokenRole ("new");
|
||||
public readonly static Role<ArrayInitializerExpression> InitializerRole = ArrayCreateExpression.InitializerRole;
|
||||
|
||||
public CSharpTokenNode NewToken {
|
||||
get { return GetChildByRole (NewKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Arguments {
|
||||
get { return GetChildrenByRole (Roles.Argument); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public ArrayInitializerExpression Initializer {
|
||||
get { return GetChildByRole (InitializerRole); }
|
||||
set { SetChildByRole (InitializerRole, value); }
|
||||
}
|
||||
|
||||
public ObjectCreateExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public ObjectCreateExpression (AstType type, IEnumerable<Expression> arguments = null)
|
||||
{
|
||||
AddChild (type, Roles.Type);
|
||||
if (arguments != null) {
|
||||
foreach (var arg in arguments) {
|
||||
AddChild (arg, Roles.Argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectCreateExpression (AstType type, params Expression[] arguments) : this (type, (IEnumerable<Expression>)arguments)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitObjectCreateExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitObjectCreateExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitObjectCreateExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ObjectCreateExpression o = other as ObjectCreateExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.Initializer.DoMatch(o.Initializer, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
//
|
||||
// ParenthesizedExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// ( Expression )
|
||||
/// </summary>
|
||||
public class ParenthesizedExpression : Expression
|
||||
{
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public ParenthesizedExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public ParenthesizedExpression(Expression expr)
|
||||
{
|
||||
Expression = expr;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitParenthesizedExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitParenthesizedExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitParenthesizedExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ParenthesizedExpression o = other as ParenthesizedExpression;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the expression acts like a parenthesized expression,
|
||||
/// i.e. whether information about the expected type (for lambda type inference) flows
|
||||
/// into the inner expression.
|
||||
/// </summary>
|
||||
/// <returns>Returns true for ParenthesizedExpression, CheckedExpression or UncheckedExpression; false otherwise.</returns>
|
||||
public static bool ActsAsParenthesizedExpression(AstNode expression)
|
||||
{
|
||||
return expression is ParenthesizedExpression || expression is CheckedExpression || expression is UncheckedExpression;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpacks the given expression if it is a ParenthesizedExpression, CheckedExpression or UncheckedExpression.
|
||||
/// </summary>
|
||||
public static Expression UnpackParenthesizedExpression(Expression expr)
|
||||
{
|
||||
while (ActsAsParenthesizedExpression(expr))
|
||||
expr = expr.GetChildByRole(Roles.Expression);
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
//
|
||||
// PointerReferenceExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Target->MemberName
|
||||
/// </summary>
|
||||
public class PointerReferenceExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole ArrowRole = new TokenRole ("->");
|
||||
|
||||
public Expression Target {
|
||||
get { return GetChildByRole (Roles.TargetExpression); }
|
||||
set { SetChildByRole(Roles.TargetExpression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode ArrowToken {
|
||||
get { return GetChildByRole (ArrowRole); }
|
||||
}
|
||||
|
||||
public string MemberName {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier MemberNameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> TypeArguments {
|
||||
get { return GetChildrenByRole (Roles.TypeArgument); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPointerReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPointerReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPointerReferenceExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
PointerReferenceExpression o = other as PointerReferenceExpression;
|
||||
return o != null && MatchString(this.MemberName, o.MemberName) && this.TypeArguments.DoMatch(o.TypeArguments, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
//
|
||||
// PrimitiveExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a literal value.
|
||||
/// </summary>
|
||||
public class PrimitiveExpression : Expression
|
||||
{
|
||||
public static readonly object AnyValue = new object();
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
string literalValue;
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (StartLocation.Line, StartLocation.Column + literalValue.Length);
|
||||
}
|
||||
}
|
||||
|
||||
object value;
|
||||
|
||||
public object Value {
|
||||
get { return this.value; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string LiteralValue {
|
||||
get { return literalValue; }
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException();
|
||||
ThrowIfFrozen();
|
||||
literalValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public PrimitiveExpression (object value)
|
||||
{
|
||||
this.Value = value;
|
||||
this.literalValue = "";
|
||||
}
|
||||
|
||||
public PrimitiveExpression (object value, string literalValue)
|
||||
{
|
||||
this.Value = value;
|
||||
this.literalValue = literalValue ?? "";
|
||||
}
|
||||
|
||||
public PrimitiveExpression (object value, TextLocation startLocation, string literalValue)
|
||||
{
|
||||
this.Value = value;
|
||||
this.startLocation = startLocation;
|
||||
this.literalValue = literalValue ?? "";
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPrimitiveExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPrimitiveExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPrimitiveExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
PrimitiveExpression o = other as PrimitiveExpression;
|
||||
return o != null && (this.Value == AnyValue || object.Equals(this.Value, o.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,576 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class QueryExpression : Expression
|
||||
{
|
||||
public static readonly Role<QueryClause> ClauseRole = new Role<QueryClause>("Clause");
|
||||
|
||||
#region Null
|
||||
public new static readonly QueryExpression Null = new NullQueryExpression ();
|
||||
|
||||
sealed class NullQueryExpression : QueryExpression
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public AstNodeCollection<QueryClause> Clauses {
|
||||
get { return GetChildrenByRole(ClauseRole); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryExpression o = other as QueryExpression;
|
||||
return o != null && !o.IsNull && this.Clauses.DoMatch(o.Clauses, match);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class QueryClause : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.QueryClause; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a query continuation.
|
||||
/// "(from .. select ..) into Identifier" or "(from .. group .. by ..) into Identifier"
|
||||
/// Note that "join .. into .." is not a query continuation!
|
||||
///
|
||||
/// This is always the first(!!) clause in a query expression.
|
||||
/// The tree for "from a in b select c into d select e" looks like this:
|
||||
/// new QueryExpression {
|
||||
/// new QueryContinuationClause {
|
||||
/// PrecedingQuery = new QueryExpression {
|
||||
/// new QueryFromClause(a in b),
|
||||
/// new QuerySelectClause(c)
|
||||
/// },
|
||||
/// Identifier = d
|
||||
/// },
|
||||
/// new QuerySelectClause(e)
|
||||
/// }
|
||||
/// </summary>
|
||||
public class QueryContinuationClause : QueryClause
|
||||
{
|
||||
public static readonly Role<QueryExpression> PrecedingQueryRole = new Role<QueryExpression>("PrecedingQuery", QueryExpression.Null);
|
||||
public static readonly TokenRole IntoKeywordRole = new TokenRole ("into");
|
||||
|
||||
public QueryExpression PrecedingQuery {
|
||||
get { return GetChildByRole(PrecedingQueryRole); }
|
||||
set { SetChildByRole(PrecedingQueryRole, value); }
|
||||
}
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier IdentifierToken {
|
||||
get { return GetChildByRole (Roles.Identifier); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryContinuationClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryContinuationClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryContinuationClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryContinuationClause o = other as QueryContinuationClause;
|
||||
return o != null && MatchString(this.Identifier, o.Identifier) && this.PrecedingQuery.DoMatch(o.PrecedingQuery, match);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryFromClause : QueryClause
|
||||
{
|
||||
public static readonly TokenRole FromKeywordRole = new TokenRole ("from");
|
||||
public static readonly TokenRole InKeywordRole = new TokenRole ("in");
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier IdentifierToken {
|
||||
get { return GetChildByRole(Roles.Identifier); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryFromClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryFromClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryFromClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryFromClause o = other as QueryFromClause;
|
||||
return o != null && this.Type.DoMatch(o.Type, match) && MatchString(this.Identifier, o.Identifier)
|
||||
&& this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryLetClause : QueryClause
|
||||
{
|
||||
public readonly static TokenRole LetKeywordRole = new TokenRole ("let");
|
||||
|
||||
public CSharpTokenNode LetKeyword {
|
||||
get { return GetChildByRole(LetKeywordRole); }
|
||||
}
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return GetChildByRole(Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier IdentifierToken {
|
||||
get { return GetChildByRole(Roles.Identifier); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode AssignToken {
|
||||
get { return GetChildByRole(Roles.Assign); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole(Roles.Expression); }
|
||||
set { SetChildByRole(Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryLetClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryLetClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryLetClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryLetClause o = other as QueryLetClause;
|
||||
return o != null && MatchString(this.Identifier, o.Identifier) && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class QueryWhereClause : QueryClause
|
||||
{
|
||||
public readonly static TokenRole WhereKeywordRole = new TokenRole ("where");
|
||||
|
||||
public CSharpTokenNode WhereKeyword {
|
||||
get { return GetChildByRole (WhereKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression Condition {
|
||||
get { return GetChildByRole (Roles.Condition); }
|
||||
set { SetChildByRole (Roles.Condition, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryWhereClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryWhereClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryWhereClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryWhereClause o = other as QueryWhereClause;
|
||||
return o != null && this.Condition.DoMatch(o.Condition, match);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a join or group join clause.
|
||||
/// </summary>
|
||||
public class QueryJoinClause : QueryClause
|
||||
{
|
||||
public static readonly TokenRole JoinKeywordRole = new TokenRole ("join");
|
||||
public static readonly Role<AstType> TypeRole = Roles.Type;
|
||||
public static readonly Role<Identifier> JoinIdentifierRole = Roles.Identifier;
|
||||
public static readonly TokenRole InKeywordRole = new TokenRole ("in");
|
||||
public static readonly Role<Expression> InExpressionRole = Roles.Expression;
|
||||
public static readonly TokenRole OnKeywordRole = new TokenRole ("on");
|
||||
public static readonly Role<Expression> OnExpressionRole = new Role<Expression>("OnExpression", Expression.Null);
|
||||
public static readonly TokenRole EqualsKeywordRole = new TokenRole ("equals");
|
||||
public static readonly Role<Expression> EqualsExpressionRole = new Role<Expression>("EqualsExpression", Expression.Null);
|
||||
public static readonly TokenRole IntoKeywordRole = new TokenRole ("into");
|
||||
public static readonly Role<Identifier> IntoIdentifierRole = new Role<Identifier>("IntoIdentifier", Identifier.Null);
|
||||
|
||||
public bool IsGroupJoin {
|
||||
get { return !string.IsNullOrEmpty(this.IntoIdentifier); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode JoinKeyword {
|
||||
get { return GetChildByRole (JoinKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (TypeRole); }
|
||||
set { SetChildByRole (TypeRole, value); }
|
||||
}
|
||||
|
||||
public string JoinIdentifier {
|
||||
get {
|
||||
return GetChildByRole(JoinIdentifierRole).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(JoinIdentifierRole, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier JoinIdentifierToken {
|
||||
get { return GetChildByRole(JoinIdentifierRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode InKeyword {
|
||||
get { return GetChildByRole (InKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression InExpression {
|
||||
get { return GetChildByRole (InExpressionRole); }
|
||||
set { SetChildByRole (InExpressionRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode OnKeyword {
|
||||
get { return GetChildByRole (OnKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression OnExpression {
|
||||
get { return GetChildByRole (OnExpressionRole); }
|
||||
set { SetChildByRole (OnExpressionRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode EqualsKeyword {
|
||||
get { return GetChildByRole (EqualsKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression EqualsExpression {
|
||||
get { return GetChildByRole (EqualsExpressionRole); }
|
||||
set { SetChildByRole (EqualsExpressionRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode IntoKeyword {
|
||||
get { return GetChildByRole (IntoKeywordRole); }
|
||||
}
|
||||
|
||||
public string IntoIdentifier {
|
||||
get {
|
||||
return GetChildByRole (IntoIdentifierRole).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(IntoIdentifierRole, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier IntoIdentifierToken {
|
||||
get { return GetChildByRole(IntoIdentifierRole); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryJoinClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryJoinClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryJoinClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryJoinClause o = other as QueryJoinClause;
|
||||
return o != null && this.IsGroupJoin == o.IsGroupJoin
|
||||
&& this.Type.DoMatch(o.Type, match) && MatchString(this.JoinIdentifier, o.JoinIdentifier)
|
||||
&& this.InExpression.DoMatch(o.InExpression, match) && this.OnExpression.DoMatch(o.OnExpression, match)
|
||||
&& this.EqualsExpression.DoMatch(o.EqualsExpression, match)
|
||||
&& MatchString(this.IntoIdentifier, o.IntoIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryOrderClause : QueryClause
|
||||
{
|
||||
public static readonly TokenRole OrderbyKeywordRole = new TokenRole ("orderby");
|
||||
public static readonly Role<QueryOrdering> OrderingRole = new Role<QueryOrdering>("Ordering");
|
||||
|
||||
public CSharpTokenNode OrderbyToken {
|
||||
get { return GetChildByRole (OrderbyKeywordRole); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<QueryOrdering> Orderings {
|
||||
get { return GetChildrenByRole (OrderingRole); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryOrderClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryOrderClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryOrderClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryOrderClause o = other as QueryOrderClause;
|
||||
return o != null && this.Orderings.DoMatch(o.Orderings, match);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryOrdering : AstNode
|
||||
{
|
||||
public readonly static TokenRole AscendingKeywordRole = new TokenRole ("ascending");
|
||||
public readonly static TokenRole DescendingKeywordRole = new TokenRole ("descending");
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Unknown; }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public QueryOrderingDirection Direction {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CSharpTokenNode DirectionToken {
|
||||
get { return Direction == QueryOrderingDirection.Ascending ? GetChildByRole (AscendingKeywordRole) : GetChildByRole (DescendingKeywordRole); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryOrdering (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryOrdering (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryOrdering (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryOrdering o = other as QueryOrdering;
|
||||
return o != null && this.Direction == o.Direction && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
|
||||
public enum QueryOrderingDirection
|
||||
{
|
||||
None,
|
||||
Ascending,
|
||||
Descending
|
||||
}
|
||||
|
||||
public class QuerySelectClause : QueryClause
|
||||
{
|
||||
public readonly static TokenRole SelectKeywordRole = new TokenRole ("select");
|
||||
|
||||
public CSharpTokenNode SelectKeyword {
|
||||
get { return GetChildByRole (SelectKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQuerySelectClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQuerySelectClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQuerySelectClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QuerySelectClause o = other as QuerySelectClause;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryGroupClause : QueryClause
|
||||
{
|
||||
public static readonly TokenRole GroupKeywordRole = new TokenRole ("group");
|
||||
public static readonly Role<Expression> ProjectionRole = new Role<Expression>("Projection", Expression.Null);
|
||||
public static readonly TokenRole ByKeywordRole = new TokenRole ("by");
|
||||
public static readonly Role<Expression> KeyRole = new Role<Expression>("Key", Expression.Null);
|
||||
|
||||
public CSharpTokenNode GroupKeyword {
|
||||
get { return GetChildByRole (GroupKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression Projection {
|
||||
get { return GetChildByRole (ProjectionRole); }
|
||||
set { SetChildByRole (ProjectionRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode ByKeyword {
|
||||
get { return GetChildByRole (ByKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression Key {
|
||||
get { return GetChildByRole (KeyRole); }
|
||||
set { SetChildByRole (KeyRole, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitQueryGroupClause (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitQueryGroupClause (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitQueryGroupClause (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
QueryGroupClause o = other as QueryGroupClause;
|
||||
return o != null && this.Projection.DoMatch(o.Projection, match) && this.Key.DoMatch(o.Key, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// SizeOfExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// sizeof(Type)
|
||||
/// </summary>
|
||||
public class SizeOfExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole SizeofKeywordRole = new TokenRole ("sizeof");
|
||||
|
||||
public CSharpTokenNode SizeOfToken {
|
||||
get { return GetChildByRole (SizeofKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public SizeOfExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public SizeOfExpression (AstType type)
|
||||
{
|
||||
AddChild (type, Roles.Type);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitSizeOfExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitSizeOfExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitSizeOfExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
SizeOfExpression o = other as SizeOfExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// StackAllocExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// stackalloc Type[Count]
|
||||
/// </summary>
|
||||
public class StackAllocExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole StackallocKeywordRole = new TokenRole ("stackalloc");
|
||||
|
||||
public CSharpTokenNode StackAllocToken {
|
||||
get { return GetChildByRole (StackallocKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LBracketToken {
|
||||
get { return GetChildByRole (Roles.LBracket); }
|
||||
}
|
||||
|
||||
public Expression CountExpression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBracketToken {
|
||||
get { return GetChildByRole (Roles.RBracket); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitStackAllocExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitStackAllocExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitStackAllocExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
StackAllocExpression o = other as StackAllocExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match) && this.CountExpression.DoMatch(o.CountExpression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
//
|
||||
// ThisReferenceExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// this
|
||||
/// </summary>
|
||||
public class ThisReferenceExpression : Expression
|
||||
{
|
||||
public TextLocation Location {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return Location;
|
||||
}
|
||||
}
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (Location.Line, Location.Column + "this".Length);
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitThisReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitThisReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitThisReferenceExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ThisReferenceExpression o = other as ThisReferenceExpression;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
//
|
||||
// TypeOfExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// typeof(Type)
|
||||
/// </summary>
|
||||
public class TypeOfExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole TypeofKeywordRole = new TokenRole ("typeof");
|
||||
|
||||
public CSharpTokenNode TypeOfToken {
|
||||
get { return GetChildByRole (TypeofKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public TypeOfExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public TypeOfExpression (AstType type)
|
||||
{
|
||||
AddChild (type, Roles.Type);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitTypeOfExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitTypeOfExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitTypeOfExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
TypeOfExpression o = other as TypeOfExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an AstType as an expression.
|
||||
/// This is used when calling a method on a primitive type: "int.Parse()"
|
||||
/// </summary>
|
||||
public class TypeReferenceExpression : Expression
|
||||
{
|
||||
public AstType Type {
|
||||
get { return GetChildByRole(Roles.Type); }
|
||||
set { SetChildByRole(Roles.Type, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitTypeReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitTypeReferenceExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitTypeReferenceExpression(this, data);
|
||||
}
|
||||
|
||||
public TypeReferenceExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public TypeReferenceExpression (AstType type)
|
||||
{
|
||||
AddChild (type, Roles.Type);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
TypeReferenceExpression o = other as TypeReferenceExpression;
|
||||
return o != null && this.Type.DoMatch(o.Type, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
//
|
||||
// UnaryOperatorExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Operator Expression
|
||||
/// </summary>
|
||||
public class UnaryOperatorExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole NotRole = new TokenRole ("!");
|
||||
public readonly static TokenRole BitNotRole = new TokenRole ("~");
|
||||
public readonly static TokenRole MinusRole = new TokenRole ("-");
|
||||
public readonly static TokenRole PlusRole = new TokenRole ("+");
|
||||
public readonly static TokenRole IncrementRole = new TokenRole ("++");
|
||||
public readonly static TokenRole DecrementRole = new TokenRole ("--");
|
||||
public readonly static TokenRole DereferenceRole = new TokenRole ("*");
|
||||
public readonly static TokenRole AddressOfRole = new TokenRole ("&");
|
||||
public readonly static TokenRole AwaitRole = new TokenRole ("await");
|
||||
|
||||
public UnaryOperatorExpression()
|
||||
{
|
||||
}
|
||||
|
||||
public UnaryOperatorExpression(UnaryOperatorType op, Expression expression)
|
||||
{
|
||||
this.Operator = op;
|
||||
this.Expression = expression;
|
||||
}
|
||||
|
||||
public UnaryOperatorType Operator {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CSharpTokenNode OperatorToken {
|
||||
get { return GetChildByRole (GetOperatorRole (Operator)); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitUnaryOperatorExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitUnaryOperatorExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitUnaryOperatorExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
UnaryOperatorExpression o = other as UnaryOperatorExpression;
|
||||
return o != null && (this.Operator == UnaryOperatorType.Any || this.Operator == o.Operator)
|
||||
&& this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
|
||||
public static TokenRole GetOperatorRole(UnaryOperatorType op)
|
||||
{
|
||||
switch (op) {
|
||||
case UnaryOperatorType.Not:
|
||||
return NotRole;
|
||||
case UnaryOperatorType.BitNot:
|
||||
return BitNotRole;
|
||||
case UnaryOperatorType.Minus:
|
||||
return MinusRole;
|
||||
case UnaryOperatorType.Plus:
|
||||
return PlusRole;
|
||||
case UnaryOperatorType.Increment:
|
||||
case UnaryOperatorType.PostIncrement:
|
||||
return IncrementRole;
|
||||
case UnaryOperatorType.PostDecrement:
|
||||
case UnaryOperatorType.Decrement:
|
||||
return DecrementRole;
|
||||
case UnaryOperatorType.Dereference:
|
||||
return DereferenceRole;
|
||||
case UnaryOperatorType.AddressOf:
|
||||
return AddressOfRole;
|
||||
case UnaryOperatorType.Await:
|
||||
return AwaitRole;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for UnaryOperatorType");
|
||||
}
|
||||
}
|
||||
|
||||
public static ExpressionType GetLinqNodeType(UnaryOperatorType op, bool checkForOverflow)
|
||||
{
|
||||
switch (op) {
|
||||
case UnaryOperatorType.Not:
|
||||
return ExpressionType.Not;
|
||||
case UnaryOperatorType.BitNot:
|
||||
return ExpressionType.OnesComplement;
|
||||
case UnaryOperatorType.Minus:
|
||||
return checkForOverflow ? ExpressionType.NegateChecked : ExpressionType.Negate;
|
||||
case UnaryOperatorType.Plus:
|
||||
return ExpressionType.UnaryPlus;
|
||||
case UnaryOperatorType.Increment:
|
||||
return ExpressionType.PreIncrementAssign;
|
||||
case UnaryOperatorType.Decrement:
|
||||
return ExpressionType.PreDecrementAssign;
|
||||
case UnaryOperatorType.PostIncrement:
|
||||
return ExpressionType.PostIncrementAssign;
|
||||
case UnaryOperatorType.PostDecrement:
|
||||
return ExpressionType.PostDecrementAssign;
|
||||
case UnaryOperatorType.Dereference:
|
||||
case UnaryOperatorType.AddressOf:
|
||||
case UnaryOperatorType.Await:
|
||||
return ExpressionType.Extension;
|
||||
default:
|
||||
throw new NotSupportedException("Invalid value for UnaryOperatorType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum UnaryOperatorType
|
||||
{
|
||||
/// <summary>
|
||||
/// Any unary operator (used in pattern matching)
|
||||
/// </summary>
|
||||
Any,
|
||||
|
||||
/// <summary>Logical not (!a)</summary>
|
||||
Not,
|
||||
/// <summary>Bitwise not (~a)</summary>
|
||||
BitNot,
|
||||
/// <summary>Unary minus (-a)</summary>
|
||||
Minus,
|
||||
/// <summary>Unary plus (+a)</summary>
|
||||
Plus,
|
||||
/// <summary>Pre increment (++a)</summary>
|
||||
Increment,
|
||||
/// <summary>Pre decrement (--a)</summary>
|
||||
Decrement,
|
||||
/// <summary>Post increment (a++)</summary>
|
||||
PostIncrement,
|
||||
/// <summary>Post decrement (a--)</summary>
|
||||
PostDecrement,
|
||||
/// <summary>Dereferencing (*a)</summary>
|
||||
Dereference,
|
||||
/// <summary>Get address (&a)</summary>
|
||||
AddressOf,
|
||||
/// <summary>C# 5.0 await</summary>
|
||||
Await
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// UncheckedExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// unchecked(Expression)
|
||||
/// </summary>
|
||||
public class UncheckedExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole UncheckedKeywordRole = new TokenRole ("unchecked");
|
||||
|
||||
public CSharpTokenNode UncheckedToken {
|
||||
get { return GetChildByRole (UncheckedKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole(Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public UncheckedExpression ()
|
||||
{
|
||||
}
|
||||
|
||||
public UncheckedExpression (Expression expression)
|
||||
{
|
||||
AddChild (expression, Roles.Expression);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitUncheckedExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitUncheckedExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitUncheckedExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
UncheckedExpression o = other as UncheckedExpression;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
//
|
||||
// UndocumentedExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum UndocumentedExpressionType
|
||||
{
|
||||
ArgListAccess, // __arglist
|
||||
ArgList, // __arglist (a1, a2, ..., an)
|
||||
RefValue, // __refvalue (expr , type)
|
||||
RefType, // __reftype (expr)
|
||||
MakeRef // __makeref (expr)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents undocumented expressions.
|
||||
/// </summary>
|
||||
public class UndocumentedExpression : Expression
|
||||
{
|
||||
public readonly static TokenRole ArglistKeywordRole = new TokenRole ("__arglist");
|
||||
public readonly static TokenRole RefvalueKeywordRole = new TokenRole ("__refvalue");
|
||||
public readonly static TokenRole ReftypeKeywordRole = new TokenRole ("__reftype");
|
||||
public readonly static TokenRole MakerefKeywordRole = new TokenRole ("__makeref");
|
||||
|
||||
public UndocumentedExpressionType UndocumentedExpressionType {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public CSharpTokenNode UndocumentedToken {
|
||||
get {
|
||||
switch (UndocumentedExpressionType) {
|
||||
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.ArgListAccess:
|
||||
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.ArgList:
|
||||
return GetChildByRole (ArglistKeywordRole);
|
||||
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.RefValue:
|
||||
return GetChildByRole (RefvalueKeywordRole);
|
||||
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.RefType:
|
||||
return GetChildByRole (ReftypeKeywordRole);
|
||||
case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.MakeRef:
|
||||
return GetChildByRole (MakerefKeywordRole);
|
||||
}
|
||||
return CSharpTokenNode.Null;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Arguments {
|
||||
get { return GetChildrenByRole(Roles.Argument); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitUndocumentedExpression (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitUndocumentedExpression (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitUndocumentedExpression (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
UndocumentedExpression o = other as UndocumentedExpression;
|
||||
return o != null && this.UndocumentedExpressionType == o.UndocumentedExpressionType && this.Arguments.DoMatch(o.Arguments, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
//
|
||||
// Attribute.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute(Arguments)
|
||||
/// </summary>
|
||||
public class Attribute : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Expression> Arguments {
|
||||
get { return base.GetChildrenByRole (Roles.Argument); }
|
||||
}
|
||||
|
||||
// HasArgumentList == false: [Empty]
|
||||
public bool HasArgumentList {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitAttribute (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitAttribute (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitAttribute (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
Attribute o = other as Attribute;
|
||||
return o != null && this.Type.DoMatch (o.Type, match) && this.Arguments.DoMatch (o.Arguments, match);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (IsNull)
|
||||
return "Null";
|
||||
else
|
||||
return GetText();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
//
|
||||
// AttributeSection.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// [AttributeTarget: Attributes]
|
||||
/// </summary>
|
||||
public class AttributeSection : AstNode
|
||||
{
|
||||
#region PatternPlaceholder
|
||||
public static implicit operator AttributeSection(PatternMatching.Pattern pattern)
|
||||
{
|
||||
return pattern != null ? new PatternPlaceholder(pattern) : null;
|
||||
}
|
||||
|
||||
sealed class PatternPlaceholder : AttributeSection, PatternMatching.INode
|
||||
{
|
||||
readonly PatternMatching.Pattern child;
|
||||
|
||||
public PatternPlaceholder(PatternMatching.Pattern child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Pattern; }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPatternPlaceholder (this, child);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder (this, child);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return child.DoMatch(other, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode LBracketToken {
|
||||
get { return GetChildByRole (Roles.LBracket); }
|
||||
}
|
||||
|
||||
public string AttributeTarget {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier AttributeTargetToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<Attribute> Attributes {
|
||||
get { return base.GetChildrenByRole (Roles.Attribute); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBracketToken {
|
||||
get { return GetChildByRole (Roles.RBracket); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitAttributeSection (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitAttributeSection (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitAttributeSection (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
AttributeSection o = other as AttributeSection;
|
||||
return o != null && this.AttributeTarget == o.AttributeTarget && this.Attributes.DoMatch(o.Attributes, match);
|
||||
}
|
||||
|
||||
public AttributeSection()
|
||||
{
|
||||
}
|
||||
|
||||
public AttributeSection(Attribute attr)
|
||||
{
|
||||
this.Attributes.Add(attr);
|
||||
}
|
||||
|
||||
// public static string GetAttributeTargetName(AttributeTarget attributeTarget)
|
||||
// {
|
||||
// switch (attributeTarget) {
|
||||
// case AttributeTarget.None:
|
||||
// return null;
|
||||
// case AttributeTarget.Assembly:
|
||||
// return "assembly";
|
||||
// case AttributeTarget.Module:
|
||||
// return "module";
|
||||
// case AttributeTarget.Type:
|
||||
// return "type";
|
||||
// case AttributeTarget.Param:
|
||||
// return "param";
|
||||
// case AttributeTarget.Field:
|
||||
// return "field";
|
||||
// case AttributeTarget.Return:
|
||||
// return "return";
|
||||
// case AttributeTarget.Method:
|
||||
// return "method";
|
||||
// default:
|
||||
// throw new NotSupportedException("Invalid value for AttributeTarget");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public enum AttributeTarget {
|
||||
None,
|
||||
Assembly,
|
||||
Module,
|
||||
|
||||
Type,
|
||||
Param,
|
||||
Field,
|
||||
Return,
|
||||
Method,
|
||||
Unknown
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
//
|
||||
// Comment.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum CommentType
|
||||
{
|
||||
/// <summary>
|
||||
/// "//" comment
|
||||
/// </summary>
|
||||
SingleLine,
|
||||
/// <summary>
|
||||
/// "/* */" comment
|
||||
/// </summary>
|
||||
MultiLine,
|
||||
/// <summary>
|
||||
/// "///" comment
|
||||
/// </summary>
|
||||
Documentation,
|
||||
/// <summary>
|
||||
/// Inactive code (code in non-taken "#if")
|
||||
/// </summary>
|
||||
InactiveCode,
|
||||
/// <summary>
|
||||
/// "/** */" comment
|
||||
/// </summary>
|
||||
MultiLineDocumentation
|
||||
}
|
||||
|
||||
public class Comment : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Whitespace;
|
||||
}
|
||||
}
|
||||
|
||||
CommentType commentType;
|
||||
|
||||
public CommentType CommentType {
|
||||
get { return commentType; }
|
||||
set { ThrowIfFrozen(); commentType = value; }
|
||||
}
|
||||
|
||||
bool startsLine;
|
||||
|
||||
public bool StartsLine {
|
||||
get { return startsLine; }
|
||||
set { ThrowIfFrozen(); startsLine = value; }
|
||||
}
|
||||
|
||||
string content;
|
||||
|
||||
public string Content {
|
||||
get { return content; }
|
||||
set { ThrowIfFrozen(); content = value; }
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
TextLocation endLocation;
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return endLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public Comment (string content, CommentType type = CommentType.SingleLine)
|
||||
{
|
||||
this.CommentType = type;
|
||||
this.Content = content;
|
||||
}
|
||||
|
||||
public Comment (CommentType commentType, TextLocation startLocation, TextLocation endLocation)
|
||||
{
|
||||
this.CommentType = commentType;
|
||||
this.startLocation = startLocation;
|
||||
this.endLocation = endLocation;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitComment (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitComment (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitComment (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
Comment o = other as Comment;
|
||||
return o != null && this.CommentType == o.CommentType && MatchString(this.Content, o.Content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
//
|
||||
// Constraint.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// where TypeParameter : BaseTypes
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// new(), struct and class constraints are represented using a PrimitiveType "new", "struct" or "class"
|
||||
/// </remarks>
|
||||
public class Constraint : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleType TypeParameter {
|
||||
get {
|
||||
return GetChildByRole (Roles.ConstraintTypeParameter);
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.ConstraintTypeParameter, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> BaseTypes {
|
||||
get {
|
||||
return GetChildrenByRole(Roles.BaseType); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitConstraint (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitConstraint (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitConstraint (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
Constraint o = other as Constraint;
|
||||
return o != null && this.TypeParameter.DoMatch (o.TypeParameter, match) && this.BaseTypes.DoMatch(o.BaseTypes, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// DelegateDeclaration.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// delegate ReturnType Name<TypeParameters>(Parameters) where Constraints;
|
||||
/// </summary>
|
||||
public class DelegateDeclaration : EntityDeclaration
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.TypeDeclaration; }
|
||||
}
|
||||
|
||||
public override EntityType EntityType {
|
||||
get { return EntityType.TypeDefinition; }
|
||||
}
|
||||
|
||||
public CSharpTokenNode DelegateToken {
|
||||
get { return GetChildByRole(Roles.DelegateKeyword); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
|
||||
get { return GetChildrenByRole (Roles.TypeParameter); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<ParameterDeclaration> Parameters {
|
||||
get { return GetChildrenByRole (Roles.Parameter); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Constraint> Constraints {
|
||||
get { return GetChildrenByRole (Roles.Constraint); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitDelegateDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitDelegateDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitDelegateDeclaration (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
DelegateDeclaration o = other as DelegateDeclaration;
|
||||
return o != null && MatchString(this.Name, o.Name)
|
||||
&& this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match)
|
||||
&& this.TypeParameters.DoMatch(o.TypeParameters, match) && this.Parameters.DoMatch(o.Parameters, match)
|
||||
&& this.Constraints.DoMatch(o.Constraints, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
//
|
||||
// ExternAliasDeclaration.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// extern alias <Identifier>;
|
||||
/// </summary>
|
||||
public class ExternAliasDeclaration : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode ExternToken {
|
||||
get { return GetChildByRole (Roles.ExternKeyword); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode AliasToken {
|
||||
get { return GetChildByRole (Roles.AliasKeyword); }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier NameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitExternAliasDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitExternAliasDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitExternAliasDeclaration (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as ExternAliasDeclaration;
|
||||
return o != null && MatchString (this.Name, o.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
//
|
||||
// NamespaceDeclaration.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// namespace Name { Members }
|
||||
/// </summary>
|
||||
public class NamespaceDeclaration : AstNode
|
||||
{
|
||||
public static readonly Role<AstNode> MemberRole = SyntaxTree.MemberRole;
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode NamespaceToken {
|
||||
get { return GetChildByRole (Roles.NamespaceKeyword); }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
StringBuilder builder = new StringBuilder ();
|
||||
foreach (Identifier identifier in GetChildrenByRole (Roles.Identifier)) {
|
||||
if (builder.Length > 0)
|
||||
builder.Append ('.');
|
||||
builder.Append (identifier.Name);
|
||||
}
|
||||
return builder.ToString ();
|
||||
}
|
||||
set {
|
||||
GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident)));
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<Identifier> Identifiers {
|
||||
get { return GetChildrenByRole (Roles.Identifier); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the full namespace name (including any parent namespaces)
|
||||
/// </summary>
|
||||
public string FullName {
|
||||
get {
|
||||
NamespaceDeclaration parentNamespace = Parent as NamespaceDeclaration;
|
||||
if (parentNamespace != null)
|
||||
return BuildQualifiedName (parentNamespace.FullName, Name);
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode LBraceToken {
|
||||
get { return GetChildByRole (Roles.LBrace); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstNode> Members {
|
||||
get { return GetChildrenByRole(MemberRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBraceToken {
|
||||
get { return GetChildByRole (Roles.RBrace); }
|
||||
}
|
||||
|
||||
public NamespaceDeclaration ()
|
||||
{
|
||||
}
|
||||
|
||||
public NamespaceDeclaration (string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public static string BuildQualifiedName (string name1, string name2)
|
||||
{
|
||||
if (string.IsNullOrEmpty (name1))
|
||||
return name2;
|
||||
if (string.IsNullOrEmpty (name2))
|
||||
return name1;
|
||||
return name1 + "." + name2;
|
||||
}
|
||||
|
||||
public void AddMember (AstNode child)
|
||||
{
|
||||
AddChild (child, MemberRole);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitNamespaceDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitNamespaceDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitNamespaceDeclaration (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
NamespaceDeclaration o = other as NamespaceDeclaration;
|
||||
return o != null && MatchString(this.Name, o.Name) && this.Members.DoMatch(o.Members, match);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,132 +0,0 @@
|
||||
using System;
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum NewLineType {
|
||||
Unix,
|
||||
Windows,
|
||||
Mac
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A New line node represents a line break in the text.
|
||||
/// </summary>
|
||||
public abstract class NewLineNode : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Whitespace;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract NewLineType NewLineType {
|
||||
get;
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (startLocation.Line + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public NewLineNode() : this (TextLocation.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public NewLineNode(TextLocation startLocation)
|
||||
{
|
||||
this.startLocation = startLocation;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor(IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitNewLine (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitNewLine (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitNewLine (this, data);
|
||||
}
|
||||
}
|
||||
|
||||
public class UnixNewLine : NewLineNode
|
||||
{
|
||||
public override NewLineType NewLineType {
|
||||
get {
|
||||
return NewLineType.Unix;
|
||||
}
|
||||
}
|
||||
|
||||
public UnixNewLine()
|
||||
{
|
||||
}
|
||||
|
||||
public UnixNewLine(TextLocation startLocation) : base (startLocation)
|
||||
{
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as UnixNewLine;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowsNewLine : NewLineNode
|
||||
{
|
||||
public override NewLineType NewLineType {
|
||||
get {
|
||||
return NewLineType.Windows;
|
||||
}
|
||||
}
|
||||
|
||||
public WindowsNewLine()
|
||||
{
|
||||
}
|
||||
|
||||
public WindowsNewLine(TextLocation startLocation) : base (startLocation)
|
||||
{
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as WindowsNewLine;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
|
||||
public class MacNewLine : NewLineNode
|
||||
{
|
||||
public override NewLineType NewLineType {
|
||||
get {
|
||||
return NewLineType.Mac;
|
||||
}
|
||||
}
|
||||
|
||||
public MacNewLine()
|
||||
{
|
||||
}
|
||||
|
||||
public MacNewLine(TextLocation startLocation) : base (startLocation)
|
||||
{
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as MacNewLine;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
//
|
||||
// PreProcessorDirective.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Xamarin Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum PreProcessorDirectiveType : byte
|
||||
{
|
||||
Invalid = 0,
|
||||
Region = 1,
|
||||
Endregion = 2,
|
||||
|
||||
If = 3,
|
||||
Endif = 4,
|
||||
Elif = 5,
|
||||
Else = 6,
|
||||
|
||||
Define = 7,
|
||||
Undef = 8,
|
||||
Error = 9,
|
||||
Warning = 10,
|
||||
Pragma = 11,
|
||||
Line = 12
|
||||
}
|
||||
|
||||
public class PreProcessorDirective : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Whitespace;
|
||||
}
|
||||
}
|
||||
|
||||
public PreProcessorDirectiveType Type {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string Argument {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For an '#if' directive, specifies whether the condition evaluated to true.
|
||||
/// </summary>
|
||||
public bool Take {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
TextLocation endLocation;
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return endLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public PreProcessorDirective(PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation)
|
||||
{
|
||||
this.Type = type;
|
||||
this.startLocation = startLocation;
|
||||
this.endLocation = endLocation;
|
||||
}
|
||||
|
||||
public PreProcessorDirective(PreProcessorDirectiveType type, string argument = null)
|
||||
{
|
||||
this.Type = type;
|
||||
this.Argument = argument;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPreProcessorDirective (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPreProcessorDirective (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPreProcessorDirective (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
PreProcessorDirective o = other as PreProcessorDirective;
|
||||
return o != null && Type == o.Type && MatchString(Argument, o.Argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
//
|
||||
// TextNode.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A text node contains text without syntactic or semantic information.
|
||||
/// (non parseable part of a text)
|
||||
/// </summary>
|
||||
public class TextNode : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Whitespace;
|
||||
}
|
||||
}
|
||||
|
||||
public string Text {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
TextLocation endLocation;
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return endLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public TextNode(string text) : this (text, TextLocation.Empty, TextLocation.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public TextNode(string text, TextLocation startLocation, TextLocation endLocation)
|
||||
{
|
||||
this.Text = text;
|
||||
this.startLocation = startLocation;
|
||||
this.endLocation = endLocation;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor(IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitText (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitText (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitText (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as TextNode;
|
||||
return o != null && o.Text == Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
//
|
||||
// TypeDeclaration.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum ClassType
|
||||
{
|
||||
Class,
|
||||
Struct,
|
||||
Interface,
|
||||
Enum
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// class Name<TypeParameters> : BaseTypes where Constraints;
|
||||
/// </summary>
|
||||
public class TypeDeclaration : EntityDeclaration
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.TypeDeclaration; }
|
||||
}
|
||||
|
||||
public override EntityType EntityType {
|
||||
get { return EntityType.TypeDefinition; }
|
||||
}
|
||||
|
||||
ClassType classType;
|
||||
|
||||
public CSharpTokenNode TypeKeyword {
|
||||
get {
|
||||
switch (classType) {
|
||||
case ClassType.Class:
|
||||
return GetChildByRole(Roles.ClassKeyword);
|
||||
case ClassType.Struct:
|
||||
return GetChildByRole(Roles.StructKeyword);
|
||||
case ClassType.Interface:
|
||||
return GetChildByRole(Roles.InterfaceKeyword);
|
||||
case ClassType.Enum:
|
||||
return GetChildByRole(Roles.EnumKeyword);
|
||||
default:
|
||||
return CSharpTokenNode.Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ClassType ClassType {
|
||||
get { return classType; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
classType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
|
||||
get { return GetChildrenByRole (Roles.TypeParameter); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> BaseTypes {
|
||||
get { return GetChildrenByRole(Roles.BaseType); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Constraint> Constraints {
|
||||
get { return GetChildrenByRole(Roles.Constraint); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LBraceToken {
|
||||
get { return GetChildByRole (Roles.LBrace); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<EntityDeclaration> Members {
|
||||
get { return GetChildrenByRole (Roles.TypeMemberRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBraceToken {
|
||||
get { return GetChildByRole (Roles.RBrace); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitTypeDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitTypeDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitTypeDeclaration (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
TypeDeclaration o = other as TypeDeclaration;
|
||||
return o != null && this.ClassType == o.ClassType && MatchString(this.Name, o.Name)
|
||||
&& this.MatchAttributesAndModifiers(o, match) && this.TypeParameters.DoMatch(o.TypeParameters, match)
|
||||
&& this.BaseTypes.DoMatch(o.BaseTypes, match) && this.Constraints.DoMatch(o.Constraints, match)
|
||||
&& this.Members.DoMatch(o.Members, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// [in|out] Name
|
||||
///
|
||||
/// Represents a type parameter.
|
||||
/// Note: mirroring the C# syntax, constraints are not part of the type parameter declaration, but belong
|
||||
/// to the parent type or method.
|
||||
/// </summary>
|
||||
public class TypeParameterDeclaration : AstNode
|
||||
{
|
||||
public static readonly Role<AttributeSection> AttributeRole = EntityDeclaration.AttributeRole;
|
||||
public static readonly TokenRole OutVarianceKeywordRole = new TokenRole ("out");
|
||||
public static readonly TokenRole InVarianceKeywordRole = new TokenRole ("in");
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Unknown; }
|
||||
}
|
||||
|
||||
public AstNodeCollection<AttributeSection> Attributes {
|
||||
get { return GetChildrenByRole (AttributeRole); }
|
||||
}
|
||||
|
||||
VarianceModifier variance;
|
||||
|
||||
public VarianceModifier Variance {
|
||||
get { return variance; }
|
||||
set { ThrowIfFrozen(); variance = value; }
|
||||
}
|
||||
|
||||
public CSharpTokenNode VarianceToken {
|
||||
get {
|
||||
switch (Variance) {
|
||||
case VarianceModifier.Covariant:
|
||||
return GetChildByRole(OutVarianceKeywordRole);
|
||||
case VarianceModifier.Contravariant:
|
||||
return GetChildByRole(InVarianceKeywordRole);
|
||||
default:
|
||||
return CSharpTokenNode.Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier NameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public TypeParameterDeclaration ()
|
||||
{
|
||||
}
|
||||
|
||||
public TypeParameterDeclaration (string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitTypeParameterDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitTypeParameterDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitTypeParameterDeclaration(this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
TypeParameterDeclaration o = other as TypeParameterDeclaration;
|
||||
return o != null && this.Variance == o.Variance && MatchString(this.Name, o.Name) && this.Attributes.DoMatch(o.Attributes, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
//
|
||||
// UsingAliasDeclaration.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// using Alias = Import;
|
||||
/// </summary>
|
||||
public class UsingAliasDeclaration : AstNode
|
||||
{
|
||||
public static readonly TokenRole UsingKeywordRole = new TokenRole ("using");
|
||||
public static readonly Role<Identifier> AliasRole = new Role<Identifier>("Alias", Identifier.Null);
|
||||
public static readonly Role<AstType> ImportRole = UsingDeclaration.ImportRole;
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode UsingToken {
|
||||
get { return GetChildByRole (UsingKeywordRole); }
|
||||
}
|
||||
|
||||
public string Alias {
|
||||
get {
|
||||
return GetChildByRole (AliasRole).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(AliasRole, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode AssignToken {
|
||||
get { return GetChildByRole (Roles.Assign); }
|
||||
}
|
||||
|
||||
public AstType Import {
|
||||
get { return GetChildByRole (ImportRole); }
|
||||
set { SetChildByRole (ImportRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public UsingAliasDeclaration ()
|
||||
{
|
||||
}
|
||||
|
||||
public UsingAliasDeclaration (string alias, string nameSpace)
|
||||
{
|
||||
AddChild (Identifier.Create (alias), AliasRole);
|
||||
AddChild (new SimpleType (nameSpace), ImportRole);
|
||||
}
|
||||
|
||||
public UsingAliasDeclaration (string alias, AstType import)
|
||||
{
|
||||
AddChild (Identifier.Create (alias), AliasRole);
|
||||
AddChild (import, ImportRole);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitUsingAliasDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitUsingAliasDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitUsingAliasDeclaration (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
UsingAliasDeclaration o = other as UsingAliasDeclaration;
|
||||
return o != null && MatchString(this.Alias, o.Alias) && this.Import.DoMatch(o.Import, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
//
|
||||
// UsingDeclaration.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// using Import;
|
||||
/// </summary>
|
||||
public class UsingDeclaration : AstNode
|
||||
{
|
||||
public static readonly TokenRole UsingKeywordRole = new TokenRole ("using");
|
||||
public static readonly Role<AstType> ImportRole = new Role<AstType>("Import", AstType.Null);
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode UsingToken {
|
||||
get { return GetChildByRole (UsingKeywordRole); }
|
||||
}
|
||||
|
||||
public AstType Import {
|
||||
get { return GetChildByRole (ImportRole); }
|
||||
set { SetChildByRole (ImportRole, value); }
|
||||
}
|
||||
|
||||
public string Namespace {
|
||||
get { return this.Import.ToString(); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public UsingDeclaration ()
|
||||
{
|
||||
}
|
||||
|
||||
public UsingDeclaration (string nameSpace)
|
||||
{
|
||||
AddChild (new SimpleType (nameSpace), ImportRole);
|
||||
}
|
||||
|
||||
public UsingDeclaration (AstType import)
|
||||
{
|
||||
AddChild (import, ImportRole);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitUsingDeclaration (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitUsingDeclaration (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitUsingDeclaration (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
UsingDeclaration o = other as UsingDeclaration;
|
||||
return o != null && this.Import.DoMatch(o.Import, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
//
|
||||
// WhitespaceNode.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin Inc. (http://xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A Whitespace node contains only whitespaces.
|
||||
/// </summary>
|
||||
public class WhitespaceNode : AstNode
|
||||
{
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Whitespace;
|
||||
}
|
||||
}
|
||||
|
||||
public string WhiteSpaceText {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (startLocation.Line, startLocation.Column + WhiteSpaceText.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public WhitespaceNode(string whiteSpaceText) : this (whiteSpaceText, TextLocation.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public WhitespaceNode(string whiteSpaceText, TextLocation startLocation)
|
||||
{
|
||||
this.WhiteSpaceText = WhiteSpaceText;
|
||||
this.startLocation = startLocation;
|
||||
}
|
||||
|
||||
public override void AcceptVisitor(IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitWhitespace (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitWhitespace (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitWhitespace (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
var o = other as WhitespaceNode;
|
||||
return o != null && o.WhiteSpaceText == WhiteSpaceText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,415 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// AST visitor.
|
||||
/// </summary>
|
||||
public interface IAstVisitor
|
||||
{
|
||||
void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
|
||||
void VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
|
||||
void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
|
||||
void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
|
||||
void VisitAsExpression(AsExpression asExpression);
|
||||
void VisitAssignmentExpression(AssignmentExpression assignmentExpression);
|
||||
void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
|
||||
void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
|
||||
void VisitCastExpression(CastExpression castExpression);
|
||||
void VisitCheckedExpression(CheckedExpression checkedExpression);
|
||||
void VisitConditionalExpression(ConditionalExpression conditionalExpression);
|
||||
void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
|
||||
void VisitDirectionExpression(DirectionExpression directionExpression);
|
||||
void VisitIdentifierExpression(IdentifierExpression identifierExpression);
|
||||
void VisitIndexerExpression(IndexerExpression indexerExpression);
|
||||
void VisitInvocationExpression(InvocationExpression invocationExpression);
|
||||
void VisitIsExpression(IsExpression isExpression);
|
||||
void VisitLambdaExpression(LambdaExpression lambdaExpression);
|
||||
void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
|
||||
void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
|
||||
void VisitNamedExpression(NamedExpression namedExpression);
|
||||
void VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
|
||||
void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
|
||||
void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
|
||||
void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
|
||||
void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
|
||||
void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
|
||||
void VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
|
||||
void VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
|
||||
void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
|
||||
void VisitTypeOfExpression(TypeOfExpression typeOfExpression);
|
||||
void VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
|
||||
void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
|
||||
void VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
|
||||
void VisitEmptyExpression (EmptyExpression emptyExpression);
|
||||
|
||||
void VisitQueryExpression(QueryExpression queryExpression);
|
||||
void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
|
||||
void VisitQueryFromClause(QueryFromClause queryFromClause);
|
||||
void VisitQueryLetClause(QueryLetClause queryLetClause);
|
||||
void VisitQueryWhereClause(QueryWhereClause queryWhereClause);
|
||||
void VisitQueryJoinClause(QueryJoinClause queryJoinClause);
|
||||
void VisitQueryOrderClause(QueryOrderClause queryOrderClause);
|
||||
void VisitQueryOrdering(QueryOrdering queryOrdering);
|
||||
void VisitQuerySelectClause(QuerySelectClause querySelectClause);
|
||||
void VisitQueryGroupClause(QueryGroupClause queryGroupClause);
|
||||
|
||||
void VisitAttribute(Attribute attribute);
|
||||
void VisitAttributeSection(AttributeSection attributeSection);
|
||||
void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
|
||||
void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
|
||||
void VisitTypeDeclaration(TypeDeclaration typeDeclaration);
|
||||
void VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
|
||||
void VisitUsingDeclaration(UsingDeclaration usingDeclaration);
|
||||
void VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
|
||||
|
||||
void VisitBlockStatement(BlockStatement blockStatement);
|
||||
void VisitBreakStatement(BreakStatement breakStatement);
|
||||
void VisitCheckedStatement(CheckedStatement checkedStatement);
|
||||
void VisitContinueStatement(ContinueStatement continueStatement);
|
||||
void VisitDoWhileStatement(DoWhileStatement doWhileStatement);
|
||||
void VisitEmptyStatement(EmptyStatement emptyStatement);
|
||||
void VisitExpressionStatement(ExpressionStatement expressionStatement);
|
||||
void VisitFixedStatement(FixedStatement fixedStatement);
|
||||
void VisitForeachStatement(ForeachStatement foreachStatement);
|
||||
void VisitForStatement(ForStatement forStatement);
|
||||
void VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
|
||||
void VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
|
||||
void VisitGotoStatement(GotoStatement gotoStatement);
|
||||
void VisitIfElseStatement(IfElseStatement ifElseStatement);
|
||||
void VisitLabelStatement(LabelStatement labelStatement);
|
||||
void VisitLockStatement(LockStatement lockStatement);
|
||||
void VisitReturnStatement(ReturnStatement returnStatement);
|
||||
void VisitSwitchStatement(SwitchStatement switchStatement);
|
||||
void VisitSwitchSection(SwitchSection switchSection);
|
||||
void VisitCaseLabel(CaseLabel caseLabel);
|
||||
void VisitThrowStatement(ThrowStatement throwStatement);
|
||||
void VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
|
||||
void VisitCatchClause(CatchClause catchClause);
|
||||
void VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
|
||||
void VisitUnsafeStatement(UnsafeStatement unsafeStatement);
|
||||
void VisitUsingStatement(UsingStatement usingStatement);
|
||||
void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
|
||||
void VisitWhileStatement(WhileStatement whileStatement);
|
||||
void VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
|
||||
void VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
|
||||
|
||||
void VisitAccessor(Accessor accessor);
|
||||
void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
|
||||
void VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
|
||||
void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
|
||||
void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
|
||||
void VisitEventDeclaration(EventDeclaration eventDeclaration);
|
||||
void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
|
||||
void VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
|
||||
void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
|
||||
void VisitMethodDeclaration(MethodDeclaration methodDeclaration);
|
||||
void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
|
||||
void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
|
||||
void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
|
||||
void VisitVariableInitializer(VariableInitializer variableInitializer);
|
||||
void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
|
||||
void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
|
||||
|
||||
void VisitSyntaxTree(SyntaxTree syntaxTree);
|
||||
void VisitSimpleType(SimpleType simpleType);
|
||||
void VisitMemberType(MemberType memberType);
|
||||
void VisitComposedType(ComposedType composedType);
|
||||
void VisitArraySpecifier(ArraySpecifier arraySpecifier);
|
||||
void VisitPrimitiveType(PrimitiveType primitiveType);
|
||||
|
||||
void VisitComment(Comment comment);
|
||||
void VisitNewLine(NewLineNode newLineNode);
|
||||
void VisitWhitespace(WhitespaceNode whitespaceNode);
|
||||
void VisitText(TextNode textNode);
|
||||
void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
|
||||
void VisitDocumentationReference(DocumentationReference documentationReference);
|
||||
|
||||
void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
|
||||
void VisitConstraint(Constraint constraint);
|
||||
void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
|
||||
void VisitIdentifier(Identifier identifier);
|
||||
|
||||
void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AST visitor.
|
||||
/// </summary>
|
||||
public interface IAstVisitor<out S>
|
||||
{
|
||||
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression);
|
||||
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression);
|
||||
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression);
|
||||
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression);
|
||||
S VisitAsExpression(AsExpression asExpression);
|
||||
S VisitAssignmentExpression(AssignmentExpression assignmentExpression);
|
||||
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression);
|
||||
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression);
|
||||
S VisitCastExpression(CastExpression castExpression);
|
||||
S VisitCheckedExpression(CheckedExpression checkedExpression);
|
||||
S VisitConditionalExpression(ConditionalExpression conditionalExpression);
|
||||
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression);
|
||||
S VisitDirectionExpression(DirectionExpression directionExpression);
|
||||
S VisitIdentifierExpression(IdentifierExpression identifierExpression);
|
||||
S VisitIndexerExpression(IndexerExpression indexerExpression);
|
||||
S VisitInvocationExpression(InvocationExpression invocationExpression);
|
||||
S VisitIsExpression(IsExpression isExpression);
|
||||
S VisitLambdaExpression(LambdaExpression lambdaExpression);
|
||||
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression);
|
||||
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression);
|
||||
S VisitNamedExpression(NamedExpression namedExpression);
|
||||
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression);
|
||||
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression);
|
||||
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression);
|
||||
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression);
|
||||
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression);
|
||||
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression);
|
||||
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression);
|
||||
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression);
|
||||
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression);
|
||||
S VisitTypeOfExpression(TypeOfExpression typeOfExpression);
|
||||
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression);
|
||||
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression);
|
||||
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression);
|
||||
S VisitEmptyExpression (EmptyExpression emptyExpression);
|
||||
|
||||
S VisitQueryExpression(QueryExpression queryExpression);
|
||||
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause);
|
||||
S VisitQueryFromClause(QueryFromClause queryFromClause);
|
||||
S VisitQueryLetClause(QueryLetClause queryLetClause);
|
||||
S VisitQueryWhereClause(QueryWhereClause queryWhereClause);
|
||||
S VisitQueryJoinClause(QueryJoinClause queryJoinClause);
|
||||
S VisitQueryOrderClause(QueryOrderClause queryOrderClause);
|
||||
S VisitQueryOrdering(QueryOrdering queryOrdering);
|
||||
S VisitQuerySelectClause(QuerySelectClause querySelectClause);
|
||||
S VisitQueryGroupClause(QueryGroupClause queryGroupClause);
|
||||
|
||||
S VisitAttribute(Attribute attribute);
|
||||
S VisitAttributeSection(AttributeSection attributeSection);
|
||||
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration);
|
||||
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration);
|
||||
S VisitTypeDeclaration(TypeDeclaration typeDeclaration);
|
||||
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration);
|
||||
S VisitUsingDeclaration(UsingDeclaration usingDeclaration);
|
||||
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration);
|
||||
|
||||
S VisitBlockStatement(BlockStatement blockStatement);
|
||||
S VisitBreakStatement(BreakStatement breakStatement);
|
||||
S VisitCheckedStatement(CheckedStatement checkedStatement);
|
||||
S VisitContinueStatement(ContinueStatement continueStatement);
|
||||
S VisitDoWhileStatement(DoWhileStatement doWhileStatement);
|
||||
S VisitEmptyStatement(EmptyStatement emptyStatement);
|
||||
S VisitExpressionStatement(ExpressionStatement expressionStatement);
|
||||
S VisitFixedStatement(FixedStatement fixedStatement);
|
||||
S VisitForeachStatement(ForeachStatement foreachStatement);
|
||||
S VisitForStatement(ForStatement forStatement);
|
||||
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement);
|
||||
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement);
|
||||
S VisitGotoStatement(GotoStatement gotoStatement);
|
||||
S VisitIfElseStatement(IfElseStatement ifElseStatement);
|
||||
S VisitLabelStatement(LabelStatement labelStatement);
|
||||
S VisitLockStatement(LockStatement lockStatement);
|
||||
S VisitReturnStatement(ReturnStatement returnStatement);
|
||||
S VisitSwitchStatement(SwitchStatement switchStatement);
|
||||
S VisitSwitchSection(SwitchSection switchSection);
|
||||
S VisitCaseLabel(CaseLabel caseLabel);
|
||||
S VisitThrowStatement(ThrowStatement throwStatement);
|
||||
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement);
|
||||
S VisitCatchClause(CatchClause catchClause);
|
||||
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement);
|
||||
S VisitUnsafeStatement(UnsafeStatement unsafeStatement);
|
||||
S VisitUsingStatement(UsingStatement usingStatement);
|
||||
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement);
|
||||
S VisitWhileStatement(WhileStatement whileStatement);
|
||||
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement);
|
||||
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement);
|
||||
|
||||
S VisitAccessor(Accessor accessor);
|
||||
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration);
|
||||
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer);
|
||||
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration);
|
||||
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration);
|
||||
S VisitEventDeclaration(EventDeclaration eventDeclaration);
|
||||
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration);
|
||||
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration);
|
||||
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration);
|
||||
S VisitMethodDeclaration(MethodDeclaration methodDeclaration);
|
||||
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration);
|
||||
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration);
|
||||
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration);
|
||||
S VisitVariableInitializer(VariableInitializer variableInitializer);
|
||||
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration);
|
||||
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer);
|
||||
|
||||
S VisitSyntaxTree(SyntaxTree syntaxTree);
|
||||
S VisitSimpleType(SimpleType simpleType);
|
||||
S VisitMemberType(MemberType memberType);
|
||||
S VisitComposedType(ComposedType composedType);
|
||||
S VisitArraySpecifier(ArraySpecifier arraySpecifier);
|
||||
S VisitPrimitiveType(PrimitiveType primitiveType);
|
||||
|
||||
S VisitComment(Comment comment);
|
||||
S VisitWhitespace(WhitespaceNode whitespaceNode);
|
||||
S VisitText(TextNode textNode);
|
||||
S VisitNewLine(NewLineNode newLineNode);
|
||||
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective);
|
||||
S VisitDocumentationReference(DocumentationReference documentationReference);
|
||||
|
||||
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration);
|
||||
S VisitConstraint(Constraint constraint);
|
||||
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode);
|
||||
S VisitIdentifier(Identifier identifier);
|
||||
|
||||
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AST visitor.
|
||||
/// </summary>
|
||||
public interface IAstVisitor<in T, out S>
|
||||
{
|
||||
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data);
|
||||
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data);
|
||||
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data);
|
||||
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data);
|
||||
S VisitAsExpression(AsExpression asExpression, T data);
|
||||
S VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data);
|
||||
S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, T data);
|
||||
S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data);
|
||||
S VisitCastExpression(CastExpression castExpression, T data);
|
||||
S VisitCheckedExpression(CheckedExpression checkedExpression, T data);
|
||||
S VisitConditionalExpression(ConditionalExpression conditionalExpression, T data);
|
||||
S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, T data);
|
||||
S VisitDirectionExpression(DirectionExpression directionExpression, T data);
|
||||
S VisitIdentifierExpression(IdentifierExpression identifierExpression, T data);
|
||||
S VisitIndexerExpression(IndexerExpression indexerExpression, T data);
|
||||
S VisitInvocationExpression(InvocationExpression invocationExpression, T data);
|
||||
S VisitIsExpression(IsExpression isExpression, T data);
|
||||
S VisitLambdaExpression(LambdaExpression lambdaExpression, T data);
|
||||
S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, T data);
|
||||
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data);
|
||||
S VisitNamedExpression(NamedExpression namedExpression, T data);
|
||||
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data);
|
||||
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data);
|
||||
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
|
||||
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
|
||||
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);
|
||||
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data);
|
||||
S VisitSizeOfExpression(SizeOfExpression sizeOfExpression, T data);
|
||||
S VisitStackAllocExpression(StackAllocExpression stackAllocExpression, T data);
|
||||
S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, T data);
|
||||
S VisitTypeOfExpression(TypeOfExpression typeOfExpression, T data);
|
||||
S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data);
|
||||
S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data);
|
||||
S VisitUncheckedExpression(UncheckedExpression uncheckedExpression, T data);
|
||||
S VisitEmptyExpression (EmptyExpression emptyExpression, T data);
|
||||
|
||||
S VisitQueryExpression(QueryExpression queryExpression, T data);
|
||||
S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, T data);
|
||||
S VisitQueryFromClause(QueryFromClause queryFromClause, T data);
|
||||
S VisitQueryLetClause(QueryLetClause queryLetClause, T data);
|
||||
S VisitQueryWhereClause(QueryWhereClause queryWhereClause, T data);
|
||||
S VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data);
|
||||
S VisitQueryOrderClause(QueryOrderClause queryOrderClause, T data);
|
||||
S VisitQueryOrdering(QueryOrdering queryOrdering, T data);
|
||||
S VisitQuerySelectClause(QuerySelectClause querySelectClause, T data);
|
||||
S VisitQueryGroupClause(QueryGroupClause queryGroupClause, T data);
|
||||
|
||||
S VisitAttribute(Attribute attribute, T data);
|
||||
S VisitAttributeSection(AttributeSection attributeSection, T data);
|
||||
S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data);
|
||||
S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data);
|
||||
S VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data);
|
||||
S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, T data);
|
||||
S VisitUsingDeclaration(UsingDeclaration usingDeclaration, T data);
|
||||
S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, T data);
|
||||
|
||||
S VisitBlockStatement(BlockStatement blockStatement, T data);
|
||||
S VisitBreakStatement(BreakStatement breakStatement, T data);
|
||||
S VisitCheckedStatement(CheckedStatement checkedStatement, T data);
|
||||
S VisitContinueStatement(ContinueStatement continueStatement, T data);
|
||||
S VisitDoWhileStatement(DoWhileStatement doWhileStatement, T data);
|
||||
S VisitEmptyStatement(EmptyStatement emptyStatement, T data);
|
||||
S VisitExpressionStatement(ExpressionStatement expressionStatement, T data);
|
||||
S VisitFixedStatement(FixedStatement fixedStatement, T data);
|
||||
S VisitForeachStatement(ForeachStatement foreachStatement, T data);
|
||||
S VisitForStatement(ForStatement forStatement, T data);
|
||||
S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, T data);
|
||||
S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, T data);
|
||||
S VisitGotoStatement(GotoStatement gotoStatement, T data);
|
||||
S VisitIfElseStatement(IfElseStatement ifElseStatement, T data);
|
||||
S VisitLabelStatement(LabelStatement labelStatement, T data);
|
||||
S VisitLockStatement(LockStatement lockStatement, T data);
|
||||
S VisitReturnStatement(ReturnStatement returnStatement, T data);
|
||||
S VisitSwitchStatement(SwitchStatement switchStatement, T data);
|
||||
S VisitSwitchSection(SwitchSection switchSection, T data);
|
||||
S VisitCaseLabel(CaseLabel caseLabel, T data);
|
||||
S VisitThrowStatement(ThrowStatement throwStatement, T data);
|
||||
S VisitTryCatchStatement(TryCatchStatement tryCatchStatement, T data);
|
||||
S VisitCatchClause(CatchClause catchClause, T data);
|
||||
S VisitUncheckedStatement(UncheckedStatement uncheckedStatement, T data);
|
||||
S VisitUnsafeStatement(UnsafeStatement unsafeStatement, T data);
|
||||
S VisitUsingStatement(UsingStatement usingStatement, T data);
|
||||
S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, T data);
|
||||
S VisitWhileStatement(WhileStatement whileStatement, T data);
|
||||
S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, T data);
|
||||
S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement, T data);
|
||||
|
||||
S VisitAccessor(Accessor accessor, T data);
|
||||
S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data);
|
||||
S VisitConstructorInitializer(ConstructorInitializer constructorInitializer, T data);
|
||||
S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, T data);
|
||||
S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data);
|
||||
S VisitEventDeclaration(EventDeclaration eventDeclaration, T data);
|
||||
S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration, T data);
|
||||
S VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data);
|
||||
S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, T data);
|
||||
S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data);
|
||||
S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data);
|
||||
S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data);
|
||||
S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data);
|
||||
S VisitVariableInitializer(VariableInitializer variableInitializer, T data);
|
||||
S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data);
|
||||
S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data);
|
||||
|
||||
S VisitSyntaxTree(SyntaxTree syntaxTree, T data);
|
||||
S VisitSimpleType(SimpleType simpleType, T data);
|
||||
S VisitMemberType(MemberType memberType, T data);
|
||||
S VisitComposedType(ComposedType composedType, T data);
|
||||
S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data);
|
||||
S VisitPrimitiveType(PrimitiveType primitiveType, T data);
|
||||
|
||||
S VisitComment(Comment comment, T data);
|
||||
S VisitNewLine(NewLineNode newLineNode, T data);
|
||||
S VisitWhitespace(WhitespaceNode whitespaceNode, T data);
|
||||
S VisitText(TextNode textNode, T data);
|
||||
S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data);
|
||||
S VisitDocumentationReference(DocumentationReference documentationReference, T data);
|
||||
|
||||
S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data);
|
||||
S VisitConstraint(Constraint constraint, T data);
|
||||
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, T data);
|
||||
S VisitIdentifier(Identifier identifier, T data);
|
||||
|
||||
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
//
|
||||
// Identifier.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class Identifier : AstNode
|
||||
{
|
||||
public new static readonly Identifier Null = new NullIdentifier ();
|
||||
sealed class NullIdentifier : Identifier
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get {
|
||||
return NodeType.Token;
|
||||
}
|
||||
}
|
||||
|
||||
string name;
|
||||
public string Name {
|
||||
get { return this.name; }
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
ThrowIfFrozen();
|
||||
this.name = value;
|
||||
}
|
||||
}
|
||||
|
||||
TextLocation startLocation;
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
const uint verbatimBit = 1u << AstNodeFlagsUsedBits;
|
||||
|
||||
public bool IsVerbatim {
|
||||
get {
|
||||
return (flags & verbatimBit) != 0;
|
||||
}
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
if (value)
|
||||
flags |= verbatimBit;
|
||||
else
|
||||
flags &= ~verbatimBit;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + (IsVerbatim ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
Identifier ()
|
||||
{
|
||||
this.name = string.Empty;
|
||||
}
|
||||
|
||||
protected Identifier (string name, TextLocation location)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException("name");
|
||||
this.Name = name;
|
||||
this.startLocation = location;
|
||||
}
|
||||
|
||||
public static Identifier Create (string name)
|
||||
{
|
||||
return Create (name, TextLocation.Empty);
|
||||
}
|
||||
|
||||
public static Identifier Create (string name, TextLocation location)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return Identifier.Null;
|
||||
if (name[0] == '@')
|
||||
return new Identifier (name.Substring (1), location) { IsVerbatim = true };
|
||||
else
|
||||
return new Identifier (name, location);
|
||||
}
|
||||
|
||||
public static Identifier Create (string name, TextLocation location, bool isVerbatim)
|
||||
{
|
||||
if (string.IsNullOrEmpty (name))
|
||||
return Identifier.Null;
|
||||
|
||||
if (isVerbatim)
|
||||
return new Identifier (name, location) { IsVerbatim = true };
|
||||
return new Identifier (name, location);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitIdentifier (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitIdentifier (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitIdentifier (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
Identifier o = other as Identifier;
|
||||
return o != null && !o.IsNull && MatchString(this.Name, o.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using ICSharpCode.NRefactory.PatternMatching;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Matches identifier expressions that have the same identifier as the referenced variable/type definition/method definition.
|
||||
/// </summary>
|
||||
public class IdentifierExpressionBackreference : Pattern
|
||||
{
|
||||
readonly string referencedGroupName;
|
||||
|
||||
public string ReferencedGroupName {
|
||||
get { return referencedGroupName; }
|
||||
}
|
||||
|
||||
public IdentifierExpressionBackreference(string referencedGroupName)
|
||||
{
|
||||
if (referencedGroupName == null)
|
||||
throw new ArgumentNullException("referencedGroupName");
|
||||
this.referencedGroupName = referencedGroupName;
|
||||
}
|
||||
|
||||
public override bool DoMatch(INode other, Match match)
|
||||
{
|
||||
CSharp.IdentifierExpression ident = other as CSharp.IdentifierExpression;
|
||||
if (ident == null || ident.TypeArguments.Any())
|
||||
return false;
|
||||
CSharp.AstNode referenced = (CSharp.AstNode)match.Get(referencedGroupName).Last();
|
||||
if (referenced == null)
|
||||
return false;
|
||||
return ident.Identifier == referenced.GetChildByRole(CSharp.Roles.Identifier).Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
//
|
||||
// FullTypeName.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ICSharpCode.NRefactory.CSharp.TypeSystem;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class MemberType : AstType
|
||||
{
|
||||
public static readonly Role<AstType> TargetRole = new Role<AstType>("Target", AstType.Null);
|
||||
|
||||
bool isDoubleColon;
|
||||
|
||||
public bool IsDoubleColon {
|
||||
get { return isDoubleColon; }
|
||||
set {
|
||||
ThrowIfFrozen();
|
||||
isDoubleColon = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AstType Target {
|
||||
get { return GetChildByRole(TargetRole); }
|
||||
set { SetChildByRole(TargetRole, value); }
|
||||
}
|
||||
|
||||
public string MemberName {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier MemberNameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> TypeArguments {
|
||||
get { return GetChildrenByRole (Roles.TypeArgument); }
|
||||
}
|
||||
|
||||
public MemberType ()
|
||||
{
|
||||
}
|
||||
|
||||
public MemberType (AstType target, string memberName)
|
||||
{
|
||||
this.Target = target;
|
||||
this.MemberName = memberName;
|
||||
}
|
||||
|
||||
public MemberType (AstType target, string memberName, IEnumerable<AstType> typeArguments)
|
||||
{
|
||||
this.Target = target;
|
||||
this.MemberName = memberName;
|
||||
foreach (var arg in typeArguments) {
|
||||
AddChild (arg, Roles.TypeArgument);
|
||||
}
|
||||
}
|
||||
|
||||
public MemberType (AstType target, string memberName, params AstType[] typeArguments) : this (target, memberName, (IEnumerable<AstType>)typeArguments)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitMemberType (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitMemberType (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitMemberType (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
MemberType o = other as MemberType;
|
||||
return o != null && this.IsDoubleColon == o.IsDoubleColon && MatchString(this.MemberName, o.MemberName) && this.Target.DoMatch(o.Target, match);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.Append(this.Target);
|
||||
if (IsDoubleColon)
|
||||
b.Append("::");
|
||||
else
|
||||
b.Append('.');
|
||||
b.Append(this.MemberName);
|
||||
if (this.TypeArguments.Any()) {
|
||||
b.Append('<');
|
||||
b.Append(string.Join(", ", this.TypeArguments));
|
||||
b.Append('>');
|
||||
}
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type)
|
||||
{
|
||||
TypeOrNamespaceReference t;
|
||||
if (this.IsDoubleColon) {
|
||||
SimpleType st = this.Target as SimpleType;
|
||||
if (st != null) {
|
||||
t = new AliasNamespaceReference(st.Identifier);
|
||||
} else {
|
||||
t = null;
|
||||
}
|
||||
} else {
|
||||
t = this.Target.ToTypeReference(lookupMode) as TypeOrNamespaceReference;
|
||||
}
|
||||
if (t == null)
|
||||
return SpecialType.UnknownType;
|
||||
var typeArguments = new List<ITypeReference>();
|
||||
foreach (var ta in this.TypeArguments) {
|
||||
typeArguments.Add(ta.ToTypeReference(lookupMode));
|
||||
}
|
||||
return new MemberTypeOrNamespaceReference(t, this.MemberName, typeArguments, lookupMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
//
|
||||
// Modifiers.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
[Flags]
|
||||
public enum Modifiers
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Private = 0x0001,
|
||||
Internal = 0x0002,
|
||||
Protected = 0x0004,
|
||||
Public = 0x0008,
|
||||
|
||||
Abstract = 0x0010,
|
||||
Virtual = 0x0020,
|
||||
Sealed = 0x0040,
|
||||
Static = 0x0080,
|
||||
Override = 0x0100,
|
||||
Readonly = 0x0200,
|
||||
Const = 0x0400,
|
||||
New = 0x0800,
|
||||
Partial = 0x1000,
|
||||
|
||||
Extern = 0x2000,
|
||||
Volatile = 0x4000,
|
||||
Unsafe = 0x8000,
|
||||
Async = 0x10000,
|
||||
|
||||
VisibilityMask = Private | Internal | Protected | Public,
|
||||
|
||||
/// <summary>
|
||||
/// Special value used to match any modifiers during pattern matching.
|
||||
/// </summary>
|
||||
Any = unchecked((int)0x80000000)
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// NodeType.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public enum NodeType
|
||||
{
|
||||
Unknown,
|
||||
/// <summary>
|
||||
/// AstType
|
||||
/// </summary>
|
||||
TypeReference,
|
||||
/// <summary>
|
||||
/// Type or delegate declaration
|
||||
/// </summary>
|
||||
TypeDeclaration,
|
||||
Member,
|
||||
Statement,
|
||||
Expression,
|
||||
Token,
|
||||
QueryClause,
|
||||
/// <summary>
|
||||
/// Comment or whitespace or pre-processor directive
|
||||
/// </summary>
|
||||
Whitespace,
|
||||
/// <summary>
|
||||
/// Placeholder for a pattern
|
||||
/// </summary>
|
||||
Pattern
|
||||
}
|
||||
}
|
||||
@@ -1,856 +0,0 @@
|
||||
//
|
||||
// ObservableAstVisitor.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class ObservableAstVisitor : IAstVisitor
|
||||
{
|
||||
void Visit<T>(Action<T> enter, Action<T> leave, T node) where T : AstNode
|
||||
{
|
||||
if (enter != null)
|
||||
enter(node);
|
||||
AstNode next;
|
||||
for (var child = node.FirstChild; child != null; child = next) {
|
||||
// Store next to allow the loop to continue
|
||||
// if the visitor removes/replaces children.
|
||||
next = child.NextSibling;
|
||||
child.AcceptVisitor (this);
|
||||
}
|
||||
if (leave != null)
|
||||
leave(node);
|
||||
}
|
||||
|
||||
public event Action<SyntaxTree> EnterSyntaxTree, LeaveSyntaxTree;
|
||||
|
||||
void IAstVisitor.VisitSyntaxTree(SyntaxTree unit)
|
||||
{
|
||||
Visit(EnterSyntaxTree, LeaveSyntaxTree, unit);
|
||||
}
|
||||
|
||||
public event Action<Comment> EnterComment, LeaveComment;
|
||||
|
||||
void IAstVisitor.VisitComment(Comment comment)
|
||||
{
|
||||
Visit(EnterComment, LeaveComment, comment);
|
||||
}
|
||||
|
||||
public event Action<NewLineNode> EnterNewLine, LeaveNewLine;
|
||||
|
||||
void IAstVisitor.VisitNewLine(NewLineNode newLineNode)
|
||||
{
|
||||
Visit(EnterNewLine, LeaveNewLine, newLineNode);
|
||||
}
|
||||
|
||||
public event Action<WhitespaceNode> EnterWhitespace, LeaveWhitespace;
|
||||
|
||||
void IAstVisitor.VisitWhitespace(WhitespaceNode whitespace)
|
||||
{
|
||||
Visit(EnterWhitespace, LeaveWhitespace, whitespace);
|
||||
}
|
||||
|
||||
public event Action<TextNode> EnterText, LeaveText;
|
||||
|
||||
void IAstVisitor.VisitText(TextNode textNode)
|
||||
{
|
||||
Visit(EnterText, LeaveText, textNode);
|
||||
}
|
||||
|
||||
public event Action<PreProcessorDirective> EnterPreProcessorDirective, LeavePreProcessorDirective;
|
||||
void IAstVisitor.VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective)
|
||||
{
|
||||
Visit(EnterPreProcessorDirective, LeavePreProcessorDirective, preProcessorDirective);
|
||||
}
|
||||
|
||||
public event Action<DocumentationReference> EnterDocumentationReference, LeaveDocumentationReference;
|
||||
|
||||
void IAstVisitor.VisitDocumentationReference(DocumentationReference documentationReference)
|
||||
{
|
||||
Visit(EnterDocumentationReference, LeaveDocumentationReference, documentationReference);
|
||||
}
|
||||
|
||||
public event Action<Identifier> EnterIdentifier, LeaveIdentifier;
|
||||
|
||||
void IAstVisitor.VisitIdentifier(Identifier identifier)
|
||||
{
|
||||
Visit(EnterIdentifier, LeaveIdentifier, identifier);
|
||||
}
|
||||
|
||||
public event Action<CSharpTokenNode> EnterCSharpTokenNode, LeaveCSharpTokenNode;
|
||||
|
||||
void IAstVisitor.VisitCSharpTokenNode(CSharpTokenNode token)
|
||||
{
|
||||
Visit(EnterCSharpTokenNode, LeaveCSharpTokenNode, token);
|
||||
}
|
||||
|
||||
public event Action<PrimitiveType> EnterPrimitiveType, LeavePrimitiveType;
|
||||
|
||||
void IAstVisitor.VisitPrimitiveType(PrimitiveType primitiveType)
|
||||
{
|
||||
Visit(EnterPrimitiveType, LeavePrimitiveType, primitiveType);
|
||||
}
|
||||
|
||||
public event Action<ComposedType> EnterComposedType, LeaveComposedType;
|
||||
|
||||
void IAstVisitor.VisitComposedType(ComposedType composedType)
|
||||
{
|
||||
Visit(EnterComposedType, LeaveComposedType, composedType);
|
||||
}
|
||||
|
||||
public event Action<SimpleType> EnterSimpleType, LeaveSimpleType;
|
||||
|
||||
void IAstVisitor.VisitSimpleType(SimpleType simpleType)
|
||||
{
|
||||
Visit(EnterSimpleType, LeaveSimpleType, simpleType);
|
||||
}
|
||||
|
||||
public event Action<MemberType> EnterMemberType, LeaveMemberType;
|
||||
|
||||
void IAstVisitor.VisitMemberType(MemberType memberType)
|
||||
{
|
||||
Visit(EnterMemberType, LeaveMemberType, memberType);
|
||||
}
|
||||
|
||||
public event Action<Attribute> EnterAttribute, LeaveAttribute;
|
||||
|
||||
void IAstVisitor.VisitAttribute(Attribute attribute)
|
||||
{
|
||||
Visit(EnterAttribute, LeaveAttribute, attribute);
|
||||
}
|
||||
|
||||
public event Action<AttributeSection> EnterAttributeSection, LeaveAttributeSection;
|
||||
|
||||
void IAstVisitor.VisitAttributeSection(AttributeSection attributeSection)
|
||||
{
|
||||
Visit(EnterAttributeSection, LeaveAttributeSection, attributeSection);
|
||||
}
|
||||
|
||||
public event Action<DelegateDeclaration> EnterDelegateDeclaration, LeaveDelegateDeclaration;
|
||||
|
||||
void IAstVisitor.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration)
|
||||
{
|
||||
Visit(EnterDelegateDeclaration, LeaveDelegateDeclaration, delegateDeclaration);
|
||||
}
|
||||
|
||||
public event Action<NamespaceDeclaration> EnterNamespaceDeclaration, LeaveNamespaceDeclaration;
|
||||
|
||||
void IAstVisitor.VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
|
||||
{
|
||||
Visit(EnterNamespaceDeclaration, LeaveNamespaceDeclaration, namespaceDeclaration);
|
||||
}
|
||||
|
||||
public event Action<TypeDeclaration> EnterTypeDeclaration, LeaveTypeDeclaration;
|
||||
|
||||
void IAstVisitor.VisitTypeDeclaration(TypeDeclaration typeDeclaration)
|
||||
{
|
||||
Visit(EnterTypeDeclaration, LeaveTypeDeclaration, typeDeclaration);
|
||||
}
|
||||
|
||||
public event Action<TypeParameterDeclaration> EnterTypeParameterDeclaration, LeaveTypeParameterDeclaration;
|
||||
|
||||
void IAstVisitor.VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration)
|
||||
{
|
||||
Visit(EnterTypeParameterDeclaration, LeaveTypeParameterDeclaration, typeParameterDeclaration);
|
||||
}
|
||||
|
||||
public event Action<EnumMemberDeclaration> EnterEnumMemberDeclaration, LeaveEnumMemberDeclaration;
|
||||
|
||||
void IAstVisitor.VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
|
||||
{
|
||||
Visit(EnterEnumMemberDeclaration, LeaveEnumMemberDeclaration, enumMemberDeclaration);
|
||||
}
|
||||
|
||||
public event Action<UsingDeclaration> EnterUsingDeclaration, LeaveUsingDeclaration;
|
||||
|
||||
void IAstVisitor.VisitUsingDeclaration(UsingDeclaration usingDeclaration)
|
||||
{
|
||||
Visit(EnterUsingDeclaration, LeaveUsingDeclaration, usingDeclaration);
|
||||
}
|
||||
|
||||
public event Action<UsingAliasDeclaration> EnterUsingAliasDeclaration, LeaveUsingAliasDeclaration;
|
||||
|
||||
void IAstVisitor.VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration)
|
||||
{
|
||||
Visit(EnterUsingAliasDeclaration, LeaveUsingAliasDeclaration, usingDeclaration);
|
||||
}
|
||||
|
||||
public event Action<ExternAliasDeclaration> EnterExternAliasDeclaration, LeaveExternAliasDeclaration;
|
||||
|
||||
void IAstVisitor.VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration)
|
||||
{
|
||||
Visit(EnterExternAliasDeclaration, LeaveExternAliasDeclaration, externAliasDeclaration);
|
||||
}
|
||||
|
||||
public event Action<ConstructorDeclaration> EnterConstructorDeclaration, LeaveConstructorDeclaration;
|
||||
|
||||
void IAstVisitor.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
|
||||
{
|
||||
Visit(EnterConstructorDeclaration, LeaveConstructorDeclaration, constructorDeclaration);
|
||||
}
|
||||
|
||||
public event Action<ConstructorInitializer> EnterConstructorInitializer, LeaveConstructorInitializer;
|
||||
|
||||
void IAstVisitor.VisitConstructorInitializer(ConstructorInitializer constructorInitializer)
|
||||
{
|
||||
Visit(EnterConstructorInitializer, LeaveConstructorInitializer, constructorInitializer);
|
||||
}
|
||||
|
||||
public event Action<DestructorDeclaration> EnterDestructorDeclaration, LeaveDestructorDeclaration;
|
||||
|
||||
void IAstVisitor.VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration)
|
||||
{
|
||||
Visit(EnterDestructorDeclaration, LeaveDestructorDeclaration, destructorDeclaration);
|
||||
}
|
||||
|
||||
public event Action<EventDeclaration> EnterEventDeclaration, LeaveEventDeclaration;
|
||||
|
||||
void IAstVisitor.VisitEventDeclaration(EventDeclaration eventDeclaration)
|
||||
{
|
||||
Visit(EnterEventDeclaration, LeaveEventDeclaration, eventDeclaration);
|
||||
}
|
||||
|
||||
public event Action<CustomEventDeclaration> EnterCustomEventDeclaration, LeaveCustomEventDeclaration;
|
||||
|
||||
void IAstVisitor.VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
|
||||
{
|
||||
Visit(EnterCustomEventDeclaration, LeaveCustomEventDeclaration, eventDeclaration);
|
||||
}
|
||||
|
||||
public event Action<FieldDeclaration> EnterFieldDeclaration, LeaveFieldDeclaration;
|
||||
|
||||
void IAstVisitor.VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
|
||||
{
|
||||
Visit(EnterFieldDeclaration, LeaveFieldDeclaration, fieldDeclaration);
|
||||
}
|
||||
|
||||
public event Action<FixedFieldDeclaration> EnterFixedFieldDeclaration, LeaveFixedFieldDeclaration;
|
||||
|
||||
void IAstVisitor.VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration)
|
||||
{
|
||||
Visit(EnterFixedFieldDeclaration, LeaveFixedFieldDeclaration, fixedFieldDeclaration);
|
||||
}
|
||||
|
||||
public event Action<FixedVariableInitializer> EnterFixedVariableInitializer, LeaveFixedVariableInitializer;
|
||||
|
||||
void IAstVisitor.VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer)
|
||||
{
|
||||
Visit(EnterFixedVariableInitializer, LeaveFixedVariableInitializer, fixedVariableInitializer);
|
||||
}
|
||||
|
||||
public event Action<IndexerDeclaration> EnterIndexerDeclaration, LeaveIndexerDeclaration;
|
||||
|
||||
void IAstVisitor.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration)
|
||||
{
|
||||
Visit(EnterIndexerDeclaration, LeaveIndexerDeclaration, indexerDeclaration);
|
||||
}
|
||||
|
||||
public event Action<MethodDeclaration> EnterMethodDeclaration, LeaveMethodDeclaration;
|
||||
|
||||
void IAstVisitor.VisitMethodDeclaration(MethodDeclaration methodDeclaration)
|
||||
{
|
||||
Visit(EnterMethodDeclaration, LeaveMethodDeclaration, methodDeclaration);
|
||||
}
|
||||
|
||||
public event Action<OperatorDeclaration> EnterOperatorDeclaration, LeaveOperatorDeclaration;
|
||||
|
||||
void IAstVisitor.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
|
||||
{
|
||||
Visit(EnterOperatorDeclaration, LeaveOperatorDeclaration, operatorDeclaration);
|
||||
}
|
||||
|
||||
public event Action<PropertyDeclaration> EnterPropertyDeclaration, LeavePropertyDeclaration;
|
||||
|
||||
void IAstVisitor.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration)
|
||||
{
|
||||
Visit(EnterPropertyDeclaration, LeavePropertyDeclaration, propertyDeclaration);
|
||||
}
|
||||
|
||||
public event Action<Accessor> EnterAccessor, LeaveAccessor;
|
||||
|
||||
void IAstVisitor.VisitAccessor(Accessor accessor)
|
||||
{
|
||||
Visit(EnterAccessor, LeaveAccessor, accessor);
|
||||
}
|
||||
|
||||
public event Action<VariableInitializer> EnterVariableInitializer, LeaveVariableInitializer;
|
||||
|
||||
void IAstVisitor.VisitVariableInitializer(VariableInitializer variableInitializer)
|
||||
{
|
||||
Visit(EnterVariableInitializer, LeaveVariableInitializer, variableInitializer);
|
||||
}
|
||||
|
||||
public event Action<ParameterDeclaration> EnterParameterDeclaration, LeaveParameterDeclaration;
|
||||
|
||||
void IAstVisitor.VisitParameterDeclaration(ParameterDeclaration parameterDeclaration)
|
||||
{
|
||||
Visit(EnterParameterDeclaration, LeaveParameterDeclaration, parameterDeclaration);
|
||||
}
|
||||
|
||||
public event Action<Constraint> EnterConstraint, LeaveConstraint;
|
||||
|
||||
void IAstVisitor.VisitConstraint(Constraint constraint)
|
||||
{
|
||||
Visit(EnterConstraint, LeaveConstraint, constraint);
|
||||
}
|
||||
|
||||
public event Action<BlockStatement> EnterBlockStatement, LeaveBlockStatement;
|
||||
|
||||
void IAstVisitor.VisitBlockStatement(BlockStatement blockStatement)
|
||||
{
|
||||
Visit(EnterBlockStatement, LeaveBlockStatement, blockStatement);
|
||||
}
|
||||
|
||||
public event Action<ExpressionStatement> EnterExpressionStatement, LeaveExpressionStatement;
|
||||
|
||||
void IAstVisitor.VisitExpressionStatement(ExpressionStatement expressionStatement)
|
||||
{
|
||||
Visit(EnterExpressionStatement, LeaveExpressionStatement, expressionStatement);
|
||||
}
|
||||
|
||||
public event Action<BreakStatement> EnterBreakStatement, LeaveBreakStatement;
|
||||
|
||||
void IAstVisitor.VisitBreakStatement(BreakStatement breakStatement)
|
||||
{
|
||||
Visit(EnterBreakStatement, LeaveBreakStatement, breakStatement);
|
||||
}
|
||||
|
||||
public event Action<CheckedStatement> EnterCheckedStatement, LeaveCheckedStatement;
|
||||
|
||||
void IAstVisitor.VisitCheckedStatement(CheckedStatement checkedStatement)
|
||||
{
|
||||
Visit(EnterCheckedStatement, LeaveCheckedStatement, checkedStatement);
|
||||
}
|
||||
|
||||
public event Action<ContinueStatement> EnterContinueStatement, LeaveContinueStatement;
|
||||
|
||||
void IAstVisitor.VisitContinueStatement(ContinueStatement continueStatement)
|
||||
{
|
||||
Visit(EnterContinueStatement, LeaveContinueStatement, continueStatement);
|
||||
}
|
||||
|
||||
public event Action<DoWhileStatement> EnterDoWhileStatement, LeaveDoWhileStatement;
|
||||
|
||||
void IAstVisitor.VisitDoWhileStatement(DoWhileStatement doWhileStatement)
|
||||
{
|
||||
Visit(EnterDoWhileStatement, LeaveDoWhileStatement, doWhileStatement);
|
||||
}
|
||||
|
||||
public event Action<EmptyStatement> EnterEmptyStatement, LeaveEmptyStatement;
|
||||
|
||||
void IAstVisitor.VisitEmptyStatement(EmptyStatement emptyStatement)
|
||||
{
|
||||
Visit(EnterEmptyStatement, LeaveEmptyStatement, emptyStatement);
|
||||
}
|
||||
|
||||
public event Action<FixedStatement> EnterFixedStatement, LeaveFixedStatement;
|
||||
|
||||
void IAstVisitor.VisitFixedStatement(FixedStatement fixedStatement)
|
||||
{
|
||||
Visit(EnterFixedStatement, LeaveFixedStatement, fixedStatement);
|
||||
}
|
||||
|
||||
public event Action<ForeachStatement> EnterForeachStatement, LeaveForeachStatement;
|
||||
|
||||
void IAstVisitor.VisitForeachStatement(ForeachStatement foreachStatement)
|
||||
{
|
||||
Visit(EnterForeachStatement, LeaveForeachStatement, foreachStatement);
|
||||
}
|
||||
|
||||
public event Action<ForStatement> EnterForStatement, LeaveForStatement;
|
||||
|
||||
void IAstVisitor.VisitForStatement(ForStatement forStatement)
|
||||
{
|
||||
Visit(EnterForStatement, LeaveForStatement, forStatement);
|
||||
}
|
||||
|
||||
public event Action<GotoCaseStatement> EnterGotoCaseStatement, LeaveGotoCaseStatement;
|
||||
|
||||
void IAstVisitor.VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement)
|
||||
{
|
||||
Visit(EnterGotoCaseStatement, LeaveGotoCaseStatement, gotoCaseStatement);
|
||||
}
|
||||
|
||||
public event Action<GotoDefaultStatement> EnterGotoDefaultStatement, LeaveGotoDefaultStatement;
|
||||
|
||||
void IAstVisitor.VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement)
|
||||
{
|
||||
Visit(EnterGotoDefaultStatement, LeaveGotoDefaultStatement, gotoDefaultStatement);
|
||||
}
|
||||
|
||||
public event Action<GotoStatement> EnterGotoStatement, LeaveGotoStatement;
|
||||
|
||||
void IAstVisitor.VisitGotoStatement(GotoStatement gotoStatement)
|
||||
{
|
||||
Visit(EnterGotoStatement, LeaveGotoStatement, gotoStatement);
|
||||
}
|
||||
|
||||
public event Action<IfElseStatement> EnterIfElseStatement, LeaveIfElseStatement;
|
||||
|
||||
void IAstVisitor.VisitIfElseStatement(IfElseStatement ifElseStatement)
|
||||
{
|
||||
Visit(EnterIfElseStatement, LeaveIfElseStatement, ifElseStatement);
|
||||
}
|
||||
|
||||
public event Action<LabelStatement> EnterLabelStatement, LeaveLabelStatement;
|
||||
|
||||
void IAstVisitor.VisitLabelStatement(LabelStatement labelStatement)
|
||||
{
|
||||
Visit(EnterLabelStatement, LeaveLabelStatement, labelStatement);
|
||||
}
|
||||
|
||||
public event Action<LockStatement> EnterLockStatement, LeaveLockStatement;
|
||||
|
||||
void IAstVisitor.VisitLockStatement(LockStatement lockStatement)
|
||||
{
|
||||
Visit(EnterLockStatement, LeaveLockStatement, lockStatement);
|
||||
}
|
||||
|
||||
public event Action<ReturnStatement> EnterReturnStatement, LeaveReturnStatement;
|
||||
|
||||
void IAstVisitor.VisitReturnStatement(ReturnStatement returnStatement)
|
||||
{
|
||||
Visit(EnterReturnStatement, LeaveReturnStatement, returnStatement);
|
||||
}
|
||||
|
||||
public event Action<SwitchStatement> EnterSwitchStatement, LeaveSwitchStatement;
|
||||
|
||||
void IAstVisitor.VisitSwitchStatement(SwitchStatement switchStatement)
|
||||
{
|
||||
Visit(EnterSwitchStatement, LeaveSwitchStatement, switchStatement);
|
||||
}
|
||||
|
||||
public event Action<SwitchSection> EnterSwitchSection, LeaveSwitchSection;
|
||||
|
||||
void IAstVisitor.VisitSwitchSection(SwitchSection switchSection)
|
||||
{
|
||||
Visit(EnterSwitchSection, LeaveSwitchSection, switchSection);
|
||||
}
|
||||
|
||||
public event Action<CaseLabel> EnterCaseLabel, LeaveCaseLabel;
|
||||
|
||||
void IAstVisitor.VisitCaseLabel(CaseLabel caseLabel)
|
||||
{
|
||||
Visit(EnterCaseLabel, LeaveCaseLabel, caseLabel);
|
||||
}
|
||||
|
||||
public event Action<ThrowStatement> EnterThrowStatement, LeaveThrowStatement;
|
||||
|
||||
void IAstVisitor.VisitThrowStatement(ThrowStatement throwStatement)
|
||||
{
|
||||
Visit(EnterThrowStatement, LeaveThrowStatement, throwStatement);
|
||||
}
|
||||
|
||||
public event Action<TryCatchStatement> EnterTryCatchStatement, LeaveTryCatchStatement;
|
||||
|
||||
void IAstVisitor.VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
|
||||
{
|
||||
Visit(EnterTryCatchStatement, LeaveTryCatchStatement, tryCatchStatement);
|
||||
}
|
||||
|
||||
public event Action<CatchClause> EnterCatchClause, LeaveCatchClause;
|
||||
|
||||
void IAstVisitor.VisitCatchClause(CatchClause catchClause)
|
||||
{
|
||||
Visit(EnterCatchClause, LeaveCatchClause, catchClause);
|
||||
}
|
||||
|
||||
public event Action<UncheckedStatement> EnterUncheckedStatement, LeaveUncheckedStatement;
|
||||
|
||||
void IAstVisitor.VisitUncheckedStatement(UncheckedStatement uncheckedStatement)
|
||||
{
|
||||
Visit(EnterUncheckedStatement, LeaveUncheckedStatement, uncheckedStatement);
|
||||
}
|
||||
|
||||
public event Action<UnsafeStatement> EnterUnsafeStatement, LeaveUnsafeStatement;
|
||||
|
||||
void IAstVisitor.VisitUnsafeStatement(UnsafeStatement unsafeStatement)
|
||||
{
|
||||
Visit(EnterUnsafeStatement, LeaveUnsafeStatement, unsafeStatement);
|
||||
}
|
||||
|
||||
public event Action<UsingStatement> EnterUsingStatement, LeaveUsingStatement;
|
||||
|
||||
void IAstVisitor.VisitUsingStatement(UsingStatement usingStatement)
|
||||
{
|
||||
Visit(EnterUsingStatement, LeaveUsingStatement, usingStatement);
|
||||
}
|
||||
|
||||
public event Action<VariableDeclarationStatement> EnterVariableDeclarationStatement, LeaveVariableDeclarationStatement;
|
||||
|
||||
void IAstVisitor.VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement)
|
||||
{
|
||||
Visit(EnterVariableDeclarationStatement, LeaveVariableDeclarationStatement, variableDeclarationStatement);
|
||||
}
|
||||
|
||||
public event Action<WhileStatement> EnterWhileStatement, LeaveWhileStatement;
|
||||
|
||||
void IAstVisitor.VisitWhileStatement(WhileStatement whileStatement)
|
||||
{
|
||||
Visit(EnterWhileStatement, LeaveWhileStatement, whileStatement);
|
||||
}
|
||||
|
||||
public event Action<YieldBreakStatement> EnterYieldBreakStatement, LeaveYieldBreakStatement;
|
||||
|
||||
void IAstVisitor.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement)
|
||||
{
|
||||
Visit(EnterYieldBreakStatement, LeaveYieldBreakStatement, yieldBreakStatement);
|
||||
}
|
||||
|
||||
public event Action<YieldReturnStatement> EnterYieldReturnStatement, LeaveYieldReturnStatement;
|
||||
|
||||
void IAstVisitor.VisitYieldReturnStatement(YieldReturnStatement yieldStatement)
|
||||
{
|
||||
Visit(EnterYieldReturnStatement, LeaveYieldReturnStatement, yieldStatement);
|
||||
}
|
||||
|
||||
public event Action<AnonymousMethodExpression> EnterAnonymousMethodExpression, LeaveAnonymousMethodExpression;
|
||||
|
||||
void IAstVisitor.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression)
|
||||
{
|
||||
Visit(EnterAnonymousMethodExpression, LeaveAnonymousMethodExpression, anonymousMethodExpression);
|
||||
}
|
||||
|
||||
public event Action<LambdaExpression> EnterLambdaExpression, LeaveLambdaExpression;
|
||||
|
||||
void IAstVisitor.VisitLambdaExpression(LambdaExpression lambdaExpression)
|
||||
{
|
||||
Visit(EnterLambdaExpression, LeaveLambdaExpression, lambdaExpression);
|
||||
}
|
||||
|
||||
public event Action<AssignmentExpression> EnterAssignmentExpression, LeaveAssignmentExpression;
|
||||
|
||||
void IAstVisitor.VisitAssignmentExpression(AssignmentExpression assignmentExpression)
|
||||
{
|
||||
Visit(EnterAssignmentExpression, LeaveAssignmentExpression, assignmentExpression);
|
||||
}
|
||||
|
||||
public event Action<BaseReferenceExpression> EnterBaseReferenceExpression, LeaveBaseReferenceExpression;
|
||||
|
||||
void IAstVisitor.VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
|
||||
{
|
||||
Visit(EnterBaseReferenceExpression, LeaveBaseReferenceExpression, baseReferenceExpression);
|
||||
}
|
||||
|
||||
public event Action<BinaryOperatorExpression> EnterBinaryOperatorExpression, LeaveBinaryOperatorExpression;
|
||||
|
||||
void IAstVisitor.VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression)
|
||||
{
|
||||
Visit(EnterBinaryOperatorExpression, LeaveBinaryOperatorExpression, binaryOperatorExpression);
|
||||
}
|
||||
|
||||
public event Action<CastExpression> EnterCastExpression, LeaveCastExpression;
|
||||
|
||||
void IAstVisitor.VisitCastExpression(CastExpression castExpression)
|
||||
{
|
||||
Visit(EnterCastExpression, LeaveCastExpression, castExpression);
|
||||
}
|
||||
|
||||
public event Action<CheckedExpression> EnterCheckedExpression, LeaveCheckedExpression;
|
||||
|
||||
void IAstVisitor.VisitCheckedExpression(CheckedExpression checkedExpression)
|
||||
{
|
||||
Visit(EnterCheckedExpression, LeaveCheckedExpression, checkedExpression);
|
||||
}
|
||||
|
||||
public event Action<ConditionalExpression> EnterConditionalExpression, LeaveConditionalExpression;
|
||||
|
||||
void IAstVisitor.VisitConditionalExpression(ConditionalExpression conditionalExpression)
|
||||
{
|
||||
Visit(EnterConditionalExpression, LeaveConditionalExpression, conditionalExpression);
|
||||
}
|
||||
|
||||
public event Action<IdentifierExpression> EnterIdentifierExpression, LeaveIdentifierExpression;
|
||||
|
||||
void IAstVisitor.VisitIdentifierExpression(IdentifierExpression identifierExpression)
|
||||
{
|
||||
Visit(EnterIdentifierExpression, LeaveIdentifierExpression, identifierExpression);
|
||||
}
|
||||
|
||||
public event Action<IndexerExpression> EnterIndexerExpression, LeaveIndexerExpression;
|
||||
|
||||
void IAstVisitor.VisitIndexerExpression(IndexerExpression indexerExpression)
|
||||
{
|
||||
Visit(EnterIndexerExpression, LeaveIndexerExpression, indexerExpression);
|
||||
}
|
||||
|
||||
public event Action<InvocationExpression> EnterInvocationExpression, LeaveInvocationExpression;
|
||||
|
||||
void IAstVisitor.VisitInvocationExpression(InvocationExpression invocationExpression)
|
||||
{
|
||||
Visit(EnterInvocationExpression, LeaveInvocationExpression, invocationExpression);
|
||||
}
|
||||
|
||||
public event Action<DirectionExpression> EnterDirectionExpression, LeaveDirectionExpression;
|
||||
|
||||
void IAstVisitor.VisitDirectionExpression(DirectionExpression directionExpression)
|
||||
{
|
||||
Visit(EnterDirectionExpression, LeaveDirectionExpression, directionExpression);
|
||||
}
|
||||
|
||||
public event Action<MemberReferenceExpression> EnterMemberReferenceExpression, LeaveMemberReferenceExpression;
|
||||
|
||||
void IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
|
||||
{
|
||||
Visit(EnterMemberReferenceExpression, LeaveMemberReferenceExpression, memberReferenceExpression);
|
||||
}
|
||||
|
||||
public event Action<NullReferenceExpression> EnterNullReferenceExpression, LeaveNullReferenceExpression;
|
||||
|
||||
void IAstVisitor.VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression)
|
||||
{
|
||||
Visit(EnterNullReferenceExpression, LeaveNullReferenceExpression, nullReferenceExpression);
|
||||
}
|
||||
|
||||
public event Action<ObjectCreateExpression> EnterObjectCreateExpression, LeaveObjectCreateExpression;
|
||||
|
||||
void IAstVisitor.VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression)
|
||||
{
|
||||
Visit(EnterObjectCreateExpression, LeaveObjectCreateExpression, objectCreateExpression);
|
||||
}
|
||||
|
||||
public event Action<AnonymousTypeCreateExpression> EnterAnonymousTypeCreateExpression, LeaveAnonymousTypeCreateExpression;
|
||||
|
||||
void IAstVisitor.VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression)
|
||||
{
|
||||
Visit(EnterAnonymousTypeCreateExpression, LeaveAnonymousTypeCreateExpression, anonymousTypeCreateExpression);
|
||||
}
|
||||
|
||||
public event Action<ArrayCreateExpression> EnterArrayCreateExpression, LeaveArrayCreateExpression;
|
||||
|
||||
void IAstVisitor.VisitArrayCreateExpression(ArrayCreateExpression arraySCreateExpression)
|
||||
{
|
||||
Visit(EnterArrayCreateExpression, LeaveArrayCreateExpression, arraySCreateExpression);
|
||||
}
|
||||
|
||||
public event Action<ParenthesizedExpression> EnterParenthesizedExpression, LeaveParenthesizedExpression;
|
||||
|
||||
void IAstVisitor.VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression)
|
||||
{
|
||||
Visit(EnterParenthesizedExpression, LeaveParenthesizedExpression, parenthesizedExpression);
|
||||
}
|
||||
|
||||
public event Action<PointerReferenceExpression> EnterPointerReferenceExpression, LeavePointerReferenceExpression;
|
||||
|
||||
void IAstVisitor.VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression)
|
||||
{
|
||||
Visit(EnterPointerReferenceExpression, LeavePointerReferenceExpression, pointerReferenceExpression);
|
||||
}
|
||||
|
||||
public event Action<PrimitiveExpression> EnterPrimitiveExpression, LeavePrimitiveExpression;
|
||||
|
||||
void IAstVisitor.VisitPrimitiveExpression(PrimitiveExpression primitiveExpression)
|
||||
{
|
||||
Visit(EnterPrimitiveExpression, LeavePrimitiveExpression, primitiveExpression);
|
||||
}
|
||||
|
||||
public event Action<SizeOfExpression> EnterSizeOfExpression, LeaveSizeOfExpression;
|
||||
|
||||
void IAstVisitor.VisitSizeOfExpression(SizeOfExpression sizeOfExpression)
|
||||
{
|
||||
Visit(EnterSizeOfExpression, LeaveSizeOfExpression, sizeOfExpression);
|
||||
}
|
||||
|
||||
public event Action<StackAllocExpression> EnterStackAllocExpression, LeaveStackAllocExpression;
|
||||
|
||||
void IAstVisitor.VisitStackAllocExpression(StackAllocExpression stackAllocExpression)
|
||||
{
|
||||
Visit(EnterStackAllocExpression, LeaveStackAllocExpression, stackAllocExpression);
|
||||
}
|
||||
|
||||
public event Action<ThisReferenceExpression> EnterThisReferenceExpression, LeaveThisReferenceExpression;
|
||||
|
||||
void IAstVisitor.VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression)
|
||||
{
|
||||
Visit(EnterThisReferenceExpression, LeaveThisReferenceExpression, thisReferenceExpression);
|
||||
}
|
||||
|
||||
public event Action<TypeOfExpression> EnterTypeOfExpression, LeaveTypeOfExpression;
|
||||
|
||||
void IAstVisitor.VisitTypeOfExpression(TypeOfExpression typeOfExpression)
|
||||
{
|
||||
Visit(EnterTypeOfExpression, LeaveTypeOfExpression, typeOfExpression);
|
||||
}
|
||||
|
||||
public event Action<TypeReferenceExpression> EnterTypeReferenceExpression, LeaveTypeReferenceExpression;
|
||||
|
||||
void IAstVisitor.VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression)
|
||||
{
|
||||
Visit(EnterTypeReferenceExpression, LeaveTypeReferenceExpression, typeReferenceExpression);
|
||||
}
|
||||
|
||||
public event Action<UnaryOperatorExpression> EnterUnaryOperatorExpression, LeaveUnaryOperatorExpression;
|
||||
|
||||
void IAstVisitor.VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression)
|
||||
{
|
||||
Visit(EnterUnaryOperatorExpression, LeaveUnaryOperatorExpression, unaryOperatorExpression);
|
||||
}
|
||||
|
||||
public event Action<UncheckedExpression> EnterUncheckedExpression, LeaveUncheckedExpression;
|
||||
|
||||
void IAstVisitor.VisitUncheckedExpression(UncheckedExpression uncheckedExpression)
|
||||
{
|
||||
Visit(EnterUncheckedExpression, LeaveUncheckedExpression, uncheckedExpression);
|
||||
}
|
||||
|
||||
public event Action<QueryExpression> EnterQueryExpression, LeaveQueryExpression;
|
||||
|
||||
void IAstVisitor.VisitQueryExpression(QueryExpression queryExpression)
|
||||
{
|
||||
Visit(EnterQueryExpression, LeaveQueryExpression, queryExpression);
|
||||
}
|
||||
|
||||
public event Action<QueryContinuationClause> EnterQueryContinuationClause, LeaveQueryContinuationClause;
|
||||
|
||||
void IAstVisitor.VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause)
|
||||
{
|
||||
Visit(EnterQueryContinuationClause, LeaveQueryContinuationClause, queryContinuationClause);
|
||||
}
|
||||
|
||||
public event Action<QueryFromClause> EnterQueryFromClause, LeaveQueryFromClause;
|
||||
|
||||
void IAstVisitor.VisitQueryFromClause(QueryFromClause queryFromClause)
|
||||
{
|
||||
Visit(EnterQueryFromClause, LeaveQueryFromClause, queryFromClause);
|
||||
}
|
||||
|
||||
public event Action<QueryLetClause> EnterQueryLetClause, LeaveQueryLetClause;
|
||||
|
||||
void IAstVisitor.VisitQueryLetClause(QueryLetClause queryLetClause)
|
||||
{
|
||||
Visit(EnterQueryLetClause, LeaveQueryLetClause, queryLetClause);
|
||||
}
|
||||
|
||||
public event Action<QueryWhereClause> EnterQueryWhereClause, LeaveQueryWhereClause;
|
||||
|
||||
void IAstVisitor.VisitQueryWhereClause(QueryWhereClause queryWhereClause)
|
||||
{
|
||||
Visit(EnterQueryWhereClause, LeaveQueryWhereClause, queryWhereClause);
|
||||
}
|
||||
|
||||
public event Action<QueryJoinClause> EnterQueryJoinClause, LeaveQueryJoinClause;
|
||||
|
||||
void IAstVisitor.VisitQueryJoinClause(QueryJoinClause queryJoinClause)
|
||||
{
|
||||
Visit(EnterQueryJoinClause, LeaveQueryJoinClause, queryJoinClause);
|
||||
}
|
||||
|
||||
public event Action<QueryOrderClause> EnterQueryOrderClause, LeaveQueryOrderClause;
|
||||
|
||||
void IAstVisitor.VisitQueryOrderClause(QueryOrderClause queryOrderClause)
|
||||
{
|
||||
Visit(EnterQueryOrderClause, LeaveQueryOrderClause, queryOrderClause);
|
||||
}
|
||||
|
||||
public event Action<QueryOrdering> EnterQueryOrdering, LeaveQueryOrdering;
|
||||
|
||||
void IAstVisitor.VisitQueryOrdering(QueryOrdering queryOrdering)
|
||||
{
|
||||
Visit(EnterQueryOrdering, LeaveQueryOrdering, queryOrdering);
|
||||
}
|
||||
|
||||
public event Action<QuerySelectClause> EnterQuerySelectClause, LeaveQuerySelectClause;
|
||||
|
||||
void IAstVisitor.VisitQuerySelectClause(QuerySelectClause querySelectClause)
|
||||
{
|
||||
Visit(EnterQuerySelectClause, LeaveQuerySelectClause, querySelectClause);
|
||||
}
|
||||
|
||||
public event Action<QueryGroupClause> EnterQueryGroupClause, LeaveQueryGroupClause;
|
||||
|
||||
void IAstVisitor.VisitQueryGroupClause(QueryGroupClause queryGroupClause)
|
||||
{
|
||||
Visit(EnterQueryGroupClause, LeaveQueryGroupClause, queryGroupClause);
|
||||
}
|
||||
|
||||
public event Action<AsExpression> EnterAsExpression, LeaveAsExpression;
|
||||
|
||||
void IAstVisitor.VisitAsExpression(AsExpression asExpression)
|
||||
{
|
||||
Visit(EnterAsExpression, LeaveAsExpression, asExpression);
|
||||
}
|
||||
|
||||
public event Action<IsExpression> EnterIsExpression, LeaveIsExpression;
|
||||
|
||||
void IAstVisitor.VisitIsExpression(IsExpression isExpression)
|
||||
{
|
||||
Visit(EnterIsExpression, LeaveIsExpression, isExpression);
|
||||
}
|
||||
|
||||
public event Action<DefaultValueExpression> EnterDefaultValueExpression, LeaveDefaultValueExpression;
|
||||
|
||||
void IAstVisitor.VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
|
||||
{
|
||||
Visit(EnterDefaultValueExpression, LeaveDefaultValueExpression, defaultValueExpression);
|
||||
}
|
||||
|
||||
public event Action<UndocumentedExpression> EnterUndocumentedExpression, LeaveUndocumentedExpression;
|
||||
|
||||
void IAstVisitor.VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression)
|
||||
{
|
||||
Visit(EnterUndocumentedExpression, LeaveUndocumentedExpression, undocumentedExpression);
|
||||
}
|
||||
|
||||
public event Action<ArrayInitializerExpression> EnterArrayInitializerExpression, LeaveArrayInitializerExpression;
|
||||
|
||||
void IAstVisitor.VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
|
||||
{
|
||||
Visit(EnterArrayInitializerExpression, LeaveArrayInitializerExpression, arrayInitializerExpression);
|
||||
}
|
||||
|
||||
public event Action<ArraySpecifier> EnterArraySpecifier, LeaveArraySpecifier;
|
||||
|
||||
void IAstVisitor.VisitArraySpecifier(ArraySpecifier arraySpecifier)
|
||||
{
|
||||
Visit(EnterArraySpecifier, LeaveArraySpecifier, arraySpecifier);
|
||||
}
|
||||
|
||||
public event Action<NamedArgumentExpression> EnterNamedArgumentExpression, LeaveNamedArgumentExpression;
|
||||
|
||||
void IAstVisitor.VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression)
|
||||
{
|
||||
Visit(EnterNamedArgumentExpression, LeaveNamedArgumentExpression, namedArgumentExpression);
|
||||
}
|
||||
|
||||
public event Action<NamedExpression> EnterNamedExpression, LeaveNamedExpression;
|
||||
|
||||
void IAstVisitor.VisitNamedExpression(NamedExpression namedExpression)
|
||||
{
|
||||
Visit(EnterNamedExpression, LeaveNamedExpression, namedExpression);
|
||||
}
|
||||
|
||||
public event Action<EmptyExpression> EnterEmptyExpression, LeaveEmptyExpression;
|
||||
|
||||
void IAstVisitor.VisitEmptyExpression(EmptyExpression emptyExpression)
|
||||
{
|
||||
Visit(EnterEmptyExpression, LeaveEmptyExpression, emptyExpression);
|
||||
}
|
||||
|
||||
void IAstVisitor.VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
//
|
||||
// FullTypeName.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ICSharpCode.NRefactory.CSharp.Resolver;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class PrimitiveType : AstType
|
||||
{
|
||||
TextLocation location;
|
||||
string keyword = string.Empty;
|
||||
|
||||
public string Keyword {
|
||||
get { return keyword; }
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException();
|
||||
ThrowIfFrozen();
|
||||
keyword = value;
|
||||
}
|
||||
}
|
||||
|
||||
public KnownTypeCode KnownTypeCode {
|
||||
get { return GetTypeCodeForPrimitiveType(this.Keyword); }
|
||||
}
|
||||
|
||||
public PrimitiveType()
|
||||
{
|
||||
}
|
||||
|
||||
public PrimitiveType(string keyword)
|
||||
{
|
||||
this.Keyword = keyword;
|
||||
}
|
||||
|
||||
public PrimitiveType(string keyword, TextLocation location)
|
||||
{
|
||||
this.Keyword = keyword;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (location.Line, location.Column + keyword.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPrimitiveType (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPrimitiveType (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPrimitiveType (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
PrimitiveType o = other as PrimitiveType;
|
||||
return o != null && MatchString(this.Keyword, o.Keyword);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Keyword;
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type)
|
||||
{
|
||||
KnownTypeCode typeCode = GetTypeCodeForPrimitiveType(this.Keyword);
|
||||
if (typeCode == KnownTypeCode.None)
|
||||
return new UnknownType(null, this.Keyword);
|
||||
else
|
||||
return KnownTypeReference.Get(typeCode);
|
||||
}
|
||||
|
||||
public static KnownTypeCode GetTypeCodeForPrimitiveType(string keyword)
|
||||
{
|
||||
switch (keyword) {
|
||||
case "string":
|
||||
return KnownTypeCode.String;
|
||||
case "int":
|
||||
return KnownTypeCode.Int32;
|
||||
case "uint":
|
||||
return KnownTypeCode.UInt32;
|
||||
case "object":
|
||||
return KnownTypeCode.Object;
|
||||
case "bool":
|
||||
return KnownTypeCode.Boolean;
|
||||
case "sbyte":
|
||||
return KnownTypeCode.SByte;
|
||||
case "byte":
|
||||
return KnownTypeCode.Byte;
|
||||
case "short":
|
||||
return KnownTypeCode.Int16;
|
||||
case "ushort":
|
||||
return KnownTypeCode.UInt16;
|
||||
case "long":
|
||||
return KnownTypeCode.Int64;
|
||||
case "ulong":
|
||||
return KnownTypeCode.UInt64;
|
||||
case "float":
|
||||
return KnownTypeCode.Single;
|
||||
case "double":
|
||||
return KnownTypeCode.Double;
|
||||
case "decimal":
|
||||
return KnownTypeCode.Decimal;
|
||||
case "char":
|
||||
return KnownTypeCode.Char;
|
||||
case "void":
|
||||
return KnownTypeCode.Void;
|
||||
default:
|
||||
return KnownTypeCode.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
//
|
||||
// Roles.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2012 Xamarin <http://xamarin.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public static class Roles
|
||||
{
|
||||
public static readonly Role<AstNode> Root = AstNode.RootRole;
|
||||
|
||||
// some pre defined constants for common roles
|
||||
public static readonly Role<Identifier> Identifier = new Role<Identifier> ("Identifier", CSharp.Identifier.Null);
|
||||
public static readonly Role<BlockStatement> Body = new Role<BlockStatement> ("Body", CSharp.BlockStatement.Null);
|
||||
public static readonly Role<ParameterDeclaration> Parameter = new Role<ParameterDeclaration> ("Parameter");
|
||||
public static readonly Role<Expression> Argument = new Role<Expression> ("Argument", CSharp.Expression.Null);
|
||||
public static readonly Role<AstType> Type = new Role<AstType> ("Type", CSharp.AstType.Null);
|
||||
public static readonly Role<Expression> Expression = new Role<Expression> ("Expression", CSharp.Expression.Null);
|
||||
public static readonly Role<Expression> TargetExpression = new Role<Expression> ("Target", CSharp.Expression.Null);
|
||||
public readonly static Role<Expression> Condition = new Role<Expression> ("Condition", CSharp.Expression.Null);
|
||||
public static readonly Role<TypeParameterDeclaration> TypeParameter = new Role<TypeParameterDeclaration> ("TypeParameter");
|
||||
public static readonly Role<AstType> TypeArgument = new Role<AstType> ("TypeArgument", CSharp.AstType.Null);
|
||||
public readonly static Role<Constraint> Constraint = new Role<Constraint> ("Constraint");
|
||||
public static readonly Role<VariableInitializer> Variable = new Role<VariableInitializer> ("Variable", VariableInitializer.Null);
|
||||
public static readonly Role<Statement> EmbeddedStatement = new Role<Statement> ("EmbeddedStatement", CSharp.Statement.Null);
|
||||
public readonly static Role<EntityDeclaration> TypeMemberRole = new Role<EntityDeclaration> ("TypeMember");
|
||||
|
||||
|
||||
// public static readonly TokenRole Keyword = new TokenRole ("Keyword", CSharpTokenNode.Null);
|
||||
// public static readonly TokenRole InKeyword = new TokenRole ("InKeyword", CSharpTokenNode.Null);
|
||||
|
||||
// some pre defined constants for most used punctuation
|
||||
public static readonly TokenRole LPar = new TokenRole ("(");
|
||||
public static readonly TokenRole RPar = new TokenRole (")");
|
||||
public static readonly TokenRole LBracket = new TokenRole ("[");
|
||||
public static readonly TokenRole RBracket = new TokenRole ("]");
|
||||
public static readonly TokenRole LBrace = new TokenRole ("{");
|
||||
public static readonly TokenRole RBrace = new TokenRole ("}");
|
||||
public static readonly TokenRole LChevron = new TokenRole ("<");
|
||||
public static readonly TokenRole RChevron = new TokenRole (">");
|
||||
public static readonly TokenRole Comma = new TokenRole (",");
|
||||
public static readonly TokenRole Dot = new TokenRole (".");
|
||||
public static readonly TokenRole Semicolon = new TokenRole (";");
|
||||
public static readonly TokenRole Assign = new TokenRole ("=");
|
||||
public static readonly TokenRole Colon = new TokenRole (":");
|
||||
public static readonly TokenRole DoubleColon = new TokenRole ("::");
|
||||
public static readonly Role<Comment> Comment = new Role<Comment> ("Comment");
|
||||
public static readonly Role<NewLineNode> NewLine = new Role<NewLineNode> ("NewLine");
|
||||
public static readonly Role<WhitespaceNode> Whitespace = new Role<WhitespaceNode> ("Whitespace");
|
||||
public static readonly Role<TextNode> Text = new Role<TextNode> ("Text");
|
||||
public static readonly Role<PreProcessorDirective> PreProcessorDirective = new Role<PreProcessorDirective> ("PreProcessorDirective");
|
||||
public static readonly Role<ErrorNode> Error = new Role<ErrorNode> ("Error");
|
||||
|
||||
public readonly static Role<AstType> BaseType = new Role<AstType> ("BaseType", AstType.Null);
|
||||
|
||||
public static readonly Role<Attribute> Attribute = new Role<Attribute> ("Attribute");
|
||||
public static readonly Role<CSharpTokenNode> AttributeTargetRole = new Role<CSharpTokenNode> ("AttributeTarget", CSharpTokenNode.Null);
|
||||
|
||||
public readonly static TokenRole WhereKeyword = new TokenRole ("where");
|
||||
public readonly static Role<SimpleType> ConstraintTypeParameter = new Role<SimpleType> ("TypeParameter", SimpleType.Null);
|
||||
public readonly static TokenRole DelegateKeyword = new TokenRole ("delegate");
|
||||
public static readonly TokenRole ExternKeyword = new TokenRole ("extern");
|
||||
public static readonly TokenRole AliasKeyword = new TokenRole ("alias");
|
||||
public static readonly TokenRole NamespaceKeyword = new TokenRole ("namespace");
|
||||
|
||||
public static readonly TokenRole EnumKeyword = new TokenRole ("enum");
|
||||
public static readonly TokenRole InterfaceKeyword = new TokenRole ("interface");
|
||||
public static readonly TokenRole StructKeyword = new TokenRole ("struct");
|
||||
public static readonly TokenRole ClassKeyword = new TokenRole ("class");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
//
|
||||
// FullTypeName.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ICSharpCode.NRefactory.CSharp.Resolver;
|
||||
using ICSharpCode.NRefactory.CSharp.TypeSystem;
|
||||
using ICSharpCode.NRefactory.TypeSystem;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
public class SimpleType : AstType
|
||||
{
|
||||
#region Null
|
||||
public new static readonly SimpleType Null = new NullSimpleType ();
|
||||
|
||||
sealed class NullSimpleType : SimpleType
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode)
|
||||
{
|
||||
return SpecialType.UnknownType;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public SimpleType()
|
||||
{
|
||||
}
|
||||
|
||||
public SimpleType(string identifier)
|
||||
{
|
||||
this.Identifier = identifier;
|
||||
}
|
||||
|
||||
public SimpleType (Identifier identifier)
|
||||
{
|
||||
this.IdentifierToken = identifier;
|
||||
}
|
||||
|
||||
public SimpleType(string identifier, TextLocation location)
|
||||
{
|
||||
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (identifier, location));
|
||||
}
|
||||
|
||||
public SimpleType (string identifier, IEnumerable<AstType> typeArguments)
|
||||
{
|
||||
this.Identifier = identifier;
|
||||
foreach (var arg in typeArguments) {
|
||||
AddChild (arg, Roles.TypeArgument);
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleType (string identifier, params AstType[] typeArguments) : this (identifier, (IEnumerable<AstType>)typeArguments)
|
||||
{
|
||||
}
|
||||
|
||||
public string Identifier {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier IdentifierToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole (Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AstNodeCollection<AstType> TypeArguments {
|
||||
get { return GetChildrenByRole (Roles.TypeArgument); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitSimpleType (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitSimpleType (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitSimpleType (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
SimpleType o = other as SimpleType;
|
||||
return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder(this.Identifier);
|
||||
if (this.TypeArguments.Any()) {
|
||||
b.Append('<');
|
||||
b.Append(string.Join(", ", this.TypeArguments));
|
||||
b.Append('>');
|
||||
}
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type)
|
||||
{
|
||||
var typeArguments = new List<ITypeReference>();
|
||||
foreach (var ta in this.TypeArguments) {
|
||||
typeArguments.Add(ta.ToTypeReference(lookupMode));
|
||||
}
|
||||
if (typeArguments.Count == 0 && string.IsNullOrEmpty(this.Identifier)) {
|
||||
// empty SimpleType is used for typeof(List<>).
|
||||
return SpecialType.UnboundTypeArgument;
|
||||
}
|
||||
return new SimpleTypeOrNamespaceReference(this.Identifier, typeArguments, lookupMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
//
|
||||
// BlockStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// { Statements }
|
||||
/// </summary>
|
||||
public class BlockStatement : Statement, IEnumerable<Statement>
|
||||
{
|
||||
public static readonly Role<Statement> StatementRole = new Role<Statement>("Statement", Statement.Null);
|
||||
|
||||
#region Null
|
||||
public static readonly new BlockStatement Null = new NullBlockStatement ();
|
||||
sealed class NullBlockStatement : BlockStatement
|
||||
{
|
||||
public override bool IsNull {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return default (T);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return default (S);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return other == null || other.IsNull;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PatternPlaceholder
|
||||
public static implicit operator BlockStatement(PatternMatching.Pattern pattern)
|
||||
{
|
||||
return pattern != null ? new PatternPlaceholder(pattern) : null;
|
||||
}
|
||||
|
||||
sealed class PatternPlaceholder : BlockStatement, PatternMatching.INode
|
||||
{
|
||||
readonly PatternMatching.Pattern child;
|
||||
|
||||
public PatternPlaceholder(PatternMatching.Pattern child)
|
||||
{
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public override NodeType NodeType {
|
||||
get { return NodeType.Pattern; }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitPatternPlaceholder(this, child);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitPatternPlaceholder(this, child, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
return child.DoMatch(other, match);
|
||||
}
|
||||
|
||||
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
|
||||
{
|
||||
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public CSharpTokenNode LBraceToken {
|
||||
get { return GetChildByRole (Roles.LBrace); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Statement> Statements {
|
||||
get { return GetChildrenByRole (StatementRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RBraceToken {
|
||||
get { return GetChildByRole (Roles.RBrace); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitBlockStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitBlockStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitBlockStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
BlockStatement o = other as BlockStatement;
|
||||
return o != null && !o.IsNull && this.Statements.DoMatch(o.Statements, match);
|
||||
}
|
||||
|
||||
public void Add(Statement statement)
|
||||
{
|
||||
AddChild(statement, StatementRole);
|
||||
}
|
||||
|
||||
public void Add(Expression expression)
|
||||
{
|
||||
AddChild(new ExpressionStatement(expression), StatementRole);
|
||||
}
|
||||
|
||||
IEnumerator<Statement> IEnumerable<Statement>.GetEnumerator()
|
||||
{
|
||||
return this.Statements.GetEnumerator();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.Statements.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
//
|
||||
// BreakStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// break;
|
||||
/// </summary>
|
||||
public class BreakStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole BreakKeywordRole = new TokenRole ("break");
|
||||
|
||||
public CSharpTokenNode BreakToken {
|
||||
get { return GetChildByRole (BreakKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitBreakStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitBreakStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitBreakStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
BreakStatement o = other as BreakStatement;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
//
|
||||
// CheckedStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// checked BodyBlock
|
||||
/// </summary>
|
||||
public class CheckedStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole CheckedKeywordRole = new TokenRole ("checked");
|
||||
|
||||
public CSharpTokenNode CheckedToken {
|
||||
get { return GetChildByRole (CheckedKeywordRole); }
|
||||
}
|
||||
|
||||
public BlockStatement Body {
|
||||
get { return GetChildByRole (Roles.Body); }
|
||||
set { SetChildByRole (Roles.Body, value); }
|
||||
}
|
||||
|
||||
public CheckedStatement ()
|
||||
{
|
||||
}
|
||||
|
||||
public CheckedStatement (BlockStatement body)
|
||||
{
|
||||
AddChild (body, Roles.Body);
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitCheckedStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitCheckedStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitCheckedStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
CheckedStatement o = other as CheckedStatement;
|
||||
return o != null && this.Body.DoMatch(o.Body, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
//
|
||||
// ContinueStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// continue;
|
||||
/// </summary>
|
||||
public class ContinueStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole ContinueKeywordRole = new TokenRole ("continue");
|
||||
|
||||
public CSharpTokenNode ContinueToken {
|
||||
get { return GetChildByRole (ContinueKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitContinueStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitContinueStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitContinueStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ContinueStatement o = other as ContinueStatement;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
//
|
||||
// DoWhileStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.using System;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// "do EmbeddedStatement while(Condition);"
|
||||
/// </summary>
|
||||
public class DoWhileStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole DoKeywordRole = new TokenRole ("do");
|
||||
public static readonly TokenRole WhileKeywordRole = new TokenRole ("while");
|
||||
|
||||
public CSharpTokenNode DoToken {
|
||||
get { return GetChildByRole (DoKeywordRole); }
|
||||
}
|
||||
|
||||
public Statement EmbeddedStatement {
|
||||
get { return GetChildByRole (Roles.EmbeddedStatement); }
|
||||
set { SetChildByRole (Roles.EmbeddedStatement, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode WhileToken {
|
||||
get { return GetChildByRole (WhileKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public Expression Condition {
|
||||
get { return GetChildByRole (Roles.Condition); }
|
||||
set { SetChildByRole (Roles.Condition, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitDoWhileStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitDoWhileStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitDoWhileStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
DoWhileStatement o = other as DoWhileStatement;
|
||||
return o != null && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match) && this.Condition.DoMatch(o.Condition, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
//
|
||||
// EmptyStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// ;
|
||||
/// </summary>
|
||||
public class EmptyStatement : Statement
|
||||
{
|
||||
public TextLocation Location {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override TextLocation StartLocation {
|
||||
get {
|
||||
return Location;
|
||||
}
|
||||
}
|
||||
|
||||
public override TextLocation EndLocation {
|
||||
get {
|
||||
return new TextLocation (Location.Line, Location.Column + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitEmptyStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitEmptyStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitEmptyStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
EmptyStatement o = other as EmptyStatement;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
//
|
||||
// ExpressionStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Expression;
|
||||
/// </summary>
|
||||
public class ExpressionStatement : Statement
|
||||
{
|
||||
public Expression Expression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitExpressionStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitExpressionStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitExpressionStatement (this, data);
|
||||
}
|
||||
|
||||
public ExpressionStatement()
|
||||
{
|
||||
}
|
||||
|
||||
public ExpressionStatement(Expression expression)
|
||||
{
|
||||
this.Expression = expression;
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ExpressionStatement o = other as ExpressionStatement;
|
||||
return o != null && this.Expression.DoMatch(o.Expression, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
//
|
||||
// FixedStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// fixed (Type Variables) EmbeddedStatement
|
||||
/// </summary>
|
||||
public class FixedStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole FixedKeywordRole = new TokenRole ("fixed");
|
||||
|
||||
public CSharpTokenNode FixedToken {
|
||||
get { return GetChildByRole (FixedKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstType Type {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<VariableInitializer> Variables {
|
||||
get { return GetChildrenByRole (Roles.Variable); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public Statement EmbeddedStatement {
|
||||
get { return GetChildByRole (Roles.EmbeddedStatement); }
|
||||
set { SetChildByRole (Roles.EmbeddedStatement, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitFixedStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitFixedStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitFixedStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
FixedStatement o = other as FixedStatement;
|
||||
return o != null && this.Type.DoMatch(o.Type, match) && this.Variables.DoMatch(o.Variables, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
//
|
||||
// ForStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// for (Initializers; Condition; Iterators) EmbeddedStatement
|
||||
/// </summary>
|
||||
public class ForStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole ForKeywordRole = new TokenRole ("for");
|
||||
public readonly static Role<Statement> InitializerRole = new Role<Statement>("Initializer", Statement.Null);
|
||||
public readonly static Role<Statement> IteratorRole = new Role<Statement>("Iterator", Statement.Null);
|
||||
|
||||
public CSharpTokenNode ForToken {
|
||||
get { return GetChildByRole (ForKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of initializer statements.
|
||||
/// Note: this contains multiple statements for "for (a = 2, b = 1; a > b; a--)", but contains
|
||||
/// only a single statement for "for (int a = 2, b = 1; a > b; a--)" (a single VariableDeclarationStatement with two variables)
|
||||
/// </summary>
|
||||
public AstNodeCollection<Statement> Initializers {
|
||||
get { return GetChildrenByRole (InitializerRole); }
|
||||
}
|
||||
|
||||
public Expression Condition {
|
||||
get { return GetChildByRole (Roles.Condition); }
|
||||
set { SetChildByRole (Roles.Condition, value); }
|
||||
}
|
||||
|
||||
public AstNodeCollection<Statement> Iterators {
|
||||
get { return GetChildrenByRole (IteratorRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public Statement EmbeddedStatement {
|
||||
get { return GetChildByRole (Roles.EmbeddedStatement); }
|
||||
set { SetChildByRole (Roles.EmbeddedStatement, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitForStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitForStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitForStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ForStatement o = other as ForStatement;
|
||||
return o != null && this.Initializers.DoMatch(o.Initializers, match) && this.Condition.DoMatch(o.Condition, match)
|
||||
&& this.Iterators.DoMatch(o.Iterators, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
//
|
||||
// ForeachStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// foreach (Type VariableName in InExpression) EmbeddedStatement
|
||||
/// </summary>
|
||||
public class ForeachStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole ForeachKeywordRole = new TokenRole ("foreach");
|
||||
public static readonly TokenRole InKeywordRole = new TokenRole ("in");
|
||||
|
||||
public CSharpTokenNode ForeachToken {
|
||||
get { return GetChildByRole (ForeachKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public AstType VariableType {
|
||||
get { return GetChildByRole (Roles.Type); }
|
||||
set { SetChildByRole (Roles.Type, value); }
|
||||
}
|
||||
|
||||
public string VariableName {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public Identifier VariableNameToken {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier);
|
||||
}
|
||||
set {
|
||||
SetChildByRole(Roles.Identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode InToken {
|
||||
get { return GetChildByRole (InKeywordRole); }
|
||||
}
|
||||
|
||||
public Expression InExpression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public Statement EmbeddedStatement {
|
||||
get { return GetChildByRole (Roles.EmbeddedStatement); }
|
||||
set { SetChildByRole (Roles.EmbeddedStatement, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitForeachStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitForeachStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitForeachStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
ForeachStatement o = other as ForeachStatement;
|
||||
return o != null && this.VariableType.DoMatch(o.VariableType, match) && MatchString(this.VariableName, o.VariableName)
|
||||
&& this.InExpression.DoMatch(o.InExpression, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
//
|
||||
// GotoStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// "goto Label;"
|
||||
/// </summary>
|
||||
public class GotoStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
|
||||
|
||||
public GotoStatement ()
|
||||
{
|
||||
}
|
||||
|
||||
public GotoStatement (string label)
|
||||
{
|
||||
this.Label = label;
|
||||
}
|
||||
|
||||
public CSharpTokenNode GotoToken {
|
||||
get { return GetChildByRole (GotoKeywordRole); }
|
||||
}
|
||||
|
||||
public string Label {
|
||||
get {
|
||||
return GetChildByRole (Roles.Identifier).Name;
|
||||
}
|
||||
set {
|
||||
if (string.IsNullOrEmpty(value))
|
||||
SetChildByRole(Roles.Identifier, null);
|
||||
else
|
||||
SetChildByRole(Roles.Identifier, Identifier.Create (value));
|
||||
}
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitGotoStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitGotoStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitGotoStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
GotoStatement o = other as GotoStatement;
|
||||
return o != null && MatchString(this.Label, o.Label);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// or "goto case LabelExpression;"
|
||||
/// </summary>
|
||||
public class GotoCaseStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
|
||||
public static readonly TokenRole CaseKeywordRole = new TokenRole ("case");
|
||||
|
||||
public CSharpTokenNode GotoToken {
|
||||
get { return GetChildByRole (GotoKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode CaseToken {
|
||||
get { return GetChildByRole (CaseKeywordRole); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for "goto case LabelExpression;"
|
||||
/// </summary>
|
||||
public Expression LabelExpression {
|
||||
get { return GetChildByRole (Roles.Expression); }
|
||||
set { SetChildByRole (Roles.Expression, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitGotoCaseStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitGotoCaseStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitGotoCaseStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
GotoCaseStatement o = other as GotoCaseStatement;
|
||||
return o != null && this.LabelExpression.DoMatch(o.LabelExpression, match);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// or "goto default;"
|
||||
/// </summary>
|
||||
public class GotoDefaultStatement : Statement
|
||||
{
|
||||
public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto");
|
||||
public static readonly TokenRole DefaultKeywordRole = new TokenRole ("default");
|
||||
|
||||
public CSharpTokenNode GotoToken {
|
||||
get { return GetChildByRole (GotoKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode DefaultToken {
|
||||
get { return GetChildByRole (DefaultKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode SemicolonToken {
|
||||
get { return GetChildByRole (Roles.Semicolon); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitGotoDefaultStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitGotoDefaultStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitGotoDefaultStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
GotoDefaultStatement o = other as GotoDefaultStatement;
|
||||
return o != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
//
|
||||
// IfElseStatement.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <[email protected]>
|
||||
//
|
||||
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// if (Condition) TrueStatement else FalseStatement
|
||||
/// </summary>
|
||||
public class IfElseStatement : Statement
|
||||
{
|
||||
public readonly static TokenRole IfKeywordRole = new TokenRole ("if");
|
||||
public readonly static Role<Expression> ConditionRole = Roles.Condition;
|
||||
public readonly static Role<Statement> TrueRole = new Role<Statement>("True", Statement.Null);
|
||||
public readonly static TokenRole ElseKeywordRole = new TokenRole ("else");
|
||||
public readonly static Role<Statement> FalseRole = new Role<Statement>("False", Statement.Null);
|
||||
|
||||
public CSharpTokenNode IfToken {
|
||||
get { return GetChildByRole (IfKeywordRole); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode LParToken {
|
||||
get { return GetChildByRole (Roles.LPar); }
|
||||
}
|
||||
|
||||
public Expression Condition {
|
||||
get { return GetChildByRole (ConditionRole); }
|
||||
set { SetChildByRole (ConditionRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode RParToken {
|
||||
get { return GetChildByRole (Roles.RPar); }
|
||||
}
|
||||
|
||||
public Statement TrueStatement {
|
||||
get { return GetChildByRole (TrueRole); }
|
||||
set { SetChildByRole (TrueRole, value); }
|
||||
}
|
||||
|
||||
public CSharpTokenNode ElseToken {
|
||||
get { return GetChildByRole (ElseKeywordRole); }
|
||||
}
|
||||
|
||||
public Statement FalseStatement {
|
||||
get { return GetChildByRole (FalseRole); }
|
||||
set { SetChildByRole (FalseRole, value); }
|
||||
}
|
||||
|
||||
public override void AcceptVisitor (IAstVisitor visitor)
|
||||
{
|
||||
visitor.VisitIfElseStatement (this);
|
||||
}
|
||||
|
||||
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
|
||||
{
|
||||
return visitor.VisitIfElseStatement (this);
|
||||
}
|
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
|
||||
{
|
||||
return visitor.VisitIfElseStatement (this, data);
|
||||
}
|
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
|
||||
{
|
||||
IfElseStatement o = other as IfElseStatement;
|
||||
return o != null && this.Condition.DoMatch(o.Condition, match) && this.TrueStatement.DoMatch(o.TrueStatement, match) && this.FalseStatement.DoMatch(o.FalseStatement, match);
|
||||
}
|
||||
|
||||
public IfElseStatement()
|
||||
{
|
||||
}
|
||||
|
||||
public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement = null)
|
||||
{
|
||||
this.Condition = condition;
|
||||
this.TrueStatement = trueStatement;
|
||||
this.FalseStatement = falseStatement;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user