├── site ├── hot.gif ├── npp │ └── npp.png ├── screen1.PNG ├── screen2.png ├── screen3.png ├── screen4.png ├── screen5.png ├── screen6.png ├── SettingsUI.png ├── menu_location.png ├── vs │ └── dark_theme.png ├── vs2010_html.png ├── vs2010_marks.png ├── MarksFontStyle.png ├── new-icon-small.gif ├── panel_top_menu.png ├── menu_location_old.png ├── screen_FindExample.png ├── screen_optionsdialog.png ├── settings │ └── html-mixed.png ├── screen_define_shortcut.png ├── vs2010_errors_tasklist.png ├── screen_expandcollapseoption.png └── DisplayParametersInFunctionChain.png ├── source ├── JsParser.NppPlugin │ ├── build │ │ └── readme.txt │ ├── DllExport │ │ ├── Mono.Cecil.dll │ │ ├── NppPlugin.DllExport.dll │ │ ├── NppPlugin.DllExport.MSBuild.dll │ │ ├── DllExportAttribute.cs │ │ └── NppPlugin.DllExport.targets │ ├── tools │ │ └── ILMerge │ │ │ ├── ILMerge.exe │ │ │ ├── ILMerge.exe.config │ │ │ └── test.cmd │ ├── Properties │ │ ├── jsparsericon.bmp │ │ └── AssemblyInfo.cs │ ├── packages.config │ ├── Forms │ │ ├── PluginUiPanel.cs │ │ └── PluginUiPanel.designer.cs │ ├── NppPluginBaseInfrastructure │ │ └── NppPluginBaseSpecifics.cs │ ├── Helpers │ │ └── TimerHelper.cs │ ├── NppCodeProvider.cs │ └── JsMapParserPluginSettings.cs ├── JsParser.UI │ ├── obj │ │ └── Debug │ │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs │ │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs │ │ │ └── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs │ ├── Key.snk │ ├── Resources │ │ ├── jsp.png │ │ ├── menu.png │ │ ├── tree.png │ │ ├── type.png │ │ ├── SortAZ.png │ │ ├── Find-icon.png │ │ ├── flag_blue.gif │ │ ├── flag_red.gif │ │ ├── function.png │ │ ├── js_file.gif │ │ ├── refresh.gif │ │ ├── setttings.png │ │ ├── task_List.png │ │ ├── undefined.png │ │ ├── arrow_left.gif │ │ ├── error_icon.png │ │ ├── flag_green.gif │ │ ├── flag_orange.gif │ │ ├── flag_white.gif │ │ ├── js_function.gif │ │ ├── quick-find.png │ │ ├── statistics.jpg │ │ ├── list_settings.gif │ │ ├── navExpandArrow.gif │ │ ├── icon_favourites.gif │ │ ├── navCollapseArrow.gif │ │ ├── treeleaf_collapsed.png │ │ ├── treeleaf_expanded.png │ │ └── variable_declaration.gif │ ├── packages.config │ ├── Infrastructure │ │ ├── IJsParserToolWindow.cs │ │ └── JsParserToolWindowManager.cs │ ├── UI │ │ ├── CustomPanel.cs │ │ ├── CustomTreeNode.cs │ │ ├── SettingsForm.cs │ │ ├── Form_SendStatisticsConfirmation.cs │ │ ├── Palette.cs │ │ ├── CustomTreeView.cs │ │ └── ColorPicker.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Helpers │ │ ├── ExpandedNodesManager.cs │ │ └── StatisticsSender.cs ├── JsParser.Test │ ├── Parser │ │ ├── Source │ │ │ ├── New │ │ │ │ ├── Assignment.js │ │ │ │ ├── InlineOrDecralation.js │ │ │ │ ├── DebuggerKeyword.js │ │ │ │ ├── ReturnStatement.js │ │ │ │ ├── CallbackChain.js │ │ │ │ ├── ArrayChain.js │ │ │ │ ├── Es6_GetSet2.js │ │ │ │ ├── FunctionsHierarchy2.js │ │ │ │ ├── TodoList.js │ │ │ │ ├── FunctionsHierarchy.js │ │ │ │ ├── Comments.js │ │ │ │ └── Es6_GetSet.js │ │ │ ├── Test_FunctionWithPlainObject.js │ │ │ ├── Test_JsonObject_StringPropNames.js │ │ │ ├── Test_AnonymousWithNames.js │ │ │ ├── Test_PropsInArrayStyleNames.js │ │ │ ├── Test5_1.js │ │ │ ├── Test_HierarhizeOnPostProcessing.js │ │ │ ├── Test_DoubleAssign.js │ │ │ ├── Test_NewStatements.js │ │ │ ├── Test_AnonymousSelfExecBlock.js │ │ │ ├── Test_StringScriptBlock.js │ │ │ ├── Test1.js │ │ │ ├── Test_JSParserSkipHandling.js │ │ │ ├── Test_Functions_In_IF_Statement.js │ │ │ ├── Test_Anonimous_In_Return_Statement.js │ │ │ ├── Test5.js │ │ │ ├── Test4.js │ │ │ ├── Test4_2.js │ │ │ ├── Test2.js │ │ │ ├── Test3.js │ │ │ ├── Test_TernerStatements.js │ │ │ ├── Test_AspTagsReplace.aspx │ │ │ ├── Test_XmlComments.js │ │ │ ├── Test_Functions_In_CASE_Statement.js │ │ │ ├── Test_Construct_Object_In_Return_Statement.js │ │ │ ├── Test_Functions_In_TryCatch_Statement.js │ │ │ ├── Test_AspScriptCombiner.aspx │ │ │ ├── Test_StringContinuationCharacter.js │ │ │ ├── Test_ReservedWords_Goto.js │ │ │ ├── Test_RazorSyntax.cshtml │ │ │ └── HtmlScriptBlocks.htm │ │ ├── ExpectedResult │ │ │ ├── New │ │ │ │ ├── Assignment.txt │ │ │ │ ├── InlineOrDecralation.txt │ │ │ │ ├── DebuggerKeyword.txt │ │ │ │ ├── ReturnStatement.txt │ │ │ │ ├── ArrayChain.txt │ │ │ │ ├── Es6_GetSet2.txt │ │ │ │ ├── CallbackChain.txt │ │ │ │ ├── TodoList.txt │ │ │ │ ├── FunctionsHierarchy2.txt │ │ │ │ ├── Es6_GetSet.txt │ │ │ │ ├── Comments.txt │ │ │ │ └── FunctionsHierarchy.txt │ │ │ ├── Test_AspScriptCombiner.txt │ │ │ ├── Test_FunctionWithPlainObject.txt │ │ │ ├── Test_RazorSyntax.txt │ │ │ ├── Test_StringScriptBlock.txt │ │ │ ├── Test_DoubleAssign.txt │ │ │ ├── Test_Functions_In_IF_Statement.txt │ │ │ ├── Test_AspTagsReplace.txt │ │ │ ├── Test5_1.txt │ │ │ ├── Test_JsonObject_StringPropNames.txt │ │ │ ├── Test_NewStatements.txt │ │ │ ├── Test_JSParserSkipHandling.txt │ │ │ ├── Test1.txt │ │ │ ├── Test_AnonymousSelfExecBlock.txt │ │ │ ├── Test_StringContinuationCharacter.txt │ │ │ ├── Test_Anonimous_In_Return_Statement.txt │ │ │ ├── Test5.txt │ │ │ ├── Test_Functions_In_TryCatch_Statement.txt │ │ │ ├── Test_ReservedWords_Goto.txt │ │ │ ├── Test2.txt │ │ │ ├── Test3.txt │ │ │ ├── Test4.txt │ │ │ ├── Test_Functions_In_CASE_Statement.txt │ │ │ ├── Test4_2.txt │ │ │ ├── Test_Construct_Object_In_Return_Statement.txt │ │ │ └── HtmlScriptBlocks.txt │ │ ├── Tests.nunit │ │ ├── Tests.VisualState.xml │ │ ├── JSParserTests_Frameworks.cs │ │ ├── JsParserTests_New.cs │ │ └── TestRunner.cs │ ├── Key.snk │ ├── packages.config │ ├── app.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── AssemblyInfo.cs │ │ └── Settings.Designer.cs │ ├── Program.cs │ ├── Helpers │ │ ├── TestsHelper.cs │ │ └── StringExtText.cs │ ├── Themes │ │ └── ThemeProviderTest.cs │ ├── SimpleCodeProvider.cs │ └── Find │ │ ├── SearchFinalTest.cs │ │ └── FindDialogTest.cs ├── build-Release.cmd ├── Jint.Parser │ ├── Key.snk │ ├── Ast │ │ ├── EmptyStatement.cs │ │ ├── UpdateExpression.cs │ │ ├── DebuggerStatement.cs │ │ ├── ThisExpression.cs │ │ ├── Statement.cs │ │ ├── BreakStatement.cs │ │ ├── ContinueStatement.cs │ │ ├── ReturnStatement.cs │ │ ├── ThrowStatement.cs │ │ ├── ExpressionStatement.cs │ │ ├── CatchClause.cs │ │ ├── WhileStatement.cs │ │ ├── WithStatement.cs │ │ ├── LabeledStatement.cs │ │ ├── DoWhileStatement.cs │ │ ├── VariableDeclarator.cs │ │ ├── BlockStatement.cs │ │ ├── ArrayExpression.cs │ │ ├── ObjectExpression.cs │ │ ├── SequenceExpression.cs │ │ ├── IfStatement.cs │ │ ├── Expression.cs │ │ ├── ConditionalExpression.cs │ │ ├── SwitchCase.cs │ │ ├── CallExpression.cs │ │ ├── ForInStatement.cs │ │ ├── NewExpression.cs │ │ ├── SwitchStatement.cs │ │ ├── VariableDeclaration.cs │ │ ├── Identifier.cs │ │ ├── IPropertyKeyExpression.cs │ │ ├── Literal.cs │ │ ├── MemberExpression.cs │ │ ├── ForStatement.cs │ │ ├── TryStatement.cs │ │ ├── RegExpLiteral.cs │ │ ├── Property.cs │ │ ├── SyntaxNode.cs │ │ ├── Program.cs │ │ ├── LogicalExpression.cs │ │ ├── FunctionExpression.cs │ │ ├── FunctionDeclaration.cs │ │ ├── SyntaxNodes.cs │ │ ├── UnaryExpression.cs │ │ ├── AssignmentExpression.cs │ │ └── BinaryExpression.cs │ ├── Position.cs │ ├── Loc.cs │ ├── Comment.cs │ ├── ParserOptions.cs │ ├── IFunctionDeclaration.cs │ ├── ParserException.cs │ ├── State.cs │ ├── IVariableScope.cs │ ├── IFunctionScope.cs │ ├── Token.cs │ ├── ParserExtensions.cs │ ├── LICENSE.txt │ ├── Properties │ │ └── AssemblyInfo.cs │ └── StringPrototype.cs ├── JsParser.Core │ ├── Key.snk │ ├── Code │ │ ├── CodeNodeType.cs │ │ ├── ICodeProvider.cs │ │ ├── CodeNodeComparer.cs │ │ └── CodeNode.cs │ ├── Parsers │ │ ├── TaskListItem.cs │ │ ├── IJavascriptParser.cs │ │ ├── CommentWrapper.cs │ │ ├── NodesPostProcessor.cs │ │ ├── JSParserResult.cs │ │ ├── TaskListAggregator.cs │ │ ├── ParserContext.cs │ │ ├── JSParserExtensions.cs │ │ ├── CommentsAgregator.cs │ │ └── JavascriptParser.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── SharedAssemblyInfo.cs │ ├── Helpers │ │ ├── ErrorHandler.cs │ │ ├── CustomTraceListener.cs │ │ ├── HierarchyComparer.cs │ │ └── Hierachy.cs │ ├── Infrastructure │ │ └── JsParserService.cs │ └── Search │ │ └── SearchHelper.cs ├── .editorconfig ├── JsParser.VsExtension │ ├── Key.snk │ ├── jsparser_icon.png │ ├── screen_shot_mini.png │ ├── Resources │ │ ├── error_icon.png │ │ └── Images_24bit1.bmp │ ├── PkgCmdID.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Guids.cs │ ├── GlobalSuppressions.cs │ ├── UI │ │ ├── JsParserNavTreeHolder.xaml.cs │ │ ├── JsParserNavTreeHolder.xaml │ │ ├── JSParserErrorsNotificationMarginFactory.cs │ │ └── ErrorsNotificationControl.xaml │ ├── License.txt │ ├── packages.config │ ├── source.extension.vsixmanifest │ ├── OptionsUI │ │ └── OptionsPageCustom.cs │ └── Infrastructure │ │ └── VS2010CodeProvider.cs └── packages │ └── repositories.config ├── .gitignore └── README.md /site/hot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/hot.gif -------------------------------------------------------------------------------- /site/npp/npp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/npp/npp.png -------------------------------------------------------------------------------- /site/screen1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen1.PNG -------------------------------------------------------------------------------- /site/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen2.png -------------------------------------------------------------------------------- /site/screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen3.png -------------------------------------------------------------------------------- /site/screen4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen4.png -------------------------------------------------------------------------------- /site/screen5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen5.png -------------------------------------------------------------------------------- /site/screen6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen6.png -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/build/readme.txt: -------------------------------------------------------------------------------- 1 | Here should be copied the result of build process -------------------------------------------------------------------------------- /source/JsParser.UI/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/JsParser.UI/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/JsParser.UI/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /site/SettingsUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/SettingsUI.png -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/Assignment.js: -------------------------------------------------------------------------------- 1 | window.globalFunc = function() { 2 | 3 | } -------------------------------------------------------------------------------- /site/menu_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/menu_location.png -------------------------------------------------------------------------------- /site/vs/dark_theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/vs/dark_theme.png -------------------------------------------------------------------------------- /site/vs2010_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/vs2010_html.png -------------------------------------------------------------------------------- /site/vs2010_marks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/vs2010_marks.png -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/InlineOrDecralation.js: -------------------------------------------------------------------------------- 1 | var func = options.func || function() {} -------------------------------------------------------------------------------- /source/build-Release.cmd: -------------------------------------------------------------------------------- 1 | C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild ^ 2 | JSparser.sln -------------------------------------------------------------------------------- /site/MarksFontStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/MarksFontStyle.png -------------------------------------------------------------------------------- /site/new-icon-small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/new-icon-small.gif -------------------------------------------------------------------------------- /site/panel_top_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/panel_top_menu.png -------------------------------------------------------------------------------- /site/menu_location_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/menu_location_old.png -------------------------------------------------------------------------------- /site/screen_FindExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen_FindExample.png -------------------------------------------------------------------------------- /source/Jint.Parser/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/Jint.Parser/Key.snk -------------------------------------------------------------------------------- /source/JsParser.UI/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Key.snk -------------------------------------------------------------------------------- /site/screen_optionsdialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen_optionsdialog.png -------------------------------------------------------------------------------- /site/settings/html-mixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/settings/html-mixed.png -------------------------------------------------------------------------------- /source/JsParser.Core/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.Core/Key.snk -------------------------------------------------------------------------------- /source/JsParser.Test/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.Test/Key.snk -------------------------------------------------------------------------------- /site/screen_define_shortcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen_define_shortcut.png -------------------------------------------------------------------------------- /site/vs2010_errors_tasklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/vs2010_errors_tasklist.png -------------------------------------------------------------------------------- /source/.editorconfig: -------------------------------------------------------------------------------- 1 | ; Top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 -------------------------------------------------------------------------------- /site/screen_expandcollapseoption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/screen_expandcollapseoption.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/jsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/jsp.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/menu.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/tree.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/type.png -------------------------------------------------------------------------------- /source/JsParser.VsExtension/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.VsExtension/Key.snk -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/SortAZ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/SortAZ.png -------------------------------------------------------------------------------- /site/DisplayParametersInFunctionChain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/site/DisplayParametersInFunctionChain.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/Find-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/Find-icon.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/flag_blue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/flag_blue.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/flag_red.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/flag_red.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/function.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/js_file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/js_file.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/refresh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/refresh.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/setttings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/setttings.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/task_List.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/task_List.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/undefined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/undefined.png -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/New/DebuggerKeyword.js: -------------------------------------------------------------------------------- 1 | function Aha() { 2 | debugger; 3 | 4 | function Inner() { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/arrow_left.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/arrow_left.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/error_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/error_icon.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/flag_green.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/flag_green.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/flag_orange.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/flag_orange.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/flag_white.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/flag_white.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/js_function.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/js_function.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/quick-find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/quick-find.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/statistics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/statistics.jpg -------------------------------------------------------------------------------- /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.UI/Resources/list_settings.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/list_settings.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/navExpandArrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/navExpandArrow.gif -------------------------------------------------------------------------------- /source/JsParser.VsExtension/jsparser_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.VsExtension/jsparser_icon.png -------------------------------------------------------------------------------- /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/UpdateExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class UpdateExpression : UnaryExpression 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/icon_favourites.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/icon_favourites.gif -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/navCollapseArrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/navCollapseArrow.gif -------------------------------------------------------------------------------- /source/JsParser.VsExtension/screen_shot_mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.VsExtension/screen_shot_mini.png -------------------------------------------------------------------------------- /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/ThisExpression.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ThisExpression : Expression 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.NppPlugin/DllExport/Mono.Cecil.dll -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/tools/ILMerge/ILMerge.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.NppPlugin/tools/ILMerge/ILMerge.exe -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/treeleaf_collapsed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/treeleaf_collapsed.png -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/treeleaf_expanded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/treeleaf_expanded.png -------------------------------------------------------------------------------- /source/JsParser.VsExtension/Resources/error_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.VsExtension/Resources/error_icon.png -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/Properties/jsparsericon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.NppPlugin/Properties/jsparsericon.bmp -------------------------------------------------------------------------------- /source/JsParser.UI/Resources/variable_declaration.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.UI/Resources/variable_declaration.gif -------------------------------------------------------------------------------- /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/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/Test_JsonObject_StringPropNames.js: -------------------------------------------------------------------------------- 1 | var testObj = { 2 | "OK": function () { 3 | }, 4 | "Cancel": function () { 5 | } 6 | } -------------------------------------------------------------------------------- /source/JsParser.VsExtension/Resources/Images_24bit1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.VsExtension/Resources/Images_24bit1.bmp -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.dll -------------------------------------------------------------------------------- /source/JsParser.Test/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /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/Position.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser 2 | { 3 | public struct Position 4 | { 5 | public int Line; 6 | public int Column; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /source/JsParser.UI/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /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/ReturnStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ReturnStatement : Statement 4 | { 5 | public Expression Argument; 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/JsParser.Test/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.MSBuild.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/megaboich/js-map-parser/HEAD/source/JsParser.NppPlugin/DllExport/NppPlugin.DllExport.MSBuild.dll -------------------------------------------------------------------------------- /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/Jint.Parser/Ast/ExpressionStatement.cs: -------------------------------------------------------------------------------- 1 | namespace Jint.Parser.Ast 2 | { 3 | public class ExpressionStatement : Statement 4 | { 5 | public Expression Expression; 6 | } 7 | } -------------------------------------------------------------------------------- /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/New/ArrayChain.js: -------------------------------------------------------------------------------- 1 | var promises = [ 2 | function loadFirst() { 3 | 4 | }, 5 | function loadSecond() { 6 | 7 | }, 8 | function loadThird() { 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/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/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/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/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/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/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/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/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/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/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/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/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/packages/repositories.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/JsParser.NppPlugin/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /source/JsParser.NppPlugin/tools/ILMerge/ILMerge.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /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/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/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/JsParser.UI/Infrastructure/IJsParserToolWindow.cs: -------------------------------------------------------------------------------- 1 | using JsParser.UI.UI; 2 | 3 | namespace JsParser.UI.Infrastructure 4 | { 5 | public interface IJsParserToolWindow 6 | { 7 | NavigationTreeView NavigationTreeView { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /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/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/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/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/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 | } -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/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/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/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.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/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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/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.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/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_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/Tests.nunit: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /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/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/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/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.UI/UI/CustomPanel.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace JsParser.UI.UI 4 | { 5 | public class CustomPanel : Panel 6 | { 7 | public CustomPanel() 8 | : base() 9 | { 10 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/JsParser.VsExtension/PkgCmdID.cs: -------------------------------------------------------------------------------- 1 | // PkgCmdID.cs 2 | // MUST match PkgCmdID.h 3 | using System; 4 | 5 | namespace JsParser.VsExtension 6 | { 7 | static class PkgCmdIDList 8 | { 9 | public const uint cmdJsParser = 0x101; 10 | 11 | public const uint cmdJsParserFind = 0x102; 12 | }; 13 | } -------------------------------------------------------------------------------- /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/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/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/Source/Test_StringScriptBlock.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | var s1 = ""; 3 | 4 | var s2 = ''; 5 | 6 | var s3 = ' 21 | 22 | <%----%> -------------------------------------------------------------------------------- /source/JsParser.Test/Parser/Source/Test_XmlComments.js: -------------------------------------------------------------------------------- 1 | 2 | /// 3 | /// Function F1 - the main purpose is to illustrate XML comments working. 4 | /// 5 | /// Parameter that is responsible for everything on this planet. 6 | /// Returns literally nothing, just to have a lot text in it. 7 | function F1() { 8 | value.properties.push(new (acc ? Access : Index)(idx)); 9 | } 10 | 11 | function F2() { } 12 | 13 | function F3(def, classdef) { 14 | obj.prototype = new this(PROTO); 15 | return obj; 16 | }; 17 | 18 | function F4() { } 19 | -------------------------------------------------------------------------------- /source/JsParser.VsExtension/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Resources; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("JsParser.Package")] 11 | [assembly: AssemblyProduct("JsParser.Package")] 12 | [assembly: AssemblyDescription("")] 13 | [assembly: AssemblyConfiguration("")] 14 | 15 | -------------------------------------------------------------------------------- /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.VsExtension/Guids.cs: -------------------------------------------------------------------------------- 1 | // Guids.cs 2 | // MUST match guids.h 3 | using System; 4 | 5 | namespace JsParser.VsExtension 6 | { 7 | static class GuidList 8 | { 9 | public const string guidJsParserPackagePkgString = "85fcde11-d0ea-4b3e-b03a-79b16c2379f7"; 10 | public const string guidJsParserPackageCmdSetString = "a770d5ac-aede-4255-84a2-c3fc9d3e8e96"; 11 | public const string guidToolWindowPersistanceString = "5c1947b9-a2ea-42cd-8299-f2603a9c033d"; 12 | 13 | public static readonly Guid guidJsParserPackageCmdSet = new Guid(guidJsParserPackageCmdSetString); 14 | }; 15 | } -------------------------------------------------------------------------------- /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.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_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.VsExtension/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. Project-level 3 | // suppressions either have no target or are given a specific target 4 | // and scoped to a namespace, type, member, etc. 5 | // 6 | // To add a suppression to this file, right-click the message in the 7 | // Error List, point to "Suppress Message(s)", and click "In Project 8 | // Suppression File". You do not need to add suppressions to this 9 | // file manually. 10 | 11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")] 12 | -------------------------------------------------------------------------------- /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.UI/UI/SettingsForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | 5 | namespace JsParser.UI.UI 6 | { 7 | public partial class SettingsForm : Form 8 | { 9 | public SettingsForm(Font defaultTreeFont) 10 | { 11 | InitializeComponent(); 12 | jsParserSettingsControl1.DefaultTreeFont = defaultTreeFont; 13 | jsParserSettingsControl1.InitSettings(); 14 | } 15 | 16 | private void button1_Click(object sender, EventArgs e) 17 | { 18 | jsParserSettingsControl1.SaveSettings(); 19 | Close(); 20 | } 21 | 22 | private void button2_Click(object sender, EventArgs e) 23 | { 24 | Close(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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/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/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/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/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/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_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/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/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.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/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.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.Test/Parser/Tests.VisualState.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [0-1000]D:\Dev\Projects\js-addin\trunk\UnitTests\Tests.nunit 4 | [0-1001]UnitTests.AutoTester 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /source/JsParser.VsExtension/UI/JsParserNavTreeHolder.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace JsParser.VsExtension.UI 16 | { 17 | /// 18 | /// Interaction logic for JsParserHolder.xaml 19 | /// 20 | public partial class JsParserNavTreeHolder : UserControl 21 | { 22 | public JsParserNavTreeHolder() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /source/JsParser.VsExtension/UI/JsParserNavTreeHolder.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /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.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/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/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/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/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/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/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.UI/UI/Form_SendStatisticsConfirmation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace JsParser.UI.UI 5 | { 6 | public partial class Form_SendStatisticsConfirmation : Form 7 | { 8 | public Form_SendStatisticsConfirmation() 9 | { 10 | InitializeComponent(); 11 | DialogResult = DialogResult.Ignore; 12 | } 13 | 14 | private void button1_Click(object sender, EventArgs e) 15 | { 16 | if (checkBox1.Checked) 17 | { 18 | DialogResult = DialogResult.OK; 19 | } 20 | else 21 | { 22 | DialogResult = DialogResult.Cancel; 23 | } 24 | 25 | Close(); 26 | } 27 | 28 | private void button2_Click(object sender, EventArgs e) 29 | { 30 | Close(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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/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.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.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/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/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/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.UI/UI/Palette.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | 5 | namespace JsParser.UI.UI 6 | { 7 | public class Palette: IDisposable 8 | { 9 | private Dictionary _solidBrushes = new Dictionary(); 10 | 11 | public Brush GetSolidBrush(Color c) 12 | { 13 | Brush br; 14 | if (_solidBrushes.TryGetValue(c.ToArgb(), out br)) 15 | { 16 | return br; 17 | } 18 | else 19 | { 20 | br = new SolidBrush(c); 21 | _solidBrushes.Add(c.ToArgb(), br); 22 | return br; 23 | } 24 | } 25 | 26 | public void CleanUp() 27 | { 28 | foreach (var kv in _solidBrushes) 29 | { 30 | kv.Value.Dispose(); 31 | } 32 | 33 | _solidBrushes.Clear(); 34 | } 35 | 36 | public void Dispose() 37 | { 38 | CleanUp(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /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/JsParser.VsExtension/License.txt: -------------------------------------------------------------------------------- 1 | Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php. Copyright (C) 2016 by Oleksandr Boiko. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 3 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 4 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /source/JsParser.VsExtension/UI/JSParserErrorsNotificationMarginFactory.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using Microsoft.VisualStudio.Text.Editor; 3 | using Microsoft.VisualStudio.Utilities; 4 | using Microsoft.VisualStudio.Text; 5 | 6 | namespace JsParser.VsExtension.UI 7 | { 8 | /// 9 | /// Export a , which returns an instance of the margin for the editor 10 | /// to use. 11 | /// 12 | [Export(typeof(IWpfTextViewMarginProvider))] 13 | [Name(ErrorsNotificationControl.MarginName)] 14 | [MarginContainer(PredefinedMarginNames.Top)] //Set the container to the bottom of the editor window 15 | [ContentType("text")] //Show this margin for all text-based types 16 | [TextViewRole(PredefinedTextViewRoles.Interactive)] 17 | public sealed class JSParserErrorsNotificationMarginFactory : IWpfTextViewMarginProvider 18 | { 19 | public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) 20 | { 21 | return new ErrorsNotificationControl(textViewHost.TextView); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /source/JsParser.Test/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17020 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace JsParserTest.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 18 | 19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 20 | 21 | public static Settings Default { 22 | get { 23 | return defaultInstance; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /source/JsParser.Test/Themes/ThemeProviderTest.cs: -------------------------------------------------------------------------------- 1 | using JsParser.UI.UI; 2 | using NUnit.Framework; 3 | using System.Linq; 4 | 5 | namespace JsParser.Test.Themes 6 | { 7 | [TestFixture] 8 | public class ThemeProviderTest 9 | { 10 | [Test] 11 | public void TestDefaults() 12 | { 13 | var tp = ThemeProvider.Deserialize("something wrong"); 14 | var themes = tp.GetThemes(); 15 | Assert.AreEqual(3, themes.Count()); 16 | 17 | var defTheme = themes.First(); 18 | Assert.AreEqual("Light", defTheme.Name); 19 | } 20 | 21 | [Test] 22 | public void TestAddAndSerialize() 23 | { 24 | var tp = ThemeProvider.Deserialize("something wrong"); 25 | tp.AddTheme("new"); 26 | var themes = tp.GetThemes(); 27 | Assert.AreEqual(4, themes.Count()); 28 | 29 | var serialized = tp.Serialize(); 30 | var ntp = ThemeProvider.Deserialize(serialized); 31 | 32 | Assert.AreEqual(4, ntp.GetThemes().Count()); 33 | var serialized2 = ntp.Serialize(); 34 | 35 | Assert.AreEqual(serialized, serialized2); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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/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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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.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.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/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/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/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/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.UI/Helpers/ExpandedNodesManager.cs: -------------------------------------------------------------------------------- 1 | using JsParser.UI.UI; 2 | using System.Collections.Generic; 3 | 4 | namespace JsParser.UI.Helpers 5 | { 6 | class ExpandedNodesManager 7 | { 8 | private Dictionary> _storage = new Dictionary>(); 9 | private string _activeDocName; 10 | private Dictionary _activeStorage; 11 | 12 | public void SetFile(string activeDocumentName ) 13 | { 14 | _activeDocName = activeDocumentName; 15 | if (!HasDocumentInStorage(_activeDocName)) 16 | { 17 | _storage.Add(_activeDocName, new Dictionary()); 18 | } 19 | 20 | _activeStorage = _storage[_activeDocName]; 21 | } 22 | 23 | public bool HasDocumentInStorage(string docName) 24 | { 25 | return _storage.ContainsKey(docName); 26 | } 27 | 28 | public Dictionary ActiveStorage 29 | { 30 | get 31 | { 32 | return _activeStorage; 33 | } 34 | } 35 | 36 | public bool? IsNoteExpanded(CustomTreeNode node) 37 | { 38 | var storage = ActiveStorage; 39 | var nodeKey = GetNodeKey(node); 40 | if (storage.ContainsKey(nodeKey)) 41 | { 42 | return storage[nodeKey]; 43 | } 44 | 45 | return null; 46 | } 47 | 48 | public void SetExpandedState(CustomTreeNode node) 49 | { 50 | ActiveStorage[GetNodeKey(node)] = node.IsExpanded; 51 | } 52 | 53 | private string GetNodeKey(CustomTreeNode node) 54 | { 55 | return node.CodeNode.StartLine + "_(" + node.Text + ")"; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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/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/JsParser.VsExtension/UI/ErrorsNotificationControl.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 15 | 17 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /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/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.NppPlugin/DllExport/NppPlugin.DllExport.targets: -------------------------------------------------------------------------------- 1 | 3 | 5 | 8 | 9 | 11 | $(DevEnvDir)\..\..\VC\bin 12 | 13 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /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.UI/UI/CustomTreeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows.Forms; 4 | 5 | namespace JsParser.UI.UI 6 | { 7 | public class CustomTreeView : TreeView 8 | { 9 | private const int WM_HSCROL = 0x114; 10 | private const int WM_VSCROLL = 0x115; 11 | private const int WM_MOUSEWHEEL = 0x20A; 12 | 13 | public enum ScrollType 14 | { 15 | Vertical, 16 | Horizontal 17 | } 18 | 19 | public class ScrollEventArgs: EventArgs 20 | { 21 | public ScrollType ScrollType{get;set;} 22 | } 23 | 24 | public delegate void ScrollEventHandler(object sender, ScrollEventArgs e); 25 | 26 | [Description("UserControlOnLoadDescr")] 27 | [Category("CatBehavior")] 28 | public event ScrollEventHandler OnScroll; 29 | 30 | public CustomTreeView() 31 | : base() 32 | { 33 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 34 | } 35 | 36 | protected override void WndProc(ref Message m) 37 | { 38 | var scrollType = ScrollType.Vertical; 39 | switch (m.Msg) 40 | { 41 | case WM_HSCROL: 42 | scrollType = ScrollType.Horizontal; 43 | goto action; 44 | case WM_MOUSEWHEEL: 45 | case WM_VSCROLL: 46 | action:; 47 | OnScroll.Invoke( 48 | this, 49 | new ScrollEventArgs { ScrollType = scrollType }); 50 | break; 51 | } 52 | 53 | base.WndProc(ref m); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /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.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/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/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/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.UI/UI/ColorPicker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Drawing; 4 | using System.Windows.Forms; 5 | 6 | namespace JsParser.UI.UI 7 | { 8 | public partial class ColorPicker : UserControl 9 | { 10 | private bool _skipTextBoxEvent = false; 11 | 12 | [Description("SelectedColorChanged")] 13 | [Category("CatBehavior")] 14 | public event EventHandler SelectedColorChanged; 15 | 16 | public Color SelectedColor 17 | { 18 | get { return panel1.BackColor; } 19 | set 20 | { 21 | panel1.BackColor = value; 22 | _skipTextBoxEvent = true; 23 | textBox1.Text = ColorTranslator.ToHtml(panel1.BackColor); 24 | _skipTextBoxEvent = false; 25 | if (SelectedColorChanged != null) 26 | { 27 | SelectedColorChanged(this, EventArgs.Empty); 28 | } 29 | } 30 | } 31 | 32 | public ColorPicker() 33 | { 34 | InitializeComponent(); 35 | } 36 | 37 | private void panel1_Paint(object sender, PaintEventArgs e) 38 | { 39 | 40 | } 41 | 42 | private void panel1_Click(object sender, EventArgs e) 43 | { 44 | colorDialog1.Color = SelectedColor; 45 | if (colorDialog1.ShowDialog() == DialogResult.OK) 46 | { 47 | SelectedColor = colorDialog1.Color; 48 | } 49 | } 50 | 51 | private void textBox1_TextChanged(object sender, EventArgs e) 52 | { 53 | if (_skipTextBoxEvent) 54 | { 55 | return; 56 | } 57 | 58 | var text = textBox1.Text; 59 | try 60 | { 61 | var color = ColorTranslator.FromHtml(text); 62 | panel1.BackColor = color; 63 | } 64 | catch 65 | { 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /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/JsParser.UI/Helpers/StatisticsSender.cs: -------------------------------------------------------------------------------- 1 | using JsParser.UI.Properties; 2 | using JsParser.UI.UI; 3 | using System; 4 | 5 | namespace JsParser.UI.Helpers 6 | { 7 | public static class StatisticsSender 8 | { 9 | public static void Send() 10 | { 11 | if (Settings.Default.SendStatistics && Settings.Default.SendStatisticsPolitic == "Approved") 12 | { 13 | //all is OK - just send it 14 | StatisticsManager.Instance.SubmitStatisticsToServer(); 15 | return; 16 | } 17 | 18 | //Ask user if it is normal to send statistics 19 | if (Settings.Default.SendStatisticsPolitic == "Ask" 20 | && StatisticsManager.Instance.Statistics.FirstDateUse.AddDays(3) < DateTime.UtcNow 21 | && StatisticsManager.Instance.Statistics.NavigateFromFunctionsTreeCount > 10) 22 | { 23 | var askForm = new Form_SendStatisticsConfirmation(); 24 | var result = askForm.ShowDialog(); 25 | if (result == System.Windows.Forms.DialogResult.OK) 26 | { 27 | //set OK settings 28 | Settings.Default.SendStatisticsPolitic = "Approved"; 29 | Settings.Default.SendStatistics = true; 30 | Settings.Default.Save(); 31 | 32 | //call self recursively 33 | Send(); 34 | return; 35 | } 36 | 37 | if (result == System.Windows.Forms.DialogResult.Cancel) 38 | { 39 | //no - user don't want this shit 40 | Settings.Default.SendStatisticsPolitic = "Not allowed"; 41 | Settings.Default.SendStatistics = false; 42 | Settings.Default.Save(); 43 | 44 | return; 45 | } 46 | 47 | if (result == System.Windows.Forms.DialogResult.Ignore) 48 | { 49 | //just do nothing - only update Last submitting time 50 | StatisticsManager.Instance.Statistics.LastSubmittedTime = DateTime.UtcNow; 51 | Settings.Default.Save(); 52 | return; 53 | } 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /source/JsParser.VsExtension/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /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.VsExtension/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JavaScript Map Parser 5 | Oleksandr Boiko 6 | 4.1 7 | Extension for Visual Studio that shows a map for JavaScript code in a separate panel. 8 | 1033 9 | https://github.com/megaboich/js-map-parser/wiki 10 | License.txt 11 | https://github.com/megaboich/js-map-parser/wiki/Getting-Started 12 | jsparser_icon.png 13 | screen_shot_mini.png 14 | false 15 | 16 | 17 | Ultimate 18 | Premium 19 | Pro 20 | 21 | 22 | Ultimate 23 | Premium 24 | Pro 25 | 26 | 27 | Ultimate 28 | Premium 29 | Pro 30 | 31 | 32 | Ultimate 33 | Premium 34 | Pro 35 | 36 | 37 | Ultimate 38 | Premium 39 | Pro 40 | 41 | 42 | 43 | 44 | 45 | 46 | Visual Studio MPF 47 | 48 | 49 | 50 | |%CurrentProject%;PkgdefProjectOutputGroup| 51 | |%CurrentProject%| 52 | 53 | 54 | -------------------------------------------------------------------------------- /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.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/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.Test/SimpleCodeProvider.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using System.Linq; 3 | using System.Windows.Forms; 4 | 5 | namespace JsParser.Test 6 | { 7 | public class SimpleCodeProvider :ICodeProvider 8 | { 9 | private string _name; 10 | private string _path; 11 | private RichTextBox _textBox; 12 | 13 | public SimpleCodeProvider(RichTextBox textBox, string path, string name) 14 | { 15 | _textBox = textBox; 16 | _name = name; 17 | _path = path; 18 | ContainerName = typeof(SimpleCodeProvider).Assembly.FullName; 19 | } 20 | 21 | #region ICodeProvider Members 22 | 23 | public string LoadCode() 24 | { 25 | return _textBox.Text; 26 | } 27 | 28 | public string Path 29 | { 30 | get { return _path; } 31 | } 32 | 33 | public string Name 34 | { 35 | get { return _name; } 36 | } 37 | 38 | public string FullName 39 | { 40 | get 41 | { 42 | return System.IO.Path.Combine(Path, Name); 43 | } 44 | } 45 | 46 | public void SelectionMoveToLineAndOffset(int startLine, int startColumn) 47 | { 48 | if (startLine == 1) 49 | { 50 | _textBox.Select(startLine + startColumn - 1, 0); 51 | } 52 | else 53 | { 54 | var textLen = _textBox.Lines.Take(startLine - 1).Select(l => l.Length + 1).Aggregate((t, l) => t += l); 55 | _textBox.Select(textLen + startColumn - 1, 0); 56 | } 57 | } 58 | 59 | public void SetFocus() 60 | { 61 | _textBox.Focus(); 62 | } 63 | 64 | public void GetCursorPos(out int line, out int column) 65 | { 66 | try 67 | { 68 | var cursorPos = _textBox.SelectionStart; 69 | line = 1 + _textBox.GetLineFromCharIndex(cursorPos); 70 | column = 1; 71 | } 72 | 73 | /* 74 | var cumLength = 0; 75 | int i = 0; 76 | var cursorPos = _textBox.SelectionStart; 77 | for (; i < _textBox.Lines.Length; ++i) 78 | { 79 | var curLineLength = _textBox.Lines[i].Length + 1; 80 | cumLength += curLineLength; 81 | 82 | if (cumLength > cursorPos) 83 | { 84 | line = i + 1; //one-based index 85 | column = cursorPos - cumLength + curLineLength; 86 | return; 87 | } 88 | }*/ 89 | 90 | catch 91 | { 92 | line = -1; 93 | column = -1; 94 | } 95 | } 96 | 97 | #endregion 98 | 99 | 100 | public string ContainerName {get; set;} 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /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.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.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.VsExtension/OptionsUI/OptionsPageCustom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | using System.ComponentModel; 5 | using Microsoft.VisualStudio.Shell; 6 | using System.Runtime.InteropServices; 7 | using JsParser.UI.UI; 8 | using System.Diagnostics; 9 | 10 | namespace JsParser.VsExtension 11 | { 12 | /// 13 | /// Extends a standard dialog functionality for implementing ToolsOptions pages, 14 | /// with support for the Visual Studio automation model, Windows Forms, and state 15 | /// persistence through the Visual Studio settings mechanism. 16 | /// 17 | [Guid("C5B955B9-6220-4DC9-9B46-C3ECE0D66B69")] 18 | public class OptionsPageCustom : DialogPage 19 | { 20 | #region Fields 21 | 22 | private JsParserSettingsControl _settingsUI; 23 | private bool _needReinitOnActivate = false; 24 | 25 | #endregion Fields 26 | 27 | #region Properties 28 | /// 29 | /// Gets the window an instance of DialogPage that it uses as its user interface. 30 | /// 31 | /// 32 | /// The window this dialog page will use for its UI. 33 | /// This window handle must be constant, so if you are 34 | /// returning a Windows Forms control you must make sure 35 | /// it does not recreate its handle. If the window object 36 | /// implements IComponent it will be sited by the 37 | /// dialog page so it can get access to global services. 38 | /// 39 | [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] 40 | protected override IWin32Window Window 41 | { 42 | get 43 | { 44 | return SettingsUI; 45 | } 46 | } 47 | 48 | protected JsParserSettingsControl SettingsUI 49 | { 50 | get 51 | { 52 | if (_settingsUI == null) 53 | { 54 | _settingsUI = new JsParser.UI.UI.JsParserSettingsControl(); 55 | _settingsUI.Location = new Point(0, 0); 56 | _settingsUI.Dock = DockStyle.Fill; 57 | _settingsUI.InitSettings(); 58 | } 59 | 60 | return _settingsUI; 61 | } 62 | } 63 | 64 | protected override void OnApply(PageApplyEventArgs e) 65 | { 66 | SettingsUI.SaveSettings(); 67 | _needReinitOnActivate = true; 68 | base.OnApply(e); 69 | } 70 | 71 | protected override void OnClosed(EventArgs e) 72 | { 73 | SettingsUI.InitSettings(); 74 | _needReinitOnActivate = true; 75 | base.OnClosed(e); 76 | } 77 | 78 | protected override void OnActivate(CancelEventArgs e) 79 | { 80 | if (_needReinitOnActivate) 81 | { 82 | SettingsUI.InitSettings(); 83 | } 84 | 85 | _needReinitOnActivate = false; 86 | base.OnActivate(e); 87 | } 88 | 89 | protected override void OnDeactivate(CancelEventArgs e) 90 | { 91 | base.OnDeactivate(e); 92 | } 93 | 94 | #endregion Properties 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /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/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.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.VsExtension/Infrastructure/VS2010CodeProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using JsParser.Core.Code; 6 | using EnvDTE80; 7 | using EnvDTE; 8 | using System.Threading; 9 | 10 | namespace JsParser.VsExtension.Infrastructure 11 | { 12 | public class VS2010CodeProvider : ICodeProvider 13 | { 14 | private readonly Document _activeDocument; 15 | 16 | public VS2010CodeProvider(Document activeDocument) 17 | { 18 | _activeDocument = activeDocument; 19 | 20 | ContainerName = "Visual Studio " + activeDocument.DTE.Version; 21 | } 22 | 23 | private Document Doc 24 | { 25 | get 26 | { 27 | return _activeDocument; 28 | } 29 | } 30 | 31 | #region ICodeProvider Members 32 | 33 | public string LoadCode() 34 | { 35 | try 36 | { 37 | var textDocument = (TextDocument)Doc.Object("TextDocument"); 38 | var docContent = textDocument.CreateEditPoint(textDocument.StartPoint).GetText(textDocument.EndPoint); 39 | return docContent; 40 | } 41 | catch 42 | { 43 | return "function Error_Loading_Document(){}"; 44 | } 45 | } 46 | 47 | public string FullName 48 | { 49 | get 50 | { 51 | return System.IO.Path.Combine(Path, Name); 52 | } 53 | } 54 | 55 | public string Path 56 | { 57 | get { return Doc != null ? Doc.Path : string.Empty; } 58 | } 59 | 60 | public string Name 61 | { 62 | get { return Doc != null ? Doc.Name : string.Empty; } 63 | } 64 | 65 | public void SelectionMoveToLineAndOffset(int StartLine, int StartColumn) 66 | { 67 | try 68 | { 69 | var textDocument = (TextDocument)Doc.Object("TextDocument"); 70 | textDocument.Selection.MoveToLineAndOffset(StartLine, StartColumn, false); 71 | } 72 | catch 73 | { 74 | } 75 | } 76 | 77 | public void SetFocus() 78 | { 79 | if (Doc == null) 80 | { 81 | return; 82 | } 83 | 84 | Doc.Activate(); 85 | //ThreadPool.QueueUserWorkItem((state) => 86 | //{ 87 | // try 88 | // { 89 | // Doc.Activate(); 90 | // } 91 | // catch { } 92 | //}, null); 93 | } 94 | 95 | public void GetCursorPos(out int line, out int column) 96 | { 97 | line = -1; 98 | column = -1; 99 | try 100 | { 101 | var textDocument = (TextDocument)Doc.Object("TextDocument"); 102 | if (textDocument != null) 103 | { 104 | line = textDocument.Selection.ActivePoint.Line; 105 | column = textDocument.Selection.ActivePoint.DisplayColumn; 106 | } 107 | } 108 | catch 109 | { 110 | line = -1; 111 | column = -1; 112 | } 113 | } 114 | 115 | #endregion 116 | 117 | 118 | public string ContainerName {get; set;} 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /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/JsParser.UI/Infrastructure/JsParserToolWindowManager.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using JsParser.Core.Infrastructure; 3 | using JsParser.UI.UI; 4 | using System; 5 | 6 | namespace JsParser.UI.Infrastructure 7 | { 8 | public class JsParserToolWindowManager 9 | { 10 | string _activeDocFullName; 11 | JsParserService _jsParserService; 12 | Func _findWindowDelegate; 13 | 14 | public JsParserToolWindowManager( 15 | JsParserService jsParserService, 16 | Func findWindowDelegate) 17 | 18 | { 19 | _jsParserService = jsParserService; 20 | _findWindowDelegate = findWindowDelegate; 21 | } 22 | 23 | public string ActiveDocFullName 24 | { 25 | get 26 | { 27 | return _activeDocFullName; 28 | } 29 | } 30 | 31 | public void PerformInitialParsing(NavigationTreeView navTree = null) 32 | { 33 | if (navTree == null) 34 | { 35 | navTree = _findWindowDelegate().NavigationTreeView; 36 | } 37 | if (_jsParserService.Code != null) 38 | { 39 | var result = _jsParserService.Process(_jsParserService.Code, skipHashCheck: true); 40 | if (navTree != null) 41 | { 42 | navTree.UpdateTree(result, _jsParserService.Code); 43 | } 44 | } 45 | } 46 | 47 | public void CallParserForDocument(ICodeProvider codeProvider) 48 | { 49 | _activeDocFullName = codeProvider.FullName; 50 | 51 | var result = _jsParserService.Process(codeProvider); 52 | 53 | var toolWindow = _findWindowDelegate(); 54 | 55 | if (result == null) 56 | { 57 | // Not JS case - need to clean tree 58 | _jsParserService.InvalidateCash(); 59 | if (toolWindow != null) 60 | { 61 | toolWindow.NavigationTreeView.Clear(); 62 | } 63 | 64 | return; 65 | } 66 | 67 | if (result.IsEmpty) 68 | { 69 | // skip - cached result 70 | return; 71 | } 72 | 73 | JsParserEventsBroadcaster.FireActionsForDoc( 74 | _activeDocFullName, 75 | new JsParserErrorsNotificationArgs 76 | { 77 | Code = codeProvider, 78 | FullFileName = _activeDocFullName, 79 | Errors = result.Errors 80 | }); 81 | 82 | if (toolWindow != null) 83 | { 84 | toolWindow.NavigationTreeView.UpdateTree(result, codeProvider); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /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.Test/Parser/TestRunner.cs: -------------------------------------------------------------------------------- 1 | using JsParser.Core.Code; 2 | using JsParser.Core.Helpers; 3 | using JsParser.Core.Parsers; 4 | using JsParser.Test.Helpers; 5 | using JsParserTest.Helpers; 6 | using NUnit.Framework; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | 10 | namespace JsParser.Test.Parser 11 | { 12 | public static class TestRunner 13 | { 14 | /// 15 | /// The comparer for code node. 16 | /// 17 | public class CodeNodeAssertComparer : Comparer 18 | { 19 | public override int Compare(CodeNode x, CodeNode y) 20 | { 21 | Assert.IsNotNull(x); 22 | Assert.IsNotNull(y); 23 | 24 | Assert.AreEqual(x.StartLine, y.StartLine); 25 | Assert.AreEqual(x.EndLine, y.EndLine); 26 | Assert.AreEqual(x.Alias, y.Alias); 27 | Assert.AreEqual(x.Comment, y.Comment); 28 | Assert.AreEqual(x.NodeType, y.NodeType); 29 | 30 | return 0; 31 | } 32 | } 33 | 34 | public static JSParserResult RunTest(string sourceName, string resultName) 35 | { 36 | var source = TestsHelper.GetEmbeddedText("JsParser.Test.Parser.Source." + sourceName); 37 | 38 | // Fix line endings in test files. All should be unix way, but on some GIT clients it is updated automatically. 39 | source = source.Replace("\r\n", "\n"); 40 | 41 | var settings = new JavascriptParserSettings(); 42 | var actualResult = (new JavascriptParser(settings)).Parse(source, sourceName); 43 | 44 | var outDir = "C:\\js_parser_units_output"; 45 | Directory.CreateDirectory(outDir); 46 | 47 | // Save actual hierarchy xml 48 | var serialized = SimpleHierarchySerializer.Serialize(actualResult.Nodes); 49 | File.WriteAllText(outDir + "\\" + resultName, serialized); 50 | 51 | // Load test data 52 | var resName = "JsParser.Test.Parser.ExpectedResult." + resultName; 53 | 54 | var passed = false; 55 | if (TestsHelper.CheckEmbeddedRes(resName)) 56 | { 57 | File.WriteAllText(outDir + "\\" + resultName, SimpleHierarchySerializer.Serialize(actualResult.Nodes)); 58 | 59 | var expectedresultSerialized = TestsHelper.GetEmbeddedText(resName); 60 | var expectedresult = SimpleHierarchySerializer.Deserialize(expectedresultSerialized); 61 | 62 | // Save expected hierarchy serialized 63 | File.WriteAllText(outDir + "\\" + resultName + ".ex", expectedresultSerialized); 64 | 65 | if (HierarchyComparer.Compare(actualResult.Nodes, expectedresult, new CodeNodeAssertComparer())) 66 | { 67 | passed = true; 68 | } 69 | } 70 | 71 | Assert.IsTrue(passed); 72 | 73 | return actualResult; 74 | } 75 | } 76 | } 77 | --------------------------------------------------------------------------------