├── .gitattributes ├── .gitignore ├── LICENSE ├── NPPXmlTreeview.sln ├── README.md ├── appveyor.yml ├── build.cake ├── build.ps1 ├── build.sh ├── src ├── NppXmlTreeviewPlugin.Parsers │ ├── NppXmlNode.cs │ ├── NppXmlNodePosition.cs │ ├── NppXmlTreeviewPlugin.Parsers.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config └── NppXmlTreeviewPlugin │ ├── DllExport │ ├── DllExportAttribute.cs │ ├── Mono.Cecil.dll │ ├── NppPlugin.DllExport.MSBuild.dll │ ├── NppPlugin.DllExport.dll │ └── NppPlugin.DllExport.targets │ ├── Extensions │ └── StringExtensions.cs │ ├── Forms │ ├── FormAbout.Designer.cs │ ├── FormAbout.cs │ ├── FormAbout.resx │ ├── FormTreeView.Designer.cs │ ├── FormTreeView.cs │ ├── FormTreeView.resx │ └── MenuButton.cs │ ├── Main.cs │ ├── NppPluginNETBase.cs │ ├── NppPluginNETHelper.cs │ ├── NppXmlTreeviewPlugin.csproj │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── star.png │ └── star_bmp.bmp │ ├── Resources │ ├── blue-document-tree.png │ ├── node-name.png │ ├── toggle-expand.png │ └── toggle.png │ ├── TextBoundary.cs │ ├── UnmanagedExports.cs │ └── packages.config └── tests └── NppXmlTreeviewPlugin.Parsers.Tests.Unit ├── NppXmlTreeviewPlugin.Parsers.Tests.Unit.csproj ├── Properties └── AssemblyInfo.cs ├── Stubs └── LoggerStub.cs ├── TestFiles ├── invalid_comments.xml ├── invalid_nocomments.xml ├── valid_comments.xml └── valid_nocomments.xml ├── WhenParsingInvalidXml.cs ├── WhenParsingValidXml.cs └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | 290 | # Cake 291 | tools/* 292 | tools/**/* 293 | 294 | # Nuget Packages 295 | **/*.nupkg 296 | 297 | # Rider 298 | .idea/ 299 | *.*.iml 300 | 301 | # VSCode 302 | .vscode/ 303 | 304 | # artifacts 305 | artifacts/ 306 | 307 | # publish 308 | publish/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /NPPXmlTreeview.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2043 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A574CF2B-F7EF-4656-906A-730C2A8DB6C0}" 7 | ProjectSection(SolutionItems) = preProject 8 | LICENSE = LICENSE 9 | README.md = README.md 10 | EndProjectSection 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NppXmlTreeviewPlugin", "src\NppXmlTreeviewPlugin\NppXmlTreeviewPlugin.csproj", "{E56F6E12-089C-40ED-BCFD-923E5FA121A1}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NppXmlTreeviewPlugin.Parsers", "src\NppXmlTreeviewPlugin.Parsers\NppXmlTreeviewPlugin.Parsers.csproj", "{EABA4132-6E8C-41EC-B6F0-666EFCA5439A}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{0B3B9BE3-29A4-494C-A373-E104940FB537}" 17 | ProjectSection(SolutionItems) = preProject 18 | appveyor.yml = appveyor.yml 19 | build.cake = build.cake 20 | build.ps1 = build.ps1 21 | build.sh = build.sh 22 | EndProjectSection 23 | EndProject 24 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2800F860-8256-4EF2-BB05-C64D0039617D}" 25 | EndProject 26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9F6C2373-27E9-4FF6-B96A-480F95E10711}" 27 | EndProject 28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NppXmlTreeviewPlugin.Parsers.Tests.Unit", "tests\NppXmlTreeviewPlugin.Parsers.Tests.Unit\NppXmlTreeviewPlugin.Parsers.Tests.Unit.csproj", "{B73045E6-591E-4356-9B25-69D058D40ADB}" 29 | EndProject 30 | Global 31 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 32 | Debug|Any CPU = Debug|Any CPU 33 | Debug|x64 = Debug|x64 34 | Debug|x86 = Debug|x86 35 | Release|Any CPU = Release|Any CPU 36 | Release|x64 = Release|x64 37 | Release|x86 = Release|x86 38 | EndGlobalSection 39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 40 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Debug|x64.ActiveCfg = Debug|x64 43 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Debug|x64.Build.0 = Debug|x64 44 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Debug|x86.ActiveCfg = Debug|Any CPU 45 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Debug|x86.Build.0 = Debug|Any CPU 46 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Release|x64.ActiveCfg = Release|x64 49 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Release|x64.Build.0 = Release|x64 50 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Release|x86.ActiveCfg = Release|Any CPU 51 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1}.Release|x86.Build.0 = Release|Any CPU 52 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Debug|x64.ActiveCfg = Debug|x64 55 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Debug|x64.Build.0 = Debug|x64 56 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Debug|x86.ActiveCfg = Debug|Any CPU 57 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Debug|x86.Build.0 = Debug|Any CPU 58 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Release|x64.ActiveCfg = Release|x64 61 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Release|x64.Build.0 = Release|x64 62 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Release|x86.ActiveCfg = Release|Any CPU 63 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A}.Release|x86.Build.0 = Release|Any CPU 64 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Debug|x64.ActiveCfg = Debug|x64 67 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Debug|x64.Build.0 = Debug|x64 68 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Debug|x86.ActiveCfg = Debug|Any CPU 69 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Debug|x86.Build.0 = Debug|Any CPU 70 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Release|Any CPU.Build.0 = Release|Any CPU 72 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Release|x64.ActiveCfg = Release|x64 73 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Release|x64.Build.0 = Release|x64 74 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Release|x86.ActiveCfg = Release|Any CPU 75 | {B73045E6-591E-4356-9B25-69D058D40ADB}.Release|x86.Build.0 = Release|Any CPU 76 | EndGlobalSection 77 | GlobalSection(SolutionProperties) = preSolution 78 | HideSolutionNode = FALSE 79 | EndGlobalSection 80 | GlobalSection(NestedProjects) = preSolution 81 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1} = {2800F860-8256-4EF2-BB05-C64D0039617D} 82 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A} = {2800F860-8256-4EF2-BB05-C64D0039617D} 83 | {B73045E6-591E-4356-9B25-69D058D40ADB} = {9F6C2373-27E9-4FF6-B96A-480F95E10711} 84 | EndGlobalSection 85 | GlobalSection(ExtensibilityGlobals) = postSolution 86 | SolutionGuid = {61C37722-AAD8-4166-A3F3-7F48A5C49BFC} 87 | EndGlobalSection 88 | EndGlobal 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Notepadd++ XML Treeview Plugin 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/mvhq920dyybn775a?svg=true)](https://ci.appveyor.com/project/joaoasrosa/nppxmltreeview) 4 | 5 | An Notepadd++ XML Treeview Plugin. 6 | Since the lack of an treeview to visualize XML, this plugin fill the gap. Base on C# displays the XML document as treeview. 7 | 8 | All pull requests and contributions are welcome. 9 | 10 | You can find the installation instructions [here](https://github.com/joaoasrosa/nppxmltreeview/wiki). 11 | 12 | The project is license under [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). 13 | 14 | Plugin based on [Notepad++ C# template](http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download). 15 | 16 | [PostSharp](https://www.postsharp.net/) supports this project with a OSS license. 17 | 18 | The plugin use the icons from the project [p.yusukekamiyamane](http://p.yusukekamiyamane.com/). 19 | 20 | ## New owner wanted 21 | 22 | This project is looking for a new owner! At the moment I can't support it anymore. However, I believe that it is an valuable plugin to the community! 23 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | image: Visual Studio 2017 3 | build_script: 4 | - ps: .\build.ps1 --target=AppVeyor --configuration=Release 5 | test: off 6 | artifacts: 7 | - path: .\artifacts\NppXmlTreeviewPlugin_*.zip 8 | name: nppxmltreeview 9 | deploy: 10 | - provider: GitHub 11 | tag: Rome v$(appveyor_build_version) 12 | release: NppTreeViewPlugin Rome v$(appveyor_build_version) 13 | auth_token: 14 | secure: yYYP2c1jtrjIbccXBUjTmCqdGWnI5AxPgNUfNhjZZrpA81Y+DKsGh3wamK/pOSMt 15 | artifact: 16 | draft: true 17 | on: 18 | branch: master -------------------------------------------------------------------------------- /build.cake: -------------------------------------------------------------------------------- 1 | #tool "nuget:?package=GitVersion.CommandLine" 2 | #tool "nuget:?package=xunit.runner.console&version=2.3.1" 3 | #addin "nuget:?package=Cake.DependenciesAnalyser&version=2.0.0" 4 | 5 | /////////////////////////////////////////////////////////////////////////////// 6 | // ARGUMENTS 7 | /////////////////////////////////////////////////////////////////////////////// 8 | 9 | var target = Argument("target", "Default"); 10 | var configuration = Argument("configuration", "Debug"); 11 | var verbosity = Argument("verbosity", "Minimal"); 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | // GLOBAL VARIABLES 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | var sourceDir = Directory("./src"); 18 | var testsDir = Directory("./tests"); 19 | 20 | var solutions = GetFiles("./**/*.sln"); 21 | 22 | GitVersion gitVersion = null; 23 | 24 | // USED TO CREATE ZIP PACKAGES 25 | var createPackage = false; 26 | 27 | // BUILD OUTPUT DIRECTORIES 28 | var artifactsDir = Directory("./artifacts"); 29 | 30 | // VERBOSITY 31 | var msBuildVerbosity = Cake.Core.Diagnostics.Verbosity.Diagnostic; 32 | if (!Enum.TryParse(verbosity, true, out msBuildVerbosity)) 33 | { 34 | Warning( 35 | "Verbosity could not be parsed into type 'Cake.Core.Diagnostics.Verbosity'. Defaulting to {0}", 36 | msBuildVerbosity); 37 | } 38 | 39 | /////////////////////////////////////////////////////////////////////////////// 40 | // COMMON FUNCTION DEFINITIONS 41 | /////////////////////////////////////////////////////////////////////////////// 42 | 43 | void Test(string testDllGlob) 44 | { 45 | var settings = new XUnit2Settings(); 46 | 47 | Information("Testing '{0}'...", testDllGlob); 48 | XUnit2(testDllGlob, settings); 49 | Information("'{0}' has been tested.", testDllGlob); 50 | } 51 | 52 | void Build(PlatformTarget platformTarget) 53 | { 54 | var settings = new MSBuildSettings 55 | { 56 | Verbosity = msBuildVerbosity, 57 | Configuration = configuration, 58 | PlatformTarget = platformTarget, 59 | ToolVersion = MSBuildToolVersion.VS2015 60 | }; 61 | 62 | foreach(var solution in solutions) 63 | { 64 | Information("Building '{0}'...", solution.FullPath); 65 | MSBuild(solution.FullPath, settings); 66 | Information("'{0}' has been built.", solution.FullPath); 67 | } 68 | } 69 | 70 | void Pack(string directory, string outputFile) 71 | { 72 | var directoryToClean = string.Format("{0}*.pdb", directory); 73 | 74 | Information("Cleaning '{0}'...", directoryToClean); 75 | DeleteFiles(directoryToClean); 76 | Information("'{0}' has been cleaned.", directoryToClean); 77 | 78 | directoryToClean = string.Format("{0}*.xml", directory); 79 | 80 | Information("Cleaning '{0}'...", directoryToClean); 81 | DeleteFiles(directoryToClean); 82 | Information("'{0}' has been cleaned.", directoryToClean); 83 | 84 | Information("Compressing '{0}' to '{1}'...", directory, outputFile); 85 | Zip(directory, outputFile); 86 | Information("'{0}' has been compressed to '{1}'.", directory, outputFile); 87 | } 88 | 89 | void CopyPlugin(string source, string destination) 90 | { 91 | var directoryToClean = string.Format("{0}*.pdb", source); 92 | 93 | Information("Cleaning '{0}'...", directoryToClean); 94 | DeleteFiles(directoryToClean); 95 | Information("'{0}' has been cleaned.", directoryToClean); 96 | 97 | directoryToClean = string.Format("{0}*.xml", source); 98 | 99 | Information("Cleaning '{0}'...", directoryToClean); 100 | DeleteFiles(directoryToClean); 101 | Information("'{0}' has been cleaned.", directoryToClean); 102 | 103 | Information("Copying '{0}' to '{1}'...", source, destination); 104 | CopyDirectory(source, destination); 105 | Information("'{0}' has been copied to '{1}'.", source, destination); 106 | } 107 | 108 | /////////////////////////////////////////////////////////////////////////////// 109 | // SETUP / TEARDOWN 110 | /////////////////////////////////////////////////////////////////////////////// 111 | 112 | Setup(ctx => 113 | { 114 | // Executed BEFORE the first task. 115 | EnsureDirectoryExists(artifactsDir); 116 | Information("Running tasks..."); 117 | }); 118 | 119 | Teardown(ctx => 120 | { 121 | // Executed AFTER the last task. 122 | Information("Finished running tasks."); 123 | }); 124 | 125 | /////////////////////////////////////////////////////////////////////////////// 126 | // TASK DEFINITIONS 127 | /////////////////////////////////////////////////////////////////////////////// 128 | 129 | Task("Clean") 130 | .Description("Cleans all directories that are used during the build process.") 131 | .Does(() => 132 | { 133 | foreach(var solution in solutions) 134 | { 135 | Information("Cleaning {0}", solution.FullPath); 136 | CleanDirectories(sourceDir.Path + "/**/bin/*"); 137 | CleanDirectories(sourceDir.Path + "/**/obj/*"); 138 | CleanDirectories(testsDir.Path + "/**/bin/*"); 139 | CleanDirectories(testsDir.Path + "/**/obj/*"); 140 | Information("{0} was clean.", solution.FullPath); 141 | } 142 | 143 | CleanDirectory(artifactsDir); 144 | }); 145 | 146 | 147 | Task("Restore") 148 | .Description("Restores all the NuGet packages that are used by the specified solution.") 149 | .Does(() => 150 | { 151 | var settings = new NuGetRestoreSettings 152 | { 153 | MSBuildVersion = NuGetMSBuildVersion.MSBuild14, 154 | NoCache = true, 155 | Verbosity = NuGetVerbosity.Normal 156 | }; 157 | 158 | foreach(var solution in solutions) 159 | { 160 | Information("Restoring NuGet packages for '{0}'...", solution); 161 | NuGetRestore(solution, settings); 162 | Information("NuGet packages restored for '{0}'.", solution); 163 | } 164 | }); 165 | 166 | Task("SemVer") 167 | .Description("Applies the SemVer to all the different parts of the project.") 168 | .Does(() => 169 | { 170 | var settings = new GitVersionSettings 171 | { 172 | UpdateAssemblyInfo = true 173 | }; 174 | 175 | Information("Applying SemVer."); 176 | gitVersion = GitVersion(settings); 177 | Information("SemVer has been applied."); 178 | }); 179 | 180 | Task("Build") 181 | .Description("Builds all the different parts of the project.") 182 | .Does(() => 183 | { 184 | Build(PlatformTarget.MSIL); 185 | Build(PlatformTarget.x64); 186 | }); 187 | 188 | Task("Test-Unit") 189 | .Description("Runs all your unit tests, using dotnet CLI.") 190 | .Does(() => 191 | { 192 | var unitTestsProjects = $"./tests/**/bin/{configuration}/**/*.Tests.Unit.dll"; 193 | Test(unitTestsProjects); 194 | 195 | unitTestsProjects = $"./tests/**/bin/x64/{configuration}/**/*.Tests.Unit.dll"; 196 | Test(unitTestsProjects); 197 | }); 198 | 199 | Task("Dependencies-Analyse") 200 | .Description("Runs the Dependencies Analyser on the solution.") 201 | .Does(() => 202 | { 203 | var settings = new DependenciesAnalyserSettings 204 | { 205 | Folder = "./src/" 206 | }; 207 | 208 | Information("Analysing dependencies on folder '{0}'...", sourceDir.Path); 209 | AnalyseDependencies(settings); 210 | Information("'{0}' dependencies for the projects had been analysed.", sourceDir.Path); 211 | }); 212 | 213 | Task("AppVeyor-Pack") 214 | .Description("Prepares to pack the project, using AppVeyor.") 215 | .Does(() => 216 | { 217 | var tagBuildEnvVar = EnvironmentVariable("APPVEYOR_REPO_TAG"); 218 | bool.TryParse(tagBuildEnvVar, out createPackage); 219 | }); 220 | 221 | Task("Local-Pack") 222 | .Description("Prepares to pack the project, using local environment.") 223 | .Does(() => 224 | { 225 | createPackage = true; 226 | }); 227 | 228 | Task("Pack") 229 | .Description("Packs all the different parts of the project.") 230 | .Does(() => 231 | { 232 | if(!createPackage) 233 | { 234 | Information("Skipping the Zip pack step."); 235 | return; 236 | } 237 | 238 | var patternFolder = "./src/NppXmlTreeviewPlugin/bin/{0}/"; 239 | var patternOutput = "{0}/NppXMLTreeViewPlugin_{1}.zip"; 240 | var platform = "x86"; 241 | 242 | Pack( 243 | string.Format(patternFolder, configuration), 244 | string.Format(patternOutput, artifactsDir.Path, platform)); 245 | 246 | patternFolder = "./src/NppXmlTreeviewPlugin/bin/x64/{0}/"; 247 | platform = "x64"; 248 | 249 | Pack( 250 | string.Format(patternFolder, configuration), 251 | string.Format(patternOutput, artifactsDir.Path, platform)); 252 | }); 253 | 254 | Task("Local-Deploy") 255 | .Description("Deploys the puglin, using local environment.") 256 | .Does(() => 257 | { 258 | var patternFolder = "./src/NppXmlTreeviewPlugin/bin/{0}/"; 259 | 260 | CopyPlugin( 261 | string.Format(patternFolder, configuration), 262 | @"C:\Program Files (x86)\Notepad++\plugins"); 263 | 264 | patternFolder = "./src/NppXmlTreeviewPlugin/bin/x64/{0}/"; 265 | 266 | CopyPlugin( 267 | string.Format(patternFolder, configuration), 268 | @"C:\Program Files\Notepad++\plugins"); 269 | }); 270 | 271 | /////////////////////////////////////////////////////////////////////////////// 272 | // COMBINATIONS - let's make life easier... 273 | /////////////////////////////////////////////////////////////////////////////// 274 | 275 | Task("Build+Test") 276 | .Description("First runs Build, then Test targets.") 277 | .IsDependentOn("Clean") 278 | .IsDependentOn("Restore") 279 | .IsDependentOn("SemVer") 280 | .IsDependentOn("Build") 281 | .IsDependentOn("Test-Unit") 282 | .Does(() => { Information("Ran Build+Test target"); }); 283 | 284 | Task("Rebuild") 285 | .Description("Runs a full Clean+Restore+Build build.") 286 | .IsDependentOn("Clean") 287 | .IsDependentOn("Restore") 288 | .IsDependentOn("SemVer") 289 | .IsDependentOn("Build") 290 | .Does(() => { Information("Rebuilt everything"); }); 291 | 292 | Task("Test-All") 293 | .Description("Runs all your tests.") 294 | .IsDependentOn("Test-Unit") 295 | .Does(() => { Information("Tested everything"); }); 296 | 297 | Task("Analyse") 298 | .Description("Analyse the solution.") 299 | .IsDependentOn("Build+Test") 300 | .IsDependentOn("Dependencies-Analyse") 301 | .Does(() => { Information("Analyses done"); }); 302 | 303 | Task("LocalPack") 304 | .Description("Runs locally.") 305 | .IsDependentOn("Clean") 306 | .IsDependentOn("Restore") 307 | .IsDependentOn("SemVer") 308 | .IsDependentOn("Build") 309 | .IsDependentOn("Test-Unit") 310 | //.IsDependentOn("Dependencies-Analyse") 311 | .IsDependentOn("Local-Pack") 312 | .IsDependentOn("Pack") 313 | .Does(() => { Information("Everything is done! Well done Local Pack."); }); 314 | 315 | Task("LocalDeploy") 316 | .Description("Runs locally.") 317 | .IsDependentOn("Clean") 318 | .IsDependentOn("Restore") 319 | .IsDependentOn("SemVer") 320 | .IsDependentOn("Build") 321 | .IsDependentOn("Test-Unit") 322 | //.IsDependentOn("Dependencies-Analyse") 323 | .IsDependentOn("Local-Deploy") 324 | .Does(() => { Information("Everything is done! Well done Local Deploy."); }); 325 | 326 | Task("AppVeyor") 327 | .Description("Runs on AppVeyor after 'merging master'.") 328 | .IsDependentOn("Clean") 329 | .IsDependentOn("Restore") 330 | .IsDependentOn("SemVer") 331 | .IsDependentOn("Build") 332 | .IsDependentOn("Test-Unit") 333 | //.IsDependentOn("Dependencies-Analyse") 334 | .IsDependentOn("AppVeyor-Pack") 335 | .IsDependentOn("Pack") 336 | .Does(() => { Information("Everything is done! Well done AppVeyor."); }); 337 | 338 | /////////////////////////////////////////////////////////////////////////////// 339 | // DEFAULT TARGET 340 | /////////////////////////////////////////////////////////////////////////////// 341 | 342 | Task("Default") 343 | .Description("This is the default task which will run if no specific target is passed in.") 344 | .IsDependentOn("Build+Test") 345 | .Does(() => { Warning("No 'Target' was passed in, so we ran the 'Build+Test' operation."); }); 346 | 347 | /////////////////////////////////////////////////////////////////////////////// 348 | // EXECUTION 349 | /////////////////////////////////////////////////////////////////////////////// 350 | 351 | RunTarget(target); -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This is the Cake bootstrapper script for PowerShell. 3 | # This file was downloaded from https://github.com/cake-build/resources 4 | # Feel free to change this file to fit your needs. 5 | ########################################################################## 6 | 7 | <# 8 | 9 | .SYNOPSIS 10 | This is a Powershell script to bootstrap a Cake build. 11 | 12 | .DESCRIPTION 13 | This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) 14 | and execute your Cake build script with the parameters you provide. 15 | 16 | .PARAMETER Script 17 | The build script to execute. 18 | .PARAMETER Target 19 | The build script target to run. 20 | .PARAMETER Configuration 21 | The build configuration to use. 22 | .PARAMETER Verbosity 23 | Specifies the amount of information to be displayed. 24 | .PARAMETER ShowDescription 25 | Shows description about tasks. 26 | .PARAMETER DryRun 27 | Performs a dry run. 28 | .PARAMETER Experimental 29 | Uses the nightly builds of the Roslyn script engine. 30 | .PARAMETER Mono 31 | Uses the Mono Compiler rather than the Roslyn script engine. 32 | .PARAMETER SkipToolPackageRestore 33 | Skips restoring of packages. 34 | .PARAMETER ScriptArgs 35 | Remaining arguments are added here. 36 | 37 | .LINK 38 | https://cakebuild.net 39 | 40 | #> 41 | 42 | [CmdletBinding()] 43 | Param( 44 | [string]$Script = "build.cake", 45 | [string]$Target, 46 | [string]$Configuration, 47 | [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] 48 | [string]$Verbosity, 49 | [switch]$ShowDescription, 50 | [Alias("WhatIf", "Noop")] 51 | [switch]$DryRun, 52 | [switch]$Experimental, 53 | [switch]$Mono, 54 | [switch]$SkipToolPackageRestore, 55 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 56 | [string[]]$ScriptArgs 57 | ) 58 | 59 | [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null 60 | function MD5HashFile([string] $filePath) 61 | { 62 | if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) 63 | { 64 | return $null 65 | } 66 | 67 | [System.IO.Stream] $file = $null; 68 | [System.Security.Cryptography.MD5] $md5 = $null; 69 | try 70 | { 71 | $md5 = [System.Security.Cryptography.MD5]::Create() 72 | $file = [System.IO.File]::OpenRead($filePath) 73 | return [System.BitConverter]::ToString($md5.ComputeHash($file)) 74 | } 75 | finally 76 | { 77 | if ($file -ne $null) 78 | { 79 | $file.Dispose() 80 | } 81 | } 82 | } 83 | 84 | function GetProxyEnabledWebClient 85 | { 86 | $wc = New-Object System.Net.WebClient 87 | $proxy = [System.Net.WebRequest]::GetSystemWebProxy() 88 | $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials 89 | $wc.Proxy = $proxy 90 | return $wc 91 | } 92 | 93 | Write-Host "Preparing to run build script..." 94 | 95 | if(!$PSScriptRoot){ 96 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 97 | } 98 | 99 | $TOOLS_DIR = Join-Path $PSScriptRoot "tools" 100 | $ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" 101 | $MODULES_DIR = Join-Path $TOOLS_DIR "Modules" 102 | $NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" 103 | $CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" 104 | $NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" 105 | $PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" 106 | $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" 107 | $ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" 108 | $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" 109 | 110 | # Make sure tools folder exists 111 | if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { 112 | Write-Verbose -Message "Creating tools directory..." 113 | New-Item -Path $TOOLS_DIR -Type directory | out-null 114 | } 115 | 116 | # Make sure that packages.config exist. 117 | if (!(Test-Path $PACKAGES_CONFIG)) { 118 | Write-Verbose -Message "Downloading packages.config..." 119 | try { 120 | $wc = GetProxyEnabledWebClient 121 | $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { 122 | Throw "Could not download packages.config." 123 | } 124 | } 125 | 126 | # Try find NuGet.exe in path if not exists 127 | if (!(Test-Path $NUGET_EXE)) { 128 | Write-Verbose -Message "Trying to find nuget.exe in PATH..." 129 | $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } 130 | $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 131 | if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { 132 | Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." 133 | $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName 134 | } 135 | } 136 | 137 | # Try download NuGet.exe if not exists 138 | if (!(Test-Path $NUGET_EXE)) { 139 | Write-Verbose -Message "Downloading NuGet.exe..." 140 | try { 141 | $wc = GetProxyEnabledWebClient 142 | $wc.DownloadFile($NUGET_URL, $NUGET_EXE) 143 | } catch { 144 | Throw "Could not download NuGet.exe." 145 | } 146 | } 147 | 148 | # Save nuget.exe path to environment to be available to child processed 149 | $ENV:NUGET_EXE = $NUGET_EXE 150 | 151 | # Restore tools from NuGet? 152 | if(-Not $SkipToolPackageRestore.IsPresent) { 153 | Push-Location 154 | Set-Location $TOOLS_DIR 155 | 156 | # Check for changes in packages.config and remove installed tools if true. 157 | [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) 158 | if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or 159 | ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { 160 | Write-Verbose -Message "Missing or changed package.config hash..." 161 | Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | 162 | Remove-Item -Recurse 163 | } 164 | 165 | Write-Verbose -Message "Restoring tools from NuGet..." 166 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" 167 | 168 | if ($LASTEXITCODE -ne 0) { 169 | Throw "An error occurred while restoring NuGet tools." 170 | } 171 | else 172 | { 173 | $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" 174 | } 175 | Write-Verbose -Message ($NuGetOutput | out-string) 176 | 177 | Pop-Location 178 | } 179 | 180 | # Restore addins from NuGet 181 | if (Test-Path $ADDINS_PACKAGES_CONFIG) { 182 | Push-Location 183 | Set-Location $ADDINS_DIR 184 | 185 | Write-Verbose -Message "Restoring addins from NuGet..." 186 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" 187 | 188 | if ($LASTEXITCODE -ne 0) { 189 | Throw "An error occurred while restoring NuGet addins." 190 | } 191 | 192 | Write-Verbose -Message ($NuGetOutput | out-string) 193 | 194 | Pop-Location 195 | } 196 | 197 | # Restore modules from NuGet 198 | if (Test-Path $MODULES_PACKAGES_CONFIG) { 199 | Push-Location 200 | Set-Location $MODULES_DIR 201 | 202 | Write-Verbose -Message "Restoring modules from NuGet..." 203 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" 204 | 205 | if ($LASTEXITCODE -ne 0) { 206 | Throw "An error occurred while restoring NuGet modules." 207 | } 208 | 209 | Write-Verbose -Message ($NuGetOutput | out-string) 210 | 211 | Pop-Location 212 | } 213 | 214 | # Make sure that Cake has been installed. 215 | if (!(Test-Path $CAKE_EXE)) { 216 | Throw "Could not find Cake.exe at $CAKE_EXE" 217 | } 218 | 219 | 220 | 221 | # Build Cake arguments 222 | $cakeArguments = @("$Script"); 223 | if ($Target) { $cakeArguments += "-target=$Target" } 224 | if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } 225 | if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } 226 | if ($ShowDescription) { $cakeArguments += "-showdescription" } 227 | if ($DryRun) { $cakeArguments += "-dryrun" } 228 | if ($Experimental) { $cakeArguments += "-experimental" } 229 | if ($Mono) { $cakeArguments += "-mono" } 230 | $cakeArguments += $ScriptArgs 231 | 232 | # Start Cake 233 | Write-Host "Running build script..." 234 | &$CAKE_EXE $cakeArguments 235 | exit $LASTEXITCODE 236 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ########################################################################## 4 | # This is the Cake bootstrapper script for Linux and OS X. 5 | # This file was downloaded from https://github.com/cake-build/resources 6 | # Feel free to change this file to fit your needs. 7 | ########################################################################## 8 | 9 | # Define directories. 10 | SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 11 | TOOLS_DIR=$SCRIPT_DIR/tools 12 | ADDINS_DIR=$TOOLS_DIR/Addins 13 | MODULES_DIR=$TOOLS_DIR/Modules 14 | NUGET_EXE=$TOOLS_DIR/nuget.exe 15 | CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe 16 | PACKAGES_CONFIG=$TOOLS_DIR/packages.config 17 | PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum 18 | ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config 19 | MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config 20 | 21 | # Define md5sum or md5 depending on Linux/OSX 22 | MD5_EXE= 23 | if [[ "$(uname -s)" == "Darwin" ]]; then 24 | MD5_EXE="md5 -r" 25 | else 26 | MD5_EXE="md5sum" 27 | fi 28 | 29 | # Define default arguments. 30 | SCRIPT="build.cake" 31 | CAKE_ARGUMENTS=() 32 | 33 | # Parse arguments. 34 | for i in "$@"; do 35 | case $1 in 36 | -s|--script) SCRIPT="$2"; shift ;; 37 | --) shift; CAKE_ARGUMENTS+=("$@"); break ;; 38 | *) CAKE_ARGUMENTS+=("$1") ;; 39 | esac 40 | shift 41 | done 42 | 43 | # Make sure the tools folder exist. 44 | if [ ! -d "$TOOLS_DIR" ]; then 45 | mkdir "$TOOLS_DIR" 46 | fi 47 | 48 | # Make sure that packages.config exist. 49 | if [ ! -f "$TOOLS_DIR/packages.config" ]; then 50 | echo "Downloading packages.config..." 51 | curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages 52 | if [ $? -ne 0 ]; then 53 | echo "An error occurred while downloading packages.config." 54 | exit 1 55 | fi 56 | fi 57 | 58 | # Download NuGet if it does not exist. 59 | if [ ! -f "$NUGET_EXE" ]; then 60 | echo "Downloading NuGet..." 61 | curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe 62 | if [ $? -ne 0 ]; then 63 | echo "An error occurred while downloading nuget.exe." 64 | exit 1 65 | fi 66 | fi 67 | 68 | # Restore tools from NuGet. 69 | pushd "$TOOLS_DIR" >/dev/null 70 | if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then 71 | find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf 72 | fi 73 | 74 | mono "$NUGET_EXE" install -ExcludeVersion 75 | if [ $? -ne 0 ]; then 76 | echo "Could not restore NuGet tools." 77 | exit 1 78 | fi 79 | 80 | $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" 81 | 82 | popd >/dev/null 83 | 84 | # Restore addins from NuGet. 85 | if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then 86 | pushd "$ADDINS_DIR" >/dev/null 87 | 88 | mono "$NUGET_EXE" install -ExcludeVersion 89 | if [ $? -ne 0 ]; then 90 | echo "Could not restore NuGet addins." 91 | exit 1 92 | fi 93 | 94 | popd >/dev/null 95 | fi 96 | 97 | # Restore modules from NuGet. 98 | if [ -f "$MODULES_PACKAGES_CONFIG" ]; then 99 | pushd "$MODULES_DIR" >/dev/null 100 | 101 | mono "$NUGET_EXE" install -ExcludeVersion 102 | if [ $? -ne 0 ]; then 103 | echo "Could not restore NuGet modules." 104 | exit 1 105 | fi 106 | 107 | popd >/dev/null 108 | fi 109 | 110 | # Make sure that Cake has been installed. 111 | if [ ! -f "$CAKE_EXE" ]; then 112 | echo "Could not find Cake.exe at '$CAKE_EXE'." 113 | exit 1 114 | fi 115 | 116 | # Start Cake 117 | exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}" 118 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin.Parsers/NppXmlNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Xml; 6 | 7 | using Serilog; 8 | 9 | namespace NppXmlTreeviewPlugin.Parsers 10 | { 11 | /// 12 | /// Represents a Notepadd++ Xml Node. 13 | /// 14 | public class NppXmlNode 15 | { 16 | private static int _nodeId = 1; 17 | 18 | /// 19 | /// The start position of the node. 20 | /// 21 | public NppXmlNodePosition StartPosition { get; } 22 | 23 | /// 24 | /// The end position of the node. 25 | /// 26 | public NppXmlNodePosition EndPosition { get; private set; } 27 | 28 | /// 29 | /// The name of the node. 30 | /// 31 | public string Name { get; private set; } 32 | 33 | /// 34 | /// Internal id for the node. 35 | /// 36 | public int Id { get; } 37 | 38 | /// 39 | /// The childrens of the node. 40 | /// 41 | public IReadOnlyCollection ChildNodes => _childNodes; 42 | 43 | /// 44 | /// The parent of the node. 45 | /// 46 | private NppXmlNode Parent { get; } 47 | 48 | /// 49 | /// Flag to indicate if the node has child nodes. 50 | /// 51 | public bool HasChildNodes => ChildNodes.Any(); 52 | 53 | private readonly List _childNodes; 54 | 55 | /// 56 | /// The default constructor for the class. 57 | /// 58 | /// The node name. 59 | /// The node start position. 60 | private NppXmlNode(string name, NppXmlNodePosition startPosition) 61 | { 62 | Name = name; 63 | StartPosition = startPosition; 64 | Id = _nodeId; 65 | _childNodes = new List(); 66 | 67 | _nodeId++; 68 | } 69 | 70 | /// 71 | /// The default constructor for the class. 72 | /// 73 | /// The node name. 74 | /// The node start position. 75 | /// The parent node. 76 | private NppXmlNode(string name, NppXmlNodePosition startPosition, NppXmlNode parent) 77 | { 78 | Name = name; 79 | StartPosition = startPosition; 80 | Parent = parent; 81 | Id = _nodeId; 82 | _childNodes = new List(); 83 | 84 | _nodeId++; 85 | } 86 | 87 | /// 88 | /// Returns the first NppXmlNode for the line number. 89 | /// 90 | /// The line number. 91 | /// The position in line. 92 | /// The first NppXmlNode in the line. 93 | public NppXmlNode FindNppXmlNodeByLine(int lineNumber, int positionInLine) 94 | { 95 | if(StartPosition.LineNumber.Equals(lineNumber) 96 | && StartPosition.LinePosition <= positionInLine 97 | && EndPosition.LinePosition >= positionInLine) 98 | return this; 99 | 100 | if(!HasChildNodes) 101 | return null; 102 | 103 | foreach(var nppXmlNode in ChildNodes) 104 | { 105 | var node = nppXmlNode.FindNppXmlNodeByLine(lineNumber, positionInLine); 106 | if(null != node) 107 | return node; 108 | } 109 | 110 | return null; 111 | } 112 | 113 | /// 114 | /// Method to try parse the XML. 115 | /// 116 | /// The XMl as string. 117 | /// The logger. 118 | /// The Notepad++ XmlNode. 119 | /// True if parse successfully, false otherwise. 120 | public static bool TryParse(string xml, ILogger logger, out NppXmlNode nppXmlNode) 121 | { 122 | return TryParse(xml, null, logger, out nppXmlNode); 123 | } 124 | 125 | /// 126 | /// Method to try parse the XML. 127 | /// 128 | /// The XMl as string. 129 | /// 130 | /// The attribute, that will be used as node name. If no one of that attribute, tag name 131 | /// will be used 132 | /// 133 | /// The logger. 134 | /// The Notepad++ XmlNode. 135 | /// True if parse successfully, false otherwise. 136 | public static bool TryParse(string xml, string nodeNameAttribute, ILogger logger, out NppXmlNode nppXmlNode) 137 | { 138 | nppXmlNode = null; 139 | _nodeId = 1; 140 | 141 | try 142 | { 143 | using(var stringReader = new StringReader(xml)) 144 | { 145 | using(var xmlTextReader = new XmlTextReader(stringReader)) 146 | { 147 | while(xmlTextReader.Read()) 148 | { 149 | if(xmlTextReader.NodeType != XmlNodeType.Element || !xmlTextReader.IsStartElement()) 150 | continue; 151 | 152 | nppXmlNode = new NppXmlNode(xmlTextReader.Name, new NppXmlNodePosition(xmlTextReader)); 153 | 154 | ReadChildOrSibling(xmlTextReader, xmlTextReader.Depth, nppXmlNode, nodeNameAttribute); 155 | } 156 | 157 | if(null == nppXmlNode) 158 | throw new ArgumentException("nppXmlNode"); 159 | 160 | nppXmlNode.EndPosition = new NppXmlNodePosition(xmlTextReader, true); 161 | 162 | return true; 163 | } 164 | } 165 | } 166 | catch(Exception exception) 167 | { 168 | logger.Warning(exception, exception.Message); 169 | nppXmlNode = null; 170 | return false; 171 | } 172 | } 173 | 174 | /// 175 | /// Method to read a child or a sibling of the node. 176 | /// 177 | /// The XML text reader. 178 | /// The current depth on the XML tree. 179 | /// The XML node. 180 | /// The node attribute name. 181 | private static void ReadChildOrSibling(XmlTextReader xmlTextReader, 182 | int currentDepth, 183 | NppXmlNode node, 184 | string nodeNameAttribute) 185 | { 186 | var nodeName = xmlTextReader.Name; 187 | if(!string.IsNullOrEmpty(nodeNameAttribute)) 188 | { 189 | var attr = xmlTextReader.GetAttribute(nodeNameAttribute); 190 | if(attr != null) 191 | nodeName = attr; 192 | } 193 | 194 | node.Name = nodeName; 195 | 196 | while(xmlTextReader.Read()) 197 | { 198 | // It's a sibling. 199 | if(currentDepth == xmlTextReader.Depth) 200 | { 201 | if(xmlTextReader.NodeType != XmlNodeType.Element || !xmlTextReader.IsStartElement()) 202 | return; 203 | 204 | var sibling = new NppXmlNode(xmlTextReader.Name, 205 | new NppXmlNodePosition(xmlTextReader), 206 | node.Parent); 207 | node.Parent.AddNode(sibling); 208 | 209 | // Can be a single node. 210 | sibling.EndPosition = new NppXmlNodePosition(xmlTextReader, true); 211 | 212 | ReadChildOrSibling(xmlTextReader, xmlTextReader.Depth, sibling, nodeNameAttribute); 213 | 214 | sibling.EndPosition = new NppXmlNodePosition(xmlTextReader, true); 215 | 216 | return; 217 | } 218 | 219 | if(xmlTextReader.NodeType != XmlNodeType.Element || !xmlTextReader.IsStartElement()) 220 | continue; 221 | 222 | // It's a child. 223 | var child = new NppXmlNode(xmlTextReader.Name, new NppXmlNodePosition(xmlTextReader), node); 224 | node.AddNode(child); 225 | 226 | // Can be a single node. 227 | child.EndPosition = new NppXmlNodePosition(xmlTextReader, true); 228 | 229 | ReadChildOrSibling(xmlTextReader, xmlTextReader.Depth, child, nodeNameAttribute); 230 | 231 | child.EndPosition = new NppXmlNodePosition(xmlTextReader, true); 232 | } 233 | } 234 | 235 | private void AddNode(NppXmlNode node) 236 | { 237 | _childNodes.Add(node); 238 | } 239 | } 240 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin.Parsers/NppXmlNodePosition.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | 3 | namespace NppXmlTreeviewPlugin.Parsers 4 | { 5 | /// 6 | /// The npp xml node position. 7 | /// 8 | public class NppXmlNodePosition 9 | { 10 | /// 11 | /// The line number. 12 | /// 13 | public int LineNumber { get; } 14 | 15 | /// 16 | /// The line position. 17 | /// 18 | public int LinePosition { get; } 19 | 20 | /// 21 | /// Internal constructor 22 | /// 23 | /// The XML text reader. 24 | /// Flag to indicate if it is a end position. 25 | internal NppXmlNodePosition(XmlTextReader xmlTextReader, bool isEndPosition = false) 26 | { 27 | LineNumber = xmlTextReader.LineNumber - 1; 28 | LinePosition = xmlTextReader.LinePosition + (isEndPosition ? xmlTextReader.Name.Length : -2); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin.Parsers/NppXmlTreeviewPlugin.Parsers.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {EABA4132-6E8C-41EC-B6F0-666EFCA5439A} 8 | Library 9 | Properties 10 | NppXmlTreeviewPlugin.Parsers 11 | NppXmlTreeviewPlugin.Parsers 12 | v4.6.1 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | true 37 | bin\x64\Debug\ 38 | DEBUG;TRACE 39 | full 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | false 44 | 45 | 46 | bin\x64\Release\ 47 | TRACE 48 | true 49 | pdbonly 50 | x64 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | false 54 | 55 | 56 | 57 | ..\..\packages\Serilog.2.6.0\lib\net46\Serilog.dll 58 | True 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 83 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin.Parsers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NppXmlTreeviewPlugin.Parsers")] 9 | [assembly: AssemblyDescription("A Notepad++ TreeView plugin")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("João Rosa")] 12 | [assembly: AssemblyProduct("NppXmlTreeviewPlugin.Parsers")] 13 | [assembly: AssemblyCopyright("Copyright © João Rosa 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("eaba4132-6e8c-41ec-b6f0-666efca5439a")] 24 | 25 | [assembly: AssemblyVersion("0.1.0.0")] 26 | [assembly: AssemblyInformationalVersion("0.1.0-Logging.1+86.Branch.Logging.Sha.0b2f3cd3fb32e2fdb47e3a778ba22b63726b2c6c")] 27 | [assembly: AssemblyFileVersion("0.1.0.0")] 28 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin.Parsers/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/DllExport/DllExportAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace NppPlugin.DllExport 5 | { 6 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 7 | partial class DllExportAttribute : Attribute 8 | { 9 | public DllExportAttribute() 10 | { 11 | } 12 | public DllExportAttribute(string exportName) 13 | : this(exportName, CallingConvention.StdCall) 14 | { 15 | } 16 | public DllExportAttribute(string exportName, CallingConvention callingConvention) 17 | { 18 | ExportName = exportName; 19 | CallingConvention = callingConvention; 20 | } 21 | CallingConvention _callingConvention; 22 | public CallingConvention CallingConvention 23 | { 24 | get { return _callingConvention; } 25 | set { _callingConvention = value; } 26 | } 27 | string _exportName; 28 | public string ExportName 29 | { 30 | get { return _exportName; } 31 | set { _exportName = value; } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/DllExport/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/DllExport/Mono.Cecil.dll -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/DllExport/NppPlugin.DllExport.MSBuild.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/DllExport/NppPlugin.DllExport.MSBuild.dll -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/DllExport/NppPlugin.DllExport.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/DllExport/NppPlugin.DllExport.dll -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/DllExport/NppPlugin.DllExport.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | 3 | namespace NppXmlTreviewPlugin.Extensions 4 | { 5 | /// 6 | /// String extension methods. 7 | /// 8 | public static class StringExtensions 9 | { 10 | /// 11 | /// Method to validate a string as XML. 12 | /// 13 | /// The xml string. 14 | /// The xml document to parse it. 15 | /// True if the string is a valid xml, false otherwise. 16 | public static bool IsValidXml(this string xmlString, out XmlDocument xmlDocument) 17 | { 18 | try 19 | { 20 | xmlDocument = new XmlDocument(); 21 | xmlDocument.LoadXml(xmlString); 22 | return true; 23 | } 24 | catch 25 | { 26 | xmlDocument = null; 27 | return false; 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/FormAbout.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NppXmlTreeviewPlugin.Forms 2 | { 3 | partial class FormAbout 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.ButtonDonate = new System.Windows.Forms.Button(); 32 | this.ButtonOk = new System.Windows.Forms.Button(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.label2 = new System.Windows.Forms.Label(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.label4 = new System.Windows.Forms.Label(); 37 | this.SuspendLayout(); 38 | // 39 | // ButtonDonate 40 | // 41 | this.ButtonDonate.Location = new System.Drawing.Point(245, 59); 42 | this.ButtonDonate.Name = "ButtonDonate"; 43 | this.ButtonDonate.Size = new System.Drawing.Size(75, 23); 44 | this.ButtonDonate.TabIndex = 0; 45 | this.ButtonDonate.Text = "Donate"; 46 | this.ButtonDonate.UseVisualStyleBackColor = true; 47 | this.ButtonDonate.Click += new System.EventHandler(this.ButtonDonate_Click); 48 | // 49 | // ButtonOk 50 | // 51 | this.ButtonOk.DialogResult = System.Windows.Forms.DialogResult.Cancel; 52 | this.ButtonOk.Location = new System.Drawing.Point(245, 88); 53 | this.ButtonOk.Name = "ButtonOk"; 54 | this.ButtonOk.Size = new System.Drawing.Size(75, 23); 55 | this.ButtonOk.TabIndex = 1; 56 | this.ButtonOk.Text = "Ok"; 57 | this.ButtonOk.UseVisualStyleBackColor = true; 58 | this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click); 59 | // 60 | // label1 61 | // 62 | this.label1.AutoSize = true; 63 | this.label1.Location = new System.Drawing.Point(53, 39); 64 | this.label1.Name = "label1"; 65 | this.label1.Size = new System.Drawing.Size(132, 13); 66 | this.label1.TabIndex = 2; 67 | this.label1.Text = "Notepad++ XML Treeview"; 68 | // 69 | // label2 70 | // 71 | this.label2.AutoSize = true; 72 | this.label2.Location = new System.Drawing.Point(53, 69); 73 | this.label2.Name = "label2"; 74 | this.label2.Size = new System.Drawing.Size(35, 13); 75 | this.label2.TabIndex = 3; 76 | this.label2.Text = "label2"; 77 | // 78 | // label3 79 | // 80 | this.label3.AutoSize = true; 81 | this.label3.Location = new System.Drawing.Point(53, 98); 82 | this.label3.Name = "label3"; 83 | this.label3.Size = new System.Drawing.Size(58, 13); 84 | this.label3.TabIndex = 4; 85 | this.label3.Text = "João Rosa"; 86 | // 87 | // label4 88 | // 89 | this.label4.AutoSize = true; 90 | this.label4.Location = new System.Drawing.Point(53, 127); 91 | this.label4.Name = "label4"; 92 | this.label4.Size = new System.Drawing.Size(132, 13); 93 | this.label4.TabIndex = 5; 94 | this.label4.Text = "License under Apache 2.0"; 95 | // 96 | // FormAbout 97 | // 98 | this.AcceptButton = this.ButtonOk; 99 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 100 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 101 | this.CancelButton = this.ButtonOk; 102 | this.ClientSize = new System.Drawing.Size(378, 181); 103 | this.Controls.Add(this.label4); 104 | this.Controls.Add(this.label3); 105 | this.Controls.Add(this.label2); 106 | this.Controls.Add(this.label1); 107 | this.Controls.Add(this.ButtonOk); 108 | this.Controls.Add(this.ButtonDonate); 109 | this.MaximizeBox = false; 110 | this.MaximumSize = new System.Drawing.Size(394, 220); 111 | this.MinimizeBox = false; 112 | this.MinimumSize = new System.Drawing.Size(394, 220); 113 | this.Name = "FormAbout"; 114 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 115 | this.Text = "About"; 116 | this.ResumeLayout(false); 117 | this.PerformLayout(); 118 | 119 | } 120 | 121 | #endregion 122 | 123 | private System.Windows.Forms.Button ButtonDonate; 124 | private System.Windows.Forms.Button ButtonOk; 125 | private System.Windows.Forms.Label label1; 126 | private System.Windows.Forms.Label label2; 127 | private System.Windows.Forms.Label label3; 128 | private System.Windows.Forms.Label label4; 129 | } 130 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/FormAbout.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Windows.Forms; 4 | 5 | namespace NppXmlTreeviewPlugin.Forms 6 | { 7 | public partial class FormAbout : Form 8 | { 9 | public FormAbout() 10 | { 11 | InitializeComponent(); 12 | 13 | this.label2.Text = $"Version {Assembly.GetExecutingAssembly().GetName().Version}"; 14 | } 15 | 16 | private void ButtonDonate_Click(object sender, EventArgs e) 17 | { 18 | System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7YQVNRJ7WAQ8G"); 19 | } 20 | 21 | private void ButtonOk_Click(object sender, EventArgs e) 22 | { 23 | this.Close(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/FormAbout.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/FormTreeView.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows.Forms; 3 | 4 | namespace NppXmlTreeviewPlugin.Forms 5 | { 6 | partial class FormTreeView 7 | { 8 | /// 9 | /// Required designer variable. 10 | /// 11 | private IContainer components = null; 12 | 13 | /// 14 | /// Clean up any resources being used. 15 | /// 16 | /// true if managed resources should be disposed; otherwise, false. 17 | protected override void Dispose(bool disposing) 18 | { 19 | if (disposing && (this.components != null)) 20 | { 21 | this.components.Dispose(); 22 | } 23 | base.Dispose(disposing); 24 | } 25 | 26 | #region Windows Form Designer generated code 27 | 28 | /// 29 | /// Required method for Designer support - do not modify 30 | /// the contents of this method with the code editor. 31 | /// 32 | private void InitializeComponent() 33 | { 34 | this.components = new System.ComponentModel.Container(); 35 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 36 | this.treeView = new System.Windows.Forms.TreeView(); 37 | this.LabelStatus = new System.Windows.Forms.Label(); 38 | this.TooltipButtonToogle = new System.Windows.Forms.ToolTip(this.components); 39 | this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); 40 | this.ButtonToggle = new System.Windows.Forms.Button(); 41 | this.nodeNameMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 42 | this.tagNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.attributeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 44 | this.attributeNameTextBox = new System.Windows.Forms.TextBox(); 45 | this.menuButton1 = new NppXmlTreeviewPlugin.Forms.MenuButton(); 46 | this.tableLayoutPanel1.SuspendLayout(); 47 | this.flowLayoutPanel1.SuspendLayout(); 48 | this.nodeNameMenu.SuspendLayout(); 49 | this.SuspendLayout(); 50 | // 51 | // tableLayoutPanel1 52 | // 53 | this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 54 | this.tableLayoutPanel1.ColumnCount = 1; 55 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 56 | this.tableLayoutPanel1.Controls.Add(this.treeView, 0, 2); 57 | this.tableLayoutPanel1.Controls.Add(this.LabelStatus, 0, 1); 58 | this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 0); 59 | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 60 | this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); 61 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 62 | this.tableLayoutPanel1.RowCount = 3; 63 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F)); 64 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22F)); 65 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 66 | this.tableLayoutPanel1.Size = new System.Drawing.Size(515, 506); 67 | this.tableLayoutPanel1.TabIndex = 0; 68 | // 69 | // treeView 70 | // 71 | this.treeView.Dock = System.Windows.Forms.DockStyle.Fill; 72 | this.treeView.Location = new System.Drawing.Point(3, 47); 73 | this.treeView.Name = "treeView"; 74 | this.treeView.Size = new System.Drawing.Size(509, 456); 75 | this.treeView.TabIndex = 2; 76 | this.treeView.Visible = false; 77 | this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.TreeView_NodeMouseClick); 78 | // 79 | // LabelStatus 80 | // 81 | this.LabelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 82 | | System.Windows.Forms.AnchorStyles.Left))); 83 | this.LabelStatus.AutoSize = true; 84 | this.LabelStatus.Location = new System.Drawing.Point(3, 25); 85 | this.LabelStatus.Margin = new System.Windows.Forms.Padding(3); 86 | this.LabelStatus.Name = "LabelStatus"; 87 | this.LabelStatus.Size = new System.Drawing.Size(0, 16); 88 | this.LabelStatus.TabIndex = 3; 89 | this.LabelStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 90 | // 91 | // flowLayoutPanel1 92 | // 93 | this.flowLayoutPanel1.Controls.Add(this.ButtonToggle); 94 | this.flowLayoutPanel1.Controls.Add(this.menuButton1); 95 | this.flowLayoutPanel1.Controls.Add(this.attributeNameTextBox); 96 | this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 97 | this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); 98 | this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); 99 | this.flowLayoutPanel1.Name = "flowLayoutPanel1"; 100 | this.flowLayoutPanel1.Size = new System.Drawing.Size(515, 22); 101 | this.flowLayoutPanel1.TabIndex = 4; 102 | // 103 | // ButtonToggle 104 | // 105 | this.ButtonToggle.BackColor = System.Drawing.Color.Transparent; 106 | this.ButtonToggle.FlatAppearance.BorderSize = 0; 107 | this.ButtonToggle.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 108 | this.ButtonToggle.Image = global::NppXmlTreeviewPlugin.Properties.Resources.toggle; 109 | this.ButtonToggle.Location = new System.Drawing.Point(3, 3); 110 | this.ButtonToggle.Name = "ButtonToggle"; 111 | this.ButtonToggle.Size = new System.Drawing.Size(16, 16); 112 | this.ButtonToggle.TabIndex = 0; 113 | this.ButtonToggle.UseVisualStyleBackColor = false; 114 | this.ButtonToggle.Click += new System.EventHandler(this.ButtonToggle_Click); 115 | // 116 | // nodeNameMenu 117 | // 118 | this.nodeNameMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 119 | this.tagNameToolStripMenuItem, 120 | this.attributeToolStripMenuItem}); 121 | this.nodeNameMenu.Name = "nodeNameMenu"; 122 | this.nodeNameMenu.Size = new System.Drawing.Size(129, 48); 123 | // 124 | // tagNameToolStripMenuItem 125 | // 126 | this.tagNameToolStripMenuItem.Checked = true; 127 | this.tagNameToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; 128 | this.tagNameToolStripMenuItem.Name = "tagNameToolStripMenuItem"; 129 | this.tagNameToolStripMenuItem.Size = new System.Drawing.Size(128, 22); 130 | this.tagNameToolStripMenuItem.Text = "Tag Name"; 131 | this.tagNameToolStripMenuItem.Click += new System.EventHandler(this.tagNameToolStripMenuItem_Click); 132 | // 133 | // attributeToolStripMenuItem 134 | // 135 | this.attributeToolStripMenuItem.Name = "attributeToolStripMenuItem"; 136 | this.attributeToolStripMenuItem.Size = new System.Drawing.Size(128, 22); 137 | this.attributeToolStripMenuItem.Text = "Attribute"; 138 | this.attributeToolStripMenuItem.Click += new System.EventHandler(this.attributeToolStripMenuItem_Click); 139 | // 140 | // attributeNameTextBox 141 | // 142 | this.attributeNameTextBox.Enabled = false; 143 | this.attributeNameTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 5.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 144 | this.attributeNameTextBox.Location = new System.Drawing.Point(68, 3); 145 | this.attributeNameTextBox.Name = "attributeNameTextBox"; 146 | this.attributeNameTextBox.Size = new System.Drawing.Size(100, 16); 147 | this.attributeNameTextBox.TabIndex = 2; 148 | this.attributeNameTextBox.TextChanged += new System.EventHandler(this.attributeNameTextBox_TextChanged); 149 | // 150 | // menuButton1 151 | // 152 | this.menuButton1.FlatAppearance.BorderSize = 0; 153 | this.menuButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 154 | this.menuButton1.Image = global::NppXmlTreeviewPlugin.Properties.Resources.node_name; 155 | this.menuButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 156 | this.menuButton1.Location = new System.Drawing.Point(25, 3); 157 | this.menuButton1.Menu = this.nodeNameMenu; 158 | this.menuButton1.Name = "menuButton1"; 159 | this.menuButton1.Size = new System.Drawing.Size(37, 16); 160 | this.menuButton1.TabIndex = 1; 161 | this.menuButton1.UseVisualStyleBackColor = true; 162 | // 163 | // FormTreeView 164 | // 165 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 166 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 167 | this.ClientSize = new System.Drawing.Size(515, 506); 168 | this.Controls.Add(this.tableLayoutPanel1); 169 | this.Name = "FormTreeView"; 170 | this.Text = "frmMyDlg"; 171 | this.tableLayoutPanel1.ResumeLayout(false); 172 | this.tableLayoutPanel1.PerformLayout(); 173 | this.flowLayoutPanel1.ResumeLayout(false); 174 | this.flowLayoutPanel1.PerformLayout(); 175 | this.nodeNameMenu.ResumeLayout(false); 176 | this.ResumeLayout(false); 177 | 178 | } 179 | 180 | #endregion 181 | 182 | private TableLayoutPanel tableLayoutPanel1; 183 | private Button ButtonToggle; 184 | private ToolTip TooltipButtonToogle; 185 | private TreeView treeView; 186 | private Label LabelStatus; 187 | private FlowLayoutPanel flowLayoutPanel1; 188 | private MenuButton menuButton1; 189 | private ContextMenuStrip nodeNameMenu; 190 | private ToolStripMenuItem tagNameToolStripMenuItem; 191 | private ToolStripMenuItem attributeToolStripMenuItem; 192 | private TextBox attributeNameTextBox; 193 | } 194 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/FormTreeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | using NppPluginNET; 7 | using NppXmlTreeviewPlugin.Parsers; 8 | using NppXmlTreeviewPlugin.Properties; 9 | 10 | using Serilog; 11 | 12 | namespace NppXmlTreeviewPlugin.Forms 13 | { 14 | public partial class FormTreeView : Form 15 | { 16 | private bool _expanded; 17 | private bool _workerIsRunning; 18 | private NppXmlNode _rootNode; 19 | private readonly ILogger _logger; 20 | 21 | #region CONSTRUCTORS 22 | 23 | public FormTreeView() 24 | { 25 | InitializeComponent(); 26 | 27 | _logger = new LoggerConfiguration() 28 | .WriteTo.RollingFile(@"./plugins/NppXmlTreeviewPlugin/logs/log-{Date}.txt") 29 | .CreateLogger(); 30 | 31 | this.TooltipButtonToogle.SetToolTip(this.ButtonToggle, "Collapse treeview"); 32 | 33 | // Get the values from the open document. 34 | UpdateUserInterface(); 35 | } 36 | 37 | #endregion 38 | 39 | #region PUBLIC METHODS 40 | 41 | /// 42 | /// Updates the plugin user interface. 43 | /// 44 | public void UpdateUserInterface() 45 | { 46 | if (this._workerIsRunning) 47 | { 48 | return; 49 | } 50 | 51 | // Start the background worker. 52 | var backgroundWorker = new BackgroundWorker(); 53 | backgroundWorker.DoWork += BackgroundWorker_UpdateUserInterfaceDoWork; 54 | backgroundWorker.RunWorkerAsync(); 55 | this._workerIsRunning = true; 56 | } 57 | 58 | 59 | public void SetNodeSelection() 60 | { 61 | if (this._workerIsRunning) 62 | { 63 | return; 64 | } 65 | 66 | // Start the background worker. 67 | var backgroundWorker = new BackgroundWorker(); 68 | backgroundWorker.DoWork += BackgroundWorker_SetNodeSelectionDoWork; 69 | backgroundWorker.RunWorkerAsync(); 70 | this._workerIsRunning = true; 71 | } 72 | 73 | #endregion 74 | 75 | #region PRIVATE METHODS 76 | 77 | /// 78 | /// Background worker method to do the user interface updated. 79 | /// 80 | /// The background worker object. 81 | /// The event arguments. 82 | private void BackgroundWorker_UpdateUserInterfaceDoWork(object sender, DoWorkEventArgs e) 83 | { 84 | this._rootNode = null; 85 | 86 | if (this.ButtonToggle.InvokeRequired) 87 | { 88 | this.ButtonToggle.Invoke(new EnableToggleButtonDelegate(EnableToggleButton), false); 89 | } 90 | else 91 | { 92 | EnableToggleButton(false); 93 | } 94 | 95 | if (this.treeView.InvokeRequired) 96 | { 97 | this.treeView.Invoke(new SetTreeviewVisibilityDelegate(SetTreeviewVisibility), false); 98 | } 99 | else 100 | { 101 | SetTreeviewVisibility(false); 102 | } 103 | 104 | if (this.LabelStatus.InvokeRequired) 105 | { 106 | this.LabelStatus.Invoke(new SetStatusLabelTextDelegate(SetStatusLabelText), "Parsing the document"); 107 | } 108 | else 109 | { 110 | SetStatusLabelText("Parsing the document"); 111 | } 112 | 113 | string attributeName = attributeNameTextBox.Enabled ? attributeNameTextBox.Text : null; 114 | 115 | // Do validations. 116 | if (!NppXmlNode.TryParse(GetDocumentText(PluginBase.GetCurrentScintilla()), attributeName, _logger, out this._rootNode)) 117 | { 118 | if (this.LabelStatus.InvokeRequired) 119 | { 120 | this.LabelStatus.Invoke(new SetStatusLabelTextDelegate(SetStatusLabelText), "Document is not valid."); 121 | } 122 | else 123 | { 124 | SetStatusLabelText("Document is not valid."); 125 | } 126 | 127 | this._workerIsRunning = false; 128 | return; 129 | } 130 | 131 | if (this.treeView.InvokeRequired) 132 | { 133 | this.treeView.Invoke(new ClearNodesDelegate(ClearNodes)); 134 | } 135 | else 136 | { 137 | ClearNodes(); 138 | } 139 | 140 | if (this.treeView.InvokeRequired) 141 | { 142 | this.treeView.Invoke(new AddNodeToTreeViewDelegate(AddNodeToTreeView), GenerateTreeNode(this._rootNode)); 143 | } 144 | else 145 | { 146 | this.treeView.Nodes.Add(GenerateTreeNode(this._rootNode)); 147 | } 148 | 149 | // Add the rest of the nodes. 150 | var treeNode = this.treeView.Nodes[0]; 151 | AddNode(this._rootNode, treeNode); 152 | 153 | // Finish up the operation. 154 | if (this.treeView.InvokeRequired) 155 | { 156 | this.treeView.Invoke(new ExpandTreeViewDelegate(ExpandTreeView)); 157 | } 158 | else 159 | { 160 | ExpandTreeView(); 161 | } 162 | 163 | if (this.LabelStatus.InvokeRequired) 164 | { 165 | this.LabelStatus.Invoke(new SetStatusLabelTextDelegate(SetStatusLabelText), string.Empty); 166 | } 167 | else 168 | { 169 | SetStatusLabelText(string.Empty); 170 | } 171 | 172 | if (this.ButtonToggle.InvokeRequired) 173 | { 174 | this.ButtonToggle.Invoke(new EnableToggleButtonDelegate(EnableToggleButton), true); 175 | } 176 | else 177 | { 178 | EnableToggleButton(true); 179 | } 180 | 181 | this._workerIsRunning = false; 182 | } 183 | 184 | /// 185 | /// Background worker method to do the user interface updated. 186 | /// 187 | /// The background worker object. 188 | /// The event arguments. 189 | private void BackgroundWorker_ToggleTreeViewDoWork(object sender, DoWorkEventArgs e) 190 | { 191 | if (this._expanded) 192 | { 193 | if (this.treeView.InvokeRequired) 194 | { 195 | this.treeView.Invoke(new CollapseTreeViewDelegate(CollapseTreeView)); 196 | } 197 | else 198 | { 199 | CollapseTreeView(); 200 | } 201 | } 202 | else 203 | { 204 | if (this.treeView.InvokeRequired) 205 | { 206 | this.treeView.Invoke(new ExpandTreeViewDelegate(ExpandTreeView)); 207 | } 208 | else 209 | { 210 | ExpandTreeView(); 211 | } 212 | } 213 | 214 | this._workerIsRunning = false; 215 | } 216 | 217 | /// 218 | /// Background worker method to do the user selects text. 219 | /// 220 | /// The background worker object. 221 | /// The event arguments. 222 | private void BackgroundWorker_SetNodeSelectionDoWork(object sender, DoWorkEventArgs e) 223 | { 224 | // Highlight the text. 225 | var currentScintilla = PluginBase.GetCurrentScintilla(); 226 | 227 | var selectionStartPos = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_GETSELECTIONSTART, 0, 0); 228 | var selectionStartLine = 229 | (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_LINEFROMPOSITION, selectionStartPos, 0); 230 | var selectionStartPosInLine = 231 | (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_GETCOLUMN, selectionStartPos, 0); 232 | 233 | var node = this._rootNode.FindNppXmlNodeByLine(selectionStartLine, selectionStartPosInLine); 234 | 235 | if (null != node) 236 | { 237 | if (this.treeView.InvokeRequired) 238 | { 239 | this.treeView.Invoke(new SetTreeviewSelectionDelegate(SetTreeviewSelection), node.Id.ToString()); 240 | } 241 | else 242 | { 243 | SetTreeviewSelection(node.Id.ToString()); 244 | } 245 | } 246 | 247 | this._workerIsRunning = false; 248 | } 249 | 250 | /// 251 | /// Clear the treeview nodes. 252 | /// 253 | private void ClearNodes() 254 | { 255 | this.treeView.Nodes.Clear(); 256 | } 257 | 258 | /// 259 | /// Method to add a npp xml node to a tree node. 260 | /// 261 | /// The npp xml node. 262 | /// The tree node. 263 | private void AddNode(NppXmlNode inXmlNode, TreeNode inTreeNode) 264 | { 265 | if (!inXmlNode.HasChildNodes) 266 | { 267 | return; 268 | } 269 | for (var i = 0; i < inXmlNode.ChildNodes.Count; i++) 270 | { 271 | var xNode = inXmlNode.ChildNodes.ElementAt(i); 272 | 273 | if (this.treeView.InvokeRequired) 274 | { 275 | this.treeView.Invoke(new AddNodeToNodeDelegate(AddNodeToNode), GenerateTreeNode(xNode), inTreeNode); 276 | } 277 | else 278 | { 279 | AddNodeToNode(GenerateTreeNode(xNode), inTreeNode); 280 | } 281 | AddNode(xNode, inTreeNode.Nodes[i]); 282 | } 283 | } 284 | 285 | /// 286 | /// Method to add a node to the tree view. 287 | /// 288 | /// The node to add. 289 | private void AddNodeToTreeView(TreeNode treeNode) 290 | { 291 | this.treeView.Nodes.Add(treeNode); 292 | } 293 | 294 | /// 295 | /// Method to expand the tree view. 296 | /// 297 | private void ExpandTreeView() 298 | { 299 | this.treeView.ShowNodeToolTips = true; 300 | this.treeView.ExpandAll(); 301 | this.treeView.Nodes[0].EnsureVisible(); 302 | this.treeView.Visible = true; 303 | 304 | this._expanded = true; 305 | 306 | this.ButtonToggle.Image = Resources.toggle; 307 | this.TooltipButtonToogle.SetToolTip(this.ButtonToggle, "Collapse treeview"); 308 | } 309 | 310 | /// 311 | /// Method to collapse the tree view. 312 | /// 313 | private void CollapseTreeView() 314 | { 315 | this.treeView.ShowNodeToolTips = true; 316 | this.treeView.CollapseAll(); 317 | this.treeView.Nodes[0].EnsureVisible(); 318 | this._expanded = false; 319 | 320 | this.ButtonToggle.Image = Resources.toggle_expand; 321 | this.TooltipButtonToogle.SetToolTip(this.ButtonToggle, "Expand treeview"); 322 | } 323 | 324 | /// 325 | /// Method to set the label status text. 326 | /// 327 | /// The text. 328 | private void SetStatusLabelText(string text) 329 | { 330 | this.LabelStatus.Text = text; 331 | } 332 | 333 | /// 334 | /// Method to set the label visibility. 335 | /// 336 | /// The visibility. 337 | private void SetTreeviewVisibility(bool visible) 338 | { 339 | this.treeView.Visible = visible; 340 | } 341 | 342 | /// 343 | /// Method to enable the toggle button. 344 | /// 345 | /// Flag with the enable value. 346 | private void EnableToggleButton(bool enable) 347 | { 348 | this.ButtonToggle.Enabled = enable; 349 | } 350 | 351 | /// 352 | /// Selects the treenode in the treeview. 353 | /// 354 | /// The node id 355 | private void SetTreeviewSelection(string id) 356 | { 357 | this.treeView.SelectedNode = this.treeView.Nodes.Find(id, true)[0]; 358 | this.treeView.Focus(); 359 | } 360 | 361 | /// 362 | /// Method to handle the tree node click. 363 | /// 364 | /// The treeview. 365 | /// The event arguments. 366 | private void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) 367 | { 368 | var textBoundary = (TextBoundary)e.Node.Tag; 369 | 370 | // Highlight the text. 371 | var currentScintilla = PluginBase.GetCurrentScintilla(); 372 | 373 | var startLineStartPos = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_POSITIONFROMLINE, 374 | textBoundary.StartNodePosition.LineNumber, 0); 375 | var endLineStartPos = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_POSITIONFROMLINE, 376 | textBoundary.EndNodePosition.LineNumber, 0); 377 | 378 | Win32.SendMessage(currentScintilla, SciMsg.SCI_SETSELECTIONSTART, 379 | startLineStartPos + textBoundary.StartNodePosition.LinePosition, 0); 380 | Win32.SendMessage(currentScintilla, SciMsg.SCI_SETSELECTIONEND, 381 | endLineStartPos + textBoundary.EndNodePosition.LinePosition, 0); 382 | Win32.SendMessage(currentScintilla, SciMsg.SCI_SCROLLCARET, 0, 0); 383 | } 384 | 385 | /// 386 | /// Method to handle the toggle button click. 387 | /// 388 | /// The button. 389 | /// The event arguments. 390 | private void ButtonToggle_Click(object sender, EventArgs e) 391 | { 392 | if (this._workerIsRunning) 393 | { 394 | return; 395 | } 396 | 397 | // Start the background worker. 398 | var backgroundWorker = new BackgroundWorker(); 399 | backgroundWorker.DoWork += BackgroundWorker_ToggleTreeViewDoWork; 400 | backgroundWorker.RunWorkerAsync(); 401 | this._workerIsRunning = true; 402 | } 403 | 404 | private void tagNameToolStripMenuItem_Click(object sender, EventArgs e) 405 | { 406 | attributeToolStripMenuItem.Checked = false; 407 | tagNameToolStripMenuItem.Checked = true; 408 | attributeNameTextBox.Enabled = false; 409 | UpdateUserInterface(); 410 | } 411 | 412 | private void attributeToolStripMenuItem_Click(object sender, EventArgs e) 413 | { 414 | attributeToolStripMenuItem.Checked = true; 415 | tagNameToolStripMenuItem.Checked = false; 416 | attributeNameTextBox.Enabled = true; 417 | UpdateUserInterface(); 418 | } 419 | 420 | private void attributeNameTextBox_TextChanged(object sender, EventArgs e) 421 | { 422 | UpdateUserInterface(); 423 | } 424 | 425 | #endregion 426 | 427 | #region PRIVATE STATIC METHODS 428 | 429 | /// 430 | /// Method to add a tree node to a parent tree node. 431 | /// 432 | /// The tree node to add. 433 | /// The parent tree node. 434 | private static void AddNodeToNode(TreeNode treeNode, TreeNode parent) 435 | { 436 | parent.Nodes.Add(treeNode); 437 | } 438 | 439 | /// 440 | /// Method to get the text from the Scintilla component. 441 | /// 442 | /// The current Scintilla. 443 | /// The document text. 444 | private static string GetDocumentText(IntPtr currentScintilla) 445 | { 446 | var length = (int)Win32.SendMessage(currentScintilla, SciMsg.SCI_GETLENGTH, 0, 0) + 1; 447 | var sb = new byte[length]; 448 | 449 | unsafe 450 | { 451 | fixed (byte* p = sb) 452 | { 453 | var ptr = (IntPtr)p; 454 | Win32.SendMessage(currentScintilla, SciMsg.SCI_GETTEXT, length, ptr); 455 | } 456 | 457 | return Encoding.UTF8.GetString(sb).TrimEnd('\0'); 458 | } 459 | } 460 | 461 | /// 462 | /// Method to generate a treenode from a npp tree node. 463 | /// 464 | /// The npp tree node. 465 | /// The tree node. 466 | private static TreeNode GenerateTreeNode(NppXmlNode node) 467 | { 468 | return new TreeNode 469 | { 470 | ToolTipText = $"{node.Name}", 471 | Tag = new TextBoundary(node.StartPosition, node.EndPosition, node.Id), 472 | Text = node.Name, 473 | // The name is the key. 474 | Name = node.Id.ToString() 475 | }; 476 | } 477 | 478 | #endregion 479 | 480 | #region PRIVATE DELEGATES 481 | 482 | private delegate void ClearNodesDelegate(); 483 | 484 | private delegate void AddNodeToTreeViewDelegate(TreeNode treeNode); 485 | 486 | private delegate void AddNodeToNodeDelegate(TreeNode treeNode, TreeNode parent); 487 | 488 | private delegate void ExpandTreeViewDelegate(); 489 | 490 | private delegate void CollapseTreeViewDelegate(); 491 | 492 | private delegate void SetTreeviewVisibilityDelegate(bool visible); 493 | 494 | private delegate void SetStatusLabelTextDelegate(string text); 495 | 496 | private delegate void EnableToggleButtonDelegate(bool enable); 497 | 498 | private delegate void SetTreeviewSelectionDelegate(string id); 499 | 500 | #endregion 501 | } 502 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/FormTreeView.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 181, 17 122 | 123 | 124 | 17, 17 125 | 126 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Forms/MenuButton.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | 5 | namespace NppXmlTreeviewPlugin.Forms 6 | { 7 | public class MenuButton : Button 8 | { 9 | [DefaultValue(null)] 10 | public ContextMenuStrip Menu { get; set; } 11 | 12 | [DefaultValue(false)] 13 | public bool ShowMenuUnderCursor { get; set; } 14 | 15 | protected override void OnMouseDown(MouseEventArgs mevent) 16 | { 17 | base.OnMouseDown(mevent); 18 | 19 | if (Menu != null && mevent.Button == MouseButtons.Left) 20 | { 21 | Point menuLocation; 22 | 23 | if (ShowMenuUnderCursor) 24 | { 25 | menuLocation = mevent.Location; 26 | } 27 | else 28 | { 29 | menuLocation = new Point(0, Height); 30 | } 31 | 32 | Menu.Show(this, menuLocation); 33 | } 34 | } 35 | 36 | protected override void OnPaint(PaintEventArgs pevent) 37 | { 38 | base.OnPaint(pevent); 39 | 40 | if (Menu != null) 41 | { 42 | int arrowX = ClientRectangle.Width - 14; 43 | int arrowY = ClientRectangle.Height / 2 - 1; 44 | 45 | Brush brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow; 46 | Point[] arrows = new Point[] { new Point(arrowX, arrowY), new Point(arrowX + 7, arrowY), new Point(arrowX + 3, arrowY + 4) }; 47 | pevent.Graphics.FillPolygon(brush, arrows); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Drawing; 4 | using System.Drawing.Imaging; 5 | using System.IO; 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | using NppPluginNET; 11 | using NppXmlTreeviewPlugin.Forms; 12 | using NppXmlTreeviewPlugin.Properties; 13 | 14 | namespace NppXmlTreeviewPlugin 15 | { 16 | class Main 17 | { 18 | #region " Fields " 19 | internal const string PluginName = "Npp Xml Treview"; 20 | static string iniFilePath = null; 21 | static bool someSetting = false; 22 | public static FormTreeView frmMyDlg = null; 23 | static int idMyDlg = -1; 24 | static Bitmap tbBmp = Resources.blue_document_tree; 25 | static Icon tbIcon = null; 26 | #endregion 27 | 28 | #region " StartUp/CleanUp " 29 | static Main() 30 | { 31 | // Following code let's you reference any additional .net assembly 32 | // from a subfolder which has the same name as your plugin. Example: 33 | // ...\plugins\NppXmlTreeviewPlugin.dll 34 | // ...\plugins\NppXmlTreeviewPlugin\AdditionalAssembly1.dll 35 | // ...\plugins\NppXmlTreeviewPlugin\AdditionalAssembly2.dll 36 | AppDomain.CurrentDomain.AssemblyResolve += LoadFromPluginSubFolder; 37 | } 38 | 39 | static Assembly LoadFromPluginSubFolder(object sender, ResolveEventArgs args) 40 | { 41 | string pluginPath = typeof(Main).Assembly.Location; 42 | string pluginName = Path.GetFileNameWithoutExtension(pluginPath); 43 | string pluginSubFolder = Path.Combine(Path.GetDirectoryName(pluginPath), pluginName); 44 | string assemblyPath = Path.Combine(pluginSubFolder, new AssemblyName(args.Name).Name + ".dll"); 45 | if (File.Exists(assemblyPath)) 46 | { 47 | return Assembly.LoadFrom(assemblyPath); 48 | } 49 | 50 | // HACK: allow loading of session files created with older assembly versions 51 | Assembly asm = typeof(Main).Assembly; 52 | if (args.Name.Contains("NppXmlTreeviewPlugin, Version=") && (args.Name != asm.FullName)) 53 | return typeof(Main).Assembly; 54 | return null; 55 | } 56 | 57 | internal static void CommandMenuInit() 58 | { 59 | StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH); 60 | Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath); 61 | iniFilePath = sbIniFilePath.ToString(); 62 | if (!Directory.Exists(iniFilePath)) Directory.CreateDirectory(iniFilePath); 63 | iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini"); 64 | someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0); 65 | 66 | PluginBase.SetCommand(0, "Npp XML TreeView", myDockableDialog); 67 | PluginBase.SetCommand(1, "About NppXMLTreeView", myMenuFunction, new ShortcutKey(false, false, false, Keys.None)); 68 | 69 | // The command for the plugin. 70 | idMyDlg = 0; 71 | } 72 | 73 | internal static void SetToolBarIcon() 74 | { 75 | toolbarIcons tbIcons = new toolbarIcons(); 76 | tbIcons.hToolbarBmp = tbBmp.GetHbitmap(); 77 | IntPtr pTbIcons = Marshal.AllocHGlobal(Marshal.SizeOf(tbIcons)); 78 | Marshal.StructureToPtr(tbIcons, pTbIcons, false); 79 | Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_ADDTOOLBARICON, PluginBase._funcItems.Items[idMyDlg]._cmdID, pTbIcons); 80 | Marshal.FreeHGlobal(pTbIcons); 81 | } 82 | 83 | internal static void PluginCleanUp() 84 | { 85 | Win32.WritePrivateProfileString("SomeSection", "SomeKey", someSetting ? "1" : "0", iniFilePath); 86 | } 87 | #endregion 88 | 89 | #region " Menu functions " 90 | 91 | internal static void myMenuFunction() 92 | { 93 | var about = new FormAbout(); 94 | about.ShowDialog(); 95 | } 96 | 97 | internal static void myDockableDialog() 98 | { 99 | if (frmMyDlg == null) 100 | { 101 | frmMyDlg = new FormTreeView(); 102 | 103 | using (Bitmap newBmp = new Bitmap(16, 16)) 104 | { 105 | Graphics g = Graphics.FromImage(newBmp); 106 | ColorMap[] colorMap = new ColorMap[1]; 107 | colorMap[0] = new ColorMap 108 | { 109 | OldColor = Color.Blue, 110 | NewColor = Color.FromKnownColor(KnownColor.ButtonFace) 111 | }; 112 | ImageAttributes attr = new ImageAttributes(); 113 | attr.SetRemapTable(colorMap); 114 | g.DrawImage(tbBmp, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); 115 | tbIcon = Icon.FromHandle(newBmp.GetHicon()); 116 | } 117 | 118 | NppTbData _nppTbData = new NppTbData(); 119 | _nppTbData.hClient = frmMyDlg.Handle; 120 | _nppTbData.pszName = "XML Treeview"; 121 | _nppTbData.dlgID = idMyDlg; 122 | _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; 123 | _nppTbData.hIconTab = (uint)tbIcon.Handle; 124 | _nppTbData.pszModuleName = PluginName; 125 | IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); 126 | Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); 127 | 128 | Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); 129 | } 130 | else 131 | { 132 | Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle); 133 | } 134 | } 135 | 136 | #endregion 137 | 138 | #region " Logging " 139 | internal static void ErrorOut(Exception ex) 140 | { 141 | TRACE(ex.Message); 142 | try 143 | { 144 | using (TextWriter w = new StreamWriter("c:\\temp\\log.text", true)) 145 | { 146 | w.WriteLine( 147 | $"\n{DateTime.Now.Year}-{DateTime.Now.Month.ToString("00")}-{DateTime.Now.Day.ToString("00")} {DateTime.Now.Hour.ToString("00")}-{DateTime.Now.Minute.ToString("00")}-{DateTime.Now.Second.ToString("00")}:\n" + 148 | "===================="); 149 | w.WriteLine(ex.Message); 150 | w.WriteLine(ex.StackTrace); 151 | } 152 | MessageBox.Show( 153 | "Owing to unfortunate circumstances an error with the following message occured:\n\n" + 154 | $"\"{ex.Message}\"\n\n" + "Hence a logfile has been written to the SourceCookifier folder.\n" + 155 | "Please post its content in the forum, if you think it's worth being fixed.\n" + 156 | "Sorry for the inconvenience.", 157 | "NppXmlTreeview", MessageBoxButtons.OK, MessageBoxIcon.Error); 158 | } 159 | catch (Exception e) 160 | { 161 | MessageBox.Show($"Error while attempting to write error logfile:\n{e.Message}", 162 | "NppXmlTreeview", MessageBoxButtons.OK, MessageBoxIcon.Error); 163 | } 164 | } 165 | 166 | [Conditional("TRACE_ALL")] 167 | internal static void TRACE(string msg) 168 | { 169 | try 170 | { 171 | if (string.IsNullOrEmpty(TRACEPATH)) 172 | { 173 | TRACEPATH = Environment.ExpandEnvironmentVariables("%SYSTEMDRIVE%\\NppXmlTreeview.TRACE.txt"); 174 | TRACEPID = Process.GetCurrentProcess().Id.ToString("X04"); 175 | } 176 | using (TextWriter w = new StreamWriter(TRACEPATH, true)) 177 | { 178 | StackTrace stackTrace = new StackTrace(); 179 | MethodBase methodBase = stackTrace.GetFrame(1).GetMethod(); 180 | w.WriteLine("{0}:{1:000} <{2}> {3}[{4}] {5}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond, TRACEPID, new String(' ', (stackTrace.FrameCount - 1) * 3), methodBase.Name, msg); 181 | } 182 | } 183 | catch (Exception ex) 184 | { 185 | if (!TRACEERRORSHOWN) 186 | { 187 | TRACEERRORSHOWN = true; 188 | MessageBox.Show($"Error while attempting to write trace file:\n{ex.Message}", 189 | "NppXmlTreeview", MessageBoxButtons.OK, MessageBoxIcon.Error); 190 | } 191 | } 192 | } 193 | static string TRACEPATH, TRACEPID; 194 | static bool TRACEERRORSHOWN; 195 | #endregion 196 | } 197 | } -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/NppPluginNETBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NppPluginNET 4 | { 5 | class PluginBase 6 | { 7 | #region " Fields " 8 | internal static NppData nppData; 9 | internal static FuncItems _funcItems = new FuncItems(); 10 | #endregion 11 | 12 | #region " Helper " 13 | internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer) 14 | { 15 | SetCommand(index, commandName, functionPointer, new ShortcutKey(), false); 16 | } 17 | internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut) 18 | { 19 | SetCommand(index, commandName, functionPointer, shortcut, false); 20 | } 21 | internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, bool checkOnInit) 22 | { 23 | SetCommand(index, commandName, functionPointer, new ShortcutKey(), checkOnInit); 24 | } 25 | internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut, bool checkOnInit) 26 | { 27 | FuncItem funcItem = new FuncItem(); 28 | funcItem._cmdID = index; 29 | funcItem._itemName = commandName; 30 | if (functionPointer != null) 31 | funcItem._pFunc = new NppFuncItemDelegate(functionPointer); 32 | if (shortcut._key != 0) 33 | funcItem._pShKey = shortcut; 34 | funcItem._init2Check = checkOnInit; 35 | _funcItems.Add(funcItem); 36 | } 37 | 38 | internal static IntPtr GetCurrentScintilla() 39 | { 40 | int curScintilla; 41 | Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_GETCURRENTSCINTILLA, 0, out curScintilla); 42 | return (curScintilla == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle; 43 | } 44 | #endregion 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/NppXmlTreeviewPlugin.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 2.0 7 | {E56F6E12-089C-40ED-BCFD-923E5FA121A1} 8 | Library 9 | Properties 10 | NppXmlTreeviewPlugin 11 | NppXmlTreeviewPlugin 12 | bin\Debug\ 13 | v4.6.1 14 | 15 | 16 | 3.5 17 | 18 | 19 | 20 | 21 | 22 | 23 | true 24 | DEBUG;TRACE 25 | full 26 | prompt 27 | false 28 | bin\Debug 29 | x86 30 | false 31 | true 32 | 33 | 34 | TRACE 35 | true 36 | bin\Release 37 | pdbonly 38 | prompt 39 | x86 40 | false 41 | true 42 | 43 | 44 | true 45 | bin\x64\Debug\ 46 | DEBUG;TRACE 47 | true 48 | full 49 | x64 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | false 53 | 54 | 55 | bin\x64\Release\ 56 | TRACE 57 | true 58 | true 59 | pdbonly 60 | x64 61 | prompt 62 | MinimumRecommendedRules.ruleset 63 | false 64 | 65 | 66 | 67 | ..\..\packages\Serilog.2.6.0\lib\net46\Serilog.dll 68 | True 69 | 70 | 71 | ..\..\packages\Serilog.Sinks.File.3.2.0\lib\net45\Serilog.Sinks.File.dll 72 | 73 | 74 | ..\..\packages\Serilog.Sinks.RollingFile.3.3.0\lib\net45\Serilog.Sinks.RollingFile.dll 75 | True 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | Form 89 | 90 | 91 | FormAbout.cs 92 | 93 | 94 | Form 95 | 96 | 97 | FormTreeView.cs 98 | 99 | 100 | Component 101 | 102 | 103 | 104 | 105 | 106 | 107 | True 108 | True 109 | Resources.resx 110 | 111 | 112 | 113 | 114 | 115 | 116 | FormAbout.cs 117 | 118 | 119 | FormTreeView.cs 120 | 121 | 122 | ResXFileCodeGenerator 123 | Resources.Designer.cs 124 | Designer 125 | 126 | 127 | 128 | 129 | {eaba4132-6e8c-41ec-b6f0-666efca5439a} 130 | NppXmlTreeviewPlugin.Parsers 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | MKDIR NppXmlTreeviewPlugin 150 | XCOPY /Y NppXmlTreeviewPlugin.Parsers.dll NppXmlTreeviewPlugin 151 | XCOPY /Y Serilog*.dll NppXmlTreeviewPlugin 152 | DEL /F NppXmlTreeviewPlugin.Parsers.* 153 | DEL /F NppXmlTreeviewPlugin.exp 154 | DEL /F NppXmlTreeviewPlugin.lib 155 | DEL /F NppXmlTreeviewPlugin.pssym 156 | DEL /F Serilog* 157 | 158 | 165 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/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("NppXmlTreeviewPlugin")] 8 | [assembly: AssemblyDescription("A Notepad++ TreeView plugin")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("João Rosa")] 11 | [assembly: AssemblyProduct("NppXmlTreeviewPlugin")] 12 | [assembly: AssemblyCopyright("Copyright © João Rosa 2018")] 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("31492674-6fe0-485c-91f0-2e17244588ff")] 23 | 24 | [assembly: AssemblyVersion("0.1.0.0")] 25 | [assembly: AssemblyInformationalVersion("0.1.0-Logging.1+86.Branch.Logging.Sha.0b2f3cd3fb32e2fdb47e3a778ba22b63726b2c6c")] 26 | [assembly: AssemblyFileVersion("0.1.0.0")] 27 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 NppXmlTreeviewPlugin.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NppXmlTreeviewPlugin.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap blue_document_tree { 67 | get { 68 | object obj = ResourceManager.GetObject("blue_document_tree", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap node_name { 77 | get { 78 | object obj = ResourceManager.GetObject("node-name", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap toggle { 87 | get { 88 | object obj = ResourceManager.GetObject("toggle", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap toggle_expand { 97 | get { 98 | object obj = ResourceManager.GetObject("toggle_expand", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\blue-document-tree.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\toggle-expand.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Resources\toggle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Resources\node-name.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Properties/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/Properties/star.png -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Properties/star_bmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/Properties/star_bmp.bmp -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Resources/blue-document-tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/Resources/blue-document-tree.png -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Resources/node-name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/Resources/node-name.png -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Resources/toggle-expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/Resources/toggle-expand.png -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/Resources/toggle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaoasrosa/nppxmltreeview/e9c4c9bde0cb48947e697006947d924ee76a1f7b/src/NppXmlTreeviewPlugin/Resources/toggle.png -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/TextBoundary.cs: -------------------------------------------------------------------------------- 1 | using NppXmlTreeviewPlugin.Parsers; 2 | 3 | namespace NppXmlTreeviewPlugin 4 | { 5 | /// 6 | /// Struct to store the text boundary for the treenode. 7 | /// 8 | public struct TextBoundary 9 | { 10 | /// 11 | /// Default struct constructor. 12 | /// 13 | /// The start node position. 14 | /// The end index. 15 | /// The node id. 16 | public TextBoundary(NppXmlNodePosition startNodePosition, NppXmlNodePosition endNodePosition, int id) 17 | { 18 | this.StartNodePosition = startNodePosition; 19 | this.EndNodePosition = endNodePosition; 20 | this.Id = id; 21 | } 22 | 23 | /// 24 | /// The start node position of the text. 25 | /// 26 | public NppXmlNodePosition StartNodePosition { get; private set; } 27 | 28 | /// 29 | /// The end node position of the text. 30 | /// 31 | public NppXmlNodePosition EndNodePosition { get; private set; } 32 | 33 | /// 34 | /// The node id. 35 | /// 36 | public int Id { get; private set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/UnmanagedExports.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.InteropServices; 4 | 5 | using NppPlugin.DllExport; 6 | using NppPluginNET; 7 | 8 | namespace NppXmlTreeviewPlugin 9 | { 10 | class UnmanagedExports 11 | { 12 | [DllExport(CallingConvention = CallingConvention.Cdecl)] 13 | static bool isUnicode() 14 | { 15 | return true; 16 | } 17 | 18 | [DllExport(CallingConvention = CallingConvention.Cdecl)] 19 | static void setInfo(NppData notepadPlusData) 20 | { 21 | PluginBase.nppData = notepadPlusData; 22 | Main.CommandMenuInit(); 23 | } 24 | 25 | [DllExport(CallingConvention = CallingConvention.Cdecl)] 26 | static IntPtr getFuncsArray(ref int nbF) 27 | { 28 | nbF = PluginBase._funcItems.Items.Count; 29 | return PluginBase._funcItems.NativePointer; 30 | } 31 | 32 | [DllExport(CallingConvention = CallingConvention.Cdecl)] 33 | static uint messageProc(uint Message, IntPtr wParam, IntPtr lParam) 34 | { 35 | return 1; 36 | } 37 | 38 | static IntPtr _ptrPluginName = IntPtr.Zero; 39 | [DllExport(CallingConvention = CallingConvention.Cdecl)] 40 | static IntPtr getName() 41 | { 42 | if (_ptrPluginName == IntPtr.Zero) 43 | _ptrPluginName = Marshal.StringToHGlobalUni(Main.PluginName); 44 | return _ptrPluginName; 45 | } 46 | 47 | [DllExport(CallingConvention = CallingConvention.Cdecl)] 48 | static void beNotified(IntPtr notifyCode) 49 | { 50 | SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); 51 | switch (nc.nmhdr.code) 52 | { 53 | case (uint)NppMsg.NPPN_TBMODIFICATION: 54 | PluginBase._funcItems.RefreshItems(); 55 | Main.SetToolBarIcon(); 56 | break; 57 | case (uint)NppMsg.NPPN_SHUTDOWN: 58 | Main.PluginCleanUp(); 59 | Marshal.FreeHGlobal(_ptrPluginName); 60 | break; 61 | case (uint)NppMsg.NPPN_FILESAVED: 62 | case (uint)NppMsg.NPPN_FILEOPENED: 63 | case 4294967294: 64 | if (null == Main.frmMyDlg) 65 | { 66 | return; 67 | } 68 | Main.frmMyDlg.UpdateUserInterface(); 69 | break; 70 | case (uint)SciMsg.SCN_MODIFIED: 71 | if (null == Main.frmMyDlg || !new[] { 1048576, 2064, 16400 }.Contains(nc.modificationType)) 72 | { 73 | return; 74 | } 75 | 76 | // Mouse selection. 77 | // TODO: and if I use keyboard? 78 | if (nc.modificationType == 16400) 79 | { 80 | // Update selection. 81 | Main.frmMyDlg.SetNodeSelection(); 82 | 83 | return; 84 | } 85 | 86 | Main.frmMyDlg.UpdateUserInterface(); 87 | break; 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/NppXmlTreeviewPlugin/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/NppXmlTreeviewPlugin.Parsers.Tests.Unit.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | AnyCPU 9 | {B73045E6-591E-4356-9B25-69D058D40ADB} 10 | Library 11 | Properties 12 | NppXmlTreeviewPlugin.Parsers.Tests.Unit 13 | NppXmlTreeviewPlugin.Parsers.Tests.Unit 14 | v4.6.1 15 | 512 16 | 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | true 38 | bin\x64\Debug\ 39 | DEBUG;TRACE 40 | full 41 | x64 42 | prompt 43 | MinimumRecommendedRules.ruleset 44 | 45 | 46 | bin\x64\Release\ 47 | TRACE 48 | true 49 | pdbonly 50 | x64 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | 54 | 55 | 56 | ..\..\packages\FluentAssertions.5.3.0\lib\net45\FluentAssertions.dll 57 | 58 | 59 | ..\..\packages\Serilog.2.6.0\lib\net46\Serilog.dll 60 | 61 | 62 | 63 | 64 | ..\..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll 74 | 75 | 76 | ..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll 77 | 78 | 79 | ..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll 80 | 81 | 82 | ..\..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | {eaba4132-6e8c-41ec-b6f0-666efca5439a} 94 | NppXmlTreeviewPlugin.Parsers 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | Always 106 | 107 | 108 | Always 109 | 110 | 111 | Always 112 | 113 | 114 | Always 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/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("NppXmlTreeviewPlugin.Parsers.Tests.Unit")] 8 | [assembly: AssemblyDescription("A Notepad++ TreeView plugin")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("João Rosa")] 11 | [assembly: AssemblyProduct("NppXmlTreeviewPlugin.Parsers.Tests.Unit")] 12 | [assembly: AssemblyCopyright("Copyright © João Rosa 2018")] 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("b73045e6-591e-4356-9b25-69d058d40adb")] 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("0.1.0.0")] 34 | [assembly: AssemblyVersion("0.1.0.0")] 35 | [assembly: AssemblyFileVersion("0.1.0.0")] 36 | 37 | [assembly: AssemblyInformationalVersion("0.1.0-Logging.1+86.Branch.Logging.Sha.0b2f3cd3fb32e2fdb47e3a778ba22b63726b2c6c")] 38 | -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/Stubs/LoggerStub.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using Serilog; 5 | using Serilog.Core; 6 | using Serilog.Events; 7 | 8 | namespace NppXmlTreeviewPlugin.Parsers.Tests.Unit.Stubs 9 | { 10 | public class LoggerStub : ILogger 11 | { 12 | public ILogger ForContext(ILogEventEnricher enricher) 13 | { 14 | throw new NotImplementedException(); 15 | } 16 | 17 | public ILogger ForContext(IEnumerable enrichers) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | 22 | public ILogger ForContext(string propertyName, object value, bool destructureObjects = false) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | 27 | public ILogger ForContext() 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | 32 | public ILogger ForContext(Type source) 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | 37 | public void Write(LogEvent logEvent) 38 | { 39 | throw new NotImplementedException(); 40 | } 41 | 42 | public void Write(LogEventLevel level, string messageTemplate) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | 47 | public void Write(LogEventLevel level, string messageTemplate, T propertyValue) 48 | { 49 | throw new NotImplementedException(); 50 | } 51 | 52 | public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1) 53 | { 54 | throw new NotImplementedException(); 55 | } 56 | 57 | public void Write(LogEventLevel level, 58 | string messageTemplate, 59 | T0 propertyValue0, 60 | T1 propertyValue1, 61 | T2 propertyValue2) 62 | { 63 | throw new NotImplementedException(); 64 | } 65 | 66 | public void Write(LogEventLevel level, string messageTemplate, params object[] propertyValues) 67 | { 68 | throw new NotImplementedException(); 69 | } 70 | 71 | public void Write(LogEventLevel level, Exception exception, string messageTemplate) 72 | { 73 | throw new NotImplementedException(); 74 | } 75 | 76 | public void Write(LogEventLevel level, Exception exception, string messageTemplate, T propertyValue) 77 | { 78 | throw new NotImplementedException(); 79 | } 80 | 81 | public void Write(LogEventLevel level, 82 | Exception exception, 83 | string messageTemplate, 84 | T0 propertyValue0, 85 | T1 propertyValue1) 86 | { 87 | throw new NotImplementedException(); 88 | } 89 | 90 | public void Write(LogEventLevel level, 91 | Exception exception, 92 | string messageTemplate, 93 | T0 propertyValue0, 94 | T1 propertyValue1, 95 | T2 propertyValue2) 96 | { 97 | throw new NotImplementedException(); 98 | } 99 | 100 | public void Write(LogEventLevel level, 101 | Exception exception, 102 | string messageTemplate, 103 | params object[] propertyValues) 104 | { 105 | throw new NotImplementedException(); 106 | } 107 | 108 | public bool IsEnabled(LogEventLevel level) 109 | { 110 | throw new NotImplementedException(); 111 | } 112 | 113 | public void Verbose(string messageTemplate) 114 | { 115 | throw new NotImplementedException(); 116 | } 117 | 118 | public void Verbose(string messageTemplate, T propertyValue) 119 | { 120 | throw new NotImplementedException(); 121 | } 122 | 123 | public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1) 124 | { 125 | throw new NotImplementedException(); 126 | } 127 | 128 | public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) 129 | { 130 | throw new NotImplementedException(); 131 | } 132 | 133 | public void Verbose(string messageTemplate, params object[] propertyValues) 134 | { 135 | throw new NotImplementedException(); 136 | } 137 | 138 | public void Verbose(Exception exception, string messageTemplate) 139 | { 140 | throw new NotImplementedException(); 141 | } 142 | 143 | public void Verbose(Exception exception, string messageTemplate, T propertyValue) 144 | { 145 | throw new NotImplementedException(); 146 | } 147 | 148 | public void Verbose(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) 149 | { 150 | throw new NotImplementedException(); 151 | } 152 | 153 | public void Verbose(Exception exception, 154 | string messageTemplate, 155 | T0 propertyValue0, 156 | T1 propertyValue1, 157 | T2 propertyValue2) 158 | { 159 | throw new NotImplementedException(); 160 | } 161 | 162 | public void Verbose(Exception exception, string messageTemplate, params object[] propertyValues) 163 | { 164 | throw new NotImplementedException(); 165 | } 166 | 167 | public void Debug(string messageTemplate) 168 | { 169 | throw new NotImplementedException(); 170 | } 171 | 172 | public void Debug(string messageTemplate, T propertyValue) 173 | { 174 | throw new NotImplementedException(); 175 | } 176 | 177 | public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1) 178 | { 179 | throw new NotImplementedException(); 180 | } 181 | 182 | public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) 183 | { 184 | throw new NotImplementedException(); 185 | } 186 | 187 | public void Debug(string messageTemplate, params object[] propertyValues) 188 | { 189 | throw new NotImplementedException(); 190 | } 191 | 192 | public void Debug(Exception exception, string messageTemplate) 193 | { 194 | throw new NotImplementedException(); 195 | } 196 | 197 | public void Debug(Exception exception, string messageTemplate, T propertyValue) 198 | { 199 | throw new NotImplementedException(); 200 | } 201 | 202 | public void Debug(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) 203 | { 204 | throw new NotImplementedException(); 205 | } 206 | 207 | public void Debug(Exception exception, 208 | string messageTemplate, 209 | T0 propertyValue0, 210 | T1 propertyValue1, 211 | T2 propertyValue2) 212 | { 213 | throw new NotImplementedException(); 214 | } 215 | 216 | public void Debug(Exception exception, string messageTemplate, params object[] propertyValues) 217 | { 218 | throw new NotImplementedException(); 219 | } 220 | 221 | public void Information(string messageTemplate) 222 | { 223 | throw new NotImplementedException(); 224 | } 225 | 226 | public void Information(string messageTemplate, T propertyValue) 227 | { 228 | throw new NotImplementedException(); 229 | } 230 | 231 | public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1) 232 | { 233 | throw new NotImplementedException(); 234 | } 235 | 236 | public void Information(string messageTemplate, 237 | T0 propertyValue0, 238 | T1 propertyValue1, 239 | T2 propertyValue2) 240 | { 241 | throw new NotImplementedException(); 242 | } 243 | 244 | public void Information(string messageTemplate, params object[] propertyValues) 245 | { 246 | throw new NotImplementedException(); 247 | } 248 | 249 | public void Information(Exception exception, string messageTemplate) 250 | { 251 | throw new NotImplementedException(); 252 | } 253 | 254 | public void Information(Exception exception, string messageTemplate, T propertyValue) 255 | { 256 | throw new NotImplementedException(); 257 | } 258 | 259 | public void Information(Exception exception, 260 | string messageTemplate, 261 | T0 propertyValue0, 262 | T1 propertyValue1) 263 | { 264 | throw new NotImplementedException(); 265 | } 266 | 267 | public void Information(Exception exception, 268 | string messageTemplate, 269 | T0 propertyValue0, 270 | T1 propertyValue1, 271 | T2 propertyValue2) 272 | { 273 | throw new NotImplementedException(); 274 | } 275 | 276 | public void Information(Exception exception, string messageTemplate, params object[] propertyValues) 277 | { 278 | throw new NotImplementedException(); 279 | } 280 | 281 | public void Warning(string messageTemplate) 282 | { 283 | throw new NotImplementedException(); 284 | } 285 | 286 | public void Warning(string messageTemplate, T propertyValue) 287 | { 288 | throw new NotImplementedException(); 289 | } 290 | 291 | public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1) 292 | { 293 | throw new NotImplementedException(); 294 | } 295 | 296 | public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) 297 | { 298 | throw new NotImplementedException(); 299 | } 300 | 301 | public void Warning(string messageTemplate, params object[] propertyValues) 302 | { 303 | throw new NotImplementedException(); 304 | } 305 | 306 | public void Warning(Exception exception, string messageTemplate) 307 | { 308 | } 309 | 310 | public void Warning(Exception exception, string messageTemplate, T propertyValue) 311 | { 312 | throw new NotImplementedException(); 313 | } 314 | 315 | public void Warning(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) 316 | { 317 | throw new NotImplementedException(); 318 | } 319 | 320 | public void Warning(Exception exception, 321 | string messageTemplate, 322 | T0 propertyValue0, 323 | T1 propertyValue1, 324 | T2 propertyValue2) 325 | { 326 | throw new NotImplementedException(); 327 | } 328 | 329 | public void Warning(Exception exception, string messageTemplate, params object[] propertyValues) 330 | { 331 | throw new NotImplementedException(); 332 | } 333 | 334 | public void Error(string messageTemplate) 335 | { 336 | throw new NotImplementedException(); 337 | } 338 | 339 | public void Error(string messageTemplate, T propertyValue) 340 | { 341 | throw new NotImplementedException(); 342 | } 343 | 344 | public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1) 345 | { 346 | throw new NotImplementedException(); 347 | } 348 | 349 | public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) 350 | { 351 | throw new NotImplementedException(); 352 | } 353 | 354 | public void Error(string messageTemplate, params object[] propertyValues) 355 | { 356 | throw new NotImplementedException(); 357 | } 358 | 359 | public void Error(Exception exception, string messageTemplate) 360 | { 361 | throw new NotImplementedException(); 362 | } 363 | 364 | public void Error(Exception exception, string messageTemplate, T propertyValue) 365 | { 366 | throw new NotImplementedException(); 367 | } 368 | 369 | public void Error(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) 370 | { 371 | throw new NotImplementedException(); 372 | } 373 | 374 | public void Error(Exception exception, 375 | string messageTemplate, 376 | T0 propertyValue0, 377 | T1 propertyValue1, 378 | T2 propertyValue2) 379 | { 380 | throw new NotImplementedException(); 381 | } 382 | 383 | public void Error(Exception exception, string messageTemplate, params object[] propertyValues) 384 | { 385 | throw new NotImplementedException(); 386 | } 387 | 388 | public void Fatal(string messageTemplate) 389 | { 390 | throw new NotImplementedException(); 391 | } 392 | 393 | public void Fatal(string messageTemplate, T propertyValue) 394 | { 395 | throw new NotImplementedException(); 396 | } 397 | 398 | public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1) 399 | { 400 | throw new NotImplementedException(); 401 | } 402 | 403 | public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) 404 | { 405 | throw new NotImplementedException(); 406 | } 407 | 408 | public void Fatal(string messageTemplate, params object[] propertyValues) 409 | { 410 | throw new NotImplementedException(); 411 | } 412 | 413 | public void Fatal(Exception exception, string messageTemplate) 414 | { 415 | throw new NotImplementedException(); 416 | } 417 | 418 | public void Fatal(Exception exception, string messageTemplate, T propertyValue) 419 | { 420 | throw new NotImplementedException(); 421 | } 422 | 423 | public void Fatal(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) 424 | { 425 | throw new NotImplementedException(); 426 | } 427 | 428 | public void Fatal(Exception exception, 429 | string messageTemplate, 430 | T0 propertyValue0, 431 | T1 propertyValue1, 432 | T2 propertyValue2) 433 | { 434 | throw new NotImplementedException(); 435 | } 436 | 437 | public void Fatal(Exception exception, string messageTemplate, params object[] propertyValues) 438 | { 439 | throw new NotImplementedException(); 440 | } 441 | 442 | public bool BindMessageTemplate(string messageTemplate, 443 | object[] propertyValues, 444 | out MessageTemplate parsedTemplate, 445 | out IEnumerable boundProperties) 446 | { 447 | throw new NotImplementedException(); 448 | } 449 | 450 | public bool BindProperty(string propertyName, 451 | object value, 452 | bool destructureObjects, 453 | out LogEventProperty property) 454 | { 455 | throw new NotImplementedException(); 456 | } 457 | } 458 | } -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/TestFiles/invalid_nocomments.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | atc:experiment 4 | xmlns:atc="http://www.humanfactors.uq.edu.au/atc/2006/atc-ns" 5 | atc:idx="Experiment1" 6 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 7 | xsi:schemaLocation="http://www.humanfactors.uq.edu.au/atc/2006/atc-ns atc_experiment.xsd"> 8 | 9 | 10 | 11 | 12 | NM-FT 13 | 14 | 15 | 16 | 420 17 | 370 18 | 2000 19 | 1000 20 | 21 | 22 | 23 | 450 24 | 370 25 | 2000 26 | 1000 27 | 28 | 29 | 30 | 450 31 | 470 32 | 1500 33 | 500 34 | 35 | 36 | 37 | 450 38 | 470 39 | 1500 40 | 500 41 | 42 | 43 | 44 | 480 45 | 430 46 | 2000 47 | 1000 48 | 49 | 50 | 51 | 440 52 | 370 53 | 2000 54 | 1000 55 | 56 | 57 | 58 | 490 59 | 430 60 | 2000 61 | 1000 62 | 63 | 64 | 65 | 450 66 | 390 67 | 2000 68 | 1000 69 | 70 | 71 | 72 | 470 73 | 430 74 | 2000 75 | 1000 76 | 77 | 78 | 79 | 210 80 | 250 81 | 2000 82 | 1000 83 | 84 | 85 | 86 | 205 87 | 240 88 | 1500 89 | 1000 90 | 91 | 92 | 93 | 94 | 95 |
96 | 97 | 100 |
98 |

Please wait for the next trial to start.

99 |
101 |
102 | ]]> 103 |
104 | 30 105 | true 106 |
107 | 108 | 109 | 110 | 111 |
112 | 113 | 116 |
114 |

You have five minutes to rest. Please inform the experimenter.

115 |
117 |
118 | ]]> 119 |
120 | 300 121 | true 122 |
123 | 124 | 125 | 126 | 127 |
128 | 129 | 132 |
130 |

Press the [SPACE] key to begin the experiment.

131 |
133 |
134 | ]]> 135 |
136 | Space 137 |
138 | 139 | 140 | 141 | 142 |
143 | 144 | 148 |
145 |

This is the end of the experiment. Thank you for participating.

146 |

Press the [SPACE] key to continue

147 |
149 |
150 | ]]> 151 |
152 | Space 153 |
154 | 155 |
156 | 157 | 158 | 159 | 160 | 5 161 | 1 162 | 1000 163 | 1 164 | 5 165 | 0 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 0 243 | 40000 244 | 460 245 | 246 | 247 | 248 | 249 | 250 | trial1 251 | 0 252 | 17 253 | GH21 254 | 255 | 256 | 257 | 258 | 0 259 | 40000 260 | 480 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | trial1 269 | 0 270 | 17 271 | GY58 272 | 273 | 274 | 275 | 276 | 0 277 | 34000 278 | 480 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | trial1 287 | 0 288 | 26 289 | DE68 290 | 291 | 292 | 293 | 294 | 0 295 | 34000 296 | 480 297 | 298 | 299 | 300 | 301 | 302 | 303 | trial1 304 | 0 305 | 26 306 | UK34 307 | 308 | 309 | 310 | 311 | 0 312 | 43000 313 | 470 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 0 323 | 35000 324 | 480 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 0 333 | 35000 334 | 500 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 0 343 | 31000 344 | 480 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 0 356 | 38000 357 | 460 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 0 366 | 34000 367 | 480 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 0 376 | 40000 377 | 480 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 15 387 | 38000 388 | 450 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 0 398 | 39000 399 | 460 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 10 408 | 36000 409 | 480 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 0 418 | 34000 419 | 430 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 0 430 | 39000 431 | 480 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 0 440 | 32000 441 | 450 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 10 450 | 40000 451 | 480 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | false 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 26 474 | Interrupting Scenario 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/WhenParsingInvalidXml.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | using FluentAssertions; 4 | 5 | using NppXmlTreeviewPlugin.Parsers.Tests.Unit.Stubs; 6 | 7 | using Xunit; 8 | 9 | namespace NppXmlTreeviewPlugin.Parsers.Tests.Unit 10 | { 11 | public class WhenParsingInvalidXml 12 | { 13 | [Theory] 14 | [InlineData(@"./TestFiles/invalid_comments.xml")] 15 | [InlineData(@"./TestFiles/invalid_nocomments.xml")] 16 | public void GivenValidXml_ThenTryParseIsValid(string path) 17 | { 18 | var xml = File.ReadAllText(path); 19 | 20 | NppXmlNode nppXmlNode; 21 | 22 | var result = NppXmlNode.TryParse(xml, new LoggerStub(), out nppXmlNode); 23 | 24 | result.Should().BeFalse(because: "the XML is invalid"); 25 | } 26 | 27 | [Theory] 28 | [InlineData(@"./TestFiles/invalid_comments.xml")] 29 | [InlineData(@"./TestFiles/invalid_nocomments.xml")] 30 | public void GivenValidXml_ThenNumberOfChildNodesMatch(string path) 31 | { 32 | var xml = File.ReadAllText(path); 33 | 34 | NppXmlNode nppXmlNode = null; 35 | 36 | NppXmlNode.TryParse(xml, new LoggerStub(), out nppXmlNode); 37 | 38 | nppXmlNode.Should().BeNull(because: "the XML is invalid"); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/WhenParsingValidXml.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | using FluentAssertions; 4 | 5 | using NppXmlTreeviewPlugin.Parsers.Tests.Unit.Stubs; 6 | 7 | using Xunit; 8 | 9 | namespace NppXmlTreeviewPlugin.Parsers.Tests.Unit 10 | { 11 | public class WhenParsingValidXml 12 | { 13 | [Theory] 14 | [InlineData(@"./TestFiles/valid_comments.xml")] 15 | [InlineData(@"./TestFiles/valid_nocomments.xml")] 16 | public void GivenValidXml_ThenTryParseIsValid(string path) 17 | { 18 | var xml = File.ReadAllText(path); 19 | 20 | NppXmlNode nppXmlNode; 21 | 22 | var result = NppXmlNode.TryParse(xml, new LoggerStub(), out nppXmlNode); 23 | 24 | result.Should().BeTrue(because: "the XML is valid"); 25 | } 26 | 27 | [Theory] 28 | [InlineData(@"./TestFiles/valid_comments.xml", 3)] 29 | [InlineData(@"./TestFiles/valid_nocomments.xml", 3)] 30 | public void GivenValidXml_ThenNumberOfChildNodesMatch(string path, int nodeCount) 31 | { 32 | var xml = File.ReadAllText(path); 33 | 34 | NppXmlNode nppXmlNode; 35 | 36 | NppXmlNode.TryParse(xml, new LoggerStub(), out nppXmlNode); 37 | 38 | nppXmlNode.ChildNodes.Count.Should().Be(nodeCount, because: $"the number of child nodes is {nodeCount}"); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /tests/NppXmlTreeviewPlugin.Parsers.Tests.Unit/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------