32 changed files with 0 additions and 24171 deletions
@ -1,120 +0,0 @@ |
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00 |
|
||||||
# Visual Studio 2010 |
|
||||||
# SharpDevelop 4.1.0.7683-alpha |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptBinding", "Project\JavaScriptBinding.csproj", "{062B7E01-AF3D-430D-BE33-17FF3EF4F647}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptBinding.Tests", "Test\JavaScriptBinding.Tests.csproj", "{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonDock", "..\..\..\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj", "{87E61430-4243-45F2-B74E-0A4C096CEBF3}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" |
|
||||||
EndProject |
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" |
|
||||||
EndProject |
|
||||||
Global |
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
||||||
Debug|x86 = Debug|x86 |
|
||||||
Release|x86 = Release|x86 |
|
||||||
Debug|Any CPU = Debug|Any CPU |
|
||||||
Release|Any CPU = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
||||||
{062B7E01-AF3D-430D-BE33-17FF3EF4F647}.Debug|x86.Build.0 = Debug|x86 |
|
||||||
{062B7E01-AF3D-430D-BE33-17FF3EF4F647}.Debug|x86.ActiveCfg = Debug|x86 |
|
||||||
{062B7E01-AF3D-430D-BE33-17FF3EF4F647}.Release|x86.Build.0 = Release|x86 |
|
||||||
{062B7E01-AF3D-430D-BE33-17FF3EF4F647}.Release|x86.ActiveCfg = Release|x86 |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Debug|x86.Build.0 = Debug|x86 |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Debug|x86.ActiveCfg = Debug|x86 |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Release|x86.Build.0 = Release|x86 |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Release|x86.ActiveCfg = Release|x86 |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{87E61430-4243-45F2-B74E-0A4C096CEBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|x86.Build.0 = Debug|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|x86.ActiveCfg = Debug|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|x86.Build.0 = Release|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|x86.ActiveCfg = Release|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU |
|
||||||
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
||||||
EndGlobalSection |
|
||||||
EndGlobal |
|
@ -1,31 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.Reflection; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("JavaScript Binding")] |
|
||||||
[assembly: AssemblyDescription("JavaScript language binding for SharpDevelop")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
@ -1,32 +0,0 @@ |
|||||||
<AddIn |
|
||||||
name="Python Binding" |
|
||||||
author="Matt Ward" |
|
||||||
copyright="prj:///doc/copyright.txt" |
|
||||||
description="Language binding for JavaScript" |
|
||||||
addInManagerHidden="preinstalled"> |
|
||||||
|
|
||||||
<Manifest> |
|
||||||
<Identity name="ICSharpCode.JavaScript"/> |
|
||||||
</Manifest> |
|
||||||
|
|
||||||
<Runtime> |
|
||||||
<Import assembly=":ICSharpCode.SharpDevelop"/> |
|
||||||
<Import assembly="JavaScriptBinding.dll"/> |
|
||||||
</Runtime> |
|
||||||
|
|
||||||
<!-- JavaScript parser --> |
|
||||||
<Path name="/SharpDevelop/Parser"> |
|
||||||
<Parser |
|
||||||
id="JavaScript" |
|
||||||
supportedextensions=".js" |
|
||||||
projectfileextension=".csproj" |
|
||||||
class="ICSharpCode.JavaScriptBinding.JavaScriptParser"/> |
|
||||||
</Path> |
|
||||||
|
|
||||||
<Path name="/Workspace/Icons"> |
|
||||||
<Icon |
|
||||||
id="JavaScript.File" |
|
||||||
extensions=".js" |
|
||||||
resource="JScript.FileIcon"/> |
|
||||||
</Path> |
|
||||||
</AddIn> |
|
@ -1,99 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
|
||||||
<PropertyGroup> |
|
||||||
<ProjectGuid>{062B7E01-AF3D-430D-BE33-17FF3EF4F647}</ProjectGuid> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
<RootNamespace>ICSharpCode.JavaScriptBinding</RootNamespace> |
|
||||||
<AssemblyName>JavaScriptBinding</AssemblyName> |
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|
||||||
<OutputPath>..\..\..\..\..\AddIns\BackendBindings\JavaScriptBinding\</OutputPath> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
|
||||||
<PlatformTarget>x86</PlatformTarget> |
|
||||||
<RegisterForComInterop>False</RegisterForComInterop> |
|
||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
|
||||||
<BaseAddress>4194304</BaseAddress> |
|
||||||
<FileAlignment>4096</FileAlignment> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
|
||||||
<DebugSymbols>true</DebugSymbols> |
|
||||||
<DebugType>Full</DebugType> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|
||||||
<DebugSymbols>False</DebugSymbols> |
|
||||||
<DebugType>None</DebugType> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="Antlr3.Runtime"> |
|
||||||
<HintPath>..\RequiredLibraries\Antlr3.Runtime.dll</HintPath> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
|
||||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
|
||||||
</Compile> |
|
||||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
|
||||||
<Compile Include="Src\CommonTreeExtensions.cs" /> |
|
||||||
<Compile Include="Src\ES3\ES3Lexer.Action.cs" /> |
|
||||||
<Compile Include="Src\ES3\ES3Parser.Action.cs" /> |
|
||||||
<Compile Include="Src\ES3\Generated\ES3Lexer.cs" /> |
|
||||||
<Compile Include="Src\ES3\Generated\ES3Parser.cs" /> |
|
||||||
<Compile Include="Src\ITokenExtensions.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptAst.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptAstFactory.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptAstWalker.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptRegion.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptRegionEnd.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptRegionStart.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptCompilationUnit.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptFunctionDefinition.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptGlobalClass.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptMethodRegion.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptParser.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptRegionWalker.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Folder Include="Src" /> |
|
||||||
<Folder Include="Src\ES3" /> |
|
||||||
<Folder Include="Src\ES3\Generated" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<None Include="JavaScriptBinding.addin"> |
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
||||||
</None> |
|
||||||
<None Include="Src\ES3\ES3.g3" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
|
||||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop</Name> |
|
||||||
<Private>False</Private> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
|
||||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
|
||||||
<Name>ICSharpCode.Core</Name> |
|
||||||
<Private>False</Private> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
|
||||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
|
||||||
<Private>False</Private> |
|
||||||
</ProjectReference> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
@ -1,52 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime.Tree; |
|
||||||
using Xebic.Parsers.ES3; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public static class CommonTreeExtensions |
|
||||||
{ |
|
||||||
public static bool IsFunction(this CommonTree tree) |
|
||||||
{ |
|
||||||
return tree.Type == ES3Parser.FUNCTION; |
|
||||||
} |
|
||||||
|
|
||||||
public static bool HasChildren(this CommonTree tree) |
|
||||||
{ |
|
||||||
return tree.ChildCount > 0; |
|
||||||
} |
|
||||||
|
|
||||||
public static CommonTree GetFirstChild(this CommonTree tree) |
|
||||||
{ |
|
||||||
return tree.GetChild(0) as CommonTree; |
|
||||||
} |
|
||||||
|
|
||||||
public static CommonTree GetFirstChildArguments(this CommonTree tree) |
|
||||||
{ |
|
||||||
return tree.GetFirstChildWithType(ES3Parser.ARGS) as CommonTree; |
|
||||||
} |
|
||||||
|
|
||||||
public static int BeginColumn(this CommonTree tree) |
|
||||||
{ |
|
||||||
return tree.CharPositionInLine + 1; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
File diff suppressed because it is too large
Load Diff
@ -1,184 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.Globalization; |
|
||||||
using System.Text; |
|
||||||
|
|
||||||
using Antlr.Runtime; |
|
||||||
|
|
||||||
namespace Xebic.Parsers.ES3 |
|
||||||
{ |
|
||||||
using IToken = Antlr.Runtime.IToken; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This partial class is complementary to the lexer generated with ANTLR from the JavaScript.g grammar.
|
|
||||||
/// It implements the actions used in the lexer.
|
|
||||||
/// </summary>
|
|
||||||
public partial class ES3Lexer |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Containts the last on channel token.
|
|
||||||
/// </summary>
|
|
||||||
protected IToken last; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates whether regular expression (yields true) or division expression recognition (false) in the lexer is enabled.
|
|
||||||
/// These are mutual exclusive and the decision which is active in the lexer is based on the previous on channel token.
|
|
||||||
/// When the previous token can be identified as a possible left operand for a division this results in false, otherwise true.
|
|
||||||
/// </summary>
|
|
||||||
private bool AreRegularExpressionsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (last == null) |
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
switch (last.Type) |
|
||||||
{ |
|
||||||
// identifier
|
|
||||||
case Identifier: |
|
||||||
// literals
|
|
||||||
case NULL: |
|
||||||
case TRUE: |
|
||||||
case FALSE: |
|
||||||
case THIS: |
|
||||||
case OctalIntegerLiteral: |
|
||||||
case DecimalLiteral: |
|
||||||
case HexIntegerLiteral: |
|
||||||
case StringLiteral: |
|
||||||
// member access ending
|
|
||||||
case RBRACK: |
|
||||||
// function call or nested expression ending
|
|
||||||
case RPAREN: |
|
||||||
return false; |
|
||||||
|
|
||||||
// otherwise OK
|
|
||||||
default: |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Consumes an unicode identifier after validating that the first character can be the starting character.
|
|
||||||
/// This method is called by the lexer logic as fallback alternative when a character can not be considered as start of an identifier in the ASCII range.
|
|
||||||
/// See the Identfier lexer rule for more details.
|
|
||||||
/// </summary>
|
|
||||||
private void ConsumeIdentifierUnicodeStart() |
|
||||||
{ |
|
||||||
int ch = (char)input.LA(1); |
|
||||||
if (IsIdentifierStartUnicode(ch)) |
|
||||||
{ |
|
||||||
MatchAny(); |
|
||||||
do |
|
||||||
{ |
|
||||||
ch = (char)input.LA(1); |
|
||||||
if (ch == '$' || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '\\' || ch == '_' || (ch >= 'a' && ch <= 'z') || IsIdentifierPartUnicode(ch)) |
|
||||||
{ |
|
||||||
mIdentifierPart(); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
while (true); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
throw new NoViableAltException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates whether a given character can be a part of an unicode identifier.
|
|
||||||
/// This method doesn't consider ASCII characters that can be a part of an identifier, that is left to the mIdentifierPart method.
|
|
||||||
/// The latter method will call this method to check other characters in the unicode range after evaluating those in the ASCII range.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ch">The character to check.</param>
|
|
||||||
/// <returns>True when the character matches, false otherwise.</returns>
|
|
||||||
public static bool IsIdentifierPartUnicode(int ch) |
|
||||||
{ |
|
||||||
switch (Char.GetUnicodeCategory((char)ch)) |
|
||||||
{ |
|
||||||
// UnicodeLetter
|
|
||||||
case UnicodeCategory.UppercaseLetter: // Lu
|
|
||||||
case UnicodeCategory.LowercaseLetter: // Ll
|
|
||||||
case UnicodeCategory.TitlecaseLetter: // Lt
|
|
||||||
case UnicodeCategory.ModifierLetter: // Lm
|
|
||||||
case UnicodeCategory.OtherLetter: // Lo
|
|
||||||
case UnicodeCategory.LetterNumber: // Nl
|
|
||||||
// UnicodeCombiningMark
|
|
||||||
case UnicodeCategory.NonSpacingMark: // Mn
|
|
||||||
case UnicodeCategory.SpacingCombiningMark: // Mc
|
|
||||||
// UnicodeDigit
|
|
||||||
case UnicodeCategory.DecimalDigitNumber: // Nd
|
|
||||||
// UnicodeConnectorPuntuation
|
|
||||||
case UnicodeCategory.ConnectorPunctuation: // Pc
|
|
||||||
return true; |
|
||||||
|
|
||||||
// Not matching
|
|
||||||
default: |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates whether a given character can be the first character of an unicode identifier.
|
|
||||||
/// This method doesn't consider ASCII characters as it is used in a fallback scenario after the ASCII range is evaluated.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ch">The character to check.</param>
|
|
||||||
/// <returns>True when the character matches, false otherwise.</returns>
|
|
||||||
public static bool IsIdentifierStartUnicode(int ch) |
|
||||||
{ |
|
||||||
switch (Char.GetUnicodeCategory((char)ch)) |
|
||||||
{ |
|
||||||
// UnicodeLetter
|
|
||||||
case UnicodeCategory.UppercaseLetter: // Lu
|
|
||||||
case UnicodeCategory.LowercaseLetter: // Ll
|
|
||||||
case UnicodeCategory.TitlecaseLetter: // Lt
|
|
||||||
case UnicodeCategory.ModifierLetter: // Lm
|
|
||||||
case UnicodeCategory.OtherLetter: // Lo
|
|
||||||
case UnicodeCategory.LetterNumber: // Nl
|
|
||||||
return true; |
|
||||||
|
|
||||||
// Not matching
|
|
||||||
default: |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Override of base to track previous on channel token.
|
|
||||||
/// This token is needed as input to decide whether regular expression or division expression recognition is enabled.
|
|
||||||
/// </summary>
|
|
||||||
public override IToken NextToken() |
|
||||||
{ |
|
||||||
IToken result = base.NextToken(); |
|
||||||
if (result.Channel == DefaultTokenChannel) |
|
||||||
{ |
|
||||||
last = result; |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,192 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.Text; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
|
|
||||||
using Antlr.Runtime; |
|
||||||
using Antlr.Runtime.Tree; |
|
||||||
|
|
||||||
namespace Xebic.Parsers.ES3 |
|
||||||
{ |
|
||||||
using IToken = Antlr.Runtime.IToken; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This partial class is complementary to the parser generated with ANTLR from the JavaScript.g grammar.
|
|
||||||
/// It implements the actions used in the parser.
|
|
||||||
/// </summary>
|
|
||||||
public partial class ES3Parser |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Is a RuleReturnScope node candidate for the left-hand-side of an assignment expression?
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="lhs">The RuleReturnScope node</param>
|
|
||||||
/// <param name="cached">The cached result of a former call to this method</param>
|
|
||||||
/// <returns>True if so, false otherwise</returns>
|
|
||||||
public bool IsLeftHandSideAssign(IAstRuleReturnScope lhs, ref bool? cached) |
|
||||||
{ |
|
||||||
if (cached.HasValue) |
|
||||||
{ |
|
||||||
return cached.Value; |
|
||||||
} |
|
||||||
|
|
||||||
bool result; |
|
||||||
if (IsLeftHandSideExpression(lhs)) |
|
||||||
{ |
|
||||||
switch (input.LA(1)) |
|
||||||
{ |
|
||||||
case ASSIGN: |
|
||||||
case MULASS: |
|
||||||
case DIVASS: |
|
||||||
case MODASS: |
|
||||||
case ADDASS: |
|
||||||
case SUBASS: |
|
||||||
case SHLASS: |
|
||||||
case SHRASS: |
|
||||||
case SHUASS: |
|
||||||
case ANDASS: |
|
||||||
case XORASS: |
|
||||||
case ORASS: |
|
||||||
result = true; |
|
||||||
break; |
|
||||||
|
|
||||||
default: |
|
||||||
result = false; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
result = false; |
|
||||||
} |
|
||||||
|
|
||||||
cached = result; |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Is a RuleReturnScope node candidate a left-hand-side expression?
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="lhs">The RuleReturnScope node</param>
|
|
||||||
/// <returns>True if so, false otherwise</returns>
|
|
||||||
private bool IsLeftHandSideExpression(IAstRuleReturnScope lhs) |
|
||||||
{ |
|
||||||
if (lhs.Tree == null) // e.g. during backtracking
|
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
switch (((ITree)lhs.Tree).Type) |
|
||||||
{ |
|
||||||
// primaryExpression
|
|
||||||
case THIS: |
|
||||||
case Identifier: |
|
||||||
case NULL: |
|
||||||
case TRUE: |
|
||||||
case FALSE: |
|
||||||
case DecimalLiteral: |
|
||||||
case OctalIntegerLiteral: |
|
||||||
case HexIntegerLiteral: |
|
||||||
case StringLiteral: |
|
||||||
case RegularExpressionLiteral: |
|
||||||
case ARRAY: |
|
||||||
case OBJECT: |
|
||||||
case PAREXPR: |
|
||||||
// functionExpression
|
|
||||||
case FUNCTION: |
|
||||||
// newExpression
|
|
||||||
case NEW: |
|
||||||
// leftHandSideExpression
|
|
||||||
case CALL: |
|
||||||
case BYFIELD: |
|
||||||
case BYINDEX: |
|
||||||
return true; |
|
||||||
|
|
||||||
default: |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Is a RuleReturnScope node candidate for the left-hand-side of an in expression?
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="lhs">The RuleReturnScope node</param>
|
|
||||||
/// <param name="cached">The cached result of a former call to this method</param>
|
|
||||||
/// <returns>True if so, false otherwise</returns>
|
|
||||||
public bool IsLeftHandSideIn(IAstRuleReturnScope lhs, ref bool? cached) |
|
||||||
{ |
|
||||||
if (cached.HasValue) |
|
||||||
{ |
|
||||||
return cached.Value; |
|
||||||
} |
|
||||||
|
|
||||||
bool result = IsLeftHandSideExpression(lhs) && (input.LA(1) == IN); |
|
||||||
|
|
||||||
cached = result; |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method handles promotion of an EOL token to on channel in situations where the ECMA 3 specification
|
|
||||||
/// states there should be a semicolon inserted because of an EOL between the current (offending) token
|
|
||||||
/// and the previous token.
|
|
||||||
/// So an semicolon is not actually inserted but the EOL present is switched from off to on channel. In this
|
|
||||||
/// way that EOL gets the notion of an "virtual" semicolon.
|
|
||||||
/// As a side effect a given rule's return scope starting point is set to the found EOL and the input stream is repositioned on it.
|
|
||||||
/// A multi line comment with an EOL is also promoted.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rule">The invoking rule's return scope</param>
|
|
||||||
public void PromoteEOL(ParserRuleReturnScope<IToken> rule) |
|
||||||
{ |
|
||||||
// Get current token and its type (the possibly offending token).
|
|
||||||
IToken lt = input.LT(1); |
|
||||||
int la = lt.Type; |
|
||||||
|
|
||||||
// We only need to promote an EOL when the current token is offending (not a SEMIC, EOF, RBRACE or EOL).
|
|
||||||
// Promoting an EOL means switching it from off channel to on channel.
|
|
||||||
if (!(la == SEMIC || la == EOF || la == RBRACE || la == EOL)) |
|
||||||
{ |
|
||||||
// Start on the possition before the current token and scan backwards off channel tokens until the previous on channel token.
|
|
||||||
for (int ix = lt.TokenIndex - 1; ix > 0; ix--) |
|
||||||
{ |
|
||||||
lt = input.Get(ix); |
|
||||||
if (lt.Channel == DefaultTokenChannel) |
|
||||||
{ |
|
||||||
// On channel token found: stop scanning.
|
|
||||||
break; |
|
||||||
} |
|
||||||
else if (lt.Type == EOL || (lt.Type == MultiLineComment && Regex.IsMatch(lt.Text, "/.*\r\n|\r|\n"))) |
|
||||||
{ |
|
||||||
// We found our EOL: promote it to on channel, position the input on it and reset the rule start.
|
|
||||||
lt.Channel = DefaultTokenChannel; |
|
||||||
input.Seek(lt.TokenIndex); |
|
||||||
if (rule != null) |
|
||||||
{ |
|
||||||
rule.Start = lt; |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,42 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
using Xebic.Parsers.ES3; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public static class ITokenExtensions |
|
||||||
{ |
|
||||||
public static int BeginColumn(this IToken token) |
|
||||||
{ |
|
||||||
return token.CharPositionInLine + 1; |
|
||||||
} |
|
||||||
|
|
||||||
public static int EndColumn(this IToken token) |
|
||||||
{ |
|
||||||
return token.CharPositionInLine + token.Text.Length + 1; |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsSingleLineComment(this IToken token) |
|
||||||
{ |
|
||||||
return token.Type == ES3Lexer.SingleLineComment; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,55 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
using Antlr.Runtime.Tree; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptAst |
|
||||||
{ |
|
||||||
CommonTokenStream tokenStream; |
|
||||||
CommonTree tree; |
|
||||||
|
|
||||||
public JavaScriptAst(CommonTokenStream tokenStream, CommonTree tree) |
|
||||||
{ |
|
||||||
this.tokenStream = tokenStream; |
|
||||||
this.tree = tree; |
|
||||||
} |
|
||||||
|
|
||||||
public CommonTree Tree { |
|
||||||
get { return tree; } |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsValid { |
|
||||||
get { return tree != null; } |
|
||||||
} |
|
||||||
|
|
||||||
public IToken GetToken(int index) |
|
||||||
{ |
|
||||||
return tokenStream.Get(index); |
|
||||||
} |
|
||||||
|
|
||||||
public IList<IToken> GetTokens() |
|
||||||
{ |
|
||||||
return tokenStream.GetTokens(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,53 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
using Antlr.Runtime.Tree; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using Xebic.Parsers.ES3; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptAstFactory |
|
||||||
{ |
|
||||||
string code; |
|
||||||
CommonTokenStream tokenStream; |
|
||||||
ES3Parser.program_return programReturn; |
|
||||||
|
|
||||||
public JavaScriptAstFactory(ITextBuffer textBuffer) |
|
||||||
{ |
|
||||||
code = textBuffer.Text; |
|
||||||
} |
|
||||||
|
|
||||||
public JavaScriptAst Create() |
|
||||||
{ |
|
||||||
CreateTokenStream(); |
|
||||||
var parser = new ES3Parser(tokenStream); |
|
||||||
programReturn = parser.program(); |
|
||||||
return new JavaScriptAst(tokenStream, programReturn.Tree as CommonTree); |
|
||||||
} |
|
||||||
|
|
||||||
void CreateTokenStream() |
|
||||||
{ |
|
||||||
var stream = new ANTLRStringStream(code); |
|
||||||
var lexer = new ES3Lexer(stream); |
|
||||||
tokenStream = new CommonTokenStream(lexer); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,78 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime.Tree; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using Xebic.Parsers.ES3; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptAstWalker |
|
||||||
{ |
|
||||||
JavaScriptCompilationUnit compilationUnit; |
|
||||||
JavaScriptAst ast; |
|
||||||
|
|
||||||
public JavaScriptAstWalker( |
|
||||||
JavaScriptCompilationUnit compilationUnit, |
|
||||||
JavaScriptAst ast) |
|
||||||
{ |
|
||||||
this.compilationUnit = compilationUnit; |
|
||||||
this.ast = ast; |
|
||||||
} |
|
||||||
|
|
||||||
public void Walk() |
|
||||||
{ |
|
||||||
if (ast.IsValid) { |
|
||||||
Walk(ast.Tree); |
|
||||||
WalkRegions(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void Walk(CommonTree tree) |
|
||||||
{ |
|
||||||
if (tree.IsFunction()) { |
|
||||||
AddMethod(tree); |
|
||||||
} |
|
||||||
|
|
||||||
if (tree.HasChildren()) { |
|
||||||
WalkChildren(tree.Children); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void AddMethod(CommonTree tree) |
|
||||||
{ |
|
||||||
var functionDefinition = new JavaScriptFunctionDefinition(ast, tree); |
|
||||||
functionDefinition.AddMethod(compilationUnit.GlobalClass); |
|
||||||
} |
|
||||||
|
|
||||||
void WalkChildren(IEnumerable<ITree> children) |
|
||||||
{ |
|
||||||
foreach (CommonTree child in children) { |
|
||||||
Walk(child); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void WalkRegions() |
|
||||||
{ |
|
||||||
var regionWalker = new JavaScriptRegionWalker(ast, compilationUnit); |
|
||||||
regionWalker.Walk(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,60 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.IO; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptCompilationUnit : DefaultCompilationUnit |
|
||||||
{ |
|
||||||
public JavaScriptCompilationUnit( |
|
||||||
IProjectContent projectContent, |
|
||||||
string fileName) |
|
||||||
: base(projectContent) |
|
||||||
{ |
|
||||||
this.FileName = fileName; |
|
||||||
AddGlobalClass(); |
|
||||||
} |
|
||||||
|
|
||||||
void AddGlobalClass() |
|
||||||
{ |
|
||||||
GlobalClass = CreateGlobalClass(); |
|
||||||
AddClass(GlobalClass); |
|
||||||
} |
|
||||||
|
|
||||||
public JavaScriptGlobalClass GlobalClass { get; private set; } |
|
||||||
|
|
||||||
JavaScriptGlobalClass CreateGlobalClass() |
|
||||||
{ |
|
||||||
string className = GetGlobalClassName(); |
|
||||||
return new JavaScriptGlobalClass(this, className); |
|
||||||
} |
|
||||||
|
|
||||||
string GetGlobalClassName() |
|
||||||
{ |
|
||||||
return Path.GetFileNameWithoutExtension(FileName); |
|
||||||
} |
|
||||||
|
|
||||||
void AddClass(IClass c) |
|
||||||
{ |
|
||||||
Classes.Add(c); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,56 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime.Tree; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptFunctionDefinition |
|
||||||
{ |
|
||||||
JavaScriptAst ast; |
|
||||||
CommonTree tree; |
|
||||||
|
|
||||||
public JavaScriptFunctionDefinition(JavaScriptAst ast, CommonTree tree) |
|
||||||
{ |
|
||||||
this.ast = ast; |
|
||||||
this.tree = tree; |
|
||||||
} |
|
||||||
|
|
||||||
public void AddMethod(JavaScriptGlobalClass c) |
|
||||||
{ |
|
||||||
string methodName = GetMethodName(); |
|
||||||
DefaultMethod method = c.AddMethod(methodName); |
|
||||||
UpdateRegions(method); |
|
||||||
} |
|
||||||
|
|
||||||
string GetMethodName() |
|
||||||
{ |
|
||||||
CommonTree child = tree.GetFirstChild(); |
|
||||||
return child.Text; |
|
||||||
} |
|
||||||
|
|
||||||
void UpdateRegions(DefaultMethod method) |
|
||||||
{ |
|
||||||
var methodRegion = new JavaScriptMethodRegion(ast, tree); |
|
||||||
method.Region = methodRegion.GetHeaderRegion(); |
|
||||||
method.BodyRegion = methodRegion.GetBodyRegion(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,45 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptGlobalClass : DefaultClass |
|
||||||
{ |
|
||||||
public JavaScriptGlobalClass( |
|
||||||
ICompilationUnit compilationUnit, |
|
||||||
string fullyQualifiedName) |
|
||||||
: base(compilationUnit, fullyQualifiedName) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public DefaultMethod AddMethod(string name) |
|
||||||
{ |
|
||||||
var method = new DefaultMethod(this, name); |
|
||||||
AddMethod(method); |
|
||||||
return method; |
|
||||||
} |
|
||||||
|
|
||||||
public void AddMethod(IMethod method) |
|
||||||
{ |
|
||||||
Methods.Add(method); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,92 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
using Antlr.Runtime.Tree; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using Xebic.Parsers.ES3; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptMethodRegion |
|
||||||
{ |
|
||||||
JavaScriptAst ast; |
|
||||||
CommonTree methodDefinition; |
|
||||||
IToken functionDefinitionEndToken; |
|
||||||
|
|
||||||
public JavaScriptMethodRegion(JavaScriptAst ast, CommonTree methodDefinition) |
|
||||||
{ |
|
||||||
this.ast = ast; |
|
||||||
this.methodDefinition = methodDefinition; |
|
||||||
} |
|
||||||
|
|
||||||
public DomRegion GetHeaderRegion() |
|
||||||
{ |
|
||||||
int beginLine = methodDefinition.Line; |
|
||||||
int endLine = beginLine; //TODO - function header definition can go across lines.
|
|
||||||
int beginColumn = GetMethodHeaderBeginColumn(); |
|
||||||
int endColumn = GetMethodHeaderEndColumn(); |
|
||||||
return new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
} |
|
||||||
|
|
||||||
int GetMethodHeaderBeginColumn() |
|
||||||
{ |
|
||||||
return methodDefinition.BeginColumn(); |
|
||||||
} |
|
||||||
|
|
||||||
int GetMethodHeaderEndColumn() |
|
||||||
{ |
|
||||||
CommonTree arguments = methodDefinition.GetFirstChildArguments(); |
|
||||||
if (arguments != null) { |
|
||||||
IToken token = ast.GetToken(arguments.TokenStopIndex); |
|
||||||
return token.EndColumn(); |
|
||||||
} |
|
||||||
return 0; |
|
||||||
} |
|
||||||
|
|
||||||
public DomRegion GetBodyRegion() |
|
||||||
{ |
|
||||||
int beginLine = methodDefinition.Line; |
|
||||||
int endLine = GetMethodBodyEndLine(); |
|
||||||
int beginColumn = GetMethodHeaderEndColumn(); |
|
||||||
int endColumn = GetMethodBodyEndColumn(); |
|
||||||
return new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
} |
|
||||||
|
|
||||||
int GetMethodBodyEndLine() |
|
||||||
{ |
|
||||||
IToken token = GetFunctionDefinitionEndToken(); |
|
||||||
return token.Line; |
|
||||||
} |
|
||||||
|
|
||||||
IToken GetFunctionDefinitionEndToken() |
|
||||||
{ |
|
||||||
if (functionDefinitionEndToken == null) { |
|
||||||
functionDefinitionEndToken = ast.GetToken(methodDefinition.TokenStopIndex); |
|
||||||
} |
|
||||||
return functionDefinitionEndToken; |
|
||||||
} |
|
||||||
|
|
||||||
int GetMethodBodyEndColumn() |
|
||||||
{ |
|
||||||
IToken token = GetFunctionDefinitionEndToken(); |
|
||||||
return token.EndColumn(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,88 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.IO; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptParser : IParser |
|
||||||
{ |
|
||||||
public JavaScriptParser() |
|
||||||
{ |
|
||||||
LexerTags = new string[0]; |
|
||||||
} |
|
||||||
|
|
||||||
public string[] LexerTags { get; set; } |
|
||||||
|
|
||||||
public LanguageProperties Language { |
|
||||||
get { return LanguageProperties.None; } |
|
||||||
} |
|
||||||
|
|
||||||
public IExpressionFinder CreateExpressionFinder(string fileName) |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanParse(string fileName) |
|
||||||
{ |
|
||||||
string extension = Path.GetExtension(fileName); |
|
||||||
if (extension != null) { |
|
||||||
return IsJavaScriptFileExtension(extension); |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
bool IsJavaScriptFileExtension(string extension) |
|
||||||
{ |
|
||||||
return extension.Equals(".js", StringComparison.InvariantCultureIgnoreCase); |
|
||||||
} |
|
||||||
|
|
||||||
public bool CanParse(IProject project) |
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent) |
|
||||||
{ |
|
||||||
try { |
|
||||||
var astFactory = new JavaScriptAstFactory(fileContent); |
|
||||||
JavaScriptAst ast = astFactory.Create(); |
|
||||||
|
|
||||||
var unit = new JavaScriptCompilationUnit(projectContent, fileName); |
|
||||||
var walker = new JavaScriptAstWalker(unit, ast); |
|
||||||
walker.Walk(); |
|
||||||
|
|
||||||
return unit; |
|
||||||
} catch (Exception ex) { |
|
||||||
LoggingService.Debug(ex.ToString()); |
|
||||||
} |
|
||||||
|
|
||||||
return new DefaultCompilationUnit(projectContent) { FileName = fileName }; |
|
||||||
} |
|
||||||
|
|
||||||
public IResolver CreateResolver() |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,57 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.SharpDevelop.Dom; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptRegion |
|
||||||
{ |
|
||||||
JavaScriptRegionStart start; |
|
||||||
JavaScriptRegionEnd end; |
|
||||||
|
|
||||||
public JavaScriptRegion(JavaScriptRegionStart start, JavaScriptRegionEnd end) |
|
||||||
{ |
|
||||||
this.start = start; |
|
||||||
this.end = end; |
|
||||||
} |
|
||||||
|
|
||||||
public void AddRegion(IList<FoldingRegion> foldingRegions) |
|
||||||
{ |
|
||||||
FoldingRegion namedFoldingRegion = CreateFoldingRegion(); |
|
||||||
foldingRegions.Add(namedFoldingRegion); |
|
||||||
} |
|
||||||
|
|
||||||
FoldingRegion CreateFoldingRegion() |
|
||||||
{ |
|
||||||
DomRegion location = GetRegionLocation(); |
|
||||||
return new FoldingRegion(start.Name, location); |
|
||||||
} |
|
||||||
|
|
||||||
DomRegion GetRegionLocation() |
|
||||||
{ |
|
||||||
int beginLine = start.Line; |
|
||||||
int endLine = end.Line; |
|
||||||
int beginColumn = start.StartColumn; |
|
||||||
int endColumn = end.EndColumn; |
|
||||||
return new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,49 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptRegionEnd |
|
||||||
{ |
|
||||||
public static readonly string RegionEndText = "//#endregion"; |
|
||||||
public static readonly int RegionEndTextLength = RegionEndText.Length; |
|
||||||
|
|
||||||
IToken token; |
|
||||||
|
|
||||||
public JavaScriptRegionEnd(IToken token) |
|
||||||
{ |
|
||||||
this.token = token; |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsRegionEnd(IToken token) |
|
||||||
{ |
|
||||||
return token.Text.StartsWith(RegionEndText); |
|
||||||
} |
|
||||||
|
|
||||||
public int Line { |
|
||||||
get { return token.Line; } |
|
||||||
} |
|
||||||
|
|
||||||
public int EndColumn { |
|
||||||
get { return token.BeginColumn() + RegionEndTextLength; } |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,66 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptRegionStart |
|
||||||
{ |
|
||||||
public static readonly string RegionStartText = "//#region "; |
|
||||||
public static readonly int RegionStartTextLength = RegionStartText.Length; |
|
||||||
|
|
||||||
IToken token; |
|
||||||
string name; |
|
||||||
|
|
||||||
public JavaScriptRegionStart(IToken token) |
|
||||||
{ |
|
||||||
this.token = token; |
|
||||||
} |
|
||||||
|
|
||||||
public string Name { |
|
||||||
get { |
|
||||||
if (name == null) { |
|
||||||
GetName(); |
|
||||||
} |
|
||||||
return name; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void GetName() |
|
||||||
{ |
|
||||||
string text = token.Text; |
|
||||||
int index = text.IndexOf(RegionStartText); |
|
||||||
name = text.Substring(index + RegionStartTextLength); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool IsRegionStart(IToken token) |
|
||||||
{ |
|
||||||
return token.Text.StartsWith(RegionStartText); |
|
||||||
} |
|
||||||
|
|
||||||
public int Line { |
|
||||||
get { return token.Line; } |
|
||||||
} |
|
||||||
|
|
||||||
public int StartColumn { |
|
||||||
get { return token.BeginColumn(); } |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,79 +0,0 @@ |
|||||||
// Copyright (c) 2014 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 Antlr.Runtime; |
|
||||||
using Antlr.Runtime.Tree; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using Xebic.Parsers.ES3; |
|
||||||
|
|
||||||
namespace ICSharpCode.JavaScriptBinding |
|
||||||
{ |
|
||||||
public class JavaScriptRegionWalker |
|
||||||
{ |
|
||||||
JavaScriptAst ast; |
|
||||||
ICompilationUnit compilationUnit; |
|
||||||
Stack<JavaScriptRegionStart> regions; |
|
||||||
|
|
||||||
public JavaScriptRegionWalker( |
|
||||||
JavaScriptAst ast, |
|
||||||
ICompilationUnit compilationUnit) |
|
||||||
{ |
|
||||||
this.ast = ast; |
|
||||||
this.compilationUnit = compilationUnit; |
|
||||||
} |
|
||||||
|
|
||||||
public void Walk() |
|
||||||
{ |
|
||||||
regions = new Stack<JavaScriptRegionStart>(); |
|
||||||
|
|
||||||
foreach (IToken token in ast.GetTokens()) { |
|
||||||
if (token.IsSingleLineComment()) { |
|
||||||
WalkComment(token); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void WalkComment(IToken token) |
|
||||||
{ |
|
||||||
if (JavaScriptRegionStart.IsRegionStart(token)) { |
|
||||||
WalkRegionStart(token); |
|
||||||
} else if (JavaScriptRegionEnd.IsRegionEnd(token)) { |
|
||||||
WalkRegionEnd(token); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void WalkRegionStart(IToken token) |
|
||||||
{ |
|
||||||
var regionStart = new JavaScriptRegionStart(token); |
|
||||||
regions.Push(regionStart); |
|
||||||
} |
|
||||||
|
|
||||||
void WalkRegionEnd(IToken token) |
|
||||||
{ |
|
||||||
if (regions.Count > 0) { |
|
||||||
JavaScriptRegionStart regionStart = regions.Pop(); |
|
||||||
|
|
||||||
var regionEnd = new JavaScriptRegionEnd(token); |
|
||||||
var region = new JavaScriptRegion(regionStart, regionEnd); |
|
||||||
region.AddRegion(compilationUnit.FoldingRegions); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Binary file not shown.
@ -1,29 +0,0 @@ |
|||||||
[The "BSD licence"] |
|
||||||
Copyright (c) 2005-2008 Terence Parr |
|
||||||
All rights reserved. |
|
||||||
|
|
||||||
Conversion to C#: |
|
||||||
Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc. |
|
||||||
All rights reserved. |
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without |
|
||||||
modification, are permitted provided that the following conditions |
|
||||||
are met: |
|
||||||
1. Redistributions of source code must retain the above copyright |
|
||||||
notice, this list of conditions and the following disclaimer. |
|
||||||
2. Redistributions in binary form must reproduce the above copyright |
|
||||||
notice, this list of conditions and the following disclaimer in the |
|
||||||
documentation and/or other materials provided with the distribution. |
|
||||||
3. The name of the author may not be used to endorse or promote products |
|
||||||
derived from this software without specific prior written permission. |
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
||||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
||||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
||||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
@ -1,3 +0,0 @@ |
|||||||
C# 3 Runtime for Antlr |
|
||||||
Antlr3.Runtime.dll |
|
||||||
http://www.tunnelvisionlabs.com/downloads/antlr/antlr-dotnet-tool-3.3.1.7705.7z |
|
@ -1,30 +0,0 @@ |
|||||||
Software License Agreement (BSD License) |
|
||||||
|
|
||||||
Copyright (c) 2008-2009, Xebic Research B.V. |
|
||||||
All rights reserved. |
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms, with or without modification, are |
|
||||||
permitted provided that the following conditions are met: |
|
||||||
|
|
||||||
* Redistributions of source code must retain the above |
|
||||||
copyright notice, this list of conditions and the |
|
||||||
following disclaimer. |
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above |
|
||||||
copyright notice, this list of conditions and the |
|
||||||
following disclaimer in the documentation and/or other |
|
||||||
materials provided with the distribution. |
|
||||||
|
|
||||||
* Neither the name of Xebic Research B.V. nor the names of its |
|
||||||
contributors may be used to endorse or promote products |
|
||||||
derived from this software without specific prior |
|
||||||
written permission of Xebic Research B.V. |
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
||||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
||||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
|
||||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
@ -1,28 +0,0 @@ |
|||||||
A complete ECMAScript 3 grammar for ANTLR 3 |
|
||||||
|
|
||||||
http://research.xebic.com/es3/ |
|
||||||
|
|
||||||
Licence: (BSD) - http://research.xebic.com/es3/license.txt |
|
||||||
|
|
||||||
Copyrights Xebic Research B.V. All rights reserved. |
|
||||||
Original work by Patrick Hulsmeijer. |
|
||||||
Please use the antlr-interest mailing list for questions. |
|
||||||
|
|
||||||
|
|
||||||
Download: |
|
||||||
Combined lexer and parser for AST creation ES3.g3 |
|
||||||
Treeparser template to walk the AST generated by ES3.g3 ES3Walker.g3 |
|
||||||
License license.txt |
|
||||||
C# Version C# |
|
||||||
All files ES3.zip |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
History |
|
||||||
|
|
||||||
2008-4-9: Initial release. |
|
||||||
2008-4-11: Solely targeting Java for simplicity sake. |
|
||||||
2008-4-15: Added license. Fixed two bugs: EOL in MultiLineComment should be treated as SEMIC, function bodies should accept functionDeclarations. |
|
||||||
2009-4-16: Updated license statements. |
|
||||||
2009-12-4: Added seperate C# version. |
|
||||||
2010-2-25: Updated license. |
|
@ -1,31 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.Reflection; |
|
||||||
|
|
||||||
// Information about this assembly is defined by the following
|
|
||||||
// attributes.
|
|
||||||
//
|
|
||||||
// change them to the information which is associated with the assembly
|
|
||||||
// you compile.
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("JavaScriptBinding.Tests")] |
|
||||||
[assembly: AssemblyDescription("JavaScript Language Binding Unit Tests")] |
|
||||||
[assembly: AssemblyConfiguration("")] |
|
||||||
[assembly: AssemblyTrademark("")] |
|
||||||
[assembly: AssemblyCulture("")] |
|
@ -1,66 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
|
||||||
<PropertyGroup> |
|
||||||
<ProjectGuid>{66B1741A-CCCE-4692-81EA-1D5D58ECC5E5}</ProjectGuid> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
<RootNamespace>JavaScriptBinding.Tests</RootNamespace> |
|
||||||
<AssemblyName>JavaScriptBinding.Tests</AssemblyName> |
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|
||||||
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
|
||||||
<PlatformTarget>x86</PlatformTarget> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
|
||||||
<DebugSymbols>True</DebugSymbols> |
|
||||||
<DebugType>Full</DebugType> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|
||||||
<DebugSymbols>False</DebugSymbols> |
|
||||||
<DebugType>None</DebugType> |
|
||||||
<Optimize>True</Optimize> |
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
|
||||||
<DefineConstants>TRACE</DefineConstants> |
|
||||||
</PropertyGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Reference Include="nunit.framework"> |
|
||||||
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath> |
|
||||||
</Reference> |
|
||||||
<Reference Include="System" /> |
|
||||||
<Reference Include="System.Xml" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
|
||||||
<Compile Include="Src\Helpers\FakeTextBuffer.cs" /> |
|
||||||
<Compile Include="Src\JavaScriptParserTests.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<Folder Include="Src" /> |
|
||||||
<Folder Include="Src\Helpers" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
|
||||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
|
||||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
|
||||||
<Name>ICSharpCode.Core</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
|
||||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\Project\JavaScriptBinding.csproj"> |
|
||||||
<Project>{062B7E01-AF3D-430D-BE33-17FF3EF4F647}</Project> |
|
||||||
<Name>JavaScriptBinding</Name> |
|
||||||
</ProjectReference> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
@ -1,77 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.SharpDevelop; |
|
||||||
|
|
||||||
namespace JavaScriptBinding.Tests.Helpers |
|
||||||
{ |
|
||||||
public class FakeTextBuffer : ITextBuffer |
|
||||||
{ |
|
||||||
public FakeTextBuffer(string text) |
|
||||||
{ |
|
||||||
this.Text = text; |
|
||||||
} |
|
||||||
|
|
||||||
#pragma warning disable 0067
|
|
||||||
public event EventHandler TextChanged; |
|
||||||
#pragma warning restore
|
|
||||||
|
|
||||||
public int TextLength { |
|
||||||
get { return Text.Length; } |
|
||||||
} |
|
||||||
|
|
||||||
public string Text { get; set; } |
|
||||||
|
|
||||||
public ITextBufferVersion Version { |
|
||||||
get { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ITextBuffer CreateSnapshot() |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public ITextBuffer CreateSnapshot(int offset, int length) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public System.IO.TextReader CreateReader() |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public System.IO.TextReader CreateReader(int offset, int length) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public char GetCharAt(int offset) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public string GetText(int offset, int length) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,522 +0,0 @@ |
|||||||
// Copyright (c) 2014 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.JavaScriptBinding; |
|
||||||
using ICSharpCode.SharpDevelop.Dom; |
|
||||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
using JavaScriptBinding.Tests.Helpers; |
|
||||||
using NUnit.Framework; |
|
||||||
|
|
||||||
namespace JavaScriptBinding.Tests |
|
||||||
{ |
|
||||||
[TestFixture] |
|
||||||
public class JavaScriptParserTests |
|
||||||
{ |
|
||||||
JavaScriptParser parser; |
|
||||||
ICompilationUnit compilationUnit; |
|
||||||
|
|
||||||
void CreateParser() |
|
||||||
{ |
|
||||||
parser = new JavaScriptParser(); |
|
||||||
} |
|
||||||
|
|
||||||
IProject CreateCSharpProject() |
|
||||||
{ |
|
||||||
var createInfo = new ProjectCreateInformation(); |
|
||||||
createInfo.Solution = new Solution(new MockProjectChangeWatcher()); |
|
||||||
createInfo.OutputProjectFileName = @"d:\projects\MyProject\MyProject.csproj"; |
|
||||||
return new MSBuildBasedProject(createInfo); |
|
||||||
} |
|
||||||
|
|
||||||
void ParseEmptyJavaScriptFileWithFileName(string fileName) |
|
||||||
{ |
|
||||||
ParseJavaScript(fileName, String.Empty); |
|
||||||
} |
|
||||||
|
|
||||||
void ParseEmptyJavaScriptFileWithProjectContent(IProjectContent projectContent) |
|
||||||
{ |
|
||||||
Parse(projectContent, String.Empty, String.Empty); |
|
||||||
} |
|
||||||
|
|
||||||
void ParseJavaScript(string code) |
|
||||||
{ |
|
||||||
ParseJavaScript("test.js", code); |
|
||||||
} |
|
||||||
|
|
||||||
void ParseJavaScript(string fileName, string code) |
|
||||||
{ |
|
||||||
var projectContent = new DefaultProjectContent(); |
|
||||||
Parse(projectContent, fileName, code); |
|
||||||
} |
|
||||||
|
|
||||||
void Parse(IProjectContent projectContent, string fileName, string code) |
|
||||||
{ |
|
||||||
var textBuffer = new FakeTextBuffer(code); |
|
||||||
CreateParser(); |
|
||||||
compilationUnit = parser.Parse(projectContent, fileName, textBuffer); |
|
||||||
} |
|
||||||
|
|
||||||
IClass FirstClass { |
|
||||||
get { return compilationUnit.Classes[0]; } |
|
||||||
} |
|
||||||
|
|
||||||
IMethod FirstClassFirstMethod { |
|
||||||
get { return FirstClass.Methods[0]; } |
|
||||||
} |
|
||||||
|
|
||||||
FoldingRegion FirstRegion { |
|
||||||
get { return compilationUnit.FoldingRegions[0]; } |
|
||||||
} |
|
||||||
|
|
||||||
FoldingRegion SecondRegion { |
|
||||||
get { return compilationUnit.FoldingRegions[1]; } |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CanParse_CSharpProjectPassed_ReturnsTrue() |
|
||||||
{ |
|
||||||
CreateParser(); |
|
||||||
IProject project = CreateCSharpProject(); |
|
||||||
bool result = parser.CanParse(project); |
|
||||||
|
|
||||||
Assert.IsTrue(result); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CanParse_JavaScriptFileNamePassed_ReturnsTrue() |
|
||||||
{ |
|
||||||
CreateParser(); |
|
||||||
bool result = parser.CanParse("test.js"); |
|
||||||
|
|
||||||
Assert.IsTrue(result); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CanParse_TextFileNamePassed_ReturnsFalse() |
|
||||||
{ |
|
||||||
CreateParser(); |
|
||||||
bool result = parser.CanParse("test.txt"); |
|
||||||
|
|
||||||
Assert.IsFalse(result); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CanParse_NullFileNamePassed_ReturnsFalse() |
|
||||||
{ |
|
||||||
CreateParser(); |
|
||||||
bool result = parser.CanParse((string)null); |
|
||||||
|
|
||||||
Assert.IsFalse(result); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CanParse_JavaScriptFileNameInUpperCasePassed_ReturnsTrue() |
|
||||||
{ |
|
||||||
CreateParser(); |
|
||||||
bool result = parser.CanParse("TEST.JS"); |
|
||||||
|
|
||||||
Assert.IsTrue(result); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_FileNamePassed_ReturnsCompilationUnitWithFileName() |
|
||||||
{ |
|
||||||
string expectedFileName = @"d:\projects\test\MyScript.js"; |
|
||||||
ParseEmptyJavaScriptFileWithFileName(expectedFileName); |
|
||||||
|
|
||||||
string fileName = compilationUnit.FileName; |
|
||||||
Assert.AreEqual(expectedFileName, fileName); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_ProjectContentPassed_ReturnsCompilationUnitWithProjectContent() |
|
||||||
{ |
|
||||||
var expectedProjectContent = new DefaultProjectContent(); |
|
||||||
ParseEmptyJavaScriptFileWithProjectContent(expectedProjectContent); |
|
||||||
|
|
||||||
IProjectContent projectContent = compilationUnit.ProjectContent; |
|
||||||
Assert.AreEqual(expectedProjectContent, projectContent); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunction_ReturnsOneClassInCompilationUnit() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function test() {\r\n " + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(1, compilationUnit.Classes.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunction_ClassNameIsFileNameWithoutExtension() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function test() {\r\n " + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript("myscript.js", code); |
|
||||||
|
|
||||||
string className = FirstClass.Name; |
|
||||||
|
|
||||||
Assert.AreEqual("myscript", className); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunction_ReturnsOneMethodInClass() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function test() {\r\n " + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
CreateParser(); |
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(1, FirstClass.Methods.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunction_MethodNameExistsInClass() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function test() {\r\n " + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
CreateParser(); |
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
string methodName = FirstClassFirstMethod.Name; |
|
||||||
|
|
||||||
Assert.AreEqual("test", methodName); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunctionCalledMyFunction_MethodNameExistsInClass() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function MyFunction() {\r\n " + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
string methodName = FirstClassFirstMethod.Name; |
|
||||||
|
|
||||||
Assert.AreEqual("MyFunction", methodName); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOnlyFunctionKeyword_NoMethodsParsed() |
|
||||||
{ |
|
||||||
string code = "function"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(0, FirstClass.Methods.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasFunctionKeywordAndFunctionNameOnly_NoOverflowExceptionThrown() |
|
||||||
{ |
|
||||||
string code = "function test"; |
|
||||||
|
|
||||||
Assert.DoesNotThrow(() => ParseJavaScript(code)); |
|
||||||
|
|
||||||
string methodName = FirstClassFirstMethod.Name; |
|
||||||
|
|
||||||
Assert.AreEqual("test", methodName); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasTwoFunctions_TwoMethodsReturned() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function one() { }\r\n" + |
|
||||||
"function two() { }\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
int count = FirstClass.Methods.Count; |
|
||||||
|
|
||||||
Assert.AreEqual(2, count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunctionSpanningThreeLines_MethodHeaderRegionCoversStartOfFunctionToMethodRightParenthesis() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function myfunction() {\r\n" + |
|
||||||
" alert('test');\r\n" + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
DomRegion methodHeaderRegion = FirstClassFirstMethod.Region; |
|
||||||
|
|
||||||
int beginLine = 1; |
|
||||||
int endLine = 1; |
|
||||||
int beginColumn = 1; |
|
||||||
int endColumn = 22; |
|
||||||
|
|
||||||
var expectedRegion = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedRegion, methodHeaderRegion); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneFunctionSpanningThreeLines_MethodBodyRegionCoversFunctionFromAfterParametersToRightBrace() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"function myfunction() {\r\n" + |
|
||||||
" alert('test');\r\n" + |
|
||||||
"}\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
DomRegion methodBodyRegion = FirstClassFirstMethod.BodyRegion; |
|
||||||
|
|
||||||
int beginLine = 1; |
|
||||||
int endLine = 3; |
|
||||||
int beginColumn = 22; |
|
||||||
int endColumn = 2; |
|
||||||
|
|
||||||
var expectedRegion = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedRegion, methodBodyRegion); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneRegion_OneFoldingRegionAddedToCompilationUnit() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region MyRegion\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
int count = compilationUnit.FoldingRegions.Count; |
|
||||||
|
|
||||||
Assert.AreEqual(1, count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneRegionWithName_FoldingRegionAddedWithName() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region MyRegion\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
string name = FirstRegion.Name; |
|
||||||
|
|
||||||
Assert.AreEqual("MyRegion", name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasNoRegions_NoFoldingRegionsAddedToCompilationUnit() |
|
||||||
{ |
|
||||||
string code = "var a = 1;"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
int count = compilationUnit.FoldingRegions.Count; |
|
||||||
|
|
||||||
Assert.AreEqual(0, count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeSingleCommentEndsWithRegionTextButDoesNotStartWithRegion_NoRegionsAddedToCompilationUnit() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//not a #region test\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//not an #endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(0, compilationUnit.FoldingRegions.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneRegion_RegionLocationIsSpecified() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region MyRegion\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
DomRegion location = FirstRegion.Region; |
|
||||||
|
|
||||||
int beginLine = 1; |
|
||||||
int endLine = 3; |
|
||||||
int beginColumn = 1; |
|
||||||
int endColumn = 13; |
|
||||||
|
|
||||||
var expectedLocation = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedLocation, location); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasRegionStartOnly_NoRegionsAddedToCompilationUnit() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region MyRegion\r\n" + |
|
||||||
"var a = 1;\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(0, compilationUnit.FoldingRegions.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasOneRegionWithEndRegionFollowedByText_TextFollowingEndRegionIsNotPartOfFold() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region MyRegion\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion abc\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
DomRegion location = FirstRegion.Region; |
|
||||||
|
|
||||||
int beginLine = 1; |
|
||||||
int endLine = 3; |
|
||||||
int beginColumn = 1; |
|
||||||
int endColumn = 13; |
|
||||||
|
|
||||||
var expectedLocation = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedLocation, location); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasTwoRegions_TwoRegionsAddedToCompilationUnit() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region One\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion\r\n" + |
|
||||||
"\r\n" + |
|
||||||
"//#region Two\r\n" + |
|
||||||
"var b = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(2, compilationUnit.FoldingRegions.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasTwoRegions_RegionsHaveCorrectLocationsAndNames() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region One\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion\r\n" + |
|
||||||
"\r\n" + |
|
||||||
"//#region Two\r\n" + |
|
||||||
"var b = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
DomRegion firstRegionLocation = FirstRegion.Region; |
|
||||||
|
|
||||||
int beginLine = 1; |
|
||||||
int endLine = 3; |
|
||||||
int beginColumn = 1; |
|
||||||
int endColumn = 13; |
|
||||||
|
|
||||||
var expectedFirstRegionLocation = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
DomRegion secondRegionLocation = SecondRegion.Region; |
|
||||||
|
|
||||||
beginLine = 5; |
|
||||||
endLine = 7; |
|
||||||
beginColumn = 1; |
|
||||||
endColumn = 13; |
|
||||||
|
|
||||||
var expectedSecondRegionLocation = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedFirstRegionLocation, firstRegionLocation); |
|
||||||
Assert.AreEqual("One", FirstRegion.Name); |
|
||||||
Assert.AreEqual(expectedSecondRegionLocation, secondRegionLocation); |
|
||||||
Assert.AreEqual("Two", SecondRegion.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasEndRegionButNoStartRegion_NoRegionsAddedToCompilationUnit() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
Assert.AreEqual(0, compilationUnit.FoldingRegions.Count); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void Parse_JavaScriptCodeHasTwoNestedRegions_RegionsHaveCorrectLocationsAndNames() |
|
||||||
{ |
|
||||||
string code = |
|
||||||
"//#region One\r\n" + |
|
||||||
"var a = 1;\r\n" + |
|
||||||
"//#region Two\r\n" + |
|
||||||
"var b = 1;\r\n" + |
|
||||||
"//#endregion\r\n" + |
|
||||||
"var c = 1;\r\n" + |
|
||||||
"//#endregion\r\n"; |
|
||||||
|
|
||||||
ParseJavaScript(code); |
|
||||||
|
|
||||||
DomRegion firstRegionLocation = FirstRegion.Region; |
|
||||||
|
|
||||||
int beginLine = 3; |
|
||||||
int endLine = 5; |
|
||||||
int beginColumn = 1; |
|
||||||
int endColumn = 13; |
|
||||||
|
|
||||||
var expectedFirstRegionLocation = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
DomRegion secondRegionLocation = SecondRegion.Region; |
|
||||||
|
|
||||||
beginLine = 1; |
|
||||||
endLine = 7; |
|
||||||
beginColumn = 1; |
|
||||||
endColumn = 13; |
|
||||||
|
|
||||||
var expectedSecondRegionLocation = new DomRegion(beginLine, beginColumn, endLine, endColumn); |
|
||||||
|
|
||||||
Assert.AreEqual(expectedFirstRegionLocation, firstRegionLocation); |
|
||||||
Assert.AreEqual("Two", FirstRegion.Name); |
|
||||||
Assert.AreEqual(expectedSecondRegionLocation, secondRegionLocation); |
|
||||||
Assert.AreEqual("One", SecondRegion.Name); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue