[clang-tidy] Move clang-tidy integration to contrib (iz #270763 - Move clang-tidy integration to nb contrib) release82
authorIlia Gromov <ilia@netbeans.org>
Tue, 30 May 2017 15:29:39 +0300
branchrelease82
changeset 1840367d78b11d2e0
parent 18396 23c0ac76825f
child 18404 d5e37d181d90
[clang-tidy] Move clang-tidy integration to contrib (iz #270763 - Move clang-tidy integration to nb contrib)
ide.analysis.modernize/build.xml
ide.analysis.modernize/l10n.list
ide.analysis.modernize/license.txt
ide.analysis.modernize/manifest.mf
ide.analysis.modernize/nbproject/project.properties
ide.analysis.modernize/nbproject/project.xml
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/Bundle.properties
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/AnalyzedFiles.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/Bundle.properties
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ConfigureHintsFix.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/DiagnosticsTool.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeCodeAudit.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorInfo.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorProvider.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeFix.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ResponseMerger.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/YamlParser.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/bugs.png
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/layer.xml
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/AnalyzerPreferences.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/Bundle.properties
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/ClangAnalyzerOptions.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/Bundle.properties
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/BundleUtilities.java
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang-tools-extra.patch
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang.patch
ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/utils/AnalyticsTools.java
ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.h
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.h
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/.dep.inc
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/Makefile
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml
ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h
ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp
ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp
ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp
ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world.json
ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java
ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java
ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java
ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java
ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java
ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ide.analysis.modernize/build.xml	Tue May 30 15:29:39 2017 +0300
     1.3 @@ -0,0 +1,8 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
     1.6 +<!-- for some information on what you could do (e.g. targets to override). -->
     1.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
     1.8 +<project name="contrib/ide.analysis.modernize" default="netbeans" basedir=".">
     1.9 +    <description>Builds, tests, and runs the project org.netbeans.modules.ide.analysis.modernize.</description>
    1.10 +    <import file="../../nbbuild/templates/projectized.xml"/>
    1.11 +</project>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/ide.analysis.modernize/l10n.list	Tue May 30 15:29:39 2017 +0300
     2.3 @@ -0,0 +1,2 @@
     2.4 +src/**/Bundle.properties
     2.5 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/ide.analysis.modernize/license.txt	Tue May 30 15:29:39 2017 +0300
     3.3 @@ -0,0 +1,565 @@
     3.4 +NetBeans IDE Dual License Header and License Notice
     3.5 +
     3.6 +Oracle elects to use only the GNU Lesser General Public License version 2.1 
     3.7 +(LGPL) for any software where a choice of LGPL/GPL license versions are made 
     3.8 +available with the language indicating that LGPLv2.1/GPLv2 or any later version 
     3.9 +may be used, or where a choice of which version of the LGPL/GPL is applied is 
    3.10 +unspecified.
    3.11 +For more information on the license please see: the NetBeans License FAQs. 
    3.12 +
    3.13 +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
    3.14 +
    3.15 +1. Definitions.
    3.16 +1.1. "Contributor" means each individual or entity that creates or contributes 
    3.17 +to the creation of Modifications.
    3.18 +1.2. "Contributor Version" means the combination of the Original Software, 
    3.19 +prior Modifications used by a Contributor (if any), and the Modifications made 
    3.20 +by that particular Contributor.
    3.21 +1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, 
    3.22 +or (c) the combination of files containing Original Software with files 
    3.23 +containing Modifications, in each case including portions thereof.
    3.24 +1.4. "Executable" means the Covered Software in any form other than Source Code.
    3.25 +1.5. "Initial Developer" means the individual or entity that first makes 
    3.26 +Original Software available under this License.
    3.27 +1.6. "Larger Work" means a work which combines Covered Software or portions 
    3.28 +thereof with code not governed by the terms of this License.
    3.29 +1.7. "License" means this document.
    3.30 +1.8. "Licensable" means having the right to grant, to the maximum extent 
    3.31 +possible, whether at the time of the initial grant or subsequently acquired, 
    3.32 +any and all of the rights conveyed herein.
    3.33 +1.9 "Modifications" means the Source Code and Executable form of any of the 
    3.34 +following:
    3.35 +A. Any file that results from an addition to, deletion from or modification of 
    3.36 +the contents of a file containing Original Software or previous Modifications;
    3.37 +B. Any new file that contains any part of the Original Software or previous 
    3.38 +Modification; or
    3.39 +C. Any new file that is contributed or otherwise made available under the terms 
    3.40 +of this License.
    3.41 +1.10. "Original Software" means the Source Code and Executable form of computer 
    3.42 +software code that is originally released under this License.
    3.43 +1.11. "Patent Claims" means any patent claim(s), now owned or hereafter 
    3.44 +acquired, including without limitation, method, process, and apparatus claims, 
    3.45 +in any patent Licensable by grantor.
    3.46 +1.12. "Source Code" means (a) the common form of computer software code in 
    3.47 +which modifications are made and (b) associated documentation included in or 
    3.48 +with such code.
    3.49 +1.13. "You" (or "Your") means an individual or a legal entity exercising rights 
    3.50 +under, and complying with all of the terms of, this License. For legal 
    3.51 +entities, "You" includes any entity which controls, is controlled by, or is 
    3.52 +under common control with You. For purposes of this definition, "control" means 
    3.53 +(a) the power, direct or indirect, to cause the direction or management of such 
    3.54 +entity, whether by contract or otherwise, or (b) ownership of more than fifty 
    3.55 +percent (50%) of the outstanding shares or beneficial ownership of such entity.
    3.56 +2. License Grants.
    3.57 +2.1. The Initial Developer Grant.
    3.58 +Conditioned upon Your compliance with Section 3.1 below and subject to third 
    3.59 +party intellectual property claims, the Initial Developer hereby grants You a 
    3.60 +world-wide, royalty-free, non-exclusive license:
    3.61 +(a) under intellectual property rights (other than patent or trademark) 
    3.62 +Licensable by Initial Developer, to use, reproduce, modify, display, perform, 
    3.63 +sublicense and distribute the Original Software (or portions thereof), with or 
    3.64 +without Modifications, and/or as part of a Larger Work; and
    3.65 +(b) under Patent Claims infringed by the making, using or selling of Original 
    3.66 +Software, to make, have made, use, practice, sell, and offer for sale, and/or 
    3.67 +otherwise dispose of the Original Software (or portions thereof).
    3.68 +(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date 
    3.69 +Initial Developer first distributes or otherwise makes the Original Software 
    3.70 +available to a third party under the terms of this License.
    3.71 +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for 
    3.72 +code that You delete from the Original Software, or (2) for infringements 
    3.73 +caused by: (i) the modification of the Original Software, or (ii) the 
    3.74 +combination of the Original Software with other software or devices.
    3.75 +2.2. Contributor Grant.
    3.76 +Conditioned upon Your compliance with Section 3.1 below and subject to third 
    3.77 +party intellectual property claims, each Contributor hereby grants You a 
    3.78 +world-wide, royalty-free, non-exclusive license:
    3.79 +(a) under intellectual property rights (other than patent or trademark) 
    3.80 +Licensable by Contributor to use, reproduce, modify, display, perform, 
    3.81 +sublicense and distribute the Modifications created by such Contributor (or 
    3.82 +portions thereof), either on an unmodified basis, with other Modifications, as 
    3.83 +Covered Software and/or as part of a Larger Work; and
    3.84 +(b) under Patent Claims infringed by the making, using, or selling of 
    3.85 +Modifications made by that Contributor either alone and/or in combination with 
    3.86 +its Contributor Version (or portions of such combination), to make, use, sell, 
    3.87 +offer for sale, have made, and/or otherwise dispose of: (1) Modifications made 
    3.88 +by that Contributor (or portions thereof); and (2) the combination of 
    3.89 +Modifications made by that Contributor with its Contributor Version (or 
    3.90 +portions of such combination).
    3.91 +(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the 
    3.92 +date Contributor first distributes or otherwise makes the Modifications 
    3.93 +available to a third party.
    3.94 +(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for 
    3.95 +any code that Contributor has deleted from the Contributor Version; (2) for 
    3.96 +infringements caused by: (i) third party modifications of Contributor Version, 
    3.97 +or (ii) the combination of Modifications made by that Contributor with other 
    3.98 +software (except as part of the Contributor Version) or other devices; or (3) 
    3.99 +under Patent Claims infringed by Covered Software in the absence of 
   3.100 +Modifications made by that Contributor.
   3.101 +3. Distribution Obligations.
   3.102 +3.1. Availability of Source Code.
   3.103 +Any Covered Software that You distribute or otherwise make available in 
   3.104 +Executable form must also be made available in Source Code form and that Source 
   3.105 +Code form must be distributed only under the terms of this License. You must 
   3.106 +include a copy of this License with every copy of the Source Code form of the 
   3.107 +Covered Software You distribute or otherwise make available. You must inform 
   3.108 +recipients of any such Covered Software in Executable form as to how they can 
   3.109 +obtain such Covered Software in Source Code form in a reasonable manner on or 
   3.110 +through a medium customarily used for software exchange.
   3.111 +3.2. Modifications.
   3.112 +The Modifications that You create or to which You contribute are governed by 
   3.113 +the terms of this License. You represent that You believe Your Modifications 
   3.114 +are Your original creation(s) and/or You have sufficient rights to grant the 
   3.115 +rights conveyed by this License.
   3.116 +3.3. Required Notices.
   3.117 +You must include a notice in each of Your Modifications that identifies You as 
   3.118 +the Contributor of the Modification. You may not remove or alter any copyright, 
   3.119 +patent or trademark notices contained within the Covered Software, or any 
   3.120 +notices of licensing or any descriptive text giving attribution to any 
   3.121 +Contributor or the Initial Developer.
   3.122 +3.4. Application of Additional Terms.
   3.123 +You may not offer or impose any terms on any Covered Software in Source Code 
   3.124 +form that alters or restricts the applicable version of this License or the 
   3.125 +recipients� rights hereunder. You may choose to offer, and to charge a fee 
   3.126 +for, warranty, support, indemnity or liability obligations to one or more 
   3.127 +recipients of Covered Software. However, you may do so only on Your own behalf, 
   3.128 +and not on behalf of the Initial Developer or any Contributor. You must make it 
   3.129 +absolutely clear that any such warranty, support, indemnity or liability 
   3.130 +obligation is offered by You alone, and You hereby agree to indemnify the 
   3.131 +Initial Developer and every Contributor for any liability incurred by the 
   3.132 +Initial Developer or such Contributor as a result of warranty, support, 
   3.133 +indemnity or liability terms You offer.
   3.134 +3.5. Distribution of Executable Versions.
   3.135 +You may distribute the Executable form of the Covered Software under the terms 
   3.136 +of this License or under the terms of a license of Your choice, which may 
   3.137 +contain terms different from this License, provided that You are in compliance 
   3.138 +with the terms of this License and that the license for the Executable form 
   3.139 +does not attempt to limit or alter the recipient�s rights in the Source Code 
   3.140 +form from the rights set forth in this License. If You distribute the Covered 
   3.141 +Software in Executable form under a different license, You must make it 
   3.142 +absolutely clear that any terms which differ from this License are offered by 
   3.143 +You alone, not by the Initial Developer or Contributor. You hereby agree to 
   3.144 +indemnify the Initial Developer and every Contributor for any liability 
   3.145 +incurred by the Initial Developer or such Contributor as a result of any such 
   3.146 +terms You offer.
   3.147 +3.6. Larger Works.
   3.148 +You may create a Larger Work by combining Covered Software with other code not 
   3.149 +governed by the terms of this License and distribute the Larger Work as a 
   3.150 +single product. In such a case, You must make sure the requirements of this 
   3.151 +License are fulfilled for the Covered Software.
   3.152 +4. Versions of the License.
   3.153 +4.1. New Versions.
   3.154 +Oracle Corp. is the initial license steward and may publish revised and/or new 
   3.155 +versions of this License from time to time. Each version will be given a 
   3.156 +distinguishing version number. Except as provided in Section 4.3, no one other 
   3.157 +than the license steward has the right to modify this License.
   3.158 +4.2. Effect of New Versions.
   3.159 +You may always continue to use, distribute or otherwise make the Covered 
   3.160 +Software available under the terms of the version of the License under which 
   3.161 +You originally received the Covered Software. If the Initial Developer includes 
   3.162 +a notice in the Original Software prohibiting it from being distributed or 
   3.163 +otherwise made available under any subsequent version of the License, You must 
   3.164 +distribute and make the Covered Software available under the terms of the 
   3.165 +version of the License under which You originally received the Covered 
   3.166 +Software. Otherwise, You may also choose to use, distribute or otherwise make 
   3.167 +the Covered Software available under the terms of any subsequent version of the 
   3.168 +License published by the license steward.
   3.169 +4.3. Modified Versions.
   3.170 +When You are an Initial Developer and You want to create a new license for Your 
   3.171 +Original Software, You may create and use a modified version of this License if 
   3.172 +You: (a) rename the license and remove any references to the name of the 
   3.173 +license steward (except to note that the license differs from this License); 
   3.174 +and (b) otherwise make it clear that the license contains terms which differ 
   3.175 +from this License.
   3.176 +5. DISCLAIMER OF WARRANTY.
   3.177 +COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT 
   3.178 +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT 
   3.179 +LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, 
   3.180 +MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK 
   3.181 +AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD 
   3.182 +ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL 
   3.183 +DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, 
   3.184 +REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART 
   3.185 +OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT 
   3.186 +UNDER THIS DISCLAIMER.
   3.187 +6. TERMINATION.
   3.188 +6.1. This License and the rights granted hereunder will terminate automatically 
   3.189 +if You fail to comply with terms herein and fail to cure such breach within 30 
   3.190 +days of becoming aware of the breach. Provisions which, by their nature, must 
   3.191 +remain in effect beyond the termination of this License shall survive.
   3.192 +6.2. If You assert a patent infringement claim (excluding declaratory judgment 
   3.193 +actions) against Initial Developer or a Contributor (the Initial Developer or 
   3.194 +Contributor against whom You assert such claim is referred to as "Participant") 
   3.195 +alleging that the Participant Software (meaning the Contributor Version where 
   3.196 +the Participant is a Contributor or the Original Software where the Participant 
   3.197 +is the Initial Developer) directly or indirectly infringes any patent, then any 
   3.198 +and all rights granted directly or indirectly to You by such Participant, the 
   3.199 +Initial Developer (if the Initial Developer is not the Participant) and all 
   3.200 +Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days 
   3.201 +notice from Participant terminate prospectively and automatically at the 
   3.202 +expiration of such 60 day notice period, unless if within such 60 day period 
   3.203 +You withdraw Your claim with respect to the Participant Software against such 
   3.204 +Participant either unilaterally or pursuant to a written agreement with 
   3.205 +Participant.
   3.206 +6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user 
   3.207 +licenses that have been validly granted by You or any distributor hereunder 
   3.208 +prior to termination (excluding licenses granted to You by any distributor) 
   3.209 +shall survive termination.
   3.210 +7. LIMITATION OF LIABILITY.
   3.211 +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING 
   3.212 +NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY 
   3.213 +OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF 
   3.214 +ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, 
   3.215 +INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT 
   3.216 +LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER 
   3.217 +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN 
   3.218 +IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS 
   3.219 +LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL 
   3.220 +INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW 
   3.221 +PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR 
   3.222 +LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND 
   3.223 +LIMITATION MAY NOT APPLY TO YOU.
   3.224 +8. U.S. GOVERNMENT END USERS.
   3.225 +The Covered Software is a "commercial item," as that term is defined in 48 
   3.226 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that 
   3.227 +term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer 
   3.228 +software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. 
   3.229 +1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 
   3.230 +227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software 
   3.231 +with only those rights set forth herein. This U.S. Government Rights clause is 
   3.232 +in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision 
   3.233 +that addresses Government rights in computer software under this License.
   3.234 +9. MISCELLANEOUS.
   3.235 +This License represents the complete agreement concerning subject matter 
   3.236 +hereof. If any provision of this License is held to be unenforceable, such 
   3.237 +provision shall be reformed only to the extent necessary to make it 
   3.238 +enforceable. This License shall be governed by the law of the jurisdiction 
   3.239 +specified in a notice contained within the Original Software (except to the 
   3.240 +extent applicable law, if any, provides otherwise), excluding such 
   3.241 +jurisdiction�s conflict-of-law provisions. Any litigation relating to this 
   3.242 +License shall be subject to the jurisdiction of the courts located in the 
   3.243 +jurisdiction and venue specified in a notice contained within the Original 
   3.244 +Software, with the losing party responsible for costs, including, without 
   3.245 +limitation, court costs and reasonable attorneys� fees and expenses. The 
   3.246 +application of the United Nations Convention on Contracts for the International 
   3.247 +Sale of Goods is expressly excluded. Any law or regulation which provides that 
   3.248 +the language of a contract shall be construed against the drafter shall not 
   3.249 +apply to this License. You agree that You alone are responsible for compliance 
   3.250 +with the United States export administration regulations (and the export 
   3.251 +control laws and regulation of any other countries) when You use, distribute or 
   3.252 +otherwise make available any Covered Software.
   3.253 +10. RESPONSIBILITY FOR CLAIMS.
   3.254 +As between Initial Developer and the Contributors, each party is responsible 
   3.255 +for claims and damages arising, directly or indirectly, out of its utilization 
   3.256 +of rights under this License and You agree to work with Initial Developer and 
   3.257 +Contributors to distribute such responsibility on an equitable basis. Nothing 
   3.258 +herein is intended or shall be deemed to constitute any admission of liability.
   3.259 +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE 
   3.260 +(CDDL)
   3.261 +The code released under the CDDL shall be governed by the laws of the State of 
   3.262 +California (excluding conflict-of-law provisions). Any litigation relating to 
   3.263 +this License shall be subject to the jurisdiction of the Federal Courts of the 
   3.264 +Northern District of California and the state courts of the State of 
   3.265 +California, with venue lying in Santa Clara County, California.
   3.266 +The GNU General Public License (GPL) Version 2, June 1991
   3.267 +
   3.268 +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 
   3.269 +330, Boston, MA 02111-1307 USA
   3.270 +Everyone is permitted to copy and distribute verbatim copies of this license 
   3.271 +document, but changing it is not allowed.
   3.272 +Preamble
   3.273 +The licenses for most software are designed to take away your freedom to share 
   3.274 +and change it. By contrast, the GNU General Public License is intended to 
   3.275 +guarantee your freedom to share and change free software--to make sure the 
   3.276 +software is free for all its users. This General Public License applies to most 
   3.277 +of the Free Software Foundation's software and to any other program whose 
   3.278 +authors commit to using it. (Some other Free Software Foundation software is 
   3.279 +covered by the GNU Library General Public License instead.) You can apply it to 
   3.280 +your programs, too.
   3.281 +When we speak of free software, we are referring to freedom, not price. Our 
   3.282 +General Public Licenses are designed to make sure that you have the freedom to 
   3.283 +distribute copies of free software (and charge for this service if you wish), 
   3.284 +that you receive source code or can get it if you want it, that you can change 
   3.285 +the software or use pieces of it in new free programs; and that you know you 
   3.286 +can do these things.
   3.287 +To protect your rights, we need to make restrictions that forbid anyone to deny 
   3.288 +you these rights or to ask you to surrender the rights. These restrictions 
   3.289 +translate to certain responsibilities for you if you distribute copies of the 
   3.290 +software, or if you modify it.
   3.291 +For example, if you distribute copies of such a program, whether gratis or for 
   3.292 +a fee, you must give the recipients all the rights that you have. You must make 
   3.293 +sure that they, too, receive or can get the source code. And you must show them 
   3.294 +these terms so they know their rights.
   3.295 +We protect your rights with two steps: (1) copyright the software, and (2) 
   3.296 +offer you this license which gives you legal permission to copy, distribute 
   3.297 +and/or modify the software.
   3.298 +Also, for each author's protection and ours, we want to make certain that 
   3.299 +everyone understands that there is no warranty for this free software. If the 
   3.300 +software is modified by someone else and passed on, we want its recipients to 
   3.301 +know that what they have is not the original, so that any problems introduced 
   3.302 +by others will not reflect on the original authors' reputations.
   3.303 +Finally, any free program is threatened constantly by software patents. We wish 
   3.304 +to avoid the danger that redistributors of a free program will individually 
   3.305 +obtain patent licenses, in effect making the program proprietary. To prevent 
   3.306 +this, we have made it clear that any patent must be licensed for everyone's 
   3.307 +free use or not licensed at all.
   3.308 +The precise terms and conditions for copying, distribution and modification 
   3.309 +follow.
   3.310 +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
   3.311 +0. This License applies to any program or other work which contains a notice 
   3.312 +placed by the copyright holder saying it may be distributed under the terms of 
   3.313 +this General Public License. The "Program", below, refers to any such program 
   3.314 +or work, and a "work based on the Program" means either the Program or any 
   3.315 +derivative work under copyright law: that is to say, a work containing the 
   3.316 +Program or a portion of it, either verbatim or with modifications and/or 
   3.317 +translated into another language. (Hereinafter, translation is included without 
   3.318 +limitation in the term "modification".) Each licensee is addressed as "you".
   3.319 +Activities other than copying, distribution and modification are not covered by 
   3.320 +this License; they are outside its scope. The act of running the Program is not 
   3.321 +restricted, and the output from the Program is covered only if its contents 
   3.322 +constitute a work based on the Program (independent of having been made by 
   3.323 +running the Program). Whether that is true depends on what the Program does.
   3.324 +1. You may copy and distribute verbatim copies of the Program's source code as 
   3.325 +you receive it, in any medium, provided that you conspicuously and 
   3.326 +appropriately publish on each copy an appropriate copyright notice and 
   3.327 +disclaimer of warranty; keep intact all the notices that refer to this License 
   3.328 +and to the absence of any warranty; and give any other recipients of the 
   3.329 +Program a copy of this License along with the Program.
   3.330 +You may charge a fee for the physical act of transferring a copy, and you may 
   3.331 +at your option offer warranty protection in exchange for a fee.
   3.332 +2. You may modify your copy or copies of the Program or any portion of it, thus 
   3.333 +forming a work based on the Program, and copy and distribute such modifications 
   3.334 +or work under the terms of Section 1 above, provided that you also meet all of 
   3.335 +these conditions:
   3.336 +a) You must cause the modified files to carry prominent notices stating that 
   3.337 +you changed the files and the date of any change.
   3.338 +b) You must cause any work that you distribute or publish, that in whole or in 
   3.339 +part contains or is derived from the Program or any part thereof, to be 
   3.340 +licensed as a whole at no charge to all third parties under the terms of this 
   3.341 +License.
   3.342 +c) If the modified program normally reads commands interactively when run, you 
   3.343 +must cause it, when started running for such interactive use in the most 
   3.344 +ordinary way, to print or display an announcement including an appropriate 
   3.345 +copyright notice and a notice that there is no warranty (or else, saying that 
   3.346 +you provide a warranty) and that users may redistribute the program under these 
   3.347 +conditions, and telling the user how to view a copy of this License. 
   3.348 +(Exception: if the Program itself is interactive but does not normally print 
   3.349 +such an announcement, your work based on the Program is not required to print 
   3.350 +an announcement.)
   3.351 +These requirements apply to the modified work as a whole. If identifiable 
   3.352 +sections of that work are not derived from the Program, and can be reasonably 
   3.353 +considered independent and separate works in themselves, then this License, and 
   3.354 +its terms, do not apply to those sections when you distribute them as separate 
   3.355 +works. But when you distribute the same sections as part of a whole which is a 
   3.356 +work based on the Program, the distribution of the whole must be on the terms 
   3.357 +of this License, whose permissions for other licensees extend to the entire 
   3.358 +whole, and thus to each and every part regardless of who wrote it.
   3.359 +Thus, it is not the intent of this section to claim rights or contest your 
   3.360 +rights to work written entirely by you; rather, the intent is to exercise the 
   3.361 +right to control the distribution of derivative or collective works based on 
   3.362 +the Program.
   3.363 +In addition, mere aggregation of another work not based on the Program with the 
   3.364 +Program (or with a work based on the Program) on a volume of a storage or 
   3.365 +distribution medium does not bring the other work under the scope of this 
   3.366 +License.
   3.367 +3. You may copy and distribute the Program (or a work based on it, under 
   3.368 +Section 2) in object code or executable form under the terms of Sections 1 and 
   3.369 +2 above provided that you also do one of the following:
   3.370 +a) Accompany it with the complete corresponding machine-readable source code, 
   3.371 +which must be distributed under the terms of Sections 1 and 2 above on a medium 
   3.372 +customarily used for software interchange; or,
   3.373 +b) Accompany it with a written offer, valid for at least three years, to give 
   3.374 +any third party, for a charge no more than your cost of physically performing 
   3.375 +source distribution, a complete machine-readable copy of the corresponding 
   3.376 +source code, to be distributed under the terms of Sections 1 and 2 above on a 
   3.377 +medium customarily used for software interchange; or,
   3.378 +c) Accompany it with the information you received as to the offer to distribute 
   3.379 +corresponding source code. (This alternative is allowed only for noncommercial 
   3.380 +distribution and only if you received the program in object code or executable 
   3.381 +form with such an offer, in accord with Subsection b above.)
   3.382 +The source code for a work means the preferred form of the work for making 
   3.383 +modifications to it. For an executable work, complete source code means all the 
   3.384 +source code for all modules it contains, plus any associated interface 
   3.385 +definition files, plus the scripts used to control compilation and installation 
   3.386 +of the executable. However, as a special exception, the source code distributed 
   3.387 +need not include anything that is normally distributed (in either source or 
   3.388 +binary form) with the major components (compiler, kernel, and so on) of the 
   3.389 +operating system on which the executable runs, unless that component itself 
   3.390 +accompanies the executable.
   3.391 +If distribution of executable or object code is made by offering access to copy 
   3.392 +from a designated place, then offering equivalent access to copy the source 
   3.393 +code from the same place counts as distribution of the source code, even though 
   3.394 +third parties are not compelled to copy the source along with the object code.
   3.395 +4. You may not copy, modify, sublicense, or distribute the Program except as 
   3.396 +expressly provided under this License. Any attempt otherwise to copy, modify, 
   3.397 +sublicense or distribute the Program is void, and will automatically terminate 
   3.398 +your rights under this License. However, parties who have received copies, or 
   3.399 +rights, from you under this License will not have their licenses terminated so 
   3.400 +long as such parties remain in full compliance.
   3.401 +5. You are not required to accept this License, since you have not signed it. 
   3.402 +However, nothing else grants you permission to modify or distribute the Program 
   3.403 +or its derivative works. These actions are prohibited by law if you do not 
   3.404 +accept this License. Therefore, by modifying or distributing the Program (or 
   3.405 +any work based on the Program), you indicate your acceptance of this License to 
   3.406 +do so, and all its terms and conditions for copying, distributing or modifying 
   3.407 +the Program or works based on it.
   3.408 +6. Each time you redistribute the Program (or any work based on the Program), 
   3.409 +the recipient automatically receives a license from the original licensor to 
   3.410 +copy, distribute or modify the Program subject to these terms and conditions. 
   3.411 +You may not impose any further restrictions on the recipients' exercise of the 
   3.412 +rights granted herein. You are not responsible for enforcing compliance by 
   3.413 +third parties to this License.
   3.414 +7. If, as a consequence of a court judgment or allegation of patent 
   3.415 +infringement or for any other reason (not limited to patent issues), conditions 
   3.416 +are imposed on you (whether by court order, agreement or otherwise) that 
   3.417 +contradict the conditions of this License, they do not excuse you from the 
   3.418 +conditions of this License. If you cannot distribute so as to satisfy 
   3.419 +simultaneously your obligations under this License and any other pertinent 
   3.420 +obligations, then as a consequence you may not distribute the Program at all. 
   3.421 +For example, if a patent license would not permit royalty-free redistribution 
   3.422 +of the Program by all those who receive copies directly or indirectly through 
   3.423 +you, then the only way you could satisfy both it and this License would be to 
   3.424 +refrain entirely from distribution of the Program.
   3.425 +If any portion of this section is held invalid or unenforceable under any 
   3.426 +particular circumstance, the balance of the section is intended to apply and 
   3.427 +the section as a whole is intended to apply in other circumstances.
   3.428 +It is not the purpose of this section to induce you to infringe any patents or 
   3.429 +other property right claims or to contest validity of any such claims; this 
   3.430 +section has the sole purpose of protecting the integrity of the free software 
   3.431 +distribution system, which is implemented by public license practices. Many 
   3.432 +people have made generous contributions to the wide range of software 
   3.433 +distributed through that system in reliance on consistent application of that 
   3.434 +system; it is up to the author/donor to decide if he or she is willing to 
   3.435 +distribute software through any other system and a licensee cannot impose that 
   3.436 +choice.
   3.437 +This section is intended to make thoroughly clear what is believed to be a 
   3.438 +consequence of the rest of this License.
   3.439 +8. If the distribution and/or use of the Program is restricted in certain 
   3.440 +countries either by patents or by copyrighted interfaces, the original 
   3.441 +copyright holder who places the Program under this License may add an explicit 
   3.442 +geographical distribution limitation excluding those countries, so that 
   3.443 +distribution is permitted only in or among countries not thus excluded. In such 
   3.444 +case, this License incorporates the limitation as if written in the body of 
   3.445 +this License.
   3.446 +9. The Free Software Foundation may publish revised and/or new versions of the 
   3.447 +General Public License from time to time. Such new versions will be similar in 
   3.448 +spirit to the present version, but may differ in detail to address new problems 
   3.449 +or concerns.
   3.450 +Each version is given a distinguishing version number. If the Program specifies 
   3.451 +a version number of this License which applies to it and "any later version", 
   3.452 +you have the option of following the terms and conditions either of that 
   3.453 +version or of any later version published by the Free Software Foundation. If 
   3.454 +the Program does not specify a version number of this License, you may choose 
   3.455 +any version ever published by the Free Software Foundation.
   3.456 +10. If you wish to incorporate parts of the Program into other free programs 
   3.457 +whose distribution conditions are different, write to the author to ask for 
   3.458 +permission. For software which is copyrighted by the Free Software Foundation, 
   3.459 +write to the Free Software Foundation; we sometimes make exceptions for this. 
   3.460 +Our decision will be guided by the two goals of preserving the free status of 
   3.461 +all derivatives of our free software and of promoting the sharing and reuse of 
   3.462 +software generally.
   3.463 +NO WARRANTY
   3.464 +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR 
   3.465 +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE 
   3.466 +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE 
   3.467 +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
   3.468 +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
   3.469 +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND 
   3.470 +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU 
   3.471 +ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
   3.472 +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL 
   3.473 +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE 
   3.474 +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 
   3.475 +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR 
   3.476 +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA 
   3.477 +BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 
   3.478 +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER 
   3.479 +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
   3.480 +END OF TERMS AND CONDITIONS
   3.481 +How to Apply These Terms to Your New Programs
   3.482 +If you develop a new program, and you want it to be of the greatest possible 
   3.483 +use to the public, the best way to achieve this is to make it free software 
   3.484 +which everyone can redistribute and change under these terms.
   3.485 +To do so, attach the following notices to the program. It is safest to attach 
   3.486 +them to the start of each source file to most effectively convey the exclusion 
   3.487 +of warranty; and each file should have at least the "copyright" line and a 
   3.488 +pointer to where the full notice is found.
   3.489 +One line to give the program's name and a brief idea of what it does.
   3.490 +Copyright (C)
   3.491 +This program is free software; you can redistribute it and/or modify it under 
   3.492 +the terms of the GNU General Public License as published by the Free Software 
   3.493 +Foundation; either version 2 of the License, or (at your option) any later 
   3.494 +version.
   3.495 +This program is distributed in the hope that it will be useful, but WITHOUT ANY 
   3.496 +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
   3.497 +PARTICULAR PURPOSE. See the GNU General Public License for more details.
   3.498 +You should have received a copy of the GNU General Public License along with 
   3.499 +this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
   3.500 +Place, Suite 330, Boston, MA 02111-1307 USA
   3.501 +Also add information on how to contact you by electronic and paper mail.
   3.502 +If the program is interactive, make it output a short notice like this when it 
   3.503 +starts in an interactive mode:
   3.504 +Gnomovision version 69, Copyright (C) year name of author
   3.505 +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This 
   3.506 +is free software, and you are welcome to redistribute it under certain 
   3.507 +conditions; type `show c' for details.
   3.508 +The hypothetical commands `show w' and `show c' should show the appropriate 
   3.509 +parts of the General Public License. Of course, the commands you use may be 
   3.510 +called something other than `show w' and `show c'; they could even be 
   3.511 +mouse-clicks or menu items--whatever suits your program.
   3.512 +You should also get your employer (if you work as a programmer) or your school, 
   3.513 +if any, to sign a "copyright disclaimer" for the program, if necessary. Here is 
   3.514 +a sample; alter the names:
   3.515 +Yoyodyne, Inc., hereby disclaims all copyright interest in the program 
   3.516 +`Gnomovision' (which makes passes at compilers) written by James Hacker.
   3.517 +signature of Ty Coon, 1 April 1989
   3.518 +Ty Coon, President of Vice
   3.519 +This General Public License does not permit incorporating your program into 
   3.520 +proprietary programs. If your program is a subroutine library, you may consider 
   3.521 +it more useful to permit linking proprietary applications with the library. If 
   3.522 +this is what you want to do, use the GNU Library General Public License instead 
   3.523 +of this License.
   3.524 +"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
   3.525 +Certain source files distributed by Oracle America, Inc. and/or its affiliates 
   3.526 +are subject to the following clarification and special exception to the GPLv2, 
   3.527 +based on the GNU Project exception for its Classpath libraries, known as the 
   3.528 +GNU Classpath Exception, but only where Oracle has expressly included in the 
   3.529 +particular source file's header the words "Oracle designates this particular 
   3.530 +file as subject to the "Classpath" exception as provided by Oracle in the 
   3.531 +LICENSE file that accompanied this code."
   3.532 +You should also note that Oracle includes multiple, independent programs in 
   3.533 +this software package. Some of those programs are provided under licenses 
   3.534 +deemed incompatible with the GPLv2 by the Free Software Foundation and others. 
   3.535 +For example, the package includes programs licensed under the Apache License, 
   3.536 +Version 2.0. Such programs are licensed to you under their original licenses.
   3.537 +Oracle facilitates your further distribution of this package by adding the 
   3.538 +Classpath Exception to the necessary parts of its GPLv2 code, which permits you 
   3.539 +to use that code in combination with other independent modules not licensed 
   3.540 +under the GPLv2. However, note that this would not permit you to commingle code 
   3.541 +under an incompatible license with Oracle's GPLv2 licensed code by, for 
   3.542 +example, cutting and pasting such code into a file also containing Oracle's 
   3.543 +GPLv2 licensed code and then distributing the result.
   3.544 +Additionally, if you were to remove the Classpath Exception from any of the 
   3.545 +files to which it applies and distribute the result, you would likely be 
   3.546 +required to license some or all of the other code in that distribution under 
   3.547 +the GPLv2 as well, and since the GPLv2 is incompatible with the license terms 
   3.548 +of some items included in the distribution by Oracle, removing the Classpath 
   3.549 +Exception could therefore effectively compromise your ability to further 
   3.550 +distribute the package.
   3.551 +Proceed with caution and we recommend that you obtain the advice of a lawyer 
   3.552 +skilled in open source matters before removing the Classpath Exception or 
   3.553 +making modifications to this package which may subsequently be redistributed 
   3.554 +and/or involve the use of third party software.
   3.555 +CLASSPATH EXCEPTION
   3.556 +Linking this library statically or dynamically with other modules is making a 
   3.557 +combined work based on this library. Thus, the terms and conditions of the GNU 
   3.558 +General Public License version 2 cover the whole combination.
   3.559 +As a special exception, the copyright holders of this library give you 
   3.560 +permission to link this library with independent modules to produce an 
   3.561 +executable, regardless of the license terms of these independent modules, and 
   3.562 +to copy and distribute the resulting executable under terms of your choice, 
   3.563 +provided that you also meet, for each linked independent module, the terms and 
   3.564 +conditions of the license of that module. An independent module is a module 
   3.565 +which is not derived from or based on this library. If you modify this library, 
   3.566 +you may extend this exception to your version of the library, but you are not 
   3.567 +obligated to do so. If you do not wish to do so, delete this exception 
   3.568 +statement from your version.
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/ide.analysis.modernize/manifest.mf	Tue May 30 15:29:39 2017 +0300
     4.3 @@ -0,0 +1,6 @@
     4.4 +Manifest-Version: 1.0
     4.5 +AutoUpdate-Show-In-Client: true
     4.6 +OpenIDE-Module: org.netbeans.modules.ide.analysis.modernize
     4.7 +OpenIDE-Module-Layer: org/netbeans/modules/ide/analysis/modernize/layer.xml
     4.8 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ide/analysis/modernize/Bundle.properties
     4.9 +OpenIDE-Module-Specification-Version: 1.1
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/ide.analysis.modernize/nbproject/project.properties	Tue May 30 15:29:39 2017 +0300
     5.3 @@ -0,0 +1,13 @@
     5.4 +javac.source=1.7
     5.5 +javac.compilerargs=-Xlint -Xlint:-serial
     5.6 +
     5.7 +license.file=license.txt
     5.8 +nbm.module.author=Ilia Gromov
     5.9 +nbm.needs.restart=true
    5.10 +test.unit.cp.extra=../../cnd.modelimpl/build/test/unit/classes:\
    5.11 +../../cnd/build/test/unit/classes:\
    5.12 +../../dlight.nativeexecution/build/test/unit/classes:\
    5.13 +../../editor.mimelookup/build/test/unit/classes:\
    5.14 +../../cnd.classview/build/test/unit/classes
    5.15 +
    5.16 +test.unit.run.cp.extra=../../editor.mimelookup/build/test/unit/classes
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/ide.analysis.modernize/nbproject/project.xml	Tue May 30 15:29:39 2017 +0300
     6.3 @@ -0,0 +1,334 @@
     6.4 +<?xml version="1.0" encoding="UTF-8"?>
     6.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
     6.6 +    <type>org.netbeans.modules.apisupport.project</type>
     6.7 +    <configuration>
     6.8 +        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
     6.9 +            <code-name-base>org.netbeans.modules.ide.analysis.modernize</code-name-base>
    6.10 +            <module-dependencies>
    6.11 +                <dependency>
    6.12 +                    <code-name-base>org.netbeans.api.progress</code-name-base>
    6.13 +                    <build-prerequisite/>
    6.14 +                    <compile-dependency/>
    6.15 +                    <run-dependency>
    6.16 +                        <release-version>1</release-version>
    6.17 +                        <specification-version>1.46.1</specification-version>
    6.18 +                    </run-dependency>
    6.19 +                </dependency>
    6.20 +                <dependency>
    6.21 +                    <code-name-base>org.netbeans.api.progress.nb</code-name-base>
    6.22 +                    <build-prerequisite/>
    6.23 +                    <compile-dependency/>
    6.24 +                    <run-dependency>
    6.25 +                        <specification-version>1.46.1</specification-version>
    6.26 +                    </run-dependency>
    6.27 +                </dependency>
    6.28 +                <dependency>
    6.29 +                    <code-name-base>org.netbeans.modules.cnd.analysis.api</code-name-base>
    6.30 +                    <build-prerequisite/>
    6.31 +                    <compile-dependency/>
    6.32 +                    <run-dependency>
    6.33 +                        <specification-version>1.3.1</specification-version>
    6.34 +                    </run-dependency>
    6.35 +                </dependency>
    6.36 +                <dependency>
    6.37 +                    <code-name-base>org.netbeans.modules.cnd.api.model</code-name-base>
    6.38 +                    <build-prerequisite/>
    6.39 +                    <compile-dependency/>
    6.40 +                    <run-dependency>
    6.41 +                        <release-version>1</release-version>
    6.42 +                        <specification-version>1.13.1.1</specification-version>
    6.43 +                    </run-dependency>
    6.44 +                </dependency>
    6.45 +                <dependency>
    6.46 +                    <code-name-base>org.netbeans.modules.cnd.api.project</code-name-base>
    6.47 +                    <build-prerequisite/>
    6.48 +                    <compile-dependency/>
    6.49 +                    <run-dependency>
    6.50 +                        <release-version>1</release-version>
    6.51 +                        <specification-version>1.31.4</specification-version>
    6.52 +                    </run-dependency>
    6.53 +                </dependency>
    6.54 +                <dependency>
    6.55 +                    <code-name-base>org.netbeans.modules.cnd.api.remote</code-name-base>
    6.56 +                    <build-prerequisite/>
    6.57 +                    <compile-dependency/>
    6.58 +                    <run-dependency>
    6.59 +                        <release-version>1</release-version>
    6.60 +                        <specification-version>1.22.2</specification-version>
    6.61 +                    </run-dependency>
    6.62 +                </dependency>
    6.63 +                <dependency>
    6.64 +                    <code-name-base>org.netbeans.modules.cnd.kit</code-name-base>
    6.65 +                    <run-dependency>
    6.66 +                        <specification-version>1.30.5.1</specification-version>
    6.67 +                    </run-dependency>
    6.68 +                </dependency>
    6.69 +                <dependency>
    6.70 +                    <code-name-base>org.netbeans.modules.cnd.makeproject</code-name-base>
    6.71 +                    <build-prerequisite/>
    6.72 +                    <compile-dependency/>
    6.73 +                    <run-dependency>
    6.74 +                        <release-version>2</release-version>
    6.75 +                        <specification-version>1.15.0.1</specification-version>
    6.76 +                    </run-dependency>
    6.77 +                </dependency>
    6.78 +                <dependency>
    6.79 +                    <code-name-base>org.netbeans.modules.cnd.model.services</code-name-base>
    6.80 +                    <build-prerequisite/>
    6.81 +                    <compile-dependency/>
    6.82 +                    <run-dependency>
    6.83 +                        <release-version>1</release-version>
    6.84 +                        <specification-version>1.42.16</specification-version>
    6.85 +                    </run-dependency>
    6.86 +                </dependency>
    6.87 +                <dependency>
    6.88 +                    <code-name-base>org.netbeans.modules.cnd.modelutil</code-name-base>
    6.89 +                    <build-prerequisite/>
    6.90 +                    <compile-dependency/>
    6.91 +                    <run-dependency>
    6.92 +                        <release-version>1</release-version>
    6.93 +                        <specification-version>1.14.0.1</specification-version>
    6.94 +                    </run-dependency>
    6.95 +                </dependency>
    6.96 +                <dependency>
    6.97 +                    <code-name-base>org.netbeans.modules.cnd.toolchain</code-name-base>
    6.98 +                    <build-prerequisite/>
    6.99 +                    <compile-dependency/>
   6.100 +                    <run-dependency>
   6.101 +                        <specification-version>1.5.0.1</specification-version>
   6.102 +                    </run-dependency>
   6.103 +                </dependency>
   6.104 +                <dependency>
   6.105 +                    <code-name-base>org.netbeans.modules.cnd.utils</code-name-base>
   6.106 +                    <build-prerequisite/>
   6.107 +                    <compile-dependency/>
   6.108 +                    <run-dependency>
   6.109 +                        <specification-version>1.17.1</specification-version>
   6.110 +                    </run-dependency>
   6.111 +                </dependency>
   6.112 +                <dependency>
   6.113 +                    <code-name-base>org.netbeans.modules.cnd.utils.ui</code-name-base>
   6.114 +                    <build-prerequisite/>
   6.115 +                    <compile-dependency/>
   6.116 +                    <run-dependency>
   6.117 +                        <specification-version>1.0</specification-version>
   6.118 +                    </run-dependency>
   6.119 +                </dependency>
   6.120 +                <dependency>
   6.121 +                    <code-name-base>org.netbeans.modules.code.analysis</code-name-base>
   6.122 +                    <build-prerequisite/>
   6.123 +                    <compile-dependency/>
   6.124 +                    <run-dependency>
   6.125 +                        <release-version>0</release-version>
   6.126 +                        <specification-version>1.8</specification-version>
   6.127 +                    </run-dependency>
   6.128 +                </dependency>
   6.129 +                <dependency>
   6.130 +                    <code-name-base>org.netbeans.modules.dlight.nativeexecution</code-name-base>
   6.131 +                    <build-prerequisite/>
   6.132 +                    <compile-dependency/>
   6.133 +                    <run-dependency>
   6.134 +                        <specification-version>1.10.3</specification-version>
   6.135 +                    </run-dependency>
   6.136 +                </dependency>
   6.137 +                <dependency>
   6.138 +                    <code-name-base>org.netbeans.modules.dlight.remote</code-name-base>
   6.139 +                    <build-prerequisite/>
   6.140 +                    <compile-dependency/>
   6.141 +                    <run-dependency>
   6.142 +                        <specification-version>1.28.7.1</specification-version>
   6.143 +                    </run-dependency>
   6.144 +                </dependency>
   6.145 +                <dependency>
   6.146 +                    <code-name-base>org.netbeans.modules.dlight.remote.ui</code-name-base>
   6.147 +                    <build-prerequisite/>
   6.148 +                    <compile-dependency/>
   6.149 +                    <run-dependency>
   6.150 +                        <specification-version>1.1.0</specification-version>
   6.151 +                    </run-dependency>
   6.152 +                </dependency>
   6.153 +                <dependency>
   6.154 +                    <code-name-base>org.netbeans.modules.editor.document</code-name-base>
   6.155 +                    <build-prerequisite/>
   6.156 +                    <compile-dependency/>
   6.157 +                    <run-dependency>
   6.158 +                        <specification-version>1.6.0.1</specification-version>
   6.159 +                    </run-dependency>
   6.160 +                </dependency>
   6.161 +                <dependency>
   6.162 +                    <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
   6.163 +                    <build-prerequisite/>
   6.164 +                    <compile-dependency/>
   6.165 +                    <run-dependency>
   6.166 +                        <release-version>3</release-version>
   6.167 +                        <specification-version>4.3.1.22.1.44</specification-version>
   6.168 +                    </run-dependency>
   6.169 +                </dependency>
   6.170 +                <dependency>
   6.171 +                    <code-name-base>org.netbeans.modules.options.api</code-name-base>
   6.172 +                    <build-prerequisite/>
   6.173 +                    <compile-dependency/>
   6.174 +                    <run-dependency>
   6.175 +                        <release-version>1</release-version>
   6.176 +                        <specification-version>1.22</specification-version>
   6.177 +                    </run-dependency>
   6.178 +                </dependency>
   6.179 +                <dependency>
   6.180 +                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
   6.181 +                    <build-prerequisite/>
   6.182 +                    <compile-dependency/>
   6.183 +                    <run-dependency>
   6.184 +                        <release-version>1</release-version>
   6.185 +                        <specification-version>1.36</specification-version>
   6.186 +                    </run-dependency>
   6.187 +                </dependency>
   6.188 +                <dependency>
   6.189 +                    <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
   6.190 +                    <build-prerequisite/>
   6.191 +                    <compile-dependency/>
   6.192 +                    <run-dependency>
   6.193 +                        <specification-version>1.47.1.1</specification-version>
   6.194 +                    </run-dependency>
   6.195 +                </dependency>
   6.196 +                <dependency>
   6.197 +                    <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
   6.198 +                    <build-prerequisite/>
   6.199 +                    <compile-dependency/>
   6.200 +                    <run-dependency>
   6.201 +                        <release-version>0-1</release-version>
   6.202 +                        <specification-version>1.18.0.7.9</specification-version>
   6.203 +                    </run-dependency>
   6.204 +                </dependency>
   6.205 +                <dependency>
   6.206 +                    <code-name-base>org.openide.awt</code-name-base>
   6.207 +                    <build-prerequisite/>
   6.208 +                    <compile-dependency/>
   6.209 +                    <run-dependency>
   6.210 +                        <specification-version>7.31</specification-version>
   6.211 +                    </run-dependency>
   6.212 +                </dependency>
   6.213 +                <dependency>
   6.214 +                    <code-name-base>org.openide.filesystems</code-name-base>
   6.215 +                    <build-prerequisite/>
   6.216 +                    <compile-dependency/>
   6.217 +                    <run-dependency>
   6.218 +                        <specification-version>9.8.1</specification-version>
   6.219 +                    </run-dependency>
   6.220 +                </dependency>
   6.221 +                <dependency>
   6.222 +                    <code-name-base>org.openide.filesystems.nb</code-name-base>
   6.223 +                    <build-prerequisite/>
   6.224 +                    <compile-dependency/>
   6.225 +                    <run-dependency>
   6.226 +                        <specification-version>9.7.1</specification-version>
   6.227 +                    </run-dependency>
   6.228 +                </dependency>
   6.229 +                <dependency>
   6.230 +                    <code-name-base>org.openide.loaders</code-name-base>
   6.231 +                    <build-prerequisite/>
   6.232 +                    <compile-dependency/>
   6.233 +                    <run-dependency>
   6.234 +                        <specification-version>7.61</specification-version>
   6.235 +                    </run-dependency>
   6.236 +                </dependency>
   6.237 +                <dependency>
   6.238 +                    <code-name-base>org.openide.modules</code-name-base>
   6.239 +                    <build-prerequisite/>
   6.240 +                    <compile-dependency/>
   6.241 +                    <run-dependency>
   6.242 +                        <specification-version>7.47.1</specification-version>
   6.243 +                    </run-dependency>
   6.244 +                </dependency>
   6.245 +                <dependency>
   6.246 +                    <code-name-base>org.openide.text</code-name-base>
   6.247 +                    <build-prerequisite/>
   6.248 +                    <compile-dependency/>
   6.249 +                    <run-dependency>
   6.250 +                        <specification-version>6.66.1</specification-version>
   6.251 +                    </run-dependency>
   6.252 +                </dependency>
   6.253 +                <dependency>
   6.254 +                    <code-name-base>org.openide.util</code-name-base>
   6.255 +                    <build-prerequisite/>
   6.256 +                    <compile-dependency/>
   6.257 +                    <run-dependency>
   6.258 +                        <specification-version>9.3</specification-version>
   6.259 +                    </run-dependency>
   6.260 +                </dependency>
   6.261 +                <dependency>
   6.262 +                    <code-name-base>org.openide.util.lookup</code-name-base>
   6.263 +                    <build-prerequisite/>
   6.264 +                    <compile-dependency/>
   6.265 +                    <run-dependency>
   6.266 +                        <specification-version>8.23</specification-version>
   6.267 +                    </run-dependency>
   6.268 +                </dependency>
   6.269 +                <dependency>
   6.270 +                    <code-name-base>org.openide.util.ui</code-name-base>
   6.271 +                    <build-prerequisite/>
   6.272 +                    <compile-dependency/>
   6.273 +                    <run-dependency>
   6.274 +                        <specification-version>9.3</specification-version>
   6.275 +                    </run-dependency>
   6.276 +                </dependency>
   6.277 +                <dependency>
   6.278 +                    <code-name-base>org.openide.windows</code-name-base>
   6.279 +                    <build-prerequisite/>
   6.280 +                    <compile-dependency/>
   6.281 +                    <run-dependency>
   6.282 +                        <specification-version>6.74.1</specification-version>
   6.283 +                    </run-dependency>
   6.284 +                </dependency>
   6.285 +            </module-dependencies>
   6.286 +            <test-dependencies>
   6.287 +                <test-type>
   6.288 +                    <name>unit</name>
   6.289 +                    <test-dependency>
   6.290 +                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
   6.291 +                        <compile-dependency/>
   6.292 +                    </test-dependency>
   6.293 +                    <test-dependency>
   6.294 +                        <code-name-base>org.netbeans.modules.cnd.classview</code-name-base>
   6.295 +                        <compile-dependency/>
   6.296 +                    </test-dependency>
   6.297 +                    <test-dependency>
   6.298 +                        <code-name-base>org.netbeans.modules.cnd.kit</code-name-base>
   6.299 +                        <recursive/>
   6.300 +                        <compile-dependency/>
   6.301 +                        <test/>
   6.302 +                    </test-dependency>
   6.303 +                    <test-dependency>
   6.304 +                        <code-name-base>org.netbeans.modules.cnd.makeproject</code-name-base>
   6.305 +                        <recursive/>
   6.306 +                        <compile-dependency/>
   6.307 +                        <test/>
   6.308 +                    </test-dependency>
   6.309 +                    <test-dependency>
   6.310 +                        <code-name-base>org.netbeans.modules.cnd.modelimpl</code-name-base>
   6.311 +                        <recursive/>
   6.312 +                        <compile-dependency/>
   6.313 +                        <test/>
   6.314 +                    </test-dependency>
   6.315 +                    <test-dependency>
   6.316 +                        <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
   6.317 +                        <recursive/>
   6.318 +                        <compile-dependency/>
   6.319 +                        <test/>
   6.320 +                    </test-dependency>
   6.321 +                    <test-dependency>
   6.322 +                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
   6.323 +                        <recursive/>
   6.324 +                        <compile-dependency/>
   6.325 +                    </test-dependency>
   6.326 +                    <test-dependency>
   6.327 +                        <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
   6.328 +                        <recursive/>
   6.329 +                        <compile-dependency/>
   6.330 +                        <test/>
   6.331 +                    </test-dependency>
   6.332 +                </test-type>
   6.333 +            </test-dependencies>
   6.334 +            <public-packages/>
   6.335 +        </data>
   6.336 +    </configuration>
   6.337 +</project>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/Bundle.properties	Tue May 30 15:29:39 2017 +0300
     7.3 @@ -0,0 +1,8 @@
     7.4 +OpenIDE-Module-Display-Category=Oracle Developer Studio
     7.5 +OpenIDE-Module-Long-Description=\
     7.6 +    This plugin enables clang-tidy analysis on C/C++ projects and files via Source->Inspect or right in the Editor.\n\
     7.7 +    Works only with "Clang-tidy wrapper for <OS> <bitness>" plugin.\n\n\
     7.8 +    Please note that in order to have clang-tidy hints in the Editor you should run Source->Inspect on your whole project.\n\
     7.9 +    You can view list of checks and enable/disable them in Options->Editor->Hints.
    7.10 +OpenIDE-Module-Name=Clang-TIdy integration
    7.11 +OpenIDE-Module-Short-Description=clang-tidy analyzer integration
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/AnalyzedFiles.java	Tue May 30 15:29:39 2017 +0300
     8.3 @@ -0,0 +1,114 @@
     8.4 +/*
     8.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     8.6 + *
     8.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
     8.8 + *
     8.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    8.10 + * Other names may be trademarks of their respective owners.
    8.11 + *
    8.12 + * The contents of this file are subject to the terms of either the GNU
    8.13 + * General Public License Version 2 only ("GPL") or the Common
    8.14 + * Development and Distribution License("CDDL") (collectively, the
    8.15 + * "License"). You may not use this file except in compliance with the
    8.16 + * License. You can obtain a copy of the License at
    8.17 + * http://www.netbeans.org/cddl-gplv2.html
    8.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    8.19 + * specific language governing permissions and limitations under the
    8.20 + * License.  When distributing the software, include this License Header
    8.21 + * Notice in each file and include the License file at
    8.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    8.23 + * particular file as subject to the "Classpath" exception as provided
    8.24 + * by Oracle in the GPL Version 2 section of the License file that
    8.25 + * accompanied this code. If applicable, add the following below the
    8.26 + * License Header, with the fields enclosed by brackets [] replaced by
    8.27 + * your own identifying information:
    8.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    8.29 + *
    8.30 + * If you wish your version of this file to be governed by only the CDDL
    8.31 + * or only the GPL Version 2, indicate your decision by adding
    8.32 + * "[Contributor] elects to include this software in this distribution
    8.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    8.34 + * single choice of license, a recipient has the option to distribute
    8.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    8.36 + * to extend the choice of license to its licensees as provided above.
    8.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    8.38 + * Version 2 license, then the option applies only if the new code is
    8.39 + * made subject to such option by the copyright holder.
    8.40 + *
    8.41 + * Contributor(s): Ilia Gromov
    8.42 + */
    8.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
    8.44 +
    8.45 +import java.util.Collection;
    8.46 +import java.util.HashMap;
    8.47 +import java.util.HashSet;
    8.48 +import java.util.Map;
    8.49 +import java.util.Set;
    8.50 +import org.netbeans.modules.cnd.api.model.CsmFile;
    8.51 +
    8.52 +/**
    8.53 + * This cache is designed to help Editor showing correct checks for included
    8.54 + * files.
    8.55 + *
    8.56 + * @param <T>
    8.57 + */
    8.58 +public class AnalyzedFiles {
    8.59 +
    8.60 +    private final Map<CsmFile, Set<CsmFile>> hierarchyCache = new HashMap<CsmFile, Set<CsmFile>>();
    8.61 +//    private final Map<FileObject, Set<CsmErrorInfo>> diagnosticsCache = new HashMap<FileObject, Set<CsmErrorInfo>>();
    8.62 +
    8.63 +//    public void cacheDiagnostics(FileObject fo, CsmErrorInfo info) {
    8.64 +//        Set<CsmErrorInfo> alreadyMapped = diagnosticsCache.get(fo);
    8.65 +//
    8.66 +//        if (alreadyMapped == null) {
    8.67 +//            alreadyMapped = new HashSet<CsmErrorInfo>();
    8.68 +//            diagnosticsCache.put(fo, alreadyMapped);
    8.69 +//        }
    8.70 +//
    8.71 +//        alreadyMapped.add(info);
    8.72 +//    }
    8.73 +    public void cacheHierarchy(CsmFile startFile, Collection<CsmFile> includedFiles) {
    8.74 +        Set<CsmFile> alreadyMapped = hierarchyCache.get(startFile);
    8.75 +
    8.76 +        if (alreadyMapped == null) {
    8.77 +            alreadyMapped = new HashSet<CsmFile>();
    8.78 +            hierarchyCache.put(startFile, alreadyMapped);
    8.79 +        }
    8.80 +
    8.81 +        alreadyMapped.addAll(includedFiles);
    8.82 +    }
    8.83 +
    8.84 +//    public Set<CsmErrorInfo> getDiagnostics(FileObject fo) {
    8.85 +//        return diagnosticsCache.get(fo);
    8.86 +//    }
    8.87 +
    8.88 +    public Collection<? extends CsmFile> getStartFiles(CsmFile includedFile) {
    8.89 +        Set<CsmFile> result = new HashSet<CsmFile>();
    8.90 +        for (Map.Entry<CsmFile, Set<CsmFile>> entry : hierarchyCache.entrySet()) {
    8.91 +            CsmFile key = entry.getKey();
    8.92 +            Set<CsmFile> value = entry.getValue();
    8.93 +
    8.94 +            if (value.contains(includedFile)) {
    8.95 +                result.add(key);
    8.96 +            }
    8.97 +        }
    8.98 +        return result;
    8.99 +    }
   8.100 +
   8.101 +    public boolean isStartFile(CsmFile file) {
   8.102 +        return hierarchyCache.containsKey(file);
   8.103 +    }
   8.104 +
   8.105 +    public void clear() {
   8.106 +        hierarchyCache.clear();
   8.107 +    }
   8.108 +
   8.109 +    public static AnalyzedFiles getDefault() {
   8.110 +        return HOLDER.INSTANCE;
   8.111 +    }
   8.112 +
   8.113 +    private static class HOLDER {
   8.114 +
   8.115 +        public static final AnalyzedFiles INSTANCE = new AnalyzedFiles();
   8.116 +    }
   8.117 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/Bundle.properties	Tue May 30 15:29:39 2017 +0300
     9.3 @@ -0,0 +1,59 @@
     9.4 +#
     9.5 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     9.6 +#
     9.7 +# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
     9.8 +#
     9.9 +# The contents of this file are subject to the terms of either the GNU
    9.10 +# General Public License Version 2 only ("GPL") or the Common
    9.11 +# Development and Distribution License("CDDL") (collectively, the
    9.12 +# "License"). You may not use this file except in compliance with the
    9.13 +# License. You can obtain a copy of the License at
    9.14 +# http://www.netbeans.org/cddl-gplv2.html
    9.15 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    9.16 +# specific language governing permissions and limitations under the
    9.17 +# License.  When distributing the software, include this License Header
    9.18 +# Notice in each file and include the License file at
    9.19 +# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    9.20 +# particular file as subject to the "Classpath" exception as provided
    9.21 +# by Sun in the GPL Version 2 section of the License file that
    9.22 +# accompanied this code. If applicable, add the following below the
    9.23 +# License Header, with the fields enclosed by brackets [] replaced by
    9.24 +# your own identifying information:
    9.25 +# "Portions Copyrighted [year] [name of copyright owner]"
    9.26 +#
    9.27 +# Contributor(s):
    9.28 +#
    9.29 +# The Original Software is NetBeans. The Initial Developer of the Original
    9.30 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
    9.31 +# Microsystems, Inc. All Rights Reserved.
    9.32 +#
    9.33 +# If you wish your version of this file to be governed by only the CDDL
    9.34 +# or only the GPL Version 2, indicate your decision by adding
    9.35 +# "[Contributor] elects to include this software in this distribution
    9.36 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
    9.37 +# single choice of license, a recipient has the option to distribute
    9.38 +# your version of this file under either the CDDL, the GPL Version 2 or
    9.39 +# to extend the choice of license to its licensees as provided above.
    9.40 +# However, if you add GPL Version 2 code and therefore, elected the GPL
    9.41 +# Version 2 license, then the option applies only if the new code is
    9.42 +# made subject to such option by the copyright holder.
    9.43 +#
    9.44 +
    9.45 +LBL_ProviderName=C/C++ Errors
    9.46 +LBL_ProviderDescription=C/C++ errors and warnings
    9.47 +
    9.48 +#Previse errors
    9.49 +Modernize_NAME=Clang-Tidy analyzer
    9.50 +Modernize_DESCRIPTION=Show warnings identified by clang-tidy.\
    9.51 +   <br>clang-tidy is a clang-based C++ \u201clinter\u201d tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis. \
    9.52 +   <br>Expand the node to specify which static checks you want to be displayed.
    9.53 +DisableHint=Configure clang-tidy analyzer - {0}
    9.54 +
    9.55 +#internal error
    9.56 +tool.error=Oracle Developer Studio compilers not found
    9.57 +remote.mode.error=Unsupported remote mode
    9.58 +remote.mode.error.info=Mode {0}
    9.59 +temporary.file.error=Cannot create temporary file
    9.60 +compile.file.error=Clang-tidy was unable to analyze file
    9.61 +fatal.analyze.error=Clang-tidy was unable to analyze file
    9.62 +compile.file.error.info=Exit code: {0}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ConfigureHintsFix.java	Tue May 30 15:29:39 2017 +0300
    10.3 @@ -0,0 +1,80 @@
    10.4 +/*
    10.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    10.6 + *
    10.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    10.8 + *
    10.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   10.10 + * Other names may be trademarks of their respective owners.
   10.11 + *
   10.12 + * The contents of this file are subject to the terms of either the GNU
   10.13 + * General Public License Version 2 only ("GPL") or the Common
   10.14 + * Development and Distribution License("CDDL") (collectively, the
   10.15 + * "License"). You may not use this file except in compliance with the
   10.16 + * License. You can obtain a copy of the License at
   10.17 + * http://www.netbeans.org/cddl-gplv2.html
   10.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   10.19 + * specific language governing permissions and limitations under the
   10.20 + * License.  When distributing the software, include this License Header
   10.21 + * Notice in each file and include the License file at
   10.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   10.23 + * particular file as subject to the "Classpath" exception as provided
   10.24 + * by Oracle in the GPL Version 2 section of the License file that
   10.25 + * accompanied this code. If applicable, add the following below the
   10.26 + * License Header, with the fields enclosed by brackets [] replaced by
   10.27 + * your own identifying information:
   10.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   10.29 + *
   10.30 + * If you wish your version of this file to be governed by only the CDDL
   10.31 + * or only the GPL Version 2, indicate your decision by adding
   10.32 + * "[Contributor] elects to include this software in this distribution
   10.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   10.34 + * single choice of license, a recipient has the option to distribute
   10.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   10.36 + * to extend the choice of license to its licensees as provided above.
   10.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   10.38 + * Version 2 license, then the option applies only if the new code is
   10.39 + * made subject to such option by the copyright holder.
   10.40 + *
   10.41 + * Contributor(s): Ilia Gromov
   10.42 + */
   10.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   10.44 +
   10.45 +import org.netbeans.api.options.OptionsDisplayer;
   10.46 +import org.netbeans.spi.editor.hints.ChangeInfo;
   10.47 +import org.netbeans.spi.editor.hints.EnhancedFix;
   10.48 +import org.openide.util.NbBundle;
   10.49 +
   10.50 +class ConfigureHintsFix implements EnhancedFix {
   10.51 +    
   10.52 +    private final ModernizeErrorInfo error;
   10.53 +    private final String text;
   10.54 +
   10.55 +    ConfigureHintsFix(ModernizeErrorInfo error) {
   10.56 +        this.error = error;
   10.57 +        String id = error.getId();
   10.58 +        this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N
   10.59 +    } 
   10.60 +
   10.61 +    @Override
   10.62 +    public String getText() {
   10.63 +        return NbBundle.getMessage(ModernizeErrorProvider.class, "DisableHint", text); // NOI18N
   10.64 +    }
   10.65 +
   10.66 +    @Override
   10.67 +    public ChangeInfo implement() throws Exception {
   10.68 +        String provider = ModernizeErrorProvider.NAME;
   10.69 +        String name = error.getId();
   10.70 +        OptionsDisplayer.getDefault().open("Editor/Hints/text/x-cnd+sourcefile/" + provider + "/" + name); // NOI18N
   10.71 +        return null;
   10.72 +    }
   10.73 +
   10.74 +    @Override
   10.75 +    public CharSequence getSortText() {
   10.76 +        //Hint opening options dialog should always be the lastest in offered list
   10.77 +        return Integer.toString(Integer.MAX_VALUE);
   10.78 +    }
   10.79 +
   10.80 +    public ModernizeErrorInfo getError() {
   10.81 +        return error;
   10.82 +    }
   10.83 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/DiagnosticsTool.java	Tue May 30 15:29:39 2017 +0300
    11.3 @@ -0,0 +1,307 @@
    11.4 +/*
    11.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    11.6 + *
    11.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    11.8 + *
    11.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   11.10 + * Other names may be trademarks of their respective owners.
   11.11 + *
   11.12 + * The contents of this file are subject to the terms of either the GNU
   11.13 + * General Public License Version 2 only ("GPL") or the Common
   11.14 + * Development and Distribution License("CDDL") (collectively, the
   11.15 + * "License"). You may not use this file except in compliance with the
   11.16 + * License. You can obtain a copy of the License at
   11.17 + * http://www.netbeans.org/cddl-gplv2.html
   11.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   11.19 + * specific language governing permissions and limitations under the
   11.20 + * License.  When distributing the software, include this License Header
   11.21 + * Notice in each file and include the License file at
   11.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   11.23 + * particular file as subject to the "Classpath" exception as provided
   11.24 + * by Oracle in the GPL Version 2 section of the License file that
   11.25 + * accompanied this code. If applicable, add the following below the
   11.26 + * License Header, with the fields enclosed by brackets [] replaced by
   11.27 + * your own identifying information:
   11.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   11.29 + *
   11.30 + * If you wish your version of this file to be governed by only the CDDL
   11.31 + * or only the GPL Version 2, indicate your decision by adding
   11.32 + * "[Contributor] elects to include this software in this distribution
   11.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   11.34 + * single choice of license, a recipient has the option to distribute
   11.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   11.36 + * to extend the choice of license to its licensees as provided above.
   11.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   11.38 + * Version 2 license, then the option applies only if the new code is
   11.39 + * made subject to such option by the copyright holder.
   11.40 + *
   11.41 + * Contributor(s): Ilia Gromov
   11.42 + */
   11.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   11.44 +
   11.45 +import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools;
   11.46 +import java.io.BufferedReader;
   11.47 +import java.io.File;
   11.48 +import java.io.FileReader;
   11.49 +import java.io.IOException;
   11.50 +import java.nio.file.Files;
   11.51 +import java.nio.file.Path;
   11.52 +import java.util.ArrayList;
   11.53 +import java.util.Collection;
   11.54 +import java.util.Collections;
   11.55 +import java.util.List;
   11.56 +import java.util.logging.Level;
   11.57 +import java.util.logging.Logger;
   11.58 +import org.netbeans.modules.cnd.api.model.CsmFile;
   11.59 +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
   11.60 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
   11.61 +import org.netbeans.modules.cnd.api.toolchain.AbstractCompiler;
   11.62 +import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCCompiler;
   11.63 +import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCompiler;
   11.64 +import org.netbeans.modules.cnd.api.toolchain.Tool;
   11.65 +import org.netbeans.modules.cnd.makeproject.api.MakeProject;
   11.66 +import org.netbeans.modules.cnd.makeproject.api.configurations.CCCCompilerConfiguration;
   11.67 +import org.netbeans.modules.cnd.makeproject.api.configurations.CCCompilerConfiguration;
   11.68 +import org.netbeans.modules.cnd.makeproject.api.configurations.CCompilerConfiguration;
   11.69 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
   11.70 +import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
   11.71 +import org.netbeans.modules.cnd.makeproject.api.support.MakeProjectOptionsFormat;
   11.72 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
   11.73 +import org.netbeans.modules.nativeexecution.api.HostInfo;
   11.74 +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
   11.75 +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
   11.76 +import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
   11.77 +import org.openide.filesystems.FileObject;
   11.78 +import org.openide.filesystems.FileUtil;
   11.79 +
   11.80 +/**
   11.81 + *
   11.82 + * @author Ilia Gromov
   11.83 + */
   11.84 +public class DiagnosticsTool {
   11.85 +
   11.86 +    public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N
   11.87 +    public static final String CACHE_ID = "TIDY-CACHE"; //NOI18N
   11.88 +
   11.89 +    public static final int STATUS_OK = 0;
   11.90 +    public static final int STATUS_IO_ERROR = -1;
   11.91 +
   11.92 +    public static List<CodeAudit> getAudits(String path, ExecutionEnvironment env, AuditPreferences preferences) {
   11.93 +        List<CodeAudit> res = new ArrayList<>();
   11.94 +
   11.95 +        ProcessUtils.ExitStatus status = ProcessUtils.execute(env, path, new String[]{"-checks=*", "-list-checks", "dummy", "--"}); // NOI18N
   11.96 +
   11.97 +        if (status.exitCode == 0) {
   11.98 +            String out = status.getOutputString();
   11.99 +            out = out.substring(status.getOutputString().indexOf('\n') + 1);
  11.100 +            String[] checks = out.split("\n"); // NOI18N
  11.101 +
  11.102 +            FileObject disabledChecksFolder = FileUtil.getConfigFile("Analysis/Clang-Tidy/Disabled_Default"); // NOI18N
  11.103 +
  11.104 +            List<String> disabledChecks = new ArrayList<>();
  11.105 +            for (FileObject fileObject : disabledChecksFolder.getChildren()) {
  11.106 +                disabledChecks.add(fileObject.getName());
  11.107 +            }
  11.108 +
  11.109 +            for (String check : checks) {
  11.110 +                check = check.trim();
  11.111 +                ModernizeCodeAudit myCodeAudit = new ModernizeCodeAudit(
  11.112 +                        check,
  11.113 +                        check,
  11.114 +                        check,
  11.115 +                        "warning", //NOI18N
  11.116 +                        !disabledChecks.contains(check),
  11.117 +                        preferences);
  11.118 +                res.add(myCodeAudit);
  11.119 +            }
  11.120 +        }
  11.121 +
  11.122 +        return res;
  11.123 +    }
  11.124 +
  11.125 +    private final ExecutionEnvironment execEnv;
  11.126 +    private final Item item;
  11.127 +    private final MakeProject project;
  11.128 +    private final String binaryPath;
  11.129 +
  11.130 +    private StringBuilder buf;
  11.131 +
  11.132 +    public DiagnosticsTool(ExecutionEnvironment execEnv, Item item, MakeProject project, String binaryPath) {
  11.133 +        this.execEnv = execEnv;
  11.134 +        this.item = item;
  11.135 +        this.project = project;
  11.136 +        this.binaryPath = binaryPath;
  11.137 +    }
  11.138 +
  11.139 +    /**
  11.140 +     * @return clang-tidy's exit code or negative code if some other problem has
  11.141 +     * occurred.
  11.142 +     */
  11.143 +    public int process(Collection<String> checks, CsmFile csmFile, boolean isStartFile) throws ConnectionManager.CancellationException, IOException {
  11.144 +        // TODO: can we split analyzer (Source -> Inspect) ant editor error providing?
  11.145 +
  11.146 +        final String directoryMacro = "xDIRx"; //NOI18N
  11.147 +
  11.148 +        File tmpDir = null;
  11.149 +        try {
  11.150 +            List<String> args = new ArrayList<String>();
  11.151 +
  11.152 +            HostInfo hostInfo = HostInfoUtils.getHostInfo(execEnv);
  11.153 +
  11.154 +            try {
  11.155 +                if (execEnv.isRemote()) {
  11.156 +                    tmpDir = Files.createTempDirectory(hostInfo.getTempDirFile().toPath(), "tidy").toFile();  //NOI18N
  11.157 +                } else {
  11.158 +                    tmpDir = Files.createTempDirectory("tidy").toFile();  //NOI18N
  11.159 +                }
  11.160 +            } catch (IOException ex) {
  11.161 +                return -1;
  11.162 +            }
  11.163 +
  11.164 +            Path tmpFile = Files.createTempFile(tmpDir.toPath(), null, null);
  11.165 +
  11.166 +            args.add("-header-filter=.*"); //NOI18N
  11.167 +            StringBuilder sb = new StringBuilder("-checks=");// NOI18N
  11.168 +            for (String check : checks) {
  11.169 +                sb.append(check);
  11.170 +                sb.append(","); // NOI18N
  11.171 +            }
  11.172 +            args.add(sb.toString().substring(0, sb.length() - 1));
  11.173 +
  11.174 +            args.add("-export-fixes=" + tmpFile); // NOI18N
  11.175 +            int directoryIdx = args.size() - 1;
  11.176 +
  11.177 +            Collection<? extends CsmFile> startFiles = Collections.EMPTY_LIST;
  11.178 +            args.add(csmFile.getFileObject().getPath());
  11.179 +
  11.180 +            args.add("--");  //NOI18N
  11.181 +            args.addAll(getAdditionalFlags(csmFile));
  11.182 +
  11.183 +            List<String> copy = new ArrayList<String>(args);
  11.184 +
  11.185 +            copy.set(directoryIdx, copy.get(directoryIdx).replace(directoryMacro, tmpDir.getAbsolutePath()));
  11.186 +
  11.187 +            // TODO: execute in the ${WORKING_DIR} ? Because we can have relative path includes (-Isrc/libs/abcd)
  11.188 +            ProcessUtils.ExitStatus executeStatus = ProcessUtils.executeInDir(tmpDir.getAbsolutePath(),
  11.189 +                    execEnv,
  11.190 +                    binaryPath,
  11.191 +                    copy.toArray(new String[copy.size()]));
  11.192 +
  11.193 +            if (executeStatus.exitCode != STATUS_OK) {
  11.194 +                LOG.log(Level.INFO, "clang-tidy exit code {0}: {1}", new Object[]{executeStatus.exitCode, arrayAsString(binaryPath, copy)});
  11.195 +                LOG.fine(executeStatus.getOutputString());
  11.196 +                LOG.fine(executeStatus.getErrorString());
  11.197 +                return executeStatus.exitCode;
  11.198 +            } else {
  11.199 +                LOG.log(Level.FINEST, "{0}", arrayAsString(binaryPath, copy));
  11.200 +                LOG.finest(executeStatus.getOutputString());
  11.201 +                LOG.finest(executeStatus.getErrorString());
  11.202 +            }
  11.203 +
  11.204 +            File[] listFiles = tmpDir.listFiles();
  11.205 +
  11.206 +            if (listFiles.length != 1) {
  11.207 +                return STATUS_IO_ERROR;
  11.208 +            }
  11.209 +
  11.210 +            File yamlFile = listFiles[0];
  11.211 +
  11.212 +            BufferedReader in = new BufferedReader(new FileReader(yamlFile));
  11.213 +            buf = new StringBuilder();
  11.214 +            while (true) {
  11.215 +                String s = in.readLine();
  11.216 +                if (s == null) {
  11.217 +                    break;
  11.218 +                }
  11.219 +                buf.append(s).append('\n'); //NOI18N
  11.220 +            }
  11.221 +
  11.222 +        } finally {
  11.223 +            try {
  11.224 +                tmpDir.delete();
  11.225 +            } catch (Exception x) {
  11.226 +
  11.227 +            }
  11.228 +        }
  11.229 +
  11.230 +        return STATUS_OK;
  11.231 +    }
  11.232 +
  11.233 +    private List<String> getAdditionalFlags(CsmFile csmFile) {
  11.234 +        List<String> all = new ArrayList<String>();
  11.235 +
  11.236 +        Tool tool = AnalyticsTools.compiler(item, project);
  11.237 +
  11.238 +        if (tool instanceof AbstractCompiler) {
  11.239 +            AbstractCompiler compiler = (AbstractCompiler) tool;
  11.240 +
  11.241 +            for (String systemIncludeDirectory : compiler.getSystemIncludeDirectories()) {
  11.242 +                all.add("-I" + systemIncludeDirectory); //NOI18N
  11.243 +            }
  11.244 +
  11.245 +            MakeConfiguration activeConfiguration = AnalyticsTools.getConfigurationDescriptor(csmFile, project).getActiveConfiguration();
  11.246 +
  11.247 +            String options = "";
  11.248 +//            // compileSingleUnmanage as reference
  11.249 +//            // don't use getAllOptions - we need not -w flag
  11.250 +            if (tool.getKind() == CCCompiler) {
  11.251 +                CCCompilerConfiguration ccc = activeConfiguration.getCCCompilerConfiguration();
  11.252 +                options += ccc.getPreprocessorOptions(compiler.getCompilerSet());
  11.253 +                options += ccc.getIncludeDirectoriesOptions(compiler.getCompilerSet());
  11.254 +//            options += getLibrariesFlags();
  11.255 +                options += compiler.getCppStandardOptions(ccc.getInheritedCppStandard());
  11.256 +                if (!options.contains("-std=")) { //NOI18N
  11.257 +                    switch (item.getLanguageFlavor()) {
  11.258 +                        case CPP98:
  11.259 +                            options += " -std=c++98"; //NOI18N
  11.260 +                            break;
  11.261 +                        case CPP11:
  11.262 +                            options += " -std=c++11"; //NOI18N
  11.263 +                            break;
  11.264 +                        case CPP14:
  11.265 +                            options += " -std=c++14"; //NOI18N
  11.266 +                            break;
  11.267 +                    }
  11.268 +                }
  11.269 +            } else if (tool.getKind() == CCompiler) {
  11.270 +                CCompilerConfiguration cc = activeConfiguration.getCCompilerConfiguration();
  11.271 +                options += cc.getPreprocessorOptions(compiler.getCompilerSet());
  11.272 +                options += cc.getIncludeDirectoriesOptions(compiler.getCompilerSet());
  11.273 +                options += compiler.getCStandardOptions(cc.getInheritedCStandard());
  11.274 +                if (!options.contains("-std=")) { //NOI18N
  11.275 +                    switch (item.getLanguageFlavor()) {
  11.276 +                        case C11:
  11.277 +                            options += " -std=c11"; //NOI18N
  11.278 +                            break;
  11.279 +                        case C89:
  11.280 +                            options += " -std=c89"; //NOI18N
  11.281 +                            break;
  11.282 +                        case C99:
  11.283 +                            options += " -std=c99"; //NOI18N
  11.284 +                            break;
  11.285 +                    }
  11.286 +                }
  11.287 +            }
  11.288 +
  11.289 +            List<String> optionsList = AnalyticsTools.scanCommandLine(MakeProjectOptionsFormat.reformatWhitespaces(options));
  11.290 +            all.addAll(optionsList);
  11.291 +        }
  11.292 +
  11.293 +        return all;
  11.294 +    }
  11.295 +
  11.296 +    public String getYamlAsString() {
  11.297 +        if (buf == null) {
  11.298 +            throw new IllegalStateException();
  11.299 +        }
  11.300 +        return buf.toString();
  11.301 +    }
  11.302 +
  11.303 +    private static String arrayAsString(String binary, List<String> list) {
  11.304 +        StringBuilder sb = new StringBuilder(binary).append(" "); //NOI18N
  11.305 +        for (String string : list) {
  11.306 +            sb.append(string).append(" "); //NOI18N
  11.307 +        }
  11.308 +        return sb.toString();
  11.309 +    }
  11.310 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java	Tue May 30 15:29:39 2017 +0300
    12.3 @@ -0,0 +1,214 @@
    12.4 +/*
    12.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    12.6 + *
    12.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    12.8 + *
    12.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   12.10 + * Other names may be trademarks of their respective owners.
   12.11 + *
   12.12 + * The contents of this file are subject to the terms of either the GNU
   12.13 + * General Public License Version 2 only ("GPL") or the Common
   12.14 + * Development and Distribution License("CDDL") (collectively, the
   12.15 + * "License"). You may not use this file except in compliance with the
   12.16 + * License. You can obtain a copy of the License at
   12.17 + * http://www.netbeans.org/cddl-gplv2.html
   12.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   12.19 + * specific language governing permissions and limitations under the
   12.20 + * License.  When distributing the software, include this License Header
   12.21 + * Notice in each file and include the License file at
   12.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   12.23 + * particular file as subject to the "Classpath" exception as provided
   12.24 + * by Oracle in the GPL Version 2 section of the License file that
   12.25 + * accompanied this code. If applicable, add the following below the
   12.26 + * License Header, with the fields enclosed by brackets [] replaced by
   12.27 + * your own identifying information:
   12.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   12.29 + *
   12.30 + * If you wish your version of this file to be governed by only the CDDL
   12.31 + * or only the GPL Version 2, indicate your decision by adding
   12.32 + * "[Contributor] elects to include this software in this distribution
   12.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   12.34 + * single choice of license, a recipient has the option to distribute
   12.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   12.36 + * to extend the choice of license to its licensees as provided above.
   12.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   12.38 + * Version 2 license, then the option applies only if the new code is
   12.39 + * made subject to such option by the copyright holder.
   12.40 + *
   12.41 + * Contributor(s): Ilia Gromov
   12.42 + */
   12.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   12.44 +
   12.45 +import org.netbeans.modules.ide.analysis.modernize.options.ClangAnalyzerOptions;
   12.46 +import org.netbeans.modules.ide.analysis.modernize.resources.BundleUtilities;
   12.47 +import java.io.CharConversionException;
   12.48 +import java.io.File;
   12.49 +import java.util.ArrayList;
   12.50 +import java.util.Arrays;
   12.51 +import java.util.Collection;
   12.52 +import java.util.Collections;
   12.53 +import java.util.List;
   12.54 +import java.util.concurrent.atomic.AtomicBoolean;
   12.55 +import java.util.prefs.Preferences;
   12.56 +import org.netbeans.modules.analysis.spi.Analyzer;
   12.57 +import org.netbeans.modules.cnd.analysis.api.AbstractAnalyzer;
   12.58 +import org.netbeans.modules.cnd.analysis.api.AbstractHintsPanel;
   12.59 +import org.netbeans.modules.cnd.api.model.CsmFile;
   12.60 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
   12.61 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   12.62 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   12.63 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
   12.64 +import org.netbeans.modules.cnd.utils.CndPathUtilities;
   12.65 +import org.netbeans.spi.editor.hints.ErrorDescription;
   12.66 +import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
   12.67 +import org.netbeans.spi.editor.hints.LazyFixList;
   12.68 +import org.netbeans.spi.editor.hints.Severity;
   12.69 +import org.openide.filesystems.FileObject;
   12.70 +import org.openide.util.ImageUtilities;
   12.71 +import org.openide.util.NbBundle;
   12.72 +import org.openide.util.lookup.ServiceProvider;
   12.73 +import org.openide.xml.XMLUtil;
   12.74 +
   12.75 +public class ModernizeAnalyzerImpl extends AbstractAnalyzer {
   12.76 +
   12.77 +    private static final String PREFIX = "tidy-"; //NOI18N
   12.78 +
   12.79 +    private ModernizeAnalyzerImpl(Context ctx) {
   12.80 +        super(ctx);
   12.81 +    }
   12.82 +
   12.83 +    @Override
   12.84 +    public ModernizeErrorProvider getErrorProvider(Preferences preferences) {
   12.85 +        return ModernizeErrorProvider.getInstance();
   12.86 +    }
   12.87 +
   12.88 +    @Override
   12.89 +    protected boolean isCompileUnitBased() {
   12.90 +        return true;
   12.91 +    }
   12.92 +
   12.93 +    @Override
   12.94 +    protected Collection<? extends ErrorDescription> doRunImpl(final FileObject sr, final Context ctx, final CsmErrorProvider provider, final AtomicBoolean cancel) {
   12.95 +        final CsmFile csmFile = CsmUtilities.getCsmFile(sr, false, false);
   12.96 +        if (csmFile == null) {
   12.97 +            return Collections.<ErrorDescription>emptyList();
   12.98 +        }
   12.99 +        CsmErrorProvider.Request request = new RequestImpl(csmFile, ctx, cancel);
  12.100 +        final ArrayList<ErrorDescription> res = new ArrayList<ErrorDescription>();
  12.101 +        CsmErrorProvider.Response responce = new ResponseImpl(sr, res, cancel);
  12.102 +        provider.getErrors(request, responce);
  12.103 +        return res;
  12.104 +    }
  12.105 +
  12.106 +    protected static class ResponseImpl extends AbstractResponse {
  12.107 +
  12.108 +        public ResponseImpl(FileObject sr, ArrayList<ErrorDescription> res, AtomicBoolean cancel) {
  12.109 +            super(sr, res, cancel);
  12.110 +        }
  12.111 +
  12.112 +        @Override
  12.113 +        protected ErrorDescription addErrorImpl(CsmErrorInfo errorInfo, FileObject fo) {
  12.114 +            String messages[] = errorInfo.getMessage().split("\n"); //NOI18N
  12.115 +            if (messages.length > 0) {
  12.116 +                StringBuilder sb = new StringBuilder();
  12.117 +                if (errorInfo instanceof ModernizeErrorInfo) {
  12.118 +                    ModernizeErrorInfo mei = (ModernizeErrorInfo) errorInfo;
  12.119 +                    sb.append("<pre>"); //NOI18N
  12.120 +                    sb.append("["); //NOI18N
  12.121 +                    sb.append(mei.getId());
  12.122 +                    sb.append("]"); //NOI18N
  12.123 +                    sb.append("\n"); //NOI18N
  12.124 +                    List<YamlParser.Replacement> replacements = mei.getDiagnostics().getReplacements();
  12.125 +                    if (replacements.isEmpty()) {
  12.126 +                        sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), mei.getDiagnostics().getMessageFilePath())).append(" "); //NOI18N
  12.127 +                        sb.append(mei.getDiagnostics().getMessageFileOffset()).append("\n");
  12.128 +                    } else {
  12.129 +                        for (YamlParser.Replacement replacement : replacements) {
  12.130 +                            sb.append("\n"); //NOI18N
  12.131 +                            sb.append("Replacement: "); //NOI18N
  12.132 +                            sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), replacement.filePath)).append(" "); //NOI18N
  12.133 +                            sb.append(replacement.offset).append("-").append(replacement.offset + replacement.length).append("\n"); //NOI18N
  12.134 +                            String attributeValue = replacement.replacementText;
  12.135 +                            try {
  12.136 +                                attributeValue = XMLUtil.toAttributeValue(replacement.replacementText);
  12.137 +                            } catch (CharConversionException ex) {
  12.138 +                            }
  12.139 +                            sb.append(attributeValue).append("\n"); //NOI18N
  12.140 +                        }
  12.141 +                    }
  12.142 +                    sb.append(mei.getMessage());
  12.143 +                    sb.append("</pre>"); //NOI18N
  12.144 +
  12.145 +                    LazyFixList list = new LazyFixListImpl();
  12.146 +
  12.147 +                    return ErrorDescriptionFactory.createErrorDescription(PREFIX + mei.getId(), Severity.valueOf(mei.getSeverity().toString().toUpperCase()),
  12.148 +                            messages[0], sb.toString(), list, fo, errorInfo.getStartOffset(), errorInfo.getStartOffset());
  12.149 +                }
  12.150 +            }
  12.151 +            return null;
  12.152 +        }
  12.153 +    }
  12.154 +
  12.155 +    @ServiceProvider(service = AnalyzerFactory.class)
  12.156 +    public static final class AnalyzerFactoryImpl extends AnalyzerFactory {
  12.157 +
  12.158 +        public AnalyzerFactoryImpl() {
  12.159 +            super(ModernizeErrorProvider.NAME,
  12.160 +                    NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"), //NOI18N
  12.161 +                    ImageUtilities.loadImage("ide/analysis/modernize/impl/bugs.png")); //NOI18N
  12.162 +        }
  12.163 +
  12.164 +        @Override
  12.165 +        public Iterable<? extends WarningDescription> getWarnings() {
  12.166 +            List<WarningDescription> result = new ArrayList<WarningDescription>();
  12.167 +            final ModernizeErrorProvider provider = ModernizeErrorProvider.getInstance();
  12.168 +            for (CodeAudit audit : provider.getAudits()) {
  12.169 +                result.add(WarningDescription.create(PREFIX + audit.getID(), audit.getName(), ModernizeErrorProvider.NAME, provider.getDisplayName()));
  12.170 +            }
  12.171 +            String[] fatals = BundleUtilities.getFatalErrors();
  12.172 +            for (String id : fatals) { //NOI18N
  12.173 +                if (!id.isEmpty()) {
  12.174 +                    result.add(WarningDescription.create(PREFIX + id, BundleUtilities.getDescription(id), ModernizeErrorProvider.NAME, provider.getDisplayName()));
  12.175 +                }
  12.176 +            }
  12.177 +            return result;
  12.178 +        }
  12.179 +
  12.180 +        @Override
  12.181 +        public CustomizerProvider<Void, AbstractHintsPanel> getCustomizerProvider() {
  12.182 +            return new CustomizerProvider<Void, AbstractHintsPanel>() {
  12.183 +
  12.184 +                @Override
  12.185 +                public Void initialize() {
  12.186 +                    return null;
  12.187 +                }
  12.188 +
  12.189 +                @Override
  12.190 +                public AbstractHintsPanel createComponent(CustomizerContext<Void, AbstractHintsPanel> context) {
  12.191 +                    return AbstractAnalyzer.createComponent(ModernizeErrorProvider.getInstance());
  12.192 +                }
  12.193 +            };
  12.194 +        }
  12.195 +
  12.196 +        @Override
  12.197 +        public Collection<? extends MissingPlugin> requiredPlugins(Context context) {
  12.198 +//            ExecutionEnvironment env = detectEnvironment(context);
  12.199 +//            if (env == null) {
  12.200 +//                env = ExecutionEnvironmentFactory.getLocal();
  12.201 +//            }
  12.202 +            String installedTool = ClangAnalyzerOptions.getClangAnalyzerPath();
  12.203 +            if (installedTool == null || !new File(installedTool).exists()) {
  12.204 +                String codeBase = ClangAnalyzerOptions.getMissingModuleName();
  12.205 +                if (codeBase != null) {
  12.206 +                    return Arrays.asList(new MissingPlugin(codeBase, NbBundle.getMessage(ModernizeAnalyzerImpl.class, "Modernize_NAME"))); //NOI18N
  12.207 +                }
  12.208 +            }
  12.209 +            return Collections.emptyList();
  12.210 +        }
  12.211 +
  12.212 +        @Override
  12.213 +        public Analyzer createAnalyzer(Context context) {
  12.214 +            return new ModernizeAnalyzerImpl(context);
  12.215 +        }
  12.216 +    }
  12.217 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeCodeAudit.java	Tue May 30 15:29:39 2017 +0300
    13.3 @@ -0,0 +1,120 @@
    13.4 +/*
    13.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    13.6 + *
    13.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    13.8 + *
    13.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   13.10 + * Other names may be trademarks of their respective owners.
   13.11 + *
   13.12 + * The contents of this file are subject to the terms of either the GNU
   13.13 + * General Public License Version 2 only ("GPL") or the Common
   13.14 + * Development and Distribution License("CDDL") (collectively, the
   13.15 + * "License"). You may not use this file except in compliance with the
   13.16 + * License. You can obtain a copy of the License at
   13.17 + * http://www.netbeans.org/cddl-gplv2.html
   13.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   13.19 + * specific language governing permissions and limitations under the
   13.20 + * License.  When distributing the software, include this License Header
   13.21 + * Notice in each file and include the License file at
   13.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   13.23 + * particular file as subject to the "Classpath" exception as provided
   13.24 + * by Oracle in the GPL Version 2 section of the License file that
   13.25 + * accompanied this code. If applicable, add the following below the
   13.26 + * License Header, with the fields enclosed by brackets [] replaced by
   13.27 + * your own identifying information:
   13.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   13.29 + *
   13.30 + * If you wish your version of this file to be governed by only the CDDL
   13.31 + * or only the GPL Version 2, indicate your decision by adding
   13.32 + * "[Contributor] elects to include this software in this distribution
   13.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   13.34 + * single choice of license, a recipient has the option to distribute
   13.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   13.36 + * to extend the choice of license to its licensees as provided above.
   13.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   13.38 + * Version 2 license, then the option applies only if the new code is
   13.39 + * made subject to such option by the copyright holder.
   13.40 + *
   13.41 + * Contributor(s): Ilia Gromov
   13.42 + */
   13.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   13.44 +
   13.45 +import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit;
   13.46 +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
   13.47 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   13.48 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   13.49 +
   13.50 +final class ModernizeCodeAudit extends AbstractCodeAudit {
   13.51 +
   13.52 +    private final String id;
   13.53 +    private final String name;
   13.54 +    private final String description;
   13.55 +    private final String defaultSeverity;
   13.56 +    private final boolean defaultEnabled;
   13.57 +    private final AuditPreferences myPreferences;
   13.58 +
   13.59 +    public ModernizeCodeAudit(String id, String name, String description, String defaultSeverity, boolean defaultEnabled, AuditPreferences myPreferences) {
   13.60 +        super(id, name, description, defaultSeverity, defaultEnabled, myPreferences);
   13.61 +        this.id = id;
   13.62 +        this.name = name;
   13.63 +        this.description = description;
   13.64 +        this.defaultSeverity = defaultSeverity;
   13.65 +        this.defaultEnabled = defaultEnabled;
   13.66 +        this.myPreferences = myPreferences;
   13.67 +    }
   13.68 +
   13.69 +    @Override
   13.70 +    public String getID() {
   13.71 +        return id;
   13.72 +    }
   13.73 +
   13.74 +    @Override
   13.75 +    public String getName() {
   13.76 +        return name;
   13.77 +    }
   13.78 +
   13.79 +    @Override
   13.80 +    public String getDescription() {
   13.81 +        return description;
   13.82 +    }
   13.83 +
   13.84 +    public static CsmErrorInfo.Severity toSeverity(String severity) {
   13.85 +        if ("error".equals(severity)) { // NOI18N
   13.86 +            return CsmErrorInfo.Severity.ERROR;
   13.87 +        } else if ("warning".equals(severity)) { // NOI18N
   13.88 +            return CsmErrorInfo.Severity.WARNING;
   13.89 +        } else {
   13.90 +            return CsmErrorInfo.Severity.HINT;
   13.91 +        }
   13.92 +    }
   13.93 +
   13.94 +    @Override
   13.95 +    public String getKind() {
   13.96 +        return "inspection"; //NOI18N
   13.97 +    }
   13.98 +
   13.99 +    @Override
  13.100 +    public AuditPreferences getPreferences() {
  13.101 +        return myPreferences;
  13.102 +    }
  13.103 +
  13.104 +    @Override
  13.105 +    public boolean getDefaultEnabled() {
  13.106 +        return defaultEnabled;
  13.107 +    }
  13.108 +
  13.109 +    @Override
  13.110 +    public String getDefaultSeverity() {
  13.111 +        return defaultSeverity;
  13.112 +    }
  13.113 +
  13.114 +    @Override
  13.115 +    public boolean isSupportedEvent(CsmErrorProvider.EditorEvent kind) {
  13.116 +        return true;
  13.117 +    }
  13.118 +
  13.119 +    @Override
  13.120 +    public void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
  13.121 +        throw new UnsupportedOperationException("Not supported yet."); //NOI18N
  13.122 +    }
  13.123 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorInfo.java	Tue May 30 15:29:39 2017 +0300
    14.3 @@ -0,0 +1,141 @@
    14.4 +/*
    14.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    14.6 + *
    14.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    14.8 + *
    14.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   14.10 + * Other names may be trademarks of their respective owners.
   14.11 + *
   14.12 + * The contents of this file are subject to the terms of either the GNU
   14.13 + * General Public License Version 2 only ("GPL") or the Common
   14.14 + * Development and Distribution License("CDDL") (collectively, the
   14.15 + * "License"). You may not use this file except in compliance with the
   14.16 + * License. You can obtain a copy of the License at
   14.17 + * http://www.netbeans.org/cddl-gplv2.html
   14.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   14.19 + * specific language governing permissions and limitations under the
   14.20 + * License.  When distributing the software, include this License Header
   14.21 + * Notice in each file and include the License file at
   14.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   14.23 + * particular file as subject to the "Classpath" exception as provided
   14.24 + * by Oracle in the GPL Version 2 section of the License file that
   14.25 + * accompanied this code. If applicable, add the following below the
   14.26 + * License Header, with the fields enclosed by brackets [] replaced by
   14.27 + * your own identifying information:
   14.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   14.29 + *
   14.30 + * If you wish your version of this file to be governed by only the CDDL
   14.31 + * or only the GPL Version 2, indicate your decision by adding
   14.32 + * "[Contributor] elects to include this software in this distribution
   14.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   14.34 + * single choice of license, a recipient has the option to distribute
   14.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   14.36 + * to extend the choice of license to its licensees as provided above.
   14.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   14.38 + * Version 2 license, then the option applies only if the new code is
   14.39 + * made subject to such option by the copyright holder.
   14.40 + *
   14.41 + * Contributor(s): Ilia Gromov
   14.42 + */
   14.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   14.44 +
   14.45 +import java.util.Objects;
   14.46 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   14.47 +import org.netbeans.modules.cnd.api.project.NativeProject;
   14.48 +import org.openide.util.Lookup;
   14.49 +
   14.50 +public class ModernizeErrorInfo implements CsmErrorInfo, ModernizeErrorProvider.ErrorInfoWithId {
   14.51 +
   14.52 +    private final YamlParser.Diagnostics diag;
   14.53 +    private final String message;
   14.54 +    private final NativeProject project;
   14.55 +
   14.56 +    private final int startOffset;
   14.57 +    private final int endOffset;
   14.58 +
   14.59 +    public ModernizeErrorInfo(YamlParser.Diagnostics diag, String message, Lookup.Provider project) {
   14.60 +        this.diag = diag;
   14.61 +        this.message = message;
   14.62 +        this.project = project.getLookup().lookup(NativeProject.class);
   14.63 +
   14.64 +        if (diag.getReplacements().isEmpty()) {
   14.65 +            startOffset = diag.getMessageFileOffset();
   14.66 +            endOffset = diag.getMessageFileOffset();
   14.67 +        } else {
   14.68 +            YamlParser.Replacement first = diag.getReplacements().get(0);
   14.69 +            startOffset = first.offset;
   14.70 +            endOffset = first.offset + first.length;
   14.71 +        }
   14.72 +    }
   14.73 +
   14.74 +    public NativeProject getProject() {
   14.75 +        return project;
   14.76 +    }
   14.77 +
   14.78 +    @Override
   14.79 +    public String getMessage() {
   14.80 +        return message;
   14.81 +    }
   14.82 +
   14.83 +    @Override
   14.84 +    public Severity getSeverity() {
   14.85 +        return Severity.valueOf(diag.getLevel().toString().toUpperCase());
   14.86 +    }
   14.87 +
   14.88 +    @Override
   14.89 +    public int getStartOffset() {
   14.90 +        return startOffset;
   14.91 +    }
   14.92 +
   14.93 +    @Override
   14.94 +    public int getEndOffset() {
   14.95 +        return endOffset;
   14.96 +    }
   14.97 +
   14.98 +    public YamlParser.Diagnostics getDiagnostics() {
   14.99 +        return diag;
  14.100 +    }
  14.101 +
  14.102 +    @Override
  14.103 +    public String getId() {
  14.104 +        return diag.getCheckName();
  14.105 +    }
  14.106 +
  14.107 +    public boolean isNeedConfigureHint() {
  14.108 +        return true;
  14.109 +    }
  14.110 +
  14.111 +    @Override
  14.112 +    public int hashCode() {
  14.113 +        int hash = 3;
  14.114 +        hash = 19 * hash + this.diag.getCheckName().hashCode();
  14.115 +        hash = 19 * hash + this.startOffset;
  14.116 +        hash = 19 * hash + this.endOffset;
  14.117 +        return hash;
  14.118 +    }
  14.119 +
  14.120 +    @Override
  14.121 +    public boolean equals(Object obj) {
  14.122 +        if (this == obj) {
  14.123 +            return true;
  14.124 +        }
  14.125 +        if (obj == null) {
  14.126 +            return false;
  14.127 +        }
  14.128 +        if (getClass() != obj.getClass()) {
  14.129 +            return false;
  14.130 +        }
  14.131 +        final ModernizeErrorInfo other = (ModernizeErrorInfo) obj;
  14.132 +        if (this.startOffset != other.startOffset) {
  14.133 +            return false;
  14.134 +        }
  14.135 +        if (this.endOffset != other.endOffset) {
  14.136 +            return false;
  14.137 +        }
  14.138 +        if (!(this.diag.getCheckName().equals(other.diag.getCheckName()))) {
  14.139 +            return false;
  14.140 +        }
  14.141 +        return true;
  14.142 +    }
  14.143 +
  14.144 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorProvider.java	Tue May 30 15:29:39 2017 +0300
    15.3 @@ -0,0 +1,422 @@
    15.4 +/*
    15.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    15.6 + *
    15.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    15.8 + *
    15.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   15.10 + * Other names may be trademarks of their respective owners.
   15.11 + *
   15.12 + * The contents of this file are subject to the terms of either the GNU
   15.13 + * General Public License Version 2 only ("GPL") or the Common
   15.14 + * Development and Distribution License("CDDL") (collectively, the
   15.15 + * "License"). You may not use this file except in compliance with the
   15.16 + * License. You can obtain a copy of the License at
   15.17 + * http://www.netbeans.org/cddl-gplv2.html
   15.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   15.19 + * specific language governing permissions and limitations under the
   15.20 + * License.  When distributing the software, include this License Header
   15.21 + * Notice in each file and include the License file at
   15.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   15.23 + * particular file as subject to the "Classpath" exception as provided
   15.24 + * by Oracle in the GPL Version 2 section of the License file that
   15.25 + * accompanied this code. If applicable, add the following below the
   15.26 + * License Header, with the fields enclosed by brackets [] replaced by
   15.27 + * your own identifying information:
   15.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   15.29 + *
   15.30 + * If you wish your version of this file to be governed by only the CDDL
   15.31 + * or only the GPL Version 2, indicate your decision by adding
   15.32 + * "[Contributor] elects to include this software in this distribution
   15.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   15.34 + * single choice of license, a recipient has the option to distribute
   15.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   15.36 + * to extend the choice of license to its licensees as provided above.
   15.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   15.38 + * Version 2 license, then the option applies only if the new code is
   15.39 + * made subject to such option by the copyright holder.
   15.40 + *
   15.41 + * Contributor(s): Ilia Gromov
   15.42 + */
   15.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   15.44 +
   15.45 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl.ResponseImpl;
   15.46 +import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser.Replacement;
   15.47 +import org.netbeans.modules.ide.analysis.modernize.options.AnalyzerPreferences;
   15.48 +import org.netbeans.modules.ide.analysis.modernize.options.ClangAnalyzerOptions;
   15.49 +import static org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools.fatalError;
   15.50 +import static org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools.findItem;
   15.51 +import java.io.File;
   15.52 +import java.io.IOException;
   15.53 +import java.util.ArrayList;
   15.54 +import java.util.Collection;
   15.55 +import java.util.Collections;
   15.56 +import java.util.List;
   15.57 +import java.util.logging.Level;
   15.58 +import java.util.logging.Logger;
   15.59 +import java.util.prefs.Preferences;
   15.60 +import javax.swing.JComponent;
   15.61 +import javax.swing.JLabel;
   15.62 +import org.netbeans.modules.cnd.analysis.api.AbstractCustomizerProvider;
   15.63 +import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse;
   15.64 +import org.netbeans.modules.cnd.api.model.CsmFile;
   15.65 +import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit;
   15.66 +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
   15.67 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
   15.68 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditFactory;
   15.69 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditProvider;
   15.70 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   15.71 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo.Severity;
   15.72 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfoHintProvider;
   15.73 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   15.74 +import org.netbeans.modules.cnd.api.project.NativeFileItem.Language;
   15.75 +import org.netbeans.modules.cnd.api.project.NativeProject;
   15.76 +import org.netbeans.modules.cnd.api.remote.RemoteProject;
   15.77 +import org.netbeans.modules.cnd.makeproject.api.MakeProject;
   15.78 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
   15.79 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
   15.80 +import org.netbeans.modules.cnd.utils.MIMENames;
   15.81 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
   15.82 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
   15.83 +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
   15.84 +import org.netbeans.spi.editor.hints.Fix;
   15.85 +import org.openide.awt.Actions;
   15.86 +import org.openide.filesystems.FileObject;
   15.87 +import org.openide.filesystems.FileUtil;
   15.88 +import org.openide.util.Exceptions;
   15.89 +import org.openide.util.Lookup;
   15.90 +import org.openide.util.NbBundle;
   15.91 +import org.openide.util.lookup.ServiceProvider;
   15.92 +import org.openide.util.lookup.ServiceProviders;
   15.93 +
   15.94 +@ServiceProviders({
   15.95 +    @ServiceProvider(service = CsmErrorProvider.class, position = 2100)
   15.96 +    ,
   15.97 +    @ServiceProvider(service = CodeAuditProvider.class, position = 2100)
   15.98 +})
   15.99 +public final class ModernizeErrorProvider extends CsmErrorProvider implements CodeAuditProvider, AbstractCustomizerProvider {
  15.100 +
  15.101 +    public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N
  15.102 +    private Collection<CodeAudit> audits;
  15.103 +    public static final String NAME = "Modernize"; //NOI18N
  15.104 +
  15.105 +    public static ModernizeErrorProvider getInstance() {
  15.106 +        for (CsmErrorProvider provider : Lookup.getDefault().lookupAll(CsmErrorProvider.class)) {
  15.107 +            if (NAME.equals(provider.getName()) && provider instanceof ModernizeErrorProvider) {
  15.108 +                return (ModernizeErrorProvider) provider;
  15.109 +            }
  15.110 +        }
  15.111 +        return null;
  15.112 +    }
  15.113 +
  15.114 +    @Override
  15.115 +    protected boolean validate(Request request) {
  15.116 +        CsmFile file = request.getFile();
  15.117 +        return file != null;
  15.118 +    }
  15.119 +
  15.120 +    @Override
  15.121 +    public boolean hasHintControlPanel() {
  15.122 +        return true;
  15.123 +    }
  15.124 +
  15.125 +    @Override
  15.126 +    public String getName() {
  15.127 +        return NAME;
  15.128 +    }
  15.129 +
  15.130 +    @Override
  15.131 +    public String getDisplayName() {
  15.132 +        return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"); //NOI18N
  15.133 +    }
  15.134 +
  15.135 +    @Override
  15.136 +    public String getDescription() {
  15.137 +        return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_DESCRIPTION"); //NOI18N
  15.138 +    }
  15.139 +
  15.140 +    @Override
  15.141 +    public String getMimeType() {
  15.142 +        return MIMENames.SOURCES_MIME_TYPE;
  15.143 +    }
  15.144 +
  15.145 +    @Override
  15.146 +    public boolean isSupportedEvent(EditorEvent kind) {
  15.147 +        return kind == EditorEvent.FileBased;
  15.148 +    }
  15.149 +
  15.150 +    @Override
  15.151 +    protected void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
  15.152 +        CsmFile file = request.getFile();
  15.153 +        if (file != null) {
  15.154 +            if (request.isCancelled()) {
  15.155 +                return;
  15.156 +            }
  15.157 +            Object platformProject = file.getProject().getPlatformProject();
  15.158 +            if (platformProject instanceof NativeProject) {
  15.159 +                Lookup.Provider project = ((NativeProject) platformProject).getProject();
  15.160 +                if (project != null) {
  15.161 +                    if (request.isCancelled()) {
  15.162 +                        return;
  15.163 +                    }
  15.164 +                    Thread currentThread = Thread.currentThread();
  15.165 +                    currentThread.setName("Provider " + getName() + " prosess " + file.getAbsolutePath()); // NOI18N
  15.166 +                    RemoteProject info = project.getLookup().lookup(RemoteProject.class);
  15.167 +                    if (info != null) {
  15.168 +                        ExecutionEnvironment execEnv = info.getDevelopmentHost();
  15.169 +                        if (execEnv != null) {
  15.170 +                            if (request.isCancelled()) {
  15.171 +                                return;
  15.172 +                            }
  15.173 +                            if (ConnectionManager.getInstance().isConnectedTo(execEnv)) {
  15.174 +                                Item item = findItem(file, project);
  15.175 +                                if (item != null) {
  15.176 +                                    if (request.isCancelled()) {
  15.177 +                                        return;
  15.178 +                                    }
  15.179 +                                    // Temporarily analyzing even excluded items
  15.180 +                                    if (/* !item.isExcluded() &&  */(item.getLanguage() == Language.C || item.getLanguage() == Language.CPP || item.getLanguage() == Language.C_HEADER)) {
  15.181 +                                        analyze(execEnv, item, project, request, response);
  15.182 +                                    }
  15.183 +                                }
  15.184 +                            }
  15.185 +                        }
  15.186 +                    }
  15.187 +                }
  15.188 +            }
  15.189 +        }
  15.190 +    }
  15.191 +
  15.192 +    public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
  15.193 +        String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath();
  15.194 +        boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ResponseImpl;
  15.195 +        if (binaryPath == null) {
  15.196 +            Level level = isAnalyzer ? Level.INFO : Level.FINE;
  15.197 +            LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N
  15.198 +            return;
  15.199 +        }
  15.200 +
  15.201 +        if (isAnalyzer && isNewRun()) {
  15.202 +            AnalyzedFiles.getDefault().clear();
  15.203 +        }
  15.204 +
  15.205 +        DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath);
  15.206 +        try {
  15.207 +            CsmFile csmFile = request.getFile();
  15.208 +            Collection<String> checks = /*isAnalyzer ? Collections.singleton("*") : */ getEnabledChecks(); //NOI18N
  15.209 +
  15.210 +            Collection<CsmFile> tu = new ArrayList<CsmFile>();
  15.211 +            if (isAnalyzer) {
  15.212 +                tu.add(csmFile);
  15.213 +            } else {
  15.214 +                if (AnalyzedFiles.getDefault().isStartFile(csmFile)) {
  15.215 +                    tu.add(csmFile);
  15.216 +                } else {
  15.217 +                    tu.addAll(AnalyzedFiles.getDefault().getStartFiles(csmFile));
  15.218 +                }
  15.219 +            }
  15.220 +
  15.221 +            if (!isAnalyzer) {
  15.222 +                response = new ResponseMerger(response);
  15.223 +            }
  15.224 +
  15.225 +            for (CsmFile startFile : tu) {
  15.226 +                int exitCode = diagnosticsTool.process(checks, startFile, true);
  15.227 +                if (exitCode != DiagnosticsTool.STATUS_OK) {
  15.228 +                    String error = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error"); //NOI18N
  15.229 +                    String info = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error.info", "" + exitCode); //NOI18N
  15.230 +                    fatalError(AnalyzerResponse.AnalyzerSeverity.FileError, "fatal.analyze.error", error + "\n" + info, csmFile, response); //NOI18N
  15.231 +                    return;
  15.232 +                }
  15.233 +                List<YamlParser.Diagnostics> results = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString());
  15.234 +                postProcess(isAnalyzer, startFile, project, results, request, response);
  15.235 +            }
  15.236 +
  15.237 +            if (!isAnalyzer) {
  15.238 +                response.done();
  15.239 +            }
  15.240 +
  15.241 +        } catch (ConnectionManager.CancellationException ex) {
  15.242 +            Exceptions.printStackTrace(ex);
  15.243 +        } catch (IOException ex) {
  15.244 +            Exceptions.printStackTrace(ex);
  15.245 +        }
  15.246 +    }
  15.247 +
  15.248 +    private static CsmErrorProvider last;
  15.249 +
  15.250 +    private boolean isNewRun() {
  15.251 +        if (last == null || this != last) {
  15.252 +            last = this;
  15.253 +            return true;
  15.254 +        }
  15.255 +        return false;
  15.256 +    }
  15.257 +
  15.258 +    public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List<YamlParser.Diagnostics> results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
  15.259 +        CsmFile file = request.getFile();
  15.260 +        List<CsmFile> otherCsmFiles = new ArrayList<CsmFile>();
  15.261 +
  15.262 +        for (YamlParser.Diagnostics diag : results) {
  15.263 +            // TODO: don't add "Configure Hint" fix multiple times for one line
  15.264 +            FileObject fo = FileUtil.toFileObject(new File(diag.getMessageFilePath()));
  15.265 +            CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false);
  15.266 +
  15.267 +            // Composing a preview message. Showing a start file for compilation unit
  15.268 +            // in case we analysing a header file
  15.269 +            String message;
  15.270 +            if (startFile.equals(file) && csmFile.equals(file)) {
  15.271 +                message = String.format("[%s]: %s", diag.getCheckName(), diag.getMessage()); //NOI18N
  15.272 +            } else {
  15.273 +                message = String.format("[%s; %s]: %s", diag.getCheckName(), startFile.getName(), diag.getMessage()); //NOI18N
  15.274 +            }
  15.275 +
  15.276 +            ModernizeErrorInfo info = new ModernizeErrorInfo(diag, message, project);  //NOI18N
  15.277 +
  15.278 +            if (isAnalyzer) {
  15.279 +                // Add found errors for all files (can be other files from compileUnit)
  15.280 +                ((ResponseImpl) response).addError(AnalyzerResponse.AnalyzerSeverity.DetectedError, null, fo, info);
  15.281 +
  15.282 +                if (!csmFile.equals(file)) {
  15.283 +                    // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... )
  15.284 +                    otherCsmFiles.add(csmFile);
  15.285 +                }
  15.286 +            } else if (fo.equals(file.getFileObject())) {
  15.287 +                // Add found errors only for file displayed in Editor
  15.288 +                response.addError(info);
  15.289 +            }
  15.290 +        }
  15.291 +
  15.292 +        if (isAnalyzer /* and not empty? */) {
  15.293 +            AnalyzedFiles.getDefault().cacheHierarchy(file, otherCsmFiles);
  15.294 +        }
  15.295 +    }
  15.296 +
  15.297 +    @ServiceProvider(path = CodeAuditFactory.REGISTRATION_PATH + ModernizeErrorProvider.NAME, service = CodeAuditFactory.class, position = 4000)
  15.298 +    public static final class Factory implements CodeAuditFactory {
  15.299 +
  15.300 +        @Override
  15.301 +        public AbstractCodeAudit create(AuditPreferences preferences) {
  15.302 +            String id = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderName");  // NOI18N
  15.303 +            String description = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderDescription");  // NOI18N
  15.304 +            return new ModernizeCodeAudit(id, id, description, "error", false, preferences);  // NOI18N
  15.305 +        }
  15.306 +    }
  15.307 +
  15.308 +    private String oldPath;
  15.309 +
  15.310 +    @Override
  15.311 +    public synchronized Collection<CodeAudit> getAudits() {
  15.312 +        String path = ClangAnalyzerOptions.getClangAnalyzerPath();
  15.313 +
  15.314 +        if (path == null) {
  15.315 +            return Collections.emptyList();
  15.316 +        }
  15.317 +
  15.318 +        if (oldPath == null) {
  15.319 +            oldPath = path;
  15.320 +        }
  15.321 +
  15.322 +        if (audits == null || !oldPath.equals(path)) {
  15.323 +            List<CodeAudit> res = DiagnosticsTool.getAudits(path, ExecutionEnvironmentFactory.getLocal(), AnalyzerPreferences.getAuditPreferences());
  15.324 +
  15.325 +            audits = res;
  15.326 +            oldPath = path;
  15.327 +        }
  15.328 +        return audits;
  15.329 +    }
  15.330 +
  15.331 +    public Collection<String> getEnabledChecks() {
  15.332 +        Collection<CodeAudit> auditList = getAudits();
  15.333 +        List<String> enabled = new ArrayList<String>();
  15.334 +        for (CodeAudit codeAudit : auditList) {
  15.335 +            if (codeAudit.isEnabled()) {
  15.336 +                enabled.add(codeAudit.getID());
  15.337 +            }
  15.338 +        }
  15.339 +        return enabled.size() == auditList.size() ? Collections.singleton("*") : enabled; //NOI18N
  15.340 +    }
  15.341 +
  15.342 +    @Override
  15.343 +    public AuditPreferences getPreferences() {
  15.344 +        return AnalyzerPreferences.getAuditPreferences();
  15.345 +    }
  15.346 +
  15.347 +    @Override
  15.348 +    public JComponent createComponent(Preferences context) {
  15.349 +        return new JLabel();
  15.350 +    }
  15.351 +
  15.352 +    public static interface ErrorInfoWithId {
  15.353 +
  15.354 +        String getId();
  15.355 +    }
  15.356 +
  15.357 +    public static final class FatalErrorInfo implements CsmErrorInfo, ErrorInfoWithId {
  15.358 +
  15.359 +        private final String id;
  15.360 +        private final String message;
  15.361 +
  15.362 +        public FatalErrorInfo(String id, String message) {
  15.363 +            this.id = id;
  15.364 +            this.message = message;
  15.365 +        }
  15.366 +
  15.367 +        @Override
  15.368 +        public String getMessage() {
  15.369 +            return message;
  15.370 +        }
  15.371 +
  15.372 +        @Override
  15.373 +        public Severity getSeverity() {
  15.374 +            return Severity.WARNING;
  15.375 +        }
  15.376 +
  15.377 +        @Override
  15.378 +        public int getStartOffset() {
  15.379 +            return 0;
  15.380 +        }
  15.381 +
  15.382 +        @Override
  15.383 +        public int getEndOffset() {
  15.384 +            return 1;
  15.385 +        }
  15.386 +
  15.387 +        @Override
  15.388 +        public String getId() {
  15.389 +            return id;
  15.390 +        }
  15.391 +    }
  15.392 +
  15.393 +    @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 9100)
  15.394 +    public final static class ModerinzeHintProvider extends CsmErrorInfoHintProvider {
  15.395 +
  15.396 +        @Override
  15.397 +        protected List<Fix> doGetFixes(CsmErrorInfo info, List<Fix> alreadyFound) {
  15.398 +            if (info instanceof ModernizeErrorInfo) {
  15.399 +                alreadyFound.add(new ConfigureHintsFix((ModernizeErrorInfo) info));
  15.400 +            }
  15.401 +            return alreadyFound;
  15.402 +        }
  15.403 +    }
  15.404 +
  15.405 +    @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 1600)
  15.406 +    public static final class ModernizeFixProvider extends CsmErrorInfoHintProvider {
  15.407 +
  15.408 +        @Override
  15.409 +        protected List<Fix> doGetFixes(CsmErrorInfo info, List<Fix> alreadyFound) {
  15.410 +            alreadyFound.addAll(createFixes(info));
  15.411 +            return alreadyFound;
  15.412 +        }
  15.413 +    }
  15.414 +
  15.415 +    private static List<? extends Fix> createFixes(CsmErrorInfo info) {
  15.416 +        if (info instanceof ModernizeErrorInfo) {
  15.417 +            ModernizeErrorInfo mei = (ModernizeErrorInfo) info;
  15.418 +            List<Replacement> replacements = mei.getDiagnostics().getReplacements();
  15.419 +            if (!replacements.isEmpty()) {
  15.420 +                return Collections.singletonList(new ModernizeFix(replacements, mei.getId()));
  15.421 +            }
  15.422 +        }
  15.423 +        return Collections.EMPTY_LIST;
  15.424 +    }
  15.425 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeFix.java	Tue May 30 15:29:39 2017 +0300
    16.3 @@ -0,0 +1,133 @@
    16.4 +/*
    16.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    16.6 + *
    16.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    16.8 + *
    16.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   16.10 + * Other names may be trademarks of their respective owners.
   16.11 + *
   16.12 + * The contents of this file are subject to the terms of either the GNU
   16.13 + * General Public License Version 2 only ("GPL") or the Common
   16.14 + * Development and Distribution License("CDDL") (collectively, the
   16.15 + * "License"). You may not use this file except in compliance with the
   16.16 + * License. You can obtain a copy of the License at
   16.17 + * http://www.netbeans.org/cddl-gplv2.html
   16.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   16.19 + * specific language governing permissions and limitations under the
   16.20 + * License.  When distributing the software, include this License Header
   16.21 + * Notice in each file and include the License file at
   16.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   16.23 + * particular file as subject to the "Classpath" exception as provided
   16.24 + * by Oracle in the GPL Version 2 section of the License file that
   16.25 + * accompanied this code. If applicable, add the following below the
   16.26 + * License Header, with the fields enclosed by brackets [] replaced by
   16.27 + * your own identifying information:
   16.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   16.29 + *
   16.30 + * If you wish your version of this file to be governed by only the CDDL
   16.31 + * or only the GPL Version 2, indicate your decision by adding
   16.32 + * "[Contributor] elects to include this software in this distribution
   16.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   16.34 + * single choice of license, a recipient has the option to distribute
   16.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   16.36 + * to extend the choice of license to its licensees as provided above.
   16.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   16.38 + * Version 2 license, then the option applies only if the new code is
   16.39 + * made subject to such option by the copyright holder.
   16.40 + *
   16.41 + * Contributor(s): Ilia Gromov
   16.42 + */
   16.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   16.44 +
   16.45 +import java.io.File;
   16.46 +import java.util.List;
   16.47 +import javax.swing.text.Document;
   16.48 +import javax.swing.text.Position;
   16.49 +import org.netbeans.editor.BaseDocument;
   16.50 +import org.netbeans.modules.cnd.api.model.CsmFile;
   16.51 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
   16.52 +import org.netbeans.spi.editor.hints.ChangeInfo;
   16.53 +import org.netbeans.spi.editor.hints.EnhancedFix;
   16.54 +import org.openide.filesystems.FileObject;
   16.55 +import org.openide.filesystems.FileUtil;
   16.56 +import org.openide.text.CloneableEditorSupport;
   16.57 +import org.openide.text.PositionRef;
   16.58 +
   16.59 +/**
   16.60 + *
   16.61 + * @author Ilia Gromov
   16.62 + */
   16.63 +public class ModernizeFix implements EnhancedFix {
   16.64 +    
   16.65 +    private final YamlParser.Replacement[] replacements;
   16.66 +    private final String text;
   16.67 +    private CloneableEditorSupport ces;
   16.68 +    private final PositionRef[] beg;
   16.69 +    private final PositionRef[] end;
   16.70 +
   16.71 +    public ModernizeFix(List<YamlParser.Replacement> replacementList, String id) {
   16.72 +        this.beg = new PositionRef[replacementList.size()];
   16.73 +        this.end = new PositionRef[replacementList.size()];
   16.74 +        this.replacements = replacementList.toArray(new YamlParser.Replacement[replacementList.size()]);
   16.75 +        this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N
   16.76 +        for (int i = 0; i < replacements.length; i++) {
   16.77 +            YamlParser.Replacement replacement = replacements[i];
   16.78 +            FileObject fo = FileUtil.toFileObject(new File(replacement.filePath));
   16.79 +            CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false);
   16.80 +            if (csmFile != null) {
   16.81 +                ces = CsmUtilities.findCloneableEditorSupport(csmFile);
   16.82 +                if (ces != null) {
   16.83 +                    beg[i] = ces.createPositionRef(replacement.offset, Position.Bias.Forward);
   16.84 +                    end[i] = ces.createPositionRef(replacement.offset + replacement.length, Position.Bias.Backward);
   16.85 +                } else {
   16.86 +                }
   16.87 +            }
   16.88 +        }
   16.89 +    } //NOI18N
   16.90 +
   16.91 +    @Override
   16.92 +    public String getText() {
   16.93 +        return "Apply replacement - " + text; //NOI18N
   16.94 +    }
   16.95 +
   16.96 +    @Override
   16.97 +    public ChangeInfo implement() throws Exception {
   16.98 +        Document doc = CsmUtilities.openDocument(ces);
   16.99 +        if (doc instanceof BaseDocument) {
  16.100 +            Position min = beg[0];
  16.101 +            Position max = end[0];
  16.102 +            for (int i = 0; i < replacements.length; i++) {
  16.103 +                YamlParser.Replacement replacement = replacements[i];
  16.104 +                PositionRef b = beg[i];
  16.105 +                PositionRef e = end[i];
  16.106 +                if (b != null && e != null) {
  16.107 +                    int newBeg = b.getOffset();
  16.108 +                    int newLength = e.getOffset() - b.getOffset();
  16.109 +                    if (b.getOffset() < min.getOffset()) {
  16.110 +                        min = b;
  16.111 +                    }
  16.112 +                    if (e.getOffset() > max.getOffset()) {
  16.113 +                        max = e;
  16.114 +                    }
  16.115 +                    if (newLength < 1) {
  16.116 +                        // TODO: temp fix
  16.117 +                        newLength = 0;
  16.118 +                    }
  16.119 +                    ((BaseDocument) doc).replace(newBeg, newLength, replacement.replacementText, null);
  16.120 +                }
  16.121 +            }
  16.122 +            return new ChangeInfo(min, max);
  16.123 +        }
  16.124 +        return null;
  16.125 +    }
  16.126 +
  16.127 +    @Override
  16.128 +    public CharSequence getSortText() {
  16.129 +        return Integer.toString(Integer.MIN_VALUE);
  16.130 +    }
  16.131 +
  16.132 +    public YamlParser.Replacement[] getReplacements() {
  16.133 +        return replacements;
  16.134 +    }
  16.135 +    
  16.136 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ResponseMerger.java	Tue May 30 15:29:39 2017 +0300
    17.3 @@ -0,0 +1,73 @@
    17.4 +/*
    17.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    17.6 + *
    17.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    17.8 + *
    17.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   17.10 + * Other names may be trademarks of their respective owners.
   17.11 + *
   17.12 + * The contents of this file are subject to the terms of either the GNU
   17.13 + * General Public License Version 2 only ("GPL") or the Common
   17.14 + * Development and Distribution License("CDDL") (collectively, the
   17.15 + * "License"). You may not use this file except in compliance with the
   17.16 + * License. You can obtain a copy of the License at
   17.17 + * http://www.netbeans.org/cddl-gplv2.html
   17.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   17.19 + * specific language governing permissions and limitations under the
   17.20 + * License.  When distributing the software, include this License Header
   17.21 + * Notice in each file and include the License file at
   17.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   17.23 + * particular file as subject to the "Classpath" exception as provided
   17.24 + * by Oracle in the GPL Version 2 section of the License file that
   17.25 + * accompanied this code. If applicable, add the following below the
   17.26 + * License Header, with the fields enclosed by brackets [] replaced by
   17.27 + * your own identifying information:
   17.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   17.29 + *
   17.30 + * If you wish your version of this file to be governed by only the CDDL
   17.31 + * or only the GPL Version 2, indicate your decision by adding
   17.32 + * "[Contributor] elects to include this software in this distribution
   17.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   17.34 + * single choice of license, a recipient has the option to distribute
   17.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   17.36 + * to extend the choice of license to its licensees as provided above.
   17.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   17.38 + * Version 2 license, then the option applies only if the new code is
   17.39 + * made subject to such option by the copyright holder.
   17.40 + *
   17.41 + * Contributor(s): Ilia Gromov
   17.42 + */
   17.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   17.44 +
   17.45 +import java.util.HashSet;
   17.46 +import java.util.Set;
   17.47 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   17.48 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   17.49 +
   17.50 +/**
   17.51 + *
   17.52 + * @author Ilia Gromov
   17.53 + */
   17.54 +public class ResponseMerger implements CsmErrorProvider.Response {
   17.55 +
   17.56 +    private final Set<CsmErrorInfo> bag = new HashSet<>();
   17.57 +    private final CsmErrorProvider.Response delegate;
   17.58 +
   17.59 +    public ResponseMerger(CsmErrorProvider.Response delegate) {
   17.60 +        this.delegate = delegate;
   17.61 +    }
   17.62 +
   17.63 +    @Override
   17.64 +    public void addError(CsmErrorInfo errorInfo) {
   17.65 +        bag.add(errorInfo);
   17.66 +    }
   17.67 +
   17.68 +    @Override
   17.69 +    public void done() {    
   17.70 +        for (CsmErrorInfo modernizeErrorInfo : bag) {
   17.71 +            delegate.addError(modernizeErrorInfo);
   17.72 +        }
   17.73 +        delegate.done();
   17.74 +        bag.clear();
   17.75 +    }
   17.76 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/YamlParser.java	Tue May 30 15:29:39 2017 +0300
    18.3 @@ -0,0 +1,357 @@
    18.4 +/*
    18.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    18.6 + *
    18.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    18.8 + *
    18.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   18.10 + * Other names may be trademarks of their respective owners.
   18.11 + *
   18.12 + * The contents of this file are subject to the terms of either the GNU
   18.13 + * General Public License Version 2 only ("GPL") or the Common
   18.14 + * Development and Distribution License("CDDL") (collectively, the
   18.15 + * "License"). You may not use this file except in compliance with the
   18.16 + * License. You can obtain a copy of the License at
   18.17 + * http://www.netbeans.org/cddl-gplv2.html
   18.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   18.19 + * specific language governing permissions and limitations under the
   18.20 + * License.  When distributing the software, include this License Header
   18.21 + * Notice in each file and include the License file at
   18.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   18.23 + * particular file as subject to the "Classpath" exception as provided
   18.24 + * by Oracle in the GPL Version 2 section of the License file that
   18.25 + * accompanied this code. If applicable, add the following below the
   18.26 + * License Header, with the fields enclosed by brackets [] replaced by
   18.27 + * your own identifying information:
   18.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   18.29 + *
   18.30 + * If you wish your version of this file to be governed by only the CDDL
   18.31 + * or only the GPL Version 2, indicate your decision by adding
   18.32 + * "[Contributor] elects to include this software in this distribution
   18.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   18.34 + * single choice of license, a recipient has the option to distribute
   18.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   18.36 + * to extend the choice of license to its licensees as provided above.
   18.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   18.38 + * Version 2 license, then the option applies only if the new code is
   18.39 + * made subject to such option by the copyright holder.
   18.40 + *
   18.41 + * Contributor(s): Ilia Gromov
   18.42 + */
   18.43 +package org.netbeans.modules.ide.analysis.modernize.impl;
   18.44 +
   18.45 +import static org.netbeans.modules.ide.analysis.modernize.impl.YamlParser.Diagnostics.UNDEFINED;
   18.46 +import java.util.ArrayList;
   18.47 +import java.util.Collections;
   18.48 +import java.util.List;
   18.49 +import java.util.StringTokenizer;
   18.50 +import java.util.logging.Level;
   18.51 +
   18.52 +/**
   18.53 + *
   18.54 + * @author Ilia Gromov
   18.55 + */
   18.56 +public class YamlParser {
   18.57 +    // TODO check for no-replacements case
   18.58 +
   18.59 +    private static final YamlParser INSTANCE = new YamlParser();
   18.60 +
   18.61 +    public static YamlParser getDefault() {
   18.62 +        return INSTANCE;
   18.63 +    }
   18.64 +
   18.65 +    private static final String OPEN_TAG = "---"; //NOI18N
   18.66 +    private static final String CLOSE_TAG = "..."; //NOI18N
   18.67 +
   18.68 +    private static final String MAIN_SOURCE_FILE = "MainSourceFile"; //NOI18N
   18.69 +    private static final String CHECK_NAME = "CheckName"; //NOI18N
   18.70 +    private static final String LEVEL = "Level"; //NOI18N
   18.71 +    private static final String MESSAGE_FILE_PATH = "MessageFilePath"; //NOI18N
   18.72 +    private static final String MESSAGE_FILE_OFFSET = "MessageFileOffset"; //NOI18N
   18.73 +    private static final String MESSAGE = "Message"; //NOI18N
   18.74 +    private static final String REPLACEMENTS = "Replacements"; //NOI18N
   18.75 +    private static final String DIAGNOSTICS = "Diagnostics"; //NOI18N
   18.76 +
   18.77 +    private static final String FILE_PATH = "FilePath"; //NOI18N
   18.78 +    private static final String OFFSET = "Offset"; //NOI18N
   18.79 +    private static final String LENGTH = "Length"; //NOI18N
   18.80 +    private static final String REPLACEMENT_TEXT = "ReplacementText"; //NOI18N
   18.81 +
   18.82 +    // clang-modernize:
   18.83 +// ---
   18.84 +// MainSourceFile:  /home/ilia/NetBeansProjects/CppApplication_46/main.cpp
   18.85 +// Replacements:    
   18.86 +//   - FilePath:        /home/ilia/NetBeansProjects/CppApplication_46/newfile.h
   18.87 +//     Offset:          101
   18.88 +//     Length:          1
   18.89 +//     ReplacementText: nullptr
   18.90 +//   - FilePath:        /home/ilia/NetBeansProjects/CppApplication_46/newfile1.h
   18.91 +//     Offset:          380
   18.92 +//     Length:          1
   18.93 +//     ReplacementText: nullptr
   18.94 +//   - FilePath:        /home/ilia/NetBeansProjects/CppApplication_46/main.cpp
   18.95 +//     Offset:          152
   18.96 +//     Length:          1
   18.97 +//     ReplacementText: nullptr
   18.98 +// ...
   18.99 +    // clang-tidy:
  18.100 +// ---
  18.101 +// MainSourceFile:  ''
  18.102 +// Diagnostics:     
  18.103 +//   CheckName:       misc-macro-parentheses
  18.104 +//   Replacements:    
  18.105 +//     - FilePath:        /media/SSD_/code/zdoom/main_1.cpp
  18.106 +//       Offset:          1352
  18.107 +//       Length:          0
  18.108 +//       ReplacementText: '('
  18.109 +//     - FilePath:        /media/SSD_/code/zdoom/main_1.cpp
  18.110 +//       Offset:          1353
  18.111 +//       Length:          0
  18.112 +//       ReplacementText: ')'
  18.113 +// Diagnostics:     
  18.114 +//   CheckName:       misc-macro-parentheses
  18.115 +//   Replacements:    
  18.116 +//     - FilePath:        /media/SSD_/code/zdoom/main_1.cpp
  18.117 +//       Offset:          1446
  18.118 +//       Length:          0
  18.119 +//       ReplacementText: '('
  18.120 +//     - FilePath:        /media/SSD_/code/zdoom/main_1.cpp
  18.121 +//       Offset:          1447
  18.122 +//       Length:          0
  18.123 +//       ReplacementText: ')'
  18.124 +// ...
  18.125 +    public List<Diagnostics> parseYaml(String output) {
  18.126 +        try {
  18.127 +            if (output.isEmpty()) {
  18.128 +                // No warnings in header = no 'Main Source File' element
  18.129 +                return Collections.EMPTY_LIST;
  18.130 +            }
  18.131 +            StringTokenizer st = new StringTokenizer(output, "\n"); //NOI18N
  18.132 +            String line;
  18.133 +
  18.134 +            // ---
  18.135 +            line = st.nextToken();
  18.136 +
  18.137 +            line = st.nextToken();
  18.138 +            String mainSourceFile = getValue(MAIN_SOURCE_FILE, line);
  18.139 +
  18.140 +            // Replacements:    
  18.141 +            line = st.nextToken();
  18.142 +            ClangTidyVersion version = line.contains(REPLACEMENTS)
  18.143 +                    ? ClangTidyVersion.OLD_FORMAT
  18.144 +                    : ClangTidyVersion.NEW_FORMAT;
  18.145 +
  18.146 +            List<Diagnostics> list = version.parser.parse(st);
  18.147 +
  18.148 +            return list;
  18.149 +        } catch (Exception ex) {
  18.150 +            ModernizeErrorProvider.LOG.log(Level.INFO, "Can't parse output line");
  18.151 +            return Collections.EMPTY_LIST;
  18.152 +        }
  18.153 +    }
  18.154 +
  18.155 +    private static List<Replacement> parseReplacements(StringTokenizer st) {
  18.156 +        List<Replacement> replacements = new ArrayList<Replacement>();
  18.157 +        String line;
  18.158 +
  18.159 +        // eat Replacements:
  18.160 +        line = st.nextToken();
  18.161 +
  18.162 +        if (!line.contains(REPLACEMENTS)) {
  18.163 +            return replacements;
  18.164 +        }
  18.165 +
  18.166 +        while (st.hasMoreTokens()) {
  18.167 +            line = st.nextToken();
  18.168 +
  18.169 +            if (line.equals(CLOSE_TAG) || !line.contains(FILE_PATH)) {
  18.170 +                break;
  18.171 +            }
  18.172 +
  18.173 +            String filePath = getValue(FILE_PATH, line);
  18.174 +
  18.175 +            line = st.nextToken();
  18.176 +            int offset = Integer.parseInt(getValue(OFFSET, line));
  18.177 +
  18.178 +            line = st.nextToken();
  18.179 +            int length = Integer.parseInt(getValue(LENGTH, line));
  18.180 +
  18.181 +            line = st.nextToken();
  18.182 +            String replacementText = getValue(REPLACEMENT_TEXT, line);
  18.183 +            while (replacementText == null && st.hasMoreElements()) {
  18.184 +                line = line + "\n" + st.nextElement(); //NOI18N
  18.185 +                replacementText = getValue(REPLACEMENT_TEXT, line);
  18.186 +            }
  18.187 +
  18.188 +            Replacement replacement = new Replacement(filePath, offset, length, replacementText);
  18.189 +            replacements.add(replacement);
  18.190 +
  18.191 +        }
  18.192 +        return replacements;
  18.193 +    }
  18.194 +
  18.195 +    private static String getValue(String key, String line) {
  18.196 +        int keyStart = line.indexOf(key);
  18.197 +        assert keyStart != -1;
  18.198 +        int keyEnd = keyStart + key.length() + 1;
  18.199 +        String trimmed = line.substring(keyEnd).trim();
  18.200 +        boolean isTextValue = trimmed.charAt(0) == '\'';
  18.201 +        if (isTextValue) {
  18.202 +            if (trimmed.length() == 1) {
  18.203 +                // '
  18.204 +                // abcd'
  18.205 +                return null;
  18.206 +            } else if (trimmed.charAt(trimmed.length() - 1) == '\'') {
  18.207 +                trimmed = trimmed.substring(1, trimmed.length() - 1);
  18.208 +            } else {
  18.209 +                return null;
  18.210 +            }
  18.211 +        }
  18.212 +        return trimmed;
  18.213 +    }
  18.214 +
  18.215 +    public static class TranslationUnitDiagnostics {
  18.216 +
  18.217 +        private final String mainSourceFilePath;
  18.218 +        private final String context;
  18.219 +        private final List<Diagnostics> diags;
  18.220 +
  18.221 +        public TranslationUnitDiagnostics(String mainSourceFilePath, String context, List<Diagnostics> diags) {
  18.222 +            this.mainSourceFilePath = mainSourceFilePath;
  18.223 +            this.context = context;
  18.224 +            this.diags = diags;
  18.225 +        }
  18.226 +
  18.227 +        public String getMainSourceFilePath() {
  18.228 +            return mainSourceFilePath;
  18.229 +        }
  18.230 +
  18.231 +        public String getContext() {
  18.232 +            return context;
  18.233 +        }
  18.234 +
  18.235 +        public List<Diagnostics> getDiags() {
  18.236 +            return diags;
  18.237 +        }
  18.238 +    }
  18.239 +
  18.240 +    public static class Diagnostics {
  18.241 +
  18.242 +        public static final String UNDEFINED = "undefined"; // NOI18N
  18.243 +
  18.244 +        public enum Level {
  18.245 +            warning, error
  18.246 +        }
  18.247 +
  18.248 +        private final String checkName;
  18.249 +        private final Diagnostics.Level level;
  18.250 +        private final String messageFilePath;
  18.251 +        private final int messageFileOffset;
  18.252 +        private final String message;
  18.253 +        private final List<Replacement> replacements;
  18.254 +
  18.255 +        public Diagnostics(String checkName, Diagnostics.Level level, String messageFilePath, int messageFileOffset, String message, List<Replacement> replacements) {
  18.256 +            this.checkName = checkName;
  18.257 +            this.level = level;
  18.258 +            this.messageFilePath = messageFilePath;
  18.259 +            this.messageFileOffset = messageFileOffset;
  18.260 +            this.message = message;
  18.261 +            this.replacements = replacements;
  18.262 +        }
  18.263 +
  18.264 +        public String getCheckName() {
  18.265 +            return checkName;
  18.266 +        }
  18.267 +
  18.268 +        public Level getLevel() {
  18.269 +            return level;
  18.270 +        }
  18.271 +
  18.272 +        public String getMessageFilePath() {
  18.273 +            return messageFilePath;
  18.274 +        }
  18.275 +
  18.276 +        public int getMessageFileOffset() {
  18.277 +            return messageFileOffset;
  18.278 +        }
  18.279 +
  18.280 +        public String getMessage() {
  18.281 +            return message;
  18.282 +        }
  18.283 +
  18.284 +        public List<Replacement> getReplacements() {
  18.285 +            return replacements;
  18.286 +        }
  18.287 +    }
  18.288 +
  18.289 +    public static class Replacement {
  18.290 +
  18.291 +        public final String filePath;
  18.292 +        public final int offset;
  18.293 +        public final int length;
  18.294 +        public final String replacementText;
  18.295 +
  18.296 +        public Replacement(String FilePath, int offset, int length, String replacementText) {
  18.297 +            this.filePath = FilePath;
  18.298 +            this.offset = offset;
  18.299 +            this.length = length;
  18.300 +            this.replacementText = replacementText;
  18.301 +        }
  18.302 +    }
  18.303 +
  18.304 +    private static enum ClangTidyVersion {
  18.305 +        NEW_FORMAT(new NewFormatParser()),
  18.306 +        OLD_FORMAT(new OldFormatParser());
  18.307 +
  18.308 +        public final TidyParser parser;
  18.309 +
  18.310 +        private ClangTidyVersion(TidyParser parser) {
  18.311 +            this.parser = parser;
  18.312 +        }
  18.313 +    }
  18.314 +
  18.315 +    private static abstract class TidyParser {
  18.316 +
  18.317 +        abstract List<Diagnostics> parse(StringTokenizer st);
  18.318 +    }
  18.319 +
  18.320 +    private static class NewFormatParser extends TidyParser {
  18.321 +
  18.322 +        @Override
  18.323 +        public List<Diagnostics> parse(StringTokenizer st) {
  18.324 +            List<Diagnostics> list = new ArrayList<Diagnostics>();
  18.325 +
  18.326 +            String line;
  18.327 +            while (st.hasMoreElements()) {
  18.328 +                line = st.nextToken();
  18.329 +                String checkName = getValue(CHECK_NAME, line);
  18.330 +
  18.331 +                line = st.nextToken();
  18.332 +                Diagnostics.Level level = Diagnostics.Level.valueOf(getValue(LEVEL, line).toLowerCase());
  18.333 +
  18.334 +                line = st.nextToken();
  18.335 +                String messageFilePath = getValue(MESSAGE_FILE_PATH, line);
  18.336 +
  18.337 +                line = st.nextToken();
  18.338 +                int messageFileOffset = Integer.parseInt(getValue(MESSAGE_FILE_OFFSET, line));
  18.339 +
  18.340 +                line = st.nextToken();
  18.341 +                String message = getValue(MESSAGE, line);
  18.342 +
  18.343 +                List<Replacement> replacements = parseReplacements(st);
  18.344 +
  18.345 +                list.add(new Diagnostics(checkName, level, messageFilePath, messageFileOffset, message, replacements));
  18.346 +            }
  18.347 +            return list;
  18.348 +        }
  18.349 +
  18.350 +    }
  18.351 +
  18.352 +    private static class OldFormatParser extends TidyParser {
  18.353 +
  18.354 +        @Override
  18.355 +        public List<Diagnostics> parse(StringTokenizer st) {
  18.356 +            List<Replacement> parseReplacements = parseReplacements(st);
  18.357 +            return Collections.singletonList(new Diagnostics(UNDEFINED, Diagnostics.Level.warning, "", -1, "", parseReplacements)); //NOI18N
  18.358 +        }
  18.359 +    }
  18.360 +}
    19.1 Binary file ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/bugs.png has changed
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/layer.xml	Tue May 30 15:29:39 2017 +0300
    20.3 @@ -0,0 +1,75 @@
    20.4 +<?xml version="1.0" encoding="UTF-8"?>
    20.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
    20.6 +<filesystem>
    20.7 +    <folder name="Analysis">
    20.8 +        <folder name="Clang-Tidy">
    20.9 +            <folder name="Disabled_Default">
   20.10 +                <file name="misc-unused-parameters">
   20.11 +                    <![CDATA[False positive activation]]>
   20.12 +                </file>
   20.13 +                <file name="misc-unused-parameters">
   20.14 +                    <![CDATA[False positive activation]]>
   20.15 +                </file>
   20.16 +                <file name="google-runtime-int">
   20.17 +                    <![CDATA[Too much warnings]]>
   20.18 +                </file>
   20.19 +                <file name="modernize-use-nullptr">
   20.20 +                    <![CDATA[Too much warnings]]>
   20.21 +                </file>
   20.22 +                <file name="modernize-use-default">
   20.23 +                    <![CDATA[Too much warnings]]>
   20.24 +                </file>
   20.25 +                <file name="google-runtime-references">
   20.26 +                    <![CDATA[Too much warnings]]>
   20.27 +                </file>
   20.28 +                <file name="modernize-redundant-void-arg">
   20.29 +                    <![CDATA[Too much warnings]]>
   20.30 +                </file>
   20.31 +                <file name="readability-implicit-bool-cast">
   20.32 +                    <![CDATA[Too much warnings]]>
   20.33 +                </file>
   20.34 +                <file name="cppcoreguidelines-pro-bounds-pointer-arithmetic">
   20.35 +                    <![CDATA[Too much warnings]]>
   20.36 +                </file>
   20.37 +                <file name="google-readability-casting">
   20.38 +                    <![CDATA[Too much warnings]]>
   20.39 +                </file>
   20.40 +                <file name="misc-macro-parentheses">
   20.41 +                    <![CDATA[Too much warnings]]>
   20.42 +                </file>
   20.43 +                
   20.44 +                <file name="google-readability-braces-around-statements">
   20.45 +                    <![CDATA[Project-specific readability check]]>
   20.46 +                </file>
   20.47 +                <file name="readability-named-parameter">
   20.48 +                    <![CDATA[Project-specific readability check]]>
   20.49 +                </file>
   20.50 +                <file name="llvm-header-guard">
   20.51 +                    <![CDATA[Project-specific readability check]]>
   20.52 +                </file>
   20.53 +                <file name="google-readability-casting">
   20.54 +                    <![CDATA[Project-specific readability check]]>
   20.55 +                </file>
   20.56 +                <file name="google-readability-namespace-comments">
   20.57 +                    <![CDATA[Project-specific readability check]]>
   20.58 +                </file>
   20.59 +                <file name="readability-braces-around-statements">
   20.60 +                    <![CDATA[Project-specific readability check]]>
   20.61 +                </file>
   20.62 +                <file name="llvm-include-order">
   20.63 +                    <![CDATA[Project-specific readability check]]>
   20.64 +                </file>
   20.65 +                <file name="readability-else-after-return">
   20.66 +                    <![CDATA[Project-specific readability check]]>
   20.67 +                </file>
   20.68 +                <file name="cppcoreguidelines-pro-type-union-access">
   20.69 +                    <![CDATA[Requires specific library]]>
   20.70 +                </file>
   20.71 +            </folder>
   20.72 +            <folder name="Strict_Checks">
   20.73 +                <file name="readability-inconsistent-declaration-parameter-name"></file>
   20.74 +                <file name="misc-unused-using-decls"></file>
   20.75 +            </folder>
   20.76 +        </folder>
   20.77 +    </folder>
   20.78 +</filesystem>
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/AnalyzerPreferences.java	Tue May 30 15:29:39 2017 +0300
    21.3 @@ -0,0 +1,66 @@
    21.4 +/*
    21.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    21.6 + *
    21.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    21.8 + *
    21.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   21.10 + * Other names may be trademarks of their respective owners.
   21.11 + *
   21.12 + * The contents of this file are subject to the terms of either the GNU
   21.13 + * General Public License Version 2 only ("GPL") or the Common
   21.14 + * Development and Distribution License("CDDL") (collectively, the
   21.15 + * "License"). You may not use this file except in compliance with the
   21.16 + * License. You can obtain a copy of the License at
   21.17 + * http://www.netbeans.org/cddl-gplv2.html
   21.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   21.19 + * specific language governing permissions and limitations under the
   21.20 + * License.  When distributing the software, include this License Header
   21.21 + * Notice in each file and include the License file at
   21.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   21.23 + * particular file as subject to the "Classpath" exception as provided
   21.24 + * by Oracle in the GPL Version 2 section of the License file that
   21.25 + * accompanied this code. If applicable, add the following below the
   21.26 + * License Header, with the fields enclosed by brackets [] replaced by
   21.27 + * your own identifying information:
   21.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   21.29 + *
   21.30 + * If you wish your version of this file to be governed by only the CDDL
   21.31 + * or only the GPL Version 2, indicate your decision by adding
   21.32 + * "[Contributor] elects to include this software in this distribution
   21.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   21.34 + * single choice of license, a recipient has the option to distribute
   21.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   21.36 + * to extend the choice of license to its licensees as provided above.
   21.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   21.38 + * Version 2 license, then the option applies only if the new code is
   21.39 + * made subject to such option by the copyright holder.
   21.40 + *
   21.41 + * Contributor(s): Ilia Gromov
   21.42 + */
   21.43 +
   21.44 +package org.netbeans.modules.ide.analysis.modernize.options;
   21.45 +
   21.46 +import java.util.prefs.Preferences;
   21.47 +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
   21.48 +
   21.49 +/**
   21.50 + *
   21.51 + * @author Ilia Gromov
   21.52 + */
   21.53 +public class AnalyzerPreferences {
   21.54 +
   21.55 +    private static final String NODE_NAME = "clang-tidy"; //NOI18N
   21.56 +
   21.57 +    public static AuditPreferences getAuditPreferences() {
   21.58 +        return Holder.PREFS;
   21.59 +    }
   21.60 +    
   21.61 +    public static Preferences getPreferences() {
   21.62 +        return Holder.PREFS.getPreferences();
   21.63 +    }
   21.64 +
   21.65 +    private static final class Holder {
   21.66 +
   21.67 +        static final AuditPreferences PREFS = new AuditPreferences(AuditPreferences.AUDIT_PREFERENCES_ROOT.node(NODE_NAME));
   21.68 +    }
   21.69 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/Bundle.properties	Tue May 30 15:29:39 2017 +0300
    22.3 @@ -0,0 +1,15 @@
    22.4 +PreviseOptions.confidenceLabel.text=&Confidence:
    22.5 +
    22.6 +SURE_CONFIDENCE=Sure
    22.7 +HIGH_CONFIDENCE=High
    22.8 +MEDIUM_CONFIDENCE=Medium
    22.9 +LOW_CONFIDENCE=Low
   22.10 +Parfait.tool.collection=
   22.11 +ParfaitOptions.pathToParfait.notfound=Not Found
   22.12 +ParfaitOptions.browse.text=...
   22.13 +SELECT_TOOL_TITLE=Select Clang Binary Folder
   22.14 +ParfaitOptions.connect.text=Connect to host {0}
   22.15 +Parfait.tool.collection_1=clang-tidy
   22.16 +ModernizeOptions.browseButton.text=...
   22.17 +ModernizeOptions.jLabel2.text=build host
   22.18 +ModernizeOptions.pathToAnalyzer.text=
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/ClangAnalyzerOptions.java	Tue May 30 15:29:39 2017 +0300
    23.3 @@ -0,0 +1,167 @@
    23.4 +/*
    23.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    23.6 + *
    23.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    23.8 + *
    23.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   23.10 + * Other names may be trademarks of their respective owners.
   23.11 + *
   23.12 + * The contents of this file are subject to the terms of either the GNU
   23.13 + * General Public License Version 2 only ("GPL") or the Common
   23.14 + * Development and Distribution License("CDDL") (collectively, the
   23.15 + * "License"). You may not use this file except in compliance with the
   23.16 + * License. You can obtain a copy of the License at
   23.17 + * http://www.netbeans.org/cddl-gplv2.html
   23.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   23.19 + * specific language governing permissions and limitations under the
   23.20 + * License.  When distributing the software, include this License Header
   23.21 + * Notice in each file and include the License file at
   23.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   23.23 + * particular file as subject to the "Classpath" exception as provided
   23.24 + * by Oracle in the GPL Version 2 section of the License file that
   23.25 + * accompanied this code. If applicable, add the following below the
   23.26 + * License Header, with the fields enclosed by brackets [] replaced by
   23.27 + * your own identifying information:
   23.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   23.29 + *
   23.30 + * If you wish your version of this file to be governed by only the CDDL
   23.31 + * or only the GPL Version 2, indicate your decision by adding
   23.32 + * "[Contributor] elects to include this software in this distribution
   23.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   23.34 + * single choice of license, a recipient has the option to distribute
   23.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   23.36 + * to extend the choice of license to its licensees as provided above.
   23.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   23.38 + * Version 2 license, then the option applies only if the new code is
   23.39 + * made subject to such option by the copyright holder.
   23.40 + *
   23.41 + * Contributor(s): Ilia Gromov
   23.42 + */
   23.43 +
   23.44 +package org.netbeans.modules.ide.analysis.modernize.options;
   23.45 +
   23.46 +import java.io.File;
   23.47 +import java.io.IOException;
   23.48 +import java.util.Collections;
   23.49 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
   23.50 +import org.netbeans.modules.nativeexecution.api.HostInfo;
   23.51 +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
   23.52 +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
   23.53 +import org.openide.modules.InstalledFileLocator;
   23.54 +
   23.55 +/**
   23.56 + *
   23.57 + * @author Ilia Gromov
   23.58 + */
   23.59 +public class ClangAnalyzerOptions {
   23.60 +
   23.61 +    public static final String CLANG_BINARY_NAME = "clang-tidy"; //NOI18N
   23.62 +    public static final String CLANG_BINARY_PATH = "clang-tidy-path"; //NOI18N
   23.63 +
   23.64 +    private static String findInPaths() {
   23.65 +        String binaryName = CLANG_BINARY_NAME + "-" + getCodeBase(); //NOI18N
   23.66 +        String result = HostInfoUtils.searchFile(ExecutionEnvironmentFactory.getLocal(), Collections.<String>emptyList(), binaryName, true); // NOI18N
   23.67 +        return result;
   23.68 +    }
   23.69 +
   23.70 +    public static String getClangAnalyzerPath() {
   23.71 +        String result = AnalyzerPreferences.getPreferences().get(CLANG_BINARY_PATH, ""); //NOI18N
   23.72 +        String oldValue = result;
   23.73 +        if (result.isEmpty()) {
   23.74 +            String toolPath = System.getProperty("devstudio.clangtidy.path"); //NOI18N
   23.75 +            if (toolPath != null) {
   23.76 +                result = toolPath;
   23.77 +            }
   23.78 +        }
   23.79 +        if (result.isEmpty()) {
   23.80 +            final String codeBase = getCodeBase();
   23.81 +            String relativePath = String.format("%s/%s-%s", CLANG_BINARY_NAME, CLANG_BINARY_NAME, codeBase); //NOI18N
   23.82 +            File toolFile = InstalledFileLocator.getDefault().locate(relativePath, codeBase, false);
   23.83 +            if (toolFile != null && toolFile.exists()) {
   23.84 +                result = toolFile.getAbsolutePath();
   23.85 +            }
   23.86 +        }
   23.87 +        if (result.isEmpty()) {
   23.88 +            String toolPath = findInPaths();
   23.89 +            if (toolPath != null) {
   23.90 +                result = toolPath;
   23.91 +            }
   23.92 +        }
   23.93 +        if (result.isEmpty()) {
   23.94 +            return null;
   23.95 +        } else {
   23.96 +            if (!oldValue.equals(result)) {
   23.97 +                AnalyzerPreferences.getPreferences().put(CLANG_BINARY_PATH, result);
   23.98 +            }
   23.99 +        }
  23.100 +        return result;
  23.101 +    }
  23.102 +
  23.103 +    public static String getMissingModuleName() {
  23.104 +        return "com.oracle.tools.analysis.clangtidy." + getCodeBase(); //NOI18N
  23.105 +    }
  23.106 +
  23.107 +    public static String getCodeBase() {
  23.108 +        HostInfo hostInfo = null;
  23.109 +        try {
  23.110 +            hostInfo = HostInfoUtils.getHostInfo(ExecutionEnvironmentFactory.getLocal());
  23.111 +        } catch (IOException ex) {
  23.112 +            ex.printStackTrace(System.err);
  23.113 +        } catch (ConnectionManager.CancellationException ex) {
  23.114 +            ex.printStackTrace(System.err);
  23.115 +        }
  23.116 +        String module = null;
  23.117 +        if (hostInfo != null) {
  23.118 +            switch (hostInfo.getOS().getFamily()) {
  23.119 +                case SUNOS:
  23.120 +                    switch (hostInfo.getCpuFamily()) {
  23.121 +                        case X86:
  23.122 +                            switch (hostInfo.getOS().getBitness()) {
  23.123 +                                case _32:
  23.124 +                                    module = "SunOS_x86"; // NOI18N
  23.125 +                                    break;
  23.126 +                                case _64:
  23.127 +                                    module = "SunOS_x86_64"; // NOI18N
  23.128 +                                    break;
  23.129 +                            }
  23.130 +                            break;
  23.131 +                        case SPARC:
  23.132 +                            module = "SunOS_sparc"; // NOI18N
  23.133 +                            break;
  23.134 +                    }
  23.135 +                    break;
  23.136 +                case LINUX:
  23.137 +                    switch (hostInfo.getOS().getBitness()) {
  23.138 +                        case _32:
  23.139 +                            module = "Linux_x86"; // NOI18N
  23.140 +                            break;
  23.141 +                        case _64:
  23.142 +                            module = "Linux_x86_64"; // NOI18N
  23.143 +                            break;
  23.144 +                    }
  23.145 +                    break;
  23.146 +                case WINDOWS:
  23.147 +                    switch (hostInfo.getOS().getBitness()) {
  23.148 +                        case _32:
  23.149 +                            module = "Windows_x86"; // NOI18N
  23.150 +                            break;
  23.151 +                        case _64:
  23.152 +                            module = "Windows_x86_64"; // NOI18N
  23.153 +                            break;
  23.154 +                    }
  23.155 +                    break;
  23.156 +                case MACOSX:
  23.157 +                    switch (hostInfo.getOS().getBitness()) {
  23.158 +                        case _32:
  23.159 +                            module = "MacOSX_x86"; // NOI18N
  23.160 +                            break;
  23.161 +                        case _64:
  23.162 +                            module = "MacOSX_x86_64"; // NOI18N
  23.163 +                            break;
  23.164 +                    }
  23.165 +                    break;
  23.166 +            }
  23.167 +        }
  23.168 +        return module;
  23.169 +    }
  23.170 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/Bundle.properties	Tue May 30 15:29:39 2017 +0300
    24.3 @@ -0,0 +1,6 @@
    24.4 +fatals=fatal.unsupported.remote;fatal.tmp;fatal.analyze.error;fatal.language.flavor
    24.5 +
    24.6 +fatal.unsupported.remote= fatal: Unsupported remote mode
    24.7 +fatal.tmp= fatal: Cannot create temporary file
    24.8 +fatal.analyze.error= fatal: Unable to analyze file
    24.9 +fatal.language.flavor= fatal: Clang-tidy can be used with C++11 or later standard only
   24.10 \ No newline at end of file
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/BundleUtilities.java	Tue May 30 15:29:39 2017 +0300
    25.3 @@ -0,0 +1,61 @@
    25.4 +/*
    25.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    25.6 + *
    25.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    25.8 + *
    25.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   25.10 + * Other names may be trademarks of their respective owners.
   25.11 + *
   25.12 + * The contents of this file are subject to the terms of either the GNU
   25.13 + * General Public License Version 2 only ("GPL") or the Common
   25.14 + * Development and Distribution License("CDDL") (collectively, the
   25.15 + * "License"). You may not use this file except in compliance with the
   25.16 + * License. You can obtain a copy of the License at
   25.17 + * http://www.netbeans.org/cddl-gplv2.html
   25.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   25.19 + * specific language governing permissions and limitations under the
   25.20 + * License.  When distributing the software, include this License Header
   25.21 + * Notice in each file and include the License file at
   25.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   25.23 + * particular file as subject to the "Classpath" exception as provided
   25.24 + * by Oracle in the GPL Version 2 section of the License file that
   25.25 + * accompanied this code. If applicable, add the following below the
   25.26 + * License Header, with the fields enclosed by brackets [] replaced by
   25.27 + * your own identifying information:
   25.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   25.29 + *
   25.30 + * If you wish your version of this file to be governed by only the CDDL
   25.31 + * or only the GPL Version 2, indicate your decision by adding
   25.32 + * "[Contributor] elects to include this software in this distribution
   25.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   25.34 + * single choice of license, a recipient has the option to distribute
   25.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   25.36 + * to extend the choice of license to its licensees as provided above.
   25.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   25.38 + * Version 2 license, then the option applies only if the new code is
   25.39 + * made subject to such option by the copyright holder.
   25.40 + *
   25.41 + * Contributor(s): Ilia Gromov
   25.42 + */
   25.43 +package org.netbeans.modules.ide.analysis.modernize.resources;
   25.44 +
   25.45 +import org.openide.util.NbBundle;
   25.46 +
   25.47 +/**
   25.48 + *
   25.49 + * @author Ilia Gromov
   25.50 + */
   25.51 +public class BundleUtilities {
   25.52 +
   25.53 +    public static String[] getFlags() {
   25.54 +        return NbBundle.getMessage(BundleUtilities.class, "flags").split(";");
   25.55 +    }
   25.56 +
   25.57 +    public static String getDescription(String key) {
   25.58 +        return NbBundle.getMessage(BundleUtilities.class, key);
   25.59 +    }
   25.60 +
   25.61 +    public static String[] getFatalErrors() {
   25.62 +        return NbBundle.getMessage(BundleUtilities.class, "fatals").split(";");
   25.63 +    }
   25.64 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang-tools-extra.patch	Tue May 30 15:29:39 2017 +0300
    26.3 @@ -0,0 +1,139 @@
    26.4 +Index: clang-tidy/ClangTidy.cpp
    26.5 +===================================================================
    26.6 +--- clang-tidy/ClangTidy.cpp	(revision 278390)
    26.7 ++++ clang-tidy/ClangTidy.cpp	(working copy)
    26.8 +@@ -35,6 +35,7 @@
    26.9 + #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
   26.10 + #include "clang/Tooling/Refactoring.h"
   26.11 + #include "clang/Tooling/ReplacementsYaml.h"
   26.12 ++#include "clang/Tooling/DiagnosticsYaml.h"
   26.13 + #include "clang/Tooling/Tooling.h"
   26.14 + #include "llvm/Support/Process.h"
   26.15 + #include "llvm/Support/Signals.h"
   26.16 +@@ -509,13 +510,10 @@
   26.17 + 
   26.18 + void exportReplacements(const std::vector<ClangTidyError> &Errors,
   26.19 +                         raw_ostream &OS) {
   26.20 +-  tooling::TranslationUnitReplacements TUR;
   26.21 +-  for (const ClangTidyError &Error : Errors)
   26.22 +-    TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(),
   26.23 +-                            Error.Fix.end());
   26.24 +-
   26.25 +   yaml::Output YAML(OS);
   26.26 +-  YAML << TUR;
   26.27 ++  TranslationUnitDiagnostics TUD;
   26.28 ++  TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end());
   26.29 ++  YAML << TUD;
   26.30 + }
   26.31 + 
   26.32 + } // namespace tidy
   26.33 +Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
   26.34 +===================================================================
   26.35 +--- clang-tidy/ClangTidyDiagnosticConsumer.cpp	(revision 278390)
   26.36 ++++ clang-tidy/ClangTidyDiagnosticConsumer.cpp	(working copy)
   26.37 +@@ -102,25 +102,6 @@
   26.38 + };
   26.39 + } // end anonymous namespace
   26.40 + 
   26.41 +-ClangTidyMessage::ClangTidyMessage(StringRef Message)
   26.42 +-    : Message(Message), FileOffset(0) {}
   26.43 +-
   26.44 +-ClangTidyMessage::ClangTidyMessage(StringRef Message,
   26.45 +-                                   const SourceManager &Sources,
   26.46 +-                                   SourceLocation Loc)
   26.47 +-    : Message(Message) {
   26.48 +-  assert(Loc.isValid() && Loc.isFileID());
   26.49 +-  FilePath = Sources.getFilename(Loc);
   26.50 +-  FileOffset = Sources.getFileOffset(Loc);
   26.51 +-}
   26.52 +-
   26.53 +-ClangTidyError::ClangTidyError(StringRef CheckName,
   26.54 +-                               ClangTidyError::Level DiagLevel,
   26.55 +-                               bool IsWarningAsError,
   26.56 +-                               StringRef BuildDirectory)
   26.57 +-    : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
   26.58 +-      IsWarningAsError(IsWarningAsError) {}
   26.59 +-
   26.60 + // Returns true if GlobList starts with the negative indicator ('-'), removes it
   26.61 + // from the GlobList.
   26.62 + static bool ConsumeNegativeIndicator(StringRef &GlobList) {
   26.63 +Index: clang-tidy/ClangTidyDiagnosticConsumer.h
   26.64 +===================================================================
   26.65 +--- clang-tidy/ClangTidyDiagnosticConsumer.h	(revision 278390)
   26.66 ++++ clang-tidy/ClangTidyDiagnosticConsumer.h	(working copy)
   26.67 +@@ -14,6 +14,7 @@
   26.68 + #include "clang/Basic/Diagnostic.h"
   26.69 + #include "clang/Basic/SourceManager.h"
   26.70 + #include "clang/Tooling/Refactoring.h"
   26.71 ++#include "clang/Tooling/Core/Diagnostics.h"
   26.72 + #include "llvm/ADT/DenseMap.h"
   26.73 + #include "llvm/ADT/StringMap.h"
   26.74 + #include "llvm/Support/Regex.h"
   26.75 +@@ -32,52 +33,9 @@
   26.76 + 
   26.77 + namespace tidy {
   26.78 + 
   26.79 +-/// \brief A message from a clang-tidy check.
   26.80 +-///
   26.81 +-/// Note that this is independent of a \c SourceManager.
   26.82 +-struct ClangTidyMessage {
   26.83 +-  ClangTidyMessage(StringRef Message = "");
   26.84 +-  ClangTidyMessage(StringRef Message, const SourceManager &Sources,
   26.85 +-                   SourceLocation Loc);
   26.86 +-  std::string Message;
   26.87 +-  std::string FilePath;
   26.88 +-  unsigned FileOffset;
   26.89 +-};
   26.90 ++typedef clang::tooling::DiagnosticsMessage ClangTidyMessage;
   26.91 ++typedef clang::tooling::Diagnostics ClangTidyError;
   26.92 + 
   26.93 +-/// \brief A detected error complete with information to display diagnostic and
   26.94 +-/// automatic fix.
   26.95 +-///
   26.96 +-/// This is used as an intermediate format to transport Diagnostics without a
   26.97 +-/// dependency on a SourceManager.
   26.98 +-///
   26.99 +-/// FIXME: Make Diagnostics flexible enough to support this directly.
  26.100 +-struct ClangTidyError {
  26.101 +-  enum Level {
  26.102 +-    Warning = DiagnosticsEngine::Warning,
  26.103 +-    Error = DiagnosticsEngine::Error
  26.104 +-  };
  26.105 +-
  26.106 +-  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
  26.107 +-                 StringRef BuildDirectory);
  26.108 +-
  26.109 +-  std::string CheckName;
  26.110 +-  ClangTidyMessage Message;
  26.111 +-  tooling::Replacements Fix;
  26.112 +-  SmallVector<ClangTidyMessage, 1> Notes;
  26.113 +-
  26.114 +-  // A build directory of the diagnostic source file.
  26.115 +-  //
  26.116 +-  // It's an absolute path which is `directory` field of the source file in
  26.117 +-  // compilation database. If users don't specify the compilation database
  26.118 +-  // directory, it is the current directory where clang-tidy runs.
  26.119 +-  //
  26.120 +-  // Note: it is empty in unittest.
  26.121 +-  std::string BuildDirectory;
  26.122 +-
  26.123 +-  Level DiagLevel;
  26.124 +-  bool IsWarningAsError;
  26.125 +-};
  26.126 +-
  26.127 + /// \brief Read-only set of strings represented as a list of positive and
  26.128 + /// negative globs. Positive globs add all matched strings to the set, negative
  26.129 + /// globs remove them in the order of appearance in the list.
  26.130 +Index: clang-tidy/tool/ClangTidyMain.cpp
  26.131 +===================================================================
  26.132 +--- clang-tidy/tool/ClangTidyMain.cpp	(revision 278390)
  26.133 ++++ clang-tidy/tool/ClangTidyMain.cpp	(working copy)
  26.134 +@@ -389,7 +389,7 @@
  26.135 + 
  26.136 +   // -fix-errors implies -fix.
  26.137 +   handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
  26.138 +-
  26.139 ++  
  26.140 +   if (!ExportFixes.empty() && !Errors.empty()) {
  26.141 +     std::error_code EC;
  26.142 +     llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang.patch	Tue May 30 15:29:39 2017 +0300
    27.3 @@ -0,0 +1,461 @@
    27.4 +Index: include/clang/Tooling/Core/Diagnostics.h
    27.5 +===================================================================
    27.6 +--- include/clang/Tooling/Core/Diagnostics.h	(revision 278390)
    27.7 ++++ include/clang/Tooling/Core/Diagnostics.h	(working copy)
    27.8 +@@ -1,254 +1,54 @@
    27.9 +-//===--- Replacement.h - Framework for clang refactoring tools --*- C++ -*-===//
   27.10 +-//
   27.11 +-//                     The LLVM Compiler Infrastructure
   27.12 +-//
   27.13 +-// This file is distributed under the University of Illinois Open Source
   27.14 +-// License. See LICENSE.TXT for details.
   27.15 +-//
   27.16 +-//===----------------------------------------------------------------------===//
   27.17 +-//
   27.18 +-//  Classes supporting refactorings that span multiple translation units.
   27.19 +-//  While single translation unit refactorings are supported via the Rewriter,
   27.20 +-//  when refactoring multiple translation units changes must be stored in a
   27.21 +-//  SourceManager independent form, duplicate changes need to be removed, and
   27.22 +-//  all changes must be applied at once at the end of the refactoring so that
   27.23 +-//  the code is always parseable.
   27.24 +-//
   27.25 +-//===----------------------------------------------------------------------===//
   27.26 +-
   27.27 +-#ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
   27.28 +-#define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
   27.29 +-
   27.30 +-#include "clang/Basic/LangOptions.h"
   27.31 +-#include "clang/Basic/SourceLocation.h"
   27.32 +-#include "llvm/ADT/StringRef.h"
   27.33 +-#include "llvm/Support/Error.h"
   27.34 +-#include <map>
   27.35 +-#include <set>
   27.36 ++#ifndef LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H
   27.37 ++#define LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H
   27.38 ++#include "clang/Basic/Diagnostic.h"
   27.39 ++#include "llvm/ADT/SmallVector.h"
   27.40 ++#include "Replacement.h"
   27.41 + #include <string>
   27.42 +-#include <vector>
   27.43 +-
   27.44 + namespace clang {
   27.45 ++    namespace tooling {
   27.46 + 
   27.47 +-class Rewriter;
   27.48 ++        struct DiagnosticsMessage {
   27.49 ++            DiagnosticsMessage(StringRef Message = "");
   27.50 ++            DiagnosticsMessage(StringRef Message, const SourceManager &Sources,
   27.51 ++                    SourceLocation Loc);
   27.52 ++            std::string Message;
   27.53 ++            std::string FilePath;
   27.54 ++            unsigned FileOffset;
   27.55 ++        };
   27.56 + 
   27.57 +-namespace tooling {
   27.58 ++        struct Diagnostics {
   27.59 + 
   27.60 +-/// \brief A source range independent of the \c SourceManager.
   27.61 +-class Range {
   27.62 +-public:
   27.63 +-  Range() : Offset(0), Length(0) {}
   27.64 +-  Range(unsigned Offset, unsigned Length) : Offset(Offset), Length(Length) {}
   27.65 ++            enum Level {
   27.66 ++                Warning = DiagnosticsEngine::Warning,
   27.67 ++                Error = DiagnosticsEngine::Error
   27.68 ++            };
   27.69 + 
   27.70 +-  /// \brief Accessors.
   27.71 +-  /// @{
   27.72 +-  unsigned getOffset() const { return Offset; }
   27.73 +-  unsigned getLength() const { return Length; }
   27.74 +-  /// @}
   27.75 ++            Diagnostics();
   27.76 ++            Diagnostics(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
   27.77 ++                    StringRef BuildDirectory);
   27.78 ++            std::string CheckName;
   27.79 ++            DiagnosticsMessage Message;
   27.80 ++            tooling::Replacements Fix;
   27.81 ++            SmallVector<DiagnosticsMessage, 1> Notes;
   27.82 + 
   27.83 +-  /// \name Range Predicates
   27.84 +-  /// @{
   27.85 +-  /// \brief Whether this range overlaps with \p RHS or not.
   27.86 +-  bool overlapsWith(Range RHS) const {
   27.87 +-    return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length;
   27.88 +-  }
   27.89 ++            // A build directory of the diagnostic source file.
   27.90 ++            //
   27.91 ++            // It's an absolute path which is `directory` field of the source file in
   27.92 ++            // compilation database. If users don't specify the compilation database
   27.93 ++            // directory, it is the current directory where clang-tidy runs.
   27.94 ++            //
   27.95 ++            // Note: it is empty in unittest.
   27.96 ++            std::string BuildDirectory;
   27.97 + 
   27.98 +-  /// \brief Whether this range contains \p RHS or not.
   27.99 +-  bool contains(Range RHS) const {
  27.100 +-    return RHS.Offset >= Offset &&
  27.101 +-           (RHS.Offset + RHS.Length) <= (Offset + Length);
  27.102 +-  }
  27.103 ++            Level DiagLevel;
  27.104 ++            bool IsWarningAsError;
  27.105 ++        };
  27.106 + 
  27.107 +-  /// \brief Whether this range equals to \p RHS or not.
  27.108 +-  bool operator==(const Range &RHS) const {
  27.109 +-    return Offset == RHS.getOffset() && Length == RHS.getLength();
  27.110 +-  }
  27.111 +-  /// @}
  27.112 +-
  27.113 +-private:
  27.114 +-  unsigned Offset;
  27.115 +-  unsigned Length;
  27.116 +-};
  27.117 +-
  27.118 +-/// \brief A text replacement.
  27.119 +-///
  27.120 +-/// Represents a SourceManager independent replacement of a range of text in a
  27.121 +-/// specific file.
  27.122 +-class Replacement {
  27.123 +-public:
  27.124 +-  /// \brief Creates an invalid (not applicable) replacement.
  27.125 +-  Replacement();
  27.126 +-
  27.127 +-  /// \brief Creates a replacement of the range [Offset, Offset+Length) in
  27.128 +-  /// FilePath with ReplacementText.
  27.129 +-  ///
  27.130 +-  /// \param FilePath A source file accessible via a SourceManager.
  27.131 +-  /// \param Offset The byte offset of the start of the range in the file.
  27.132 +-  /// \param Length The length of the range in bytes.
  27.133 +-  Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
  27.134 +-              StringRef ReplacementText);
  27.135 +-
  27.136 +-  /// \brief Creates a Replacement of the range [Start, Start+Length) with
  27.137 +-  /// ReplacementText.
  27.138 +-  Replacement(const SourceManager &Sources, SourceLocation Start,
  27.139 +-              unsigned Length, StringRef ReplacementText);
  27.140 +-
  27.141 +-  /// \brief Creates a Replacement of the given range with ReplacementText.
  27.142 +-  Replacement(const SourceManager &Sources, const CharSourceRange &Range,
  27.143 +-              StringRef ReplacementText,
  27.144 +-              const LangOptions &LangOpts = LangOptions());
  27.145 +-
  27.146 +-  /// \brief Creates a Replacement of the node with ReplacementText.
  27.147 +-  template <typename Node>
  27.148 +-  Replacement(const SourceManager &Sources, const Node &NodeToReplace,
  27.149 +-              StringRef ReplacementText,
  27.150 +-              const LangOptions &LangOpts = LangOptions());
  27.151 +-
  27.152 +-  /// \brief Returns whether this replacement can be applied to a file.
  27.153 +-  ///
  27.154 +-  /// Only replacements that are in a valid file can be applied.
  27.155 +-  bool isApplicable() const;
  27.156 +-
  27.157 +-  /// \brief Accessors.
  27.158 +-  /// @{
  27.159 +-  StringRef getFilePath() const { return FilePath; }
  27.160 +-  unsigned getOffset() const { return ReplacementRange.getOffset(); }
  27.161 +-  unsigned getLength() const { return ReplacementRange.getLength(); }
  27.162 +-  StringRef getReplacementText() const { return ReplacementText; }
  27.163 +-  /// @}
  27.164 +-
  27.165 +-  /// \brief Applies the replacement on the Rewriter.
  27.166 +-  bool apply(Rewriter &Rewrite) const;
  27.167 +-
  27.168 +-  /// \brief Returns a human readable string representation.
  27.169 +-  std::string toString() const;
  27.170 +-
  27.171 +- private:
  27.172 +-   void setFromSourceLocation(const SourceManager &Sources,
  27.173 +-                              SourceLocation Start, unsigned Length,
  27.174 +-                              StringRef ReplacementText);
  27.175 +-   void setFromSourceRange(const SourceManager &Sources,
  27.176 +-                           const CharSourceRange &Range,
  27.177 +-                           StringRef ReplacementText,
  27.178 +-                           const LangOptions &LangOpts);
  27.179 +-
  27.180 +-  std::string FilePath;
  27.181 +-  Range ReplacementRange;
  27.182 +-  std::string ReplacementText;
  27.183 +-};
  27.184 +-
  27.185 +-/// \brief Less-than operator between two Replacements.
  27.186 +-bool operator<(const Replacement &LHS, const Replacement &RHS);
  27.187 +-
  27.188 +-/// \brief Equal-to operator between two Replacements.
  27.189 +-bool operator==(const Replacement &LHS, const Replacement &RHS);
  27.190 +-
  27.191 +-/// \brief A set of Replacements.
  27.192 +-/// FIXME: Change to a vector and deduplicate in the RefactoringTool.
  27.193 +-typedef std::set<Replacement> Replacements;
  27.194 +-
  27.195 +-/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite.
  27.196 +-///
  27.197 +-/// Replacement applications happen independently of the success of
  27.198 +-/// other applications.
  27.199 +-///
  27.200 +-/// \returns true if all replacements apply. false otherwise.
  27.201 +-bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite);
  27.202 +-
  27.203 +-/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite.
  27.204 +-///
  27.205 +-/// Replacement applications happen independently of the success of
  27.206 +-/// other applications.
  27.207 +-///
  27.208 +-/// \returns true if all replacements apply. false otherwise.
  27.209 +-bool applyAllReplacements(const std::vector<Replacement> &Replaces,
  27.210 +-                          Rewriter &Rewrite);
  27.211 +-
  27.212 +-/// \brief Applies all replacements in \p Replaces to \p Code.
  27.213 +-///
  27.214 +-/// This completely ignores the path stored in each replacement. If all
  27.215 +-/// replacements are applied successfully, this returns the code with
  27.216 +-/// replacements applied; otherwise, an llvm::Error carrying llvm::StringError
  27.217 +-/// is returned (the Error message can be converted to string using
  27.218 +-/// `llvm::toString()` and 'std::error_code` in the `Error` should be ignored).
  27.219 +-llvm::Expected<std::string> applyAllReplacements(StringRef Code,
  27.220 +-                                                 const Replacements &Replaces);
  27.221 +-
  27.222 +-/// \brief Calculates how a code \p Position is shifted when \p Replaces are
  27.223 +-/// applied.
  27.224 +-unsigned shiftedCodePosition(const Replacements& Replaces, unsigned Position);
  27.225 +-
  27.226 +-/// \brief Calculates how a code \p Position is shifted when \p Replaces are
  27.227 +-/// applied.
  27.228 +-///
  27.229 +-/// \pre Replaces[i].getOffset() <= Replaces[i+1].getOffset().
  27.230 +-unsigned shiftedCodePosition(const std::vector<Replacement> &Replaces,
  27.231 +-                             unsigned Position);
  27.232 +-
  27.233 +-/// \brief Removes duplicate Replacements and reports if Replacements conflict
  27.234 +-/// with one another. All Replacements are assumed to be in the same file.
  27.235 +-///
  27.236 +-/// \post Replaces[i].getOffset() <= Replaces[i+1].getOffset().
  27.237 +-///
  27.238 +-/// This function sorts \p Replaces so that conflicts can be reported simply by
  27.239 +-/// offset into \p Replaces and number of elements in the conflict.
  27.240 +-void deduplicate(std::vector<Replacement> &Replaces,
  27.241 +-                 std::vector<Range> &Conflicts);
  27.242 +-
  27.243 +-/// \brief Collection of Replacements generated from a single translation unit.
  27.244 +-struct TranslationUnitReplacements {
  27.245 +-  /// Name of the main source for the translation unit.
  27.246 +-  std::string MainSourceFile;
  27.247 +-
  27.248 +-  /// A freeform chunk of text to describe the context of the replacements.
  27.249 +-  /// Will be printed, for example, when detecting conflicts during replacement
  27.250 +-  /// deduplication.
  27.251 +-  std::string Context;
  27.252 +-
  27.253 +-  std::vector<Replacement> Replacements;
  27.254 +-};
  27.255 +-
  27.256 +-/// \brief Calculates the ranges in a single file that are affected by the
  27.257 +-/// Replacements. Overlapping ranges will be merged.
  27.258 +-///
  27.259 +-/// \pre Replacements must be for the same file.
  27.260 +-///
  27.261 +-/// \returns a non-overlapping and sorted ranges.
  27.262 +-std::vector<Range> calculateChangedRanges(const Replacements &Replaces);
  27.263 +-
  27.264 +-/// \brief Calculates the new ranges after \p Replaces are applied. These
  27.265 +-/// include both the original \p Ranges and the affected ranges of \p Replaces
  27.266 +-/// in the new code.
  27.267 +-///
  27.268 +-/// \pre Replacements must be for the same file.
  27.269 +-///
  27.270 +-/// \return The new ranges after \p Replaces are applied. The new ranges will be
  27.271 +-/// sorted and non-overlapping.
  27.272 +-std::vector<Range>
  27.273 +-calculateRangesAfterReplacements(const Replacements &Replaces,
  27.274 +-                                 const std::vector<Range> &Ranges);
  27.275 +-
  27.276 +-/// \brief Groups a random set of replacements by file path. Replacements
  27.277 +-/// related to the same file entry are put into the same vector.
  27.278 +-std::map<std::string, Replacements>
  27.279 +-groupReplacementsByFile(const Replacements &Replaces);
  27.280 +-
  27.281 +-/// \brief Merges two sets of replacements with the second set referring to the
  27.282 +-/// code after applying the first set. Within both 'First' and 'Second',
  27.283 +-/// replacements must not overlap.
  27.284 +-Replacements mergeReplacements(const Replacements &First,
  27.285 +-                               const Replacements &Second);
  27.286 +-
  27.287 +-template <typename Node>
  27.288 +-Replacement::Replacement(const SourceManager &Sources,
  27.289 +-                         const Node &NodeToReplace, StringRef ReplacementText,
  27.290 +-                         const LangOptions &LangOpts) {
  27.291 +-  const CharSourceRange Range =
  27.292 +-      CharSourceRange::getTokenRange(NodeToReplace->getSourceRange());
  27.293 +-  setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
  27.294 ++        struct TranslationUnitDiagnostics {
  27.295 ++            std::string MainSourceFile;
  27.296 ++            std::string Context;
  27.297 ++            std::vector<Diagnostics> Diags;
  27.298 ++        };
  27.299 ++    }
  27.300 + }
  27.301 +-
  27.302 +-} // end namespace tooling
  27.303 +-} // end namespace clang
  27.304 +-
  27.305 +-#endif // LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
  27.306 ++#endif
  27.307 +\ No newline at end of file
  27.308 +Index: lib/Tooling/Core/CMakeLists.txt
  27.309 +===================================================================
  27.310 +--- lib/Tooling/Core/CMakeLists.txt	(revision 278390)
  27.311 ++++ lib/Tooling/Core/CMakeLists.txt	(working copy)
  27.312 +@@ -3,6 +3,7 @@
  27.313 + add_clang_library(clangToolingCore
  27.314 +   Lookup.cpp
  27.315 +   Replacement.cpp
  27.316 ++  Diagnostics.cpp
  27.317 +   QualTypeNames.cpp
  27.318 + 
  27.319 +   LINK_LIBS
  27.320 +Index: lib/Tooling/Core/Diagnostics.cpp
  27.321 +===================================================================
  27.322 +--- lib/Tooling/Core/Diagnostics.cpp	(revision 278390)
  27.323 ++++ lib/Tooling/Core/Diagnostics.cpp	(working copy)
  27.324 +@@ -1,113 +1,30 @@
  27.325 +-//===--- Lookup.cpp - Framework for clang refactoring tools ---------------===//
  27.326 +-//
  27.327 +-//                     The LLVM Compiler Infrastructure
  27.328 +-//
  27.329 +-// This file is distributed under the University of Illinois Open Source
  27.330 +-// License. See LICENSE.TXT for details.
  27.331 +-//
  27.332 +-//===----------------------------------------------------------------------===//
  27.333 +-//
  27.334 +-//  This file defines helper methods for clang tools performing name lookup.
  27.335 +-//
  27.336 +-//===----------------------------------------------------------------------===//
  27.337 ++#include "clang/Tooling/Core/Diagnostics.h"
  27.338 ++#include "clang/Basic/SourceManager.h"
  27.339 ++namespace clang {
  27.340 ++    namespace tooling {
  27.341 + 
  27.342 +-#include "clang/Tooling/Core/Lookup.h"
  27.343 +-#include "clang/AST/Decl.h"
  27.344 +-using namespace clang;
  27.345 +-using namespace clang::tooling;
  27.346 ++        DiagnosticsMessage::DiagnosticsMessage(StringRef Message)
  27.347 ++        : Message(Message), FileOffset(0) {
  27.348 ++        }
  27.349 + 
  27.350 +-static bool isInsideDifferentNamespaceWithSameName(const DeclContext *DeclA,
  27.351 +-                                                   const DeclContext *DeclB) {
  27.352 +-  while (true) {
  27.353 +-    // Look past non-namespaces on DeclA.
  27.354 +-    while (DeclA && !isa<NamespaceDecl>(DeclA))
  27.355 +-      DeclA = DeclA->getParent();
  27.356 ++        DiagnosticsMessage::DiagnosticsMessage(StringRef Message,
  27.357 ++                const SourceManager &Sources,
  27.358 ++                SourceLocation Loc)
  27.359 ++        : Message(Message) {
  27.360 ++            assert(Loc.isValid() && Loc.isFileID());
  27.361 ++            FilePath = Sources.getFilename(Loc);
  27.362 ++            FileOffset = Sources.getFileOffset(Loc);
  27.363 ++        }
  27.364 + 
  27.365 +-    // Look past non-namespaces on DeclB.
  27.366 +-    while (DeclB && !isa<NamespaceDecl>(DeclB))
  27.367 +-      DeclB = DeclB->getParent();
  27.368 ++        Diagnostics::Diagnostics() {
  27.369 ++        }
  27.370 + 
  27.371 +-    // We hit the root, no namespace collision.
  27.372 +-    if (!DeclA || !DeclB)
  27.373 +-      return false;
  27.374 +-
  27.375 +-    // Literally the same namespace, not a collision.
  27.376 +-    if (DeclA == DeclB)
  27.377 +-      return false;
  27.378 +-
  27.379 +-    // Now check the names. If they match we have a different namespace with the
  27.380 +-    // same name.
  27.381 +-    if (cast<NamespaceDecl>(DeclA)->getDeclName() ==
  27.382 +-        cast<NamespaceDecl>(DeclB)->getDeclName())
  27.383 +-      return true;
  27.384 +-
  27.385 +-    DeclA = DeclA->getParent();
  27.386 +-    DeclB = DeclB->getParent();
  27.387 +-  }
  27.388 +-}
  27.389 +-
  27.390 +-static StringRef getBestNamespaceSubstr(const DeclContext *DeclA,
  27.391 +-                                        StringRef NewName,
  27.392 +-                                        bool HadLeadingColonColon) {
  27.393 +-  while (true) {
  27.394 +-    while (DeclA && !isa<NamespaceDecl>(DeclA))
  27.395 +-      DeclA = DeclA->getParent();
  27.396 +-
  27.397 +-    // Fully qualified it is! Leave :: in place if it's there already.
  27.398 +-    if (!DeclA)
  27.399 +-      return HadLeadingColonColon ? NewName : NewName.substr(2);
  27.400 +-
  27.401 +-    // Otherwise strip off redundant namespace qualifications from the new name.
  27.402 +-    // We use the fully qualified name of the namespace and remove that part
  27.403 +-    // from NewName if it has an identical prefix.
  27.404 +-    std::string NS =
  27.405 +-        "::" + cast<NamespaceDecl>(DeclA)->getQualifiedNameAsString() + "::";
  27.406 +-    if (NewName.startswith(NS))
  27.407 +-      return NewName.substr(NS.size());
  27.408 +-
  27.409 +-    // No match yet. Strip of a namespace from the end of the chain and try
  27.410 +-    // again. This allows to get optimal qualifications even if the old and new
  27.411 +-    // decl only share common namespaces at a higher level.
  27.412 +-    DeclA = DeclA->getParent();
  27.413 +-  }
  27.414 +-}
  27.415 +-
  27.416 +-/// Check if the name specifier begins with a written "::".
  27.417 +-static bool isFullyQualified(const NestedNameSpecifier *NNS) {
  27.418 +-  while (NNS) {
  27.419 +-    if (NNS->getKind() == NestedNameSpecifier::Global)
  27.420 +-      return true;
  27.421 +-    NNS = NNS->getPrefix();
  27.422 +-  }
  27.423 +-  return false;
  27.424 +-}
  27.425 +-
  27.426 +-std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
  27.427 +-                                       const DeclContext *UseContext,
  27.428 +-                                       const NamedDecl *FromDecl,
  27.429 +-                                       StringRef ReplacementString) {
  27.430 +-  assert(ReplacementString.startswith("::") &&
  27.431 +-         "Expected fully-qualified name!");
  27.432 +-
  27.433 +-  // We can do a raw name replacement when we are not inside the namespace for
  27.434 +-  // the original function and it is not in the global namespace.  The
  27.435 +-  // assumption is that outside the original namespace we must have a using
  27.436 +-  // statement that makes this work out and that other parts of this refactor
  27.437 +-  // will automatically fix using statements to point to the new function
  27.438 +-  const bool class_name_only = !Use;
  27.439 +-  const bool in_global_namespace =
  27.440 +-      isa<TranslationUnitDecl>(FromDecl->getDeclContext());
  27.441 +-  if (class_name_only && !in_global_namespace &&
  27.442 +-      !isInsideDifferentNamespaceWithSameName(FromDecl->getDeclContext(),
  27.443 +-                                              UseContext)) {
  27.444 +-    auto Pos = ReplacementString.rfind("::");
  27.445 +-    return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2)
  27.446 +-                                  : ReplacementString;
  27.447 +-  }
  27.448 +-  // We did not match this because of a using statement, so we will need to
  27.449 +-  // figure out how good a namespace match we have with our destination type.
  27.450 +-  // We work backwards (from most specific possible namespace to least
  27.451 +-  // specific).
  27.452 +-  return getBestNamespaceSubstr(UseContext, ReplacementString,
  27.453 +-                                isFullyQualified(Use));
  27.454 +-}
  27.455 ++        Diagnostics::Diagnostics(StringRef CheckName,
  27.456 ++                Diagnostics::Level DiagLevel,
  27.457 ++                bool IsWarningAsError,
  27.458 ++                StringRef BuildDirectory)
  27.459 ++        : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
  27.460 ++        IsWarningAsError(IsWarningAsError) {
  27.461 ++        }
  27.462 ++    }
  27.463 ++}
  27.464 +\ No newline at end of file
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/utils/AnalyticsTools.java	Tue May 30 15:29:39 2017 +0300
    28.3 @@ -0,0 +1,208 @@
    28.4 +/*
    28.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    28.6 + *
    28.7 + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
    28.8 + *
    28.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   28.10 + * Other names may be trademarks of their respective owners.
   28.11 + *
   28.12 + * The contents of this file are subject to the terms of either the GNU
   28.13 + * General Public License Version 2 only ("GPL") or the Common
   28.14 + * Development and Distribution License("CDDL") (collectively, the
   28.15 + * "License"). You may not use this file except in compliance with the
   28.16 + * License. You can obtain a copy of the License at
   28.17 + * http://www.netbeans.org/cddl-gplv2.html
   28.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   28.19 + * specific language governing permissions and limitations under the
   28.20 + * License.  When distributing the software, include this License Header
   28.21 + * Notice in each file and include the License file at
   28.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   28.23 + * particular file as subject to the "Classpath" exception as provided
   28.24 + * by Oracle in the GPL Version 2 section of the License file that
   28.25 + * accompanied this code. If applicable, add the following below the
   28.26 + * License Header, with the fields enclosed by brackets [] replaced by
   28.27 + * your own identifying information:
   28.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   28.29 + *
   28.30 + * If you wish your version of this file to be governed by only the CDDL
   28.31 + * or only the GPL Version 2, indicate your decision by adding
   28.32 + * "[Contributor] elects to include this software in this distribution
   28.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   28.34 + * single choice of license, a recipient has the option to distribute
   28.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   28.36 + * to extend the choice of license to its licensees as provided above.
   28.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   28.38 + * Version 2 license, then the option applies only if the new code is
   28.39 + * made subject to such option by the copyright holder.
   28.40 + *
   28.41 + * Contributor(s): Ilia Gromov
   28.42 + */
   28.43 +package org.netbeans.modules.ide.analysis.modernize.utils;
   28.44 +
   28.45 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeErrorProvider;
   28.46 +import java.util.ArrayList;
   28.47 +import java.util.List;
   28.48 +import org.netbeans.api.project.FileOwnerQuery;
   28.49 +import org.netbeans.api.project.Project;
   28.50 +import org.netbeans.modules.analysis.spi.Analyzer;
   28.51 +import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse;
   28.52 +import org.netbeans.modules.cnd.api.model.CsmFile;
   28.53 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   28.54 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   28.55 +import org.netbeans.modules.cnd.api.project.NativeFileItem;
   28.56 +import org.netbeans.modules.cnd.api.remote.RemoteProject;
   28.57 +import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
   28.58 +import org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind;
   28.59 +import org.netbeans.modules.cnd.api.toolchain.Tool;
   28.60 +import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider;
   28.61 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
   28.62 +import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
   28.63 +import org.netbeans.modules.cnd.spi.toolchain.ToolchainProject;
   28.64 +import org.netbeans.modules.cnd.utils.MIMENames;
   28.65 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
   28.66 +import org.openide.filesystems.FileObject;
   28.67 +import org.openide.util.Lookup;
   28.68 +
   28.69 +/**
   28.70 + *
   28.71 + * @author Ilia Gromov
   28.72 + */
   28.73 +public class AnalyticsTools {
   28.74 +
   28.75 +    public static ExecutionEnvironment detectEnvironment(Analyzer.Context context) {
   28.76 +        if (context.getScope() == null) {
   28.77 +            return null;
   28.78 +        }
   28.79 +        for (FileObject fo : context.getScope().getFiles()) {
   28.80 +            String mimeType = fo.getMIMEType();
   28.81 +            if (MIMENames.isHeaderOrCppOrC(mimeType)) {
   28.82 +                Project project = FileOwnerQuery.getOwner(fo);
   28.83 +                RemoteProject info = project.getLookup().lookup(RemoteProject.class);
   28.84 +                if (info != null) {
   28.85 +                    ExecutionEnvironment dh = info.getDevelopmentHost();
   28.86 +                    if (dh != null) {
   28.87 +                        return dh;
   28.88 +                    }
   28.89 +                }
   28.90 +            }
   28.91 +        }
   28.92 +        return null;
   28.93 +    }
   28.94 +
   28.95 +    public static CompilerSet toolchain(Lookup.Provider project) {
   28.96 +        ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class);
   28.97 +        if (toolchain != null) {
   28.98 +            return toolchain.getCompilerSet();
   28.99 +        }
  28.100 +        return null;
  28.101 +    }
  28.102 +
  28.103 +    public static MakeConfigurationDescriptor getConfigurationDescriptor(CsmFile file, Lookup.Provider project) {
  28.104 +        if (file != null) {
  28.105 +            ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class);
  28.106 +            if (pdp != null) {
  28.107 +                MakeConfigurationDescriptor makeConfigurationDescriptor = pdp.getConfigurationDescriptor();
  28.108 +                if (makeConfigurationDescriptor != null) {
  28.109 +                    return makeConfigurationDescriptor;
  28.110 +                }
  28.111 +            }
  28.112 +        }
  28.113 +
  28.114 +        return null;
  28.115 +    }
  28.116 +
  28.117 +    public static Item findItem(CsmFile file, Lookup.Provider project) {
  28.118 +        return getConfigurationDescriptor(file, project).findProjectItemByPath(file.getAbsolutePath().toString());
  28.119 +    }
  28.120 +
  28.121 +    public static void fatalError(AnalyzerResponse.AnalyzerSeverity severity, String id, String message, CsmFile file, CsmErrorProvider.Response response) {
  28.122 +        CsmErrorInfo fatal = new ModernizeErrorProvider.FatalErrorInfo(id, message);
  28.123 +        if (response instanceof AnalyzerResponse) {
  28.124 +            AnalyzerResponse ar = (AnalyzerResponse) response;
  28.125 +            ar.addError(severity, message, file.getFileObject(), fatal); //NOI18N
  28.126 +        } else {
  28.127 +            response.addError(fatal); //NOI18N
  28.128 +        }
  28.129 +    }
  28.130 +
  28.131 +    public static String useTool(Item item, Lookup.Provider project) {
  28.132 +        ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class);
  28.133 +        if (toolchain != null) {
  28.134 +            CompilerSet set = toolchain.getCompilerSet();
  28.135 +            if (set != null) {
  28.136 +                if (set.getCompilerFlavor().isSunStudioCompiler()) {
  28.137 +                    if (item.getLanguage() == NativeFileItem.Language.C) {
  28.138 +                        return set.findTool(PredefinedToolKind.CCompiler).getPath();
  28.139 +                    } else {
  28.140 +                        return set.findTool(PredefinedToolKind.CCCompiler).getPath();
  28.141 +                    }
  28.142 +                }
  28.143 +            }
  28.144 +        }
  28.145 +        return null;
  28.146 +    }
  28.147 +
  28.148 +    public static Tool compiler(Item item, Lookup.Provider project) {
  28.149 +        CompilerSet set = toolchain(project);
  28.150 +        if (set != null) {
  28.151 +            if (item.getLanguage() == NativeFileItem.Language.C) {
  28.152 +                return set.findTool(PredefinedToolKind.CCompiler);
  28.153 +            } else {
  28.154 +                return set.findTool(PredefinedToolKind.CCCompiler);
  28.155 +            }
  28.156 +        }
  28.157 +        return null;
  28.158 +    }
  28.159 +
  28.160 +    public static List<String> scanCommandLine(String line) {
  28.161 +        List<String> res = new ArrayList<String>();
  28.162 +        int i = 0;
  28.163 +        StringBuilder current = new StringBuilder();
  28.164 +        boolean isSingleQuoteMode = false;
  28.165 +        boolean isDoubleQuoteMode = false;
  28.166 +        while (i < line.length()) {
  28.167 +            char c = line.charAt(i);
  28.168 +            i++;
  28.169 +            switch (c) {
  28.170 +                case '\'': // NOI18N
  28.171 +                    if (isSingleQuoteMode) {
  28.172 +                        isSingleQuoteMode = false;
  28.173 +                    } else if (!isDoubleQuoteMode) {
  28.174 +                        isSingleQuoteMode = true;
  28.175 +                    }
  28.176 +                    current.append(c);
  28.177 +                    break;
  28.178 +                case '\"': // NOI18N
  28.179 +                    if (isDoubleQuoteMode) {
  28.180 +                        isDoubleQuoteMode = false;
  28.181 +                    } else if (!isSingleQuoteMode) {
  28.182 +                        isDoubleQuoteMode = true;
  28.183 +                    }
  28.184 +                    current.append(c);
  28.185 +                    break;
  28.186 +                case ' ': // NOI18N
  28.187 +                case '\t': // NOI18N
  28.188 +                case '\n': // NOI18N
  28.189 +                case '\r': // NOI18N
  28.190 +                    if (isSingleQuoteMode || isDoubleQuoteMode) {
  28.191 +                        current.append(c);
  28.192 +                        break;
  28.193 +                    } else {
  28.194 +                        if (current.length() > 0) {
  28.195 +                            res.add(current.toString());
  28.196 +                            current.setLength(0);
  28.197 +                        }
  28.198 +                    }
  28.199 +                    break;
  28.200 +                default:
  28.201 +                    current.append(c);
  28.202 +                    break;
  28.203 +            }
  28.204 +        }
  28.205 +        if (current.length() > 0) {
  28.206 +            res.add(current.toString());
  28.207 +        }
  28.208 +        return res;
  28.209 +    }
  28.210 +
  28.211 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt	Tue May 30 15:29:39 2017 +0300
    29.3 @@ -0,0 +1,2 @@
    29.4 +File clang-tidy-3.9p should be placed in this directory before testing.
    29.5 +(Won't commit large, ~25Mb binary file to Mercurial repo).
    29.6 \ No newline at end of file
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt	Tue May 30 15:29:39 2017 +0300
    30.3 @@ -0,0 +1,2 @@
    30.4 +project (HelloCMake CXX)
    30.5 +add_subdirectory (src)
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml	Tue May 30 15:29:39 2017 +0300
    31.3 @@ -0,0 +1,128 @@
    31.4 +<?xml version="1.0" encoding="UTF-8"?>
    31.5 +<!--
    31.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    31.7 +
    31.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
    31.9 +
   31.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   31.11 +Other names may be trademarks of their respective owners.
   31.12 +
   31.13 +The contents of this file are subject to the terms of either the GNU
   31.14 +General Public License Version 2 only ("GPL") or the Common
   31.15 +Development and Distribution License("CDDL") (collectively, the
   31.16 +"License"). You may not use this file except in compliance with the
   31.17 +License. You can obtain a copy of the License at
   31.18 +http://www.netbeans.org/cddl-gplv2.html
   31.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   31.20 +specific language governing permissions and limitations under the
   31.21 +License.  When distributing the software, include this License Header
   31.22 +Notice in each file and include the License file at
   31.23 +nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   31.24 +particular file as subject to the "Classpath" exception as provided
   31.25 +by Oracle in the GPL Version 2 section of the License file that
   31.26 +accompanied this code. If applicable, add the following below the
   31.27 +License Header, with the fields enclosed by brackets [] replaced by
   31.28 +your own identifying information:
   31.29 +"Portions Copyrighted [year] [name of copyright owner]"
   31.30 +
   31.31 +If you wish your version of this file to be governed by only the CDDL
   31.32 +or only the GPL Version 2, indicate your decision by adding
   31.33 +"[Contributor] elects to include this software in this distribution
   31.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
   31.35 +single choice of license, a recipient has the option to distribute
   31.36 +your version of this file under either the CDDL, the GPL Version 2 or
   31.37 +to extend the choice of license to its licensees as provided above.
   31.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
   31.39 +Version 2 license, then the option applies only if the new code is
   31.40 +made subject to such option by the copyright holder.
   31.41 +
   31.42 +Contributor(s):
   31.43 +-->
   31.44 +<configurationDescriptor version="100">
   31.45 +  <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
   31.46 +    <df root="." name="0">
   31.47 +      <df name="src">
   31.48 +        <in>llvm-header-guard.cpp</in>
   31.49 +      </df>
   31.50 +    </df>
   31.51 +    <logicalFolder name="ExternalFiles"
   31.52 +                   displayName="Important Files"
   31.53 +                   projectFiles="false"
   31.54 +                   kind="IMPORTANT_FILES_FOLDER">
   31.55 +      <itemPath>CMakeLists.txt</itemPath>
   31.56 +      <itemPath>build/Debug/Makefile</itemPath>
   31.57 +      <itemPath>build/Release/Makefile</itemPath>
   31.58 +    </logicalFolder>
   31.59 +  </logicalFolder>
   31.60 +  <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
   31.61 +  <sourceRootList>
   31.62 +    <Elem>.</Elem>
   31.63 +  </sourceRootList>
   31.64 +  <projectmakefile>build/Debug/Makefile</projectmakefile>
   31.65 +  <confs>
   31.66 +    <conf name="Debug" type="0">
   31.67 +      <toolsSet>
   31.68 +        <compilerSet>default</compilerSet>
   31.69 +        <dependencyChecking>false</dependencyChecking>
   31.70 +        <rebuildPropChanged>false</rebuildPropChanged>
   31.71 +      </toolsSet>
   31.72 +      <flagsDictionary>
   31.73 +        <element flagsID="0" commonFlags="-std=gnu++11"/>
   31.74 +      </flagsDictionary>
   31.75 +      <codeAssistance>
   31.76 +      </codeAssistance>
   31.77 +      <makefileType>
   31.78 +        <makeTool>
   31.79 +          <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
   31.80 +          <buildCommand>${MAKE} -f Makefile</buildCommand>
   31.81 +          <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
   31.82 +          <executablePath>build/Debug/src/welcome</executablePath>
   31.83 +          <ccTool flags="0">
   31.84 +            <incDir>
   31.85 +              <pElem>build/Debug/src</pElem>
   31.86 +            </incDir>
   31.87 +          </ccTool>
   31.88 +        </makeTool>
   31.89 +        <preBuild>
   31.90 +          <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
   31.91 +          <preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..</preBuildCommand>
   31.92 +          <preBuildFirst>true</preBuildFirst>
   31.93 +        </preBuild>
   31.94 +      </makefileType>
   31.95 +      <item path="src/llvm-header-guard.cpp" ex="false" tool="1" flavor2="8">
   31.96 +        <ccTool flags="0">
   31.97 +        </ccTool>
   31.98 +      </item>
   31.99 +    </conf>
  31.100 +    <conf name="Release" type="0">
  31.101 +      <toolsSet>
  31.102 +        <compilerSet>default</compilerSet>
  31.103 +        <dependencyChecking>false</dependencyChecking>
  31.104 +        <rebuildPropChanged>false</rebuildPropChanged>
  31.105 +      </toolsSet>
  31.106 +      <codeAssistance>
  31.107 +      </codeAssistance>
  31.108 +      <makefileType>
  31.109 +        <makeTool>
  31.110 +          <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
  31.111 +          <buildCommand>${MAKE} -f Makefile</buildCommand>
  31.112 +          <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
  31.113 +          <executablePath>build/Release/src/welcome</executablePath>
  31.114 +          <ccTool>
  31.115 +            <incDir>
  31.116 +              <pElem>build/Release/src</pElem>
  31.117 +            </incDir>
  31.118 +            <preprocessorList>
  31.119 +              <Elem>NDEBUG</Elem>
  31.120 +            </preprocessorList>
  31.121 +          </ccTool>
  31.122 +        </makeTool>
  31.123 +        <preBuild>
  31.124 +          <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
  31.125 +          <preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..</preBuildCommand>
  31.126 +          <preBuildFirst>true</preBuildFirst>
  31.127 +        </preBuild>
  31.128 +      </makefileType>
  31.129 +    </conf>
  31.130 +  </confs>
  31.131 +</configurationDescriptor>
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml	Tue May 30 15:29:39 2017 +0300
    32.3 @@ -0,0 +1,72 @@
    32.4 +<?xml version="1.0" encoding="UTF-8"?>
    32.5 +<!--
    32.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    32.7 +
    32.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
    32.9 +
   32.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   32.11 +Other names may be trademarks of their respective owners.
   32.12 +
   32.13 +The contents of this file are subject to the terms of either the GNU
   32.14 +General Public License Version 2 only ("GPL") or the Common
   32.15 +Development and Distribution License("CDDL") (collectively, the
   32.16 +"License"). You may not use this file except in compliance with the
   32.17 +License. You can obtain a copy of the License at
   32.18 +http://www.netbeans.org/cddl-gplv2.html
   32.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   32.20 +specific language governing permissions and limitations under the
   32.21 +License.  When distributing the software, include this License Header
   32.22 +Notice in each file and include the License file at
   32.23 +nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   32.24 +particular file as subject to the "Classpath" exception as provided
   32.25 +by Oracle in the GPL Version 2 section of the License file that
   32.26 +accompanied this code. If applicable, add the following below the
   32.27 +License Header, with the fields enclosed by brackets [] replaced by
   32.28 +your own identifying information:
   32.29 +"Portions Copyrighted [year] [name of copyright owner]"
   32.30 +
   32.31 +If you wish your version of this file to be governed by only the CDDL
   32.32 +or only the GPL Version 2, indicate your decision by adding
   32.33 +"[Contributor] elects to include this software in this distribution
   32.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
   32.35 +single choice of license, a recipient has the option to distribute
   32.36 +your version of this file under either the CDDL, the GPL Version 2 or
   32.37 +to extend the choice of license to its licensees as provided above.
   32.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
   32.39 +Version 2 license, then the option applies only if the new code is
   32.40 +made subject to such option by the copyright holder.
   32.41 +
   32.42 +Contributor(s):
   32.43 +-->
   32.44 +<project xmlns="http://www.netbeans.org/ns/project/1">
   32.45 +    <type>org.netbeans.modules.cnd.makeproject</type>
   32.46 +    <configuration>
   32.47 +        <data xmlns="http://www.netbeans.org/ns/make-project/1">
   32.48 +            <name>hello-cmake-world</name>
   32.49 +            <c-extensions/>
   32.50 +            <cpp-extensions>cpp</cpp-extensions>
   32.51 +            <header-extensions>h</header-extensions>
   32.52 +            <sourceEncoding>UTF-8</sourceEncoding>
   32.53 +            <sourceRootList>
   32.54 +                <sourceRootElem>.</sourceRootElem>
   32.55 +            </sourceRootList>
   32.56 +            <make-dep-projects/>
   32.57 +            <sourceRootList>
   32.58 +                <sourceRootElem>.</sourceRootElem>
   32.59 +            </sourceRootList>
   32.60 +            <confList>
   32.61 +                <confElem>
   32.62 +                    <name>Debug</name>
   32.63 +                    <type>0</type>
   32.64 +                </confElem>
   32.65 +                <confElem>
   32.66 +                    <name>Release</name>
   32.67 +                    <type>0</type>
   32.68 +                </confElem>
   32.69 +            </confList>
   32.70 +            <formatting>
   32.71 +                <project-formatting-style>false</project-formatting-style>
   32.72 +            </formatting>
   32.73 +        </data>
   32.74 +    </configuration>
   32.75 +</project>
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt	Tue May 30 15:29:39 2017 +0300
    33.3 @@ -0,0 +1,2 @@
    33.4 +set(CMAKE_CXX_STANDARD 11)
    33.5 +add_library (headers llvm-header-guard.cpp)
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp	Tue May 30 15:29:39 2017 +0300
    34.3 @@ -0,0 +1,1 @@
    34.4 +#include "llvm-header-guard.h"
    34.5 \ No newline at end of file
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt	Tue May 30 15:29:39 2017 +0300
    35.3 @@ -0,0 +1,2 @@
    35.4 +project (HelloCMake)
    35.5 +add_subdirectory (src)
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml	Tue May 30 15:29:39 2017 +0300
    36.3 @@ -0,0 +1,143 @@
    36.4 +<?xml version="1.0" encoding="UTF-8"?>
    36.5 +<!--
    36.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    36.7 +
    36.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
    36.9 +
   36.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   36.11 +Other names may be trademarks of their respective owners.
   36.12 +
   36.13 +The contents of this file are subject to the terms of either the GNU
   36.14 +General Public License Version 2 only ("GPL") or the Common
   36.15 +Development and Distribution License("CDDL") (collectively, the
   36.16 +"License"). You may not use this file except in compliance with the
   36.17 +License. You can obtain a copy of the License at
   36.18 +http://www.netbeans.org/cddl-gplv2.html
   36.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   36.20 +specific language governing permissions and limitations under the
   36.21 +License.  When distributing the software, include this License Header
   36.22 +Notice in each file and include the License file at
   36.23 +nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   36.24 +particular file as subject to the "Classpath" exception as provided
   36.25 +by Oracle in the GPL Version 2 section of the License file that
   36.26 +accompanied this code. If applicable, add the following below the
   36.27 +License Header, with the fields enclosed by brackets [] replaced by
   36.28 +your own identifying information:
   36.29 +"Portions Copyrighted [year] [name of copyright owner]"
   36.30 +
   36.31 +If you wish your version of this file to be governed by only the CDDL
   36.32 +or only the GPL Version 2, indicate your decision by adding
   36.33 +"[Contributor] elects to include this software in this distribution
   36.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
   36.35 +single choice of license, a recipient has the option to distribute
   36.36 +your version of this file under either the CDDL, the GPL Version 2 or
   36.37 +to extend the choice of license to its licensees as provided above.
   36.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
   36.39 +Version 2 license, then the option applies only if the new code is
   36.40 +made subject to such option by the copyright holder.
   36.41 +
   36.42 +Contributor(s):
   36.43 +-->
   36.44 +<configurationDescriptor version="100">
   36.45 +  <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
   36.46 +    <df root="." name="0">
   36.47 +      <df name="src">
   36.48 +        <in>modernize-loop-convert.cpp</in>
   36.49 +        <in>modernize-raw-string-literal.cpp</in>
   36.50 +        <in>modernize-use-nullptr.cpp</in>
   36.51 +      </df>
   36.52 +    </df>
   36.53 +    <logicalFolder name="ExternalFiles"
   36.54 +                   displayName="Important Files"
   36.55 +                   projectFiles="false"
   36.56 +                   kind="IMPORTANT_FILES_FOLDER">
   36.57 +      <itemPath>CMakeLists.txt</itemPath>
   36.58 +      <itemPath>build/Debug/Makefile</itemPath>
   36.59 +      <itemPath>build/Release/Makefile</itemPath>
   36.60 +    </logicalFolder>
   36.61 +  </logicalFolder>
   36.62 +  <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
   36.63 +  <sourceRootList>
   36.64 +    <Elem>.</Elem>
   36.65 +  </sourceRootList>
   36.66 +  <projectmakefile>build/Debug/Makefile</projectmakefile>
   36.67 +  <confs>
   36.68 +    <conf name="Debug" type="0">
   36.69 +      <toolsSet>
   36.70 +        <compilerSet>default</compilerSet>
   36.71 +        <dependencyChecking>false</dependencyChecking>
   36.72 +        <rebuildPropChanged>false</rebuildPropChanged>
   36.73 +      </toolsSet>
   36.74 +      <flagsDictionary>
   36.75 +        <element flagsID="0" commonFlags="-std=gnu++11"/>
   36.76 +      </flagsDictionary>
   36.77 +      <codeAssistance>
   36.78 +      </codeAssistance>
   36.79 +      <makefileType>
   36.80 +        <makeTool>
   36.81 +          <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
   36.82 +          <buildCommand>${MAKE} -f Makefile</buildCommand>
   36.83 +          <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
   36.84 +          <executablePath>build/Debug/src/welcome</executablePath>
   36.85 +          <ccTool flags="0">
   36.86 +            <incDir>
   36.87 +              <pElem>build/Debug/src</pElem>
   36.88 +            </incDir>
   36.89 +          </ccTool>
   36.90 +        </makeTool>
   36.91 +        <preBuild>
   36.92 +          <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
   36.93 +          <preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..</preBuildCommand>
   36.94 +          <preBuildFirst>true</preBuildFirst>
   36.95 +        </preBuild>
   36.96 +      </makefileType>
   36.97 +      <item path="src/modernize-loop-convert.cpp" ex="false" tool="1" flavor2="8">
   36.98 +        <ccTool flags="0">
   36.99 +        </ccTool>
  36.100 +      </item>
  36.101 +      <item path="src/modernize-raw-string-literal.cpp"
  36.102 +            ex="false"
  36.103 +            tool="1"
  36.104 +            flavor2="8">
  36.105 +        <ccTool flags="0">
  36.106 +        </ccTool>
  36.107 +      </item>
  36.108 +      <item path="src/modernize-use-nullptr.cpp" ex="false" tool="1" flavor2="8">
  36.109 +        <ccTool flags="0">
  36.110 +        </ccTool>
  36.111 +      </item>
  36.112 +    </conf>
  36.113 +    <conf name="Release" type="0">
  36.114 +      <toolsSet>
  36.115 +        <compilerSet>default</compilerSet>
  36.116 +        <dependencyChecking>false</dependencyChecking>
  36.117 +        <rebuildPropChanged>false</rebuildPropChanged>
  36.118 +      </toolsSet>
  36.119 +      <codeAssistance>
  36.120 +      </codeAssistance>
  36.121 +      <makefileType>
  36.122 +        <makeTool>
  36.123 +          <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
  36.124 +          <buildCommand>${MAKE} -f Makefile</buildCommand>
  36.125 +          <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
  36.126 +          <executablePath>build/Release/src/welcome</executablePath>
  36.127 +          <ccTool>
  36.128 +            <incDir>
  36.129 +              <pElem>build/Release/src</pElem>
  36.130 +            </incDir>
  36.131 +            <preprocessorList>
  36.132 +              <Elem>NDEBUG</Elem>
  36.133 +            </preprocessorList>
  36.134 +          </ccTool>
  36.135 +        </makeTool>
  36.136 +        <preBuild>
  36.137 +          <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
  36.138 +          <preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..</preBuildCommand>
  36.139 +          <preBuildFirst>true</preBuildFirst>
  36.140 +        </preBuild>
  36.141 +      </makefileType>
  36.142 +      <item path="src/modernize-use-nullptr.cpp" ex="false" tool="1" flavor2="0">
  36.143 +      </item>
  36.144 +    </conf>
  36.145 +  </confs>
  36.146 +</configurationDescriptor>
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml	Tue May 30 15:29:39 2017 +0300
    37.3 @@ -0,0 +1,72 @@
    37.4 +<?xml version="1.0" encoding="UTF-8"?>
    37.5 +<!--
    37.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    37.7 +
    37.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
    37.9 +
   37.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   37.11 +Other names may be trademarks of their respective owners.
   37.12 +
   37.13 +The contents of this file are subject to the terms of either the GNU
   37.14 +General Public License Version 2 only ("GPL") or the Common
   37.15 +Development and Distribution License("CDDL") (collectively, the
   37.16 +"License"). You may not use this file except in compliance with the
   37.17 +License. You can obtain a copy of the License at
   37.18 +http://www.netbeans.org/cddl-gplv2.html
   37.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   37.20 +specific language governing permissions and limitations under the
   37.21 +License.  When distributing the software, include this License Header
   37.22 +Notice in each file and include the License file at
   37.23 +nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   37.24 +particular file as subject to the "Classpath" exception as provided
   37.25 +by Oracle in the GPL Version 2 section of the License file that
   37.26 +accompanied this code. If applicable, add the following below the
   37.27 +License Header, with the fields enclosed by brackets [] replaced by
   37.28 +your own identifying information:
   37.29 +"Portions Copyrighted [year] [name of copyright owner]"
   37.30 +
   37.31 +If you wish your version of this file to be governed by only the CDDL
   37.32 +or only the GPL Version 2, indicate your decision by adding
   37.33 +"[Contributor] elects to include this software in this distribution
   37.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
   37.35 +single choice of license, a recipient has the option to distribute
   37.36 +your version of this file under either the CDDL, the GPL Version 2 or
   37.37 +to extend the choice of license to its licensees as provided above.
   37.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
   37.39 +Version 2 license, then the option applies only if the new code is
   37.40 +made subject to such option by the copyright holder.
   37.41 +
   37.42 +Contributor(s):
   37.43 +-->
   37.44 +<project xmlns="http://www.netbeans.org/ns/project/1">
   37.45 +    <type>org.netbeans.modules.cnd.makeproject</type>
   37.46 +    <configuration>
   37.47 +        <data xmlns="http://www.netbeans.org/ns/make-project/1">
   37.48 +            <name>hello-cmake-world</name>
   37.49 +            <c-extensions/>
   37.50 +            <cpp-extensions>cpp</cpp-extensions>
   37.51 +            <header-extensions>h</header-extensions>
   37.52 +            <sourceEncoding>UTF-8</sourceEncoding>
   37.53 +            <sourceRootList>
   37.54 +                <sourceRootElem>.</sourceRootElem>
   37.55 +            </sourceRootList>
   37.56 +            <make-dep-projects/>
   37.57 +            <sourceRootList>
   37.58 +                <sourceRootElem>.</sourceRootElem>
   37.59 +            </sourceRootList>
   37.60 +            <confList>
   37.61 +                <confElem>
   37.62 +                    <name>Debug</name>
   37.63 +                    <type>0</type>
   37.64 +                </confElem>
   37.65 +                <confElem>
   37.66 +                    <name>Release</name>
   37.67 +                    <type>0</type>
   37.68 +                </confElem>
   37.69 +            </confList>
   37.70 +            <formatting>
   37.71 +                <project-formatting-style>false</project-formatting-style>
   37.72 +            </formatting>
   37.73 +        </data>
   37.74 +    </configuration>
   37.75 +</project>
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt	Tue May 30 15:29:39 2017 +0300
    38.3 @@ -0,0 +1,2 @@
    38.4 +set(CMAKE_CXX_STANDARD 11)
    38.5 +add_library (single-cpp-file-check modernize-use-nullptr.cpp modernize-loop-convert.cpp modernize-raw-string-literal.cpp)
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp	Tue May 30 15:29:39 2017 +0300
    39.3 @@ -0,0 +1,1 @@
    39.4 +#include "llvm-header-guard.h"
    39.5 \ No newline at end of file
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp	Tue May 30 15:29:39 2017 +0300
    40.3 @@ -0,0 +1,25 @@
    40.4 +#include <vector>
    40.5 +#include <iostream>
    40.6 +
    40.7 +using namespace std;
    40.8 +
    40.9 +int loops() {
   40.10 +    const int N = 5;
   40.11 +    int arr[] = {1, 2, 3, 4, 5};
   40.12 +    vector<int> v;
   40.13 +    v.push_back(1);
   40.14 +    v.push_back(2);
   40.15 +    v.push_back(3);
   40.16 +
   40.17 +    // safe conversion
   40.18 +    for (int i = 0; i < N; ++i)
   40.19 +        cout << arr[i];
   40.20 + 
   40.21 +    // reasonable conversion
   40.22 +    for (vector<int>::iterator it = v.begin(); it != v.end(); ++it)
   40.23 +        cout << *it;
   40.24 +
   40.25 +    // reasonable conversion
   40.26 +    for (int i = 0; i < v.size(); ++i)
   40.27 +        cout << v[i];
   40.28 +}    
   40.29 \ No newline at end of file
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp	Tue May 30 15:29:39 2017 +0300
    41.3 @@ -0,0 +1,8 @@
    41.4 +const char *const Quotes{"embedded \"quotes\""};
    41.5 +const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"};
    41.6 +const char *const SingleLine{"Single line.\n"};
    41.7 +const char *const TrailingSpace{"Look here -> \n"};
    41.8 +const char *const Tab{"One\tTwo\n"};
    41.9 +const char *const Bell{"Hello!\a  And welcome!"};
   41.10 +const char *const Path{"C:\\Program Files\\Vendor\\Application.exe"};
   41.11 +const char *const RegEx{"\\w\\([a-z]\\)"};
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp	Tue May 30 15:29:39 2017 +0300
    42.3 @@ -0,0 +1,11 @@
    42.4 +#include <cstddef>
    42.5 +
    42.6 +void assignment() {
    42.7 +  char *a = NULL;
    42.8 +  char *b = 0;
    42.9 +  char c = 0;
   42.10 +}
   42.11 +
   42.12 +int *ret_ptr() {
   42.13 +  return 0;
   42.14 +}
   42.15 \ No newline at end of file
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/.dep.inc	Tue May 30 15:29:39 2017 +0300
    43.3 @@ -0,0 +1,5 @@
    43.4 +# This code depends on make tool being used
    43.5 +DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES}))
    43.6 +ifneq (${DEPFILES},)
    43.7 +include ${DEPFILES}
    43.8 +endif
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/Makefile	Tue May 30 15:29:39 2017 +0300
    44.3 @@ -0,0 +1,128 @@
    44.4 +#
    44.5 +#  There exist several targets which are by default empty and which can be 
    44.6 +#  used for execution of your targets. These targets are usually executed 
    44.7 +#  before and after some main targets. They are: 
    44.8 +#
    44.9 +#     .build-pre:              called before 'build' target
   44.10 +#     .build-post:             called after 'build' target
   44.11 +#     .clean-pre:              called before 'clean' target
   44.12 +#     .clean-post:             called after 'clean' target
   44.13 +#     .clobber-pre:            called before 'clobber' target
   44.14 +#     .clobber-post:           called after 'clobber' target
   44.15 +#     .all-pre:                called before 'all' target
   44.16 +#     .all-post:               called after 'all' target
   44.17 +#     .help-pre:               called before 'help' target
   44.18 +#     .help-post:              called after 'help' target
   44.19 +#
   44.20 +#  Targets beginning with '.' are not intended to be called on their own.
   44.21 +#
   44.22 +#  Main targets can be executed directly, and they are:
   44.23 +#  
   44.24 +#     build                    build a specific configuration
   44.25 +#     clean                    remove built files from a configuration
   44.26 +#     clobber                  remove all built files
   44.27 +#     all                      build all configurations
   44.28 +#     help                     print help mesage
   44.29 +#  
   44.30 +#  Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
   44.31 +#  .help-impl are implemented in nbproject/makefile-impl.mk.
   44.32 +#
   44.33 +#  Available make variables:
   44.34 +#
   44.35 +#     CND_BASEDIR                base directory for relative paths
   44.36 +#     CND_DISTDIR                default top distribution directory (build artifacts)
   44.37 +#     CND_BUILDDIR               default top build directory (object files, ...)
   44.38 +#     CONF                       name of current configuration
   44.39 +#     CND_PLATFORM_${CONF}       platform name (current configuration)
   44.40 +#     CND_ARTIFACT_DIR_${CONF}   directory of build artifact (current configuration)
   44.41 +#     CND_ARTIFACT_NAME_${CONF}  name of build artifact (current configuration)
   44.42 +#     CND_ARTIFACT_PATH_${CONF}  path to build artifact (current configuration)
   44.43 +#     CND_PACKAGE_DIR_${CONF}    directory of package (current configuration)
   44.44 +#     CND_PACKAGE_NAME_${CONF}   name of package (current configuration)
   44.45 +#     CND_PACKAGE_PATH_${CONF}   path to package (current configuration)
   44.46 +#
   44.47 +# NOCDDL
   44.48 +
   44.49 +
   44.50 +# Environment 
   44.51 +MKDIR=mkdir
   44.52 +CP=cp
   44.53 +CCADMIN=CCadmin
   44.54 +
   44.55 +
   44.56 +# build
   44.57 +build: .build-post
   44.58 +
   44.59 +.build-pre:
   44.60 +# Add your pre 'build' code here...
   44.61 +
   44.62 +.build-post: .build-impl
   44.63 +# Add your post 'build' code here...
   44.64 +
   44.65 +
   44.66 +# clean
   44.67 +clean: .clean-post
   44.68 +
   44.69 +.clean-pre:
   44.70 +# Add your pre 'clean' code here...
   44.71 +
   44.72 +.clean-post: .clean-impl
   44.73 +# Add your post 'clean' code here...
   44.74 +
   44.75 +
   44.76 +# clobber
   44.77 +clobber: .clobber-post
   44.78 +
   44.79 +.clobber-pre:
   44.80 +# Add your pre 'clobber' code here...
   44.81 +
   44.82 +.clobber-post: .clobber-impl
   44.83 +# Add your post 'clobber' code here...
   44.84 +
   44.85 +
   44.86 +# all
   44.87 +all: .all-post
   44.88 +
   44.89 +.all-pre:
   44.90 +# Add your pre 'all' code here...
   44.91 +
   44.92 +.all-post: .all-impl
   44.93 +# Add your post 'all' code here...
   44.94 +
   44.95 +
   44.96 +# build tests
   44.97 +build-tests: .build-tests-post
   44.98 +
   44.99 +.build-tests-pre:
  44.100 +# Add your pre 'build-tests' code here...
  44.101 +
  44.102 +.build-tests-post: .build-tests-impl
  44.103 +# Add your post 'build-tests' code here...
  44.104 +
  44.105 +
  44.106 +# run tests
  44.107 +test: .test-post
  44.108 +
  44.109 +.test-pre: build-tests
  44.110 +# Add your pre 'test' code here...
  44.111 +
  44.112 +.test-post: .test-impl
  44.113 +# Add your post 'test' code here...
  44.114 +
  44.115 +
  44.116 +# help
  44.117 +help: .help-post
  44.118 +
  44.119 +.help-pre:
  44.120 +# Add your pre 'help' code here...
  44.121 +
  44.122 +.help-post: .help-impl
  44.123 +# Add your post 'help' code here...
  44.124 +
  44.125 +
  44.126 +
  44.127 +# include project implementation makefile
  44.128 +include nbproject/Makefile-impl.mk
  44.129 +
  44.130 +# include project make variables
  44.131 +include nbproject/Makefile-variables.mk
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk	Tue May 30 15:29:39 2017 +0300
    45.3 @@ -0,0 +1,83 @@
    45.4 +#
    45.5 +# Generated Makefile - do not edit!
    45.6 +#
    45.7 +# Edit the Makefile in the project folder instead (../Makefile). Each target
    45.8 +# has a -pre and a -post target defined where you can add customized code.
    45.9 +#
   45.10 +# This makefile implements configuration specific macros and targets.
   45.11 +
   45.12 +
   45.13 +# Environment
   45.14 +MKDIR=mkdir
   45.15 +CP=cp
   45.16 +GREP=grep
   45.17 +NM=nm
   45.18 +CCADMIN=CCadmin
   45.19 +RANLIB=ranlib
   45.20 +CC=gcc
   45.21 +CCC=g++
   45.22 +CXX=g++
   45.23 +FC=gfortran
   45.24 +AS=as
   45.25 +
   45.26 +# Macros
   45.27 +CND_PLATFORM=GNU-Linux
   45.28 +CND_DLIB_EXT=so
   45.29 +CND_CONF=Debug
   45.30 +CND_DISTDIR=dist
   45.31 +CND_BUILDDIR=build
   45.32 +
   45.33 +# Include project Makefile
   45.34 +include Makefile
   45.35 +
   45.36 +# Object Directory
   45.37 +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
   45.38 +
   45.39 +# Object Files
   45.40 +OBJECTFILES= \
   45.41 +	${OBJECTDIR}/welcome.o
   45.42 +
   45.43 +
   45.44 +# C Compiler Flags
   45.45 +CFLAGS=
   45.46 +
   45.47 +# CC Compiler Flags
   45.48 +CCFLAGS=
   45.49 +CXXFLAGS=
   45.50 +
   45.51 +# Fortran Compiler Flags
   45.52 +FFLAGS=
   45.53 +
   45.54 +# Assembler Flags
   45.55 +ASFLAGS=
   45.56 +
   45.57 +# Link Libraries and Options
   45.58 +LDLIBSOPTIONS=
   45.59 +
   45.60 +# Build Targets
   45.61 +.build-conf: ${BUILD_SUBPROJECTS}
   45.62 +	"${MAKE}"  -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
   45.63 +
   45.64 +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES}
   45.65 +	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
   45.66 +	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS}
   45.67 +
   45.68 +${OBJECTDIR}/welcome.o: welcome.cc
   45.69 +	${MKDIR} -p ${OBJECTDIR}
   45.70 +	${RM} "$@.d"
   45.71 +	$(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc
   45.72 +
   45.73 +# Subprojects
   45.74 +.build-subprojects:
   45.75 +
   45.76 +# Clean Targets
   45.77 +.clean-conf: ${CLEAN_SUBPROJECTS}
   45.78 +	${RM} -r ${CND_BUILDDIR}/${CND_CONF}
   45.79 +
   45.80 +# Subprojects
   45.81 +.clean-subprojects:
   45.82 +
   45.83 +# Enable dependency checking
   45.84 +.dep.inc: .depcheck-impl
   45.85 +
   45.86 +include .dep.inc
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk	Tue May 30 15:29:39 2017 +0300
    46.3 @@ -0,0 +1,83 @@
    46.4 +#
    46.5 +# Generated Makefile - do not edit!
    46.6 +#
    46.7 +# Edit the Makefile in the project folder instead (../Makefile). Each target
    46.8 +# has a -pre and a -post target defined where you can add customized code.
    46.9 +#
   46.10 +# This makefile implements configuration specific macros and targets.
   46.11 +
   46.12 +
   46.13 +# Environment
   46.14 +MKDIR=mkdir
   46.15 +CP=cp
   46.16 +GREP=grep
   46.17 +NM=nm
   46.18 +CCADMIN=CCadmin
   46.19 +RANLIB=ranlib
   46.20 +CC=gcc
   46.21 +CCC=g++
   46.22 +CXX=g++
   46.23 +FC=gfortran
   46.24 +AS=as
   46.25 +
   46.26 +# Macros
   46.27 +CND_PLATFORM=GNU-Linux
   46.28 +CND_DLIB_EXT=so
   46.29 +CND_CONF=Release
   46.30 +CND_DISTDIR=dist
   46.31 +CND_BUILDDIR=build
   46.32 +
   46.33 +# Include project Makefile
   46.34 +include Makefile
   46.35 +
   46.36 +# Object Directory
   46.37 +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
   46.38 +
   46.39 +# Object Files
   46.40 +OBJECTFILES= \
   46.41 +	${OBJECTDIR}/welcome.o
   46.42 +
   46.43 +
   46.44 +# C Compiler Flags
   46.45 +CFLAGS=
   46.46 +
   46.47 +# CC Compiler Flags
   46.48 +CCFLAGS=
   46.49 +CXXFLAGS=
   46.50 +
   46.51 +# Fortran Compiler Flags
   46.52 +FFLAGS=
   46.53 +
   46.54 +# Assembler Flags
   46.55 +ASFLAGS=
   46.56 +
   46.57 +# Link Libraries and Options
   46.58 +LDLIBSOPTIONS=
   46.59 +
   46.60 +# Build Targets
   46.61 +.build-conf: ${BUILD_SUBPROJECTS}
   46.62 +	"${MAKE}"  -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
   46.63 +
   46.64 +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES}
   46.65 +	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
   46.66 +	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS}
   46.67 +
   46.68 +${OBJECTDIR}/welcome.o: welcome.cc
   46.69 +	${MKDIR} -p ${OBJECTDIR}
   46.70 +	${RM} "$@.d"
   46.71 +	$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc
   46.72 +
   46.73 +# Subprojects
   46.74 +.build-subprojects:
   46.75 +
   46.76 +# Clean Targets
   46.77 +.clean-conf: ${CLEAN_SUBPROJECTS}
   46.78 +	${RM} -r ${CND_BUILDDIR}/${CND_CONF}
   46.79 +
   46.80 +# Subprojects
   46.81 +.clean-subprojects:
   46.82 +
   46.83 +# Enable dependency checking
   46.84 +.dep.inc: .depcheck-impl
   46.85 +
   46.86 +include .dep.inc
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk	Tue May 30 15:29:39 2017 +0300
    47.3 @@ -0,0 +1,133 @@
    47.4 +# 
    47.5 +# Generated Makefile - do not edit! 
    47.6 +# 
    47.7 +# Edit the Makefile in the project folder instead (../Makefile). Each target
    47.8 +# has a pre- and a post- target defined where you can add customization code.
    47.9 +#
   47.10 +# This makefile implements macros and targets common to all configurations.
   47.11 +#
   47.12 +# NOCDDL
   47.13 +
   47.14 +
   47.15 +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
   47.16 +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
   47.17 +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
   47.18 +# and .clean-reqprojects-conf unless SUB has the value 'no'
   47.19 +SUB_no=NO
   47.20 +SUBPROJECTS=${SUB_${SUB}}
   47.21 +BUILD_SUBPROJECTS_=.build-subprojects
   47.22 +BUILD_SUBPROJECTS_NO=
   47.23 +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
   47.24 +CLEAN_SUBPROJECTS_=.clean-subprojects
   47.25 +CLEAN_SUBPROJECTS_NO=
   47.26 +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
   47.27 +
   47.28 +
   47.29 +# Project Name
   47.30 +PROJECTNAME=hello-world
   47.31 +
   47.32 +# Active Configuration
   47.33 +DEFAULTCONF=Debug
   47.34 +CONF=${DEFAULTCONF}
   47.35 +
   47.36 +# All Configurations
   47.37 +ALLCONFS=Debug Release 
   47.38 +
   47.39 +
   47.40 +# build
   47.41 +.build-impl: .build-pre .validate-impl .depcheck-impl
   47.42 +	@#echo "=> Running $@... Configuration=$(CONF)"
   47.43 +	"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
   47.44 +
   47.45 +
   47.46 +# clean
   47.47 +.clean-impl: .clean-pre .validate-impl .depcheck-impl
   47.48 +	@#echo "=> Running $@... Configuration=$(CONF)"
   47.49 +	"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
   47.50 +
   47.51 +
   47.52 +# clobber 
   47.53 +.clobber-impl: .clobber-pre .depcheck-impl
   47.54 +	@#echo "=> Running $@..."
   47.55 +	for CONF in ${ALLCONFS}; \
   47.56 +	do \
   47.57 +	    "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
   47.58 +	done
   47.59 +
   47.60 +# all 
   47.61 +.all-impl: .all-pre .depcheck-impl
   47.62 +	@#echo "=> Running $@..."
   47.63 +	for CONF in ${ALLCONFS}; \
   47.64 +	do \
   47.65 +	    "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
   47.66 +	done
   47.67 +
   47.68 +# build tests
   47.69 +.build-tests-impl: .build-impl .build-tests-pre
   47.70 +	@#echo "=> Running $@... Configuration=$(CONF)"
   47.71 +	"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
   47.72 +
   47.73 +# run tests
   47.74 +.test-impl: .build-tests-impl .test-pre
   47.75 +	@#echo "=> Running $@... Configuration=$(CONF)"
   47.76 +	"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
   47.77 +
   47.78 +# dependency checking support
   47.79 +.depcheck-impl:
   47.80 +	@echo "# This code depends on make tool being used" >.dep.inc
   47.81 +	@if [ -n "${MAKE_VERSION}" ]; then \
   47.82 +	    echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
   47.83 +	    echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
   47.84 +	    echo "include \$${DEPFILES}" >>.dep.inc; \
   47.85 +	    echo "endif" >>.dep.inc; \
   47.86 +	else \
   47.87 +	    echo ".KEEP_STATE:" >>.dep.inc; \
   47.88 +	    echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
   47.89 +	fi
   47.90 +
   47.91 +# configuration validation
   47.92 +.validate-impl:
   47.93 +	@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
   47.94 +	then \
   47.95 +	    echo ""; \
   47.96 +	    echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
   47.97 +	    echo "See 'make help' for details."; \
   47.98 +	    echo "Current directory: " `pwd`; \
   47.99 +	    echo ""; \
  47.100 +	fi
  47.101 +	@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
  47.102 +	then \
  47.103 +	    exit 1; \
  47.104 +	fi
  47.105 +
  47.106 +
  47.107 +# help
  47.108 +.help-impl: .help-pre
  47.109 +	@echo "This makefile supports the following configurations:"
  47.110 +	@echo "    ${ALLCONFS}"
  47.111 +	@echo ""
  47.112 +	@echo "and the following targets:"
  47.113 +	@echo "    build  (default target)"
  47.114 +	@echo "    clean"
  47.115 +	@echo "    clobber"
  47.116 +	@echo "    all"
  47.117 +	@echo "    help"
  47.118 +	@echo ""
  47.119 +	@echo "Makefile Usage:"
  47.120 +	@echo "    make [CONF=<CONFIGURATION>] [SUB=no] build"
  47.121 +	@echo "    make [CONF=<CONFIGURATION>] [SUB=no] clean"
  47.122 +	@echo "    make [SUB=no] clobber"
  47.123 +	@echo "    make [SUB=no] all"
  47.124 +	@echo "    make help"
  47.125 +	@echo ""
  47.126 +	@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
  47.127 +	@echo "    also build subprojects."
  47.128 +	@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
  47.129 +	@echo "    also clean subprojects."
  47.130 +	@echo "Target 'clobber' will remove all built files from all configurations and,"
  47.131 +	@echo "    unless 'SUB=no', also from subprojects."
  47.132 +	@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
  47.133 +	@echo "    also build subprojects."
  47.134 +	@echo "Target 'help' prints this message."
  47.135 +	@echo ""
  47.136 +
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk	Tue May 30 15:29:39 2017 +0300
    48.3 @@ -0,0 +1,35 @@
    48.4 +#
    48.5 +# Generated - do not edit!
    48.6 +#
    48.7 +# NOCDDL
    48.8 +#
    48.9 +CND_BASEDIR=`pwd`
   48.10 +CND_BUILDDIR=build
   48.11 +CND_DISTDIR=dist
   48.12 +# Debug configuration
   48.13 +CND_PLATFORM_Debug=GNU-Linux
   48.14 +CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux
   48.15 +CND_ARTIFACT_NAME_Debug=hello-world
   48.16 +CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/hello-world
   48.17 +CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
   48.18 +CND_PACKAGE_NAME_Debug=hello-world.tar
   48.19 +CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/hello-world.tar
   48.20 +# Release configuration
   48.21 +CND_PLATFORM_Release=GNU-Linux
   48.22 +CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux
   48.23 +CND_ARTIFACT_NAME_Release=hello-world
   48.24 +CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/hello-world
   48.25 +CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package
   48.26 +CND_PACKAGE_NAME_Release=hello-world.tar
   48.27 +CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/hello-world.tar
   48.28 +#
   48.29 +# include compiler specific variables
   48.30 +#
   48.31 +# dmake command
   48.32 +ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
   48.33 +	(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
   48.34 +#
   48.35 +# gmake command
   48.36 +.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
   48.37 +#
   48.38 +include nbproject/private/Makefile-variables.mk
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash	Tue May 30 15:29:39 2017 +0300
    49.3 @@ -0,0 +1,76 @@
    49.4 +#!/bin/bash -x
    49.5 +
    49.6 +#
    49.7 +# Generated - do not edit!
    49.8 +#
    49.9 +
   49.10 +# Macros
   49.11 +TOP=`pwd`
   49.12 +CND_PLATFORM=GNU-Linux
   49.13 +CND_CONF=Debug
   49.14 +CND_DISTDIR=dist
   49.15 +CND_BUILDDIR=build
   49.16 +CND_DLIB_EXT=so
   49.17 +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
   49.18 +TMPDIRNAME=tmp-packaging
   49.19 +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
   49.20 +OUTPUT_BASENAME=hello-world
   49.21 +PACKAGE_TOP_DIR=hello-world/
   49.22 +
   49.23 +# Functions
   49.24 +function checkReturnCode
   49.25 +{
   49.26 +    rc=$?
   49.27 +    if [ $rc != 0 ]
   49.28 +    then
   49.29 +        exit $rc
   49.30 +    fi
   49.31 +}
   49.32 +function makeDirectory
   49.33 +# $1 directory path
   49.34 +# $2 permission (optional)
   49.35 +{
   49.36 +    mkdir -p "$1"
   49.37 +    checkReturnCode
   49.38 +    if [ "$2" != "" ]
   49.39 +    then
   49.40 +      chmod $2 "$1"
   49.41 +      checkReturnCode
   49.42 +    fi
   49.43 +}
   49.44 +function copyFileToTmpDir
   49.45 +# $1 from-file path
   49.46 +# $2 to-file path
   49.47 +# $3 permission
   49.48 +{
   49.49 +    cp "$1" "$2"
   49.50 +    checkReturnCode
   49.51 +    if [ "$3" != "" ]
   49.52 +    then
   49.53 +        chmod $3 "$2"
   49.54 +        checkReturnCode
   49.55 +    fi
   49.56 +}
   49.57 +
   49.58 +# Setup
   49.59 +cd "${TOP}"
   49.60 +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
   49.61 +rm -rf ${NBTMPDIR}
   49.62 +mkdir -p ${NBTMPDIR}
   49.63 +
   49.64 +# Copy files and create directories and links
   49.65 +cd "${TOP}"
   49.66 +makeDirectory "${NBTMPDIR}/hello-world/bin"
   49.67 +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
   49.68 +
   49.69 +
   49.70 +# Generate tar file
   49.71 +cd "${TOP}"
   49.72 +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar
   49.73 +cd ${NBTMPDIR}
   49.74 +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar *
   49.75 +checkReturnCode
   49.76 +
   49.77 +# Cleanup
   49.78 +cd "${TOP}"
   49.79 +rm -rf ${NBTMPDIR}
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash	Tue May 30 15:29:39 2017 +0300
    50.3 @@ -0,0 +1,76 @@
    50.4 +#!/bin/bash -x
    50.5 +
    50.6 +#
    50.7 +# Generated - do not edit!
    50.8 +#
    50.9 +
   50.10 +# Macros
   50.11 +TOP=`pwd`
   50.12 +CND_PLATFORM=GNU-Linux
   50.13 +CND_CONF=Release
   50.14 +CND_DISTDIR=dist
   50.15 +CND_BUILDDIR=build
   50.16 +CND_DLIB_EXT=so
   50.17 +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
   50.18 +TMPDIRNAME=tmp-packaging
   50.19 +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
   50.20 +OUTPUT_BASENAME=hello-world
   50.21 +PACKAGE_TOP_DIR=hello-world/
   50.22 +
   50.23 +# Functions
   50.24 +function checkReturnCode
   50.25 +{
   50.26 +    rc=$?
   50.27 +    if [ $rc != 0 ]
   50.28 +    then
   50.29 +        exit $rc
   50.30 +    fi
   50.31 +}
   50.32 +function makeDirectory
   50.33 +# $1 directory path
   50.34 +# $2 permission (optional)
   50.35 +{
   50.36 +    mkdir -p "$1"
   50.37 +    checkReturnCode
   50.38 +    if [ "$2" != "" ]
   50.39 +    then
   50.40 +      chmod $2 "$1"
   50.41 +      checkReturnCode
   50.42 +    fi
   50.43 +}
   50.44 +function copyFileToTmpDir
   50.45 +# $1 from-file path
   50.46 +# $2 to-file path
   50.47 +# $3 permission
   50.48 +{
   50.49 +    cp "$1" "$2"
   50.50 +    checkReturnCode
   50.51 +    if [ "$3" != "" ]
   50.52 +    then
   50.53 +        chmod $3 "$2"
   50.54 +        checkReturnCode
   50.55 +    fi
   50.56 +}
   50.57 +
   50.58 +# Setup
   50.59 +cd "${TOP}"
   50.60 +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
   50.61 +rm -rf ${NBTMPDIR}
   50.62 +mkdir -p ${NBTMPDIR}
   50.63 +
   50.64 +# Copy files and create directories and links
   50.65 +cd "${TOP}"
   50.66 +makeDirectory "${NBTMPDIR}/hello-world/bin"
   50.67 +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
   50.68 +
   50.69 +
   50.70 +# Generate tar file
   50.71 +cd "${TOP}"
   50.72 +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar
   50.73 +cd ${NBTMPDIR}
   50.74 +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar *
   50.75 +checkReturnCode
   50.76 +
   50.77 +# Cleanup
   50.78 +cd "${TOP}"
   50.79 +rm -rf ${NBTMPDIR}
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml	Tue May 30 15:29:39 2017 +0300
    51.3 @@ -0,0 +1,71 @@
    51.4 +<?xml version="1.0" encoding="UTF-8"?>
    51.5 +<configurationDescriptor version="100">
    51.6 +  <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
    51.7 +    <logicalFolder name="HeaderFiles"
    51.8 +                   displayName="Header Files"
    51.9 +                   projectFiles="true">
   51.10 +      <itemPath>welcome.h</itemPath>
   51.11 +    </logicalFolder>
   51.12 +    <logicalFolder name="ResourceFiles"
   51.13 +                   displayName="Resource Files"
   51.14 +                   projectFiles="true">
   51.15 +    </logicalFolder>
   51.16 +    <logicalFolder name="SourceFiles"
   51.17 +                   displayName="Source Files"
   51.18 +                   projectFiles="true">
   51.19 +      <itemPath>welcome.cc</itemPath>
   51.20 +    </logicalFolder>
   51.21 +    <logicalFolder name="TestFiles"
   51.22 +                   displayName="Test Files"
   51.23 +                   projectFiles="false"
   51.24 +                   kind="TEST_LOGICAL_FOLDER">
   51.25 +    </logicalFolder>
   51.26 +    <logicalFolder name="ExternalFiles"
   51.27 +                   displayName="Important Files"
   51.28 +                   projectFiles="false"
   51.29 +                   kind="IMPORTANT_FILES_FOLDER">
   51.30 +      <itemPath>Makefile</itemPath>
   51.31 +    </logicalFolder>
   51.32 +  </logicalFolder>
   51.33 +  <projectmakefile>Makefile</projectmakefile>
   51.34 +  <confs>
   51.35 +    <conf name="Debug" type="1">
   51.36 +      <toolsSet>
   51.37 +        <compilerSet>default</compilerSet>
   51.38 +        <dependencyChecking>true</dependencyChecking>
   51.39 +        <rebuildPropChanged>false</rebuildPropChanged>
   51.40 +      </toolsSet>
   51.41 +      <compileType>
   51.42 +      </compileType>
   51.43 +      <item path="welcome.cc" ex="false" tool="1" flavor2="0">
   51.44 +      </item>
   51.45 +      <item path="welcome.h" ex="false" tool="3" flavor2="0">
   51.46 +      </item>
   51.47 +    </conf>
   51.48 +    <conf name="Release" type="1">
   51.49 +      <toolsSet>
   51.50 +        <compilerSet>default</compilerSet>
   51.51 +        <dependencyChecking>true</dependencyChecking>
   51.52 +        <rebuildPropChanged>false</rebuildPropChanged>
   51.53 +      </toolsSet>
   51.54 +      <compileType>
   51.55 +        <cTool>
   51.56 +          <developmentMode>5</developmentMode>
   51.57 +        </cTool>
   51.58 +        <ccTool>
   51.59 +          <developmentMode>5</developmentMode>
   51.60 +        </ccTool>
   51.61 +        <fortranCompilerTool>
   51.62 +          <developmentMode>5</developmentMode>
   51.63 +        </fortranCompilerTool>
   51.64 +        <asmTool>
   51.65 +          <developmentMode>5</developmentMode>
   51.66 +        </asmTool>
   51.67 +      </compileType>
   51.68 +      <item path="welcome.cc" ex="false" tool="1" flavor2="0">
   51.69 +      </item>
   51.70 +      <item path="welcome.h" ex="false" tool="3" flavor2="0">
   51.71 +      </item>
   51.72 +    </conf>
   51.73 +  </confs>
   51.74 +</configurationDescriptor>
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml	Tue May 30 15:29:39 2017 +0300
    52.3 @@ -0,0 +1,28 @@
    52.4 +<?xml version="1.0" encoding="UTF-8"?>
    52.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    52.6 +    <type>org.netbeans.modules.cnd.makeproject</type>
    52.7 +    <configuration>
    52.8 +        <data xmlns="http://www.netbeans.org/ns/make-project/1">
    52.9 +            <name>hello-world2</name>
   52.10 +            <c-extensions/>
   52.11 +            <cpp-extensions>cc</cpp-extensions>
   52.12 +            <header-extensions>h</header-extensions>
   52.13 +            <sourceEncoding>UTF-8</sourceEncoding>
   52.14 +            <make-dep-projects/>
   52.15 +            <sourceRootList/>
   52.16 +            <confList>
   52.17 +                <confElem>
   52.18 +                    <name>Debug</name>
   52.19 +                    <type>1</type>
   52.20 +                </confElem>
   52.21 +                <confElem>
   52.22 +                    <name>Release</name>
   52.23 +                    <type>1</type>
   52.24 +                </confElem>
   52.25 +            </confList>
   52.26 +            <formatting>
   52.27 +                <project-formatting-style>false</project-formatting-style>
   52.28 +            </formatting>
   52.29 +        </data>
   52.30 +    </configuration>
   52.31 +</project>
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/welcome.cc	Tue May 30 15:29:39 2017 +0300
    53.3 @@ -0,0 +1,38 @@
    53.4 +/*
    53.5 + * Copyright (c) 2009-2014, Oracle and/or its affiliates. All rights reserved.
    53.6 + *
    53.7 + * Redistribution and use in source and binary forms, with or without
    53.8 + * modification, are permitted provided that the following conditions are met:
    53.9 + *
   53.10 + * * Redistributions of source code must retain the above copyright notice,
   53.11 + *   this list of conditions and the following disclaimer.
   53.12 + *
   53.13 + * * Redistributions in binary form must reproduce the above copyright notice,
   53.14 + *   this list of conditions and the following disclaimer in the documentation
   53.15 + *   and/or other materials provided with the distribution.
   53.16 + *
   53.17 + * * Neither the name of Oracle nor the names of its contributors
   53.18 + *   may be used to endorse or promote products derived from this software without
   53.19 + *   specific prior written permission.
   53.20 + *
   53.21 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   53.22 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   53.23 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   53.24 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   53.25 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   53.26 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   53.27 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   53.28 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   53.29 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   53.30 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   53.31 + * THE POSSIBILITY OF SUCH DAMAGE.
   53.32 + */
   53.33 +
   53.34 +#include <iostream>
   53.35 +
   53.36 +int main(int argc, char**argv) {
   53.37 +    // Prints hello message...
   53.38 +    std::cout << "Hello World!" << std::endl;
   53.39 +    
   53.40 +    return 0;
   53.41 +}
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h	Tue May 30 15:29:39 2017 +0300
    54.3 @@ -0,0 +1,3 @@
    54.4 +#ifndef _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H
    54.5 +#define _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H
    54.6 +#endif
    54.7 \ No newline at end of file
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp	Tue May 30 15:29:39 2017 +0300
    55.3 @@ -0,0 +1,24 @@
    55.4 +#include <vector>
    55.5 +
    55.6 +using namespace std;
    55.7 +
    55.8 +int loops() {
    55.9 +    const int N = 5;
   55.10 +    int arr[] = {1, 2, 3, 4, 5};
   55.11 +    vector<int> v;
   55.12 +    v.push_back(1);
   55.13 +    v.push_back(2);
   55.14 +    v.push_back(3);
   55.15 +
   55.16 +    // safe conversion
   55.17 +    for (auto & elem : arr)
   55.18 +        cout << elem;
   55.19 +
   55.20 +    // reasonable conversion
   55.21 +    for (auto & elem : v)
   55.22 +        cout << elem;
   55.23 +
   55.24 +    // reasonable conversion
   55.25 +    for (auto & elem : v)
   55.26 +        cout << elem;
   55.27 +}
   55.28 \ No newline at end of file
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp	Tue May 30 15:29:39 2017 +0300
    56.3 @@ -0,0 +1,8 @@
    56.4 +const char *const Quotes{R"(embedded "quotes")"};
    56.5 +const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"};
    56.6 +const char *const SingleLine{"Single line.\n"};
    56.7 +const char *const TrailingSpace{"Look here -> \n"};
    56.8 +const char *const Tab{"One\tTwo\n"};
    56.9 +const char *const Bell{"Hello!\a  And welcome!"};
   56.10 +const char *const Path{R"(C:\Program Files\Vendor\Application.exe)"};
   56.11 +const char *const RegEx{R"(\w\([a-z]\))"};
   56.12 \ No newline at end of file
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp	Tue May 30 15:29:39 2017 +0300
    57.3 @@ -0,0 +1,11 @@
    57.4 +#include <cstddef>
    57.5 +
    57.6 +void assignment() {
    57.7 +  char *a = nullptr;
    57.8 +  char *b = nullptr;
    57.9 +  char c = 0;
   57.10 +}
   57.11 +
   57.12 +int *ret_ptr() {
   57.13 +  return nullptr;
   57.14 +}
   57.15 \ No newline at end of file
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world.json	Tue May 30 15:29:39 2017 +0300
    58.3 @@ -0,0 +1,25 @@
    58.4 +---
    58.5 +MainSourceFile:  ''
    58.6 +Diagnostics:     
    58.7 +  CheckName:       misc-unused-parameters
    58.8 +  Level:           Warning
    58.9 +  MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
   58.10 +  MessageFileOffset: 1615
   58.11 +  Message:         'parameter ''argc'' is unused'
   58.12 +  Replacements:    
   58.13 +    - FilePath:        $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
   58.14 +      Offset:          1615
   58.15 +      Length:          4
   58.16 +      ReplacementText: ' /*argc*/'
   58.17 +Diagnostics:     
   58.18 +  CheckName:       misc-unused-parameters
   58.19 +  Level:           Warning
   58.20 +  MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
   58.21 +  MessageFileOffset: 1627
   58.22 +  Message:         'parameter ''argv'' is unused'
   58.23 +  Replacements:    
   58.24 +    - FilePath:        $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
   58.25 +      Offset:          1627
   58.26 +      Length:          4
   58.27 +      ReplacementText: ' /*argv*/'
   58.28 +...
   58.29 \ No newline at end of file
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java	Tue May 30 15:29:39 2017 +0300
    59.3 @@ -0,0 +1,62 @@
    59.4 +package ide.analysis.modernize;
    59.5 +
    59.6 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
    59.7 +import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser;
    59.8 +import java.io.File;
    59.9 +import java.nio.file.Files;
   59.10 +import java.util.List;
   59.11 +import static junit.framework.TestCase.fail;
   59.12 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
   59.13 +import static org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestCase.createTempFile;
   59.14 +import org.openide.cookies.EditorCookie;
   59.15 +import org.openide.filesystems.FileObject;
   59.16 +import org.openide.filesystems.FileUtil;
   59.17 +import org.openide.loaders.DataObject;
   59.18 +
   59.19 +/*
   59.20 + * To change this license header, choose License Headers in Project Properties.
   59.21 + * To change this template file, choose Tools | Templates
   59.22 + * and open the template in the editor.
   59.23 + */
   59.24 +/**
   59.25 + *
   59.26 + * @author Ilia Gromov
   59.27 + */
   59.28 +public class HeaderTest extends TidyTestCase {
   59.29 +
   59.30 +    private final String source = "src/llvm-header-guard.cpp";
   59.31 +    private final String header = "src/llvm-header-guard.h";
   59.32 +
   59.33 +    public HeaderTest() {
   59.34 +        super("project-with-headers");
   59.35 +    }
   59.36 +
   59.37 +    public void testLlvmHeaderGuard() {
   59.38 +        performTest(source, "llvm-header-guard", true);
   59.39 +    }
   59.40 +
   59.41 +    @Override
   59.42 +    protected void processTestResults(List<ModernizeFix> fixes, String footerName) throws Exception {
   59.43 +        for (ModernizeFix fix : fixes) {
   59.44 +            fix.implement();
   59.45 +
   59.46 +            for (YamlParser.Replacement replacement : fix.getReplacements()) {
   59.47 +                FileObject fo = FileUtil.toFileObject(new File(replacement.filePath));
   59.48 +
   59.49 +                DataObject dObj = DataObject.find(fo);
   59.50 +                EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class);
   59.51 +                ec.saveDocument();
   59.52 +            }
   59.53 +        }
   59.54 +
   59.55 +        File diffFile = createTempFile("diff", null, false);
   59.56 +
   59.57 +        boolean diff = CndCoreTestUtils.diff(new File(FileUtil.toFile(getProjectDir()), header), getGoldenFile(header), diffFile);
   59.58 +
   59.59 +        if (diff) {
   59.60 +            byte[] readAllBytes = Files.readAllBytes(diffFile.toPath());
   59.61 +            System.err.println(new String(readAllBytes));
   59.62 +            fail();
   59.63 +        }
   59.64 +    }
   59.65 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java	Tue May 30 15:29:39 2017 +0300
    60.3 @@ -0,0 +1,44 @@
    60.4 +/*
    60.5 + * To change this license header, choose License Headers in Project Properties.
    60.6 + * To change this template file, choose Tools | Templates
    60.7 + * and open the template in the editor.
    60.8 + */
    60.9 +package ide.analysis.modernize;
   60.10 +
   60.11 +import javax.swing.text.Document;
   60.12 +import org.netbeans.modules.cnd.api.model.CsmFile;
   60.13 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   60.14 +
   60.15 +/**
   60.16 + *
   60.17 + * @author Ilia Gromov
   60.18 + */
   60.19 +class RequestImpl implements CsmErrorProvider.Request {
   60.20 +    
   60.21 +    private final CsmFile csmFile;
   60.22 +
   60.23 +    public RequestImpl(CsmFile csmFile) {
   60.24 +        this.csmFile = csmFile;
   60.25 +    }
   60.26 +
   60.27 +    @Override
   60.28 +    public CsmFile getFile() {
   60.29 +        return csmFile;
   60.30 +    }
   60.31 +
   60.32 +    @Override
   60.33 +    public boolean isCancelled() {
   60.34 +        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
   60.35 +    }
   60.36 +
   60.37 +    @Override
   60.38 +    public Document getDocument() {
   60.39 +        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
   60.40 +    }
   60.41 +
   60.42 +    @Override
   60.43 +    public CsmErrorProvider.EditorEvent getEvent() {
   60.44 +        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
   60.45 +    }
   60.46 +    
   60.47 +}
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java	Tue May 30 15:29:39 2017 +0300
    61.3 @@ -0,0 +1,46 @@
    61.4 +/*
    61.5 + * To change this license header, choose License Headers in Project Properties.
    61.6 + * To change this template file, choose Tools | Templates
    61.7 + * and open the template in the editor.
    61.8 + */
    61.9 +package ide.analysis.modernize;
   61.10 +
   61.11 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeErrorInfo;
   61.12 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
   61.13 +import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser;
   61.14 +import java.util.List;
   61.15 +import junit.framework.TestCase;
   61.16 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
   61.17 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   61.18 +import org.openide.util.Exceptions;
   61.19 +
   61.20 +/**
   61.21 + *
   61.22 + * @author Ilia Gromov
   61.23 + */
   61.24 +class ResponseImpl implements CsmErrorProvider.Response {
   61.25 +    
   61.26 +    private final List<ModernizeFix> fixes;
   61.27 +
   61.28 +    public ResponseImpl(List<ModernizeFix> fixes) {
   61.29 +        this.fixes = fixes;
   61.30 +    }
   61.31 +
   61.32 +    @Override
   61.33 +    public void addError(CsmErrorInfo info) {
   61.34 +        try {
   61.35 +            TestCase.assertTrue(info instanceof ModernizeErrorInfo);
   61.36 +            final List<YamlParser.Replacement> replacements = ((ModernizeErrorInfo) info).getDiagnostics().getReplacements();
   61.37 +            final String id = ((ModernizeErrorInfo) info).getId();
   61.38 +            ModernizeFix fix = new ModernizeFix(replacements, id);
   61.39 +            fixes.add(fix);
   61.40 +        } catch (Exception ex) {
   61.41 +            Exceptions.printStackTrace(ex);
   61.42 +        }
   61.43 +    }
   61.44 +
   61.45 +    @Override
   61.46 +    public void done() {
   61.47 +    }
   61.48 +    
   61.49 +}
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java	Tue May 30 15:29:39 2017 +0300
    62.3 @@ -0,0 +1,64 @@
    62.4 +package ide.analysis.modernize;
    62.5 +
    62.6 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
    62.7 +import java.io.File;
    62.8 +import java.nio.file.Files;
    62.9 +import java.util.List;
   62.10 +import org.junit.Test;
   62.11 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
   62.12 +import org.openide.cookies.EditorCookie;
   62.13 +import org.openide.filesystems.FileObject;
   62.14 +import org.openide.filesystems.FileUtil;
   62.15 +import org.openide.loaders.DataObject;
   62.16 +
   62.17 +/**
   62.18 + *
   62.19 + * @author Ilia Gromov
   62.20 + */
   62.21 +public class SingleCppFileCheckTest extends TidyTestCase {
   62.22 +
   62.23 +    public SingleCppFileCheckTest() {
   62.24 +        super("hello-cmake-world");
   62.25 +    }
   62.26 +
   62.27 +    @Override
   62.28 +    protected void setUp() throws Exception {
   62.29 +        super.setUp();
   62.30 +    }
   62.31 +
   62.32 +    public void testModernizeUseNullptr() {
   62.33 +        performTest("src/modernize-use-nullptr.cpp", "modernize-use-nullptr", true);
   62.34 +    }
   62.35 +
   62.36 +    public void testModernizeLoopConvert() {
   62.37 +        performTest("src/modernize-loop-convert.cpp", "modernize-loop-convert", true);
   62.38 +    }
   62.39 +
   62.40 +    @Test
   62.41 +    public void testModernizeRawStringLiteral() {
   62.42 +        performTest("src/modernize-raw-string-literal.cpp", "modernize-raw-string-literal", true);
   62.43 +    }
   62.44 +
   62.45 +    @Override
   62.46 +    protected void processTestResults(List<ModernizeFix> fixes, String startFileName) throws Exception {
   62.47 +        for (ModernizeFix fix : fixes) {
   62.48 +            fix.implement();
   62.49 +        }
   62.50 +
   62.51 +        FileObject footer = getSourceFile(startFileName);
   62.52 +
   62.53 +        DataObject dObj = DataObject.find(footer);
   62.54 +        EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class);
   62.55 +        ec.saveDocument();
   62.56 +
   62.57 +        File diffFile = createTempFile("diff", null, false);
   62.58 +
   62.59 +        boolean diff = CndCoreTestUtils.diff(FileUtil.toFile(footer), getGoldenFile(startFileName), diffFile);
   62.60 +
   62.61 +        if (diff) {
   62.62 +            byte[] readAllBytes = Files.readAllBytes(diffFile.toPath());
   62.63 +            System.err.println(new String(readAllBytes));
   62.64 +            fail();
   62.65 +        }
   62.66 +    }
   62.67 +}
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java	Tue May 30 15:29:39 2017 +0300
    63.3 @@ -0,0 +1,237 @@
    63.4 +/*
    63.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    63.6 + *
    63.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
    63.8 + *
    63.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   63.10 + * Other names may be trademarks of their respective owners.
   63.11 + *
   63.12 + * The contents of this file are subject to the terms of either the GNU
   63.13 + * General Public License Version 2 only ("GPL") or the Common
   63.14 + * Development and Distribution License("CDDL") (collectively, the
   63.15 + * "License"). You may not use this file except in compliance with the
   63.16 + * License. You can obtain a copy of the License at
   63.17 + * http://www.netbeans.org/cddl-gplv2.html
   63.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   63.19 + * specific language governing permissions and limitations under the
   63.20 + * License.  When distributing the software, include this License Header
   63.21 + * Notice in each file and include the License file at
   63.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   63.23 + * particular file as subject to the "Classpath" exception as provided
   63.24 + * by Oracle in the GPL Version 2 section of the License file that
   63.25 + * accompanied this code. If applicable, add the following below the
   63.26 + * License Header, with the fields enclosed by brackets [] replaced by
   63.27 + * your own identifying information:
   63.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   63.29 + *
   63.30 + * If you wish your version of this file to be governed by only the CDDL
   63.31 + * or only the GPL Version 2, indicate your decision by adding
   63.32 + * "[Contributor] elects to include this software in this distribution
   63.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   63.34 + * single choice of license, a recipient has the option to distribute
   63.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   63.36 + * to extend the choice of license to its licensees as provided above.
   63.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   63.38 + * Version 2 license, then the option applies only if the new code is
   63.39 + * made subject to such option by the copyright holder.
   63.40 + *
   63.41 + * Contributor(s):
   63.42 + *
   63.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
   63.44 + */
   63.45 +package ide.analysis.modernize;
   63.46 +
   63.47 +import org.netbeans.modules.ide.analysis.modernize.impl.DiagnosticsTool;
   63.48 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl;
   63.49 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
   63.50 +import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser;
   63.51 +import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools;
   63.52 +import java.io.File;
   63.53 +import java.nio.file.Files;
   63.54 +import java.nio.file.attribute.PosixFilePermissions;
   63.55 +import java.util.ArrayList;
   63.56 +import java.util.Arrays;
   63.57 +import java.util.Collection;
   63.58 +import java.util.Collections;
   63.59 +import java.util.List;
   63.60 +import java.util.logging.ConsoleHandler;
   63.61 +import java.util.logging.Level;
   63.62 +import java.util.logging.LogManager;
   63.63 +import java.util.prefs.Preferences;
   63.64 +import org.netbeans.api.progress.ProgressHandle;
   63.65 +import org.netbeans.api.project.Project;
   63.66 +import org.netbeans.api.project.ProjectManager;
   63.67 +import org.netbeans.api.project.ui.OpenProjects;
   63.68 +import org.netbeans.modules.analysis.SPIAccessor;
   63.69 +import org.netbeans.modules.analysis.spi.Analyzer;
   63.70 +import org.netbeans.modules.cnd.api.model.CsmFile;
   63.71 +import org.netbeans.modules.cnd.api.model.CsmModel;
   63.72 +import org.netbeans.modules.cnd.api.model.CsmModelAccessor;
   63.73 +import org.netbeans.modules.cnd.api.model.CsmProject;
   63.74 +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
   63.75 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
   63.76 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
   63.77 +import org.netbeans.modules.cnd.api.project.NativeProject;
   63.78 +import org.netbeans.modules.cnd.api.project.NativeProjectRegistry;
   63.79 +import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
   63.80 +import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager;
   63.81 +import org.netbeans.modules.cnd.makeproject.api.MakeProject;
   63.82 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
   63.83 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
   63.84 +import org.netbeans.modules.cnd.test.CndBaseTestCase;
   63.85 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
   63.86 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
   63.87 +import org.netbeans.modules.refactoring.api.Scope;
   63.88 +import org.openide.filesystems.FileObject;
   63.89 +import org.openide.filesystems.FileUtil;
   63.90 +import org.openide.util.Exceptions;
   63.91 +
   63.92 +/**
   63.93 + *
   63.94 + * @author Ilia Gromov
   63.95 + */
   63.96 +public abstract class TidyTestCase extends CndBaseTestCase {
   63.97 +
   63.98 +    private final String projectName;
   63.99 +
  63.100 +    private List<FileObject> fileObjects;
  63.101 +    private MakeProject project;
  63.102 +    private FileObject projectDirFileObject;
  63.103 +
  63.104 +    private final String CLANG_TIDY_PATH = "clang-tidy-3.9p";
  63.105 +
  63.106 +    public TidyTestCase(String projectName) {
  63.107 +        super(projectName);
  63.108 +
  63.109 +        this.projectName = projectName;
  63.110 +    }
  63.111 +
  63.112 +    protected static CodeAudit findAudit(Collection<CodeAudit> audits, String id) {
  63.113 +        for (CodeAudit audit : audits) {
  63.114 +            if (audit.getID().equals(id)) {
  63.115 +                return audit;
  63.116 +            }
  63.117 +        }
  63.118 +        return null;
  63.119 +    }
  63.120 +
  63.121 +    @Override
  63.122 +    protected void setUp() throws Exception {
  63.123 +        super.setUp();
  63.124 +        LogManager.getLogManager().reset();
  63.125 +
  63.126 +        java.util.logging.Logger LOG = java.util.logging.Logger.getLogger("ide.analysis.tidy");
  63.127 +        LOG.setLevel(Level.ALL);
  63.128 +
  63.129 +        ConsoleHandler consoleHandler = new ConsoleHandler();
  63.130 +        consoleHandler.setLevel(Level.ALL);
  63.131 +        LOG.addHandler(consoleHandler);
  63.132 +
  63.133 +        File clangTidyFile = getBinaryFile();
  63.134 +        Files.setPosixFilePermissions(clangTidyFile.toPath(), PosixFilePermissions.fromString("rwxrwxrwx"));
  63.135 +
  63.136 +        assertTrue(getBinaryFile().exists());
  63.137 +
  63.138 +        File projectDirFile = getDataFile(projectName);
  63.139 +        projectDirFileObject = FileUtil.toFileObject(projectDirFile);
  63.140 +
  63.141 +        fileObjects = new ArrayList<FileObject>();
  63.142 +
  63.143 +        project = (MakeProject) ProjectManager.getDefault().findProject(projectDirFileObject);
  63.144 +
  63.145 +        OpenProjects.getDefault().open(new Project[]{project}, false);
  63.146 +        while (!OpenProjects.getDefault().isProjectOpen(project)) {
  63.147 +            try {
  63.148 +                Thread.sleep(100);
  63.149 +            } catch (InterruptedException ex) {
  63.150 +                Exceptions.printStackTrace(ex);
  63.151 +            }
  63.152 +        }
  63.153 +
  63.154 +        CsmModel model = CsmModelAccessor.getModel();
  63.155 +        assertNotNull(project);
  63.156 +
  63.157 +        NativeProject np = project.getLookup().lookup(NativeProject.class);
  63.158 +        NativeProjectRegistry.getDefault().register(np);
  63.159 +        model.enableProject(np);
  63.160 +        assertNotNull(np);
  63.161 +
  63.162 +        CsmProject csmProject = model.getProject(np);
  63.163 +        assertNotNull(csmProject);
  63.164 +
  63.165 +        csmProject.waitParse();
  63.166 +
  63.167 +    }
  63.168 +
  63.169 +    public ExecutionEnvironment getExecEnv() {
  63.170 +        ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
  63.171 +        return execEnv;
  63.172 +    }
  63.173 +
  63.174 +    public CompilerSet getCompilerSet() {
  63.175 +        CompilerSetManager csm = CompilerSetManager.get(getExecEnv());
  63.176 +        return csm.getDefaultCompilerSet();
  63.177 +    }
  63.178 +
  63.179 +    public MakeProject getProject() {
  63.180 +        return project;
  63.181 +    }
  63.182 +
  63.183 +    public FileObject getProjectDir() {
  63.184 +        return projectDirFileObject;
  63.185 +    }
  63.186 +
  63.187 +    public FileObject getSourceFile(String name) {
  63.188 +        return FileUtil.toFileObject(new File(FileUtil.toFile(getProjectDir()), name));
  63.189 +    }
  63.190 +
  63.191 +    public File getBinaryFile() {
  63.192 +        return new File(getDataDir(), CLANG_TIDY_PATH);
  63.193 +    }
  63.194 +
  63.195 +    protected final void performTest(String startFileName, String checkName, boolean isStartFile) {
  63.196 +        try {
  63.197 +            FileObject startFile = getSourceFile(startFileName);
  63.198 +            assertTrue(startFile.isValid());
  63.199 +
  63.200 +            Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{startFile}));
  63.201 +            Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0);
  63.202 +            Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl();
  63.203 +
  63.204 +            ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context);
  63.205 +            ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
  63.206 +            final CsmFile csmFile = CsmUtilities.getCsmFile(startFile, true, false);
  63.207 +            Item item = AnalyticsTools.findItem(csmFile, getProject());
  63.208 +
  63.209 +            Collection<CodeAudit> audits = DiagnosticsTool.getAudits(getBinaryFile().getAbsolutePath(), execEnv, new AuditPreferences(Preferences.userNodeForPackage(this.getClass())));
  63.210 +            CodeAudit audit = findAudit(audits, checkName);
  63.211 +            assertNotNull(audit);
  63.212 +
  63.213 +            // ----- BEGIN diagnostics -----
  63.214 +            DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath());
  63.215 +
  63.216 +            int exitCode = diagnosticsTool.process(Collections.singleton(audit.getID()), csmFile, true);
  63.217 +            if (exitCode != DiagnosticsTool.STATUS_OK) {
  63.218 +                fail();
  63.219 +            }
  63.220 +
  63.221 +            List<YamlParser.Diagnostics> diags = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString());
  63.222 +            List<ModernizeFix> fixes = new ArrayList<ModernizeFix>();
  63.223 +
  63.224 +            CsmErrorProvider.Request request = new RequestImpl(csmFile);
  63.225 +            CsmErrorProvider.Response response = new ResponseImpl(fixes);
  63.226 +
  63.227 +            analyzer.getErrorProvider(null).postProcess(false, csmFile, getProject(), diags, request, response);
  63.228 +            // ----- END diagnostics -----
  63.229 +
  63.230 +            processTestResults(fixes, startFileName);
  63.231 +        } catch (Exception ex) {
  63.232 +            ex.printStackTrace(System.err);
  63.233 +            fail(ex.toString());
  63.234 +        }
  63.235 +    }
  63.236 +
  63.237 +    protected void processTestResults(List<ModernizeFix> fixes, String startFileName) throws Exception {
  63.238 +
  63.239 +    }
  63.240 +}
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java	Tue May 30 15:29:39 2017 +0300
    64.3 @@ -0,0 +1,117 @@
    64.4 +/*
    64.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    64.6 + *
    64.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
    64.8 + *
    64.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   64.10 + * Other names may be trademarks of their respective owners.
   64.11 + *
   64.12 + * The contents of this file are subject to the terms of either the GNU
   64.13 + * General Public License Version 2 only ("GPL") or the Common
   64.14 + * Development and Distribution License("CDDL") (collectively, the
   64.15 + * "License"). You may not use this file except in compliance with the
   64.16 + * License. You can obtain a copy of the License at
   64.17 + * http://www.netbeans.org/cddl-gplv2.html
   64.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   64.19 + * specific language governing permissions and limitations under the
   64.20 + * License.  When distributing the software, include this License Header
   64.21 + * Notice in each file and include the License file at
   64.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   64.23 + * particular file as subject to the "Classpath" exception as provided
   64.24 + * by Oracle in the GPL Version 2 section of the License file that
   64.25 + * accompanied this code. If applicable, add the following below the
   64.26 + * License Header, with the fields enclosed by brackets [] replaced by
   64.27 + * your own identifying information:
   64.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   64.29 + *
   64.30 + * If you wish your version of this file to be governed by only the CDDL
   64.31 + * or only the GPL Version 2, indicate your decision by adding
   64.32 + * "[Contributor] elects to include this software in this distribution
   64.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   64.34 + * single choice of license, a recipient has the option to distribute
   64.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   64.36 + * to extend the choice of license to its licensees as provided above.
   64.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   64.38 + * Version 2 license, then the option applies only if the new code is
   64.39 + * made subject to such option by the copyright holder.
   64.40 + *
   64.41 + * Contributor(s):
   64.42 + *
   64.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
   64.44 + */
   64.45 +package ide.analysis.modernize;
   64.46 +
   64.47 +import org.netbeans.modules.ide.analysis.modernize.impl.DiagnosticsTool;
   64.48 +import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl;
   64.49 +import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools;
   64.50 +import java.io.File;
   64.51 +import java.io.IOException;
   64.52 +import java.nio.file.Files;
   64.53 +import java.util.Arrays;
   64.54 +import java.util.Collections;
   64.55 +import org.junit.Test;
   64.56 +import org.netbeans.api.progress.ProgressHandle;
   64.57 +import org.netbeans.modules.analysis.SPIAccessor;
   64.58 +import org.netbeans.modules.analysis.spi.Analyzer;
   64.59 +import org.netbeans.modules.cnd.api.model.CsmFile;
   64.60 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
   64.61 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
   64.62 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
   64.63 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
   64.64 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
   64.65 +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
   64.66 +import org.netbeans.modules.refactoring.api.Scope;
   64.67 +import org.openide.filesystems.FileObject;
   64.68 +
   64.69 +/**
   64.70 + *
   64.71 + * @author Ilia Gromov
   64.72 + */
   64.73 +public class YamlTest extends TidyTestCase {
   64.74 +
   64.75 +    public YamlTest() {
   64.76 +        super("hello-world");
   64.77 +    }
   64.78 +
   64.79 +    @Test
   64.80 +    public void testYaml() throws IOException, ConnectionManager.CancellationException {
   64.81 +        FileObject singleFileObject = getSourceFile("welcome.cc");
   64.82 +
   64.83 +        File goldenFile = getGoldenFile("hello-world.json");
   64.84 +        String goldenYaml = new String(Files.readAllBytes(goldenFile.toPath()), "UTF-8").replaceAll("\\$path", getDataDir().getAbsolutePath());
   64.85 +
   64.86 +        Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{singleFileObject}));
   64.87 +        Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0);
   64.88 +
   64.89 +        Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl();
   64.90 +        ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context);
   64.91 +
   64.92 +        ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
   64.93 +
   64.94 +        CsmFile csmFile = CsmUtilities.getCsmFile(singleFileObject, false, false);
   64.95 +        Item item = AnalyticsTools.findItem(csmFile, getProject());
   64.96 +
   64.97 +        DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath());
   64.98 +
   64.99 +        int exitCode = diagnosticsTool.process(Collections.singleton("*"), csmFile, true);
  64.100 +
  64.101 +        if (exitCode != DiagnosticsTool.STATUS_OK) {
  64.102 +            fail();
  64.103 +        }
  64.104 +        String yamlAsString = diagnosticsTool.getYamlAsString();
  64.105 +
  64.106 +        File real = File.createTempFile("test", null);
  64.107 +        Files.write(real.toPath(), yamlAsString.getBytes());
  64.108 +
  64.109 +        File expected = File.createTempFile("test", null);
  64.110 +        Files.write(expected.toPath(), goldenYaml.getBytes());
  64.111 +
  64.112 +        File diff = File.createTempFile("test", null);
  64.113 +        if (CndCoreTestUtils.diff(real, expected, diff)) {
  64.114 +            System.err.println("============DIFF============");
  64.115 +            System.err.println(new String(Files.readAllBytes(diff.toPath()), "UTF-8"));
  64.116 +            System.err.println("============DIFF============");
  64.117 +            fail();
  64.118 +        }
  64.119 +    }
  64.120 +}