├── .gitignore ├── README.md ├── appveyor.yml ├── site ├── DisplayParametersInFunctionChain.png ├── MarksFontStyle.png ├── SettingsUI.png ├── hot.gif ├── html │ └── index.htm ├── menu_location.png ├── menu_location_old.png ├── new-icon-small.gif ├── npp │ └── npp.png ├── panel_top_menu.png ├── screen1.PNG ├── screen2.png ├── screen3.png ├── screen4.png ├── screen5.png ├── screen6.png ├── screen_FindExample.png ├── screen_define_shortcut.png ├── screen_expandcollapseoption.png ├── screen_optionsdialog.png ├── settings │ └── html-mixed.png ├── vs │ └── dark_theme.png ├── vs2010_errors_tasklist.png ├── vs2010_html.png └── vs2010_marks.png └── source ├── .editorconfig ├── JSparser.sln ├── Jint.Parser ├── Ast │ ├── ArrayExpression.cs │ ├── AssignmentExpression.cs │ ├── BinaryExpression.cs │ ├── BlockStatement.cs │ ├── BreakStatement.cs │ ├── CallExpression.cs │ ├── CatchClause.cs │ ├── ConditionalExpression.cs │ ├── ContinueStatement.cs │ ├── DebuggerStatement.cs │ ├── DoWhileStatement.cs │ ├── EmptyStatement.cs │ ├── Expression.cs │ ├── ExpressionStatement.cs │ ├── ForInStatement.cs │ ├── ForStatement.cs │ ├── FunctionDeclaration.cs │ ├── FunctionExpression.cs │ ├── IPropertyKeyExpression.cs │ ├── Identifier.cs │ ├── IfStatement.cs │ ├── LabeledStatement.cs │ ├── Literal.cs │ ├── LogicalExpression.cs │ ├── MemberExpression.cs │ ├── NewExpression.cs │ ├── ObjectExpression.cs │ ├── Program.cs │ ├── Property.cs │ ├── RegExpLiteral.cs │ ├── ReturnStatement.cs │ ├── SequenceExpression.cs │ ├── Statement.cs │ ├── SwitchCase.cs │ ├── SwitchStatement.cs │ ├── SyntaxNode.cs │ ├── SyntaxNodes.cs │ ├── ThisExpression.cs │ ├── ThrowStatement.cs │ ├── TryStatement.cs │ ├── UnaryExpression.cs │ ├── UpdateExpression.cs │ ├── VariableDeclaration.cs │ ├── VariableDeclarator.cs │ ├── WhileStatement.cs │ └── WithStatement.cs ├── Comment.cs ├── IFunctionDeclaration.cs ├── IFunctionScope.cs ├── IVariableScope.cs ├── JavascriptParser.cs ├── Jint.Parser.csproj ├── Key.snk ├── LICENSE.txt ├── Loc.cs ├── Messages.cs ├── ParserException.cs ├── ParserExtensions.cs ├── ParserOptions.cs ├── Position.cs ├── Properties │ └── AssemblyInfo.cs ├── State.cs ├── StringPrototype.cs └── Token.cs ├── JsParser.Core ├── Code │ ├── CodeNode.cs │ ├── CodeNodeComparer.cs │ ├── CodeNodeType.cs │ ├── CodeTransformer.cs │ └── ICodeProvider.cs ├── Helpers │ ├── CustomTraceListener.cs │ ├── ErrorHandler.cs │ ├── Hierachy.cs │ └── HierarchyComparer.cs ├── Infrastructure │ ├── JsParserEventsBroadcaster.cs │ └── JsParserService.cs ├── JsParser.Core.csproj ├── Key.snk ├── Parsers │ ├── CommentWrapper.cs │ ├── CommentsAgregator.cs │ ├── IJavascriptParser.cs │ ├── JSParserExtensions.cs │ ├── JSParserResult.cs │ ├── JavaScriptStructureParserV2.cs │ ├── JavascriptParser.cs │ ├── JavascriptParserSettings.cs │ ├── NodesPostProcessor.cs │ ├── ParserContext.cs │ ├── TaskListAggregator.cs │ └── TaskListItem.cs ├── Properties │ ├── AssemblyInfo.cs │ └── SharedAssemblyInfo.cs └── Search │ └── SearchHelper.cs ├── JsParser.NppPlugin ├── DllExport │ ├── DllExportAttribute.cs │ ├── Mono.Cecil.dll │ ├── NppPlugin.DllExport.MSBuild.dll │ ├── NppPlugin.DllExport.dll │ └── NppPlugin.DllExport.targets ├── Forms │ ├── PluginUiPanel.cs │ ├── PluginUiPanel.designer.cs │ └── PluginUiPanel.resx ├── Helpers │ └── TimerHelper.cs ├── JsMapParserPlugin.cs ├── JsMapParserPluginSettings.cs ├── JsParser.NppPlugin.csproj ├── NppCodeProvider.cs ├── NppPluginBaseInfrastructure │ ├── NppPluginBase.cs │ ├── NppPluginBaseExports.cs │ ├── NppPluginBaseSpecifics.cs │ └── NppPluginHelper.cs ├── Properties │ ├── AssemblyInfo.cs │ └── jsparsericon.bmp ├── Resources │ ├── Resources.Designer.cs │ └── Resources.resx ├── build │ └── readme.txt ├── packages.config └── tools │ └── ILMerge │ ├── ILMerge.exe │ ├── ILMerge.exe.config │ └── test.cmd ├── JsParser.Test ├── Comments │ └── XmlCommentsFormatterTest.cs ├── Find │ ├── FindDialogTest.cs │ └── SearchFinalTest.cs ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Form_ScanDir_Results.Designer.cs ├── Form_ScanDir_Results.cs ├── Form_ScanDir_Results.resx ├── Helpers │ ├── SimpleHierarchySerializer.cs │ ├── StringExtText.cs │ └── TestsHelper.cs ├── JsParser.Test.csproj ├── Key.snk ├── Parser │ ├── ExpectedResult │ │ ├── Frameworks │ │ │ ├── angular_v1.4.0-rc.2.txt │ │ │ ├── bootstrap.txt │ │ │ ├── jquery-2.1.4.txt │ │ │ ├── knockout-3.3.0.debug.txt │ │ │ └── ui-bootstrap-tpls-0.13.0.txt │ │ ├── HtmlScriptBlocks.txt │ │ ├── New │ │ │ ├── ArrayChain.txt │ │ │ ├── Assignment.txt │ │ │ ├── CallbackChain.txt │ │ │ ├── Comments.txt │ │ │ ├── DebuggerKeyword.txt │ │ │ ├── Es6_GetSet.txt │ │ │ ├── Es6_GetSet2.txt │ │ │ ├── FunctionsHierarchy.txt │ │ │ ├── FunctionsHierarchy2.txt │ │ │ ├── InlineOrDecralation.txt │ │ │ ├── ReturnStatement.txt │ │ │ └── TodoList.txt │ │ ├── Test1.txt │ │ ├── Test2.txt │ │ ├── Test3.txt │ │ ├── Test4.txt │ │ ├── Test4_2.txt │ │ ├── Test5.txt │ │ ├── Test5_1.txt │ │ ├── Test_Anonimous_In_Return_Statement.txt │ │ ├── Test_AnonymousSelfExecBlock.txt │ │ ├── Test_AspScriptCombiner.txt │ │ ├── Test_AspTagsReplace.txt │ │ ├── Test_Construct_Object_In_Return_Statement.txt │ │ ├── Test_DoubleAssign.txt │ │ ├── Test_FunctionWithPlainObject.txt │ │ ├── Test_Functions_In_CASE_Statement.txt │ │ ├── Test_Functions_In_IF_Statement.txt │ │ ├── Test_Functions_In_TryCatch_Statement.txt │ │ ├── Test_JSParserSkipHandling.txt │ │ ├── Test_JsonObject_StringPropNames.txt │ │ ├── Test_NewStatements.txt │ │ ├── Test_RazorSyntax.txt │ │ ├── Test_ReservedWords_Goto.txt │ │ ├── Test_StringContinuationCharacter.txt │ │ └── Test_StringScriptBlock.txt │ ├── JSParserTests_Frameworks.cs │ ├── JsParserTests.cs │ ├── JsParserTests_New.cs │ ├── Source │ │ ├── Frameworks │ │ │ ├── angular_v1.4.0-rc.2.js │ │ │ ├── bootstrap.js │ │ │ ├── jquery-2.1.4.js │ │ │ ├── knockout-3.3.0.debug.js │ │ │ └── ui-bootstrap-tpls-0.13.0.js │ │ ├── HtmlScriptBlocks.htm │ │ ├── New │ │ │ ├── ArrayChain.js │ │ │ ├── Assignment.js │ │ │ ├── CallbackChain.js │ │ │ ├── Comments.js │ │ │ ├── DebuggerKeyword.js │ │ │ ├── Es6_GetSet.js │ │ │ ├── Es6_GetSet2.js │ │ │ ├── FunctionsHierarchy.js │ │ │ ├── FunctionsHierarchy2.js │ │ │ ├── InlineOrDecralation.js │ │ │ ├── ReturnStatement.js │ │ │ └── TodoList.js │ │ ├── Test1.js │ │ ├── Test2.js │ │ ├── Test3.js │ │ ├── Test4.js │ │ ├── Test4_2.js │ │ ├── Test5.js │ │ ├── Test5_1.js │ │ ├── Test_Anonimous_In_Return_Statement.js │ │ ├── Test_AnonymousSelfExecBlock.js │ │ ├── Test_AnonymousWithNames.js │ │ ├── Test_AspScriptCombiner.aspx │ │ ├── Test_AspTagsReplace.aspx │ │ ├── Test_Construct_Object_In_Return_Statement.js │ │ ├── Test_DoubleAssign.js │ │ ├── Test_FunctionWithPlainObject.js │ │ ├── Test_Functions_In_CASE_Statement.js │ │ ├── Test_Functions_In_IF_Statement.js │ │ ├── Test_Functions_In_TryCatch_Statement.js │ │ ├── Test_HierarhizeOnPostProcessing.js │ │ ├── Test_JSParserSkipHandling.js │ │ ├── Test_JsonObject_StringPropNames.js │ │ ├── Test_NewStatements.js │ │ ├── Test_PropsInArrayStyleNames.js │ │ ├── Test_RazorSyntax.cshtml │ │ ├── Test_ReservedWords_Goto.js │ │ ├── Test_StringContinuationCharacter.js │ │ ├── Test_StringScriptBlock.js │ │ ├── Test_TernerStatements.js │ │ └── Test_XmlComments.js │ ├── TestRunner.cs │ ├── Tests.VisualState.xml │ └── Tests.nunit ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── SimpleCodeProvider.cs ├── SimpleHierarchySerializerTest │ └── SimpleHierarchySerializerTest.cs ├── Themes │ └── ThemeProviderTest.cs ├── app.config └── packages.config ├── JsParser.UI ├── Helpers │ ├── CommentTipFormatter.cs │ ├── ExpandedNodesManager.cs │ ├── SourceFileSpecificSettingsManager.cs │ ├── Statistics.cs │ ├── StatisticsManager.cs │ └── StatisticsSender.cs ├── Infrastructure │ ├── IJsParserToolWindow.cs │ └── JsParserToolWindowManager.cs ├── JsParser.UI.csproj ├── Key.snk ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.resx │ ├── Resources1.Designer.cs │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── Find-icon.png │ ├── SortAZ.png │ ├── arrow_left.gif │ ├── error_icon.png │ ├── flag_blue.gif │ ├── flag_green.gif │ ├── flag_orange.gif │ ├── flag_red.gif │ ├── flag_white.gif │ ├── function.png │ ├── icon_favourites.gif │ ├── js_file.gif │ ├── js_function.gif │ ├── jsp.png │ ├── list_settings.gif │ ├── menu.png │ ├── navCollapseArrow.gif │ ├── navExpandArrow.gif │ ├── quick-find.png │ ├── refresh.gif │ ├── setttings.png │ ├── statistics.jpg │ ├── task_List.png │ ├── tree.png │ ├── treeleaf_collapsed.png │ ├── treeleaf_expanded.png │ ├── type.png │ ├── undefined.png │ └── variable_declaration.gif ├── UI │ ├── ColorPicker.Designer.cs │ ├── ColorPicker.cs │ ├── ColorPicker.resx │ ├── ColorTable.cs │ ├── CustomPanel.cs │ ├── CustomTreeNode.cs │ ├── CustomTreeView.cs │ ├── FindDialog.Designer.cs │ ├── FindDialog.cs │ ├── FindDialog.resx │ ├── Form_SendStatisticsConfirmation.Designer.cs │ ├── Form_SendStatisticsConfirmation.cs │ ├── Form_SendStatisticsConfirmation.resx │ ├── JsParserSettingsControl.Designer.cs │ ├── JsParserSettingsControl.cs │ ├── JsParserSettingsControl.resx │ ├── NavigationTreeView.Designer.cs │ ├── NavigationTreeView.cs │ ├── NavigationTreeView.resx │ ├── Palette.cs │ ├── SettingsForm.Designer.cs │ ├── SettingsForm.cs │ ├── SettingsForm.resx │ ├── Theme.cs │ ├── ThemeEditor.Designer.cs │ ├── ThemeEditor.cs │ ├── ThemeEditor.resx │ └── ThemeProvider.cs ├── app.config ├── obj │ └── Debug │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs │ │ └── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs └── packages.config ├── JsParser.VsExtension ├── GlobalSuppressions.cs ├── Guids.cs ├── Infrastructure │ └── VS2010CodeProvider.cs ├── JsParser.Package.cs ├── JsParser.Package.vsct ├── JsParser.VsExtension.csproj ├── Key.snk ├── License.txt ├── OptionsUI │ └── OptionsPageCustom.cs ├── PkgCmdID.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── Images_24bit1.bmp │ ├── Resources.Designer.cs │ ├── Resources.resx │ └── error_icon.png ├── UI │ ├── ErrorsNotificationControl.xaml │ ├── ErrorsNotificationControl.xaml.cs │ ├── JSParserErrorsNotificationMarginFactory.cs │ ├── JSParserToolWindow.cs │ ├── JsParserNavTreeHolder.xaml │ └── JsParserNavTreeHolder.xaml.cs ├── VSPackage.resx ├── jsparser_icon.png ├── packages.config ├── screen_shot_mini.png └── source.extension.vsixmanifest ├── build-Release.cmd └── packages └── repositories.config /.gitignore: -------------------------------------------------------------------------------- 1 | source/*/obj/ 2 | source/*/bin/ 3 | *.user 4 | *.suo 5 | source/*.vsix 6 | /source/JsParser.NppPlugin/build/*.dll 7 | /source/JsParser.NppPlugin/build/*.exp 8 | /source/JsParser.NppPlugin/build/*.lib 9 | /source/JsParser.NppPlugin/build/*.pdb 10 | source/packages/* 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **UPDATE 13.06.2018:** This project could be considered as an obsolete. There are no plans to support/improve implementation unless new maintainer/contributor will appear. 2 | 3 | This is an extension for Visual Studio and Notepad++ for better JavaScript support. 4 | Here is a link to [Visual Studio Gallery](http://visualstudiogallery.msdn.microsoft.com/288a2b0f-1357-47b4-8215-1134c36bdf30). 5 | 6 | When you are editing an extremely large JavaScript files it's very useful to have some set of tools to improve development process and avoid possible bugs. 7 | To solve this problems I've created this extension. 8 | This extension works in 9 | * Visual Studio version: 2010-2015 10 | * Notepad++ version: 6.5 11 | 12 | Please check all functionality described here: [Functionality Guide](https://github.com/megaboich/jsparser/wiki/Functionality-Guide). 13 | You can also check [FAQ](https://github.com/megaboich/jsparser/wiki/Frequently-Asked-Questions). 14 | 15 | Current version is [![GitHub release](https://img.shields.io/github/release/megaboich/js-map-parser.svg)]() [Version History](https://github.com/megaboich/jsparser/wiki/Version-History) 16 | 17 | ![](https://raw.githubusercontent.com/megaboich/js-map-parser/master/site/vs/dark_theme.png) 18 | 19 | ![](https://raw.githubusercontent.com/megaboich/js-map-parser/master/site/npp/npp.png) 20 | 21 | 22 | -------------------------------------------------------------------------------- /site/DisplayParametersInFunctionChain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/DisplayParametersInFunctionChain.png -------------------------------------------------------------------------------- /site/MarksFontStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/MarksFontStyle.png -------------------------------------------------------------------------------- /site/SettingsUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/SettingsUI.png -------------------------------------------------------------------------------- /site/hot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/hot.gif -------------------------------------------------------------------------------- /site/menu_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/menu_location.png -------------------------------------------------------------------------------- /site/menu_location_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/menu_location_old.png -------------------------------------------------------------------------------- /site/new-icon-small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/new-icon-small.gif -------------------------------------------------------------------------------- /site/npp/npp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/npp/npp.png -------------------------------------------------------------------------------- /site/panel_top_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/panel_top_menu.png -------------------------------------------------------------------------------- /site/screen1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen1.PNG -------------------------------------------------------------------------------- /site/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen2.png -------------------------------------------------------------------------------- /site/screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen3.png -------------------------------------------------------------------------------- /site/screen4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen4.png -------------------------------------------------------------------------------- /site/screen5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen5.png -------------------------------------------------------------------------------- /site/screen6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen6.png -------------------------------------------------------------------------------- /site/screen_FindExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen_FindExample.png -------------------------------------------------------------------------------- /site/screen_define_shortcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen_define_shortcut.png -------------------------------------------------------------------------------- /site/screen_expandcollapseoption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen_expandcollapseoption.png -------------------------------------------------------------------------------- /site/screen_optionsdialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/screen_optionsdialog.png -------------------------------------------------------------------------------- /site/settings/html-mixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/settings/html-mixed.png -------------------------------------------------------------------------------- /site/vs/dark_theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/vs/dark_theme.png -------------------------------------------------------------------------------- /site/vs2010_errors_tasklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/vs2010_errors_tasklist.png -------------------------------------------------------------------------------- /site/vs2010_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/vs2010_html.png -------------------------------------------------------------------------------- /site/vs2010_marks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/site/vs2010_marks.png -------------------------------------------------------------------------------- /source/.editorconfig: -------------------------------------------------------------------------------- 1 | ; Top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ArrayExpression.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class ArrayExpression : Expression 6 | { 7 | public IEnumerable Elements; 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/AssignmentExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public enum AssignmentOperator 6 | { 7 | Assign, 8 | PlusAssign, 9 | MinusAssign, 10 | TimesAssign, 11 | DivideAssign, 12 | ModuloAssign, 13 | BitwiseAndAssign, 14 | BitwiseOrAssign, 15 | BitwiseXOrAssign, 16 | LeftShiftAssign, 17 | RightShiftAssign, 18 | UnsignedRightShiftAssign, 19 | } 20 | 21 | public class AssignmentExpression : Expression 22 | { 23 | public AssignmentOperator Operator; 24 | public Expression Left; 25 | public Expression Right; 26 | 27 | public static AssignmentOperator ParseAssignmentOperator(string op) 28 | { 29 | switch (op) 30 | { 31 | case "=": 32 | return AssignmentOperator.Assign; 33 | case "+=": 34 | return AssignmentOperator.PlusAssign; 35 | case "-=": 36 | return AssignmentOperator.MinusAssign; 37 | case "*=": 38 | return AssignmentOperator.TimesAssign; 39 | case "/=": 40 | return AssignmentOperator.DivideAssign; 41 | case "%=": 42 | return AssignmentOperator.ModuloAssign; 43 | case "&=": 44 | return AssignmentOperator.BitwiseAndAssign; 45 | case "|=": 46 | return AssignmentOperator.BitwiseOrAssign; 47 | case "^=": 48 | return AssignmentOperator.BitwiseXOrAssign; 49 | case "<<=": 50 | return AssignmentOperator.LeftShiftAssign; 51 | case ">>=": 52 | return AssignmentOperator.RightShiftAssign; 53 | case ">>>=": 54 | return AssignmentOperator.UnsignedRightShiftAssign; 55 | 56 | default: 57 | throw new ArgumentOutOfRangeException("Invalid assignment operator: " + op); 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/BinaryExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public enum BinaryOperator 6 | { 7 | Plus, 8 | Minus, 9 | Times, 10 | Divide, 11 | Modulo, 12 | Equal, 13 | NotEqual, 14 | Greater, 15 | GreaterOrEqual, 16 | Less, 17 | LessOrEqual, 18 | StrictlyEqual, 19 | StricltyNotEqual, 20 | BitwiseAnd, 21 | BitwiseOr, 22 | BitwiseXOr, 23 | LeftShift, 24 | RightShift, 25 | UnsignedRightShift, 26 | InstanceOf, 27 | In, 28 | } 29 | 30 | public class BinaryExpression : Expression 31 | { 32 | public BinaryOperator Operator; 33 | public Expression Left; 34 | public Expression Right; 35 | 36 | public static BinaryOperator ParseBinaryOperator(string op) 37 | { 38 | switch (op) 39 | { 40 | case "+": 41 | return BinaryOperator.Plus; 42 | case "-": 43 | return BinaryOperator.Minus; 44 | case "*": 45 | return BinaryOperator.Times; 46 | case "/": 47 | return BinaryOperator.Divide; 48 | case "%": 49 | return BinaryOperator.Modulo; 50 | case "==": 51 | return BinaryOperator.Equal; 52 | case "!=": 53 | return BinaryOperator.NotEqual; 54 | case ">": 55 | return BinaryOperator.Greater; 56 | case ">=": 57 | return BinaryOperator.GreaterOrEqual; 58 | case "<": 59 | return BinaryOperator.Less; 60 | case "<=": 61 | return BinaryOperator.LessOrEqual; 62 | case "===": 63 | return BinaryOperator.StrictlyEqual; 64 | case "!==": 65 | return BinaryOperator.StricltyNotEqual; 66 | case "&": 67 | return BinaryOperator.BitwiseAnd; 68 | case "|": 69 | return BinaryOperator.BitwiseOr; 70 | case "^": 71 | return BinaryOperator.BitwiseXOr; 72 | case "<<": 73 | return BinaryOperator.LeftShift; 74 | case ">>": 75 | return BinaryOperator.RightShift; 76 | case ">>>": 77 | return BinaryOperator.UnsignedRightShift; 78 | case "instanceof": 79 | return BinaryOperator.InstanceOf; 80 | case "in": 81 | return BinaryOperator.In; 82 | 83 | default: 84 | throw new ArgumentOutOfRangeException("Invalid binary operator: " + op); 85 | } 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/BlockStatement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class BlockStatement : Statement 6 | { 7 | public IEnumerable Body; 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/BreakStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class BreakStatement : Statement 4 | { 5 | public Identifier Label; 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/CallExpression.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class CallExpression : Expression 6 | { 7 | public Expression Callee; 8 | public IList Arguments; 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/CatchClause.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class CatchClause : Statement 4 | { 5 | public Identifier Param; 6 | public BlockStatement Body; 7 | } 8 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ConditionalExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ConditionalExpression : Expression 4 | { 5 | public Expression Test; 6 | public Expression Consequent; 7 | public Expression Alternate; 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ContinueStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ContinueStatement : Statement 4 | { 5 | public Identifier Label; 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/DebuggerStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class DebuggerStatement: Statement 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/DoWhileStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class DoWhileStatement : Statement 4 | { 5 | public Statement Body; 6 | public Expression Test; 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/EmptyStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class EmptyStatement : Statement 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/Expression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class Expression : SyntaxNode 4 | { 5 | // an expression represents an actual value 6 | // foo() is an expression, a switch/case is a statement 7 | } 8 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ExpressionStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ExpressionStatement : Statement 4 | { 5 | public Expression Expression; 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ForInStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ForInStatement : Statement 4 | { 5 | public SyntaxNode Left; 6 | public Expression Right; 7 | public Statement Body; 8 | public bool Each; 9 | } 10 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ForStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ForStatement : Statement 4 | { 5 | // can be a Statement (var i) or an Expression (i=0) 6 | public SyntaxNode Init; 7 | public Expression Test; 8 | public Expression Update; 9 | public Statement Body; 10 | } 11 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/FunctionDeclaration.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class FunctionDeclaration : Statement, IFunctionDeclaration 6 | { 7 | public FunctionDeclaration() 8 | { 9 | VariableDeclarations = new List(); 10 | } 11 | 12 | public Identifier Id { get; set; } 13 | public IEnumerable Parameters { get; set; } 14 | public Statement Body { get; set; } 15 | public bool Strict { get; set; } 16 | 17 | public IList VariableDeclarations { get; set; } 18 | 19 | #region ECMA6 20 | 21 | public IEnumerable Defaults; 22 | public SyntaxNode Rest; 23 | public bool Generator; 24 | public bool Expression; 25 | 26 | #endregion 27 | 28 | public IList FunctionDeclarations { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/FunctionExpression.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class FunctionExpression : Expression, IFunctionDeclaration 6 | { 7 | public FunctionExpression() 8 | { 9 | VariableDeclarations = new List(); 10 | } 11 | 12 | public Identifier Id { get; set; } 13 | public IEnumerable Parameters { get; set; } 14 | public Statement Body { get; set; } 15 | public bool Strict { get; set; } 16 | 17 | public IList VariableDeclarations { get; set; } 18 | public IList FunctionDeclarations { get; set; } 19 | 20 | #region ECMA6 21 | public IEnumerable Defaults; 22 | public SyntaxNode Rest; 23 | public bool Generator; 24 | public bool Expression; 25 | #endregion 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/IPropertyKeyExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | /// 4 | /// Reprensents an expression which can be a key of a Property 5 | /// 6 | public interface IPropertyKeyExpression 7 | { 8 | string GetKey(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/Identifier.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class Identifier : Expression, IPropertyKeyExpression 4 | { 5 | public string Name; 6 | 7 | public string GetKey() 8 | { 9 | return Name; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/IfStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class IfStatement : Statement 4 | { 5 | public Expression Test; 6 | public Statement Consequent; 7 | public Statement Alternate; 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/LabeledStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class LabelledStatement : Statement 4 | { 5 | public Identifier Label; 6 | public Statement Body; 7 | } 8 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/Literal.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class Literal : Expression, IPropertyKeyExpression 4 | { 5 | public object Value; 6 | public string Raw; 7 | 8 | public string GetKey() 9 | { 10 | return Value.ToString(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/LogicalExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public enum LogicalOperator 6 | { 7 | LogicalAnd, 8 | LogicalOr 9 | } 10 | 11 | public class LogicalExpression : Expression 12 | { 13 | public LogicalOperator Operator; 14 | public Expression Left; 15 | public Expression Right; 16 | 17 | public static LogicalOperator ParseLogicalOperator(string op) 18 | { 19 | switch (op) 20 | { 21 | case "&&": 22 | return LogicalOperator.LogicalAnd; 23 | case "||": 24 | return LogicalOperator.LogicalOr; 25 | 26 | default: 27 | throw new ArgumentOutOfRangeException("Invalid binary operator: " + op); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/MemberExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class MemberExpression : Expression 4 | { 5 | public Expression Object; 6 | public Expression Property; 7 | 8 | // true if an indexer is used and the property to be evaluated 9 | public bool Computed; 10 | } 11 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/NewExpression.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class NewExpression : Expression 6 | { 7 | public Expression Callee; 8 | public IEnumerable Arguments; 9 | } 10 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ObjectExpression.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class ObjectExpression : Expression 6 | { 7 | public IEnumerable Properties; 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class Program : Statement, IVariableScope, IFunctionScope 6 | { 7 | public Program() 8 | { 9 | VariableDeclarations = new List(); 10 | } 11 | public ICollection Body; 12 | 13 | public List Comments; 14 | public List Tokens; 15 | public List Errors; 16 | public bool Strict; 17 | 18 | public IList VariableDeclarations { get; set; } 19 | public IList FunctionDeclarations { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/Property.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | [Flags] 6 | public enum PropertyKind 7 | { 8 | Data = 1, 9 | Get = 2, 10 | Set = 4 11 | }; 12 | 13 | 14 | public class Property : Expression 15 | { 16 | public PropertyKind Kind; 17 | public IPropertyKeyExpression Key; 18 | public Expression Value; 19 | } 20 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/RegExpLiteral.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class RegExpLiteral : Expression, IPropertyKeyExpression 4 | { 5 | public object Value; 6 | public string Raw; 7 | public string Flags; 8 | 9 | public string GetKey() 10 | { 11 | return Value.ToString(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ReturnStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ReturnStatement : Statement 4 | { 5 | public Expression Argument; 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/SequenceExpression.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class SequenceExpression : Expression 6 | { 7 | public IList Expressions; 8 | } 9 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/Statement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class Statement : SyntaxNode 4 | { 5 | public string LabelSet; 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/SwitchCase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class SwitchCase : SyntaxNode 6 | { 7 | public Expression Test; 8 | public IEnumerable Consequent; 9 | } 10 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/SwitchStatement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class SwitchStatement : Statement 6 | { 7 | public Expression Discriminant; 8 | public IEnumerable Cases; 9 | } 10 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/SyntaxNode.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class SyntaxNode 6 | { 7 | public SyntaxNodes Type; 8 | public int[] Range; 9 | public Location Location; 10 | 11 | [DebuggerStepThrough] 12 | public T As() where T : SyntaxNode 13 | { 14 | return (T)this; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/SyntaxNodes.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public enum SyntaxNodes 4 | { 5 | AssignmentExpression, 6 | ArrayExpression, 7 | BlockStatement, 8 | BinaryExpression, 9 | BreakStatement, 10 | CallExpression, 11 | CatchClause, 12 | ConditionalExpression, 13 | ContinueStatement, 14 | DoWhileStatement, 15 | DebuggerStatement, 16 | EmptyStatement, 17 | ExpressionStatement, 18 | ForStatement, 19 | ForInStatement, 20 | FunctionDeclaration, 21 | FunctionExpression, 22 | Identifier, 23 | IfStatement, 24 | Literal, 25 | RegularExpressionLiteral, 26 | LabeledStatement, 27 | LogicalExpression, 28 | MemberExpression, 29 | NewExpression, 30 | ObjectExpression, 31 | Program, 32 | Property, 33 | ReturnStatement, 34 | SequenceExpression, 35 | SwitchStatement, 36 | SwitchCase, 37 | ThisExpression, 38 | ThrowStatement, 39 | TryStatement, 40 | UnaryExpression, 41 | UpdateExpression, 42 | VariableDeclaration, 43 | VariableDeclarator, 44 | WhileStatement, 45 | WithStatement 46 | }; 47 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ThisExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ThisExpression : Expression 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/ThrowStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ThrowStatement : Statement 4 | { 5 | public Expression Argument; 6 | } 7 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/TryStatement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class TryStatement : Statement 6 | { 7 | public Statement Block; 8 | public IEnumerable GuardedHandlers; 9 | public IEnumerable Handlers; 10 | public Statement Finalizer; 11 | } 12 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/UnaryExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public enum UnaryOperator 6 | { 7 | Plus, 8 | Minus, 9 | BitwiseNot, 10 | LogicalNot, 11 | Delete, 12 | Void, 13 | TypeOf, 14 | Increment, 15 | Decrement, 16 | } 17 | 18 | public class UnaryExpression : Expression 19 | { 20 | public UnaryOperator Operator; 21 | public Expression Argument; 22 | public bool Prefix; 23 | 24 | public static UnaryOperator ParseUnaryOperator(string op) 25 | { 26 | switch (op) 27 | { 28 | case "+": 29 | return UnaryOperator.Plus; 30 | case "-": 31 | return UnaryOperator.Minus; 32 | case "++": 33 | return UnaryOperator.Increment; 34 | case "--": 35 | return UnaryOperator.Decrement; 36 | case "~": 37 | return UnaryOperator.BitwiseNot; 38 | case "!": 39 | return UnaryOperator.LogicalNot; 40 | case "delete": 41 | return UnaryOperator.Delete; 42 | case "void": 43 | return UnaryOperator.Void; 44 | case "typeof": 45 | return UnaryOperator.TypeOf; 46 | 47 | default: 48 | throw new ArgumentOutOfRangeException("Invalid unary operator: " + op); 49 | 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/UpdateExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class UpdateExpression : UnaryExpression 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/VariableDeclaration.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser.Ast 4 | { 5 | public class VariableDeclaration : Statement 6 | { 7 | public IEnumerable Declarations; 8 | public string Kind; 9 | } 10 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/VariableDeclarator.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class VariableDeclarator : Expression 4 | { 5 | public Identifier Id; 6 | public Expression Init; 7 | } 8 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/WhileStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class WhileStatement : Statement 4 | { 5 | public Expression Test; 6 | public Statement Body; 7 | } 8 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Ast/WithStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class WithStatement : Statement 4 | { 5 | public Expression Object; 6 | public Statement Body; 7 | } 8 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Comment.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser 2 | { 3 | public class Comment 4 | { 5 | public Location Location; 6 | public int[] Range; 7 | public string Type; 8 | public string Value; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /source/Jint.Parser/IFunctionDeclaration.cs: -------------------------------------------------------------------------------- 1 | using Jint.Parser.Ast; 2 | using System.Collections.Generic; 3 | 4 | namespace Jint.Parser 5 | { 6 | public interface IFunctionDeclaration : IFunctionScope 7 | { 8 | Identifier Id { get; } 9 | IEnumerable Parameters { get; } 10 | Statement Body { get; } 11 | bool Strict { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /source/Jint.Parser/IFunctionScope.cs: -------------------------------------------------------------------------------- 1 | using Jint.Parser.Ast; 2 | using System.Collections.Generic; 3 | 4 | namespace Jint.Parser 5 | { 6 | /// 7 | /// Used to safe references to all function delcarations in a specific scope. 8 | /// 9 | public interface IFunctionScope: IVariableScope 10 | { 11 | IList FunctionDeclarations { get; set; } 12 | } 13 | 14 | public class FunctionScope : IFunctionScope 15 | { 16 | public FunctionScope() 17 | { 18 | FunctionDeclarations = new List(); 19 | } 20 | 21 | public IList FunctionDeclarations { get; set; } 22 | public IList VariableDeclarations { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /source/Jint.Parser/IVariableScope.cs: -------------------------------------------------------------------------------- 1 | using Jint.Parser.Ast; 2 | using System.Collections.Generic; 3 | 4 | namespace Jint.Parser 5 | { 6 | /// 7 | /// Used to safe references to all variable delcarations in a specific scope. 8 | /// Hoisting. 9 | /// 10 | public interface IVariableScope 11 | { 12 | IList VariableDeclarations { get; set; } 13 | } 14 | 15 | public class VariableScope : IVariableScope 16 | { 17 | public VariableScope() 18 | { 19 | VariableDeclarations = new List(); 20 | } 21 | 22 | public IList VariableDeclarations { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /source/Jint.Parser/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/Jint.Parser/Key.snk -------------------------------------------------------------------------------- /source/Jint.Parser/LICENSE.txt: -------------------------------------------------------------------------------- 1 | https://github.com/sebastienros/jint 2 | 3 | BSD 2-Clause License 4 | 5 | Copyright (c) 2013, Sebastien Ros 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | 12 | 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. 13 | 14 | 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 HOLDER 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. -------------------------------------------------------------------------------- /source/Jint.Parser/Loc.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser 2 | { 3 | public class Location 4 | { 5 | public Position Start; 6 | public Position End; 7 | public string Source; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /source/Jint.Parser/ParserException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Jint.Parser 4 | { 5 | public class ParserException : Exception 6 | { 7 | public int Column; 8 | public string Description; 9 | public int Index; 10 | public int LineNumber; 11 | public string Source; 12 | 13 | public ParserException(string message) : base(message) 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /source/Jint.Parser/ParserExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Jint.Parser 5 | { 6 | public static class ParserExtensions 7 | { 8 | public static string Slice(this string source, int start, int end) 9 | { 10 | return source.Substring(start, Math.Min(source.Length, end) - start); 11 | } 12 | 13 | public static char CharCodeAt(this string source, int index) 14 | { 15 | if (index < 0 || index > source.Length - 1) 16 | { 17 | // char.MinValue is used as the null value 18 | return char.MinValue; 19 | } 20 | 21 | return source[index]; 22 | } 23 | 24 | public static T Pop(this List list) 25 | { 26 | var lastIndex = list.Count - 1; 27 | var last = list[lastIndex]; 28 | list.RemoveAt(lastIndex); 29 | return last; 30 | } 31 | 32 | public static void Push(this List list, T item) 33 | { 34 | list.Add(item); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /source/Jint.Parser/ParserOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser 2 | { 3 | public class ParserOptions 4 | { 5 | public string Source { get; set; } 6 | public bool Tokens { get; set; } 7 | public bool Comment { get; set; } 8 | public bool Tolerant { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /source/Jint.Parser/Position.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser 2 | { 3 | public struct Position 4 | { 5 | public int Line; 6 | public int Column; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /source/Jint.Parser/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Jint.Parser")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Jint.Parser")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("e34fe255-d28c-42af-8c66-3656e8cf6af9")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /source/Jint.Parser/State.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Jint.Parser 4 | { 5 | public struct State 6 | { 7 | public int LastCommentStart; 8 | public bool AllowIn; 9 | public HashSet LabelSet; 10 | public bool InFunctionBody; 11 | public bool InIteration; 12 | public bool InSwitch; 13 | public Stack MarkerStack; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /source/Jint.Parser/StringPrototype.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Native.String 2 | { 3 | /// 4 | /// http://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4 5 | /// 6 | public sealed class StringPrototype 7 | { 8 | // http://msdn.microsoft.com/en-us/library/system.char.iswhitespace(v=vs.110).aspx 9 | // http://en.wikipedia.org/wiki/Byte_order_mark 10 | const char BOM_CHAR = '\uFEFF'; 11 | const char MONGOLIAN_VOWEL_SEPARATOR = '\u180E'; 12 | 13 | private static bool IsWhiteSpaceEx(char c) 14 | { 15 | return 16 | char.IsWhiteSpace(c) || 17 | c == BOM_CHAR || 18 | // In .NET 4.6 this was removed from WS based on Unicode 6.3 changes 19 | c == MONGOLIAN_VOWEL_SEPARATOR; 20 | } 21 | 22 | public static string TrimEndEx(string s) 23 | { 24 | if (s.Length == 0) 25 | return string.Empty; 26 | 27 | var i = s.Length - 1; 28 | while (i >= 0) 29 | { 30 | if (IsWhiteSpaceEx(s[i])) 31 | i--; 32 | else 33 | break; 34 | } 35 | if (i >= 0) 36 | return s.Substring(0, i + 1); 37 | else 38 | return string.Empty; 39 | } 40 | 41 | public static string TrimStartEx(string s) 42 | { 43 | if (s.Length == 0) 44 | return string.Empty; 45 | 46 | var i = 0; 47 | while (i < s.Length) 48 | { 49 | if (IsWhiteSpaceEx(s[i])) 50 | i++; 51 | else 52 | break; 53 | } 54 | if (i >= s.Length) 55 | return string.Empty; 56 | else 57 | return s.Substring(i); 58 | } 59 | 60 | public static string TrimEx(string s) 61 | { 62 | return TrimEndEx(TrimStartEx(s)); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /source/Jint.Parser/Token.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser 2 | { 3 | public enum Tokens 4 | { 5 | BooleanLiteral = 1, 6 | EOF = 2, 7 | Identifier = 3, 8 | Keyword = 4, 9 | NullLiteral = 5, 10 | NumericLiteral = 6, 11 | Punctuator = 7, 12 | StringLiteral = 8, 13 | RegularExpression = 9 14 | }; 15 | 16 | public class Token 17 | { 18 | public static Token Empty = new Token(); 19 | 20 | public Tokens Type; 21 | public string Literal; 22 | public object Value; 23 | public int[] Range; 24 | public int? LineNumber; 25 | public int LineStart; 26 | public bool Octal; 27 | public Location Location; 28 | public int Precedence; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /source/JsParser.Core/Code/CodeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace JsParser.Core.Code 5 | { 6 | /// 7 | /// The code node. 8 | /// 9 | public class CodeNode : IEquatable 10 | { 11 | /// 12 | /// Gets or sets Alias. 13 | /// 14 | public string Alias { get; set; } 15 | 16 | /// 17 | /// Gets or sets StartLine. 18 | /// 19 | public int StartLine { get; set; } 20 | 21 | /// 22 | /// Gets or sets EndLine. 23 | /// 24 | public int EndLine { get; set; } 25 | 26 | /// 27 | /// Gets or sets EndColumn. 28 | /// 29 | public int EndColumn { get; set; } 30 | 31 | /// 32 | /// Gets or sets StartPosition. 33 | /// 34 | public int StartColumn { get; set; } 35 | 36 | /// 37 | /// Gets or sets type of node 38 | /// 39 | public CodeNodeType NodeType { get; set; } 40 | 41 | /// 42 | /// Gets or sets The Comment. 43 | /// 44 | public string Comment { get; set; } 45 | 46 | private static IComparer _comparer = new CodeNodeComparer(); 47 | 48 | public CodeNode() 49 | { 50 | } 51 | 52 | public CodeNode(string alias, int startLine, int endLine, string comment = null, CodeNodeType type = CodeNodeType.Function) 53 | { 54 | Alias = alias; 55 | StartLine = startLine; 56 | EndLine = endLine; 57 | Comment = comment; 58 | NodeType = type; 59 | } 60 | 61 | public bool Equals(CodeNode other) 62 | { 63 | return _comparer.Compare(this, other) == 0; 64 | } 65 | 66 | public override bool Equals(Object obj) 67 | { 68 | return Equals(obj as CodeNode); 69 | } 70 | 71 | public override int GetHashCode() 72 | { 73 | unchecked // Overflow is fine, just wrap 74 | { 75 | int hash = 17; 76 | // Suitable nullity checks etc, of course :) 77 | hash = hash * 23 + StartLine.GetHashCode(); 78 | hash = hash * 23 + EndLine.GetHashCode(); 79 | hash = hash * 23 + (Alias ?? string.Empty).GetHashCode(); 80 | hash = hash * 23 + (Comment ?? string.Empty).GetHashCode(); 81 | hash = hash * 23 + NodeType.GetHashCode(); 82 | return hash; 83 | } 84 | } 85 | 86 | public static IComparer GetDefaultComparer() 87 | { 88 | return _comparer; 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /source/JsParser.Core/Code/CodeNodeComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace JsParser.Core.Code 4 | { 5 | /// 6 | /// The comparer for code node. 7 | /// 8 | public class CodeNodeComparer : Comparer 9 | { 10 | public override int Compare(CodeNode x, CodeNode y) 11 | { 12 | if (x == null || y == null) 13 | { 14 | return -1; 15 | } 16 | 17 | if (x.StartLine == y.StartLine 18 | && x.EndLine == y.EndLine 19 | && x.Alias == y.Alias 20 | && x.Comment == y.Comment 21 | && x.NodeType == y.NodeType) 22 | { 23 | return 0; 24 | } 25 | 26 | return -1; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /source/JsParser.Core/Code/CodeNodeType.cs: -------------------------------------------------------------------------------- 1 | namespace JsParser.Core.Code 2 | { 3 | public enum CodeNodeType 4 | { 5 | Function, 6 | AnonymousFunction, 7 | Object 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /source/JsParser.Core/Code/ICodeProvider.cs: -------------------------------------------------------------------------------- 1 | namespace JsParser.Core.Code 2 | { 3 | public interface ICodeProvider 4 | { 5 | string LoadCode(); 6 | 7 | string Path { get; } 8 | 9 | string Name { get; } 10 | 11 | string FullName { get; } 12 | 13 | string ContainerName { get; set; } 14 | 15 | void SelectionMoveToLineAndOffset(int startLine, int startColumn); 16 | 17 | void SetFocus(); 18 | 19 | void GetCursorPos(out int line, out int column); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /source/JsParser.Core/Helpers/CustomTraceListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | 5 | namespace JsParser.Core.Helpers 6 | { 7 | public class CustomTraceListener: TraceListener 8 | { 9 | private static object _lock = new object(); 10 | 11 | public override void Write(string message) 12 | { 13 | lock (_lock) 14 | { 15 | var logFilePath = "c:\\jsparser.log"; 16 | using (var f = File.AppendText(logFilePath)) 17 | { 18 | f.Write(string.Format("{0}:{1}", DateTime.Now, message)); 19 | } 20 | } 21 | } 22 | 23 | public override void WriteLine(string message) 24 | { 25 | Write(message + Environment.NewLine); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source/JsParser.Core/Helpers/ErrorHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace JsParser.Core.Helpers 5 | { 6 | public static class ErrorHandler 7 | { 8 | public static void WriteExceptionDetailsToTrace(string subj, Exception ex) 9 | { 10 | Trace.TraceError("{0}\r\nMessage: {1}\r\nSource: {2}\r\nStack Trace: {3}", subj, ex.Message, ex.Source, ex.StackTrace); 11 | if (ex.InnerException != null) 12 | { 13 | WriteExceptionDetailsToTrace("Inner exception:", ex.InnerException); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /source/JsParser.Core/Helpers/Hierachy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace JsParser.Core.Helpers 5 | { 6 | /// 7 | /// Represents a hierarchy template. 8 | /// 9 | /// 10 | /// Type of objects used in hierarchy. 11 | /// 12 | [Serializable] 13 | public class Hierarchy 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// 19 | /// The item to be stored. 20 | /// 21 | /// 22 | /// The parent. 23 | /// 24 | public Hierarchy(T item) 25 | { 26 | Item = item; 27 | } 28 | 29 | /// 30 | /// Prevents a default instance of the class from being created. 31 | /// 32 | private Hierarchy() 33 | { 34 | } 35 | 36 | /// 37 | /// Gets or sets Item. 38 | /// 39 | public T Item { get; set; } 40 | 41 | /// 42 | /// Gets or sets Childrens. 43 | /// 44 | public List> Children { get; set; } 45 | 46 | /// 47 | /// Gets a value indicating whether HasChildren. 48 | /// 49 | public bool HasChildren 50 | { 51 | get 52 | { 53 | return Children != null && Children.Count > 0; 54 | } 55 | } 56 | 57 | /// 58 | /// Adds set of childrens to current hierarchy node. 59 | /// 60 | /// 61 | /// The childs. 62 | /// 63 | public void Add(IEnumerable childs) 64 | { 65 | foreach (T child in childs) 66 | { 67 | Add(child); 68 | } 69 | } 70 | 71 | /// 72 | /// Adds one child to current hierarchy node. 73 | /// 74 | /// 75 | /// The child. 76 | /// 77 | /// 78 | /// The add children. 79 | /// 80 | public Hierarchy Add(T child) 81 | { 82 | var h = new Hierarchy(child); 83 | 84 | if (Children == null) 85 | { 86 | Children = new List>(); 87 | } 88 | 89 | Children.Add(h); 90 | return h; 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /source/JsParser.Core/Helpers/HierarchyComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace JsParser.Core.Helpers 4 | { 5 | public static class HierarchyComparer 6 | { 7 | /// 8 | /// Compares two hierarchies 9 | /// 10 | /// Type of hierarchy item 11 | /// One hierarchy 12 | /// Other hierarchy 13 | /// True if equals, false otherwise 14 | public static bool Compare(Hierarchy one, Hierarchy other, IComparer comparer) 15 | { 16 | if (one == null || other == null) 17 | { 18 | return false; 19 | } 20 | 21 | if (comparer.Compare(one.Item, other.Item) != 0) 22 | { 23 | return false; 24 | } 25 | 26 | int oneCount = one.Children != null ? one.Children.Count : 0; 27 | int otherCount = other.Children != null ? other.Children.Count : 0; 28 | 29 | if (oneCount == 0 && otherCount == 0) 30 | { 31 | return true; 32 | } 33 | 34 | if (oneCount != otherCount) 35 | { 36 | return false; 37 | } 38 | 39 | for (int index = 0; index < oneCount; ++index) 40 | { 41 | if (!HierarchyComparer.Compare(one.Children[index], other.Children[index], comparer)) 42 | { 43 | return false; 44 | } 45 | } 46 | 47 | return true; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source/JsParser.Core/Infrastructure/JsParserService.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using JsParser.Core.Parsers; 3 | using System; 4 | using System.IO; 5 | using System.Security.Cryptography; 6 | using System.Text; 7 | 8 | namespace JsParser.Core.Infrastructure 9 | { 10 | public class JsParserService 11 | { 12 | private string _loadedCodeHash; 13 | private readonly IJavascriptParserSettings _settings; 14 | 15 | public JsParserService(IJavascriptParserSettings settings) 16 | { 17 | _settings = settings; 18 | } 19 | 20 | /// 21 | /// Gets Code. 22 | /// 23 | public ICodeProvider Code { get; private set; } 24 | 25 | public void InvalidateCash() 26 | { 27 | _loadedCodeHash = null; 28 | } 29 | 30 | public JSParserResult Process(ICodeProvider codeProvider, bool skipHashCheck = false) 31 | { 32 | Code = codeProvider; 33 | string docName = Path.Combine(Code.Path, Code.Name); 34 | 35 | if (!CheckExt(docName)) 36 | { 37 | return null; 38 | } 39 | 40 | var code = Code.LoadCode(); 41 | var hash = Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.Default.GetBytes(code))); 42 | if (!skipHashCheck && _loadedCodeHash == hash) 43 | { 44 | return new JSParserResult(); 45 | } 46 | _loadedCodeHash = hash; 47 | 48 | var result = (new JavascriptParser(_settings)).Parse(code, docName); 49 | result.FileName = docName; 50 | return result; 51 | } 52 | 53 | private bool CheckExt(string fileName) 54 | { 55 | if (_settings.Extensions.Count > 0) 56 | { 57 | var currentExt = Path.GetExtension(fileName).SafeTrimStart('.'); 58 | foreach (var ext in _settings.Extensions) 59 | { 60 | if (string.Compare(currentExt, ext, StringComparison.InvariantCultureIgnoreCase) == 0) 61 | { 62 | return true; 63 | } 64 | } 65 | 66 | return false; 67 | } 68 | 69 | return true; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /source/JsParser.Core/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.Core/Key.snk -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/CommentWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace JsParser.Core.Parsers 2 | { 3 | public class CommentWrapper 4 | { 5 | public string Spelling { get; set; } 6 | public int StartLine { get; set; } 7 | public int EndLine { get; set; } 8 | public bool Processed { get; set; } 9 | 10 | public CommentWrapper(Jint.Parser.Comment orig) 11 | { 12 | Spelling = orig.Value; 13 | StartLine = orig.Location.Start.Line; 14 | EndLine = orig.Location.End.Line; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/CommentsAgregator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace JsParser.Core.Parsers 6 | { 7 | internal class CommentsAgregator 8 | { 9 | private List _comments; 10 | 11 | public IList Comments 12 | { 13 | get 14 | { 15 | return _comments.AsReadOnly(); 16 | } 17 | } 18 | 19 | public void ProcessComments(IEnumerable rawComments) 20 | { 21 | _comments = new List(); 22 | CommentWrapper prevCom = null; 23 | 24 | // Combine comments on neighbour lines to comment groups 25 | foreach(var currentCom in rawComments) 26 | { 27 | if (prevCom != null) 28 | { 29 | if (prevCom.EndLine == currentCom.StartLine - 1) 30 | { 31 | prevCom.Spelling = prevCom.Spelling + Environment.NewLine + currentCom.Spelling; 32 | prevCom.EndLine = currentCom.EndLine; 33 | } 34 | else 35 | { 36 | _comments.Add(currentCom); 37 | prevCom = currentCom; 38 | } 39 | } 40 | else 41 | { 42 | _comments.Add(currentCom); 43 | prevCom = currentCom; 44 | } 45 | } 46 | } 47 | 48 | public string GetComment(int startline, int endline) 49 | { 50 | var result = new List(); 51 | foreach (var comment in _comments.Where(c => !c.Processed)) 52 | { 53 | if (comment.EndLine == startline // The same line 54 | || comment.EndLine == startline - 1 // The prev line 55 | || comment.StartLine == startline + 1 // The next line 56 | ) 57 | { 58 | result.Add(comment.Spelling); 59 | comment.Processed = true; 60 | } 61 | } 62 | 63 | var r = string.Join(Environment.NewLine, result.ToArray()); 64 | if (string.IsNullOrEmpty(r.Trim())) 65 | { 66 | return null; 67 | } 68 | 69 | return r.Trim(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/IJavascriptParser.cs: -------------------------------------------------------------------------------- 1 | namespace JsParser.Core.Parsers 2 | { 3 | public interface IJavascriptParser 4 | { 5 | /// 6 | /// Parse JavaScript 7 | /// 8 | /// string with JavaScript code 9 | /// 10 | /// 11 | JSParserResult Parse(string code, string filename); 12 | } 13 | } -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/JSParserExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using System.Linq; 5 | 6 | namespace JsParser.Core.Parsers 7 | { 8 | public static class JsParserExtensions 9 | { 10 | public static string SafeTrimStart(this string s, char symbol) 11 | { 12 | if (string.IsNullOrEmpty(s)) 13 | { 14 | return string.Empty; 15 | } 16 | 17 | return s.TrimStart(symbol); 18 | } 19 | 20 | public static string Shortenize(this String s, int targetLength) 21 | { 22 | if (targetLength <= 0) 23 | { 24 | return string.Empty; 25 | } 26 | 27 | if (s.Length > targetLength) 28 | { 29 | var si = (int) 2*(targetLength/3); 30 | s = s.Substring(0, si) + '\x2026' + s.Substring(s.Length + 1 - targetLength + si); 31 | } 32 | 33 | return s; 34 | } 35 | 36 | /// 37 | /// Transform input string by adding spaces where words should be separeated. 38 | /// Example: "ThisStringShouldBeSeparated" => "This String Shoud Be Separated" 39 | /// 40 | /// 41 | /// 42 | public static string SplitWordsByCamelCase(this String s) 43 | { 44 | if (string.IsNullOrEmpty(s)) 45 | { 46 | return s; 47 | } 48 | 49 | var chars = s.ToList(); 50 | for (int charIndex = 0; charIndex < chars.Count; charIndex++) 51 | { 52 | if (char.IsUpper(chars[charIndex])) 53 | { 54 | chars.Insert(charIndex, ' '); 55 | charIndex++; 56 | } 57 | } 58 | 59 | return new string(chars.ToArray()).Trim(); 60 | } 61 | 62 | public static StringCollection ToStringCollection(this string[] strings) 63 | { 64 | var sc = new StringCollection(); 65 | sc.AddRange(strings); 66 | return sc; 67 | } 68 | 69 | public static IEnumerable GetEnumerable(this StringCollection sc) 70 | { 71 | foreach (var s in sc) 72 | { 73 | yield return s; 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/JSParserResult.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using JsParser.Core.Helpers; 3 | using System.Collections.Generic; 4 | 5 | namespace JsParser.Core.Parsers 6 | { 7 | public class JSParserResult 8 | { 9 | public string FileName { get; set; } 10 | 11 | public Hierarchy Nodes { get; set; } 12 | 13 | public List Errors { get; set; } 14 | 15 | public List InternalErrors { get; set; } 16 | 17 | public List TaskList { get; set; } 18 | 19 | public JSParserResult() 20 | { 21 | Nodes = new Hierarchy(new CodeNode(){Alias = "All"}); 22 | Errors = new List(); 23 | InternalErrors = new List(); 24 | TaskList = new List(); 25 | } 26 | 27 | /// 28 | /// Get the IsEmpty flag. If so then result is empty - probably service returned empty result when there is not need to update previous. 29 | /// 30 | public bool IsEmpty 31 | { 32 | get { return string.IsNullOrEmpty(FileName); } 33 | } 34 | } 35 | 36 | public class ErrorMessage 37 | { 38 | public string Message { get; set; } 39 | 40 | public int StartLine { get; set; } 41 | 42 | public int StartColumn { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/JavascriptParser.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using System.IO; 3 | 4 | namespace JsParser.Core.Parsers 5 | { 6 | /// 7 | /// The JavaScript parser. 8 | /// 9 | public class JavascriptParser : IJavascriptParser 10 | { 11 | private readonly IJavascriptParserSettings _settings; 12 | 13 | public JavascriptParser(IJavascriptParserSettings settings) 14 | { 15 | _settings = settings; 16 | } 17 | 18 | /// 19 | /// Parse JavaScript 20 | /// 21 | public JSParserResult Parse(string code, string filename) 22 | { 23 | // Get extension 24 | var ext = Path.GetExtension(filename).ToLower(); 25 | if (ext.StartsWith(".")) 26 | { 27 | ext = ext.Substring(1); 28 | } 29 | 30 | code = CodeTransformer.ApplyJSParserSkip(code); 31 | 32 | code = CodeTransformer.FixStringScriptBlocks(code); 33 | 34 | if (_settings.FixAspNetTags && _settings.FixAspNetTagsExtensions.Contains(ext)) 35 | { 36 | code = CodeTransformer.KillAspNetTags(code); 37 | } 38 | if (_settings.FixRazorSyntax && _settings.FixRazorSyntaxExtensions.Contains(ext)) 39 | { 40 | code = CodeTransformer.FixRazorSyntax(code); 41 | } 42 | 43 | if (_settings.ScriptStripEnabled && _settings.ScriptStripExtensions.Contains(ext)) 44 | { 45 | var foundScriptBlocks = CodeTransformer.ExtractJsFromSource(ref code); 46 | 47 | if (!foundScriptBlocks) //empty file 48 | { 49 | return ParseInternal(string.Empty); 50 | } 51 | } 52 | 53 | var result = ParseInternal(code); 54 | 55 | if (_settings.HideAnonymousFunctions) 56 | { 57 | NodesPostProcessor.HideAnonymousFunctions(result.Nodes); 58 | } 59 | 60 | return result; 61 | } 62 | 63 | /// 64 | /// The parse. 65 | /// 66 | /// 67 | /// The JavaScript script. 68 | /// 69 | /// 70 | /// Hierarchy with code structure. 71 | /// 72 | private JSParserResult ParseInternal(string sourceCode) 73 | { 74 | var parser = new JavascriptStructureParserV2(_settings); 75 | return parser.Parse(sourceCode); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/NodesPostProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace JsParser.Core.Parsers 2 | { 3 | using JsParser.Core.Code; 4 | using JsParser.Core.Helpers; 5 | 6 | /// 7 | /// Process nodes hierarchy after parsing to improve structure 8 | /// 9 | public static class NodesPostProcessor 10 | { 11 | public static bool HideAnonymousFunctions(Hierarchy hierachy) 12 | { 13 | if (hierachy.HasChildren) 14 | { 15 | hierachy.Children.RemoveAll(child => HideAnonymousFunctions(child)); 16 | } 17 | 18 | if (hierachy.HasChildren) 19 | { 20 | return false; 21 | } 22 | 23 | if (hierachy.Item.NodeType == CodeNodeType.AnonymousFunction) 24 | { 25 | return true; 26 | } 27 | 28 | return false; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/ParserContext.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using JsParser.Core.Helpers; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace JsParser.Core.Parsers 7 | { 8 | public class ParserContext 9 | { 10 | public ParserContext(ParserContext context, bool copyNames = false) 11 | :this(context.Nodes) 12 | { 13 | if (copyNames) 14 | { 15 | NameStack.AddRange(context.NameStack); 16 | } 17 | } 18 | 19 | public ParserContext(Hierarchy nodes) 20 | { 21 | Nodes = nodes; 22 | NameStack = new List(); 23 | } 24 | 25 | public Hierarchy Nodes { get; set; } 26 | 27 | public List NameStack { get; set; } 28 | 29 | public string GetNameFromStack() 30 | { 31 | if (NameStack != null && NameStack.Count > 0) 32 | { 33 | if (NameStack.Count == 1) 34 | { 35 | return NameStack[0]; 36 | } 37 | 38 | var sb = new StringBuilder(); 39 | for (var i = NameStack.Count - 1; i > 0; i--) 40 | { 41 | sb.Append(NameStack[i]); 42 | if (NameStack[i - 1] == "?") 43 | { 44 | sb.Append(">"); 45 | } 46 | else 47 | { 48 | sb.Append("."); 49 | } 50 | } 51 | 52 | sb.Append(NameStack[0]); 53 | return sb.ToString(); 54 | } 55 | else 56 | { 57 | return "?"; 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/TaskListAggregator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace JsParser.Core.Parsers 6 | { 7 | public static class TaskListAggregator 8 | { 9 | public static IEnumerable GetTaskList(IEnumerable comments, IEnumerable todokeywords) 10 | { 11 | return comments. 12 | Select(c => { 13 | foreach (var kw in todokeywords) 14 | { 15 | var todoIndex = c.Spelling.IndexOf(kw, StringComparison.InvariantCultureIgnoreCase); 16 | if (todoIndex >= 0) 17 | { 18 | var todoClause = c.Spelling.Substring(todoIndex); 19 | var endIndex = todoClause.IndexOfAny(new[] { '\r', '\n' }); 20 | if (endIndex >= 0) 21 | { 22 | todoClause = todoClause.Substring(0, endIndex); 23 | } 24 | 25 | return new TaskListItem 26 | { 27 | Description = todoClause, 28 | StartLine = c.StartLine, 29 | StartColumn = 0 30 | }; 31 | } 32 | } 33 | 34 | return null; 35 | }) 36 | .Where(c => c != null); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /source/JsParser.Core/Parsers/TaskListItem.cs: -------------------------------------------------------------------------------- 1 | namespace JsParser.Core.Parsers 2 | { 3 | public class TaskListItem 4 | { 5 | public string Description { get; set; } 6 | 7 | public int StartLine { get; set; } 8 | 9 | public int StartColumn { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /source/JsParser.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | // General Information about an assembly is controlled through the following 4 | // set of attributes. Change these attribute values to modify the information 5 | // associated with an assembly. 6 | [assembly: AssemblyTitle("JsParser.Core")] 7 | [assembly: AssemblyProduct("JsParser.Core")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | 11 | -------------------------------------------------------------------------------- /source/JsParser.Core/Properties/SharedAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyCompany("Oleksandr Boiko")] 8 | [assembly: AssemblyCopyright("Oleksandr Boiko 2017")] 9 | [assembly: AssemblyTrademark("")] 10 | [assembly: AssemblyCulture("")] 11 | 12 | [assembly: ComVisible(false)] 13 | 14 | // Version information for an assembly consists of the following four values: 15 | // 16 | // Major Version 17 | // Minor Version 18 | // Build Number 19 | // Revision 20 | // 21 | // You can specify all the values or you can default the Build and Revision Numbers 22 | // by using the '*' as shown below: 23 | [assembly: AssemblyVersion("4.2")] 24 | [assembly: AssemblyFileVersion("4.2")] 25 | -------------------------------------------------------------------------------- /source/JsParser.Core/Search/SearchHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace JsParser.Core.Search 6 | { 7 | public static class SearchHelper 8 | { 9 | static char[] _separators = new[] { '.', '|', '^', '?', '!', '$', '(', ')', '\'', '"', ',', ';', ' ', '-', '>', '<' }; 10 | 11 | public static IEnumerable SplitFunctionName(string fname) 12 | { 13 | var res = fname 14 | .Split(_separators, StringSplitOptions.RemoveEmptyEntries) 15 | .Where(ch => !string.IsNullOrEmpty(ch.Trim())); 16 | 17 | return res 18 | .SelectMany(r => SplitByUpperCaseWording(r)) 19 | .Where(s => !string.IsNullOrEmpty(s.Trim())); 20 | } 21 | 22 | private static IEnumerable SplitByUpperCaseWording(string fname) 23 | { 24 | var lastUpperIndex = 0; 25 | var counter = 0; 26 | for (int index = 0; index < fname.Length; ++index) 27 | { 28 | if (char.IsUpper(fname[index]) || 29 | char.IsDigit(fname[index])) 30 | { 31 | var tl = lastUpperIndex; 32 | lastUpperIndex = index; 33 | ++counter; 34 | yield return fname.Substring(tl, index - tl); 35 | } 36 | } 37 | 38 | yield return fname.Substring(lastUpperIndex, fname.Length - lastUpperIndex); 39 | } 40 | 41 | public static IEnumerable GetMatches(IEnumerable source, Func nameDelegate, string input) 42 | { 43 | var inputSet = SearchHelper.SplitFunctionName(input).ToList(); 44 | 45 | var res = source 46 | .Select(item => new { 47 | item = item, 48 | count = CompareEntities(inputSet, SearchHelper.SplitFunctionName(nameDelegate(item)).ToList()) 49 | }) 50 | .Where(i => i.count > 0) 51 | .OrderByDescending(i => i.count) 52 | .Select(i => i.item); 53 | 54 | return res; 55 | } 56 | 57 | public static int CompareEntities(IList input, IList test) 58 | { 59 | int encounters = 0; 60 | foreach (var inputPart in input) 61 | { 62 | bool hasMatch = false; 63 | foreach (var testPart in test) 64 | { 65 | if (testPart.StartsWith(inputPart, StringComparison.InvariantCultureIgnoreCase)) 66 | { 67 | ++encounters; 68 | hasMatch = true; 69 | } 70 | } 71 | 72 | if (!hasMatch) 73 | { 74 | // all input tokens must be present in test 75 | return 0; 76 | } 77 | } 78 | 79 | return encounters; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/DllExportAttribute.cs: -------------------------------------------------------------------------------- 1 | // NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc. 2 | using System; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace NppPlugin.DllExport 6 | { 7 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 8 | partial class DllExportAttribute : Attribute 9 | { 10 | public DllExportAttribute() 11 | { 12 | } 13 | 14 | public DllExportAttribute(string exportName) 15 | : this(exportName, CallingConvention.StdCall) 16 | { 17 | } 18 | 19 | public DllExportAttribute(string exportName, CallingConvention callingConvention) 20 | { 21 | ExportName = exportName; 22 | CallingConvention = callingConvention; 23 | } 24 | 25 | public CallingConvention CallingConvention { get; set; } 26 | 27 | public string ExportName { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.NppPlugin/DllExport/Mono.Cecil.dll -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.MSBuild.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.MSBuild.dll -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.dll -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.targets: -------------------------------------------------------------------------------- 1 |  3 | 5 | 8 | 9 | 11 | $(DevEnvDir)\..\..\VC\bin 12 | 13 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/Forms/PluginUiPanel.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace JsMapParser.NppPlugin.Forms 4 | { 5 | partial class PluginUiPanel : Form 6 | { 7 | public PluginUiPanel() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/Forms/PluginUiPanel.designer.cs: -------------------------------------------------------------------------------- 1 | namespace JsMapParser.NppPlugin.Forms 2 | { 3 | partial class PluginUiPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.navigationTreeView1 = new JsParser.UI.UI.NavigationTreeView(); 32 | this.SuspendLayout(); 33 | // 34 | // navigationTreeView1 35 | // 36 | this.navigationTreeView1.Dock = System.Windows.Forms.DockStyle.Fill; 37 | this.navigationTreeView1.Location = new System.Drawing.Point(0, 0); 38 | this.navigationTreeView1.Name = "navigationTreeView1"; 39 | this.navigationTreeView1.Size = new System.Drawing.Size(197, 420); 40 | this.navigationTreeView1.TabIndex = 0; 41 | // 42 | // PluginPanel 43 | // 44 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 45 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 46 | this.ClientSize = new System.Drawing.Size(197, 420); 47 | this.Controls.Add(this.navigationTreeView1); 48 | this.DoubleBuffered = true; 49 | this.Name = "PluginUiPanel"; 50 | this.Text = "PluginPanel"; 51 | this.ResumeLayout(false); 52 | 53 | } 54 | 55 | #endregion 56 | 57 | public JsParser.UI.UI.NavigationTreeView navigationTreeView1; 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | } 66 | } -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/Helpers/TimerHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | 5 | namespace JsMapParser.NppPlugin.Helpers 6 | { 7 | public static class TimerHelper 8 | { 9 | /// 10 | /// Storage to keep references to timer objects. We need them to call dispose later and Garbage Collector will not dispose any timers in meantime 11 | /// 12 | private static readonly Dictionary timerReferences = new Dictionary(); 13 | 14 | /// 15 | /// Creates timer to execute action after delay only once 16 | /// 17 | /// 18 | /// 19 | public static Guid SetTimeOut(Action action, TimeSpan delay) 20 | { 21 | lock (timerReferences) 22 | { 23 | var timerId = Guid.NewGuid(); 24 | var timer = new Timer(_ => 25 | { 26 | action(); 27 | Timer timerInstance; 28 | if (timerReferences.TryGetValue(timerId, out timerInstance)) 29 | { 30 | timerInstance.Dispose(); 31 | timerReferences.Remove(timerId); 32 | } 33 | }, null, delay, TimeSpan.FromMilliseconds(-1)); 34 | timerReferences[timerId] = timer; 35 | return timerId; 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/JsMapParserPluginSettings.cs: -------------------------------------------------------------------------------- 1 | using fastJSON; 2 | using System.IO; 3 | 4 | namespace JsMapParser.NppPlugin 5 | { 6 | public class JsMapParserPluginSettings 7 | { 8 | private string _configPath; 9 | 10 | public bool ShowToolWindow { get; set; } 11 | public bool ToolWindowVisible { get; set; } 12 | 13 | public JsMapParserPluginSettings() 14 | { 15 | } 16 | 17 | private static string GetConfigFilePath(string configPath) 18 | { 19 | // if path doesn't exist, we create it 20 | if (!Directory.Exists(configPath)) 21 | { 22 | Directory.CreateDirectory(configPath); 23 | } 24 | // make your file full file path name 25 | return Path.Combine(configPath, "JsMapParser.json"); 26 | } 27 | 28 | public static JsMapParserPluginSettings Load(string configPath) 29 | { 30 | var filePath = GetConfigFilePath(configPath); 31 | if (File.Exists(filePath)) 32 | { 33 | try 34 | { 35 | var settingsJson = File.ReadAllText(filePath); 36 | var settings = JSON.ToObject(settingsJson); 37 | settings._configPath = configPath; 38 | return settings; 39 | } 40 | catch 41 | { 42 | } 43 | } 44 | 45 | return new JsMapParserPluginSettings() { _configPath = configPath }; 46 | } 47 | 48 | public void Save() 49 | { 50 | try 51 | { 52 | var serialized = JSON.ToNiceJSON(this, new JSONParameters() 53 | { 54 | UseExtensions = false 55 | }); 56 | File.WriteAllText(GetConfigFilePath(_configPath), serialized); 57 | } 58 | catch 59 | { 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/NppCodeProvider.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using System; 3 | using System.IO; 4 | 5 | namespace JsMapParser.NppPlugin 6 | { 7 | internal class NppCodeProvider : ICodeProvider 8 | { 9 | private JsMapParserPlugin _plugin; 10 | 11 | public string Path { get; private set; } 12 | public string Name { get; private set; } 13 | public string FullName { get; private set; } 14 | public string ContainerName { get; set; } 15 | 16 | public NppCodeProvider(JsMapParserPlugin plugin, string fileName) 17 | { 18 | _plugin = plugin; 19 | 20 | FullName = fileName; 21 | Path = System.IO.Path.GetDirectoryName(fileName); 22 | Name = System.IO.Path.GetFileName(fileName); 23 | 24 | ContainerName = "Notepad++ " + _plugin.GetNppVersion(); 25 | } 26 | 27 | public string LoadCode() 28 | { 29 | try 30 | { 31 | return File.ReadAllText(FullName); 32 | } 33 | catch (Exception) 34 | { 35 | return "function Failed_To_Load_File(){};"; 36 | } 37 | } 38 | 39 | public void SelectionMoveToLineAndOffset(int startLine, int startColumn) 40 | { 41 | _plugin.GoToPosition(startLine, startColumn); 42 | } 43 | 44 | public void SetFocus() 45 | { 46 | _plugin.SetFocus(); 47 | } 48 | 49 | public void GetCursorPos(out int line, out int column) 50 | { 51 | _plugin.GetCursorPos(out line, out column); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/NppPluginBaseInfrastructure/NppPluginBaseSpecifics.cs: -------------------------------------------------------------------------------- 1 | namespace JsMapParser.NppPlugin.NppPluginBaseInfrastructure 2 | { 3 | internal abstract partial class NppPluginBase 4 | { 5 | private static NppPluginBase GetPluginInstance() 6 | { 7 | return new JsMapParserPlugin(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | // General Information about an assembly is controlled through the following 4 | // set of attributes. Change these attribute values to modify the information 5 | // associated with an assembly. 6 | [assembly: AssemblyTitle("JsParser.NppPlugin")] 7 | [assembly: AssemblyProduct("JsParser.NppPlugin")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/Properties/jsparsericon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.NppPlugin/Properties/jsparsericon.bmp -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/build/readme.txt: -------------------------------------------------------------------------------- 1 | Here should be copied the result of build process -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/tools/ILMerge/ILMerge.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.NppPlugin/tools/ILMerge/ILMerge.exe -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/tools/ILMerge/ILMerge.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/tools/ILMerge/test.cmd: -------------------------------------------------------------------------------- 1 | "C:\Work\js-map-parser\source\JsParser.NppPlugin\tools\ilmerge.exe" ^ 2 | /targetplatform:v4 ^ 3 | /out:C:\Work\js-map-parser\source\JsParser.NppPlugin\build\JsMapParser.NppPlugin1.dll ^ 4 | C:\Work\js-map-parser\source\JsParser.NppPlugin\bin\Debug\JsParser.NppPlugin.dll ^ 5 | C:\Work\js-map-parser\source\JsParser.NppPlugin\bin\Debug\JsParser.Core.dll ^ 6 | C:\Work\js-map-parser\source\JsParser.NppPlugin\bin\Debug\Jint.Parser.dll ^ 7 | C:\Work\js-map-parser\source\JsParser.NppPlugin\bin\Debug\JsParser.UI.dll -------------------------------------------------------------------------------- /source/JsParser.Test/Find/FindDialogTest.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Search; 2 | using NUnit.Framework; 3 | using System; 4 | using System.Linq; 5 | 6 | namespace JsParserTest.UnitTests 7 | { 8 | [TestFixture] 9 | public class FindDialogTest 10 | { 11 | [Test] 12 | public void TestSplitting() 13 | { 14 | ValidateSplitting( 15 | new[] { 16 | new[]{"TestFunction", "Test | Function"}, 17 | new[]{"TestCreepyFunction", "Test | Creepy | Function"}, 18 | new[]{"TestFunkyFunction", "Test | Funky | Function"}, 19 | new[]{"LongFunctionTestName", "Long | Function | Test | Name"}, 20 | new[]{"LongSuperDuperFunctionName", "Long | Super | Duper | Function | Name"}, 21 | new[]{"longSuperDuperFunctionName", "long | Super | Duper | Function | Name"}, 22 | new[]{"A", "A"}, 23 | new[]{"AB", "A | B"}, 24 | new[]{"ABC", "A | B | C"}, 25 | new[]{"aBC", "a | B | C"}, 26 | new[]{"AaBbCc", "Aa | Bb | Cc"}, 27 | new[]{"aaBbCc", "aa | Bb | Cc"}, 28 | new[]{"A1B2C3", "A | 1 | B | 2 | C | 3"}, 29 | new[]{"A123", "A | 1 | 2 | 3"}, 30 | new[]{"123", "1 | 2 | 3"}, 31 | new[]{"1A2B3C", "1 | A | 2 | B | 3 | C"}, 32 | new[]{"1a2b3c", "1a | 2b | 3c"}, 33 | }); 34 | 35 | ValidateSplitting( 36 | new[] { 37 | new[]{"this.Method('btn1')", "this | Method | btn | 1"}, 38 | new[]{"this.Method('btn1', 'btn2', 'btn3')", "this | Method | btn | 1 | btn | 2 | btn | 3"}, 39 | }); 40 | } 41 | 42 | [Test] 43 | public void TestMatching() 44 | { 45 | //Check match 46 | ValidateMatch( 47 | "AB", 48 | new[] {"aaBbCc", 49 | "ABC", 50 | "AB" 51 | }, 52 | true); 53 | 54 | //Check not match 55 | ValidateMatch( 56 | "ABD", 57 | new[] { 58 | "aaBbCc", 59 | "A", 60 | "CBD", 61 | "AB", 62 | }, 63 | false); 64 | } 65 | 66 | private void ValidateMatch(string pattern, string[] fnames, bool isMatch) 67 | { 68 | if (isMatch) 69 | { 70 | fnames.ToList().ForEach(p => { var r = TestMatch(pattern, p); if (!r) Assert.Fail("Pattern not match: " + pattern + "=>" + p); }); 71 | } 72 | else 73 | { 74 | fnames.ToList().ForEach(p => { var r = TestMatch(pattern, p); if (r) Assert.Fail("Pattern match: " + pattern + "=>" + p); }); 75 | } 76 | } 77 | 78 | private bool TestMatch(string pattern, string fname) 79 | { 80 | var p = SearchHelper.SplitFunctionName(pattern).ToList(); 81 | var f = SearchHelper.SplitFunctionName(fname).ToList(); 82 | return SearchHelper.CompareEntities(p, f) > 0; 83 | } 84 | 85 | private static string GetFunctionNameTestTransform(string originalFName) 86 | { 87 | return String.Join(" | ", SearchHelper.SplitFunctionName(originalFName).ToArray()); 88 | } 89 | 90 | private void ValidateSplitting(string[][] input) 91 | { 92 | input.ToList().ForEach(p => Assert.AreEqual(p[1], GetFunctionNameTestTransform(p[0]))); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /source/JsParser.Test/Find/SearchFinalTest.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Search; 2 | using NUnit.Framework; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace JsParserTest.UnitTests 7 | { 8 | [TestFixture] 9 | public class SearchFinalTest 10 | { 11 | private static string[] _source = { //first goes the test case index - to simplify test cases 12 | "0|this.Method1()", 13 | "1|this.Method2()", 14 | "2|this.longMethodDescription()", 15 | "3|this.withParam('btn1')", 16 | "4|this.withParamChain('btn1', 'btn2', 'btn3')", 17 | "5|ABBR.bigLetters.EAContainer()" 18 | }; 19 | 20 | private static IEnumerable> TransformSource(string[] source) 21 | { 22 | return _source.Select(i => 23 | { 24 | var d = i.Split(new char[] { '|' }); 25 | return new KeyValuePair(int.Parse(d[0]), d[1]); 26 | }); 27 | } 28 | 29 | private void AssertIndexes(KeyValuePair[] data, int[] indexes) 30 | { 31 | var dic = data.ToDictionary(k => k.Key); 32 | Assert.AreEqual(indexes.Length, data.Length, "Found wrong amount"); 33 | for (int i = 0; i < data.Length; ++i) 34 | { 35 | Assert.AreEqual(indexes[i], dic[indexes[i]].Key, "Wrong index found at position " + i); 36 | } 37 | } 38 | 39 | [Test] 40 | public void CheckBaseSearch() 41 | { 42 | var src = TransformSource(_source).ToArray(); 43 | var matches = SearchHelper.GetMatches(src, i => i.Value, "method").ToArray(); 44 | AssertIndexes(matches, new[] { 0, 1, 2 }); 45 | 46 | matches = SearchHelper.GetMatches(src, i => i.Value, "btn1").ToArray(); 47 | AssertIndexes(matches, new[] { 3, 4 }); 48 | 49 | matches = SearchHelper.GetMatches(src, i => i.Value, "btn2").ToArray(); 50 | AssertIndexes(matches, new[] { 4 }); 51 | 52 | matches = SearchHelper.GetMatches(src, i => i.Value, "Chain").ToArray(); 53 | AssertIndexes(matches, new[] { 4 }); 54 | 55 | matches = SearchHelper.GetMatches(src, i => i.Value, "ABBR").ToArray(); 56 | AssertIndexes(matches, new[] { 5 }); 57 | 58 | matches = SearchHelper.GetMatches(src, i => i.Value, "EAContainer").ToArray(); 59 | AssertIndexes(matches, new[] { 5 }); 60 | 61 | matches = SearchHelper.GetMatches(src, i => i.Value, "EACont").ToArray(); 62 | AssertIndexes(matches, new[] { 5 }); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /source/JsParser.Test/Helpers/StringExtText.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Parsers; 2 | using NUnit.Framework; 3 | using System.Diagnostics; 4 | 5 | namespace JsParserTest.Helpers 6 | { 7 | [TestFixture] 8 | public class StringExtText 9 | { 10 | [Test] 11 | public void TestShortenize() 12 | { 13 | RunSample("string", 6, 6); 14 | RunSample("string", 5, 5); 15 | RunSample("string", 4, 4); 16 | RunSample("string", 3, 3); 17 | RunSample("string", 2, 2); 18 | RunSample("string", 1, 1); 19 | RunSample("string", 0, 0); 20 | RunSample("string", -1, 0); 21 | } 22 | 23 | private void RunSample(string s, int targetLen, int expectedLen) 24 | { 25 | var r = s.Shortenize(targetLen); 26 | Trace.WriteLine(s + " => " + r); 27 | Assert.AreEqual(expectedLen, r.Length); 28 | } 29 | 30 | private void TracingAssert(string expected, string actual) 31 | { 32 | Trace.WriteLine("Comparing `" + expected + "` and `" + actual + "`"); 33 | Assert.AreEqual(expected, actual, "Not equal"); 34 | } 35 | 36 | [Test] 37 | public void TestSplitWordsByCamelCase() 38 | { 39 | TracingAssert("This Words Should Be Separated", "ThisWordsShouldBeSeparated".SplitWordsByCamelCase()); 40 | TracingAssert("", "".SplitWordsByCamelCase()); 41 | string test = null; 42 | TracingAssert(null, test.SplitWordsByCamelCase()); 43 | TracingAssert("1", "1".SplitWordsByCamelCase()); 44 | TracingAssert("nothing", "nothing".SplitWordsByCamelCase()); 45 | TracingAssert("A B C", "ABC".SplitWordsByCamelCase()); 46 | TracingAssert("A", "A".SplitWordsByCamelCase()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /source/JsParser.Test/Helpers/TestsHelper.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.IO; 3 | using System.Reflection; 4 | 5 | namespace JsParserTest.Helpers 6 | { 7 | public static class TestsHelper 8 | { 9 | public static string GetEmbeddedText(string resourceName) 10 | { 11 | var stream = Assembly.GetAssembly(typeof(TestsHelper)).GetManifestResourceStream(resourceName); 12 | Assert.IsNotNull(stream); 13 | using (var sr = new StreamReader(stream)) 14 | { 15 | return sr.ReadToEnd(); 16 | } 17 | } 18 | 19 | public static bool CheckEmbeddedRes(string resourceName) 20 | { 21 | using (var stream = Assembly.GetAssembly(typeof (TestsHelper)).GetManifestResourceStream(resourceName)) 22 | { 23 | return stream != null; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /source/JsParser.Test/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/b3ffda7482f3f422998138cd39f7ff414148eab4/source/JsParser.Test/Key.snk -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/HtmlScriptBlocks.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Function_In_The_Head(param1,param2) 7 | StartLine: 8 8 | EndLine: 11 9 | NodeType: Function 10 | Comment: This is the function in the head 11 | 12 | Alias: DefaultScriptFunction() 13 | StartLine: 19 14 | EndLine: 21 15 | NodeType: Function 16 | Comment: script without type considered as javascript 17 | 18 | Alias: Function_In_The_Javascript(param1,param2) 19 | StartLine: 29 20 | EndLine: 33 21 | NodeType: Function 22 | 23 | Alias: Function_In_The_Bottom(param1,param2) 24 | StartLine: 44 25 | EndLine: 47 26 | NodeType: Function 27 | Comment: This is the function in the bottom&#D;&#A;TODO: Not forget to remove this hack! 28 | 29 | Alias: Class1(param1,param2) 30 | StartLine: 50 31 | EndLine: 74 32 | NodeType: Function 33 | Comment: This is another sample of JS class 34 | 35 | Alias: Method1() 36 | StartLine: 57 37 | EndLine: 59 38 | NodeType: Function 39 | Comment: This is First method 40 | 41 | Alias: Method2(param1) 42 | StartLine: 62 43 | EndLine: 64 44 | NodeType: Function 45 | Comment: This is Second method 46 | 47 | Alias: Method3(param1,param2) 48 | StartLine: 67 49 | EndLine: 73 50 | NodeType: Function 51 | Comment: This is Third method 52 | 53 | Alias: delegate() 54 | StartLine: 70 55 | EndLine: 72 56 | NodeType: Function 57 | Comment: delegate method 58 | 59 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/ArrayChain.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: loadFirst() 7 | StartLine: 2 8 | EndLine: 4 9 | NodeType: Function 10 | 11 | Alias: loadSecond() 12 | StartLine: 5 13 | EndLine: 7 14 | NodeType: Function 15 | 16 | Alias: loadThird() 17 | StartLine: 8 18 | EndLine: 10 19 | NodeType: Function 20 | 21 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/Assignment.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: globalFunc() 7 | StartLine: 1 8 | EndLine: 3 9 | NodeType: Function 10 | 11 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/CallbackChain.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: then>?() 7 | StartLine: 2 8 | EndLine: 4 9 | NodeType: AnonymousFunction 10 | 11 | Alias: fail>?() 12 | StartLine: 5 13 | EndLine: 7 14 | NodeType: AnonymousFunction 15 | 16 | Alias: finally_>?() 17 | StartLine: 8 18 | EndLine: 10 19 | NodeType: AnonymousFunction 20 | 21 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/Comments.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: BigMainFunc() 7 | StartLine: 2 8 | EndLine: 25 9 | NodeType: Function 10 | Comment: Simple line comment&#D;&#A;Simple two lines comments - line 1&#D;&#A;Simple two lines comments - line 2 11 | 12 | Alias: loadFirst() 13 | StartLine: 5 14 | EndLine: 7 15 | NodeType: Function 16 | 17 | Alias: loadSecond() 18 | StartLine: 9 19 | EndLine: 11 20 | NodeType: Function 21 | Comment: Comment block of 1 line 22 | 23 | Alias: loadThird() 24 | StartLine: 14 25 | EndLine: 16 26 | NodeType: Function 27 | Comment: Comment block - 1 line&#A; Comment block - 2 line 28 | 29 | Alias: loadThird() 30 | StartLine: 22 31 | EndLine: 24 32 | NodeType: Function 33 | Comment: Comment block with new lines- 2 line&#A;&#A; Comment block with new lines- 3 line 34 | 35 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/DebuggerKeyword.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Aha() 7 | StartLine: 1 8 | EndLine: 7 9 | NodeType: Function 10 | 11 | Alias: Inner() 12 | StartLine: 4 13 | EndLine: 6 14 | NodeType: Function 15 | 16 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/Es6_GetSet.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: o 7 | StartLine: 10 8 | EndLine: 18 9 | NodeType: Object 10 | Comment: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects&#A;&#A;When defining getters and setters using object initializers &#A;all you need to do is to prefix a getter method with get and a setter&#A;method with set. Of course, the getter method must not expect a parameter,&#A;while the setter method expects exactly one parameter (the new value to set).&#A;For instance: 11 | 12 | Alias: b() 13 | StartLine: 12 14 | EndLine: 14 15 | NodeType: Function 16 | 17 | Alias: b(x) 18 | StartLine: 15 19 | EndLine: 17 20 | NodeType: Function 21 | 22 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/Es6_GetSet2.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: defineProperty>? 7 | StartLine: 2 8 | EndLine: 5 9 | NodeType: Object 10 | 11 | Alias: get() 12 | StartLine: 3 13 | EndLine: 3 14 | NodeType: Function 15 | 16 | Alias: set(y) 17 | StartLine: 4 18 | EndLine: 4 19 | NodeType: Function 20 | 21 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/FunctionsHierarchy.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: L1F1() 7 | StartLine: 1 8 | EndLine: 9 9 | NodeType: Function 10 | 11 | Alias: L2F1() 12 | StartLine: 2 13 | EndLine: 6 14 | NodeType: Function 15 | 16 | Alias: L3F1() 17 | StartLine: 3 18 | EndLine: 5 19 | NodeType: Function 20 | 21 | Alias: L2F2() 22 | StartLine: 8 23 | EndLine: 8 24 | NodeType: Function 25 | 26 | Alias: L1F2() 27 | StartLine: 11 28 | EndLine: 18 29 | NodeType: Function 30 | 31 | Alias: L2F1() 32 | StartLine: 12 33 | EndLine: 17 34 | NodeType: Function 35 | 36 | Alias: L3F1() 37 | StartLine: 13 38 | EndLine: 16 39 | NodeType: Function 40 | 41 | Alias: L4F1() 42 | StartLine: 14 43 | EndLine: 14 44 | NodeType: Function 45 | 46 | Alias: L4F2() 47 | StartLine: 15 48 | EndLine: 15 49 | NodeType: Function 50 | 51 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/FunctionsHierarchy2.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: L1F1() 7 | StartLine: 1 8 | EndLine: 9 9 | NodeType: Function 10 | 11 | Alias: L2F1() 12 | StartLine: 2 13 | EndLine: 6 14 | NodeType: Function 15 | 16 | Alias: L3F1() 17 | StartLine: 3 18 | EndLine: 5 19 | NodeType: Function 20 | 21 | Alias: L2F2() 22 | StartLine: 8 23 | EndLine: 8 24 | NodeType: Function 25 | 26 | Alias: L2F2() 27 | StartLine: 10 28 | EndLine: 12 29 | NodeType: Function 30 | 31 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/InlineOrDecralation.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: func() 7 | StartLine: 1 8 | EndLine: 1 9 | NodeType: Function 10 | 11 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/ReturnStatement.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: GetNewItem(param1,param2) 7 | StartLine: 2 8 | EndLine: 5 9 | NodeType: Function 10 | 11 | Alias: each>?(subparam) 12 | StartLine: 3 13 | EndLine: 4 14 | NodeType: AnonymousFunction 15 | 16 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/New/TodoList.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: loadFirst() 7 | StartLine: 2 8 | EndLine: 4 9 | NodeType: Function 10 | 11 | Alias: loadSecond() 12 | StartLine: 5 13 | EndLine: 7 14 | NodeType: Function 15 | Comment: TODO: write some code here 16 | 17 | Alias: loadThird() 18 | StartLine: 8 19 | EndLine: 14 20 | NodeType: Function 21 | Comment: some comment&#A; to do: Another todo line&#A; some other text 22 | 23 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test1.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Function1() 7 | StartLine: 3 8 | EndLine: 5 9 | NodeType: Function 10 | Comment: Comment to funtion 1&#D;&#A; This function does nothing 11 | 12 | Alias: Function2() 13 | StartLine: 9 14 | EndLine: 17 15 | NodeType: Function 16 | Comment: Comment to funtion 2&#D;&#A; This function has declaration of other function 17 | 18 | Alias: delegate() 19 | StartLine: 14 20 | EndLine: 16 21 | NodeType: Function 22 | Comment: delegate method 23 | 24 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test2.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Class1(param1,param2) 7 | StartLine: 2 8 | EndLine: 26 9 | NodeType: Function 10 | Comment: This is sample of JS class 11 | 12 | Alias: Method1() 13 | StartLine: 9 14 | EndLine: 11 15 | NodeType: Function 16 | Comment: This is First method 17 | 18 | Alias: Method2(param1) 19 | StartLine: 14 20 | EndLine: 16 21 | NodeType: Function 22 | Comment: This is Second method 23 | 24 | Alias: Method3(param1,param2) 25 | StartLine: 19 26 | EndLine: 25 27 | NodeType: Function 28 | Comment: This is Third method 29 | 30 | Alias: delegate() 31 | StartLine: 22 32 | EndLine: 24 33 | NodeType: Function 34 | Comment: delegate method 35 | 36 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test3.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Class2(param1,param2) 7 | StartLine: 3 8 | EndLine: 26 9 | NodeType: Function 10 | Comment: ------------------------------------------------------------------------------------&#D;&#A; This is sample of JS class. 11 | 12 | Alias: Method1() 13 | StartLine: 9 14 | EndLine: 11 15 | NodeType: Function 16 | Comment: Method1 17 | 18 | Alias: Method2(param1) 19 | StartLine: 14 20 | EndLine: 16 21 | NodeType: Function 22 | Comment: Method2 23 | 24 | Alias: Method3(param1,param2) 25 | StartLine: 19 26 | EndLine: 25 27 | NodeType: Function 28 | Comment: Method3 29 | 30 | Alias: delegate() 31 | StartLine: 22 32 | EndLine: 24 33 | NodeType: Function 34 | Comment: delegate method 35 | 36 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test4.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: ItemFactory(param1,param2) 7 | StartLine: 3 8 | EndLine: 19 9 | NodeType: Function 10 | Comment: ------------------------------------------------------------------------------------&#D;&#A; This is sample of JS class. 11 | 12 | Alias: item 13 | StartLine: 5 14 | EndLine: 16 15 | NodeType: Object 16 | 17 | Alias: method1() 18 | StartLine: 8 19 | EndLine: 8 20 | NodeType: Function 21 | 22 | Alias: method2(p) 23 | StartLine: 9 24 | EndLine: 9 25 | NodeType: Function 26 | 27 | Alias: method3(p1,p2) 28 | StartLine: 10 29 | EndLine: 15 30 | NodeType: Function 31 | 32 | Alias: delegate() 33 | StartLine: 12 34 | EndLine: 14 35 | NodeType: Function 36 | Comment: method1&#D;&#A;method2&#D;&#A;method3&#D;&#A;delegate method 37 | 38 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test4_2.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: ItemFactory(param1,param2) 7 | StartLine: 3 8 | EndLine: 20 9 | NodeType: Function 10 | Comment: ------------------------------------------------------------------------------------&#D;&#A; This is sample of JS class. 11 | 12 | Alias: item 13 | StartLine: 6 14 | EndLine: 18 15 | NodeType: Object 16 | 17 | Alias: method1() 18 | StartLine: 9 19 | EndLine: 9 20 | NodeType: Function 21 | 22 | Alias: method2(p) 23 | StartLine: 10 24 | EndLine: 10 25 | NodeType: Function 26 | 27 | Alias: method3(p1,p2) 28 | StartLine: 11 29 | EndLine: 17 30 | NodeType: Function 31 | Comment: method1&#D;&#A;method2&#D;&#A;method3 32 | 33 | Alias: delegate() 34 | StartLine: 14 35 | EndLine: 16 36 | NodeType: Function 37 | Comment: delegate method 38 | 39 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test5.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Function1(delegate) 7 | StartLine: 3 8 | EndLine: 6 9 | NodeType: Function 10 | Comment: Comment to funtion 1&#D;&#A; This function run a delegate 11 | 12 | Alias: Function2() 13 | StartLine: 10 14 | EndLine: 21 15 | NodeType: Function 16 | Comment: Comment to funtion 2&#D;&#A; This function has declaration of other function 17 | 18 | Alias: delegate() 19 | StartLine: 15 20 | EndLine: 17 21 | NodeType: Function 22 | Comment: delegate method 23 | 24 | Alias: Function1>?() 25 | StartLine: 20 26 | EndLine: 20 27 | NodeType: AnonymousFunction 28 | Comment: Anonimous function 29 | 30 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test5_1.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Function1(delegate) 7 | StartLine: 3 8 | EndLine: 6 9 | NodeType: Function 10 | Comment: Comment to funtion 1&#D;&#A; This function run a delegate 11 | 12 | Alias: Function1>?() 13 | StartLine: 9 14 | EndLine: 9 15 | NodeType: AnonymousFunction 16 | Comment: Anonimous function 17 | 18 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_Anonimous_In_Return_Statement.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: jQuery(selector,context) 7 | StartLine: 2 8 | EndLine: 5 9 | NodeType: Function 10 | Comment: Define a local copy of jQuery&#D;&#A; The jQuery object is actually just the init constructor 'enhanced' 11 | 12 | Alias: ?() 13 | StartLine: 4 14 | EndLine: 4 15 | NodeType: AnonymousFunction 16 | 17 | Alias: GetNewItem(param1,param2) 18 | StartLine: 7 19 | EndLine: 11 20 | NodeType: Function 21 | 22 | Alias: each>?(subparam) 23 | StartLine: 9 24 | EndLine: 10 25 | NodeType: AnonymousFunction 26 | 27 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_AnonymousSelfExecBlock.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: BeforeSelfExec() 7 | StartLine: 2 8 | EndLine: 3 9 | NodeType: Function 10 | Comment: Some function declared before self-exec block 11 | 12 | Alias: ?($) 13 | StartLine: 5 14 | EndLine: 7 15 | NodeType: AnonymousFunction 16 | Comment: Some Anonymous Self-Executing function 17 | 18 | Alias: AfterSelfExec() 19 | StartLine: 10 20 | EndLine: 11 21 | NodeType: Function 22 | Comment: Some function declared after self-exec block 23 | 24 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_AspScriptCombiner.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: anotherFake() 7 | StartLine: 22 8 | EndLine: 24 9 | NodeType: Function 10 | 11 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_AspTagsReplace.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: clickHandlerClentID() 7 | StartLine: 4 8 | EndLine: 6 9 | NodeType: Function 10 | 11 | Alias: controlHelperClientId 12 | StartLine: 14 13 | EndLine: 18 14 | NodeType: Object 15 | 16 | Alias: click() 17 | StartLine: 16 18 | EndLine: 17 19 | NodeType: Function 20 | 21 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_Construct_Object_In_Return_Statement.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: GetNewItem(param1,param2) 7 | StartLine: 3 8 | EndLine: 21 9 | NodeType: Function 10 | Comment: ------------------------------------------------------------------------------------&#D;&#A; This is sample of JS class factory. 11 | 12 | Alias: ? 13 | StartLine: 5 14 | EndLine: 20 15 | NodeType: Object 16 | 17 | Alias: method1() 18 | StartLine: 8 19 | EndLine: 8 20 | NodeType: Function 21 | 22 | Alias: method2(p) 23 | StartLine: 9 24 | EndLine: 11 25 | NodeType: Function 26 | 27 | Alias: method3(p1,p2) 28 | StartLine: 12 29 | EndLine: 19 30 | NodeType: Function 31 | Comment: method3 32 | 33 | Alias: delegate() 34 | StartLine: 16 35 | EndLine: 18 36 | NodeType: Function 37 | Comment: Delegate method&#A; This method contains multilines comment 38 | 39 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_DoubleAssign.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: someClickHandler1() 7 | StartLine: 3 8 | EndLine: 4 9 | NodeType: Function 10 | 11 | Alias: someClickHandler2() 12 | StartLine: 6 13 | EndLine: 7 14 | NodeType: Function 15 | 16 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_FunctionWithPlainObject.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Main() 7 | StartLine: 1 8 | EndLine: 7 9 | NodeType: Function 10 | 11 | Alias: obj 12 | StartLine: 3 13 | EndLine: 6 14 | NodeType: Object 15 | 16 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_Functions_In_CASE_Statement.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: GetFunction(type) 7 | StartLine: 3 8 | EndLine: 36 9 | NodeType: Function 10 | Comment: This function returns another function 11 | 12 | Alias: t() 13 | StartLine: 8 14 | EndLine: 10 15 | NodeType: Function 16 | 17 | Alias: t1() 18 | StartLine: 13 19 | EndLine: 15 20 | NodeType: Function 21 | 22 | Alias: ?() 23 | StartLine: 18 24 | EndLine: 18 25 | NodeType: AnonymousFunction 26 | 27 | Alias: ? 28 | StartLine: 20 29 | EndLine: 20 30 | NodeType: Object 31 | 32 | Alias: exec() 33 | StartLine: 20 34 | EndLine: 20 35 | NodeType: Function 36 | 37 | Alias: tf() 38 | StartLine: 23 39 | EndLine: 26 40 | NodeType: Function 41 | 42 | Alias: doSome() 43 | StartLine: 28 44 | EndLine: 31 45 | NodeType: Function 46 | 47 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_Functions_In_IF_Statement.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: alertIsIEFunc() 7 | StartLine: 8 8 | EndLine: 11 9 | NodeType: Function 10 | Comment: ie- specific implementation 11 | 12 | Alias: alertIsIEFunc() 13 | StartLine: 16 14 | EndLine: 19 15 | NodeType: Function 16 | Comment: html standart implementation 17 | 18 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_Functions_In_TryCatch_Statement.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: f1() 7 | StartLine: 3 8 | EndLine: 5 9 | NodeType: Function 10 | 11 | Alias: f2() 12 | StartLine: 7 13 | EndLine: 24 14 | NodeType: Function 15 | 16 | Alias: f21() 17 | StartLine: 11 18 | EndLine: 13 19 | NodeType: Function 20 | 21 | Alias: f22() 22 | StartLine: 16 23 | EndLine: 18 24 | NodeType: Function 25 | 26 | Alias: f23() 27 | StartLine: 20 28 | EndLine: 22 29 | NodeType: Function 30 | 31 | Alias: f3() 32 | StartLine: 28 33 | EndLine: 30 34 | NodeType: Function 35 | 36 | Alias: f4() 37 | StartLine: 32 38 | EndLine: 34 39 | NodeType: Function 40 | 41 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_JSParserSkipHandling.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: test() 7 | StartLine: 1 8 | EndLine: 4 9 | NodeType: Function 10 | 11 | Alias: test2() 12 | StartLine: 6 13 | EndLine: 9 14 | NodeType: Function 15 | 16 | Alias: test3() 17 | StartLine: 11 18 | EndLine: 18 19 | NodeType: Function 20 | 21 | Alias: test4() 22 | StartLine: 20 23 | EndLine: 23 24 | NodeType: Function 25 | 26 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_JsonObject_StringPropNames.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: testObj 7 | StartLine: 1 8 | EndLine: 6 9 | NodeType: Object 10 | 11 | Alias: "OK"() 12 | StartLine: 2 13 | EndLine: 3 14 | NodeType: Function 15 | 16 | Alias: "Cancel"() 17 | StartLine: 4 18 | EndLine: 5 19 | NodeType: Function 20 | 21 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_NewStatements.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: F1() 7 | StartLine: 1 8 | EndLine: 3 9 | NodeType: Function 10 | 11 | Alias: F2() 12 | StartLine: 5 13 | EndLine: 5 14 | NodeType: Function 15 | 16 | Alias: F3(def,classdef) 17 | StartLine: 7 18 | EndLine: 10 19 | NodeType: Function 20 | 21 | Alias: F4() 22 | StartLine: 12 23 | EndLine: 12 24 | NodeType: Function 25 | 26 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_RazorSyntax.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: $>?() 7 | StartLine: 29 8 | EndLine: 48 9 | NodeType: AnonymousFunction 10 | 11 | Alias: Init>? 12 | StartLine: 41 13 | EndLine: 46 14 | NodeType: Object 15 | 16 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_ReservedWords_Goto.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: Pen(tag) 7 | StartLine: 2 8 | EndLine: 25 9 | NodeType: Function 10 | 11 | Alias: prototype 12 | StartLine: 26 13 | EndLine: 61 14 | NodeType: Object 15 | 16 | Alias: height() 17 | StartLine: 27 18 | EndLine: 29 19 | NodeType: Function 20 | 21 | Alias: goto(x,y) 22 | StartLine: 31 23 | EndLine: 41 24 | NodeType: Function 25 | 26 | Alias: jump(x,y) 27 | StartLine: 43 28 | EndLine: 52 29 | NodeType: Function 30 | 31 | Alias: height() 32 | StartLine: 54 33 | EndLine: 56 34 | NodeType: Function 35 | 36 | Alias: center() 37 | StartLine: 58 38 | EndLine: 60 39 | NodeType: Function 40 | 41 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_StringContinuationCharacter.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: function1() 7 | StartLine: 1 8 | EndLine: 42 9 | NodeType: Function 10 | 11 | Alias: innerFunction() 12 | StartLine: 30 13 | EndLine: 32 14 | NodeType: Function 15 | Comment: Not visible if previous hugeString declaration was throw error 16 | 17 | Alias: f 18 | StartLine: 34 19 | EndLine: 41 20 | NodeType: Object 21 | 22 | Alias: testFunction() 23 | StartLine: 39 24 | EndLine: 40 25 | NodeType: Function 26 | 27 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/ExpectedResult/Test_StringScriptBlock.txt: -------------------------------------------------------------------------------- 1 | Alias: All 2 | StartLine: 0 3 | EndLine: 0 4 | NodeType: Function 5 | 6 | Alias: test() 7 | StartLine: 1 8 | EndLine: 13 9 | NodeType: Function 10 | 11 | Alias: someInnerFunc() 12 | StartLine: 10 13 | EndLine: 12 14 | NodeType: Function 15 | 16 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/JSParserTests_Frameworks.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace JsParser.Test.Parser 4 | { 5 | [TestFixture] 6 | public class JsParserTests_Frameworks 7 | { 8 | [Test] 9 | public void Frameworks_JustHeavyLoadTest_JQuery() 10 | { 11 | for (var i = 0; i < 10; i++) 12 | { 13 | Frameworks_JQuery(); 14 | } 15 | } 16 | 17 | [Test] 18 | public void Frameworks_JQuery() 19 | { 20 | TestRunner.RunTest("Frameworks.jquery-2.1.4.js", "Frameworks.jquery-2.1.4.txt"); 21 | } 22 | 23 | [Test] 24 | public void Frameworks_Angular() 25 | { 26 | TestRunner.RunTest("Frameworks.angular_v1.4.0-rc.2.js", "Frameworks.angular_v1.4.0-rc.2.txt"); 27 | } 28 | 29 | [Test] 30 | public void Frameworks_UiBootstrap() 31 | { 32 | TestRunner.RunTest("Frameworks.ui-bootstrap-tpls-0.13.0.js", "Frameworks.ui-bootstrap-tpls-0.13.0.txt"); 33 | } 34 | 35 | [Test] 36 | public void Frameworks_Knockout() 37 | { 38 | TestRunner.RunTest("Frameworks.knockout-3.3.0.debug.js", "Frameworks.knockout-3.3.0.debug.txt"); 39 | } 40 | 41 | [Test] 42 | public void Frameworks_Bootstrap() 43 | { 44 | TestRunner.RunTest("Frameworks.bootstrap.js", "Frameworks.bootstrap.txt"); 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/JsParserTests_New.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace JsParser.Test.Parser 4 | { 5 | [TestFixture] 6 | public class JsParserTests_New 7 | { 8 | [Test] 9 | public void ArrayChain() 10 | { 11 | TestRunner.RunTest("New.ArrayChain.js", "New.ArrayChain.txt"); 12 | } 13 | 14 | [Test] 15 | public void Assignment() 16 | { 17 | TestRunner.RunTest("New.Assignment.js", "New.Assignment.txt"); 18 | } 19 | 20 | [Test] 21 | public void CallbackChain() 22 | { 23 | TestRunner.RunTest("New.CallbackChain.js", "New.CallbackChain.txt"); 24 | } 25 | 26 | [Test] 27 | public void Comments() 28 | { 29 | TestRunner.RunTest("New.Comments.js", "New.Comments.txt"); 30 | } 31 | 32 | [Test] 33 | public void DebuggerKeyword() 34 | { 35 | TestRunner.RunTest("New.DebuggerKeyword.js", "New.DebuggerKeyword.txt"); 36 | } 37 | 38 | [Test] 39 | public void FunctionsHierarchy() 40 | { 41 | TestRunner.RunTest("New.FunctionsHierarchy.js", "New.FunctionsHierarchy.txt"); 42 | } 43 | 44 | [Test] 45 | public void FunctionsHierarchy2() 46 | { 47 | TestRunner.RunTest("New.FunctionsHierarchy2.js", "New.FunctionsHierarchy2.txt"); 48 | } 49 | 50 | [Test] 51 | public void InlineOrDecralation() 52 | { 53 | TestRunner.RunTest("New.InlineOrDecralation.js", "New.InlineOrDecralation.txt"); 54 | } 55 | 56 | [Test] 57 | public void ReturnStatement() 58 | { 59 | TestRunner.RunTest("New.ReturnStatement.js", "New.ReturnStatement.txt"); 60 | } 61 | 62 | [Test] 63 | public void TodoList() 64 | { 65 | var result = TestRunner.RunTest("New.TodoList.js", "New.TodoList.txt"); 66 | 67 | Assert.AreEqual(2, result.TaskList.Count); 68 | Assert.AreEqual("TODO: write some code here", result.TaskList[0].Description); 69 | Assert.AreEqual(6, result.TaskList[0].StartLine); 70 | 71 | Assert.AreEqual("to do: Another todo line", result.TaskList[1].Description); 72 | Assert.AreEqual(9, result.TaskList[1].StartLine); 73 | } 74 | 75 | [Test] 76 | public void Es6_GetSet() 77 | { 78 | TestRunner.RunTest("New.Es6_GetSet.js", "New.Es6_GetSet.txt"); 79 | } 80 | 81 | [Test] 82 | public void Es6_GetSet2() 83 | { 84 | TestRunner.RunTest("New.Es6_GetSet2.js", "New.Es6_GetSet2.txt"); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/HtmlScriptBlocks.htm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Test 10 5 | 6 | 13 | 14 | 15 | This is the test HTM page 16 | 17 | 18 | 23 | 24 | 27 | 28 | 35 | 36 | 40 | 41 | 76 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/ArrayChain.js: -------------------------------------------------------------------------------- 1 | var promises = [ 2 | function loadFirst() { 3 | 4 | }, 5 | function loadSecond() { 6 | 7 | }, 8 | function loadThird() { 9 | 10 | } 11 | ]; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/Assignment.js: -------------------------------------------------------------------------------- 1 | window.globalFunc = function() { 2 | 3 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/CallbackChain.js: -------------------------------------------------------------------------------- 1 | $.ajax() 2 | .then(function() { 3 | 4 | }) 5 | .fail(function() { 6 | 7 | }) 8 | .finally_(function() { 9 | 10 | }); -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/Comments.js: -------------------------------------------------------------------------------- 1 | //Simple line comment 2 | var promises = function BigMainFunc(){ 3 | //Simple two lines comments - line 1 4 | //Simple two lines comments - line 2 5 | function loadFirst() { 6 | 7 | }; 8 | /*Comment block of 1 line*/ 9 | function loadSecond() { 10 | 11 | }; 12 | /*Comment block - 1 line 13 | Comment block - 2 line*/ 14 | function loadThird() { 15 | 16 | }; 17 | /* 18 | Comment block with new lines- 2 line 19 | 20 | Comment block with new lines- 3 line 21 | */ 22 | function loadThird() { 23 | 24 | }; 25 | }; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/DebuggerKeyword.js: -------------------------------------------------------------------------------- 1 | function Aha() { 2 | debugger; 3 | 4 | function Inner() { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/Es6_GetSet.js: -------------------------------------------------------------------------------- 1 | /* 2 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects 3 | 4 | When defining getters and setters using object initializers 5 | all you need to do is to prefix a getter method with get and a setter 6 | method with set. Of course, the getter method must not expect a parameter, 7 | while the setter method expects exactly one parameter (the new value to set). 8 | For instance: 9 | */ 10 | var o = { 11 | a: 7, 12 | get b() { 13 | return this.a + 1; 14 | }, 15 | set b(x) { 16 | this.a = x / 2 17 | } 18 | }; 19 | 20 | console.log(o.a); // 7 21 | console.log(o.b); // 8 22 | o.c = 50; 23 | console.log(o.a); // 25 24 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/Es6_GetSet2.js: -------------------------------------------------------------------------------- 1 | var d = Date.prototype; 2 | Object.defineProperty(d, "year", { 3 | get: function () { return this.getFullYear() }, 4 | set: function (y) { this.setFullYear(y) } 5 | }); -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/FunctionsHierarchy.js: -------------------------------------------------------------------------------- 1 | function L1F1() { 2 | function L2F1() { 3 | function L3F1() { 4 | 5 | } 6 | } 7 | 8 | function L2F2() {}; 9 | }; 10 | 11 | function L1F2() { 12 | function L2F1() { 13 | function L3F1() { 14 | function L4F1() { } 15 | function L4F2() { } 16 | } 17 | } 18 | }; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/FunctionsHierarchy2.js: -------------------------------------------------------------------------------- 1 | function L1F1() { 2 | function L2F1() { 3 | function L3F1() { 4 | 5 | } 6 | } 7 | 8 | function L2F2() {}; 9 | }; 10 | var L2F2 = function() { 11 | 12 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/InlineOrDecralation.js: -------------------------------------------------------------------------------- 1 | var func = options.func || function() {} -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/ReturnStatement.js: -------------------------------------------------------------------------------- 1 |  2 | function GetNewItem(param1, param2) { 3 | return this.each(function (subparam) { 4 | }); 5 | } 6 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/TodoList.js: -------------------------------------------------------------------------------- 1 | var promises = [ 2 | function loadFirst() { 3 | 4 | }, 5 | function loadSecond() { 6 | //TODO: write some code here 7 | }, 8 | function loadThird() { 9 | /* 10 | some comment 11 | to do: Another todo line 12 | some other text 13 | */ 14 | } 15 | ]; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test1.js: -------------------------------------------------------------------------------- 1 | // Comment to funtion 1 2 | // This function does nothing 3 | function Function1() 4 | { 5 | } 6 | 7 | // Comment to funtion 2 8 | // This function has declaration of other function 9 | function Function2() 10 | { 11 | var variable1 = 1; 12 | 13 | //delegate method 14 | var delegate = function() 15 | { 16 | }; 17 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test2.js: -------------------------------------------------------------------------------- 1 | //This is sample of JS class 2 | var Class1 = function(param1, param2) 3 | { 4 | var _this = this; 5 | _this._field1 = param1; 6 | _this._field2 = param2; 7 | 8 | //This is First method 9 | _this.Method1 = function() 10 | { 11 | }; 12 | 13 | //This is Second method 14 | _this.Method2 = function(param1) 15 | { 16 | }; 17 | 18 | //This is Third method 19 | _this.Method3 = function(param1, param2) 20 | { 21 | //delegate method 22 | var delegate = function() 23 | { 24 | }; 25 | }; 26 | }; 27 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test3.js: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------ 2 | // This is sample of JS class. 3 | function Class2(param1, param2) 4 | { 5 | this.field1 = param1; 6 | this.field2 = param2; 7 | 8 | // Method1 9 | this.Method1 = function() 10 | { 11 | }; 12 | 13 | // Method2 14 | this.Method2 = function(param1) 15 | { 16 | }; 17 | 18 | // Method3 19 | this.Method3 = function(param1, param2) 20 | { 21 | //delegate method 22 | var delegate = function() 23 | { 24 | }; 25 | }; 26 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test4.js: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------ 2 | // This is sample of JS class. 3 | function ItemFactory(param1, param2) 4 | { 5 | var item = { 6 | field1: param1, 7 | field2: param2, 8 | /*method1*/ method1: function() { }, 9 | /*method2*/ method2: function(p) { }, 10 | /*method3*/ method3: function(p1, p2) { 11 | //delegate method 12 | var delegate = function() 13 | { 14 | }; 15 | } 16 | }; 17 | 18 | return item; 19 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test4_2.js: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------ 2 | // This is sample of JS class. 3 | function ItemFactory(param1, param2) 4 | { 5 | var item = null; 6 | item = { 7 | field1: param1, 8 | field2: param2, 9 | /*method1*/method1: function() { }, 10 | /*method2*/method2: function(p) { }, 11 | /*method3*/method3: function(p1, p2) 12 | { 13 | //delegate method 14 | var delegate = function() 15 | { 16 | }; 17 | } 18 | }; 19 | return item; 20 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test5.js: -------------------------------------------------------------------------------- 1 | // Comment to funtion 1 2 | // This function run a delegate 3 | function Function1(delegate) 4 | { 5 | delegate(); 6 | } 7 | 8 | // Comment to funtion 2 9 | // This function has declaration of other function 10 | function Function2() 11 | { 12 | var variable1 = 1; 13 | 14 | //delegate method 15 | var delegate = function() 16 | { 17 | }; 18 | 19 | //Anonimous function 20 | Function1(function() {alert(1);}); 21 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test5_1.js: -------------------------------------------------------------------------------- 1 | // Comment to funtion 1 2 | // This function run a delegate 3 | function Function1(delegate) 4 | { 5 | delegate(); 6 | } 7 | 8 | //Anonimous function 9 | Function1(function() {alert(1);}); -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_Anonimous_In_Return_Statement.js: -------------------------------------------------------------------------------- 1 | // Define a local copy of jQuery 2 | var jQuery = function (selector, context) { 3 | // The jQuery object is actually just the init constructor 'enhanced' 4 | return new jQuery.fn.init(selector, context, rootjQuery, function () { }); 5 | }; 6 | 7 | function GetNewItem(param1, param2) 8 | { 9 | return this.each(function (subparam) { 10 | }); 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_AnonymousSelfExecBlock.js: -------------------------------------------------------------------------------- 1 | //Some function declared before self-exec block 2 | function BeforeSelfExec() { 3 | } 4 | 5 | (function ($) { 6 | //Some Anonymous Self-Executing function 7 | })(jQuery); 8 | 9 | //Some function declared after self-exec block 10 | function AfterSelfExec() { 11 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_AnonymousWithNames.js: -------------------------------------------------------------------------------- 1 | $.each(arr, function IAmTheImportantIteratorName() { 2 | //do smth 3 | }); 4 | 5 | (function IAmNotAnonimous($) { 6 | 7 | })(jQuery); -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_AspScriptCombiner.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Maintenance.WebForm1" %> 2 | <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | <%--combine all the script files into a single Composite Script--%> 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 26 | 27 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_AspTagsReplace.aspx: -------------------------------------------------------------------------------- 1 |  21 | 22 | <%----%> -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_Construct_Object_In_Return_Statement.js: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------ 2 | // This is sample of JS class factory. 3 | function GetNewItem(param1, param2) 4 | { 5 | return { 6 | field1: param1, 7 | field2: param2, 8 | /*method1*/method1: function() { }, 9 | /*method2*/method2: function(p) { 10 | //This function contains a lot of comments before and after declaration 11 | }, 12 | /*method3*/method3: function(p1, p2) 13 | { 14 | /*Delegate method 15 | This method contains multilines comment*/ 16 | var delegate = function() 17 | { 18 | }; 19 | } 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_DoubleAssign.js: -------------------------------------------------------------------------------- 1 | var App = {}; 2 | 3 | App.clickHandler1 = document.getElementById("someId1").onClick = function someClickHandler1() { 4 | }; 5 | 6 | App.clickHandler2 = document.getElementById("someId2").onClick = function someClickHandler2() { 7 | }; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_FunctionWithPlainObject.js: -------------------------------------------------------------------------------- 1 | function Main() 2 | { 3 | var obj = { 4 | hello: 1, 5 | bybye: 2 6 | }; 7 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_Functions_In_CASE_Statement.js: -------------------------------------------------------------------------------- 1 |  2 | // This function returns another function 3 | function GetFunction(type) 4 | { 5 | switch (type) 6 | { 7 | case 0: 8 | var t = function() 9 | { 10 | }; 11 | return t; 12 | case 1: 13 | t1 = function() 14 | { 15 | }; 16 | return t1; 17 | case 2: 18 | return function(){}; 19 | case 3: 20 | return { exec: function(){} }; 21 | case 4: 22 | { 23 | var tf = function() 24 | { 25 | alert('yoy'); 26 | }; 27 | 28 | function doSome() 29 | { 30 | alert(doSome); 31 | } 32 | 33 | doSome(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_Functions_In_IF_Statement.js: -------------------------------------------------------------------------------- 1 |  2 | // This function show alert if browser is IE 3 | var alertIsIEFunc = null; 4 | 5 | if (jQuery.browser.msie) 6 | { 7 | // ie- specific implementation 8 | alertIsIEFunc = function() 9 | { 10 | alert('This is IE'); 11 | } 12 | } 13 | else 14 | { 15 | // html standart implementation 16 | alertIsIEFunc = function() 17 | { 18 | alert('This is not IE'); 19 | } 20 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_Functions_In_TryCatch_Statement.js: -------------------------------------------------------------------------------- 1 |  2 | try { 3 | function f1() { 4 | alert('f1'); 5 | } 6 | 7 | var f2 = function () { 8 | alert('f2'); 9 | 10 | try { 11 | var f21 = function () { 12 | alert('f21'); 13 | }; 14 | } 15 | catch (e) { 16 | var f22 = function () { 17 | alert('f22'); 18 | } 19 | 20 | function f23() { 21 | alert('f23'); 22 | } 23 | } 24 | }; 25 | 26 | } 27 | catch (e) { 28 | function f3() { 29 | alert('f3'); 30 | } 31 | 32 | var f4 = function () { 33 | alert('f4'); 34 | } 35 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_HierarhizeOnPostProcessing.js: -------------------------------------------------------------------------------- 1 | var testObj = {}; 2 | 3 | testObj.level1 = function () { 4 | }; 5 | 6 | testObj.level1.level2 = function () { 7 | }; 8 | 9 | testObj.level1.level2.level3 = function () { 10 | }; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_JSParserSkipHandling.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | 3 | 4 | } 5 | 6 | function test2() { 7 | 8 | 9 | } 10 | 11 | function test3() 12 | { 13 | 14 | //jsparser:off 15 | new function(h) { var l = h.separator || "&", k = h.spaces === !1 ? !1 : !0, m = h.prefix !== !1 ? h.h : 0; 16 | //jsparser:on 17 | 18 | } 19 | 20 | function test4() { 21 | 22 | 23 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_JsonObject_StringPropNames.js: -------------------------------------------------------------------------------- 1 | var testObj = { 2 | "OK": function () { 3 | }, 4 | "Cancel": function () { 5 | } 6 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_NewStatements.js: -------------------------------------------------------------------------------- 1 | function F1() { 2 | value.properties.push(new (acc ? Access : Index)(idx)); 3 | } 4 | 5 | function F2() { } 6 | 7 | function F3(def, classdef) { 8 | obj.prototype = new this(PROTO); 9 | return obj; 10 | }; 11 | 12 | function F4() { } 13 | -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_PropsInArrayStyleNames.js: -------------------------------------------------------------------------------- 1 | var testObj = {}; 2 | 3 | testObj["Ok"] = function () { 4 | }; 5 | 6 | testObj["Cancel"] = function () { 7 | }; 8 | 9 | testObj[0] = function () { 10 | }; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_RazorSyntax.cshtml: -------------------------------------------------------------------------------- 1 | @using Newtonsoft.Json 2 | @model PageModel_Test 3 | @{ 4 | ViewBag.Title = Model.Title; 5 | } 6 | 7 | @section head 8 | { 9 | 10 | 13 | } 14 | 15 |

@ViewBag.Title

16 | 17 |
18 | Content goes here... 19 |
20 | 21 | @section scripts 22 | { 23 | 24 | 25 | 26 | 27 | 28 | 50 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_ReservedWords_Goto.js: -------------------------------------------------------------------------------- 1 |  2 | Pen = function (tag) { 3 | this.dir = -90; 4 | this.x = 0; 5 | this.y = 0; 6 | 7 | this.tag = document.getElementById(tag) || tag; 8 | 9 | this.canvas = this.tag.getContext("2d"); 10 | this.strokeStyle = this.canvas.strokeStyle = "#000"; 11 | this.lineWidth = this.canvas.lineWidth = 1; 12 | this.fillStyle = this.canvas.fillStyle = ""; 13 | 14 | this.ox = 0; 15 | this.oy = 0; 16 | 17 | this.pen = true; 18 | 19 | this.canvas.clearRect(0, 0, this.tag.width, this.tag.height); 20 | var w = this.tag.width; 21 | this.tag.width = 1; 22 | this.tag.width = w; 23 | 24 | this.canvas.beginPath(); 25 | }; 26 | Pen.prototype = { 27 | height: function () { 28 | return this.tag.height; 29 | }, 30 | 31 | goto: function (x, y) { 32 | this.x = x; 33 | this.y = y; 34 | 35 | if (!this.pen) 36 | this.canvas.moveTo(x, y); 37 | else 38 | this.canvas.lineTo(x, y); 39 | 40 | return this; 41 | }, 42 | 43 | jump: function (x, y) { 44 | this.canvas.beginPath(); 45 | 46 | var p = this.pen; 47 | this.pen = true; 48 | this.goto(x, y); 49 | this.pen = p; 50 | 51 | return this; 52 | }, 53 | 54 | height: function () { 55 | return this.tag.height; 56 | }, 57 | 58 | center: function () { 59 | return this.goto(this.width() / 2, this.height() / 2); 60 | } 61 | }; -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_StringContinuationCharacter.js: -------------------------------------------------------------------------------- 1 | function function1() { 2 | var hugeString1 = "blabla\ 3 | blabla"; 4 | 5 | var hugeString2 = 'blabla\ 6 | blabla'; 7 | 8 | var hugeString3 = 'bla "bla"\ 9 | "bla" bla'; 10 | 11 | var hugeString4 = 'bla "bla\ 12 | bla" bla'; 13 | 14 | var hugeString5 = "bla 'bla\ 15 | bla' bla"; 16 | 17 | var hugeString6 = "bla 'bla'\ 18 | 'bla' bla"; var hugeString7 = "bla 'bla'\ 19 | 'bla' bla"; var hugeString8 = "bla 'bla'\ 20 | 'bla' bla"; 21 | 22 | var theveryHUGEMultiline = "This is probably the biggest leap\ 23 | in functionality for JScript since the 1996 introduction of JScript version 1.0 with Internet Explorer 3.0.\ 24 | JScript has traditionally been used to develop client-side scripts due to its ubiquitous,\ 25 | cross-platform support on the Internet, but we've been seeing a steady increase in the\ 26 | usage of JScript on the server—particularly in Active Server Pages (ASP).\ 27 | For example, your favorite Web site (MSDN) uses a large amount of server-side\ 28 | JScript, as do many other sites on the Internet."; 29 | 30 | function innerFunction() { 31 | //Not visible if previous hugeString declaration was throw error 32 | } 33 | 34 | var f = { 35 | a: "adffsdf\ 36 | dffdf", 37 | b: "adsdadasdas\ 38 | erreer", 39 | testFunction: function () { 40 | } 41 | }; 42 | } -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_StringScriptBlock.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | var s1 = ""; 3 | 4 | var s2 = ''; 5 | 6 | var s3 = '