1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/c.s.tools.ide.analysis.modernize/build.xml Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize" default="netbeans" basedir=".">
1.9 + <description>Builds, tests, and runs the project com.sun.tools.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/c.s.tools.ide.analysis.modernize/l10n.list Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/license.txt Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/manifest.mf Wed Jun 07 20:23:29 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: com.sun.tools.ide.analysis.modernize
4.7 +OpenIDE-Module-Layer: com/sun/tools/ide/analysis/modernize/layer.xml
4.8 +OpenIDE-Module-Localizing-Bundle: com/sun/tools/ide/analysis/modernize/Bundle.properties
4.9 +OpenIDE-Module-Specification-Version: 1.1.1
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/c.s.tools.ide.analysis.modernize/nbproject/project.properties Wed Jun 07 20:23:29 2017 +0300
5.3 @@ -0,0 +1,15 @@
5.4 +javac.source=1.8
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 +keystore=nbproject/private/keystore
5.16 +nbm_alias=myself
5.17 +
5.18 +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/c.s.tools.ide.analysis.modernize/nbproject/project.xml Wed Jun 07 20:23:29 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>com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/Bundle.properties Wed Jun 07 20:23:29 2017 +0300
7.3 @@ -0,0 +1,8 @@
7.4 +OpenIDE-Module-Display-Category=Analysis tools
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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/AnalyzedFiles.java Wed Jun 07 20:23:29 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 com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/Bundle.properties Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ConfigureHintsFix.java Wed Jun 07 20:23:29 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 com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/DiagnosticsTool.java Wed Jun 07 20:23:29 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 com.sun.tools.ide.analysis.modernize.impl;
11.44 +
11.45 +import com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java Wed Jun 07 20:23:29 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 com.sun.tools.ide.analysis.modernize.impl;
12.44 +
12.45 +import com.sun.tools.ide.analysis.modernize.options.ClangAnalyzerOptions;
12.46 +import com.sun.tools.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 response = new ResponseImpl(sr, res, cancel);
12.102 + provider.getErrors(request, response);
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("com/sun/tools/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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeCodeAudit.java Wed Jun 07 20:23:29 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 com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorInfo.java Wed Jun 07 20:23:29 2017 +0300
14.3 @@ -0,0 +1,147 @@
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 com.sun.tools.ide.analysis.modernize.impl;
14.44 +
14.45 +import java.util.ArrayList;
14.46 +import java.util.Arrays;
14.47 +import java.util.Collections;
14.48 +import java.util.List;
14.49 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
14.50 +import org.netbeans.modules.cnd.api.project.NativeProject;
14.51 +import org.openide.util.Lookup;
14.52 +
14.53 +public class ModernizeErrorInfo implements CsmErrorInfo, ModernizeErrorProvider.ErrorInfoWithId {
14.54 +
14.55 + private final YamlParser.Diagnostics diag;
14.56 + private final String messagePrefix;
14.57 + private final List<String> messageInfixes;
14.58 + private final String messageBody;
14.59 + private final NativeProject project;
14.60 +
14.61 + private final int startOffset;
14.62 + private final int endOffset;
14.63 +
14.64 + public ModernizeErrorInfo(YamlParser.Diagnostics diag, String messagePrefix, List<String> messageInfixes, String messageBody, Lookup.Provider project) {
14.65 + this.diag = diag;
14.66 + this.messagePrefix = messagePrefix;
14.67 + this.messageInfixes = messageInfixes;
14.68 + this.messageBody = messageBody;
14.69 + this.project = project.getLookup().lookup(NativeProject.class);
14.70 +
14.71 + if (diag.getReplacements().isEmpty()) {
14.72 + startOffset = diag.getMessageFileOffset();
14.73 + endOffset = diag.getMessageFileOffset();
14.74 + } else {
14.75 + YamlParser.Replacement first = diag.getReplacements().get(0);
14.76 + startOffset = first.offset;
14.77 + endOffset = first.offset + first.length;
14.78 + }
14.79 + }
14.80 +
14.81 + public static ModernizeErrorInfo withFixedMessage(YamlParser.Diagnostics diag, String messageBody, Lookup.Provider project) {
14.82 + return new ModernizeErrorInfo(diag, "", new ArrayList<>(), messageBody, project);
14.83 + }
14.84 +
14.85 + public static ModernizeErrorInfo withMutableMessage(YamlParser.Diagnostics diag, String messagePrefix, String messageInfix, String messageBody, Lookup.Provider project) {
14.86 + List<String> list = new ArrayList<>();
14.87 + list.add(messageInfix);
14.88 + return new ModernizeErrorInfo(diag, messagePrefix, list, messageBody, project);
14.89 + }
14.90 +
14.91 + public static ModernizeErrorInfo withMutableMessage(YamlParser.Diagnostics diag, String messagePrefix, List<String> messageInfixes, String messageBody, Lookup.Provider project) {
14.92 + return new ModernizeErrorInfo(diag, messagePrefix, messageInfixes, messageBody, project);
14.93 + }
14.94 +
14.95 + public void addMessageInfixes(List<String> infix) {
14.96 + messageInfixes.addAll(infix);
14.97 + }
14.98 +
14.99 + public List<String> getMessageInfixes() {
14.100 + return Collections.unmodifiableList(messageInfixes);
14.101 + }
14.102 +
14.103 + public NativeProject getProject() {
14.104 + return project;
14.105 + }
14.106 +
14.107 + @Override
14.108 + public String getMessage() {
14.109 + StringBuilder sb = new StringBuilder();
14.110 + sb.append(messagePrefix).append(' ');
14.111 + if (messageInfixes.size() < 4) {
14.112 + sb.append(messageInfixes.toString());
14.113 + } else {
14.114 + ArrayList<String> list = new ArrayList<>(messageInfixes.subList(0, 2));
14.115 + list.add(String.format("... (%s more)", messageInfixes.size() - 2));
14.116 + sb.append(list.toString());
14.117 + }
14.118 + sb.append(": "); //NOI18N
14.119 + sb.append(messageBody);
14.120 + return sb.toString();
14.121 + }
14.122 +
14.123 + @Override
14.124 + public Severity getSeverity() {
14.125 + return Severity.valueOf(diag.getLevel().toString().toUpperCase());
14.126 + }
14.127 +
14.128 + @Override
14.129 + public int getStartOffset() {
14.130 + return startOffset;
14.131 + }
14.132 +
14.133 + @Override
14.134 + public int getEndOffset() {
14.135 + return endOffset;
14.136 + }
14.137 +
14.138 + public YamlParser.Diagnostics getDiagnostics() {
14.139 + return diag;
14.140 + }
14.141 +
14.142 + @Override
14.143 + public String getId() {
14.144 + return diag.getCheckName();
14.145 + }
14.146 +
14.147 + public boolean isNeedConfigureHint() {
14.148 + return true;
14.149 + }
14.150 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java Wed Jun 07 20:23:29 2017 +0300
15.3 @@ -0,0 +1,420 @@
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 com.sun.tools.ide.analysis.modernize.impl;
15.44 +
15.45 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl.ResponseImpl;
15.46 +import com.sun.tools.ide.analysis.modernize.impl.YamlParser.Replacement;
15.47 +import com.sun.tools.ide.analysis.modernize.options.AnalyzerPreferences;
15.48 +import com.sun.tools.ide.analysis.modernize.options.ClangAnalyzerOptions;
15.49 +import static com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools.fatalError;
15.50 +import static com.sun.tools.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.filesystems.FileObject;
15.86 +import org.openide.filesystems.FileUtil;
15.87 +import org.openide.util.Exceptions;
15.88 +import org.openide.util.Lookup;
15.89 +import org.openide.util.NbBundle;
15.90 +import org.openide.util.lookup.ServiceProvider;
15.91 +import org.openide.util.lookup.ServiceProviders;
15.92 +
15.93 +@ServiceProviders({
15.94 + @ServiceProvider(service = CsmErrorProvider.class, position = 2100)
15.95 + ,
15.96 + @ServiceProvider(service = CodeAuditProvider.class, position = 2100)
15.97 +})
15.98 +public final class ModernizeErrorProvider extends CsmErrorProvider implements CodeAuditProvider, AbstractCustomizerProvider {
15.99 +
15.100 + public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N
15.101 + private Collection<CodeAudit> audits;
15.102 + public static final String NAME = "Modernize"; //NOI18N
15.103 +
15.104 + public static ModernizeErrorProvider getInstance() {
15.105 + for (CsmErrorProvider provider : Lookup.getDefault().lookupAll(CsmErrorProvider.class)) {
15.106 + if (NAME.equals(provider.getName()) && provider instanceof ModernizeErrorProvider) {
15.107 + return (ModernizeErrorProvider) provider;
15.108 + }
15.109 + }
15.110 + return null;
15.111 + }
15.112 +
15.113 + @Override
15.114 + protected boolean validate(Request request) {
15.115 + CsmFile file = request.getFile();
15.116 + return file != null;
15.117 + }
15.118 +
15.119 + @Override
15.120 + public boolean hasHintControlPanel() {
15.121 + return true;
15.122 + }
15.123 +
15.124 + @Override
15.125 + public String getName() {
15.126 + return NAME;
15.127 + }
15.128 +
15.129 + @Override
15.130 + public String getDisplayName() {
15.131 + return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"); //NOI18N
15.132 + }
15.133 +
15.134 + @Override
15.135 + public String getDescription() {
15.136 + return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_DESCRIPTION"); //NOI18N
15.137 + }
15.138 +
15.139 + @Override
15.140 + public String getMimeType() {
15.141 + return MIMENames.SOURCES_MIME_TYPE;
15.142 + }
15.143 +
15.144 + @Override
15.145 + public boolean isSupportedEvent(EditorEvent kind) {
15.146 + return kind == EditorEvent.FileBased;
15.147 + }
15.148 +
15.149 + @Override
15.150 + protected void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
15.151 + CsmFile file = request.getFile();
15.152 + if (file != null) {
15.153 + if (request.isCancelled()) {
15.154 + return;
15.155 + }
15.156 + Object platformProject = file.getProject().getPlatformProject();
15.157 + if (platformProject instanceof NativeProject) {
15.158 + Lookup.Provider project = ((NativeProject) platformProject).getProject();
15.159 + if (project != null) {
15.160 + if (request.isCancelled()) {
15.161 + return;
15.162 + }
15.163 + Thread currentThread = Thread.currentThread();
15.164 + currentThread.setName("Provider " + getName() + " prosess " + file.getAbsolutePath()); // NOI18N
15.165 + RemoteProject info = project.getLookup().lookup(RemoteProject.class);
15.166 + if (info != null) {
15.167 + ExecutionEnvironment execEnv = info.getDevelopmentHost();
15.168 + if (execEnv != null) {
15.169 + if (request.isCancelled()) {
15.170 + return;
15.171 + }
15.172 + if (ConnectionManager.getInstance().isConnectedTo(execEnv)) {
15.173 + Item item = findItem(file, project);
15.174 + if (item != null) {
15.175 + if (request.isCancelled()) {
15.176 + return;
15.177 + }
15.178 + // Temporarily analyzing even excluded items
15.179 + if (/* !item.isExcluded() && */(item.getLanguage() == Language.C || item.getLanguage() == Language.CPP || item.getLanguage() == Language.C_HEADER)) {
15.180 + analyze(execEnv, item, project, request, response);
15.181 + }
15.182 + }
15.183 + }
15.184 + }
15.185 + }
15.186 + }
15.187 + }
15.188 + }
15.189 + }
15.190 +
15.191 + public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
15.192 + String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath();
15.193 + boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ResponseImpl;
15.194 + if (binaryPath == null) {
15.195 + Level level = isAnalyzer ? Level.INFO : Level.FINE;
15.196 + LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N
15.197 + return;
15.198 + }
15.199 +
15.200 + if (isAnalyzer && isNewRun()) {
15.201 + AnalyzedFiles.getDefault().clear();
15.202 + }
15.203 +
15.204 + DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath);
15.205 + try {
15.206 + CsmFile csmFile = request.getFile();
15.207 + Collection<String> checks = /*isAnalyzer ? Collections.singleton("*") : */ getEnabledChecks(); //NOI18N
15.208 +
15.209 + Collection<CsmFile> tu = new ArrayList<CsmFile>();
15.210 + if (isAnalyzer) {
15.211 + tu.add(csmFile);
15.212 + } else {
15.213 + if (AnalyzedFiles.getDefault().isStartFile(csmFile)) {
15.214 + tu.add(csmFile);
15.215 + } else {
15.216 + tu.addAll(AnalyzedFiles.getDefault().getStartFiles(csmFile));
15.217 + }
15.218 + }
15.219 +
15.220 + if (!isAnalyzer) {
15.221 + response = new ResponseMerger(response);
15.222 + }
15.223 +
15.224 + for (CsmFile startFile : tu) {
15.225 + int exitCode = diagnosticsTool.process(checks, startFile, true);
15.226 + if (exitCode != DiagnosticsTool.STATUS_OK) {
15.227 + String error = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error"); //NOI18N
15.228 + String info = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error.info", "" + exitCode); //NOI18N
15.229 + fatalError(AnalyzerResponse.AnalyzerSeverity.FileError, "fatal.analyze.error", error + "\n" + info, csmFile, response); //NOI18N
15.230 + return;
15.231 + }
15.232 + List<YamlParser.Diagnostics> results = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString());
15.233 + postProcess(isAnalyzer, startFile, project, results, request, response);
15.234 + }
15.235 +
15.236 + if (!isAnalyzer) {
15.237 + response.done();
15.238 + }
15.239 +
15.240 + } catch (ConnectionManager.CancellationException ex) {
15.241 + Exceptions.printStackTrace(ex);
15.242 + } catch (IOException ex) {
15.243 + Exceptions.printStackTrace(ex);
15.244 + }
15.245 + }
15.246 +
15.247 + private static CsmErrorProvider last;
15.248 +
15.249 + private boolean isNewRun() {
15.250 + if (last == null || this != last) {
15.251 + last = this;
15.252 + return true;
15.253 + }
15.254 + return false;
15.255 + }
15.256 +
15.257 + public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List<YamlParser.Diagnostics> results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
15.258 + CsmFile file = request.getFile();
15.259 + List<CsmFile> otherCsmFiles = new ArrayList<CsmFile>();
15.260 +
15.261 + for (YamlParser.Diagnostics diag : results) {
15.262 + // TODO: don't add "Configure Hint" fix multiple times for one line
15.263 + FileObject fo = FileUtil.toFileObject(new File(diag.getMessageFilePath()));
15.264 + CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false);
15.265 +
15.266 + // Composing a preview message. Showing a start file for compilation unit
15.267 + // in case we analysing a header file
15.268 + ModernizeErrorInfo info;
15.269 + if (startFile.equals(file) && csmFile.equals(file)) {
15.270 + String message = String.format("[%s]: %s", diag.getCheckName(), diag.getMessage()); //NOI18N
15.271 + info = ModernizeErrorInfo.withFixedMessage(diag, message, project);
15.272 + } else {
15.273 + info = ModernizeErrorInfo.withMutableMessage(diag, diag.getCheckName(), startFile.getName().toString(), diag.getMessage(), project);
15.274 + }
15.275 +
15.276 + if (isAnalyzer) {
15.277 + // Add found errors for all files (can be other files from compileUnit)
15.278 + ((ResponseImpl) response).addError(AnalyzerResponse.AnalyzerSeverity.DetectedError, null, fo, info);
15.279 +
15.280 + if (!csmFile.equals(file)) {
15.281 + // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... )
15.282 + otherCsmFiles.add(csmFile);
15.283 + }
15.284 + } else if (fo.equals(file.getFileObject())) {
15.285 + // Add found errors only for file displayed in Editor
15.286 + response.addError(info);
15.287 + }
15.288 + }
15.289 +
15.290 + if (isAnalyzer /* and not empty? */) {
15.291 + AnalyzedFiles.getDefault().cacheHierarchy(file, otherCsmFiles);
15.292 + }
15.293 + }
15.294 +
15.295 + @ServiceProvider(path = CodeAuditFactory.REGISTRATION_PATH + ModernizeErrorProvider.NAME, service = CodeAuditFactory.class, position = 4000)
15.296 + public static final class Factory implements CodeAuditFactory {
15.297 +
15.298 + @Override
15.299 + public AbstractCodeAudit create(AuditPreferences preferences) {
15.300 + String id = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderName"); // NOI18N
15.301 + String description = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderDescription"); // NOI18N
15.302 + return new ModernizeCodeAudit(id, id, description, "error", false, preferences); // NOI18N
15.303 + }
15.304 + }
15.305 +
15.306 + private String oldPath;
15.307 +
15.308 + @Override
15.309 + public synchronized Collection<CodeAudit> getAudits() {
15.310 + String path = ClangAnalyzerOptions.getClangAnalyzerPath();
15.311 +
15.312 + if (path == null) {
15.313 + return Collections.emptyList();
15.314 + }
15.315 +
15.316 + if (oldPath == null) {
15.317 + oldPath = path;
15.318 + }
15.319 +
15.320 + if (audits == null || !oldPath.equals(path)) {
15.321 + List<CodeAudit> res = DiagnosticsTool.getAudits(path, ExecutionEnvironmentFactory.getLocal(), AnalyzerPreferences.getAuditPreferences());
15.322 +
15.323 + audits = res;
15.324 + oldPath = path;
15.325 + }
15.326 + return audits;
15.327 + }
15.328 +
15.329 + public Collection<String> getEnabledChecks() {
15.330 + Collection<CodeAudit> auditList = getAudits();
15.331 + List<String> enabled = new ArrayList<String>();
15.332 + for (CodeAudit codeAudit : auditList) {
15.333 + if (codeAudit.isEnabled()) {
15.334 + enabled.add(codeAudit.getID());
15.335 + }
15.336 + }
15.337 + return enabled.size() == auditList.size() ? Collections.singleton("*") : enabled; //NOI18N
15.338 + }
15.339 +
15.340 + @Override
15.341 + public AuditPreferences getPreferences() {
15.342 + return AnalyzerPreferences.getAuditPreferences();
15.343 + }
15.344 +
15.345 + @Override
15.346 + public JComponent createComponent(Preferences context) {
15.347 + return new JLabel();
15.348 + }
15.349 +
15.350 + public static interface ErrorInfoWithId {
15.351 +
15.352 + String getId();
15.353 + }
15.354 +
15.355 + public static final class FatalErrorInfo implements CsmErrorInfo, ErrorInfoWithId {
15.356 +
15.357 + private final String id;
15.358 + private final String message;
15.359 +
15.360 + public FatalErrorInfo(String id, String message) {
15.361 + this.id = id;
15.362 + this.message = message;
15.363 + }
15.364 +
15.365 + @Override
15.366 + public String getMessage() {
15.367 + return message;
15.368 + }
15.369 +
15.370 + @Override
15.371 + public Severity getSeverity() {
15.372 + return Severity.WARNING;
15.373 + }
15.374 +
15.375 + @Override
15.376 + public int getStartOffset() {
15.377 + return 0;
15.378 + }
15.379 +
15.380 + @Override
15.381 + public int getEndOffset() {
15.382 + return 1;
15.383 + }
15.384 +
15.385 + @Override
15.386 + public String getId() {
15.387 + return id;
15.388 + }
15.389 + }
15.390 +
15.391 + @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 9100)
15.392 + public final static class ModerinzeHintProvider extends CsmErrorInfoHintProvider {
15.393 +
15.394 + @Override
15.395 + protected List<Fix> doGetFixes(CsmErrorInfo info, List<Fix> alreadyFound) {
15.396 + if (info instanceof ModernizeErrorInfo) {
15.397 + alreadyFound.add(new ConfigureHintsFix((ModernizeErrorInfo) info));
15.398 + }
15.399 + return alreadyFound;
15.400 + }
15.401 + }
15.402 +
15.403 + @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 1600)
15.404 + public static final class ModernizeFixProvider extends CsmErrorInfoHintProvider {
15.405 +
15.406 + @Override
15.407 + protected List<Fix> doGetFixes(CsmErrorInfo info, List<Fix> alreadyFound) {
15.408 + alreadyFound.addAll(createFixes(info));
15.409 + return alreadyFound;
15.410 + }
15.411 + }
15.412 +
15.413 + private static List<? extends Fix> createFixes(CsmErrorInfo info) {
15.414 + if (info instanceof ModernizeErrorInfo) {
15.415 + ModernizeErrorInfo mei = (ModernizeErrorInfo) info;
15.416 + List<Replacement> replacements = mei.getDiagnostics().getReplacements();
15.417 + if (!replacements.isEmpty()) {
15.418 + return Collections.singletonList(new ModernizeFix(replacements, mei.getId()));
15.419 + }
15.420 + }
15.421 + return Collections.EMPTY_LIST;
15.422 + }
15.423 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeFix.java Wed Jun 07 20:23:29 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 com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ResponseMerger.java Wed Jun 07 20:23:29 2017 +0300
17.3 @@ -0,0 +1,87 @@
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 com.sun.tools.ide.analysis.modernize.impl;
17.44 +
17.45 +import java.util.ArrayList;
17.46 +import java.util.List;
17.47 +import java.util.Optional;
17.48 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
17.49 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
17.50 +
17.51 +/**
17.52 + *
17.53 + * @author Ilia Gromov
17.54 + */
17.55 +public class ResponseMerger implements CsmErrorProvider.Response {
17.56 +
17.57 + private final List<ModernizeErrorInfo> bag = new ArrayList<>();
17.58 + private final CsmErrorProvider.Response delegate;
17.59 +
17.60 + public ResponseMerger(CsmErrorProvider.Response delegate) {
17.61 + this.delegate = delegate;
17.62 + }
17.63 +
17.64 + @Override
17.65 + public void addError(CsmErrorInfo errorInfo) {
17.66 + ModernizeErrorInfo o2 = (ModernizeErrorInfo) errorInfo;
17.67 + Optional<ModernizeErrorInfo> found = bag.stream()
17.68 + .filter(o1 -> isSame(o1, o2))
17.69 + .findAny();
17.70 +
17.71 + if (found.isPresent()) {
17.72 + found.get().addMessageInfixes(o2.getMessageInfixes());
17.73 + } else {
17.74 + bag.add(o2);
17.75 + }
17.76 + }
17.77 +
17.78 + @Override
17.79 + public void done() {
17.80 + bag.forEach(delegate::addError);
17.81 + delegate.done();
17.82 + bag.clear();
17.83 + }
17.84 +
17.85 + public boolean isSame(ModernizeErrorInfo o1, ModernizeErrorInfo o2) {
17.86 + return o1.getStartOffset() == o2.getStartOffset()
17.87 + && o1.getEndOffset() == o2.getEndOffset()
17.88 + && o1.getDiagnostics().getCheckName().equals(o2.getDiagnostics().getCheckName());
17.89 + }
17.90 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/YamlParser.java Wed Jun 07 20:23:29 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 com.sun.tools.ide.analysis.modernize.impl;
18.44 +
18.45 +import static com.sun.tools.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 c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/bugs.png has changed
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/layer.xml Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/AnalyzerPreferences.java Wed Jun 07 20:23:29 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 com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/Bundle.properties Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/ClangAnalyzerOptions.java Wed Jun 07 20:23:29 2017 +0300
23.3 @@ -0,0 +1,169 @@
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 com.sun.tools.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 + toolFile.setExecutable(true);
23.85 + System.out.println(toolFile.canExecute());
23.86 + result = toolFile.getAbsolutePath();
23.87 + }
23.88 + }
23.89 + if (result.isEmpty()) {
23.90 + String toolPath = findInPaths();
23.91 + if (toolPath != null) {
23.92 + result = toolPath;
23.93 + }
23.94 + }
23.95 + if (result.isEmpty()) {
23.96 + return null;
23.97 + } else {
23.98 + if (!oldValue.equals(result)) {
23.99 + AnalyzerPreferences.getPreferences().put(CLANG_BINARY_PATH, result);
23.100 + }
23.101 + }
23.102 + return result;
23.103 + }
23.104 +
23.105 + public static String getMissingModuleName() {
23.106 + return "org.netbeans.modules.analysis.clangtidy." + getCodeBase(); //NOI18N
23.107 + }
23.108 +
23.109 + public static String getCodeBase() {
23.110 + HostInfo hostInfo = null;
23.111 + try {
23.112 + hostInfo = HostInfoUtils.getHostInfo(ExecutionEnvironmentFactory.getLocal());
23.113 + } catch (IOException ex) {
23.114 + ex.printStackTrace(System.err);
23.115 + } catch (ConnectionManager.CancellationException ex) {
23.116 + ex.printStackTrace(System.err);
23.117 + }
23.118 + String module = null;
23.119 + if (hostInfo != null) {
23.120 + switch (hostInfo.getOS().getFamily()) {
23.121 + case SUNOS:
23.122 + switch (hostInfo.getCpuFamily()) {
23.123 + case X86:
23.124 + switch (hostInfo.getOS().getBitness()) {
23.125 + case _32:
23.126 + module = "SunOS_x86"; // NOI18N
23.127 + break;
23.128 + case _64:
23.129 + module = "SunOS_x86_64"; // NOI18N
23.130 + break;
23.131 + }
23.132 + break;
23.133 + case SPARC:
23.134 + module = "SunOS_sparc"; // NOI18N
23.135 + break;
23.136 + }
23.137 + break;
23.138 + case LINUX:
23.139 + switch (hostInfo.getOS().getBitness()) {
23.140 + case _32:
23.141 + module = "Linux_x86"; // NOI18N
23.142 + break;
23.143 + case _64:
23.144 + module = "Linux_x86_64"; // NOI18N
23.145 + break;
23.146 + }
23.147 + break;
23.148 + case WINDOWS:
23.149 + switch (hostInfo.getOS().getBitness()) {
23.150 + case _32:
23.151 + module = "Windows_x86"; // NOI18N
23.152 + break;
23.153 + case _64:
23.154 + module = "Windows_x86_64"; // NOI18N
23.155 + break;
23.156 + }
23.157 + break;
23.158 + case MACOSX:
23.159 + switch (hostInfo.getOS().getBitness()) {
23.160 + case _32:
23.161 + module = "MacOSX_x86"; // NOI18N
23.162 + break;
23.163 + case _64:
23.164 + module = "MacOSX_x86_64"; // NOI18N
23.165 + break;
23.166 + }
23.167 + break;
23.168 + }
23.169 + }
23.170 + return module;
23.171 + }
23.172 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/resources/Bundle.properties Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/resources/BundleUtilities.java Wed Jun 07 20:23:29 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 com.sun.tools.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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang-tools-extra.patch Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang.patch Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/utils/AnalyticsTools.java Wed Jun 07 20:23:29 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 com.sun.tools.ide.analysis.modernize.utils;
28.44 +
28.45 +import com.sun.tools.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/c.s.tools.ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h Wed Jun 07 20:23:29 2017 +0300
30.3 @@ -0,0 +1,3 @@
30.4 +#ifndef _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H
30.5 +#define _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H
30.6 +#endif
30.7 \ No newline at end of file
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp Wed Jun 07 20:23:29 2017 +0300
31.3 @@ -0,0 +1,24 @@
31.4 +#include <vector>
31.5 +
31.6 +using namespace std;
31.7 +
31.8 +int loops() {
31.9 + const int N = 5;
31.10 + int arr[] = {1, 2, 3, 4, 5};
31.11 + vector<int> v;
31.12 + v.push_back(1);
31.13 + v.push_back(2);
31.14 + v.push_back(3);
31.15 +
31.16 + // safe conversion
31.17 + for (auto & elem : arr)
31.18 + cout << elem;
31.19 +
31.20 + // reasonable conversion
31.21 + for (auto & elem : v)
31.22 + cout << elem;
31.23 +
31.24 + // reasonable conversion
31.25 + for (auto & elem : v)
31.26 + cout << elem;
31.27 +}
31.28 \ No newline at end of file
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp Wed Jun 07 20:23:29 2017 +0300
32.3 @@ -0,0 +1,8 @@
32.4 +const char *const Quotes{R"(embedded "quotes")"};
32.5 +const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"};
32.6 +const char *const SingleLine{"Single line.\n"};
32.7 +const char *const TrailingSpace{"Look here -> \n"};
32.8 +const char *const Tab{"One\tTwo\n"};
32.9 +const char *const Bell{"Hello!\a And welcome!"};
32.10 +const char *const Path{R"(C:\Program Files\Vendor\Application.exe)"};
32.11 +const char *const RegEx{R"(\w\([a-z]\))"};
32.12 \ No newline at end of file
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp Wed Jun 07 20:23:29 2017 +0300
33.3 @@ -0,0 +1,11 @@
33.4 +#include <cstddef>
33.5 +
33.6 +void assignment() {
33.7 + char *a = nullptr;
33.8 + char *b = nullptr;
33.9 + char c = 0;
33.10 +}
33.11 +
33.12 +int *ret_ptr() {
33.13 + return nullptr;
33.14 +}
33.15 \ No newline at end of file
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/YamlTest/hello-world.json Wed Jun 07 20:23:29 2017 +0300
34.3 @@ -0,0 +1,25 @@
34.4 +---
34.5 +MainSourceFile: ''
34.6 +Diagnostics:
34.7 + CheckName: misc-unused-parameters
34.8 + Level: Warning
34.9 + MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
34.10 + MessageFileOffset: 1615
34.11 + Message: 'parameter ''argc'' is unused'
34.12 + Replacements:
34.13 + - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
34.14 + Offset: 1615
34.15 + Length: 4
34.16 + ReplacementText: ' /*argc*/'
34.17 +Diagnostics:
34.18 + CheckName: misc-unused-parameters
34.19 + Level: Warning
34.20 + MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
34.21 + MessageFileOffset: 1627
34.22 + Message: 'parameter ''argv'' is unused'
34.23 + Replacements:
34.24 + - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
34.25 + Offset: 1627
34.26 + Length: 4
34.27 + ReplacementText: ' /*argv*/'
34.28 +...
34.29 \ No newline at end of file
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt Wed Jun 07 20:23:29 2017 +0300
35.3 @@ -0,0 +1,2 @@
35.4 +project (HelloCMake CXX)
35.5 +add_subdirectory (src)
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml Wed Jun 07 20:23:29 2017 +0300
36.3 @@ -0,0 +1,128 @@
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>llvm-header-guard.cpp</in>
36.49 + </df>
36.50 + </df>
36.51 + <logicalFolder name="ExternalFiles"
36.52 + displayName="Important Files"
36.53 + projectFiles="false"
36.54 + kind="IMPORTANT_FILES_FOLDER">
36.55 + <itemPath>CMakeLists.txt</itemPath>
36.56 + <itemPath>build/Debug/Makefile</itemPath>
36.57 + <itemPath>build/Release/Makefile</itemPath>
36.58 + </logicalFolder>
36.59 + </logicalFolder>
36.60 + <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
36.61 + <sourceRootList>
36.62 + <Elem>.</Elem>
36.63 + </sourceRootList>
36.64 + <projectmakefile>build/Debug/Makefile</projectmakefile>
36.65 + <confs>
36.66 + <conf name="Debug" type="0">
36.67 + <toolsSet>
36.68 + <compilerSet>default</compilerSet>
36.69 + <dependencyChecking>false</dependencyChecking>
36.70 + <rebuildPropChanged>false</rebuildPropChanged>
36.71 + </toolsSet>
36.72 + <flagsDictionary>
36.73 + <element flagsID="0" commonFlags="-std=gnu++11"/>
36.74 + </flagsDictionary>
36.75 + <codeAssistance>
36.76 + </codeAssistance>
36.77 + <makefileType>
36.78 + <makeTool>
36.79 + <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
36.80 + <buildCommand>${MAKE} -f Makefile</buildCommand>
36.81 + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
36.82 + <executablePath>build/Debug/src/welcome</executablePath>
36.83 + <ccTool flags="0">
36.84 + <incDir>
36.85 + <pElem>build/Debug/src</pElem>
36.86 + </incDir>
36.87 + </ccTool>
36.88 + </makeTool>
36.89 + <preBuild>
36.90 + <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
36.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>
36.92 + <preBuildFirst>true</preBuildFirst>
36.93 + </preBuild>
36.94 + </makefileType>
36.95 + <item path="src/llvm-header-guard.cpp" ex="false" tool="1" flavor2="8">
36.96 + <ccTool flags="0">
36.97 + </ccTool>
36.98 + </item>
36.99 + </conf>
36.100 + <conf name="Release" type="0">
36.101 + <toolsSet>
36.102 + <compilerSet>default</compilerSet>
36.103 + <dependencyChecking>false</dependencyChecking>
36.104 + <rebuildPropChanged>false</rebuildPropChanged>
36.105 + </toolsSet>
36.106 + <codeAssistance>
36.107 + </codeAssistance>
36.108 + <makefileType>
36.109 + <makeTool>
36.110 + <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
36.111 + <buildCommand>${MAKE} -f Makefile</buildCommand>
36.112 + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
36.113 + <executablePath>build/Release/src/welcome</executablePath>
36.114 + <ccTool>
36.115 + <incDir>
36.116 + <pElem>build/Release/src</pElem>
36.117 + </incDir>
36.118 + <preprocessorList>
36.119 + <Elem>NDEBUG</Elem>
36.120 + </preprocessorList>
36.121 + </ccTool>
36.122 + </makeTool>
36.123 + <preBuild>
36.124 + <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
36.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>
36.126 + <preBuildFirst>true</preBuildFirst>
36.127 + </preBuild>
36.128 + </makefileType>
36.129 + </conf>
36.130 + </confs>
36.131 +</configurationDescriptor>
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt Wed Jun 07 20:23:29 2017 +0300
38.3 @@ -0,0 +1,2 @@
38.4 +set(CMAKE_CXX_STANDARD 11)
38.5 +add_library (headers llvm-header-guard.cpp)
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp Wed Jun 07 20:23:29 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/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/CMakeLists.txt Wed Jun 07 20:23:29 2017 +0300
40.3 @@ -0,0 +1,2 @@
40.4 +project (HelloCMake CXX)
40.5 +add_subdirectory (src)
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/nbproject/configurations.xml Wed Jun 07 20:23:29 2017 +0300
41.3 @@ -0,0 +1,145 @@
41.4 +<?xml version="1.0" encoding="UTF-8"?>
41.5 +<!--
41.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
41.7 +
41.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
41.9 +
41.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
41.11 +Other names may be trademarks of their respective owners.
41.12 +
41.13 +The contents of this file are subject to the terms of either the GNU
41.14 +General Public License Version 2 only ("GPL") or the Common
41.15 +Development and Distribution License("CDDL") (collectively, the
41.16 +"License"). You may not use this file except in compliance with the
41.17 +License. You can obtain a copy of the License at
41.18 +http://www.netbeans.org/cddl-gplv2.html
41.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
41.20 +specific language governing permissions and limitations under the
41.21 +License. When distributing the software, include this License Header
41.22 +Notice in each file and include the License file at
41.23 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
41.24 +particular file as subject to the "Classpath" exception as provided
41.25 +by Oracle in the GPL Version 2 section of the License file that
41.26 +accompanied this code. If applicable, add the following below the
41.27 +License Header, with the fields enclosed by brackets [] replaced by
41.28 +your own identifying information:
41.29 +"Portions Copyrighted [year] [name of copyright owner]"
41.30 +
41.31 +If you wish your version of this file to be governed by only the CDDL
41.32 +or only the GPL Version 2, indicate your decision by adding
41.33 +"[Contributor] elects to include this software in this distribution
41.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
41.35 +single choice of license, a recipient has the option to distribute
41.36 +your version of this file under either the CDDL, the GPL Version 2 or
41.37 +to extend the choice of license to its licensees as provided above.
41.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
41.39 +Version 2 license, then the option applies only if the new code is
41.40 +made subject to such option by the copyright holder.
41.41 +
41.42 +Contributor(s):
41.43 +-->
41.44 +<configurationDescriptor version="100">
41.45 + <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
41.46 + <df root="." name="0">
41.47 + <df name="src">
41.48 + <in>header.h</in>
41.49 + <in>source_1.cpp</in>
41.50 + <in>source_2.cpp</in>
41.51 + <in>source_3.cpp</in>
41.52 + <in>source_4.cpp</in>
41.53 + </df>
41.54 + </df>
41.55 + <logicalFolder name="ExternalFiles"
41.56 + displayName="Important Files"
41.57 + projectFiles="false"
41.58 + kind="IMPORTANT_FILES_FOLDER">
41.59 + <itemPath>CMakeLists.txt</itemPath>
41.60 + <itemPath>build/Debug/Makefile</itemPath>
41.61 + <itemPath>build/Release/Makefile</itemPath>
41.62 + </logicalFolder>
41.63 + </logicalFolder>
41.64 + <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
41.65 + <sourceRootList>
41.66 + <Elem>.</Elem>
41.67 + </sourceRootList>
41.68 + <projectmakefile>build/Debug/Makefile</projectmakefile>
41.69 + <confs>
41.70 + <conf name="Debug" type="0">
41.71 + <toolsSet>
41.72 + <compilerSet>default</compilerSet>
41.73 + <dependencyChecking>false</dependencyChecking>
41.74 + <rebuildPropChanged>false</rebuildPropChanged>
41.75 + </toolsSet>
41.76 + <codeAssistance>
41.77 + </codeAssistance>
41.78 + <makefileType>
41.79 + <makeTool>
41.80 + <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
41.81 + <buildCommand>${MAKE} -f Makefile</buildCommand>
41.82 + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
41.83 + <executablePath>build/Debug/src/welcome</executablePath>
41.84 + <ccTool flags="-std=gnu++11">
41.85 + <incDir>
41.86 + <pElem>build/Debug/src</pElem>
41.87 + </incDir>
41.88 + </ccTool>
41.89 + </makeTool>
41.90 + <preBuild>
41.91 + <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
41.92 + <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>
41.93 + <preBuildFirst>true</preBuildFirst>
41.94 + </preBuild>
41.95 + </makefileType>
41.96 + <item path="src/header.h" ex="false" tool="3" flavor2="0">
41.97 + </item>
41.98 + <item path="src/source_1.cpp" ex="false" tool="1" flavor2="0">
41.99 + </item>
41.100 + <item path="src/source_2.cpp" ex="false" tool="1" flavor2="0">
41.101 + </item>
41.102 + <item path="src/source_3.cpp" ex="false" tool="1" flavor2="0">
41.103 + </item>
41.104 + <item path="src/source_4.cpp" ex="false" tool="1" flavor2="0">
41.105 + </item>
41.106 + </conf>
41.107 + <conf name="Release" type="0">
41.108 + <toolsSet>
41.109 + <compilerSet>default</compilerSet>
41.110 + <dependencyChecking>false</dependencyChecking>
41.111 + <rebuildPropChanged>false</rebuildPropChanged>
41.112 + </toolsSet>
41.113 + <codeAssistance>
41.114 + </codeAssistance>
41.115 + <makefileType>
41.116 + <makeTool>
41.117 + <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
41.118 + <buildCommand>${MAKE} -f Makefile</buildCommand>
41.119 + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
41.120 + <executablePath>build/Release/src/welcome</executablePath>
41.121 + <ccTool>
41.122 + <incDir>
41.123 + <pElem>build/Release/src</pElem>
41.124 + </incDir>
41.125 + <preprocessorList>
41.126 + <Elem>NDEBUG</Elem>
41.127 + </preprocessorList>
41.128 + </ccTool>
41.129 + </makeTool>
41.130 + <preBuild>
41.131 + <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
41.132 + <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>
41.133 + <preBuildFirst>true</preBuildFirst>
41.134 + </preBuild>
41.135 + </makefileType>
41.136 + <item path="src/header.h" ex="false" tool="3" flavor2="0">
41.137 + </item>
41.138 + <item path="src/source_1.cpp" ex="false" tool="1" flavor2="0">
41.139 + </item>
41.140 + <item path="src/source_2.cpp" ex="false" tool="1" flavor2="0">
41.141 + </item>
41.142 + <item path="src/source_3.cpp" ex="false" tool="1" flavor2="0">
41.143 + </item>
41.144 + <item path="src/source_4.cpp" ex="false" tool="1" flavor2="0">
41.145 + </item>
41.146 + </conf>
41.147 + </confs>
41.148 +</configurationDescriptor>
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/nbproject/project.xml Wed Jun 07 20:23:29 2017 +0300
42.3 @@ -0,0 +1,72 @@
42.4 +<?xml version="1.0" encoding="UTF-8"?>
42.5 +<!--
42.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
42.7 +
42.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
42.9 +
42.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
42.11 +Other names may be trademarks of their respective owners.
42.12 +
42.13 +The contents of this file are subject to the terms of either the GNU
42.14 +General Public License Version 2 only ("GPL") or the Common
42.15 +Development and Distribution License("CDDL") (collectively, the
42.16 +"License"). You may not use this file except in compliance with the
42.17 +License. You can obtain a copy of the License at
42.18 +http://www.netbeans.org/cddl-gplv2.html
42.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
42.20 +specific language governing permissions and limitations under the
42.21 +License. When distributing the software, include this License Header
42.22 +Notice in each file and include the License file at
42.23 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
42.24 +particular file as subject to the "Classpath" exception as provided
42.25 +by Oracle in the GPL Version 2 section of the License file that
42.26 +accompanied this code. If applicable, add the following below the
42.27 +License Header, with the fields enclosed by brackets [] replaced by
42.28 +your own identifying information:
42.29 +"Portions Copyrighted [year] [name of copyright owner]"
42.30 +
42.31 +If you wish your version of this file to be governed by only the CDDL
42.32 +or only the GPL Version 2, indicate your decision by adding
42.33 +"[Contributor] elects to include this software in this distribution
42.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
42.35 +single choice of license, a recipient has the option to distribute
42.36 +your version of this file under either the CDDL, the GPL Version 2 or
42.37 +to extend the choice of license to its licensees as provided above.
42.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
42.39 +Version 2 license, then the option applies only if the new code is
42.40 +made subject to such option by the copyright holder.
42.41 +
42.42 +Contributor(s):
42.43 +-->
42.44 +<project xmlns="http://www.netbeans.org/ns/project/1">
42.45 + <type>org.netbeans.modules.cnd.makeproject</type>
42.46 + <configuration>
42.47 + <data xmlns="http://www.netbeans.org/ns/make-project/1">
42.48 + <name>hello-cmake-world</name>
42.49 + <c-extensions/>
42.50 + <cpp-extensions>cpp</cpp-extensions>
42.51 + <header-extensions>h</header-extensions>
42.52 + <sourceEncoding>UTF-8</sourceEncoding>
42.53 + <sourceRootList>
42.54 + <sourceRootElem>.</sourceRootElem>
42.55 + </sourceRootList>
42.56 + <make-dep-projects/>
42.57 + <sourceRootList>
42.58 + <sourceRootElem>.</sourceRootElem>
42.59 + </sourceRootList>
42.60 + <confList>
42.61 + <confElem>
42.62 + <name>Debug</name>
42.63 + <type>0</type>
42.64 + </confElem>
42.65 + <confElem>
42.66 + <name>Release</name>
42.67 + <type>0</type>
42.68 + </confElem>
42.69 + </confList>
42.70 + <formatting>
42.71 + <project-formatting-style>false</project-formatting-style>
42.72 + </formatting>
42.73 + </data>
42.74 + </configuration>
42.75 +</project>
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/CMakeLists.txt Wed Jun 07 20:23:29 2017 +0300
43.3 @@ -0,0 +1,4 @@
43.4 +set(CMAKE_CXX_STANDARD 11)
43.5 +add_library (tu_1 source_1.cpp)
43.6 +add_library (tu_2 source_2.cpp)
43.7 +add_library (tu_3 source_3.cpp)
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/header.h Wed Jun 07 20:23:29 2017 +0300
44.3 @@ -0,0 +1,8 @@
44.4 +#ifndef HEADER_H
44.5 +#define HEADER_H
44.6 +
44.7 +using namespace std;
44.8 +
44.9 +#endif /* HEADER_H */
44.10 +
44.11 +
44.12 \ No newline at end of file
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_1.cpp Wed Jun 07 20:23:29 2017 +0300
45.3 @@ -0,0 +1,1 @@
45.4 +#include "header.h"
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_2.cpp Wed Jun 07 20:23:29 2017 +0300
46.3 @@ -0,0 +1,1 @@
46.4 +#include "header.h"
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_3.cpp Wed Jun 07 20:23:29 2017 +0300
47.3 @@ -0,0 +1,1 @@
47.4 +#include "header.h"
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_4.cpp Wed Jun 07 20:23:29 2017 +0300
48.3 @@ -0,0 +1,1 @@
48.4 +#include "header.h"
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt Wed Jun 07 20:23:29 2017 +0300
49.3 @@ -0,0 +1,2 @@
49.4 +project (HelloCMake)
49.5 +add_subdirectory (src)
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml Wed Jun 07 20:23:29 2017 +0300
50.3 @@ -0,0 +1,143 @@
50.4 +<?xml version="1.0" encoding="UTF-8"?>
50.5 +<!--
50.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
50.7 +
50.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
50.9 +
50.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
50.11 +Other names may be trademarks of their respective owners.
50.12 +
50.13 +The contents of this file are subject to the terms of either the GNU
50.14 +General Public License Version 2 only ("GPL") or the Common
50.15 +Development and Distribution License("CDDL") (collectively, the
50.16 +"License"). You may not use this file except in compliance with the
50.17 +License. You can obtain a copy of the License at
50.18 +http://www.netbeans.org/cddl-gplv2.html
50.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
50.20 +specific language governing permissions and limitations under the
50.21 +License. When distributing the software, include this License Header
50.22 +Notice in each file and include the License file at
50.23 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
50.24 +particular file as subject to the "Classpath" exception as provided
50.25 +by Oracle in the GPL Version 2 section of the License file that
50.26 +accompanied this code. If applicable, add the following below the
50.27 +License Header, with the fields enclosed by brackets [] replaced by
50.28 +your own identifying information:
50.29 +"Portions Copyrighted [year] [name of copyright owner]"
50.30 +
50.31 +If you wish your version of this file to be governed by only the CDDL
50.32 +or only the GPL Version 2, indicate your decision by adding
50.33 +"[Contributor] elects to include this software in this distribution
50.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
50.35 +single choice of license, a recipient has the option to distribute
50.36 +your version of this file under either the CDDL, the GPL Version 2 or
50.37 +to extend the choice of license to its licensees as provided above.
50.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
50.39 +Version 2 license, then the option applies only if the new code is
50.40 +made subject to such option by the copyright holder.
50.41 +
50.42 +Contributor(s):
50.43 +-->
50.44 +<configurationDescriptor version="100">
50.45 + <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
50.46 + <df root="." name="0">
50.47 + <df name="src">
50.48 + <in>modernize-loop-convert.cpp</in>
50.49 + <in>modernize-raw-string-literal.cpp</in>
50.50 + <in>modernize-use-nullptr.cpp</in>
50.51 + </df>
50.52 + </df>
50.53 + <logicalFolder name="ExternalFiles"
50.54 + displayName="Important Files"
50.55 + projectFiles="false"
50.56 + kind="IMPORTANT_FILES_FOLDER">
50.57 + <itemPath>CMakeLists.txt</itemPath>
50.58 + <itemPath>build/Debug/Makefile</itemPath>
50.59 + <itemPath>build/Release/Makefile</itemPath>
50.60 + </logicalFolder>
50.61 + </logicalFolder>
50.62 + <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
50.63 + <sourceRootList>
50.64 + <Elem>.</Elem>
50.65 + </sourceRootList>
50.66 + <projectmakefile>build/Debug/Makefile</projectmakefile>
50.67 + <confs>
50.68 + <conf name="Debug" type="0">
50.69 + <toolsSet>
50.70 + <compilerSet>default</compilerSet>
50.71 + <dependencyChecking>false</dependencyChecking>
50.72 + <rebuildPropChanged>false</rebuildPropChanged>
50.73 + </toolsSet>
50.74 + <flagsDictionary>
50.75 + <element flagsID="0" commonFlags="-std=gnu++11"/>
50.76 + </flagsDictionary>
50.77 + <codeAssistance>
50.78 + </codeAssistance>
50.79 + <makefileType>
50.80 + <makeTool>
50.81 + <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
50.82 + <buildCommand>${MAKE} -f Makefile</buildCommand>
50.83 + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
50.84 + <executablePath>build/Debug/src/welcome</executablePath>
50.85 + <ccTool flags="0">
50.86 + <incDir>
50.87 + <pElem>build/Debug/src</pElem>
50.88 + </incDir>
50.89 + </ccTool>
50.90 + </makeTool>
50.91 + <preBuild>
50.92 + <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
50.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>
50.94 + <preBuildFirst>true</preBuildFirst>
50.95 + </preBuild>
50.96 + </makefileType>
50.97 + <item path="src/modernize-loop-convert.cpp" ex="false" tool="1" flavor2="8">
50.98 + <ccTool flags="0">
50.99 + </ccTool>
50.100 + </item>
50.101 + <item path="src/modernize-raw-string-literal.cpp"
50.102 + ex="false"
50.103 + tool="1"
50.104 + flavor2="8">
50.105 + <ccTool flags="0">
50.106 + </ccTool>
50.107 + </item>
50.108 + <item path="src/modernize-use-nullptr.cpp" ex="false" tool="1" flavor2="8">
50.109 + <ccTool flags="0">
50.110 + </ccTool>
50.111 + </item>
50.112 + </conf>
50.113 + <conf name="Release" type="0">
50.114 + <toolsSet>
50.115 + <compilerSet>default</compilerSet>
50.116 + <dependencyChecking>false</dependencyChecking>
50.117 + <rebuildPropChanged>false</rebuildPropChanged>
50.118 + </toolsSet>
50.119 + <codeAssistance>
50.120 + </codeAssistance>
50.121 + <makefileType>
50.122 + <makeTool>
50.123 + <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
50.124 + <buildCommand>${MAKE} -f Makefile</buildCommand>
50.125 + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
50.126 + <executablePath>build/Release/src/welcome</executablePath>
50.127 + <ccTool>
50.128 + <incDir>
50.129 + <pElem>build/Release/src</pElem>
50.130 + </incDir>
50.131 + <preprocessorList>
50.132 + <Elem>NDEBUG</Elem>
50.133 + </preprocessorList>
50.134 + </ccTool>
50.135 + </makeTool>
50.136 + <preBuild>
50.137 + <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
50.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>
50.139 + <preBuildFirst>true</preBuildFirst>
50.140 + </preBuild>
50.141 + </makefileType>
50.142 + <item path="src/modernize-use-nullptr.cpp" ex="false" tool="1" flavor2="0">
50.143 + </item>
50.144 + </conf>
50.145 + </confs>
50.146 +</configurationDescriptor>
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml Wed Jun 07 20:23:29 2017 +0300
51.3 @@ -0,0 +1,72 @@
51.4 +<?xml version="1.0" encoding="UTF-8"?>
51.5 +<!--
51.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
51.7 +
51.8 +Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
51.9 +
51.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
51.11 +Other names may be trademarks of their respective owners.
51.12 +
51.13 +The contents of this file are subject to the terms of either the GNU
51.14 +General Public License Version 2 only ("GPL") or the Common
51.15 +Development and Distribution License("CDDL") (collectively, the
51.16 +"License"). You may not use this file except in compliance with the
51.17 +License. You can obtain a copy of the License at
51.18 +http://www.netbeans.org/cddl-gplv2.html
51.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
51.20 +specific language governing permissions and limitations under the
51.21 +License. When distributing the software, include this License Header
51.22 +Notice in each file and include the License file at
51.23 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
51.24 +particular file as subject to the "Classpath" exception as provided
51.25 +by Oracle in the GPL Version 2 section of the License file that
51.26 +accompanied this code. If applicable, add the following below the
51.27 +License Header, with the fields enclosed by brackets [] replaced by
51.28 +your own identifying information:
51.29 +"Portions Copyrighted [year] [name of copyright owner]"
51.30 +
51.31 +If you wish your version of this file to be governed by only the CDDL
51.32 +or only the GPL Version 2, indicate your decision by adding
51.33 +"[Contributor] elects to include this software in this distribution
51.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
51.35 +single choice of license, a recipient has the option to distribute
51.36 +your version of this file under either the CDDL, the GPL Version 2 or
51.37 +to extend the choice of license to its licensees as provided above.
51.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
51.39 +Version 2 license, then the option applies only if the new code is
51.40 +made subject to such option by the copyright holder.
51.41 +
51.42 +Contributor(s):
51.43 +-->
51.44 +<project xmlns="http://www.netbeans.org/ns/project/1">
51.45 + <type>org.netbeans.modules.cnd.makeproject</type>
51.46 + <configuration>
51.47 + <data xmlns="http://www.netbeans.org/ns/make-project/1">
51.48 + <name>hello-cmake-world</name>
51.49 + <c-extensions/>
51.50 + <cpp-extensions>cpp</cpp-extensions>
51.51 + <header-extensions>h</header-extensions>
51.52 + <sourceEncoding>UTF-8</sourceEncoding>
51.53 + <sourceRootList>
51.54 + <sourceRootElem>.</sourceRootElem>
51.55 + </sourceRootList>
51.56 + <make-dep-projects/>
51.57 + <sourceRootList>
51.58 + <sourceRootElem>.</sourceRootElem>
51.59 + </sourceRootList>
51.60 + <confList>
51.61 + <confElem>
51.62 + <name>Debug</name>
51.63 + <type>0</type>
51.64 + </confElem>
51.65 + <confElem>
51.66 + <name>Release</name>
51.67 + <type>0</type>
51.68 + </confElem>
51.69 + </confList>
51.70 + <formatting>
51.71 + <project-formatting-style>false</project-formatting-style>
51.72 + </formatting>
51.73 + </data>
51.74 + </configuration>
51.75 +</project>
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt Wed Jun 07 20:23:29 2017 +0300
52.3 @@ -0,0 +1,2 @@
52.4 +set(CMAKE_CXX_STANDARD 11)
52.5 +add_library (single-cpp-file-check modernize-use-nullptr.cpp modernize-loop-convert.cpp modernize-raw-string-literal.cpp)
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp Wed Jun 07 20:23:29 2017 +0300
53.3 @@ -0,0 +1,1 @@
53.4 +#include "llvm-header-guard.h"
53.5 \ No newline at end of file
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp Wed Jun 07 20:23:29 2017 +0300
54.3 @@ -0,0 +1,25 @@
54.4 +#include <vector>
54.5 +#include <iostream>
54.6 +
54.7 +using namespace std;
54.8 +
54.9 +int loops() {
54.10 + const int N = 5;
54.11 + int arr[] = {1, 2, 3, 4, 5};
54.12 + vector<int> v;
54.13 + v.push_back(1);
54.14 + v.push_back(2);
54.15 + v.push_back(3);
54.16 +
54.17 + // safe conversion
54.18 + for (int i = 0; i < N; ++i)
54.19 + cout << arr[i];
54.20 +
54.21 + // reasonable conversion
54.22 + for (vector<int>::iterator it = v.begin(); it != v.end(); ++it)
54.23 + cout << *it;
54.24 +
54.25 + // reasonable conversion
54.26 + for (int i = 0; i < v.size(); ++i)
54.27 + cout << v[i];
54.28 +}
54.29 \ No newline at end of file
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp Wed Jun 07 20:23:29 2017 +0300
55.3 @@ -0,0 +1,8 @@
55.4 +const char *const Quotes{"embedded \"quotes\""};
55.5 +const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"};
55.6 +const char *const SingleLine{"Single line.\n"};
55.7 +const char *const TrailingSpace{"Look here -> \n"};
55.8 +const char *const Tab{"One\tTwo\n"};
55.9 +const char *const Bell{"Hello!\a And welcome!"};
55.10 +const char *const Path{"C:\\Program Files\\Vendor\\Application.exe"};
55.11 +const char *const RegEx{"\\w\\([a-z]\\)"};
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp Wed Jun 07 20:23:29 2017 +0300
56.3 @@ -0,0 +1,11 @@
56.4 +#include <cstddef>
56.5 +
56.6 +void assignment() {
56.7 + char *a = NULL;
56.8 + char *b = 0;
56.9 + char c = 0;
56.10 +}
56.11 +
56.12 +int *ret_ptr() {
56.13 + return 0;
56.14 +}
56.15 \ No newline at end of file
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/.dep.inc Wed Jun 07 20:23:29 2017 +0300
57.3 @@ -0,0 +1,5 @@
57.4 +# This code depends on make tool being used
57.5 +DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES}))
57.6 +ifneq (${DEPFILES},)
57.7 +include ${DEPFILES}
57.8 +endif
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/Makefile Wed Jun 07 20:23:29 2017 +0300
58.3 @@ -0,0 +1,128 @@
58.4 +#
58.5 +# There exist several targets which are by default empty and which can be
58.6 +# used for execution of your targets. These targets are usually executed
58.7 +# before and after some main targets. They are:
58.8 +#
58.9 +# .build-pre: called before 'build' target
58.10 +# .build-post: called after 'build' target
58.11 +# .clean-pre: called before 'clean' target
58.12 +# .clean-post: called after 'clean' target
58.13 +# .clobber-pre: called before 'clobber' target
58.14 +# .clobber-post: called after 'clobber' target
58.15 +# .all-pre: called before 'all' target
58.16 +# .all-post: called after 'all' target
58.17 +# .help-pre: called before 'help' target
58.18 +# .help-post: called after 'help' target
58.19 +#
58.20 +# Targets beginning with '.' are not intended to be called on their own.
58.21 +#
58.22 +# Main targets can be executed directly, and they are:
58.23 +#
58.24 +# build build a specific configuration
58.25 +# clean remove built files from a configuration
58.26 +# clobber remove all built files
58.27 +# all build all configurations
58.28 +# help print help mesage
58.29 +#
58.30 +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
58.31 +# .help-impl are implemented in nbproject/makefile-impl.mk.
58.32 +#
58.33 +# Available make variables:
58.34 +#
58.35 +# CND_BASEDIR base directory for relative paths
58.36 +# CND_DISTDIR default top distribution directory (build artifacts)
58.37 +# CND_BUILDDIR default top build directory (object files, ...)
58.38 +# CONF name of current configuration
58.39 +# CND_PLATFORM_${CONF} platform name (current configuration)
58.40 +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
58.41 +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
58.42 +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
58.43 +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
58.44 +# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
58.45 +# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
58.46 +#
58.47 +# NOCDDL
58.48 +
58.49 +
58.50 +# Environment
58.51 +MKDIR=mkdir
58.52 +CP=cp
58.53 +CCADMIN=CCadmin
58.54 +
58.55 +
58.56 +# build
58.57 +build: .build-post
58.58 +
58.59 +.build-pre:
58.60 +# Add your pre 'build' code here...
58.61 +
58.62 +.build-post: .build-impl
58.63 +# Add your post 'build' code here...
58.64 +
58.65 +
58.66 +# clean
58.67 +clean: .clean-post
58.68 +
58.69 +.clean-pre:
58.70 +# Add your pre 'clean' code here...
58.71 +
58.72 +.clean-post: .clean-impl
58.73 +# Add your post 'clean' code here...
58.74 +
58.75 +
58.76 +# clobber
58.77 +clobber: .clobber-post
58.78 +
58.79 +.clobber-pre:
58.80 +# Add your pre 'clobber' code here...
58.81 +
58.82 +.clobber-post: .clobber-impl
58.83 +# Add your post 'clobber' code here...
58.84 +
58.85 +
58.86 +# all
58.87 +all: .all-post
58.88 +
58.89 +.all-pre:
58.90 +# Add your pre 'all' code here...
58.91 +
58.92 +.all-post: .all-impl
58.93 +# Add your post 'all' code here...
58.94 +
58.95 +
58.96 +# build tests
58.97 +build-tests: .build-tests-post
58.98 +
58.99 +.build-tests-pre:
58.100 +# Add your pre 'build-tests' code here...
58.101 +
58.102 +.build-tests-post: .build-tests-impl
58.103 +# Add your post 'build-tests' code here...
58.104 +
58.105 +
58.106 +# run tests
58.107 +test: .test-post
58.108 +
58.109 +.test-pre: build-tests
58.110 +# Add your pre 'test' code here...
58.111 +
58.112 +.test-post: .test-impl
58.113 +# Add your post 'test' code here...
58.114 +
58.115 +
58.116 +# help
58.117 +help: .help-post
58.118 +
58.119 +.help-pre:
58.120 +# Add your pre 'help' code here...
58.121 +
58.122 +.help-post: .help-impl
58.123 +# Add your post 'help' code here...
58.124 +
58.125 +
58.126 +
58.127 +# include project implementation makefile
58.128 +include nbproject/Makefile-impl.mk
58.129 +
58.130 +# include project make variables
58.131 +include nbproject/Makefile-variables.mk
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk Wed Jun 07 20:23:29 2017 +0300
59.3 @@ -0,0 +1,83 @@
59.4 +#
59.5 +# Generated Makefile - do not edit!
59.6 +#
59.7 +# Edit the Makefile in the project folder instead (../Makefile). Each target
59.8 +# has a -pre and a -post target defined where you can add customized code.
59.9 +#
59.10 +# This makefile implements configuration specific macros and targets.
59.11 +
59.12 +
59.13 +# Environment
59.14 +MKDIR=mkdir
59.15 +CP=cp
59.16 +GREP=grep
59.17 +NM=nm
59.18 +CCADMIN=CCadmin
59.19 +RANLIB=ranlib
59.20 +CC=gcc
59.21 +CCC=g++
59.22 +CXX=g++
59.23 +FC=gfortran
59.24 +AS=as
59.25 +
59.26 +# Macros
59.27 +CND_PLATFORM=GNU-Linux
59.28 +CND_DLIB_EXT=so
59.29 +CND_CONF=Debug
59.30 +CND_DISTDIR=dist
59.31 +CND_BUILDDIR=build
59.32 +
59.33 +# Include project Makefile
59.34 +include Makefile
59.35 +
59.36 +# Object Directory
59.37 +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
59.38 +
59.39 +# Object Files
59.40 +OBJECTFILES= \
59.41 + ${OBJECTDIR}/welcome.o
59.42 +
59.43 +
59.44 +# C Compiler Flags
59.45 +CFLAGS=
59.46 +
59.47 +# CC Compiler Flags
59.48 +CCFLAGS=
59.49 +CXXFLAGS=
59.50 +
59.51 +# Fortran Compiler Flags
59.52 +FFLAGS=
59.53 +
59.54 +# Assembler Flags
59.55 +ASFLAGS=
59.56 +
59.57 +# Link Libraries and Options
59.58 +LDLIBSOPTIONS=
59.59 +
59.60 +# Build Targets
59.61 +.build-conf: ${BUILD_SUBPROJECTS}
59.62 + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
59.63 +
59.64 +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES}
59.65 + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
59.66 + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS}
59.67 +
59.68 +${OBJECTDIR}/welcome.o: welcome.cc
59.69 + ${MKDIR} -p ${OBJECTDIR}
59.70 + ${RM} "$@.d"
59.71 + $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc
59.72 +
59.73 +# Subprojects
59.74 +.build-subprojects:
59.75 +
59.76 +# Clean Targets
59.77 +.clean-conf: ${CLEAN_SUBPROJECTS}
59.78 + ${RM} -r ${CND_BUILDDIR}/${CND_CONF}
59.79 +
59.80 +# Subprojects
59.81 +.clean-subprojects:
59.82 +
59.83 +# Enable dependency checking
59.84 +.dep.inc: .depcheck-impl
59.85 +
59.86 +include .dep.inc
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk Wed Jun 07 20:23:29 2017 +0300
60.3 @@ -0,0 +1,83 @@
60.4 +#
60.5 +# Generated Makefile - do not edit!
60.6 +#
60.7 +# Edit the Makefile in the project folder instead (../Makefile). Each target
60.8 +# has a -pre and a -post target defined where you can add customized code.
60.9 +#
60.10 +# This makefile implements configuration specific macros and targets.
60.11 +
60.12 +
60.13 +# Environment
60.14 +MKDIR=mkdir
60.15 +CP=cp
60.16 +GREP=grep
60.17 +NM=nm
60.18 +CCADMIN=CCadmin
60.19 +RANLIB=ranlib
60.20 +CC=gcc
60.21 +CCC=g++
60.22 +CXX=g++
60.23 +FC=gfortran
60.24 +AS=as
60.25 +
60.26 +# Macros
60.27 +CND_PLATFORM=GNU-Linux
60.28 +CND_DLIB_EXT=so
60.29 +CND_CONF=Release
60.30 +CND_DISTDIR=dist
60.31 +CND_BUILDDIR=build
60.32 +
60.33 +# Include project Makefile
60.34 +include Makefile
60.35 +
60.36 +# Object Directory
60.37 +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
60.38 +
60.39 +# Object Files
60.40 +OBJECTFILES= \
60.41 + ${OBJECTDIR}/welcome.o
60.42 +
60.43 +
60.44 +# C Compiler Flags
60.45 +CFLAGS=
60.46 +
60.47 +# CC Compiler Flags
60.48 +CCFLAGS=
60.49 +CXXFLAGS=
60.50 +
60.51 +# Fortran Compiler Flags
60.52 +FFLAGS=
60.53 +
60.54 +# Assembler Flags
60.55 +ASFLAGS=
60.56 +
60.57 +# Link Libraries and Options
60.58 +LDLIBSOPTIONS=
60.59 +
60.60 +# Build Targets
60.61 +.build-conf: ${BUILD_SUBPROJECTS}
60.62 + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
60.63 +
60.64 +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES}
60.65 + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
60.66 + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS}
60.67 +
60.68 +${OBJECTDIR}/welcome.o: welcome.cc
60.69 + ${MKDIR} -p ${OBJECTDIR}
60.70 + ${RM} "$@.d"
60.71 + $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc
60.72 +
60.73 +# Subprojects
60.74 +.build-subprojects:
60.75 +
60.76 +# Clean Targets
60.77 +.clean-conf: ${CLEAN_SUBPROJECTS}
60.78 + ${RM} -r ${CND_BUILDDIR}/${CND_CONF}
60.79 +
60.80 +# Subprojects
60.81 +.clean-subprojects:
60.82 +
60.83 +# Enable dependency checking
60.84 +.dep.inc: .depcheck-impl
60.85 +
60.86 +include .dep.inc
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk Wed Jun 07 20:23:29 2017 +0300
61.3 @@ -0,0 +1,133 @@
61.4 +#
61.5 +# Generated Makefile - do not edit!
61.6 +#
61.7 +# Edit the Makefile in the project folder instead (../Makefile). Each target
61.8 +# has a pre- and a post- target defined where you can add customization code.
61.9 +#
61.10 +# This makefile implements macros and targets common to all configurations.
61.11 +#
61.12 +# NOCDDL
61.13 +
61.14 +
61.15 +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
61.16 +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
61.17 +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
61.18 +# and .clean-reqprojects-conf unless SUB has the value 'no'
61.19 +SUB_no=NO
61.20 +SUBPROJECTS=${SUB_${SUB}}
61.21 +BUILD_SUBPROJECTS_=.build-subprojects
61.22 +BUILD_SUBPROJECTS_NO=
61.23 +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
61.24 +CLEAN_SUBPROJECTS_=.clean-subprojects
61.25 +CLEAN_SUBPROJECTS_NO=
61.26 +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
61.27 +
61.28 +
61.29 +# Project Name
61.30 +PROJECTNAME=hello-world
61.31 +
61.32 +# Active Configuration
61.33 +DEFAULTCONF=Debug
61.34 +CONF=${DEFAULTCONF}
61.35 +
61.36 +# All Configurations
61.37 +ALLCONFS=Debug Release
61.38 +
61.39 +
61.40 +# build
61.41 +.build-impl: .build-pre .validate-impl .depcheck-impl
61.42 + @#echo "=> Running $@... Configuration=$(CONF)"
61.43 + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
61.44 +
61.45 +
61.46 +# clean
61.47 +.clean-impl: .clean-pre .validate-impl .depcheck-impl
61.48 + @#echo "=> Running $@... Configuration=$(CONF)"
61.49 + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
61.50 +
61.51 +
61.52 +# clobber
61.53 +.clobber-impl: .clobber-pre .depcheck-impl
61.54 + @#echo "=> Running $@..."
61.55 + for CONF in ${ALLCONFS}; \
61.56 + do \
61.57 + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
61.58 + done
61.59 +
61.60 +# all
61.61 +.all-impl: .all-pre .depcheck-impl
61.62 + @#echo "=> Running $@..."
61.63 + for CONF in ${ALLCONFS}; \
61.64 + do \
61.65 + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
61.66 + done
61.67 +
61.68 +# build tests
61.69 +.build-tests-impl: .build-impl .build-tests-pre
61.70 + @#echo "=> Running $@... Configuration=$(CONF)"
61.71 + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
61.72 +
61.73 +# run tests
61.74 +.test-impl: .build-tests-impl .test-pre
61.75 + @#echo "=> Running $@... Configuration=$(CONF)"
61.76 + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
61.77 +
61.78 +# dependency checking support
61.79 +.depcheck-impl:
61.80 + @echo "# This code depends on make tool being used" >.dep.inc
61.81 + @if [ -n "${MAKE_VERSION}" ]; then \
61.82 + echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
61.83 + echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
61.84 + echo "include \$${DEPFILES}" >>.dep.inc; \
61.85 + echo "endif" >>.dep.inc; \
61.86 + else \
61.87 + echo ".KEEP_STATE:" >>.dep.inc; \
61.88 + echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
61.89 + fi
61.90 +
61.91 +# configuration validation
61.92 +.validate-impl:
61.93 + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
61.94 + then \
61.95 + echo ""; \
61.96 + echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
61.97 + echo "See 'make help' for details."; \
61.98 + echo "Current directory: " `pwd`; \
61.99 + echo ""; \
61.100 + fi
61.101 + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
61.102 + then \
61.103 + exit 1; \
61.104 + fi
61.105 +
61.106 +
61.107 +# help
61.108 +.help-impl: .help-pre
61.109 + @echo "This makefile supports the following configurations:"
61.110 + @echo " ${ALLCONFS}"
61.111 + @echo ""
61.112 + @echo "and the following targets:"
61.113 + @echo " build (default target)"
61.114 + @echo " clean"
61.115 + @echo " clobber"
61.116 + @echo " all"
61.117 + @echo " help"
61.118 + @echo ""
61.119 + @echo "Makefile Usage:"
61.120 + @echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
61.121 + @echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
61.122 + @echo " make [SUB=no] clobber"
61.123 + @echo " make [SUB=no] all"
61.124 + @echo " make help"
61.125 + @echo ""
61.126 + @echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
61.127 + @echo " also build subprojects."
61.128 + @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
61.129 + @echo " also clean subprojects."
61.130 + @echo "Target 'clobber' will remove all built files from all configurations and,"
61.131 + @echo " unless 'SUB=no', also from subprojects."
61.132 + @echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
61.133 + @echo " also build subprojects."
61.134 + @echo "Target 'help' prints this message."
61.135 + @echo ""
61.136 +
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk Wed Jun 07 20:23:29 2017 +0300
62.3 @@ -0,0 +1,35 @@
62.4 +#
62.5 +# Generated - do not edit!
62.6 +#
62.7 +# NOCDDL
62.8 +#
62.9 +CND_BASEDIR=`pwd`
62.10 +CND_BUILDDIR=build
62.11 +CND_DISTDIR=dist
62.12 +# Debug configuration
62.13 +CND_PLATFORM_Debug=GNU-Linux
62.14 +CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux
62.15 +CND_ARTIFACT_NAME_Debug=hello-world
62.16 +CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/hello-world
62.17 +CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
62.18 +CND_PACKAGE_NAME_Debug=hello-world.tar
62.19 +CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/hello-world.tar
62.20 +# Release configuration
62.21 +CND_PLATFORM_Release=GNU-Linux
62.22 +CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux
62.23 +CND_ARTIFACT_NAME_Release=hello-world
62.24 +CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/hello-world
62.25 +CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package
62.26 +CND_PACKAGE_NAME_Release=hello-world.tar
62.27 +CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/hello-world.tar
62.28 +#
62.29 +# include compiler specific variables
62.30 +#
62.31 +# dmake command
62.32 +ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
62.33 + (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
62.34 +#
62.35 +# gmake command
62.36 +.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
62.37 +#
62.38 +include nbproject/private/Makefile-variables.mk
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash Wed Jun 07 20:23:29 2017 +0300
63.3 @@ -0,0 +1,76 @@
63.4 +#!/bin/bash -x
63.5 +
63.6 +#
63.7 +# Generated - do not edit!
63.8 +#
63.9 +
63.10 +# Macros
63.11 +TOP=`pwd`
63.12 +CND_PLATFORM=GNU-Linux
63.13 +CND_CONF=Debug
63.14 +CND_DISTDIR=dist
63.15 +CND_BUILDDIR=build
63.16 +CND_DLIB_EXT=so
63.17 +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
63.18 +TMPDIRNAME=tmp-packaging
63.19 +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
63.20 +OUTPUT_BASENAME=hello-world
63.21 +PACKAGE_TOP_DIR=hello-world/
63.22 +
63.23 +# Functions
63.24 +function checkReturnCode
63.25 +{
63.26 + rc=$?
63.27 + if [ $rc != 0 ]
63.28 + then
63.29 + exit $rc
63.30 + fi
63.31 +}
63.32 +function makeDirectory
63.33 +# $1 directory path
63.34 +# $2 permission (optional)
63.35 +{
63.36 + mkdir -p "$1"
63.37 + checkReturnCode
63.38 + if [ "$2" != "" ]
63.39 + then
63.40 + chmod $2 "$1"
63.41 + checkReturnCode
63.42 + fi
63.43 +}
63.44 +function copyFileToTmpDir
63.45 +# $1 from-file path
63.46 +# $2 to-file path
63.47 +# $3 permission
63.48 +{
63.49 + cp "$1" "$2"
63.50 + checkReturnCode
63.51 + if [ "$3" != "" ]
63.52 + then
63.53 + chmod $3 "$2"
63.54 + checkReturnCode
63.55 + fi
63.56 +}
63.57 +
63.58 +# Setup
63.59 +cd "${TOP}"
63.60 +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
63.61 +rm -rf ${NBTMPDIR}
63.62 +mkdir -p ${NBTMPDIR}
63.63 +
63.64 +# Copy files and create directories and links
63.65 +cd "${TOP}"
63.66 +makeDirectory "${NBTMPDIR}/hello-world/bin"
63.67 +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
63.68 +
63.69 +
63.70 +# Generate tar file
63.71 +cd "${TOP}"
63.72 +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar
63.73 +cd ${NBTMPDIR}
63.74 +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar *
63.75 +checkReturnCode
63.76 +
63.77 +# Cleanup
63.78 +cd "${TOP}"
63.79 +rm -rf ${NBTMPDIR}
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
64.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash Wed Jun 07 20:23:29 2017 +0300
64.3 @@ -0,0 +1,76 @@
64.4 +#!/bin/bash -x
64.5 +
64.6 +#
64.7 +# Generated - do not edit!
64.8 +#
64.9 +
64.10 +# Macros
64.11 +TOP=`pwd`
64.12 +CND_PLATFORM=GNU-Linux
64.13 +CND_CONF=Release
64.14 +CND_DISTDIR=dist
64.15 +CND_BUILDDIR=build
64.16 +CND_DLIB_EXT=so
64.17 +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
64.18 +TMPDIRNAME=tmp-packaging
64.19 +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
64.20 +OUTPUT_BASENAME=hello-world
64.21 +PACKAGE_TOP_DIR=hello-world/
64.22 +
64.23 +# Functions
64.24 +function checkReturnCode
64.25 +{
64.26 + rc=$?
64.27 + if [ $rc != 0 ]
64.28 + then
64.29 + exit $rc
64.30 + fi
64.31 +}
64.32 +function makeDirectory
64.33 +# $1 directory path
64.34 +# $2 permission (optional)
64.35 +{
64.36 + mkdir -p "$1"
64.37 + checkReturnCode
64.38 + if [ "$2" != "" ]
64.39 + then
64.40 + chmod $2 "$1"
64.41 + checkReturnCode
64.42 + fi
64.43 +}
64.44 +function copyFileToTmpDir
64.45 +# $1 from-file path
64.46 +# $2 to-file path
64.47 +# $3 permission
64.48 +{
64.49 + cp "$1" "$2"
64.50 + checkReturnCode
64.51 + if [ "$3" != "" ]
64.52 + then
64.53 + chmod $3 "$2"
64.54 + checkReturnCode
64.55 + fi
64.56 +}
64.57 +
64.58 +# Setup
64.59 +cd "${TOP}"
64.60 +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
64.61 +rm -rf ${NBTMPDIR}
64.62 +mkdir -p ${NBTMPDIR}
64.63 +
64.64 +# Copy files and create directories and links
64.65 +cd "${TOP}"
64.66 +makeDirectory "${NBTMPDIR}/hello-world/bin"
64.67 +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
64.68 +
64.69 +
64.70 +# Generate tar file
64.71 +cd "${TOP}"
64.72 +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar
64.73 +cd ${NBTMPDIR}
64.74 +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar *
64.75 +checkReturnCode
64.76 +
64.77 +# Cleanup
64.78 +cd "${TOP}"
64.79 +rm -rf ${NBTMPDIR}
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
65.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml Wed Jun 07 20:23:29 2017 +0300
65.3 @@ -0,0 +1,71 @@
65.4 +<?xml version="1.0" encoding="UTF-8"?>
65.5 +<configurationDescriptor version="100">
65.6 + <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
65.7 + <logicalFolder name="HeaderFiles"
65.8 + displayName="Header Files"
65.9 + projectFiles="true">
65.10 + <itemPath>welcome.h</itemPath>
65.11 + </logicalFolder>
65.12 + <logicalFolder name="ResourceFiles"
65.13 + displayName="Resource Files"
65.14 + projectFiles="true">
65.15 + </logicalFolder>
65.16 + <logicalFolder name="SourceFiles"
65.17 + displayName="Source Files"
65.18 + projectFiles="true">
65.19 + <itemPath>welcome.cc</itemPath>
65.20 + </logicalFolder>
65.21 + <logicalFolder name="TestFiles"
65.22 + displayName="Test Files"
65.23 + projectFiles="false"
65.24 + kind="TEST_LOGICAL_FOLDER">
65.25 + </logicalFolder>
65.26 + <logicalFolder name="ExternalFiles"
65.27 + displayName="Important Files"
65.28 + projectFiles="false"
65.29 + kind="IMPORTANT_FILES_FOLDER">
65.30 + <itemPath>Makefile</itemPath>
65.31 + </logicalFolder>
65.32 + </logicalFolder>
65.33 + <projectmakefile>Makefile</projectmakefile>
65.34 + <confs>
65.35 + <conf name="Debug" type="1">
65.36 + <toolsSet>
65.37 + <compilerSet>default</compilerSet>
65.38 + <dependencyChecking>true</dependencyChecking>
65.39 + <rebuildPropChanged>false</rebuildPropChanged>
65.40 + </toolsSet>
65.41 + <compileType>
65.42 + </compileType>
65.43 + <item path="welcome.cc" ex="false" tool="1" flavor2="0">
65.44 + </item>
65.45 + <item path="welcome.h" ex="false" tool="3" flavor2="0">
65.46 + </item>
65.47 + </conf>
65.48 + <conf name="Release" type="1">
65.49 + <toolsSet>
65.50 + <compilerSet>default</compilerSet>
65.51 + <dependencyChecking>true</dependencyChecking>
65.52 + <rebuildPropChanged>false</rebuildPropChanged>
65.53 + </toolsSet>
65.54 + <compileType>
65.55 + <cTool>
65.56 + <developmentMode>5</developmentMode>
65.57 + </cTool>
65.58 + <ccTool>
65.59 + <developmentMode>5</developmentMode>
65.60 + </ccTool>
65.61 + <fortranCompilerTool>
65.62 + <developmentMode>5</developmentMode>
65.63 + </fortranCompilerTool>
65.64 + <asmTool>
65.65 + <developmentMode>5</developmentMode>
65.66 + </asmTool>
65.67 + </compileType>
65.68 + <item path="welcome.cc" ex="false" tool="1" flavor2="0">
65.69 + </item>
65.70 + <item path="welcome.h" ex="false" tool="3" flavor2="0">
65.71 + </item>
65.72 + </conf>
65.73 + </confs>
65.74 +</configurationDescriptor>
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml Wed Jun 07 20:23:29 2017 +0300
66.3 @@ -0,0 +1,28 @@
66.4 +<?xml version="1.0" encoding="UTF-8"?>
66.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
66.6 + <type>org.netbeans.modules.cnd.makeproject</type>
66.7 + <configuration>
66.8 + <data xmlns="http://www.netbeans.org/ns/make-project/1">
66.9 + <name>hello-world2</name>
66.10 + <c-extensions/>
66.11 + <cpp-extensions>cc</cpp-extensions>
66.12 + <header-extensions>h</header-extensions>
66.13 + <sourceEncoding>UTF-8</sourceEncoding>
66.14 + <make-dep-projects/>
66.15 + <sourceRootList/>
66.16 + <confList>
66.17 + <confElem>
66.18 + <name>Debug</name>
66.19 + <type>1</type>
66.20 + </confElem>
66.21 + <confElem>
66.22 + <name>Release</name>
66.23 + <type>1</type>
66.24 + </confElem>
66.25 + </confList>
66.26 + <formatting>
66.27 + <project-formatting-style>false</project-formatting-style>
66.28 + </formatting>
66.29 + </data>
66.30 + </configuration>
66.31 +</project>
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
67.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc Wed Jun 07 20:23:29 2017 +0300
67.3 @@ -0,0 +1,38 @@
67.4 +/*
67.5 + * Copyright (c) 2009-2014, Oracle and/or its affiliates. All rights reserved.
67.6 + *
67.7 + * Redistribution and use in source and binary forms, with or without
67.8 + * modification, are permitted provided that the following conditions are met:
67.9 + *
67.10 + * * Redistributions of source code must retain the above copyright notice,
67.11 + * this list of conditions and the following disclaimer.
67.12 + *
67.13 + * * Redistributions in binary form must reproduce the above copyright notice,
67.14 + * this list of conditions and the following disclaimer in the documentation
67.15 + * and/or other materials provided with the distribution.
67.16 + *
67.17 + * * Neither the name of Oracle nor the names of its contributors
67.18 + * may be used to endorse or promote products derived from this software without
67.19 + * specific prior written permission.
67.20 + *
67.21 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
67.22 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67.23 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67.24 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
67.25 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
67.26 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
67.27 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
67.28 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
67.29 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.30 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
67.31 + * THE POSSIBILITY OF SUCH DAMAGE.
67.32 + */
67.33 +
67.34 +#include <iostream>
67.35 +
67.36 +int main(int argc, char**argv) {
67.37 + // Prints hello message...
67.38 + std::cout << "Hello World!" << std::endl;
67.39 +
67.40 + return 0;
67.41 +}
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java Wed Jun 07 20:23:29 2017 +0300
68.3 @@ -0,0 +1,62 @@
68.4 +package ide.analysis.modernize;
68.5 +
68.6 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix;
68.7 +import com.sun.tools.ide.analysis.modernize.impl.YamlParser;
68.8 +import java.io.File;
68.9 +import java.nio.file.Files;
68.10 +import java.util.List;
68.11 +import static junit.framework.TestCase.fail;
68.12 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
68.13 +import static org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestCase.createTempFile;
68.14 +import org.openide.cookies.EditorCookie;
68.15 +import org.openide.filesystems.FileObject;
68.16 +import org.openide.filesystems.FileUtil;
68.17 +import org.openide.loaders.DataObject;
68.18 +
68.19 +/*
68.20 + * To change this license header, choose License Headers in Project Properties.
68.21 + * To change this template file, choose Tools | Templates
68.22 + * and open the template in the editor.
68.23 + */
68.24 +/**
68.25 + *
68.26 + * @author Ilia Gromov
68.27 + */
68.28 +public class HeaderTest extends TidyTestCase {
68.29 +
68.30 + private final String source = "src/llvm-header-guard.cpp";
68.31 + private final String header = "src/llvm-header-guard.h";
68.32 +
68.33 + public HeaderTest() {
68.34 + super("project-with-headers");
68.35 + }
68.36 +
68.37 + public void testLlvmHeaderGuard() {
68.38 + performTest(source, "llvm-header-guard", true);
68.39 + }
68.40 +
68.41 + @Override
68.42 + protected void processTestResults(List<ModernizeFix> fixes, String footerName) throws Exception {
68.43 + for (ModernizeFix fix : fixes) {
68.44 + fix.implement();
68.45 +
68.46 + for (YamlParser.Replacement replacement : fix.getReplacements()) {
68.47 + FileObject fo = FileUtil.toFileObject(new File(replacement.filePath));
68.48 +
68.49 + DataObject dObj = DataObject.find(fo);
68.50 + EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class);
68.51 + ec.saveDocument();
68.52 + }
68.53 + }
68.54 +
68.55 + File diffFile = createTempFile("diff", null, false);
68.56 +
68.57 + boolean diff = CndCoreTestUtils.diff(new File(FileUtil.toFile(getProjectDir()), header), getGoldenFile(header), diffFile);
68.58 +
68.59 + if (diff) {
68.60 + byte[] readAllBytes = Files.readAllBytes(diffFile.toPath());
68.61 + System.err.println(new String(readAllBytes));
68.62 + fail();
68.63 + }
68.64 + }
68.65 +}
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
69.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java Wed Jun 07 20:23:29 2017 +0300
69.3 @@ -0,0 +1,44 @@
69.4 +/*
69.5 + * To change this license header, choose License Headers in Project Properties.
69.6 + * To change this template file, choose Tools | Templates
69.7 + * and open the template in the editor.
69.8 + */
69.9 +package ide.analysis.modernize;
69.10 +
69.11 +import javax.swing.text.Document;
69.12 +import org.netbeans.modules.cnd.api.model.CsmFile;
69.13 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
69.14 +
69.15 +/**
69.16 + *
69.17 + * @author Ilia Gromov
69.18 + */
69.19 +class RequestImpl implements CsmErrorProvider.Request {
69.20 +
69.21 + private final CsmFile csmFile;
69.22 +
69.23 + public RequestImpl(CsmFile csmFile) {
69.24 + this.csmFile = csmFile;
69.25 + }
69.26 +
69.27 + @Override
69.28 + public CsmFile getFile() {
69.29 + return csmFile;
69.30 + }
69.31 +
69.32 + @Override
69.33 + public boolean isCancelled() {
69.34 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
69.35 + }
69.36 +
69.37 + @Override
69.38 + public Document getDocument() {
69.39 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
69.40 + }
69.41 +
69.42 + @Override
69.43 + public CsmErrorProvider.EditorEvent getEvent() {
69.44 + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
69.45 + }
69.46 +
69.47 +}
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
70.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java Wed Jun 07 20:23:29 2017 +0300
70.3 @@ -0,0 +1,46 @@
70.4 +/*
70.5 + * To change this license header, choose License Headers in Project Properties.
70.6 + * To change this template file, choose Tools | Templates
70.7 + * and open the template in the editor.
70.8 + */
70.9 +package ide.analysis.modernize;
70.10 +
70.11 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeErrorInfo;
70.12 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix;
70.13 +import com.sun.tools.ide.analysis.modernize.impl.YamlParser;
70.14 +import java.util.List;
70.15 +import junit.framework.TestCase;
70.16 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
70.17 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
70.18 +import org.openide.util.Exceptions;
70.19 +
70.20 +/**
70.21 + *
70.22 + * @author Ilia Gromov
70.23 + */
70.24 +class ResponseImpl implements CsmErrorProvider.Response {
70.25 +
70.26 + private final List<ModernizeFix> fixes;
70.27 +
70.28 + public ResponseImpl(List<ModernizeFix> fixes) {
70.29 + this.fixes = fixes;
70.30 + }
70.31 +
70.32 + @Override
70.33 + public void addError(CsmErrorInfo info) {
70.34 + try {
70.35 + TestCase.assertTrue(info instanceof ModernizeErrorInfo);
70.36 + final List<YamlParser.Replacement> replacements = ((ModernizeErrorInfo) info).getDiagnostics().getReplacements();
70.37 + final String id = ((ModernizeErrorInfo) info).getId();
70.38 + ModernizeFix fix = new ModernizeFix(replacements, id);
70.39 + fixes.add(fix);
70.40 + } catch (Exception ex) {
70.41 + Exceptions.printStackTrace(ex);
70.42 + }
70.43 + }
70.44 +
70.45 + @Override
70.46 + public void done() {
70.47 + }
70.48 +
70.49 +}
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
71.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java Wed Jun 07 20:23:29 2017 +0300
71.3 @@ -0,0 +1,64 @@
71.4 +package ide.analysis.modernize;
71.5 +
71.6 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix;
71.7 +import java.io.File;
71.8 +import java.nio.file.Files;
71.9 +import java.util.List;
71.10 +import org.junit.Test;
71.11 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
71.12 +import org.openide.cookies.EditorCookie;
71.13 +import org.openide.filesystems.FileObject;
71.14 +import org.openide.filesystems.FileUtil;
71.15 +import org.openide.loaders.DataObject;
71.16 +
71.17 +/**
71.18 + *
71.19 + * @author Ilia Gromov
71.20 + */
71.21 +public class SingleCppFileCheckTest extends TidyTestCase {
71.22 +
71.23 + public SingleCppFileCheckTest() {
71.24 + super("hello-cmake-world");
71.25 + }
71.26 +
71.27 + @Override
71.28 + protected void setUp() throws Exception {
71.29 + super.setUp();
71.30 + }
71.31 +
71.32 + public void testModernizeUseNullptr() {
71.33 + performTest("src/modernize-use-nullptr.cpp", "modernize-use-nullptr", true);
71.34 + }
71.35 +
71.36 + public void testModernizeLoopConvert() {
71.37 + performTest("src/modernize-loop-convert.cpp", "modernize-loop-convert", true);
71.38 + }
71.39 +
71.40 + @Test
71.41 + public void testModernizeRawStringLiteral() {
71.42 + performTest("src/modernize-raw-string-literal.cpp", "modernize-raw-string-literal", true);
71.43 + }
71.44 +
71.45 + @Override
71.46 + protected void processTestResults(List<ModernizeFix> fixes, String startFileName) throws Exception {
71.47 + for (ModernizeFix fix : fixes) {
71.48 + fix.implement();
71.49 + }
71.50 +
71.51 + FileObject footer = getSourceFile(startFileName);
71.52 +
71.53 + DataObject dObj = DataObject.find(footer);
71.54 + EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class);
71.55 + ec.saveDocument();
71.56 +
71.57 + File diffFile = createTempFile("diff", null, false);
71.58 +
71.59 + boolean diff = CndCoreTestUtils.diff(FileUtil.toFile(footer), getGoldenFile(startFileName), diffFile);
71.60 +
71.61 + if (diff) {
71.62 + byte[] readAllBytes = Files.readAllBytes(diffFile.toPath());
71.63 + System.err.println(new String(readAllBytes));
71.64 + fail();
71.65 + }
71.66 + }
71.67 +}
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
72.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java Wed Jun 07 20:23:29 2017 +0300
72.3 @@ -0,0 +1,237 @@
72.4 +/*
72.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
72.6 + *
72.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
72.8 + *
72.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
72.10 + * Other names may be trademarks of their respective owners.
72.11 + *
72.12 + * The contents of this file are subject to the terms of either the GNU
72.13 + * General Public License Version 2 only ("GPL") or the Common
72.14 + * Development and Distribution License("CDDL") (collectively, the
72.15 + * "License"). You may not use this file except in compliance with the
72.16 + * License. You can obtain a copy of the License at
72.17 + * http://www.netbeans.org/cddl-gplv2.html
72.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
72.19 + * specific language governing permissions and limitations under the
72.20 + * License. When distributing the software, include this License Header
72.21 + * Notice in each file and include the License file at
72.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
72.23 + * particular file as subject to the "Classpath" exception as provided
72.24 + * by Oracle in the GPL Version 2 section of the License file that
72.25 + * accompanied this code. If applicable, add the following below the
72.26 + * License Header, with the fields enclosed by brackets [] replaced by
72.27 + * your own identifying information:
72.28 + * "Portions Copyrighted [year] [name of copyright owner]"
72.29 + *
72.30 + * If you wish your version of this file to be governed by only the CDDL
72.31 + * or only the GPL Version 2, indicate your decision by adding
72.32 + * "[Contributor] elects to include this software in this distribution
72.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
72.34 + * single choice of license, a recipient has the option to distribute
72.35 + * your version of this file under either the CDDL, the GPL Version 2 or
72.36 + * to extend the choice of license to its licensees as provided above.
72.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
72.38 + * Version 2 license, then the option applies only if the new code is
72.39 + * made subject to such option by the copyright holder.
72.40 + *
72.41 + * Contributor(s):
72.42 + *
72.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
72.44 + */
72.45 +package ide.analysis.modernize;
72.46 +
72.47 +import com.sun.tools.ide.analysis.modernize.impl.DiagnosticsTool;
72.48 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl;
72.49 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix;
72.50 +import com.sun.tools.ide.analysis.modernize.impl.YamlParser;
72.51 +import com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools;
72.52 +import java.io.File;
72.53 +import java.nio.file.Files;
72.54 +import java.nio.file.attribute.PosixFilePermissions;
72.55 +import java.util.ArrayList;
72.56 +import java.util.Arrays;
72.57 +import java.util.Collection;
72.58 +import java.util.Collections;
72.59 +import java.util.List;
72.60 +import java.util.logging.ConsoleHandler;
72.61 +import java.util.logging.Level;
72.62 +import java.util.logging.LogManager;
72.63 +import java.util.prefs.Preferences;
72.64 +import org.netbeans.api.progress.ProgressHandle;
72.65 +import org.netbeans.api.project.Project;
72.66 +import org.netbeans.api.project.ProjectManager;
72.67 +import org.netbeans.api.project.ui.OpenProjects;
72.68 +import org.netbeans.modules.analysis.SPIAccessor;
72.69 +import org.netbeans.modules.analysis.spi.Analyzer;
72.70 +import org.netbeans.modules.cnd.api.model.CsmFile;
72.71 +import org.netbeans.modules.cnd.api.model.CsmModel;
72.72 +import org.netbeans.modules.cnd.api.model.CsmModelAccessor;
72.73 +import org.netbeans.modules.cnd.api.model.CsmProject;
72.74 +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
72.75 +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
72.76 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
72.77 +import org.netbeans.modules.cnd.api.project.NativeProject;
72.78 +import org.netbeans.modules.cnd.api.project.NativeProjectRegistry;
72.79 +import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
72.80 +import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager;
72.81 +import org.netbeans.modules.cnd.makeproject.api.MakeProject;
72.82 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
72.83 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
72.84 +import org.netbeans.modules.cnd.test.CndBaseTestCase;
72.85 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
72.86 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
72.87 +import org.netbeans.modules.refactoring.api.Scope;
72.88 +import org.openide.filesystems.FileObject;
72.89 +import org.openide.filesystems.FileUtil;
72.90 +import org.openide.util.Exceptions;
72.91 +
72.92 +/**
72.93 + *
72.94 + * @author Ilia Gromov
72.95 + */
72.96 +public abstract class TidyTestCase extends CndBaseTestCase {
72.97 +
72.98 + private final String projectName;
72.99 +
72.100 + private List<FileObject> fileObjects;
72.101 + private MakeProject project;
72.102 + private FileObject projectDirFileObject;
72.103 +
72.104 + private final String CLANG_TIDY_PATH = "clang-tidy-3.9p";
72.105 +
72.106 + public TidyTestCase(String projectName) {
72.107 + super(projectName);
72.108 +
72.109 + this.projectName = projectName;
72.110 + }
72.111 +
72.112 + protected static CodeAudit findAudit(Collection<CodeAudit> audits, String id) {
72.113 + for (CodeAudit audit : audits) {
72.114 + if (audit.getID().equals(id)) {
72.115 + return audit;
72.116 + }
72.117 + }
72.118 + return null;
72.119 + }
72.120 +
72.121 + @Override
72.122 + protected void setUp() throws Exception {
72.123 + super.setUp();
72.124 + LogManager.getLogManager().reset();
72.125 +
72.126 + java.util.logging.Logger LOG = java.util.logging.Logger.getLogger("ide.analysis.tidy");
72.127 + LOG.setLevel(Level.ALL);
72.128 +
72.129 + ConsoleHandler consoleHandler = new ConsoleHandler();
72.130 + consoleHandler.setLevel(Level.ALL);
72.131 + LOG.addHandler(consoleHandler);
72.132 +
72.133 + File clangTidyFile = getBinaryFile();
72.134 + Files.setPosixFilePermissions(clangTidyFile.toPath(), PosixFilePermissions.fromString("rwxrwxrwx"));
72.135 +
72.136 + assertTrue(getBinaryFile().exists());
72.137 +
72.138 + File projectDirFile = getDataFile(projectName);
72.139 + projectDirFileObject = FileUtil.toFileObject(projectDirFile);
72.140 +
72.141 + fileObjects = new ArrayList<FileObject>();
72.142 +
72.143 + project = (MakeProject) ProjectManager.getDefault().findProject(projectDirFileObject);
72.144 +
72.145 + OpenProjects.getDefault().open(new Project[]{project}, false);
72.146 + while (!OpenProjects.getDefault().isProjectOpen(project)) {
72.147 + try {
72.148 + Thread.sleep(100);
72.149 + } catch (InterruptedException ex) {
72.150 + Exceptions.printStackTrace(ex);
72.151 + }
72.152 + }
72.153 +
72.154 + CsmModel model = CsmModelAccessor.getModel();
72.155 + assertNotNull(project);
72.156 +
72.157 + NativeProject np = project.getLookup().lookup(NativeProject.class);
72.158 + NativeProjectRegistry.getDefault().register(np);
72.159 + model.enableProject(np);
72.160 + assertNotNull(np);
72.161 +
72.162 + CsmProject csmProject = model.getProject(np);
72.163 + assertNotNull(csmProject);
72.164 +
72.165 + csmProject.waitParse();
72.166 +
72.167 + }
72.168 +
72.169 + public ExecutionEnvironment getExecEnv() {
72.170 + ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
72.171 + return execEnv;
72.172 + }
72.173 +
72.174 + public CompilerSet getCompilerSet() {
72.175 + CompilerSetManager csm = CompilerSetManager.get(getExecEnv());
72.176 + return csm.getDefaultCompilerSet();
72.177 + }
72.178 +
72.179 + public MakeProject getProject() {
72.180 + return project;
72.181 + }
72.182 +
72.183 + public FileObject getProjectDir() {
72.184 + return projectDirFileObject;
72.185 + }
72.186 +
72.187 + public FileObject getSourceFile(String name) {
72.188 + return FileUtil.toFileObject(new File(FileUtil.toFile(getProjectDir()), name));
72.189 + }
72.190 +
72.191 + public File getBinaryFile() {
72.192 + return new File(getDataDir(), CLANG_TIDY_PATH);
72.193 + }
72.194 +
72.195 + protected final void performTest(String startFileName, String checkName, boolean isStartFile) {
72.196 + try {
72.197 + FileObject startFile = getSourceFile(startFileName);
72.198 + assertTrue(startFile.isValid());
72.199 +
72.200 + Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{startFile}));
72.201 + Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0);
72.202 + Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl();
72.203 +
72.204 + ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context);
72.205 + ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
72.206 + final CsmFile csmFile = CsmUtilities.getCsmFile(startFile, true, false);
72.207 + Item item = AnalyticsTools.findItem(csmFile, getProject());
72.208 +
72.209 + Collection<CodeAudit> audits = DiagnosticsTool.getAudits(getBinaryFile().getAbsolutePath(), execEnv, new AuditPreferences(Preferences.userNodeForPackage(this.getClass())));
72.210 + CodeAudit audit = findAudit(audits, checkName);
72.211 + assertNotNull(audit);
72.212 +
72.213 + // ----- BEGIN diagnostics -----
72.214 + DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath());
72.215 +
72.216 + int exitCode = diagnosticsTool.process(Collections.singleton(audit.getID()), csmFile, true);
72.217 + if (exitCode != DiagnosticsTool.STATUS_OK) {
72.218 + fail();
72.219 + }
72.220 +
72.221 + List<YamlParser.Diagnostics> diags = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString());
72.222 + List<ModernizeFix> fixes = new ArrayList<ModernizeFix>();
72.223 +
72.224 + CsmErrorProvider.Request request = new RequestImpl(csmFile);
72.225 + CsmErrorProvider.Response response = new ResponseImpl(fixes);
72.226 +
72.227 + analyzer.getErrorProvider(null).postProcess(false, csmFile, getProject(), diags, request, response);
72.228 + // ----- END diagnostics -----
72.229 +
72.230 + processTestResults(fixes, startFileName);
72.231 + } catch (Exception ex) {
72.232 + ex.printStackTrace(System.err);
72.233 + fail(ex.toString());
72.234 + }
72.235 + }
72.236 +
72.237 + protected void processTestResults(List<ModernizeFix> fixes, String startFileName) throws Exception {
72.238 +
72.239 + }
72.240 +}
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
73.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java Wed Jun 07 20:23:29 2017 +0300
73.3 @@ -0,0 +1,117 @@
73.4 +/*
73.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
73.6 + *
73.7 + * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
73.8 + *
73.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
73.10 + * Other names may be trademarks of their respective owners.
73.11 + *
73.12 + * The contents of this file are subject to the terms of either the GNU
73.13 + * General Public License Version 2 only ("GPL") or the Common
73.14 + * Development and Distribution License("CDDL") (collectively, the
73.15 + * "License"). You may not use this file except in compliance with the
73.16 + * License. You can obtain a copy of the License at
73.17 + * http://www.netbeans.org/cddl-gplv2.html
73.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
73.19 + * specific language governing permissions and limitations under the
73.20 + * License. When distributing the software, include this License Header
73.21 + * Notice in each file and include the License file at
73.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
73.23 + * particular file as subject to the "Classpath" exception as provided
73.24 + * by Oracle in the GPL Version 2 section of the License file that
73.25 + * accompanied this code. If applicable, add the following below the
73.26 + * License Header, with the fields enclosed by brackets [] replaced by
73.27 + * your own identifying information:
73.28 + * "Portions Copyrighted [year] [name of copyright owner]"
73.29 + *
73.30 + * If you wish your version of this file to be governed by only the CDDL
73.31 + * or only the GPL Version 2, indicate your decision by adding
73.32 + * "[Contributor] elects to include this software in this distribution
73.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
73.34 + * single choice of license, a recipient has the option to distribute
73.35 + * your version of this file under either the CDDL, the GPL Version 2 or
73.36 + * to extend the choice of license to its licensees as provided above.
73.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
73.38 + * Version 2 license, then the option applies only if the new code is
73.39 + * made subject to such option by the copyright holder.
73.40 + *
73.41 + * Contributor(s):
73.42 + *
73.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
73.44 + */
73.45 +package ide.analysis.modernize;
73.46 +
73.47 +import com.sun.tools.ide.analysis.modernize.impl.DiagnosticsTool;
73.48 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl;
73.49 +import com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools;
73.50 +import java.io.File;
73.51 +import java.io.IOException;
73.52 +import java.nio.file.Files;
73.53 +import java.util.Arrays;
73.54 +import java.util.Collections;
73.55 +import org.junit.Test;
73.56 +import org.netbeans.api.progress.ProgressHandle;
73.57 +import org.netbeans.modules.analysis.SPIAccessor;
73.58 +import org.netbeans.modules.analysis.spi.Analyzer;
73.59 +import org.netbeans.modules.cnd.api.model.CsmFile;
73.60 +import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
73.61 +import org.netbeans.modules.cnd.modelutil.CsmUtilities;
73.62 +import org.netbeans.modules.cnd.test.CndCoreTestUtils;
73.63 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
73.64 +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
73.65 +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
73.66 +import org.netbeans.modules.refactoring.api.Scope;
73.67 +import org.openide.filesystems.FileObject;
73.68 +
73.69 +/**
73.70 + *
73.71 + * @author Ilia Gromov
73.72 + */
73.73 +public class YamlTest extends TidyTestCase {
73.74 +
73.75 + public YamlTest() {
73.76 + super("hello-world");
73.77 + }
73.78 +
73.79 + @Test
73.80 + public void testYaml() throws IOException, ConnectionManager.CancellationException {
73.81 + FileObject singleFileObject = getSourceFile("welcome.cc");
73.82 +
73.83 + File goldenFile = getGoldenFile("hello-world.json");
73.84 + String goldenYaml = new String(Files.readAllBytes(goldenFile.toPath()), "UTF-8").replaceAll("\\$path", getDataDir().getAbsolutePath());
73.85 +
73.86 + Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{singleFileObject}));
73.87 + Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0);
73.88 +
73.89 + Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl();
73.90 + ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context);
73.91 +
73.92 + ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
73.93 +
73.94 + CsmFile csmFile = CsmUtilities.getCsmFile(singleFileObject, false, false);
73.95 + Item item = AnalyticsTools.findItem(csmFile, getProject());
73.96 +
73.97 + DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath());
73.98 +
73.99 + int exitCode = diagnosticsTool.process(Collections.singleton("*"), csmFile, true);
73.100 +
73.101 + if (exitCode != DiagnosticsTool.STATUS_OK) {
73.102 + fail();
73.103 + }
73.104 + String yamlAsString = diagnosticsTool.getYamlAsString();
73.105 +
73.106 + File real = File.createTempFile("test", null);
73.107 + Files.write(real.toPath(), yamlAsString.getBytes());
73.108 +
73.109 + File expected = File.createTempFile("test", null);
73.110 + Files.write(expected.toPath(), goldenYaml.getBytes());
73.111 +
73.112 + File diff = File.createTempFile("test", null);
73.113 + if (CndCoreTestUtils.diff(real, expected, diff)) {
73.114 + System.err.println("============DIFF============");
73.115 + System.err.println(new String(Files.readAllBytes(diff.toPath()), "UTF-8"));
73.116 + System.err.println("============DIFF============");
73.117 + fail();
73.118 + }
73.119 + }
73.120 +}
74.1 --- a/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/project.properties Wed Jun 07 18:50:35 2017 +0300
74.2 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/project.properties Wed Jun 07 20:23:29 2017 +0300
74.3 @@ -5,3 +5,5 @@
74.4 nbm.homepage=http://clang.llvm.org/extra/clang-tidy/
74.5 nbm.module.author=Ilia Gromov
74.6 nbm.needs.restart=true
74.7 +keystore=nbproject/private/keystore
74.8 +nbm_alias=myself
74.9 \ No newline at end of file
75.1 --- a/ide.analysis.modernize/build.xml Wed Jun 07 18:50:35 2017 +0300
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,8 +0,0 @@
75.4 -<?xml version="1.0" encoding="UTF-8"?>
75.5 -<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
75.6 -<!-- for some information on what you could do (e.g. targets to override). -->
75.7 -<!-- If you delete this file and reopen the project it will be recreated. -->
75.8 -<project name="contrib/ide.analysis.modernize" default="netbeans" basedir=".">
75.9 - <description>Builds, tests, and runs the project org.netbeans.modules.ide.analysis.modernize.</description>
75.10 - <import file="../../nbbuild/templates/projectized.xml"/>
75.11 -</project>
76.1 --- a/ide.analysis.modernize/l10n.list Wed Jun 07 18:50:35 2017 +0300
76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
76.3 @@ -1,2 +0,0 @@
76.4 -src/**/Bundle.properties
76.5 -
77.1 --- a/ide.analysis.modernize/license.txt Wed Jun 07 18:50:35 2017 +0300
77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
77.3 @@ -1,565 +0,0 @@
77.4 -NetBeans IDE Dual License Header and License Notice
77.5 -
77.6 -Oracle elects to use only the GNU Lesser General Public License version 2.1
77.7 -(LGPL) for any software where a choice of LGPL/GPL license versions are made
77.8 -available with the language indicating that LGPLv2.1/GPLv2 or any later version
77.9 -may be used, or where a choice of which version of the LGPL/GPL is applied is
77.10 -unspecified.
77.11 -For more information on the license please see: the NetBeans License FAQs.
77.12 -
77.13 -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
77.14 -
77.15 -1. Definitions.
77.16 -1.1. "Contributor" means each individual or entity that creates or contributes
77.17 -to the creation of Modifications.
77.18 -1.2. "Contributor Version" means the combination of the Original Software,
77.19 -prior Modifications used by a Contributor (if any), and the Modifications made
77.20 -by that particular Contributor.
77.21 -1.3. "Covered Software" means (a) the Original Software, or (b) Modifications,
77.22 -or (c) the combination of files containing Original Software with files
77.23 -containing Modifications, in each case including portions thereof.
77.24 -1.4. "Executable" means the Covered Software in any form other than Source Code.
77.25 -1.5. "Initial Developer" means the individual or entity that first makes
77.26 -Original Software available under this License.
77.27 -1.6. "Larger Work" means a work which combines Covered Software or portions
77.28 -thereof with code not governed by the terms of this License.
77.29 -1.7. "License" means this document.
77.30 -1.8. "Licensable" means having the right to grant, to the maximum extent
77.31 -possible, whether at the time of the initial grant or subsequently acquired,
77.32 -any and all of the rights conveyed herein.
77.33 -1.9 "Modifications" means the Source Code and Executable form of any of the
77.34 -following:
77.35 -A. Any file that results from an addition to, deletion from or modification of
77.36 -the contents of a file containing Original Software or previous Modifications;
77.37 -B. Any new file that contains any part of the Original Software or previous
77.38 -Modification; or
77.39 -C. Any new file that is contributed or otherwise made available under the terms
77.40 -of this License.
77.41 -1.10. "Original Software" means the Source Code and Executable form of computer
77.42 -software code that is originally released under this License.
77.43 -1.11. "Patent Claims" means any patent claim(s), now owned or hereafter
77.44 -acquired, including without limitation, method, process, and apparatus claims,
77.45 -in any patent Licensable by grantor.
77.46 -1.12. "Source Code" means (a) the common form of computer software code in
77.47 -which modifications are made and (b) associated documentation included in or
77.48 -with such code.
77.49 -1.13. "You" (or "Your") means an individual or a legal entity exercising rights
77.50 -under, and complying with all of the terms of, this License. For legal
77.51 -entities, "You" includes any entity which controls, is controlled by, or is
77.52 -under common control with You. For purposes of this definition, "control" means
77.53 -(a) the power, direct or indirect, to cause the direction or management of such
77.54 -entity, whether by contract or otherwise, or (b) ownership of more than fifty
77.55 -percent (50%) of the outstanding shares or beneficial ownership of such entity.
77.56 -2. License Grants.
77.57 -2.1. The Initial Developer Grant.
77.58 -Conditioned upon Your compliance with Section 3.1 below and subject to third
77.59 -party intellectual property claims, the Initial Developer hereby grants You a
77.60 -world-wide, royalty-free, non-exclusive license:
77.61 -(a) under intellectual property rights (other than patent or trademark)
77.62 -Licensable by Initial Developer, to use, reproduce, modify, display, perform,
77.63 -sublicense and distribute the Original Software (or portions thereof), with or
77.64 -without Modifications, and/or as part of a Larger Work; and
77.65 -(b) under Patent Claims infringed by the making, using or selling of Original
77.66 -Software, to make, have made, use, practice, sell, and offer for sale, and/or
77.67 -otherwise dispose of the Original Software (or portions thereof).
77.68 -(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date
77.69 -Initial Developer first distributes or otherwise makes the Original Software
77.70 -available to a third party under the terms of this License.
77.71 -(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for
77.72 -code that You delete from the Original Software, or (2) for infringements
77.73 -caused by: (i) the modification of the Original Software, or (ii) the
77.74 -combination of the Original Software with other software or devices.
77.75 -2.2. Contributor Grant.
77.76 -Conditioned upon Your compliance with Section 3.1 below and subject to third
77.77 -party intellectual property claims, each Contributor hereby grants You a
77.78 -world-wide, royalty-free, non-exclusive license:
77.79 -(a) under intellectual property rights (other than patent or trademark)
77.80 -Licensable by Contributor to use, reproduce, modify, display, perform,
77.81 -sublicense and distribute the Modifications created by such Contributor (or
77.82 -portions thereof), either on an unmodified basis, with other Modifications, as
77.83 -Covered Software and/or as part of a Larger Work; and
77.84 -(b) under Patent Claims infringed by the making, using, or selling of
77.85 -Modifications made by that Contributor either alone and/or in combination with
77.86 -its Contributor Version (or portions of such combination), to make, use, sell,
77.87 -offer for sale, have made, and/or otherwise dispose of: (1) Modifications made
77.88 -by that Contributor (or portions thereof); and (2) the combination of
77.89 -Modifications made by that Contributor with its Contributor Version (or
77.90 -portions of such combination).
77.91 -(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the
77.92 -date Contributor first distributes or otherwise makes the Modifications
77.93 -available to a third party.
77.94 -(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for
77.95 -any code that Contributor has deleted from the Contributor Version; (2) for
77.96 -infringements caused by: (i) third party modifications of Contributor Version,
77.97 -or (ii) the combination of Modifications made by that Contributor with other
77.98 -software (except as part of the Contributor Version) or other devices; or (3)
77.99 -under Patent Claims infringed by Covered Software in the absence of
77.100 -Modifications made by that Contributor.
77.101 -3. Distribution Obligations.
77.102 -3.1. Availability of Source Code.
77.103 -Any Covered Software that You distribute or otherwise make available in
77.104 -Executable form must also be made available in Source Code form and that Source
77.105 -Code form must be distributed only under the terms of this License. You must
77.106 -include a copy of this License with every copy of the Source Code form of the
77.107 -Covered Software You distribute or otherwise make available. You must inform
77.108 -recipients of any such Covered Software in Executable form as to how they can
77.109 -obtain such Covered Software in Source Code form in a reasonable manner on or
77.110 -through a medium customarily used for software exchange.
77.111 -3.2. Modifications.
77.112 -The Modifications that You create or to which You contribute are governed by
77.113 -the terms of this License. You represent that You believe Your Modifications
77.114 -are Your original creation(s) and/or You have sufficient rights to grant the
77.115 -rights conveyed by this License.
77.116 -3.3. Required Notices.
77.117 -You must include a notice in each of Your Modifications that identifies You as
77.118 -the Contributor of the Modification. You may not remove or alter any copyright,
77.119 -patent or trademark notices contained within the Covered Software, or any
77.120 -notices of licensing or any descriptive text giving attribution to any
77.121 -Contributor or the Initial Developer.
77.122 -3.4. Application of Additional Terms.
77.123 -You may not offer or impose any terms on any Covered Software in Source Code
77.124 -form that alters or restricts the applicable version of this License or the
77.125 -recipients� rights hereunder. You may choose to offer, and to charge a fee
77.126 -for, warranty, support, indemnity or liability obligations to one or more
77.127 -recipients of Covered Software. However, you may do so only on Your own behalf,
77.128 -and not on behalf of the Initial Developer or any Contributor. You must make it
77.129 -absolutely clear that any such warranty, support, indemnity or liability
77.130 -obligation is offered by You alone, and You hereby agree to indemnify the
77.131 -Initial Developer and every Contributor for any liability incurred by the
77.132 -Initial Developer or such Contributor as a result of warranty, support,
77.133 -indemnity or liability terms You offer.
77.134 -3.5. Distribution of Executable Versions.
77.135 -You may distribute the Executable form of the Covered Software under the terms
77.136 -of this License or under the terms of a license of Your choice, which may
77.137 -contain terms different from this License, provided that You are in compliance
77.138 -with the terms of this License and that the license for the Executable form
77.139 -does not attempt to limit or alter the recipient�s rights in the Source Code
77.140 -form from the rights set forth in this License. If You distribute the Covered
77.141 -Software in Executable form under a different license, You must make it
77.142 -absolutely clear that any terms which differ from this License are offered by
77.143 -You alone, not by the Initial Developer or Contributor. You hereby agree to
77.144 -indemnify the Initial Developer and every Contributor for any liability
77.145 -incurred by the Initial Developer or such Contributor as a result of any such
77.146 -terms You offer.
77.147 -3.6. Larger Works.
77.148 -You may create a Larger Work by combining Covered Software with other code not
77.149 -governed by the terms of this License and distribute the Larger Work as a
77.150 -single product. In such a case, You must make sure the requirements of this
77.151 -License are fulfilled for the Covered Software.
77.152 -4. Versions of the License.
77.153 -4.1. New Versions.
77.154 -Oracle Corp. is the initial license steward and may publish revised and/or new
77.155 -versions of this License from time to time. Each version will be given a
77.156 -distinguishing version number. Except as provided in Section 4.3, no one other
77.157 -than the license steward has the right to modify this License.
77.158 -4.2. Effect of New Versions.
77.159 -You may always continue to use, distribute or otherwise make the Covered
77.160 -Software available under the terms of the version of the License under which
77.161 -You originally received the Covered Software. If the Initial Developer includes
77.162 -a notice in the Original Software prohibiting it from being distributed or
77.163 -otherwise made available under any subsequent version of the License, You must
77.164 -distribute and make the Covered Software available under the terms of the
77.165 -version of the License under which You originally received the Covered
77.166 -Software. Otherwise, You may also choose to use, distribute or otherwise make
77.167 -the Covered Software available under the terms of any subsequent version of the
77.168 -License published by the license steward.
77.169 -4.3. Modified Versions.
77.170 -When You are an Initial Developer and You want to create a new license for Your
77.171 -Original Software, You may create and use a modified version of this License if
77.172 -You: (a) rename the license and remove any references to the name of the
77.173 -license steward (except to note that the license differs from this License);
77.174 -and (b) otherwise make it clear that the license contains terms which differ
77.175 -from this License.
77.176 -5. DISCLAIMER OF WARRANTY.
77.177 -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT
77.178 -WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
77.179 -LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS,
77.180 -MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK
77.181 -AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD
77.182 -ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL
77.183 -DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING,
77.184 -REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART
77.185 -OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT
77.186 -UNDER THIS DISCLAIMER.
77.187 -6. TERMINATION.
77.188 -6.1. This License and the rights granted hereunder will terminate automatically
77.189 -if You fail to comply with terms herein and fail to cure such breach within 30
77.190 -days of becoming aware of the breach. Provisions which, by their nature, must
77.191 -remain in effect beyond the termination of this License shall survive.
77.192 -6.2. If You assert a patent infringement claim (excluding declaratory judgment
77.193 -actions) against Initial Developer or a Contributor (the Initial Developer or
77.194 -Contributor against whom You assert such claim is referred to as "Participant")
77.195 -alleging that the Participant Software (meaning the Contributor Version where
77.196 -the Participant is a Contributor or the Original Software where the Participant
77.197 -is the Initial Developer) directly or indirectly infringes any patent, then any
77.198 -and all rights granted directly or indirectly to You by such Participant, the
77.199 -Initial Developer (if the Initial Developer is not the Participant) and all
77.200 -Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days
77.201 -notice from Participant terminate prospectively and automatically at the
77.202 -expiration of such 60 day notice period, unless if within such 60 day period
77.203 -You withdraw Your claim with respect to the Participant Software against such
77.204 -Participant either unilaterally or pursuant to a written agreement with
77.205 -Participant.
77.206 -6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user
77.207 -licenses that have been validly granted by You or any distributor hereunder
77.208 -prior to termination (excluding licenses granted to You by any distributor)
77.209 -shall survive termination.
77.210 -7. LIMITATION OF LIABILITY.
77.211 -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING
77.212 -NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY
77.213 -OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF
77.214 -ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL,
77.215 -INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
77.216 -LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
77.217 -FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN
77.218 -IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS
77.219 -LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
77.220 -INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
77.221 -PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR
77.222 -LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND
77.223 -LIMITATION MAY NOT APPLY TO YOU.
77.224 -8. U.S. GOVERNMENT END USERS.
77.225 -The Covered Software is a "commercial item," as that term is defined in 48
77.226 -C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that
77.227 -term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer
77.228 -software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
77.229 -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through
77.230 -227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software
77.231 -with only those rights set forth herein. This U.S. Government Rights clause is
77.232 -in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision
77.233 -that addresses Government rights in computer software under this License.
77.234 -9. MISCELLANEOUS.
77.235 -This License represents the complete agreement concerning subject matter
77.236 -hereof. If any provision of this License is held to be unenforceable, such
77.237 -provision shall be reformed only to the extent necessary to make it
77.238 -enforceable. This License shall be governed by the law of the jurisdiction
77.239 -specified in a notice contained within the Original Software (except to the
77.240 -extent applicable law, if any, provides otherwise), excluding such
77.241 -jurisdiction�s conflict-of-law provisions. Any litigation relating to this
77.242 -License shall be subject to the jurisdiction of the courts located in the
77.243 -jurisdiction and venue specified in a notice contained within the Original
77.244 -Software, with the losing party responsible for costs, including, without
77.245 -limitation, court costs and reasonable attorneys� fees and expenses. The
77.246 -application of the United Nations Convention on Contracts for the International
77.247 -Sale of Goods is expressly excluded. Any law or regulation which provides that
77.248 -the language of a contract shall be construed against the drafter shall not
77.249 -apply to this License. You agree that You alone are responsible for compliance
77.250 -with the United States export administration regulations (and the export
77.251 -control laws and regulation of any other countries) when You use, distribute or
77.252 -otherwise make available any Covered Software.
77.253 -10. RESPONSIBILITY FOR CLAIMS.
77.254 -As between Initial Developer and the Contributors, each party is responsible
77.255 -for claims and damages arising, directly or indirectly, out of its utilization
77.256 -of rights under this License and You agree to work with Initial Developer and
77.257 -Contributors to distribute such responsibility on an equitable basis. Nothing
77.258 -herein is intended or shall be deemed to constitute any admission of liability.
77.259 -NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
77.260 -(CDDL)
77.261 -The code released under the CDDL shall be governed by the laws of the State of
77.262 -California (excluding conflict-of-law provisions). Any litigation relating to
77.263 -this License shall be subject to the jurisdiction of the Federal Courts of the
77.264 -Northern District of California and the state courts of the State of
77.265 -California, with venue lying in Santa Clara County, California.
77.266 -The GNU General Public License (GPL) Version 2, June 1991
77.267 -
77.268 -Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite
77.269 -330, Boston, MA 02111-1307 USA
77.270 -Everyone is permitted to copy and distribute verbatim copies of this license
77.271 -document, but changing it is not allowed.
77.272 -Preamble
77.273 -The licenses for most software are designed to take away your freedom to share
77.274 -and change it. By contrast, the GNU General Public License is intended to
77.275 -guarantee your freedom to share and change free software--to make sure the
77.276 -software is free for all its users. This General Public License applies to most
77.277 -of the Free Software Foundation's software and to any other program whose
77.278 -authors commit to using it. (Some other Free Software Foundation software is
77.279 -covered by the GNU Library General Public License instead.) You can apply it to
77.280 -your programs, too.
77.281 -When we speak of free software, we are referring to freedom, not price. Our
77.282 -General Public Licenses are designed to make sure that you have the freedom to
77.283 -distribute copies of free software (and charge for this service if you wish),
77.284 -that you receive source code or can get it if you want it, that you can change
77.285 -the software or use pieces of it in new free programs; and that you know you
77.286 -can do these things.
77.287 -To protect your rights, we need to make restrictions that forbid anyone to deny
77.288 -you these rights or to ask you to surrender the rights. These restrictions
77.289 -translate to certain responsibilities for you if you distribute copies of the
77.290 -software, or if you modify it.
77.291 -For example, if you distribute copies of such a program, whether gratis or for
77.292 -a fee, you must give the recipients all the rights that you have. You must make
77.293 -sure that they, too, receive or can get the source code. And you must show them
77.294 -these terms so they know their rights.
77.295 -We protect your rights with two steps: (1) copyright the software, and (2)
77.296 -offer you this license which gives you legal permission to copy, distribute
77.297 -and/or modify the software.
77.298 -Also, for each author's protection and ours, we want to make certain that
77.299 -everyone understands that there is no warranty for this free software. If the
77.300 -software is modified by someone else and passed on, we want its recipients to
77.301 -know that what they have is not the original, so that any problems introduced
77.302 -by others will not reflect on the original authors' reputations.
77.303 -Finally, any free program is threatened constantly by software patents. We wish
77.304 -to avoid the danger that redistributors of a free program will individually
77.305 -obtain patent licenses, in effect making the program proprietary. To prevent
77.306 -this, we have made it clear that any patent must be licensed for everyone's
77.307 -free use or not licensed at all.
77.308 -The precise terms and conditions for copying, distribution and modification
77.309 -follow.
77.310 -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
77.311 -0. This License applies to any program or other work which contains a notice
77.312 -placed by the copyright holder saying it may be distributed under the terms of
77.313 -this General Public License. The "Program", below, refers to any such program
77.314 -or work, and a "work based on the Program" means either the Program or any
77.315 -derivative work under copyright law: that is to say, a work containing the
77.316 -Program or a portion of it, either verbatim or with modifications and/or
77.317 -translated into another language. (Hereinafter, translation is included without
77.318 -limitation in the term "modification".) Each licensee is addressed as "you".
77.319 -Activities other than copying, distribution and modification are not covered by
77.320 -this License; they are outside its scope. The act of running the Program is not
77.321 -restricted, and the output from the Program is covered only if its contents
77.322 -constitute a work based on the Program (independent of having been made by
77.323 -running the Program). Whether that is true depends on what the Program does.
77.324 -1. You may copy and distribute verbatim copies of the Program's source code as
77.325 -you receive it, in any medium, provided that you conspicuously and
77.326 -appropriately publish on each copy an appropriate copyright notice and
77.327 -disclaimer of warranty; keep intact all the notices that refer to this License
77.328 -and to the absence of any warranty; and give any other recipients of the
77.329 -Program a copy of this License along with the Program.
77.330 -You may charge a fee for the physical act of transferring a copy, and you may
77.331 -at your option offer warranty protection in exchange for a fee.
77.332 -2. You may modify your copy or copies of the Program or any portion of it, thus
77.333 -forming a work based on the Program, and copy and distribute such modifications
77.334 -or work under the terms of Section 1 above, provided that you also meet all of
77.335 -these conditions:
77.336 -a) You must cause the modified files to carry prominent notices stating that
77.337 -you changed the files and the date of any change.
77.338 -b) You must cause any work that you distribute or publish, that in whole or in
77.339 -part contains or is derived from the Program or any part thereof, to be
77.340 -licensed as a whole at no charge to all third parties under the terms of this
77.341 -License.
77.342 -c) If the modified program normally reads commands interactively when run, you
77.343 -must cause it, when started running for such interactive use in the most
77.344 -ordinary way, to print or display an announcement including an appropriate
77.345 -copyright notice and a notice that there is no warranty (or else, saying that
77.346 -you provide a warranty) and that users may redistribute the program under these
77.347 -conditions, and telling the user how to view a copy of this License.
77.348 -(Exception: if the Program itself is interactive but does not normally print
77.349 -such an announcement, your work based on the Program is not required to print
77.350 -an announcement.)
77.351 -These requirements apply to the modified work as a whole. If identifiable
77.352 -sections of that work are not derived from the Program, and can be reasonably
77.353 -considered independent and separate works in themselves, then this License, and
77.354 -its terms, do not apply to those sections when you distribute them as separate
77.355 -works. But when you distribute the same sections as part of a whole which is a
77.356 -work based on the Program, the distribution of the whole must be on the terms
77.357 -of this License, whose permissions for other licensees extend to the entire
77.358 -whole, and thus to each and every part regardless of who wrote it.
77.359 -Thus, it is not the intent of this section to claim rights or contest your
77.360 -rights to work written entirely by you; rather, the intent is to exercise the
77.361 -right to control the distribution of derivative or collective works based on
77.362 -the Program.
77.363 -In addition, mere aggregation of another work not based on the Program with the
77.364 -Program (or with a work based on the Program) on a volume of a storage or
77.365 -distribution medium does not bring the other work under the scope of this
77.366 -License.
77.367 -3. You may copy and distribute the Program (or a work based on it, under
77.368 -Section 2) in object code or executable form under the terms of Sections 1 and
77.369 -2 above provided that you also do one of the following:
77.370 -a) Accompany it with the complete corresponding machine-readable source code,
77.371 -which must be distributed under the terms of Sections 1 and 2 above on a medium
77.372 -customarily used for software interchange; or,
77.373 -b) Accompany it with a written offer, valid for at least three years, to give
77.374 -any third party, for a charge no more than your cost of physically performing
77.375 -source distribution, a complete machine-readable copy of the corresponding
77.376 -source code, to be distributed under the terms of Sections 1 and 2 above on a
77.377 -medium customarily used for software interchange; or,
77.378 -c) Accompany it with the information you received as to the offer to distribute
77.379 -corresponding source code. (This alternative is allowed only for noncommercial
77.380 -distribution and only if you received the program in object code or executable
77.381 -form with such an offer, in accord with Subsection b above.)
77.382 -The source code for a work means the preferred form of the work for making
77.383 -modifications to it. For an executable work, complete source code means all the
77.384 -source code for all modules it contains, plus any associated interface
77.385 -definition files, plus the scripts used to control compilation and installation
77.386 -of the executable. However, as a special exception, the source code distributed
77.387 -need not include anything that is normally distributed (in either source or
77.388 -binary form) with the major components (compiler, kernel, and so on) of the
77.389 -operating system on which the executable runs, unless that component itself
77.390 -accompanies the executable.
77.391 -If distribution of executable or object code is made by offering access to copy
77.392 -from a designated place, then offering equivalent access to copy the source
77.393 -code from the same place counts as distribution of the source code, even though
77.394 -third parties are not compelled to copy the source along with the object code.
77.395 -4. You may not copy, modify, sublicense, or distribute the Program except as
77.396 -expressly provided under this License. Any attempt otherwise to copy, modify,
77.397 -sublicense or distribute the Program is void, and will automatically terminate
77.398 -your rights under this License. However, parties who have received copies, or
77.399 -rights, from you under this License will not have their licenses terminated so
77.400 -long as such parties remain in full compliance.
77.401 -5. You are not required to accept this License, since you have not signed it.
77.402 -However, nothing else grants you permission to modify or distribute the Program
77.403 -or its derivative works. These actions are prohibited by law if you do not
77.404 -accept this License. Therefore, by modifying or distributing the Program (or
77.405 -any work based on the Program), you indicate your acceptance of this License to
77.406 -do so, and all its terms and conditions for copying, distributing or modifying
77.407 -the Program or works based on it.
77.408 -6. Each time you redistribute the Program (or any work based on the Program),
77.409 -the recipient automatically receives a license from the original licensor to
77.410 -copy, distribute or modify the Program subject to these terms and conditions.
77.411 -You may not impose any further restrictions on the recipients' exercise of the
77.412 -rights granted herein. You are not responsible for enforcing compliance by
77.413 -third parties to this License.
77.414 -7. If, as a consequence of a court judgment or allegation of patent
77.415 -infringement or for any other reason (not limited to patent issues), conditions
77.416 -are imposed on you (whether by court order, agreement or otherwise) that
77.417 -contradict the conditions of this License, they do not excuse you from the
77.418 -conditions of this License. If you cannot distribute so as to satisfy
77.419 -simultaneously your obligations under this License and any other pertinent
77.420 -obligations, then as a consequence you may not distribute the Program at all.
77.421 -For example, if a patent license would not permit royalty-free redistribution
77.422 -of the Program by all those who receive copies directly or indirectly through
77.423 -you, then the only way you could satisfy both it and this License would be to
77.424 -refrain entirely from distribution of the Program.
77.425 -If any portion of this section is held invalid or unenforceable under any
77.426 -particular circumstance, the balance of the section is intended to apply and
77.427 -the section as a whole is intended to apply in other circumstances.
77.428 -It is not the purpose of this section to induce you to infringe any patents or
77.429 -other property right claims or to contest validity of any such claims; this
77.430 -section has the sole purpose of protecting the integrity of the free software
77.431 -distribution system, which is implemented by public license practices. Many
77.432 -people have made generous contributions to the wide range of software
77.433 -distributed through that system in reliance on consistent application of that
77.434 -system; it is up to the author/donor to decide if he or she is willing to
77.435 -distribute software through any other system and a licensee cannot impose that
77.436 -choice.
77.437 -This section is intended to make thoroughly clear what is believed to be a
77.438 -consequence of the rest of this License.
77.439 -8. If the distribution and/or use of the Program is restricted in certain
77.440 -countries either by patents or by copyrighted interfaces, the original
77.441 -copyright holder who places the Program under this License may add an explicit
77.442 -geographical distribution limitation excluding those countries, so that
77.443 -distribution is permitted only in or among countries not thus excluded. In such
77.444 -case, this License incorporates the limitation as if written in the body of
77.445 -this License.
77.446 -9. The Free Software Foundation may publish revised and/or new versions of the
77.447 -General Public License from time to time. Such new versions will be similar in
77.448 -spirit to the present version, but may differ in detail to address new problems
77.449 -or concerns.
77.450 -Each version is given a distinguishing version number. If the Program specifies
77.451 -a version number of this License which applies to it and "any later version",
77.452 -you have the option of following the terms and conditions either of that
77.453 -version or of any later version published by the Free Software Foundation. If
77.454 -the Program does not specify a version number of this License, you may choose
77.455 -any version ever published by the Free Software Foundation.
77.456 -10. If you wish to incorporate parts of the Program into other free programs
77.457 -whose distribution conditions are different, write to the author to ask for
77.458 -permission. For software which is copyrighted by the Free Software Foundation,
77.459 -write to the Free Software Foundation; we sometimes make exceptions for this.
77.460 -Our decision will be guided by the two goals of preserving the free status of
77.461 -all derivatives of our free software and of promoting the sharing and reuse of
77.462 -software generally.
77.463 -NO WARRANTY
77.464 -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
77.465 -THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
77.466 -STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
77.467 -PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
77.468 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
77.469 -FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
77.470 -PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
77.471 -ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
77.472 -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
77.473 -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
77.474 -PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
77.475 -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
77.476 -INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
77.477 -BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
77.478 -FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
77.479 -OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
77.480 -END OF TERMS AND CONDITIONS
77.481 -How to Apply These Terms to Your New Programs
77.482 -If you develop a new program, and you want it to be of the greatest possible
77.483 -use to the public, the best way to achieve this is to make it free software
77.484 -which everyone can redistribute and change under these terms.
77.485 -To do so, attach the following notices to the program. It is safest to attach
77.486 -them to the start of each source file to most effectively convey the exclusion
77.487 -of warranty; and each file should have at least the "copyright" line and a
77.488 -pointer to where the full notice is found.
77.489 -One line to give the program's name and a brief idea of what it does.
77.490 -Copyright (C)
77.491 -This program is free software; you can redistribute it and/or modify it under
77.492 -the terms of the GNU General Public License as published by the Free Software
77.493 -Foundation; either version 2 of the License, or (at your option) any later
77.494 -version.
77.495 -This program is distributed in the hope that it will be useful, but WITHOUT ANY
77.496 -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
77.497 -PARTICULAR PURPOSE. See the GNU General Public License for more details.
77.498 -You should have received a copy of the GNU General Public License along with
77.499 -this program; if not, write to the Free Software Foundation, Inc., 59 Temple
77.500 -Place, Suite 330, Boston, MA 02111-1307 USA
77.501 -Also add information on how to contact you by electronic and paper mail.
77.502 -If the program is interactive, make it output a short notice like this when it
77.503 -starts in an interactive mode:
77.504 -Gnomovision version 69, Copyright (C) year name of author
77.505 -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This
77.506 -is free software, and you are welcome to redistribute it under certain
77.507 -conditions; type `show c' for details.
77.508 -The hypothetical commands `show w' and `show c' should show the appropriate
77.509 -parts of the General Public License. Of course, the commands you use may be
77.510 -called something other than `show w' and `show c'; they could even be
77.511 -mouse-clicks or menu items--whatever suits your program.
77.512 -You should also get your employer (if you work as a programmer) or your school,
77.513 -if any, to sign a "copyright disclaimer" for the program, if necessary. Here is
77.514 -a sample; alter the names:
77.515 -Yoyodyne, Inc., hereby disclaims all copyright interest in the program
77.516 -`Gnomovision' (which makes passes at compilers) written by James Hacker.
77.517 -signature of Ty Coon, 1 April 1989
77.518 -Ty Coon, President of Vice
77.519 -This General Public License does not permit incorporating your program into
77.520 -proprietary programs. If your program is a subroutine library, you may consider
77.521 -it more useful to permit linking proprietary applications with the library. If
77.522 -this is what you want to do, use the GNU Library General Public License instead
77.523 -of this License.
77.524 -"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
77.525 -Certain source files distributed by Oracle America, Inc. and/or its affiliates
77.526 -are subject to the following clarification and special exception to the GPLv2,
77.527 -based on the GNU Project exception for its Classpath libraries, known as the
77.528 -GNU Classpath Exception, but only where Oracle has expressly included in the
77.529 -particular source file's header the words "Oracle designates this particular
77.530 -file as subject to the "Classpath" exception as provided by Oracle in the
77.531 -LICENSE file that accompanied this code."
77.532 -You should also note that Oracle includes multiple, independent programs in
77.533 -this software package. Some of those programs are provided under licenses
77.534 -deemed incompatible with the GPLv2 by the Free Software Foundation and others.
77.535 -For example, the package includes programs licensed under the Apache License,
77.536 -Version 2.0. Such programs are licensed to you under their original licenses.
77.537 -Oracle facilitates your further distribution of this package by adding the
77.538 -Classpath Exception to the necessary parts of its GPLv2 code, which permits you
77.539 -to use that code in combination with other independent modules not licensed
77.540 -under the GPLv2. However, note that this would not permit you to commingle code
77.541 -under an incompatible license with Oracle's GPLv2 licensed code by, for
77.542 -example, cutting and pasting such code into a file also containing Oracle's
77.543 -GPLv2 licensed code and then distributing the result.
77.544 -Additionally, if you were to remove the Classpath Exception from any of the
77.545 -files to which it applies and distribute the result, you would likely be
77.546 -required to license some or all of the other code in that distribution under
77.547 -the GPLv2 as well, and since the GPLv2 is incompatible with the license terms
77.548 -of some items included in the distribution by Oracle, removing the Classpath
77.549 -Exception could therefore effectively compromise your ability to further
77.550 -distribute the package.
77.551 -Proceed with caution and we recommend that you obtain the advice of a lawyer
77.552 -skilled in open source matters before removing the Classpath Exception or
77.553 -making modifications to this package which may subsequently be redistributed
77.554 -and/or involve the use of third party software.
77.555 -CLASSPATH EXCEPTION
77.556 -Linking this library statically or dynamically with other modules is making a
77.557 -combined work based on this library. Thus, the terms and conditions of the GNU
77.558 -General Public License version 2 cover the whole combination.
77.559 -As a special exception, the copyright holders of this library give you
77.560 -permission to link this library with independent modules to produce an
77.561 -executable, regardless of the license terms of these independent modules, and
77.562 -to copy and distribute the resulting executable under terms of your choice,
77.563 -provided that you also meet, for each linked independent module, the terms and
77.564 -conditions of the license of that module. An independent module is a module
77.565 -which is not derived from or based on this library. If you modify this library,
77.566 -you may extend this exception to your version of the library, but you are not
77.567 -obligated to do so. If you do not wish to do so, delete this exception
77.568 -statement from your version.
78.1 --- a/ide.analysis.modernize/manifest.mf Wed Jun 07 18:50:35 2017 +0300
78.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
78.3 @@ -1,6 +0,0 @@
78.4 -Manifest-Version: 1.0
78.5 -AutoUpdate-Show-In-Client: true
78.6 -OpenIDE-Module: org.netbeans.modules.ide.analysis.modernize
78.7 -OpenIDE-Module-Layer: org/netbeans/modules/ide/analysis/modernize/layer.xml
78.8 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ide/analysis/modernize/Bundle.properties
78.9 -OpenIDE-Module-Specification-Version: 1.1.1
79.1 --- a/ide.analysis.modernize/nbproject/project.properties Wed Jun 07 18:50:35 2017 +0300
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,13 +0,0 @@
79.4 -javac.source=1.7
79.5 -javac.compilerargs=-Xlint -Xlint:-serial
79.6 -
79.7 -license.file=license.txt
79.8 -nbm.module.author=Ilia Gromov
79.9 -nbm.needs.restart=true
79.10 -test.unit.cp.extra=../../cnd.modelimpl/build/test/unit/classes:\
79.11 -../../cnd/build/test/unit/classes:\
79.12 -../../dlight.nativeexecution/build/test/unit/classes:\
79.13 -../../editor.mimelookup/build/test/unit/classes:\
79.14 -../../cnd.classview/build/test/unit/classes
79.15 -
79.16 -test.unit.run.cp.extra=../../editor.mimelookup/build/test/unit/classes
80.1 --- a/ide.analysis.modernize/nbproject/project.xml Wed Jun 07 18:50:35 2017 +0300
80.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
80.3 @@ -1,334 +0,0 @@
80.4 -<?xml version="1.0" encoding="UTF-8"?>
80.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
80.6 - <type>org.netbeans.modules.apisupport.project</type>
80.7 - <configuration>
80.8 - <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
80.9 - <code-name-base>org.netbeans.modules.ide.analysis.modernize</code-name-base>
80.10 - <module-dependencies>
80.11 - <dependency>
80.12 - <code-name-base>org.netbeans.api.progress</code-name-base>
80.13 - <build-prerequisite/>
80.14 - <compile-dependency/>
80.15 - <run-dependency>
80.16 - <release-version>1</release-version>
80.17 - <specification-version>1.46.1</specification-version>
80.18 - </run-dependency>
80.19 - </dependency>
80.20 - <dependency>
80.21 - <code-name-base>org.netbeans.api.progress.nb</code-name-base>
80.22 - <build-prerequisite/>
80.23 - <compile-dependency/>
80.24 - <run-dependency>
80.25 - <specification-version>1.46.1</specification-version>
80.26 - </run-dependency>
80.27 - </dependency>
80.28 - <dependency>
80.29 - <code-name-base>org.netbeans.modules.cnd.analysis.api</code-name-base>
80.30 - <build-prerequisite/>
80.31 - <compile-dependency/>
80.32 - <run-dependency>
80.33 - <specification-version>1.3.1</specification-version>
80.34 - </run-dependency>
80.35 - </dependency>
80.36 - <dependency>
80.37 - <code-name-base>org.netbeans.modules.cnd.api.model</code-name-base>
80.38 - <build-prerequisite/>
80.39 - <compile-dependency/>
80.40 - <run-dependency>
80.41 - <release-version>1</release-version>
80.42 - <specification-version>1.13.1.1</specification-version>
80.43 - </run-dependency>
80.44 - </dependency>
80.45 - <dependency>
80.46 - <code-name-base>org.netbeans.modules.cnd.api.project</code-name-base>
80.47 - <build-prerequisite/>
80.48 - <compile-dependency/>
80.49 - <run-dependency>
80.50 - <release-version>1</release-version>
80.51 - <specification-version>1.31.4</specification-version>
80.52 - </run-dependency>
80.53 - </dependency>
80.54 - <dependency>
80.55 - <code-name-base>org.netbeans.modules.cnd.api.remote</code-name-base>
80.56 - <build-prerequisite/>
80.57 - <compile-dependency/>
80.58 - <run-dependency>
80.59 - <release-version>1</release-version>
80.60 - <specification-version>1.22.2</specification-version>
80.61 - </run-dependency>
80.62 - </dependency>
80.63 - <dependency>
80.64 - <code-name-base>org.netbeans.modules.cnd.kit</code-name-base>
80.65 - <run-dependency>
80.66 - <specification-version>1.30.5.1</specification-version>
80.67 - </run-dependency>
80.68 - </dependency>
80.69 - <dependency>
80.70 - <code-name-base>org.netbeans.modules.cnd.makeproject</code-name-base>
80.71 - <build-prerequisite/>
80.72 - <compile-dependency/>
80.73 - <run-dependency>
80.74 - <release-version>2</release-version>
80.75 - <specification-version>1.15.0.1</specification-version>
80.76 - </run-dependency>
80.77 - </dependency>
80.78 - <dependency>
80.79 - <code-name-base>org.netbeans.modules.cnd.model.services</code-name-base>
80.80 - <build-prerequisite/>
80.81 - <compile-dependency/>
80.82 - <run-dependency>
80.83 - <release-version>1</release-version>
80.84 - <specification-version>1.42.16</specification-version>
80.85 - </run-dependency>
80.86 - </dependency>
80.87 - <dependency>
80.88 - <code-name-base>org.netbeans.modules.cnd.modelutil</code-name-base>
80.89 - <build-prerequisite/>
80.90 - <compile-dependency/>
80.91 - <run-dependency>
80.92 - <release-version>1</release-version>
80.93 - <specification-version>1.14.0.1</specification-version>
80.94 - </run-dependency>
80.95 - </dependency>
80.96 - <dependency>
80.97 - <code-name-base>org.netbeans.modules.cnd.toolchain</code-name-base>
80.98 - <build-prerequisite/>
80.99 - <compile-dependency/>
80.100 - <run-dependency>
80.101 - <specification-version>1.5.0.1</specification-version>
80.102 - </run-dependency>
80.103 - </dependency>
80.104 - <dependency>
80.105 - <code-name-base>org.netbeans.modules.cnd.utils</code-name-base>
80.106 - <build-prerequisite/>
80.107 - <compile-dependency/>
80.108 - <run-dependency>
80.109 - <specification-version>1.17.1</specification-version>
80.110 - </run-dependency>
80.111 - </dependency>
80.112 - <dependency>
80.113 - <code-name-base>org.netbeans.modules.cnd.utils.ui</code-name-base>
80.114 - <build-prerequisite/>
80.115 - <compile-dependency/>
80.116 - <run-dependency>
80.117 - <specification-version>1.0</specification-version>
80.118 - </run-dependency>
80.119 - </dependency>
80.120 - <dependency>
80.121 - <code-name-base>org.netbeans.modules.code.analysis</code-name-base>
80.122 - <build-prerequisite/>
80.123 - <compile-dependency/>
80.124 - <run-dependency>
80.125 - <release-version>0</release-version>
80.126 - <specification-version>1.8</specification-version>
80.127 - </run-dependency>
80.128 - </dependency>
80.129 - <dependency>
80.130 - <code-name-base>org.netbeans.modules.dlight.nativeexecution</code-name-base>
80.131 - <build-prerequisite/>
80.132 - <compile-dependency/>
80.133 - <run-dependency>
80.134 - <specification-version>1.10.3</specification-version>
80.135 - </run-dependency>
80.136 - </dependency>
80.137 - <dependency>
80.138 - <code-name-base>org.netbeans.modules.dlight.remote</code-name-base>
80.139 - <build-prerequisite/>
80.140 - <compile-dependency/>
80.141 - <run-dependency>
80.142 - <specification-version>1.28.7.1</specification-version>
80.143 - </run-dependency>
80.144 - </dependency>
80.145 - <dependency>
80.146 - <code-name-base>org.netbeans.modules.dlight.remote.ui</code-name-base>
80.147 - <build-prerequisite/>
80.148 - <compile-dependency/>
80.149 - <run-dependency>
80.150 - <specification-version>1.1.0</specification-version>
80.151 - </run-dependency>
80.152 - </dependency>
80.153 - <dependency>
80.154 - <code-name-base>org.netbeans.modules.editor.document</code-name-base>
80.155 - <build-prerequisite/>
80.156 - <compile-dependency/>
80.157 - <run-dependency>
80.158 - <specification-version>1.6.0.1</specification-version>
80.159 - </run-dependency>
80.160 - </dependency>
80.161 - <dependency>
80.162 - <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
80.163 - <build-prerequisite/>
80.164 - <compile-dependency/>
80.165 - <run-dependency>
80.166 - <release-version>3</release-version>
80.167 - <specification-version>4.3.1.22.1.44</specification-version>
80.168 - </run-dependency>
80.169 - </dependency>
80.170 - <dependency>
80.171 - <code-name-base>org.netbeans.modules.options.api</code-name-base>
80.172 - <build-prerequisite/>
80.173 - <compile-dependency/>
80.174 - <run-dependency>
80.175 - <release-version>1</release-version>
80.176 - <specification-version>1.22</specification-version>
80.177 - </run-dependency>
80.178 - </dependency>
80.179 - <dependency>
80.180 - <code-name-base>org.netbeans.modules.projectapi</code-name-base>
80.181 - <build-prerequisite/>
80.182 - <compile-dependency/>
80.183 - <run-dependency>
80.184 - <release-version>1</release-version>
80.185 - <specification-version>1.36</specification-version>
80.186 - </run-dependency>
80.187 - </dependency>
80.188 - <dependency>
80.189 - <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
80.190 - <build-prerequisite/>
80.191 - <compile-dependency/>
80.192 - <run-dependency>
80.193 - <specification-version>1.47.1.1</specification-version>
80.194 - </run-dependency>
80.195 - </dependency>
80.196 - <dependency>
80.197 - <code-name-base>org.netbeans.spi.editor.hints</code-name-base>
80.198 - <build-prerequisite/>
80.199 - <compile-dependency/>
80.200 - <run-dependency>
80.201 - <release-version>0-1</release-version>
80.202 - <specification-version>1.18.0.7.9</specification-version>
80.203 - </run-dependency>
80.204 - </dependency>
80.205 - <dependency>
80.206 - <code-name-base>org.openide.awt</code-name-base>
80.207 - <build-prerequisite/>
80.208 - <compile-dependency/>
80.209 - <run-dependency>
80.210 - <specification-version>7.31</specification-version>
80.211 - </run-dependency>
80.212 - </dependency>
80.213 - <dependency>
80.214 - <code-name-base>org.openide.filesystems</code-name-base>
80.215 - <build-prerequisite/>
80.216 - <compile-dependency/>
80.217 - <run-dependency>
80.218 - <specification-version>9.8.1</specification-version>
80.219 - </run-dependency>
80.220 - </dependency>
80.221 - <dependency>
80.222 - <code-name-base>org.openide.filesystems.nb</code-name-base>
80.223 - <build-prerequisite/>
80.224 - <compile-dependency/>
80.225 - <run-dependency>
80.226 - <specification-version>9.7.1</specification-version>
80.227 - </run-dependency>
80.228 - </dependency>
80.229 - <dependency>
80.230 - <code-name-base>org.openide.loaders</code-name-base>
80.231 - <build-prerequisite/>
80.232 - <compile-dependency/>
80.233 - <run-dependency>
80.234 - <specification-version>7.61</specification-version>
80.235 - </run-dependency>
80.236 - </dependency>
80.237 - <dependency>
80.238 - <code-name-base>org.openide.modules</code-name-base>
80.239 - <build-prerequisite/>
80.240 - <compile-dependency/>
80.241 - <run-dependency>
80.242 - <specification-version>7.47.1</specification-version>
80.243 - </run-dependency>
80.244 - </dependency>
80.245 - <dependency>
80.246 - <code-name-base>org.openide.text</code-name-base>
80.247 - <build-prerequisite/>
80.248 - <compile-dependency/>
80.249 - <run-dependency>
80.250 - <specification-version>6.66.1</specification-version>
80.251 - </run-dependency>
80.252 - </dependency>
80.253 - <dependency>
80.254 - <code-name-base>org.openide.util</code-name-base>
80.255 - <build-prerequisite/>
80.256 - <compile-dependency/>
80.257 - <run-dependency>
80.258 - <specification-version>9.3</specification-version>
80.259 - </run-dependency>
80.260 - </dependency>
80.261 - <dependency>
80.262 - <code-name-base>org.openide.util.lookup</code-name-base>
80.263 - <build-prerequisite/>
80.264 - <compile-dependency/>
80.265 - <run-dependency>
80.266 - <specification-version>8.23</specification-version>
80.267 - </run-dependency>
80.268 - </dependency>
80.269 - <dependency>
80.270 - <code-name-base>org.openide.util.ui</code-name-base>
80.271 - <build-prerequisite/>
80.272 - <compile-dependency/>
80.273 - <run-dependency>
80.274 - <specification-version>9.3</specification-version>
80.275 - </run-dependency>
80.276 - </dependency>
80.277 - <dependency>
80.278 - <code-name-base>org.openide.windows</code-name-base>
80.279 - <build-prerequisite/>
80.280 - <compile-dependency/>
80.281 - <run-dependency>
80.282 - <specification-version>6.74.1</specification-version>
80.283 - </run-dependency>
80.284 - </dependency>
80.285 - </module-dependencies>
80.286 - <test-dependencies>
80.287 - <test-type>
80.288 - <name>unit</name>
80.289 - <test-dependency>
80.290 - <code-name-base>org.netbeans.libs.junit4</code-name-base>
80.291 - <compile-dependency/>
80.292 - </test-dependency>
80.293 - <test-dependency>
80.294 - <code-name-base>org.netbeans.modules.cnd.classview</code-name-base>
80.295 - <compile-dependency/>
80.296 - </test-dependency>
80.297 - <test-dependency>
80.298 - <code-name-base>org.netbeans.modules.cnd.kit</code-name-base>
80.299 - <recursive/>
80.300 - <compile-dependency/>
80.301 - <test/>
80.302 - </test-dependency>
80.303 - <test-dependency>
80.304 - <code-name-base>org.netbeans.modules.cnd.makeproject</code-name-base>
80.305 - <recursive/>
80.306 - <compile-dependency/>
80.307 - <test/>
80.308 - </test-dependency>
80.309 - <test-dependency>
80.310 - <code-name-base>org.netbeans.modules.cnd.modelimpl</code-name-base>
80.311 - <recursive/>
80.312 - <compile-dependency/>
80.313 - <test/>
80.314 - </test-dependency>
80.315 - <test-dependency>
80.316 - <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
80.317 - <recursive/>
80.318 - <compile-dependency/>
80.319 - <test/>
80.320 - </test-dependency>
80.321 - <test-dependency>
80.322 - <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
80.323 - <recursive/>
80.324 - <compile-dependency/>
80.325 - </test-dependency>
80.326 - <test-dependency>
80.327 - <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
80.328 - <recursive/>
80.329 - <compile-dependency/>
80.330 - <test/>
80.331 - </test-dependency>
80.332 - </test-type>
80.333 - </test-dependencies>
80.334 - <public-packages/>
80.335 - </data>
80.336 - </configuration>
80.337 -</project>
81.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/Bundle.properties Wed Jun 07 18:50:35 2017 +0300
81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
81.3 @@ -1,8 +0,0 @@
81.4 -OpenIDE-Module-Display-Category=Analysis tools
81.5 -OpenIDE-Module-Long-Description=\
81.6 - This plugin enables clang-tidy analysis on C/C++ projects and files via Source->Inspect or right in the Editor.\n\
81.7 - Works only with "Clang-tidy wrapper for <OS> <bitness>" plugin.\n\n\
81.8 - Please note that in order to have clang-tidy hints in the Editor you should run Source->Inspect on your whole project.\n\
81.9 - You can view list of checks and enable/disable them in Options->Editor->Hints.
81.10 -OpenIDE-Module-Name=Clang-tidy integration
81.11 -OpenIDE-Module-Short-Description=Clang-tidy analyzer integration
82.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/AnalyzedFiles.java Wed Jun 07 18:50:35 2017 +0300
82.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
82.3 @@ -1,114 +0,0 @@
82.4 -/*
82.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
82.6 - *
82.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
82.8 - *
82.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
82.10 - * Other names may be trademarks of their respective owners.
82.11 - *
82.12 - * The contents of this file are subject to the terms of either the GNU
82.13 - * General Public License Version 2 only ("GPL") or the Common
82.14 - * Development and Distribution License("CDDL") (collectively, the
82.15 - * "License"). You may not use this file except in compliance with the
82.16 - * License. You can obtain a copy of the License at
82.17 - * http://www.netbeans.org/cddl-gplv2.html
82.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
82.19 - * specific language governing permissions and limitations under the
82.20 - * License. When distributing the software, include this License Header
82.21 - * Notice in each file and include the License file at
82.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
82.23 - * particular file as subject to the "Classpath" exception as provided
82.24 - * by Oracle in the GPL Version 2 section of the License file that
82.25 - * accompanied this code. If applicable, add the following below the
82.26 - * License Header, with the fields enclosed by brackets [] replaced by
82.27 - * your own identifying information:
82.28 - * "Portions Copyrighted [year] [name of copyright owner]"
82.29 - *
82.30 - * If you wish your version of this file to be governed by only the CDDL
82.31 - * or only the GPL Version 2, indicate your decision by adding
82.32 - * "[Contributor] elects to include this software in this distribution
82.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
82.34 - * single choice of license, a recipient has the option to distribute
82.35 - * your version of this file under either the CDDL, the GPL Version 2 or
82.36 - * to extend the choice of license to its licensees as provided above.
82.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
82.38 - * Version 2 license, then the option applies only if the new code is
82.39 - * made subject to such option by the copyright holder.
82.40 - *
82.41 - * Contributor(s): Ilia Gromov
82.42 - */
82.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
82.44 -
82.45 -import java.util.Collection;
82.46 -import java.util.HashMap;
82.47 -import java.util.HashSet;
82.48 -import java.util.Map;
82.49 -import java.util.Set;
82.50 -import org.netbeans.modules.cnd.api.model.CsmFile;
82.51 -
82.52 -/**
82.53 - * This cache is designed to help Editor showing correct checks for included
82.54 - * files.
82.55 - *
82.56 - * @param <T>
82.57 - */
82.58 -public class AnalyzedFiles {
82.59 -
82.60 - private final Map<CsmFile, Set<CsmFile>> hierarchyCache = new HashMap<CsmFile, Set<CsmFile>>();
82.61 -// private final Map<FileObject, Set<CsmErrorInfo>> diagnosticsCache = new HashMap<FileObject, Set<CsmErrorInfo>>();
82.62 -
82.63 -// public void cacheDiagnostics(FileObject fo, CsmErrorInfo info) {
82.64 -// Set<CsmErrorInfo> alreadyMapped = diagnosticsCache.get(fo);
82.65 -//
82.66 -// if (alreadyMapped == null) {
82.67 -// alreadyMapped = new HashSet<CsmErrorInfo>();
82.68 -// diagnosticsCache.put(fo, alreadyMapped);
82.69 -// }
82.70 -//
82.71 -// alreadyMapped.add(info);
82.72 -// }
82.73 - public void cacheHierarchy(CsmFile startFile, Collection<CsmFile> includedFiles) {
82.74 - Set<CsmFile> alreadyMapped = hierarchyCache.get(startFile);
82.75 -
82.76 - if (alreadyMapped == null) {
82.77 - alreadyMapped = new HashSet<CsmFile>();
82.78 - hierarchyCache.put(startFile, alreadyMapped);
82.79 - }
82.80 -
82.81 - alreadyMapped.addAll(includedFiles);
82.82 - }
82.83 -
82.84 -// public Set<CsmErrorInfo> getDiagnostics(FileObject fo) {
82.85 -// return diagnosticsCache.get(fo);
82.86 -// }
82.87 -
82.88 - public Collection<? extends CsmFile> getStartFiles(CsmFile includedFile) {
82.89 - Set<CsmFile> result = new HashSet<CsmFile>();
82.90 - for (Map.Entry<CsmFile, Set<CsmFile>> entry : hierarchyCache.entrySet()) {
82.91 - CsmFile key = entry.getKey();
82.92 - Set<CsmFile> value = entry.getValue();
82.93 -
82.94 - if (value.contains(includedFile)) {
82.95 - result.add(key);
82.96 - }
82.97 - }
82.98 - return result;
82.99 - }
82.100 -
82.101 - public boolean isStartFile(CsmFile file) {
82.102 - return hierarchyCache.containsKey(file);
82.103 - }
82.104 -
82.105 - public void clear() {
82.106 - hierarchyCache.clear();
82.107 - }
82.108 -
82.109 - public static AnalyzedFiles getDefault() {
82.110 - return HOLDER.INSTANCE;
82.111 - }
82.112 -
82.113 - private static class HOLDER {
82.114 -
82.115 - public static final AnalyzedFiles INSTANCE = new AnalyzedFiles();
82.116 - }
82.117 -}
83.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/Bundle.properties Wed Jun 07 18:50:35 2017 +0300
83.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
83.3 @@ -1,59 +0,0 @@
83.4 -#
83.5 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
83.6 -#
83.7 -# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
83.8 -#
83.9 -# The contents of this file are subject to the terms of either the GNU
83.10 -# General Public License Version 2 only ("GPL") or the Common
83.11 -# Development and Distribution License("CDDL") (collectively, the
83.12 -# "License"). You may not use this file except in compliance with the
83.13 -# License. You can obtain a copy of the License at
83.14 -# http://www.netbeans.org/cddl-gplv2.html
83.15 -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
83.16 -# specific language governing permissions and limitations under the
83.17 -# License. When distributing the software, include this License Header
83.18 -# Notice in each file and include the License file at
83.19 -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
83.20 -# particular file as subject to the "Classpath" exception as provided
83.21 -# by Sun in the GPL Version 2 section of the License file that
83.22 -# accompanied this code. If applicable, add the following below the
83.23 -# License Header, with the fields enclosed by brackets [] replaced by
83.24 -# your own identifying information:
83.25 -# "Portions Copyrighted [year] [name of copyright owner]"
83.26 -#
83.27 -# Contributor(s):
83.28 -#
83.29 -# The Original Software is NetBeans. The Initial Developer of the Original
83.30 -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
83.31 -# Microsystems, Inc. All Rights Reserved.
83.32 -#
83.33 -# If you wish your version of this file to be governed by only the CDDL
83.34 -# or only the GPL Version 2, indicate your decision by adding
83.35 -# "[Contributor] elects to include this software in this distribution
83.36 -# under the [CDDL or GPL Version 2] license." If you do not indicate a
83.37 -# single choice of license, a recipient has the option to distribute
83.38 -# your version of this file under either the CDDL, the GPL Version 2 or
83.39 -# to extend the choice of license to its licensees as provided above.
83.40 -# However, if you add GPL Version 2 code and therefore, elected the GPL
83.41 -# Version 2 license, then the option applies only if the new code is
83.42 -# made subject to such option by the copyright holder.
83.43 -#
83.44 -
83.45 -LBL_ProviderName=C/C++ Errors
83.46 -LBL_ProviderDescription=C/C++ errors and warnings
83.47 -
83.48 -#Previse errors
83.49 -Modernize_NAME=Clang-Tidy analyzer
83.50 -Modernize_DESCRIPTION=Show warnings identified by clang-tidy.\
83.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. \
83.52 - <br>Expand the node to specify which static checks you want to be displayed.
83.53 -DisableHint=Configure clang-tidy analyzer - {0}
83.54 -
83.55 -#internal error
83.56 -tool.error=Oracle Developer Studio compilers not found
83.57 -remote.mode.error=Unsupported remote mode
83.58 -remote.mode.error.info=Mode {0}
83.59 -temporary.file.error=Cannot create temporary file
83.60 -compile.file.error=Clang-tidy was unable to analyze file
83.61 -fatal.analyze.error=Clang-tidy was unable to analyze file
83.62 -compile.file.error.info=Exit code: {0}
84.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ConfigureHintsFix.java Wed Jun 07 18:50:35 2017 +0300
84.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
84.3 @@ -1,80 +0,0 @@
84.4 -/*
84.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
84.6 - *
84.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
84.8 - *
84.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
84.10 - * Other names may be trademarks of their respective owners.
84.11 - *
84.12 - * The contents of this file are subject to the terms of either the GNU
84.13 - * General Public License Version 2 only ("GPL") or the Common
84.14 - * Development and Distribution License("CDDL") (collectively, the
84.15 - * "License"). You may not use this file except in compliance with the
84.16 - * License. You can obtain a copy of the License at
84.17 - * http://www.netbeans.org/cddl-gplv2.html
84.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
84.19 - * specific language governing permissions and limitations under the
84.20 - * License. When distributing the software, include this License Header
84.21 - * Notice in each file and include the License file at
84.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
84.23 - * particular file as subject to the "Classpath" exception as provided
84.24 - * by Oracle in the GPL Version 2 section of the License file that
84.25 - * accompanied this code. If applicable, add the following below the
84.26 - * License Header, with the fields enclosed by brackets [] replaced by
84.27 - * your own identifying information:
84.28 - * "Portions Copyrighted [year] [name of copyright owner]"
84.29 - *
84.30 - * If you wish your version of this file to be governed by only the CDDL
84.31 - * or only the GPL Version 2, indicate your decision by adding
84.32 - * "[Contributor] elects to include this software in this distribution
84.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
84.34 - * single choice of license, a recipient has the option to distribute
84.35 - * your version of this file under either the CDDL, the GPL Version 2 or
84.36 - * to extend the choice of license to its licensees as provided above.
84.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
84.38 - * Version 2 license, then the option applies only if the new code is
84.39 - * made subject to such option by the copyright holder.
84.40 - *
84.41 - * Contributor(s): Ilia Gromov
84.42 - */
84.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
84.44 -
84.45 -import org.netbeans.api.options.OptionsDisplayer;
84.46 -import org.netbeans.spi.editor.hints.ChangeInfo;
84.47 -import org.netbeans.spi.editor.hints.EnhancedFix;
84.48 -import org.openide.util.NbBundle;
84.49 -
84.50 -class ConfigureHintsFix implements EnhancedFix {
84.51 -
84.52 - private final ModernizeErrorInfo error;
84.53 - private final String text;
84.54 -
84.55 - ConfigureHintsFix(ModernizeErrorInfo error) {
84.56 - this.error = error;
84.57 - String id = error.getId();
84.58 - this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N
84.59 - }
84.60 -
84.61 - @Override
84.62 - public String getText() {
84.63 - return NbBundle.getMessage(ModernizeErrorProvider.class, "DisableHint", text); // NOI18N
84.64 - }
84.65 -
84.66 - @Override
84.67 - public ChangeInfo implement() throws Exception {
84.68 - String provider = ModernizeErrorProvider.NAME;
84.69 - String name = error.getId();
84.70 - OptionsDisplayer.getDefault().open("Editor/Hints/text/x-cnd+sourcefile/" + provider + "/" + name); // NOI18N
84.71 - return null;
84.72 - }
84.73 -
84.74 - @Override
84.75 - public CharSequence getSortText() {
84.76 - //Hint opening options dialog should always be the lastest in offered list
84.77 - return Integer.toString(Integer.MAX_VALUE);
84.78 - }
84.79 -
84.80 - public ModernizeErrorInfo getError() {
84.81 - return error;
84.82 - }
84.83 -}
85.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/DiagnosticsTool.java Wed Jun 07 18:50:35 2017 +0300
85.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
85.3 @@ -1,307 +0,0 @@
85.4 -/*
85.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
85.6 - *
85.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
85.8 - *
85.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
85.10 - * Other names may be trademarks of their respective owners.
85.11 - *
85.12 - * The contents of this file are subject to the terms of either the GNU
85.13 - * General Public License Version 2 only ("GPL") or the Common
85.14 - * Development and Distribution License("CDDL") (collectively, the
85.15 - * "License"). You may not use this file except in compliance with the
85.16 - * License. You can obtain a copy of the License at
85.17 - * http://www.netbeans.org/cddl-gplv2.html
85.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
85.19 - * specific language governing permissions and limitations under the
85.20 - * License. When distributing the software, include this License Header
85.21 - * Notice in each file and include the License file at
85.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
85.23 - * particular file as subject to the "Classpath" exception as provided
85.24 - * by Oracle in the GPL Version 2 section of the License file that
85.25 - * accompanied this code. If applicable, add the following below the
85.26 - * License Header, with the fields enclosed by brackets [] replaced by
85.27 - * your own identifying information:
85.28 - * "Portions Copyrighted [year] [name of copyright owner]"
85.29 - *
85.30 - * If you wish your version of this file to be governed by only the CDDL
85.31 - * or only the GPL Version 2, indicate your decision by adding
85.32 - * "[Contributor] elects to include this software in this distribution
85.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
85.34 - * single choice of license, a recipient has the option to distribute
85.35 - * your version of this file under either the CDDL, the GPL Version 2 or
85.36 - * to extend the choice of license to its licensees as provided above.
85.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
85.38 - * Version 2 license, then the option applies only if the new code is
85.39 - * made subject to such option by the copyright holder.
85.40 - *
85.41 - * Contributor(s): Ilia Gromov
85.42 - */
85.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
85.44 -
85.45 -import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools;
85.46 -import java.io.BufferedReader;
85.47 -import java.io.File;
85.48 -import java.io.FileReader;
85.49 -import java.io.IOException;
85.50 -import java.nio.file.Files;
85.51 -import java.nio.file.Path;
85.52 -import java.util.ArrayList;
85.53 -import java.util.Collection;
85.54 -import java.util.Collections;
85.55 -import java.util.List;
85.56 -import java.util.logging.Level;
85.57 -import java.util.logging.Logger;
85.58 -import org.netbeans.modules.cnd.api.model.CsmFile;
85.59 -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
85.60 -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
85.61 -import org.netbeans.modules.cnd.api.toolchain.AbstractCompiler;
85.62 -import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCCompiler;
85.63 -import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCompiler;
85.64 -import org.netbeans.modules.cnd.api.toolchain.Tool;
85.65 -import org.netbeans.modules.cnd.makeproject.api.MakeProject;
85.66 -import org.netbeans.modules.cnd.makeproject.api.configurations.CCCCompilerConfiguration;
85.67 -import org.netbeans.modules.cnd.makeproject.api.configurations.CCCompilerConfiguration;
85.68 -import org.netbeans.modules.cnd.makeproject.api.configurations.CCompilerConfiguration;
85.69 -import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
85.70 -import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration;
85.71 -import org.netbeans.modules.cnd.makeproject.api.support.MakeProjectOptionsFormat;
85.72 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
85.73 -import org.netbeans.modules.nativeexecution.api.HostInfo;
85.74 -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
85.75 -import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
85.76 -import org.netbeans.modules.nativeexecution.api.util.ProcessUtils;
85.77 -import org.openide.filesystems.FileObject;
85.78 -import org.openide.filesystems.FileUtil;
85.79 -
85.80 -/**
85.81 - *
85.82 - * @author Ilia Gromov
85.83 - */
85.84 -public class DiagnosticsTool {
85.85 -
85.86 - public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N
85.87 - public static final String CACHE_ID = "TIDY-CACHE"; //NOI18N
85.88 -
85.89 - public static final int STATUS_OK = 0;
85.90 - public static final int STATUS_IO_ERROR = -1;
85.91 -
85.92 - public static List<CodeAudit> getAudits(String path, ExecutionEnvironment env, AuditPreferences preferences) {
85.93 - List<CodeAudit> res = new ArrayList<>();
85.94 -
85.95 - ProcessUtils.ExitStatus status = ProcessUtils.execute(env, path, new String[]{"-checks=*", "-list-checks", "dummy", "--"}); // NOI18N
85.96 -
85.97 - if (status.exitCode == 0) {
85.98 - String out = status.getOutputString();
85.99 - out = out.substring(status.getOutputString().indexOf('\n') + 1);
85.100 - String[] checks = out.split("\n"); // NOI18N
85.101 -
85.102 - FileObject disabledChecksFolder = FileUtil.getConfigFile("Analysis/Clang-Tidy/Disabled_Default"); // NOI18N
85.103 -
85.104 - List<String> disabledChecks = new ArrayList<>();
85.105 - for (FileObject fileObject : disabledChecksFolder.getChildren()) {
85.106 - disabledChecks.add(fileObject.getName());
85.107 - }
85.108 -
85.109 - for (String check : checks) {
85.110 - check = check.trim();
85.111 - ModernizeCodeAudit myCodeAudit = new ModernizeCodeAudit(
85.112 - check,
85.113 - check,
85.114 - check,
85.115 - "warning", //NOI18N
85.116 - !disabledChecks.contains(check),
85.117 - preferences);
85.118 - res.add(myCodeAudit);
85.119 - }
85.120 - }
85.121 -
85.122 - return res;
85.123 - }
85.124 -
85.125 - private final ExecutionEnvironment execEnv;
85.126 - private final Item item;
85.127 - private final MakeProject project;
85.128 - private final String binaryPath;
85.129 -
85.130 - private StringBuilder buf;
85.131 -
85.132 - public DiagnosticsTool(ExecutionEnvironment execEnv, Item item, MakeProject project, String binaryPath) {
85.133 - this.execEnv = execEnv;
85.134 - this.item = item;
85.135 - this.project = project;
85.136 - this.binaryPath = binaryPath;
85.137 - }
85.138 -
85.139 - /**
85.140 - * @return clang-tidy's exit code or negative code if some other problem has
85.141 - * occurred.
85.142 - */
85.143 - public int process(Collection<String> checks, CsmFile csmFile, boolean isStartFile) throws ConnectionManager.CancellationException, IOException {
85.144 - // TODO: can we split analyzer (Source -> Inspect) ant editor error providing?
85.145 -
85.146 - final String directoryMacro = "xDIRx"; //NOI18N
85.147 -
85.148 - File tmpDir = null;
85.149 - try {
85.150 - List<String> args = new ArrayList<String>();
85.151 -
85.152 - HostInfo hostInfo = HostInfoUtils.getHostInfo(execEnv);
85.153 -
85.154 - try {
85.155 - if (execEnv.isRemote()) {
85.156 - tmpDir = Files.createTempDirectory(hostInfo.getTempDirFile().toPath(), "tidy").toFile(); //NOI18N
85.157 - } else {
85.158 - tmpDir = Files.createTempDirectory("tidy").toFile(); //NOI18N
85.159 - }
85.160 - } catch (IOException ex) {
85.161 - return -1;
85.162 - }
85.163 -
85.164 - Path tmpFile = Files.createTempFile(tmpDir.toPath(), null, null);
85.165 -
85.166 - args.add("-header-filter=.*"); //NOI18N
85.167 - StringBuilder sb = new StringBuilder("-checks=");// NOI18N
85.168 - for (String check : checks) {
85.169 - sb.append(check);
85.170 - sb.append(","); // NOI18N
85.171 - }
85.172 - args.add(sb.toString().substring(0, sb.length() - 1));
85.173 -
85.174 - args.add("-export-fixes=" + tmpFile); // NOI18N
85.175 - int directoryIdx = args.size() - 1;
85.176 -
85.177 - Collection<? extends CsmFile> startFiles = Collections.EMPTY_LIST;
85.178 - args.add(csmFile.getFileObject().getPath());
85.179 -
85.180 - args.add("--"); //NOI18N
85.181 - args.addAll(getAdditionalFlags(csmFile));
85.182 -
85.183 - List<String> copy = new ArrayList<String>(args);
85.184 -
85.185 - copy.set(directoryIdx, copy.get(directoryIdx).replace(directoryMacro, tmpDir.getAbsolutePath()));
85.186 -
85.187 - // TODO: execute in the ${WORKING_DIR} ? Because we can have relative path includes (-Isrc/libs/abcd)
85.188 - ProcessUtils.ExitStatus executeStatus = ProcessUtils.executeInDir(tmpDir.getAbsolutePath(),
85.189 - execEnv,
85.190 - binaryPath,
85.191 - copy.toArray(new String[copy.size()]));
85.192 -
85.193 - if (executeStatus.exitCode != STATUS_OK) {
85.194 - LOG.log(Level.INFO, "clang-tidy exit code {0}: {1}", new Object[]{executeStatus.exitCode, arrayAsString(binaryPath, copy)});
85.195 - LOG.fine(executeStatus.getOutputString());
85.196 - LOG.fine(executeStatus.getErrorString());
85.197 - return executeStatus.exitCode;
85.198 - } else {
85.199 - LOG.log(Level.FINEST, "{0}", arrayAsString(binaryPath, copy));
85.200 - LOG.finest(executeStatus.getOutputString());
85.201 - LOG.finest(executeStatus.getErrorString());
85.202 - }
85.203 -
85.204 - File[] listFiles = tmpDir.listFiles();
85.205 -
85.206 - if (listFiles.length != 1) {
85.207 - return STATUS_IO_ERROR;
85.208 - }
85.209 -
85.210 - File yamlFile = listFiles[0];
85.211 -
85.212 - BufferedReader in = new BufferedReader(new FileReader(yamlFile));
85.213 - buf = new StringBuilder();
85.214 - while (true) {
85.215 - String s = in.readLine();
85.216 - if (s == null) {
85.217 - break;
85.218 - }
85.219 - buf.append(s).append('\n'); //NOI18N
85.220 - }
85.221 -
85.222 - } finally {
85.223 - try {
85.224 - tmpDir.delete();
85.225 - } catch (Exception x) {
85.226 -
85.227 - }
85.228 - }
85.229 -
85.230 - return STATUS_OK;
85.231 - }
85.232 -
85.233 - private List<String> getAdditionalFlags(CsmFile csmFile) {
85.234 - List<String> all = new ArrayList<String>();
85.235 -
85.236 - Tool tool = AnalyticsTools.compiler(item, project);
85.237 -
85.238 - if (tool instanceof AbstractCompiler) {
85.239 - AbstractCompiler compiler = (AbstractCompiler) tool;
85.240 -
85.241 - for (String systemIncludeDirectory : compiler.getSystemIncludeDirectories()) {
85.242 - all.add("-I" + systemIncludeDirectory); //NOI18N
85.243 - }
85.244 -
85.245 - MakeConfiguration activeConfiguration = AnalyticsTools.getConfigurationDescriptor(csmFile, project).getActiveConfiguration();
85.246 -
85.247 - String options = "";
85.248 -// // compileSingleUnmanage as reference
85.249 -// // don't use getAllOptions - we need not -w flag
85.250 - if (tool.getKind() == CCCompiler) {
85.251 - CCCompilerConfiguration ccc = activeConfiguration.getCCCompilerConfiguration();
85.252 - options += ccc.getPreprocessorOptions(compiler.getCompilerSet());
85.253 - options += ccc.getIncludeDirectoriesOptions(compiler.getCompilerSet());
85.254 -// options += getLibrariesFlags();
85.255 - options += compiler.getCppStandardOptions(ccc.getInheritedCppStandard());
85.256 - if (!options.contains("-std=")) { //NOI18N
85.257 - switch (item.getLanguageFlavor()) {
85.258 - case CPP98:
85.259 - options += " -std=c++98"; //NOI18N
85.260 - break;
85.261 - case CPP11:
85.262 - options += " -std=c++11"; //NOI18N
85.263 - break;
85.264 - case CPP14:
85.265 - options += " -std=c++14"; //NOI18N
85.266 - break;
85.267 - }
85.268 - }
85.269 - } else if (tool.getKind() == CCompiler) {
85.270 - CCompilerConfiguration cc = activeConfiguration.getCCompilerConfiguration();
85.271 - options += cc.getPreprocessorOptions(compiler.getCompilerSet());
85.272 - options += cc.getIncludeDirectoriesOptions(compiler.getCompilerSet());
85.273 - options += compiler.getCStandardOptions(cc.getInheritedCStandard());
85.274 - if (!options.contains("-std=")) { //NOI18N
85.275 - switch (item.getLanguageFlavor()) {
85.276 - case C11:
85.277 - options += " -std=c11"; //NOI18N
85.278 - break;
85.279 - case C89:
85.280 - options += " -std=c89"; //NOI18N
85.281 - break;
85.282 - case C99:
85.283 - options += " -std=c99"; //NOI18N
85.284 - break;
85.285 - }
85.286 - }
85.287 - }
85.288 -
85.289 - List<String> optionsList = AnalyticsTools.scanCommandLine(MakeProjectOptionsFormat.reformatWhitespaces(options));
85.290 - all.addAll(optionsList);
85.291 - }
85.292 -
85.293 - return all;
85.294 - }
85.295 -
85.296 - public String getYamlAsString() {
85.297 - if (buf == null) {
85.298 - throw new IllegalStateException();
85.299 - }
85.300 - return buf.toString();
85.301 - }
85.302 -
85.303 - private static String arrayAsString(String binary, List<String> list) {
85.304 - StringBuilder sb = new StringBuilder(binary).append(" "); //NOI18N
85.305 - for (String string : list) {
85.306 - sb.append(string).append(" "); //NOI18N
85.307 - }
85.308 - return sb.toString();
85.309 - }
85.310 -}
86.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java Wed Jun 07 18:50:35 2017 +0300
86.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
86.3 @@ -1,214 +0,0 @@
86.4 -/*
86.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
86.6 - *
86.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
86.8 - *
86.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
86.10 - * Other names may be trademarks of their respective owners.
86.11 - *
86.12 - * The contents of this file are subject to the terms of either the GNU
86.13 - * General Public License Version 2 only ("GPL") or the Common
86.14 - * Development and Distribution License("CDDL") (collectively, the
86.15 - * "License"). You may not use this file except in compliance with the
86.16 - * License. You can obtain a copy of the License at
86.17 - * http://www.netbeans.org/cddl-gplv2.html
86.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
86.19 - * specific language governing permissions and limitations under the
86.20 - * License. When distributing the software, include this License Header
86.21 - * Notice in each file and include the License file at
86.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
86.23 - * particular file as subject to the "Classpath" exception as provided
86.24 - * by Oracle in the GPL Version 2 section of the License file that
86.25 - * accompanied this code. If applicable, add the following below the
86.26 - * License Header, with the fields enclosed by brackets [] replaced by
86.27 - * your own identifying information:
86.28 - * "Portions Copyrighted [year] [name of copyright owner]"
86.29 - *
86.30 - * If you wish your version of this file to be governed by only the CDDL
86.31 - * or only the GPL Version 2, indicate your decision by adding
86.32 - * "[Contributor] elects to include this software in this distribution
86.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
86.34 - * single choice of license, a recipient has the option to distribute
86.35 - * your version of this file under either the CDDL, the GPL Version 2 or
86.36 - * to extend the choice of license to its licensees as provided above.
86.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
86.38 - * Version 2 license, then the option applies only if the new code is
86.39 - * made subject to such option by the copyright holder.
86.40 - *
86.41 - * Contributor(s): Ilia Gromov
86.42 - */
86.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
86.44 -
86.45 -import org.netbeans.modules.ide.analysis.modernize.options.ClangAnalyzerOptions;
86.46 -import org.netbeans.modules.ide.analysis.modernize.resources.BundleUtilities;
86.47 -import java.io.CharConversionException;
86.48 -import java.io.File;
86.49 -import java.util.ArrayList;
86.50 -import java.util.Arrays;
86.51 -import java.util.Collection;
86.52 -import java.util.Collections;
86.53 -import java.util.List;
86.54 -import java.util.concurrent.atomic.AtomicBoolean;
86.55 -import java.util.prefs.Preferences;
86.56 -import org.netbeans.modules.analysis.spi.Analyzer;
86.57 -import org.netbeans.modules.cnd.analysis.api.AbstractAnalyzer;
86.58 -import org.netbeans.modules.cnd.analysis.api.AbstractHintsPanel;
86.59 -import org.netbeans.modules.cnd.api.model.CsmFile;
86.60 -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
86.61 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
86.62 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
86.63 -import org.netbeans.modules.cnd.modelutil.CsmUtilities;
86.64 -import org.netbeans.modules.cnd.utils.CndPathUtilities;
86.65 -import org.netbeans.spi.editor.hints.ErrorDescription;
86.66 -import org.netbeans.spi.editor.hints.ErrorDescriptionFactory;
86.67 -import org.netbeans.spi.editor.hints.LazyFixList;
86.68 -import org.netbeans.spi.editor.hints.Severity;
86.69 -import org.openide.filesystems.FileObject;
86.70 -import org.openide.util.ImageUtilities;
86.71 -import org.openide.util.NbBundle;
86.72 -import org.openide.util.lookup.ServiceProvider;
86.73 -import org.openide.xml.XMLUtil;
86.74 -
86.75 -public class ModernizeAnalyzerImpl extends AbstractAnalyzer {
86.76 -
86.77 - private static final String PREFIX = "tidy-"; //NOI18N
86.78 -
86.79 - private ModernizeAnalyzerImpl(Context ctx) {
86.80 - super(ctx);
86.81 - }
86.82 -
86.83 - @Override
86.84 - public ModernizeErrorProvider getErrorProvider(Preferences preferences) {
86.85 - return ModernizeErrorProvider.getInstance();
86.86 - }
86.87 -
86.88 - @Override
86.89 - protected boolean isCompileUnitBased() {
86.90 - return true;
86.91 - }
86.92 -
86.93 - @Override
86.94 - protected Collection<? extends ErrorDescription> doRunImpl(final FileObject sr, final Context ctx, final CsmErrorProvider provider, final AtomicBoolean cancel) {
86.95 - final CsmFile csmFile = CsmUtilities.getCsmFile(sr, false, false);
86.96 - if (csmFile == null) {
86.97 - return Collections.<ErrorDescription>emptyList();
86.98 - }
86.99 - CsmErrorProvider.Request request = new RequestImpl(csmFile, ctx, cancel);
86.100 - final ArrayList<ErrorDescription> res = new ArrayList<ErrorDescription>();
86.101 - CsmErrorProvider.Response responce = new ResponseImpl(sr, res, cancel);
86.102 - provider.getErrors(request, responce);
86.103 - return res;
86.104 - }
86.105 -
86.106 - protected static class ResponseImpl extends AbstractResponse {
86.107 -
86.108 - public ResponseImpl(FileObject sr, ArrayList<ErrorDescription> res, AtomicBoolean cancel) {
86.109 - super(sr, res, cancel);
86.110 - }
86.111 -
86.112 - @Override
86.113 - protected ErrorDescription addErrorImpl(CsmErrorInfo errorInfo, FileObject fo) {
86.114 - String messages[] = errorInfo.getMessage().split("\n"); //NOI18N
86.115 - if (messages.length > 0) {
86.116 - StringBuilder sb = new StringBuilder();
86.117 - if (errorInfo instanceof ModernizeErrorInfo) {
86.118 - ModernizeErrorInfo mei = (ModernizeErrorInfo) errorInfo;
86.119 - sb.append("<pre>"); //NOI18N
86.120 - sb.append("["); //NOI18N
86.121 - sb.append(mei.getId());
86.122 - sb.append("]"); //NOI18N
86.123 - sb.append("\n"); //NOI18N
86.124 - List<YamlParser.Replacement> replacements = mei.getDiagnostics().getReplacements();
86.125 - if (replacements.isEmpty()) {
86.126 - sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), mei.getDiagnostics().getMessageFilePath())).append(" "); //NOI18N
86.127 - sb.append(mei.getDiagnostics().getMessageFileOffset()).append("\n");
86.128 - } else {
86.129 - for (YamlParser.Replacement replacement : replacements) {
86.130 - sb.append("\n"); //NOI18N
86.131 - sb.append("Replacement: "); //NOI18N
86.132 - sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), replacement.filePath)).append(" "); //NOI18N
86.133 - sb.append(replacement.offset).append("-").append(replacement.offset + replacement.length).append("\n"); //NOI18N
86.134 - String attributeValue = replacement.replacementText;
86.135 - try {
86.136 - attributeValue = XMLUtil.toAttributeValue(replacement.replacementText);
86.137 - } catch (CharConversionException ex) {
86.138 - }
86.139 - sb.append(attributeValue).append("\n"); //NOI18N
86.140 - }
86.141 - }
86.142 - sb.append(mei.getMessage());
86.143 - sb.append("</pre>"); //NOI18N
86.144 -
86.145 - LazyFixList list = new LazyFixListImpl();
86.146 -
86.147 - return ErrorDescriptionFactory.createErrorDescription(PREFIX + mei.getId(), Severity.valueOf(mei.getSeverity().toString().toUpperCase()),
86.148 - messages[0], sb.toString(), list, fo, errorInfo.getStartOffset(), errorInfo.getStartOffset());
86.149 - }
86.150 - }
86.151 - return null;
86.152 - }
86.153 - }
86.154 -
86.155 - @ServiceProvider(service = AnalyzerFactory.class)
86.156 - public static final class AnalyzerFactoryImpl extends AnalyzerFactory {
86.157 -
86.158 - public AnalyzerFactoryImpl() {
86.159 - super(ModernizeErrorProvider.NAME,
86.160 - NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"), //NOI18N
86.161 - ImageUtilities.loadImage("org/netbeans/modules/ide/analysis/modernize/impl/bugs.png")); //NOI18N
86.162 - }
86.163 -
86.164 - @Override
86.165 - public Iterable<? extends WarningDescription> getWarnings() {
86.166 - List<WarningDescription> result = new ArrayList<WarningDescription>();
86.167 - final ModernizeErrorProvider provider = ModernizeErrorProvider.getInstance();
86.168 - for (CodeAudit audit : provider.getAudits()) {
86.169 - result.add(WarningDescription.create(PREFIX + audit.getID(), audit.getName(), ModernizeErrorProvider.NAME, provider.getDisplayName()));
86.170 - }
86.171 - String[] fatals = BundleUtilities.getFatalErrors();
86.172 - for (String id : fatals) { //NOI18N
86.173 - if (!id.isEmpty()) {
86.174 - result.add(WarningDescription.create(PREFIX + id, BundleUtilities.getDescription(id), ModernizeErrorProvider.NAME, provider.getDisplayName()));
86.175 - }
86.176 - }
86.177 - return result;
86.178 - }
86.179 -
86.180 - @Override
86.181 - public CustomizerProvider<Void, AbstractHintsPanel> getCustomizerProvider() {
86.182 - return new CustomizerProvider<Void, AbstractHintsPanel>() {
86.183 -
86.184 - @Override
86.185 - public Void initialize() {
86.186 - return null;
86.187 - }
86.188 -
86.189 - @Override
86.190 - public AbstractHintsPanel createComponent(CustomizerContext<Void, AbstractHintsPanel> context) {
86.191 - return AbstractAnalyzer.createComponent(ModernizeErrorProvider.getInstance());
86.192 - }
86.193 - };
86.194 - }
86.195 -
86.196 - @Override
86.197 - public Collection<? extends MissingPlugin> requiredPlugins(Context context) {
86.198 -// ExecutionEnvironment env = detectEnvironment(context);
86.199 -// if (env == null) {
86.200 -// env = ExecutionEnvironmentFactory.getLocal();
86.201 -// }
86.202 - String installedTool = ClangAnalyzerOptions.getClangAnalyzerPath();
86.203 - if (installedTool == null || !new File(installedTool).exists()) {
86.204 - String codeBase = ClangAnalyzerOptions.getMissingModuleName();
86.205 - if (codeBase != null) {
86.206 - return Arrays.asList(new MissingPlugin(codeBase, NbBundle.getMessage(ModernizeAnalyzerImpl.class, "Modernize_NAME"))); //NOI18N
86.207 - }
86.208 - }
86.209 - return Collections.emptyList();
86.210 - }
86.211 -
86.212 - @Override
86.213 - public Analyzer createAnalyzer(Context context) {
86.214 - return new ModernizeAnalyzerImpl(context);
86.215 - }
86.216 - }
86.217 -}
87.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeCodeAudit.java Wed Jun 07 18:50:35 2017 +0300
87.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
87.3 @@ -1,120 +0,0 @@
87.4 -/*
87.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
87.6 - *
87.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
87.8 - *
87.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
87.10 - * Other names may be trademarks of their respective owners.
87.11 - *
87.12 - * The contents of this file are subject to the terms of either the GNU
87.13 - * General Public License Version 2 only ("GPL") or the Common
87.14 - * Development and Distribution License("CDDL") (collectively, the
87.15 - * "License"). You may not use this file except in compliance with the
87.16 - * License. You can obtain a copy of the License at
87.17 - * http://www.netbeans.org/cddl-gplv2.html
87.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
87.19 - * specific language governing permissions and limitations under the
87.20 - * License. When distributing the software, include this License Header
87.21 - * Notice in each file and include the License file at
87.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
87.23 - * particular file as subject to the "Classpath" exception as provided
87.24 - * by Oracle in the GPL Version 2 section of the License file that
87.25 - * accompanied this code. If applicable, add the following below the
87.26 - * License Header, with the fields enclosed by brackets [] replaced by
87.27 - * your own identifying information:
87.28 - * "Portions Copyrighted [year] [name of copyright owner]"
87.29 - *
87.30 - * If you wish your version of this file to be governed by only the CDDL
87.31 - * or only the GPL Version 2, indicate your decision by adding
87.32 - * "[Contributor] elects to include this software in this distribution
87.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
87.34 - * single choice of license, a recipient has the option to distribute
87.35 - * your version of this file under either the CDDL, the GPL Version 2 or
87.36 - * to extend the choice of license to its licensees as provided above.
87.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
87.38 - * Version 2 license, then the option applies only if the new code is
87.39 - * made subject to such option by the copyright holder.
87.40 - *
87.41 - * Contributor(s): Ilia Gromov
87.42 - */
87.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
87.44 -
87.45 -import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit;
87.46 -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
87.47 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
87.48 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
87.49 -
87.50 -final class ModernizeCodeAudit extends AbstractCodeAudit {
87.51 -
87.52 - private final String id;
87.53 - private final String name;
87.54 - private final String description;
87.55 - private final String defaultSeverity;
87.56 - private final boolean defaultEnabled;
87.57 - private final AuditPreferences myPreferences;
87.58 -
87.59 - public ModernizeCodeAudit(String id, String name, String description, String defaultSeverity, boolean defaultEnabled, AuditPreferences myPreferences) {
87.60 - super(id, name, description, defaultSeverity, defaultEnabled, myPreferences);
87.61 - this.id = id;
87.62 - this.name = name;
87.63 - this.description = description;
87.64 - this.defaultSeverity = defaultSeverity;
87.65 - this.defaultEnabled = defaultEnabled;
87.66 - this.myPreferences = myPreferences;
87.67 - }
87.68 -
87.69 - @Override
87.70 - public String getID() {
87.71 - return id;
87.72 - }
87.73 -
87.74 - @Override
87.75 - public String getName() {
87.76 - return name;
87.77 - }
87.78 -
87.79 - @Override
87.80 - public String getDescription() {
87.81 - return description;
87.82 - }
87.83 -
87.84 - public static CsmErrorInfo.Severity toSeverity(String severity) {
87.85 - if ("error".equals(severity)) { // NOI18N
87.86 - return CsmErrorInfo.Severity.ERROR;
87.87 - } else if ("warning".equals(severity)) { // NOI18N
87.88 - return CsmErrorInfo.Severity.WARNING;
87.89 - } else {
87.90 - return CsmErrorInfo.Severity.HINT;
87.91 - }
87.92 - }
87.93 -
87.94 - @Override
87.95 - public String getKind() {
87.96 - return "inspection"; //NOI18N
87.97 - }
87.98 -
87.99 - @Override
87.100 - public AuditPreferences getPreferences() {
87.101 - return myPreferences;
87.102 - }
87.103 -
87.104 - @Override
87.105 - public boolean getDefaultEnabled() {
87.106 - return defaultEnabled;
87.107 - }
87.108 -
87.109 - @Override
87.110 - public String getDefaultSeverity() {
87.111 - return defaultSeverity;
87.112 - }
87.113 -
87.114 - @Override
87.115 - public boolean isSupportedEvent(CsmErrorProvider.EditorEvent kind) {
87.116 - return true;
87.117 - }
87.118 -
87.119 - @Override
87.120 - public void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
87.121 - throw new UnsupportedOperationException("Not supported yet."); //NOI18N
87.122 - }
87.123 -}
88.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorInfo.java Wed Jun 07 18:50:35 2017 +0300
88.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
88.3 @@ -1,141 +0,0 @@
88.4 -/*
88.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
88.6 - *
88.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
88.8 - *
88.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
88.10 - * Other names may be trademarks of their respective owners.
88.11 - *
88.12 - * The contents of this file are subject to the terms of either the GNU
88.13 - * General Public License Version 2 only ("GPL") or the Common
88.14 - * Development and Distribution License("CDDL") (collectively, the
88.15 - * "License"). You may not use this file except in compliance with the
88.16 - * License. You can obtain a copy of the License at
88.17 - * http://www.netbeans.org/cddl-gplv2.html
88.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
88.19 - * specific language governing permissions and limitations under the
88.20 - * License. When distributing the software, include this License Header
88.21 - * Notice in each file and include the License file at
88.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
88.23 - * particular file as subject to the "Classpath" exception as provided
88.24 - * by Oracle in the GPL Version 2 section of the License file that
88.25 - * accompanied this code. If applicable, add the following below the
88.26 - * License Header, with the fields enclosed by brackets [] replaced by
88.27 - * your own identifying information:
88.28 - * "Portions Copyrighted [year] [name of copyright owner]"
88.29 - *
88.30 - * If you wish your version of this file to be governed by only the CDDL
88.31 - * or only the GPL Version 2, indicate your decision by adding
88.32 - * "[Contributor] elects to include this software in this distribution
88.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
88.34 - * single choice of license, a recipient has the option to distribute
88.35 - * your version of this file under either the CDDL, the GPL Version 2 or
88.36 - * to extend the choice of license to its licensees as provided above.
88.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
88.38 - * Version 2 license, then the option applies only if the new code is
88.39 - * made subject to such option by the copyright holder.
88.40 - *
88.41 - * Contributor(s): Ilia Gromov
88.42 - */
88.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
88.44 -
88.45 -import java.util.Objects;
88.46 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
88.47 -import org.netbeans.modules.cnd.api.project.NativeProject;
88.48 -import org.openide.util.Lookup;
88.49 -
88.50 -public class ModernizeErrorInfo implements CsmErrorInfo, ModernizeErrorProvider.ErrorInfoWithId {
88.51 -
88.52 - private final YamlParser.Diagnostics diag;
88.53 - private final String message;
88.54 - private final NativeProject project;
88.55 -
88.56 - private final int startOffset;
88.57 - private final int endOffset;
88.58 -
88.59 - public ModernizeErrorInfo(YamlParser.Diagnostics diag, String message, Lookup.Provider project) {
88.60 - this.diag = diag;
88.61 - this.message = message;
88.62 - this.project = project.getLookup().lookup(NativeProject.class);
88.63 -
88.64 - if (diag.getReplacements().isEmpty()) {
88.65 - startOffset = diag.getMessageFileOffset();
88.66 - endOffset = diag.getMessageFileOffset();
88.67 - } else {
88.68 - YamlParser.Replacement first = diag.getReplacements().get(0);
88.69 - startOffset = first.offset;
88.70 - endOffset = first.offset + first.length;
88.71 - }
88.72 - }
88.73 -
88.74 - public NativeProject getProject() {
88.75 - return project;
88.76 - }
88.77 -
88.78 - @Override
88.79 - public String getMessage() {
88.80 - return message;
88.81 - }
88.82 -
88.83 - @Override
88.84 - public Severity getSeverity() {
88.85 - return Severity.valueOf(diag.getLevel().toString().toUpperCase());
88.86 - }
88.87 -
88.88 - @Override
88.89 - public int getStartOffset() {
88.90 - return startOffset;
88.91 - }
88.92 -
88.93 - @Override
88.94 - public int getEndOffset() {
88.95 - return endOffset;
88.96 - }
88.97 -
88.98 - public YamlParser.Diagnostics getDiagnostics() {
88.99 - return diag;
88.100 - }
88.101 -
88.102 - @Override
88.103 - public String getId() {
88.104 - return diag.getCheckName();
88.105 - }
88.106 -
88.107 - public boolean isNeedConfigureHint() {
88.108 - return true;
88.109 - }
88.110 -
88.111 - @Override
88.112 - public int hashCode() {
88.113 - int hash = 3;
88.114 - hash = 19 * hash + this.diag.getCheckName().hashCode();
88.115 - hash = 19 * hash + this.startOffset;
88.116 - hash = 19 * hash + this.endOffset;
88.117 - return hash;
88.118 - }
88.119 -
88.120 - @Override
88.121 - public boolean equals(Object obj) {
88.122 - if (this == obj) {
88.123 - return true;
88.124 - }
88.125 - if (obj == null) {
88.126 - return false;
88.127 - }
88.128 - if (getClass() != obj.getClass()) {
88.129 - return false;
88.130 - }
88.131 - final ModernizeErrorInfo other = (ModernizeErrorInfo) obj;
88.132 - if (this.startOffset != other.startOffset) {
88.133 - return false;
88.134 - }
88.135 - if (this.endOffset != other.endOffset) {
88.136 - return false;
88.137 - }
88.138 - if (!(this.diag.getCheckName().equals(other.diag.getCheckName()))) {
88.139 - return false;
88.140 - }
88.141 - return true;
88.142 - }
88.143 -
88.144 -}
89.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorProvider.java Wed Jun 07 18:50:35 2017 +0300
89.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
89.3 @@ -1,422 +0,0 @@
89.4 -/*
89.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
89.6 - *
89.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
89.8 - *
89.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
89.10 - * Other names may be trademarks of their respective owners.
89.11 - *
89.12 - * The contents of this file are subject to the terms of either the GNU
89.13 - * General Public License Version 2 only ("GPL") or the Common
89.14 - * Development and Distribution License("CDDL") (collectively, the
89.15 - * "License"). You may not use this file except in compliance with the
89.16 - * License. You can obtain a copy of the License at
89.17 - * http://www.netbeans.org/cddl-gplv2.html
89.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
89.19 - * specific language governing permissions and limitations under the
89.20 - * License. When distributing the software, include this License Header
89.21 - * Notice in each file and include the License file at
89.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
89.23 - * particular file as subject to the "Classpath" exception as provided
89.24 - * by Oracle in the GPL Version 2 section of the License file that
89.25 - * accompanied this code. If applicable, add the following below the
89.26 - * License Header, with the fields enclosed by brackets [] replaced by
89.27 - * your own identifying information:
89.28 - * "Portions Copyrighted [year] [name of copyright owner]"
89.29 - *
89.30 - * If you wish your version of this file to be governed by only the CDDL
89.31 - * or only the GPL Version 2, indicate your decision by adding
89.32 - * "[Contributor] elects to include this software in this distribution
89.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
89.34 - * single choice of license, a recipient has the option to distribute
89.35 - * your version of this file under either the CDDL, the GPL Version 2 or
89.36 - * to extend the choice of license to its licensees as provided above.
89.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
89.38 - * Version 2 license, then the option applies only if the new code is
89.39 - * made subject to such option by the copyright holder.
89.40 - *
89.41 - * Contributor(s): Ilia Gromov
89.42 - */
89.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
89.44 -
89.45 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl.ResponseImpl;
89.46 -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser.Replacement;
89.47 -import org.netbeans.modules.ide.analysis.modernize.options.AnalyzerPreferences;
89.48 -import org.netbeans.modules.ide.analysis.modernize.options.ClangAnalyzerOptions;
89.49 -import static org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools.fatalError;
89.50 -import static org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools.findItem;
89.51 -import java.io.File;
89.52 -import java.io.IOException;
89.53 -import java.util.ArrayList;
89.54 -import java.util.Collection;
89.55 -import java.util.Collections;
89.56 -import java.util.List;
89.57 -import java.util.logging.Level;
89.58 -import java.util.logging.Logger;
89.59 -import java.util.prefs.Preferences;
89.60 -import javax.swing.JComponent;
89.61 -import javax.swing.JLabel;
89.62 -import org.netbeans.modules.cnd.analysis.api.AbstractCustomizerProvider;
89.63 -import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse;
89.64 -import org.netbeans.modules.cnd.api.model.CsmFile;
89.65 -import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit;
89.66 -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
89.67 -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
89.68 -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditFactory;
89.69 -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditProvider;
89.70 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
89.71 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo.Severity;
89.72 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfoHintProvider;
89.73 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
89.74 -import org.netbeans.modules.cnd.api.project.NativeFileItem.Language;
89.75 -import org.netbeans.modules.cnd.api.project.NativeProject;
89.76 -import org.netbeans.modules.cnd.api.remote.RemoteProject;
89.77 -import org.netbeans.modules.cnd.makeproject.api.MakeProject;
89.78 -import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
89.79 -import org.netbeans.modules.cnd.modelutil.CsmUtilities;
89.80 -import org.netbeans.modules.cnd.utils.MIMENames;
89.81 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
89.82 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
89.83 -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
89.84 -import org.netbeans.spi.editor.hints.Fix;
89.85 -import org.openide.awt.Actions;
89.86 -import org.openide.filesystems.FileObject;
89.87 -import org.openide.filesystems.FileUtil;
89.88 -import org.openide.util.Exceptions;
89.89 -import org.openide.util.Lookup;
89.90 -import org.openide.util.NbBundle;
89.91 -import org.openide.util.lookup.ServiceProvider;
89.92 -import org.openide.util.lookup.ServiceProviders;
89.93 -
89.94 -@ServiceProviders({
89.95 - @ServiceProvider(service = CsmErrorProvider.class, position = 2100)
89.96 - ,
89.97 - @ServiceProvider(service = CodeAuditProvider.class, position = 2100)
89.98 -})
89.99 -public final class ModernizeErrorProvider extends CsmErrorProvider implements CodeAuditProvider, AbstractCustomizerProvider {
89.100 -
89.101 - public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N
89.102 - private Collection<CodeAudit> audits;
89.103 - public static final String NAME = "Modernize"; //NOI18N
89.104 -
89.105 - public static ModernizeErrorProvider getInstance() {
89.106 - for (CsmErrorProvider provider : Lookup.getDefault().lookupAll(CsmErrorProvider.class)) {
89.107 - if (NAME.equals(provider.getName()) && provider instanceof ModernizeErrorProvider) {
89.108 - return (ModernizeErrorProvider) provider;
89.109 - }
89.110 - }
89.111 - return null;
89.112 - }
89.113 -
89.114 - @Override
89.115 - protected boolean validate(Request request) {
89.116 - CsmFile file = request.getFile();
89.117 - return file != null;
89.118 - }
89.119 -
89.120 - @Override
89.121 - public boolean hasHintControlPanel() {
89.122 - return true;
89.123 - }
89.124 -
89.125 - @Override
89.126 - public String getName() {
89.127 - return NAME;
89.128 - }
89.129 -
89.130 - @Override
89.131 - public String getDisplayName() {
89.132 - return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"); //NOI18N
89.133 - }
89.134 -
89.135 - @Override
89.136 - public String getDescription() {
89.137 - return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_DESCRIPTION"); //NOI18N
89.138 - }
89.139 -
89.140 - @Override
89.141 - public String getMimeType() {
89.142 - return MIMENames.SOURCES_MIME_TYPE;
89.143 - }
89.144 -
89.145 - @Override
89.146 - public boolean isSupportedEvent(EditorEvent kind) {
89.147 - return kind == EditorEvent.FileBased;
89.148 - }
89.149 -
89.150 - @Override
89.151 - protected void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
89.152 - CsmFile file = request.getFile();
89.153 - if (file != null) {
89.154 - if (request.isCancelled()) {
89.155 - return;
89.156 - }
89.157 - Object platformProject = file.getProject().getPlatformProject();
89.158 - if (platformProject instanceof NativeProject) {
89.159 - Lookup.Provider project = ((NativeProject) platformProject).getProject();
89.160 - if (project != null) {
89.161 - if (request.isCancelled()) {
89.162 - return;
89.163 - }
89.164 - Thread currentThread = Thread.currentThread();
89.165 - currentThread.setName("Provider " + getName() + " prosess " + file.getAbsolutePath()); // NOI18N
89.166 - RemoteProject info = project.getLookup().lookup(RemoteProject.class);
89.167 - if (info != null) {
89.168 - ExecutionEnvironment execEnv = info.getDevelopmentHost();
89.169 - if (execEnv != null) {
89.170 - if (request.isCancelled()) {
89.171 - return;
89.172 - }
89.173 - if (ConnectionManager.getInstance().isConnectedTo(execEnv)) {
89.174 - Item item = findItem(file, project);
89.175 - if (item != null) {
89.176 - if (request.isCancelled()) {
89.177 - return;
89.178 - }
89.179 - // Temporarily analyzing even excluded items
89.180 - if (/* !item.isExcluded() && */(item.getLanguage() == Language.C || item.getLanguage() == Language.CPP || item.getLanguage() == Language.C_HEADER)) {
89.181 - analyze(execEnv, item, project, request, response);
89.182 - }
89.183 - }
89.184 - }
89.185 - }
89.186 - }
89.187 - }
89.188 - }
89.189 - }
89.190 - }
89.191 -
89.192 - public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
89.193 - String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath();
89.194 - boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ResponseImpl;
89.195 - if (binaryPath == null) {
89.196 - Level level = isAnalyzer ? Level.INFO : Level.FINE;
89.197 - LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N
89.198 - return;
89.199 - }
89.200 -
89.201 - if (isAnalyzer && isNewRun()) {
89.202 - AnalyzedFiles.getDefault().clear();
89.203 - }
89.204 -
89.205 - DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath);
89.206 - try {
89.207 - CsmFile csmFile = request.getFile();
89.208 - Collection<String> checks = /*isAnalyzer ? Collections.singleton("*") : */ getEnabledChecks(); //NOI18N
89.209 -
89.210 - Collection<CsmFile> tu = new ArrayList<CsmFile>();
89.211 - if (isAnalyzer) {
89.212 - tu.add(csmFile);
89.213 - } else {
89.214 - if (AnalyzedFiles.getDefault().isStartFile(csmFile)) {
89.215 - tu.add(csmFile);
89.216 - } else {
89.217 - tu.addAll(AnalyzedFiles.getDefault().getStartFiles(csmFile));
89.218 - }
89.219 - }
89.220 -
89.221 - if (!isAnalyzer) {
89.222 - response = new ResponseMerger(response);
89.223 - }
89.224 -
89.225 - for (CsmFile startFile : tu) {
89.226 - int exitCode = diagnosticsTool.process(checks, startFile, true);
89.227 - if (exitCode != DiagnosticsTool.STATUS_OK) {
89.228 - String error = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error"); //NOI18N
89.229 - String info = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error.info", "" + exitCode); //NOI18N
89.230 - fatalError(AnalyzerResponse.AnalyzerSeverity.FileError, "fatal.analyze.error", error + "\n" + info, csmFile, response); //NOI18N
89.231 - return;
89.232 - }
89.233 - List<YamlParser.Diagnostics> results = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString());
89.234 - postProcess(isAnalyzer, startFile, project, results, request, response);
89.235 - }
89.236 -
89.237 - if (!isAnalyzer) {
89.238 - response.done();
89.239 - }
89.240 -
89.241 - } catch (ConnectionManager.CancellationException ex) {
89.242 - Exceptions.printStackTrace(ex);
89.243 - } catch (IOException ex) {
89.244 - Exceptions.printStackTrace(ex);
89.245 - }
89.246 - }
89.247 -
89.248 - private static CsmErrorProvider last;
89.249 -
89.250 - private boolean isNewRun() {
89.251 - if (last == null || this != last) {
89.252 - last = this;
89.253 - return true;
89.254 - }
89.255 - return false;
89.256 - }
89.257 -
89.258 - public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List<YamlParser.Diagnostics> results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
89.259 - CsmFile file = request.getFile();
89.260 - List<CsmFile> otherCsmFiles = new ArrayList<CsmFile>();
89.261 -
89.262 - for (YamlParser.Diagnostics diag : results) {
89.263 - // TODO: don't add "Configure Hint" fix multiple times for one line
89.264 - FileObject fo = FileUtil.toFileObject(new File(diag.getMessageFilePath()));
89.265 - CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false);
89.266 -
89.267 - // Composing a preview message. Showing a start file for compilation unit
89.268 - // in case we analysing a header file
89.269 - String message;
89.270 - if (startFile.equals(file) && csmFile.equals(file)) {
89.271 - message = String.format("[%s]: %s", diag.getCheckName(), diag.getMessage()); //NOI18N
89.272 - } else {
89.273 - message = String.format("[%s; %s]: %s", diag.getCheckName(), startFile.getName(), diag.getMessage()); //NOI18N
89.274 - }
89.275 -
89.276 - ModernizeErrorInfo info = new ModernizeErrorInfo(diag, message, project); //NOI18N
89.277 -
89.278 - if (isAnalyzer) {
89.279 - // Add found errors for all files (can be other files from compileUnit)
89.280 - ((ResponseImpl) response).addError(AnalyzerResponse.AnalyzerSeverity.DetectedError, null, fo, info);
89.281 -
89.282 - if (!csmFile.equals(file)) {
89.283 - // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... )
89.284 - otherCsmFiles.add(csmFile);
89.285 - }
89.286 - } else if (fo.equals(file.getFileObject())) {
89.287 - // Add found errors only for file displayed in Editor
89.288 - response.addError(info);
89.289 - }
89.290 - }
89.291 -
89.292 - if (isAnalyzer /* and not empty? */) {
89.293 - AnalyzedFiles.getDefault().cacheHierarchy(file, otherCsmFiles);
89.294 - }
89.295 - }
89.296 -
89.297 - @ServiceProvider(path = CodeAuditFactory.REGISTRATION_PATH + ModernizeErrorProvider.NAME, service = CodeAuditFactory.class, position = 4000)
89.298 - public static final class Factory implements CodeAuditFactory {
89.299 -
89.300 - @Override
89.301 - public AbstractCodeAudit create(AuditPreferences preferences) {
89.302 - String id = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderName"); // NOI18N
89.303 - String description = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderDescription"); // NOI18N
89.304 - return new ModernizeCodeAudit(id, id, description, "error", false, preferences); // NOI18N
89.305 - }
89.306 - }
89.307 -
89.308 - private String oldPath;
89.309 -
89.310 - @Override
89.311 - public synchronized Collection<CodeAudit> getAudits() {
89.312 - String path = ClangAnalyzerOptions.getClangAnalyzerPath();
89.313 -
89.314 - if (path == null) {
89.315 - return Collections.emptyList();
89.316 - }
89.317 -
89.318 - if (oldPath == null) {
89.319 - oldPath = path;
89.320 - }
89.321 -
89.322 - if (audits == null || !oldPath.equals(path)) {
89.323 - List<CodeAudit> res = DiagnosticsTool.getAudits(path, ExecutionEnvironmentFactory.getLocal(), AnalyzerPreferences.getAuditPreferences());
89.324 -
89.325 - audits = res;
89.326 - oldPath = path;
89.327 - }
89.328 - return audits;
89.329 - }
89.330 -
89.331 - public Collection<String> getEnabledChecks() {
89.332 - Collection<CodeAudit> auditList = getAudits();
89.333 - List<String> enabled = new ArrayList<String>();
89.334 - for (CodeAudit codeAudit : auditList) {
89.335 - if (codeAudit.isEnabled()) {
89.336 - enabled.add(codeAudit.getID());
89.337 - }
89.338 - }
89.339 - return enabled.size() == auditList.size() ? Collections.singleton("*") : enabled; //NOI18N
89.340 - }
89.341 -
89.342 - @Override
89.343 - public AuditPreferences getPreferences() {
89.344 - return AnalyzerPreferences.getAuditPreferences();
89.345 - }
89.346 -
89.347 - @Override
89.348 - public JComponent createComponent(Preferences context) {
89.349 - return new JLabel();
89.350 - }
89.351 -
89.352 - public static interface ErrorInfoWithId {
89.353 -
89.354 - String getId();
89.355 - }
89.356 -
89.357 - public static final class FatalErrorInfo implements CsmErrorInfo, ErrorInfoWithId {
89.358 -
89.359 - private final String id;
89.360 - private final String message;
89.361 -
89.362 - public FatalErrorInfo(String id, String message) {
89.363 - this.id = id;
89.364 - this.message = message;
89.365 - }
89.366 -
89.367 - @Override
89.368 - public String getMessage() {
89.369 - return message;
89.370 - }
89.371 -
89.372 - @Override
89.373 - public Severity getSeverity() {
89.374 - return Severity.WARNING;
89.375 - }
89.376 -
89.377 - @Override
89.378 - public int getStartOffset() {
89.379 - return 0;
89.380 - }
89.381 -
89.382 - @Override
89.383 - public int getEndOffset() {
89.384 - return 1;
89.385 - }
89.386 -
89.387 - @Override
89.388 - public String getId() {
89.389 - return id;
89.390 - }
89.391 - }
89.392 -
89.393 - @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 9100)
89.394 - public final static class ModerinzeHintProvider extends CsmErrorInfoHintProvider {
89.395 -
89.396 - @Override
89.397 - protected List<Fix> doGetFixes(CsmErrorInfo info, List<Fix> alreadyFound) {
89.398 - if (info instanceof ModernizeErrorInfo) {
89.399 - alreadyFound.add(new ConfigureHintsFix((ModernizeErrorInfo) info));
89.400 - }
89.401 - return alreadyFound;
89.402 - }
89.403 - }
89.404 -
89.405 - @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 1600)
89.406 - public static final class ModernizeFixProvider extends CsmErrorInfoHintProvider {
89.407 -
89.408 - @Override
89.409 - protected List<Fix> doGetFixes(CsmErrorInfo info, List<Fix> alreadyFound) {
89.410 - alreadyFound.addAll(createFixes(info));
89.411 - return alreadyFound;
89.412 - }
89.413 - }
89.414 -
89.415 - private static List<? extends Fix> createFixes(CsmErrorInfo info) {
89.416 - if (info instanceof ModernizeErrorInfo) {
89.417 - ModernizeErrorInfo mei = (ModernizeErrorInfo) info;
89.418 - List<Replacement> replacements = mei.getDiagnostics().getReplacements();
89.419 - if (!replacements.isEmpty()) {
89.420 - return Collections.singletonList(new ModernizeFix(replacements, mei.getId()));
89.421 - }
89.422 - }
89.423 - return Collections.EMPTY_LIST;
89.424 - }
89.425 -}
90.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeFix.java Wed Jun 07 18:50:35 2017 +0300
90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
90.3 @@ -1,133 +0,0 @@
90.4 -/*
90.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
90.6 - *
90.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
90.8 - *
90.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
90.10 - * Other names may be trademarks of their respective owners.
90.11 - *
90.12 - * The contents of this file are subject to the terms of either the GNU
90.13 - * General Public License Version 2 only ("GPL") or the Common
90.14 - * Development and Distribution License("CDDL") (collectively, the
90.15 - * "License"). You may not use this file except in compliance with the
90.16 - * License. You can obtain a copy of the License at
90.17 - * http://www.netbeans.org/cddl-gplv2.html
90.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
90.19 - * specific language governing permissions and limitations under the
90.20 - * License. When distributing the software, include this License Header
90.21 - * Notice in each file and include the License file at
90.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
90.23 - * particular file as subject to the "Classpath" exception as provided
90.24 - * by Oracle in the GPL Version 2 section of the License file that
90.25 - * accompanied this code. If applicable, add the following below the
90.26 - * License Header, with the fields enclosed by brackets [] replaced by
90.27 - * your own identifying information:
90.28 - * "Portions Copyrighted [year] [name of copyright owner]"
90.29 - *
90.30 - * If you wish your version of this file to be governed by only the CDDL
90.31 - * or only the GPL Version 2, indicate your decision by adding
90.32 - * "[Contributor] elects to include this software in this distribution
90.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
90.34 - * single choice of license, a recipient has the option to distribute
90.35 - * your version of this file under either the CDDL, the GPL Version 2 or
90.36 - * to extend the choice of license to its licensees as provided above.
90.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
90.38 - * Version 2 license, then the option applies only if the new code is
90.39 - * made subject to such option by the copyright holder.
90.40 - *
90.41 - * Contributor(s): Ilia Gromov
90.42 - */
90.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
90.44 -
90.45 -import java.io.File;
90.46 -import java.util.List;
90.47 -import javax.swing.text.Document;
90.48 -import javax.swing.text.Position;
90.49 -import org.netbeans.editor.BaseDocument;
90.50 -import org.netbeans.modules.cnd.api.model.CsmFile;
90.51 -import org.netbeans.modules.cnd.modelutil.CsmUtilities;
90.52 -import org.netbeans.spi.editor.hints.ChangeInfo;
90.53 -import org.netbeans.spi.editor.hints.EnhancedFix;
90.54 -import org.openide.filesystems.FileObject;
90.55 -import org.openide.filesystems.FileUtil;
90.56 -import org.openide.text.CloneableEditorSupport;
90.57 -import org.openide.text.PositionRef;
90.58 -
90.59 -/**
90.60 - *
90.61 - * @author Ilia Gromov
90.62 - */
90.63 -public class ModernizeFix implements EnhancedFix {
90.64 -
90.65 - private final YamlParser.Replacement[] replacements;
90.66 - private final String text;
90.67 - private CloneableEditorSupport ces;
90.68 - private final PositionRef[] beg;
90.69 - private final PositionRef[] end;
90.70 -
90.71 - public ModernizeFix(List<YamlParser.Replacement> replacementList, String id) {
90.72 - this.beg = new PositionRef[replacementList.size()];
90.73 - this.end = new PositionRef[replacementList.size()];
90.74 - this.replacements = replacementList.toArray(new YamlParser.Replacement[replacementList.size()]);
90.75 - this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N
90.76 - for (int i = 0; i < replacements.length; i++) {
90.77 - YamlParser.Replacement replacement = replacements[i];
90.78 - FileObject fo = FileUtil.toFileObject(new File(replacement.filePath));
90.79 - CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false);
90.80 - if (csmFile != null) {
90.81 - ces = CsmUtilities.findCloneableEditorSupport(csmFile);
90.82 - if (ces != null) {
90.83 - beg[i] = ces.createPositionRef(replacement.offset, Position.Bias.Forward);
90.84 - end[i] = ces.createPositionRef(replacement.offset + replacement.length, Position.Bias.Backward);
90.85 - } else {
90.86 - }
90.87 - }
90.88 - }
90.89 - } //NOI18N
90.90 -
90.91 - @Override
90.92 - public String getText() {
90.93 - return "Apply replacement - " + text; //NOI18N
90.94 - }
90.95 -
90.96 - @Override
90.97 - public ChangeInfo implement() throws Exception {
90.98 - Document doc = CsmUtilities.openDocument(ces);
90.99 - if (doc instanceof BaseDocument) {
90.100 - Position min = beg[0];
90.101 - Position max = end[0];
90.102 - for (int i = 0; i < replacements.length; i++) {
90.103 - YamlParser.Replacement replacement = replacements[i];
90.104 - PositionRef b = beg[i];
90.105 - PositionRef e = end[i];
90.106 - if (b != null && e != null) {
90.107 - int newBeg = b.getOffset();
90.108 - int newLength = e.getOffset() - b.getOffset();
90.109 - if (b.getOffset() < min.getOffset()) {
90.110 - min = b;
90.111 - }
90.112 - if (e.getOffset() > max.getOffset()) {
90.113 - max = e;
90.114 - }
90.115 - if (newLength < 1) {
90.116 - // TODO: temp fix
90.117 - newLength = 0;
90.118 - }
90.119 - ((BaseDocument) doc).replace(newBeg, newLength, replacement.replacementText, null);
90.120 - }
90.121 - }
90.122 - return new ChangeInfo(min, max);
90.123 - }
90.124 - return null;
90.125 - }
90.126 -
90.127 - @Override
90.128 - public CharSequence getSortText() {
90.129 - return Integer.toString(Integer.MIN_VALUE);
90.130 - }
90.131 -
90.132 - public YamlParser.Replacement[] getReplacements() {
90.133 - return replacements;
90.134 - }
90.135 -
90.136 -}
91.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ResponseMerger.java Wed Jun 07 18:50:35 2017 +0300
91.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
91.3 @@ -1,73 +0,0 @@
91.4 -/*
91.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
91.6 - *
91.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
91.8 - *
91.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
91.10 - * Other names may be trademarks of their respective owners.
91.11 - *
91.12 - * The contents of this file are subject to the terms of either the GNU
91.13 - * General Public License Version 2 only ("GPL") or the Common
91.14 - * Development and Distribution License("CDDL") (collectively, the
91.15 - * "License"). You may not use this file except in compliance with the
91.16 - * License. You can obtain a copy of the License at
91.17 - * http://www.netbeans.org/cddl-gplv2.html
91.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
91.19 - * specific language governing permissions and limitations under the
91.20 - * License. When distributing the software, include this License Header
91.21 - * Notice in each file and include the License file at
91.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
91.23 - * particular file as subject to the "Classpath" exception as provided
91.24 - * by Oracle in the GPL Version 2 section of the License file that
91.25 - * accompanied this code. If applicable, add the following below the
91.26 - * License Header, with the fields enclosed by brackets [] replaced by
91.27 - * your own identifying information:
91.28 - * "Portions Copyrighted [year] [name of copyright owner]"
91.29 - *
91.30 - * If you wish your version of this file to be governed by only the CDDL
91.31 - * or only the GPL Version 2, indicate your decision by adding
91.32 - * "[Contributor] elects to include this software in this distribution
91.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
91.34 - * single choice of license, a recipient has the option to distribute
91.35 - * your version of this file under either the CDDL, the GPL Version 2 or
91.36 - * to extend the choice of license to its licensees as provided above.
91.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
91.38 - * Version 2 license, then the option applies only if the new code is
91.39 - * made subject to such option by the copyright holder.
91.40 - *
91.41 - * Contributor(s): Ilia Gromov
91.42 - */
91.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
91.44 -
91.45 -import java.util.HashSet;
91.46 -import java.util.Set;
91.47 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
91.48 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
91.49 -
91.50 -/**
91.51 - *
91.52 - * @author Ilia Gromov
91.53 - */
91.54 -public class ResponseMerger implements CsmErrorProvider.Response {
91.55 -
91.56 - private final Set<CsmErrorInfo> bag = new HashSet<>();
91.57 - private final CsmErrorProvider.Response delegate;
91.58 -
91.59 - public ResponseMerger(CsmErrorProvider.Response delegate) {
91.60 - this.delegate = delegate;
91.61 - }
91.62 -
91.63 - @Override
91.64 - public void addError(CsmErrorInfo errorInfo) {
91.65 - bag.add(errorInfo);
91.66 - }
91.67 -
91.68 - @Override
91.69 - public void done() {
91.70 - for (CsmErrorInfo modernizeErrorInfo : bag) {
91.71 - delegate.addError(modernizeErrorInfo);
91.72 - }
91.73 - delegate.done();
91.74 - bag.clear();
91.75 - }
91.76 -}
92.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/YamlParser.java Wed Jun 07 18:50:35 2017 +0300
92.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
92.3 @@ -1,357 +0,0 @@
92.4 -/*
92.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
92.6 - *
92.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
92.8 - *
92.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
92.10 - * Other names may be trademarks of their respective owners.
92.11 - *
92.12 - * The contents of this file are subject to the terms of either the GNU
92.13 - * General Public License Version 2 only ("GPL") or the Common
92.14 - * Development and Distribution License("CDDL") (collectively, the
92.15 - * "License"). You may not use this file except in compliance with the
92.16 - * License. You can obtain a copy of the License at
92.17 - * http://www.netbeans.org/cddl-gplv2.html
92.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
92.19 - * specific language governing permissions and limitations under the
92.20 - * License. When distributing the software, include this License Header
92.21 - * Notice in each file and include the License file at
92.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
92.23 - * particular file as subject to the "Classpath" exception as provided
92.24 - * by Oracle in the GPL Version 2 section of the License file that
92.25 - * accompanied this code. If applicable, add the following below the
92.26 - * License Header, with the fields enclosed by brackets [] replaced by
92.27 - * your own identifying information:
92.28 - * "Portions Copyrighted [year] [name of copyright owner]"
92.29 - *
92.30 - * If you wish your version of this file to be governed by only the CDDL
92.31 - * or only the GPL Version 2, indicate your decision by adding
92.32 - * "[Contributor] elects to include this software in this distribution
92.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
92.34 - * single choice of license, a recipient has the option to distribute
92.35 - * your version of this file under either the CDDL, the GPL Version 2 or
92.36 - * to extend the choice of license to its licensees as provided above.
92.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
92.38 - * Version 2 license, then the option applies only if the new code is
92.39 - * made subject to such option by the copyright holder.
92.40 - *
92.41 - * Contributor(s): Ilia Gromov
92.42 - */
92.43 -package org.netbeans.modules.ide.analysis.modernize.impl;
92.44 -
92.45 -import static org.netbeans.modules.ide.analysis.modernize.impl.YamlParser.Diagnostics.UNDEFINED;
92.46 -import java.util.ArrayList;
92.47 -import java.util.Collections;
92.48 -import java.util.List;
92.49 -import java.util.StringTokenizer;
92.50 -import java.util.logging.Level;
92.51 -
92.52 -/**
92.53 - *
92.54 - * @author Ilia Gromov
92.55 - */
92.56 -public class YamlParser {
92.57 - // TODO check for no-replacements case
92.58 -
92.59 - private static final YamlParser INSTANCE = new YamlParser();
92.60 -
92.61 - public static YamlParser getDefault() {
92.62 - return INSTANCE;
92.63 - }
92.64 -
92.65 - private static final String OPEN_TAG = "---"; //NOI18N
92.66 - private static final String CLOSE_TAG = "..."; //NOI18N
92.67 -
92.68 - private static final String MAIN_SOURCE_FILE = "MainSourceFile"; //NOI18N
92.69 - private static final String CHECK_NAME = "CheckName"; //NOI18N
92.70 - private static final String LEVEL = "Level"; //NOI18N
92.71 - private static final String MESSAGE_FILE_PATH = "MessageFilePath"; //NOI18N
92.72 - private static final String MESSAGE_FILE_OFFSET = "MessageFileOffset"; //NOI18N
92.73 - private static final String MESSAGE = "Message"; //NOI18N
92.74 - private static final String REPLACEMENTS = "Replacements"; //NOI18N
92.75 - private static final String DIAGNOSTICS = "Diagnostics"; //NOI18N
92.76 -
92.77 - private static final String FILE_PATH = "FilePath"; //NOI18N
92.78 - private static final String OFFSET = "Offset"; //NOI18N
92.79 - private static final String LENGTH = "Length"; //NOI18N
92.80 - private static final String REPLACEMENT_TEXT = "ReplacementText"; //NOI18N
92.81 -
92.82 - // clang-modernize:
92.83 -// ---
92.84 -// MainSourceFile: /home/ilia/NetBeansProjects/CppApplication_46/main.cpp
92.85 -// Replacements:
92.86 -// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/newfile.h
92.87 -// Offset: 101
92.88 -// Length: 1
92.89 -// ReplacementText: nullptr
92.90 -// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/newfile1.h
92.91 -// Offset: 380
92.92 -// Length: 1
92.93 -// ReplacementText: nullptr
92.94 -// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/main.cpp
92.95 -// Offset: 152
92.96 -// Length: 1
92.97 -// ReplacementText: nullptr
92.98 -// ...
92.99 - // clang-tidy:
92.100 -// ---
92.101 -// MainSourceFile: ''
92.102 -// Diagnostics:
92.103 -// CheckName: misc-macro-parentheses
92.104 -// Replacements:
92.105 -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp
92.106 -// Offset: 1352
92.107 -// Length: 0
92.108 -// ReplacementText: '('
92.109 -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp
92.110 -// Offset: 1353
92.111 -// Length: 0
92.112 -// ReplacementText: ')'
92.113 -// Diagnostics:
92.114 -// CheckName: misc-macro-parentheses
92.115 -// Replacements:
92.116 -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp
92.117 -// Offset: 1446
92.118 -// Length: 0
92.119 -// ReplacementText: '('
92.120 -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp
92.121 -// Offset: 1447
92.122 -// Length: 0
92.123 -// ReplacementText: ')'
92.124 -// ...
92.125 - public List<Diagnostics> parseYaml(String output) {
92.126 - try {
92.127 - if (output.isEmpty()) {
92.128 - // No warnings in header = no 'Main Source File' element
92.129 - return Collections.EMPTY_LIST;
92.130 - }
92.131 - StringTokenizer st = new StringTokenizer(output, "\n"); //NOI18N
92.132 - String line;
92.133 -
92.134 - // ---
92.135 - line = st.nextToken();
92.136 -
92.137 - line = st.nextToken();
92.138 - String mainSourceFile = getValue(MAIN_SOURCE_FILE, line);
92.139 -
92.140 - // Replacements:
92.141 - line = st.nextToken();
92.142 - ClangTidyVersion version = line.contains(REPLACEMENTS)
92.143 - ? ClangTidyVersion.OLD_FORMAT
92.144 - : ClangTidyVersion.NEW_FORMAT;
92.145 -
92.146 - List<Diagnostics> list = version.parser.parse(st);
92.147 -
92.148 - return list;
92.149 - } catch (Exception ex) {
92.150 - ModernizeErrorProvider.LOG.log(Level.INFO, "Can't parse output line");
92.151 - return Collections.EMPTY_LIST;
92.152 - }
92.153 - }
92.154 -
92.155 - private static List<Replacement> parseReplacements(StringTokenizer st) {
92.156 - List<Replacement> replacements = new ArrayList<Replacement>();
92.157 - String line;
92.158 -
92.159 - // eat Replacements:
92.160 - line = st.nextToken();
92.161 -
92.162 - if (!line.contains(REPLACEMENTS)) {
92.163 - return replacements;
92.164 - }
92.165 -
92.166 - while (st.hasMoreTokens()) {
92.167 - line = st.nextToken();
92.168 -
92.169 - if (line.equals(CLOSE_TAG) || !line.contains(FILE_PATH)) {
92.170 - break;
92.171 - }
92.172 -
92.173 - String filePath = getValue(FILE_PATH, line);
92.174 -
92.175 - line = st.nextToken();
92.176 - int offset = Integer.parseInt(getValue(OFFSET, line));
92.177 -
92.178 - line = st.nextToken();
92.179 - int length = Integer.parseInt(getValue(LENGTH, line));
92.180 -
92.181 - line = st.nextToken();
92.182 - String replacementText = getValue(REPLACEMENT_TEXT, line);
92.183 - while (replacementText == null && st.hasMoreElements()) {
92.184 - line = line + "\n" + st.nextElement(); //NOI18N
92.185 - replacementText = getValue(REPLACEMENT_TEXT, line);
92.186 - }
92.187 -
92.188 - Replacement replacement = new Replacement(filePath, offset, length, replacementText);
92.189 - replacements.add(replacement);
92.190 -
92.191 - }
92.192 - return replacements;
92.193 - }
92.194 -
92.195 - private static String getValue(String key, String line) {
92.196 - int keyStart = line.indexOf(key);
92.197 - assert keyStart != -1;
92.198 - int keyEnd = keyStart + key.length() + 1;
92.199 - String trimmed = line.substring(keyEnd).trim();
92.200 - boolean isTextValue = trimmed.charAt(0) == '\'';
92.201 - if (isTextValue) {
92.202 - if (trimmed.length() == 1) {
92.203 - // '
92.204 - // abcd'
92.205 - return null;
92.206 - } else if (trimmed.charAt(trimmed.length() - 1) == '\'') {
92.207 - trimmed = trimmed.substring(1, trimmed.length() - 1);
92.208 - } else {
92.209 - return null;
92.210 - }
92.211 - }
92.212 - return trimmed;
92.213 - }
92.214 -
92.215 - public static class TranslationUnitDiagnostics {
92.216 -
92.217 - private final String mainSourceFilePath;
92.218 - private final String context;
92.219 - private final List<Diagnostics> diags;
92.220 -
92.221 - public TranslationUnitDiagnostics(String mainSourceFilePath, String context, List<Diagnostics> diags) {
92.222 - this.mainSourceFilePath = mainSourceFilePath;
92.223 - this.context = context;
92.224 - this.diags = diags;
92.225 - }
92.226 -
92.227 - public String getMainSourceFilePath() {
92.228 - return mainSourceFilePath;
92.229 - }
92.230 -
92.231 - public String getContext() {
92.232 - return context;
92.233 - }
92.234 -
92.235 - public List<Diagnostics> getDiags() {
92.236 - return diags;
92.237 - }
92.238 - }
92.239 -
92.240 - public static class Diagnostics {
92.241 -
92.242 - public static final String UNDEFINED = "undefined"; // NOI18N
92.243 -
92.244 - public enum Level {
92.245 - warning, error
92.246 - }
92.247 -
92.248 - private final String checkName;
92.249 - private final Diagnostics.Level level;
92.250 - private final String messageFilePath;
92.251 - private final int messageFileOffset;
92.252 - private final String message;
92.253 - private final List<Replacement> replacements;
92.254 -
92.255 - public Diagnostics(String checkName, Diagnostics.Level level, String messageFilePath, int messageFileOffset, String message, List<Replacement> replacements) {
92.256 - this.checkName = checkName;
92.257 - this.level = level;
92.258 - this.messageFilePath = messageFilePath;
92.259 - this.messageFileOffset = messageFileOffset;
92.260 - this.message = message;
92.261 - this.replacements = replacements;
92.262 - }
92.263 -
92.264 - public String getCheckName() {
92.265 - return checkName;
92.266 - }
92.267 -
92.268 - public Level getLevel() {
92.269 - return level;
92.270 - }
92.271 -
92.272 - public String getMessageFilePath() {
92.273 - return messageFilePath;
92.274 - }
92.275 -
92.276 - public int getMessageFileOffset() {
92.277 - return messageFileOffset;
92.278 - }
92.279 -
92.280 - public String getMessage() {
92.281 - return message;
92.282 - }
92.283 -
92.284 - public List<Replacement> getReplacements() {
92.285 - return replacements;
92.286 - }
92.287 - }
92.288 -
92.289 - public static class Replacement {
92.290 -
92.291 - public final String filePath;
92.292 - public final int offset;
92.293 - public final int length;
92.294 - public final String replacementText;
92.295 -
92.296 - public Replacement(String FilePath, int offset, int length, String replacementText) {
92.297 - this.filePath = FilePath;
92.298 - this.offset = offset;
92.299 - this.length = length;
92.300 - this.replacementText = replacementText;
92.301 - }
92.302 - }
92.303 -
92.304 - private static enum ClangTidyVersion {
92.305 - NEW_FORMAT(new NewFormatParser()),
92.306 - OLD_FORMAT(new OldFormatParser());
92.307 -
92.308 - public final TidyParser parser;
92.309 -
92.310 - private ClangTidyVersion(TidyParser parser) {
92.311 - this.parser = parser;
92.312 - }
92.313 - }
92.314 -
92.315 - private static abstract class TidyParser {
92.316 -
92.317 - abstract List<Diagnostics> parse(StringTokenizer st);
92.318 - }
92.319 -
92.320 - private static class NewFormatParser extends TidyParser {
92.321 -
92.322 - @Override
92.323 - public List<Diagnostics> parse(StringTokenizer st) {
92.324 - List<Diagnostics> list = new ArrayList<Diagnostics>();
92.325 -
92.326 - String line;
92.327 - while (st.hasMoreElements()) {
92.328 - line = st.nextToken();
92.329 - String checkName = getValue(CHECK_NAME, line);
92.330 -
92.331 - line = st.nextToken();
92.332 - Diagnostics.Level level = Diagnostics.Level.valueOf(getValue(LEVEL, line).toLowerCase());
92.333 -
92.334 - line = st.nextToken();
92.335 - String messageFilePath = getValue(MESSAGE_FILE_PATH, line);
92.336 -
92.337 - line = st.nextToken();
92.338 - int messageFileOffset = Integer.parseInt(getValue(MESSAGE_FILE_OFFSET, line));
92.339 -
92.340 - line = st.nextToken();
92.341 - String message = getValue(MESSAGE, line);
92.342 -
92.343 - List<Replacement> replacements = parseReplacements(st);
92.344 -
92.345 - list.add(new Diagnostics(checkName, level, messageFilePath, messageFileOffset, message, replacements));
92.346 - }
92.347 - return list;
92.348 - }
92.349 -
92.350 - }
92.351 -
92.352 - private static class OldFormatParser extends TidyParser {
92.353 -
92.354 - @Override
92.355 - public List<Diagnostics> parse(StringTokenizer st) {
92.356 - List<Replacement> parseReplacements = parseReplacements(st);
92.357 - return Collections.singletonList(new Diagnostics(UNDEFINED, Diagnostics.Level.warning, "", -1, "", parseReplacements)); //NOI18N
92.358 - }
92.359 - }
92.360 -}
93.1 Binary file ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/bugs.png has changed
94.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/layer.xml Wed Jun 07 18:50:35 2017 +0300
94.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
94.3 @@ -1,75 +0,0 @@
94.4 -<?xml version="1.0" encoding="UTF-8"?>
94.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
94.6 -<filesystem>
94.7 - <folder name="Analysis">
94.8 - <folder name="Clang-Tidy">
94.9 - <folder name="Disabled_Default">
94.10 - <file name="misc-unused-parameters">
94.11 - <![CDATA[False positive activation]]>
94.12 - </file>
94.13 - <file name="misc-unused-parameters">
94.14 - <![CDATA[False positive activation]]>
94.15 - </file>
94.16 - <file name="google-runtime-int">
94.17 - <![CDATA[Too much warnings]]>
94.18 - </file>
94.19 - <file name="modernize-use-nullptr">
94.20 - <![CDATA[Too much warnings]]>
94.21 - </file>
94.22 - <file name="modernize-use-default">
94.23 - <![CDATA[Too much warnings]]>
94.24 - </file>
94.25 - <file name="google-runtime-references">
94.26 - <![CDATA[Too much warnings]]>
94.27 - </file>
94.28 - <file name="modernize-redundant-void-arg">
94.29 - <![CDATA[Too much warnings]]>
94.30 - </file>
94.31 - <file name="readability-implicit-bool-cast">
94.32 - <![CDATA[Too much warnings]]>
94.33 - </file>
94.34 - <file name="cppcoreguidelines-pro-bounds-pointer-arithmetic">
94.35 - <![CDATA[Too much warnings]]>
94.36 - </file>
94.37 - <file name="google-readability-casting">
94.38 - <![CDATA[Too much warnings]]>
94.39 - </file>
94.40 - <file name="misc-macro-parentheses">
94.41 - <![CDATA[Too much warnings]]>
94.42 - </file>
94.43 -
94.44 - <file name="google-readability-braces-around-statements">
94.45 - <![CDATA[Project-specific readability check]]>
94.46 - </file>
94.47 - <file name="readability-named-parameter">
94.48 - <![CDATA[Project-specific readability check]]>
94.49 - </file>
94.50 - <file name="llvm-header-guard">
94.51 - <![CDATA[Project-specific readability check]]>
94.52 - </file>
94.53 - <file name="google-readability-casting">
94.54 - <![CDATA[Project-specific readability check]]>
94.55 - </file>
94.56 - <file name="google-readability-namespace-comments">
94.57 - <![CDATA[Project-specific readability check]]>
94.58 - </file>
94.59 - <file name="readability-braces-around-statements">
94.60 - <![CDATA[Project-specific readability check]]>
94.61 - </file>
94.62 - <file name="llvm-include-order">
94.63 - <![CDATA[Project-specific readability check]]>
94.64 - </file>
94.65 - <file name="readability-else-after-return">
94.66 - <![CDATA[Project-specific readability check]]>
94.67 - </file>
94.68 - <file name="cppcoreguidelines-pro-type-union-access">
94.69 - <![CDATA[Requires specific library]]>
94.70 - </file>
94.71 - </folder>
94.72 - <folder name="Strict_Checks">
94.73 - <file name="readability-inconsistent-declaration-parameter-name"></file>
94.74 - <file name="misc-unused-using-decls"></file>
94.75 - </folder>
94.76 - </folder>
94.77 - </folder>
94.78 -</filesystem>
95.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/AnalyzerPreferences.java Wed Jun 07 18:50:35 2017 +0300
95.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
95.3 @@ -1,66 +0,0 @@
95.4 -/*
95.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
95.6 - *
95.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
95.8 - *
95.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
95.10 - * Other names may be trademarks of their respective owners.
95.11 - *
95.12 - * The contents of this file are subject to the terms of either the GNU
95.13 - * General Public License Version 2 only ("GPL") or the Common
95.14 - * Development and Distribution License("CDDL") (collectively, the
95.15 - * "License"). You may not use this file except in compliance with the
95.16 - * License. You can obtain a copy of the License at
95.17 - * http://www.netbeans.org/cddl-gplv2.html
95.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
95.19 - * specific language governing permissions and limitations under the
95.20 - * License. When distributing the software, include this License Header
95.21 - * Notice in each file and include the License file at
95.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
95.23 - * particular file as subject to the "Classpath" exception as provided
95.24 - * by Oracle in the GPL Version 2 section of the License file that
95.25 - * accompanied this code. If applicable, add the following below the
95.26 - * License Header, with the fields enclosed by brackets [] replaced by
95.27 - * your own identifying information:
95.28 - * "Portions Copyrighted [year] [name of copyright owner]"
95.29 - *
95.30 - * If you wish your version of this file to be governed by only the CDDL
95.31 - * or only the GPL Version 2, indicate your decision by adding
95.32 - * "[Contributor] elects to include this software in this distribution
95.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
95.34 - * single choice of license, a recipient has the option to distribute
95.35 - * your version of this file under either the CDDL, the GPL Version 2 or
95.36 - * to extend the choice of license to its licensees as provided above.
95.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
95.38 - * Version 2 license, then the option applies only if the new code is
95.39 - * made subject to such option by the copyright holder.
95.40 - *
95.41 - * Contributor(s): Ilia Gromov
95.42 - */
95.43 -
95.44 -package org.netbeans.modules.ide.analysis.modernize.options;
95.45 -
95.46 -import java.util.prefs.Preferences;
95.47 -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
95.48 -
95.49 -/**
95.50 - *
95.51 - * @author Ilia Gromov
95.52 - */
95.53 -public class AnalyzerPreferences {
95.54 -
95.55 - private static final String NODE_NAME = "clang-tidy"; //NOI18N
95.56 -
95.57 - public static AuditPreferences getAuditPreferences() {
95.58 - return Holder.PREFS;
95.59 - }
95.60 -
95.61 - public static Preferences getPreferences() {
95.62 - return Holder.PREFS.getPreferences();
95.63 - }
95.64 -
95.65 - private static final class Holder {
95.66 -
95.67 - static final AuditPreferences PREFS = new AuditPreferences(AuditPreferences.AUDIT_PREFERENCES_ROOT.node(NODE_NAME));
95.68 - }
95.69 -}
96.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/Bundle.properties Wed Jun 07 18:50:35 2017 +0300
96.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
96.3 @@ -1,15 +0,0 @@
96.4 -PreviseOptions.confidenceLabel.text=&Confidence:
96.5 -
96.6 -SURE_CONFIDENCE=Sure
96.7 -HIGH_CONFIDENCE=High
96.8 -MEDIUM_CONFIDENCE=Medium
96.9 -LOW_CONFIDENCE=Low
96.10 -Parfait.tool.collection=
96.11 -ParfaitOptions.pathToParfait.notfound=Not Found
96.12 -ParfaitOptions.browse.text=...
96.13 -SELECT_TOOL_TITLE=Select Clang Binary Folder
96.14 -ParfaitOptions.connect.text=Connect to host {0}
96.15 -Parfait.tool.collection_1=clang-tidy
96.16 -ModernizeOptions.browseButton.text=...
96.17 -ModernizeOptions.jLabel2.text=build host
96.18 -ModernizeOptions.pathToAnalyzer.text=
97.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/ClangAnalyzerOptions.java Wed Jun 07 18:50:35 2017 +0300
97.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
97.3 @@ -1,169 +0,0 @@
97.4 -/*
97.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
97.6 - *
97.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
97.8 - *
97.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
97.10 - * Other names may be trademarks of their respective owners.
97.11 - *
97.12 - * The contents of this file are subject to the terms of either the GNU
97.13 - * General Public License Version 2 only ("GPL") or the Common
97.14 - * Development and Distribution License("CDDL") (collectively, the
97.15 - * "License"). You may not use this file except in compliance with the
97.16 - * License. You can obtain a copy of the License at
97.17 - * http://www.netbeans.org/cddl-gplv2.html
97.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
97.19 - * specific language governing permissions and limitations under the
97.20 - * License. When distributing the software, include this License Header
97.21 - * Notice in each file and include the License file at
97.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
97.23 - * particular file as subject to the "Classpath" exception as provided
97.24 - * by Oracle in the GPL Version 2 section of the License file that
97.25 - * accompanied this code. If applicable, add the following below the
97.26 - * License Header, with the fields enclosed by brackets [] replaced by
97.27 - * your own identifying information:
97.28 - * "Portions Copyrighted [year] [name of copyright owner]"
97.29 - *
97.30 - * If you wish your version of this file to be governed by only the CDDL
97.31 - * or only the GPL Version 2, indicate your decision by adding
97.32 - * "[Contributor] elects to include this software in this distribution
97.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
97.34 - * single choice of license, a recipient has the option to distribute
97.35 - * your version of this file under either the CDDL, the GPL Version 2 or
97.36 - * to extend the choice of license to its licensees as provided above.
97.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
97.38 - * Version 2 license, then the option applies only if the new code is
97.39 - * made subject to such option by the copyright holder.
97.40 - *
97.41 - * Contributor(s): Ilia Gromov
97.42 - */
97.43 -
97.44 -package org.netbeans.modules.ide.analysis.modernize.options;
97.45 -
97.46 -import java.io.File;
97.47 -import java.io.IOException;
97.48 -import java.util.Collections;
97.49 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
97.50 -import org.netbeans.modules.nativeexecution.api.HostInfo;
97.51 -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
97.52 -import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
97.53 -import org.openide.modules.InstalledFileLocator;
97.54 -
97.55 -/**
97.56 - *
97.57 - * @author Ilia Gromov
97.58 - */
97.59 -public class ClangAnalyzerOptions {
97.60 -
97.61 - public static final String CLANG_BINARY_NAME = "clang-tidy"; //NOI18N
97.62 - public static final String CLANG_BINARY_PATH = "clang-tidy-path"; //NOI18N
97.63 -
97.64 - private static String findInPaths() {
97.65 - String binaryName = CLANG_BINARY_NAME + "-" + getCodeBase(); //NOI18N
97.66 - String result = HostInfoUtils.searchFile(ExecutionEnvironmentFactory.getLocal(), Collections.<String>emptyList(), binaryName, true); // NOI18N
97.67 - return result;
97.68 - }
97.69 -
97.70 - public static String getClangAnalyzerPath() {
97.71 - String result = AnalyzerPreferences.getPreferences().get(CLANG_BINARY_PATH, ""); //NOI18N
97.72 - String oldValue = result;
97.73 - if (result.isEmpty()) {
97.74 - String toolPath = System.getProperty("devstudio.clangtidy.path"); //NOI18N
97.75 - if (toolPath != null) {
97.76 - result = toolPath;
97.77 - }
97.78 - }
97.79 - if (result.isEmpty()) {
97.80 - final String codeBase = getCodeBase();
97.81 - String relativePath = String.format("%s/%s-%s", CLANG_BINARY_NAME, CLANG_BINARY_NAME, codeBase); //NOI18N
97.82 - File toolFile = InstalledFileLocator.getDefault().locate(relativePath, codeBase, false);
97.83 - if (toolFile != null && toolFile.exists()) {
97.84 - toolFile.setExecutable(true);
97.85 - System.out.println(toolFile.canExecute());
97.86 - result = toolFile.getAbsolutePath();
97.87 - }
97.88 - }
97.89 - if (result.isEmpty()) {
97.90 - String toolPath = findInPaths();
97.91 - if (toolPath != null) {
97.92 - result = toolPath;
97.93 - }
97.94 - }
97.95 - if (result.isEmpty()) {
97.96 - return null;
97.97 - } else {
97.98 - if (!oldValue.equals(result)) {
97.99 - AnalyzerPreferences.getPreferences().put(CLANG_BINARY_PATH, result);
97.100 - }
97.101 - }
97.102 - return result;
97.103 - }
97.104 -
97.105 - public static String getMissingModuleName() {
97.106 - return "org.netbeans.modules.analysis.clangtidy." + getCodeBase(); //NOI18N
97.107 - }
97.108 -
97.109 - public static String getCodeBase() {
97.110 - HostInfo hostInfo = null;
97.111 - try {
97.112 - hostInfo = HostInfoUtils.getHostInfo(ExecutionEnvironmentFactory.getLocal());
97.113 - } catch (IOException ex) {
97.114 - ex.printStackTrace(System.err);
97.115 - } catch (ConnectionManager.CancellationException ex) {
97.116 - ex.printStackTrace(System.err);
97.117 - }
97.118 - String module = null;
97.119 - if (hostInfo != null) {
97.120 - switch (hostInfo.getOS().getFamily()) {
97.121 - case SUNOS:
97.122 - switch (hostInfo.getCpuFamily()) {
97.123 - case X86:
97.124 - switch (hostInfo.getOS().getBitness()) {
97.125 - case _32:
97.126 - module = "SunOS_x86"; // NOI18N
97.127 - break;
97.128 - case _64:
97.129 - module = "SunOS_x86_64"; // NOI18N
97.130 - break;
97.131 - }
97.132 - break;
97.133 - case SPARC:
97.134 - module = "SunOS_sparc"; // NOI18N
97.135 - break;
97.136 - }
97.137 - break;
97.138 - case LINUX:
97.139 - switch (hostInfo.getOS().getBitness()) {
97.140 - case _32:
97.141 - module = "Linux_x86"; // NOI18N
97.142 - break;
97.143 - case _64:
97.144 - module = "Linux_x86_64"; // NOI18N
97.145 - break;
97.146 - }
97.147 - break;
97.148 - case WINDOWS:
97.149 - switch (hostInfo.getOS().getBitness()) {
97.150 - case _32:
97.151 - module = "Windows_x86"; // NOI18N
97.152 - break;
97.153 - case _64:
97.154 - module = "Windows_x86_64"; // NOI18N
97.155 - break;
97.156 - }
97.157 - break;
97.158 - case MACOSX:
97.159 - switch (hostInfo.getOS().getBitness()) {
97.160 - case _32:
97.161 - module = "MacOSX_x86"; // NOI18N
97.162 - break;
97.163 - case _64:
97.164 - module = "MacOSX_x86_64"; // NOI18N
97.165 - break;
97.166 - }
97.167 - break;
97.168 - }
97.169 - }
97.170 - return module;
97.171 - }
97.172 -}
98.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/Bundle.properties Wed Jun 07 18:50:35 2017 +0300
98.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
98.3 @@ -1,6 +0,0 @@
98.4 -fatals=fatal.unsupported.remote;fatal.tmp;fatal.analyze.error;fatal.language.flavor
98.5 -
98.6 -fatal.unsupported.remote= fatal: Unsupported remote mode
98.7 -fatal.tmp= fatal: Cannot create temporary file
98.8 -fatal.analyze.error= fatal: Unable to analyze file
98.9 -fatal.language.flavor= fatal: Clang-tidy can be used with C++11 or later standard only
98.10 \ No newline at end of file
99.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/BundleUtilities.java Wed Jun 07 18:50:35 2017 +0300
99.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
99.3 @@ -1,61 +0,0 @@
99.4 -/*
99.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
99.6 - *
99.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
99.8 - *
99.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
99.10 - * Other names may be trademarks of their respective owners.
99.11 - *
99.12 - * The contents of this file are subject to the terms of either the GNU
99.13 - * General Public License Version 2 only ("GPL") or the Common
99.14 - * Development and Distribution License("CDDL") (collectively, the
99.15 - * "License"). You may not use this file except in compliance with the
99.16 - * License. You can obtain a copy of the License at
99.17 - * http://www.netbeans.org/cddl-gplv2.html
99.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
99.19 - * specific language governing permissions and limitations under the
99.20 - * License. When distributing the software, include this License Header
99.21 - * Notice in each file and include the License file at
99.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
99.23 - * particular file as subject to the "Classpath" exception as provided
99.24 - * by Oracle in the GPL Version 2 section of the License file that
99.25 - * accompanied this code. If applicable, add the following below the
99.26 - * License Header, with the fields enclosed by brackets [] replaced by
99.27 - * your own identifying information:
99.28 - * "Portions Copyrighted [year] [name of copyright owner]"
99.29 - *
99.30 - * If you wish your version of this file to be governed by only the CDDL
99.31 - * or only the GPL Version 2, indicate your decision by adding
99.32 - * "[Contributor] elects to include this software in this distribution
99.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
99.34 - * single choice of license, a recipient has the option to distribute
99.35 - * your version of this file under either the CDDL, the GPL Version 2 or
99.36 - * to extend the choice of license to its licensees as provided above.
99.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
99.38 - * Version 2 license, then the option applies only if the new code is
99.39 - * made subject to such option by the copyright holder.
99.40 - *
99.41 - * Contributor(s): Ilia Gromov
99.42 - */
99.43 -package org.netbeans.modules.ide.analysis.modernize.resources;
99.44 -
99.45 -import org.openide.util.NbBundle;
99.46 -
99.47 -/**
99.48 - *
99.49 - * @author Ilia Gromov
99.50 - */
99.51 -public class BundleUtilities {
99.52 -
99.53 - public static String[] getFlags() {
99.54 - return NbBundle.getMessage(BundleUtilities.class, "flags").split(";");
99.55 - }
99.56 -
99.57 - public static String getDescription(String key) {
99.58 - return NbBundle.getMessage(BundleUtilities.class, key);
99.59 - }
99.60 -
99.61 - public static String[] getFatalErrors() {
99.62 - return NbBundle.getMessage(BundleUtilities.class, "fatals").split(";");
99.63 - }
99.64 -}
100.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang-tools-extra.patch Wed Jun 07 18:50:35 2017 +0300
100.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
100.3 @@ -1,139 +0,0 @@
100.4 -Index: clang-tidy/ClangTidy.cpp
100.5 -===================================================================
100.6 ---- clang-tidy/ClangTidy.cpp (revision 278390)
100.7 -+++ clang-tidy/ClangTidy.cpp (working copy)
100.8 -@@ -35,6 +35,7 @@
100.9 - #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
100.10 - #include "clang/Tooling/Refactoring.h"
100.11 - #include "clang/Tooling/ReplacementsYaml.h"
100.12 -+#include "clang/Tooling/DiagnosticsYaml.h"
100.13 - #include "clang/Tooling/Tooling.h"
100.14 - #include "llvm/Support/Process.h"
100.15 - #include "llvm/Support/Signals.h"
100.16 -@@ -509,13 +510,10 @@
100.17 -
100.18 - void exportReplacements(const std::vector<ClangTidyError> &Errors,
100.19 - raw_ostream &OS) {
100.20 -- tooling::TranslationUnitReplacements TUR;
100.21 -- for (const ClangTidyError &Error : Errors)
100.22 -- TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(),
100.23 -- Error.Fix.end());
100.24 --
100.25 - yaml::Output YAML(OS);
100.26 -- YAML << TUR;
100.27 -+ TranslationUnitDiagnostics TUD;
100.28 -+ TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end());
100.29 -+ YAML << TUD;
100.30 - }
100.31 -
100.32 - } // namespace tidy
100.33 -Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
100.34 -===================================================================
100.35 ---- clang-tidy/ClangTidyDiagnosticConsumer.cpp (revision 278390)
100.36 -+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp (working copy)
100.37 -@@ -102,25 +102,6 @@
100.38 - };
100.39 - } // end anonymous namespace
100.40 -
100.41 --ClangTidyMessage::ClangTidyMessage(StringRef Message)
100.42 -- : Message(Message), FileOffset(0) {}
100.43 --
100.44 --ClangTidyMessage::ClangTidyMessage(StringRef Message,
100.45 -- const SourceManager &Sources,
100.46 -- SourceLocation Loc)
100.47 -- : Message(Message) {
100.48 -- assert(Loc.isValid() && Loc.isFileID());
100.49 -- FilePath = Sources.getFilename(Loc);
100.50 -- FileOffset = Sources.getFileOffset(Loc);
100.51 --}
100.52 --
100.53 --ClangTidyError::ClangTidyError(StringRef CheckName,
100.54 -- ClangTidyError::Level DiagLevel,
100.55 -- bool IsWarningAsError,
100.56 -- StringRef BuildDirectory)
100.57 -- : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
100.58 -- IsWarningAsError(IsWarningAsError) {}
100.59 --
100.60 - // Returns true if GlobList starts with the negative indicator ('-'), removes it
100.61 - // from the GlobList.
100.62 - static bool ConsumeNegativeIndicator(StringRef &GlobList) {
100.63 -Index: clang-tidy/ClangTidyDiagnosticConsumer.h
100.64 -===================================================================
100.65 ---- clang-tidy/ClangTidyDiagnosticConsumer.h (revision 278390)
100.66 -+++ clang-tidy/ClangTidyDiagnosticConsumer.h (working copy)
100.67 -@@ -14,6 +14,7 @@
100.68 - #include "clang/Basic/Diagnostic.h"
100.69 - #include "clang/Basic/SourceManager.h"
100.70 - #include "clang/Tooling/Refactoring.h"
100.71 -+#include "clang/Tooling/Core/Diagnostics.h"
100.72 - #include "llvm/ADT/DenseMap.h"
100.73 - #include "llvm/ADT/StringMap.h"
100.74 - #include "llvm/Support/Regex.h"
100.75 -@@ -32,52 +33,9 @@
100.76 -
100.77 - namespace tidy {
100.78 -
100.79 --/// \brief A message from a clang-tidy check.
100.80 --///
100.81 --/// Note that this is independent of a \c SourceManager.
100.82 --struct ClangTidyMessage {
100.83 -- ClangTidyMessage(StringRef Message = "");
100.84 -- ClangTidyMessage(StringRef Message, const SourceManager &Sources,
100.85 -- SourceLocation Loc);
100.86 -- std::string Message;
100.87 -- std::string FilePath;
100.88 -- unsigned FileOffset;
100.89 --};
100.90 -+typedef clang::tooling::DiagnosticsMessage ClangTidyMessage;
100.91 -+typedef clang::tooling::Diagnostics ClangTidyError;
100.92 -
100.93 --/// \brief A detected error complete with information to display diagnostic and
100.94 --/// automatic fix.
100.95 --///
100.96 --/// This is used as an intermediate format to transport Diagnostics without a
100.97 --/// dependency on a SourceManager.
100.98 --///
100.99 --/// FIXME: Make Diagnostics flexible enough to support this directly.
100.100 --struct ClangTidyError {
100.101 -- enum Level {
100.102 -- Warning = DiagnosticsEngine::Warning,
100.103 -- Error = DiagnosticsEngine::Error
100.104 -- };
100.105 --
100.106 -- ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
100.107 -- StringRef BuildDirectory);
100.108 --
100.109 -- std::string CheckName;
100.110 -- ClangTidyMessage Message;
100.111 -- tooling::Replacements Fix;
100.112 -- SmallVector<ClangTidyMessage, 1> Notes;
100.113 --
100.114 -- // A build directory of the diagnostic source file.
100.115 -- //
100.116 -- // It's an absolute path which is `directory` field of the source file in
100.117 -- // compilation database. If users don't specify the compilation database
100.118 -- // directory, it is the current directory where clang-tidy runs.
100.119 -- //
100.120 -- // Note: it is empty in unittest.
100.121 -- std::string BuildDirectory;
100.122 --
100.123 -- Level DiagLevel;
100.124 -- bool IsWarningAsError;
100.125 --};
100.126 --
100.127 - /// \brief Read-only set of strings represented as a list of positive and
100.128 - /// negative globs. Positive globs add all matched strings to the set, negative
100.129 - /// globs remove them in the order of appearance in the list.
100.130 -Index: clang-tidy/tool/ClangTidyMain.cpp
100.131 -===================================================================
100.132 ---- clang-tidy/tool/ClangTidyMain.cpp (revision 278390)
100.133 -+++ clang-tidy/tool/ClangTidyMain.cpp (working copy)
100.134 -@@ -389,7 +389,7 @@
100.135 -
100.136 - // -fix-errors implies -fix.
100.137 - handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
100.138 --
100.139 -+
100.140 - if (!ExportFixes.empty() && !Errors.empty()) {
100.141 - std::error_code EC;
100.142 - llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
101.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang.patch Wed Jun 07 18:50:35 2017 +0300
101.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
101.3 @@ -1,461 +0,0 @@
101.4 -Index: include/clang/Tooling/Core/Diagnostics.h
101.5 -===================================================================
101.6 ---- include/clang/Tooling/Core/Diagnostics.h (revision 278390)
101.7 -+++ include/clang/Tooling/Core/Diagnostics.h (working copy)
101.8 -@@ -1,254 +1,54 @@
101.9 --//===--- Replacement.h - Framework for clang refactoring tools --*- C++ -*-===//
101.10 --//
101.11 --// The LLVM Compiler Infrastructure
101.12 --//
101.13 --// This file is distributed under the University of Illinois Open Source
101.14 --// License. See LICENSE.TXT for details.
101.15 --//
101.16 --//===----------------------------------------------------------------------===//
101.17 --//
101.18 --// Classes supporting refactorings that span multiple translation units.
101.19 --// While single translation unit refactorings are supported via the Rewriter,
101.20 --// when refactoring multiple translation units changes must be stored in a
101.21 --// SourceManager independent form, duplicate changes need to be removed, and
101.22 --// all changes must be applied at once at the end of the refactoring so that
101.23 --// the code is always parseable.
101.24 --//
101.25 --//===----------------------------------------------------------------------===//
101.26 --
101.27 --#ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
101.28 --#define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
101.29 --
101.30 --#include "clang/Basic/LangOptions.h"
101.31 --#include "clang/Basic/SourceLocation.h"
101.32 --#include "llvm/ADT/StringRef.h"
101.33 --#include "llvm/Support/Error.h"
101.34 --#include <map>
101.35 --#include <set>
101.36 -+#ifndef LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H
101.37 -+#define LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H
101.38 -+#include "clang/Basic/Diagnostic.h"
101.39 -+#include "llvm/ADT/SmallVector.h"
101.40 -+#include "Replacement.h"
101.41 - #include <string>
101.42 --#include <vector>
101.43 --
101.44 - namespace clang {
101.45 -+ namespace tooling {
101.46 -
101.47 --class Rewriter;
101.48 -+ struct DiagnosticsMessage {
101.49 -+ DiagnosticsMessage(StringRef Message = "");
101.50 -+ DiagnosticsMessage(StringRef Message, const SourceManager &Sources,
101.51 -+ SourceLocation Loc);
101.52 -+ std::string Message;
101.53 -+ std::string FilePath;
101.54 -+ unsigned FileOffset;
101.55 -+ };
101.56 -
101.57 --namespace tooling {
101.58 -+ struct Diagnostics {
101.59 -
101.60 --/// \brief A source range independent of the \c SourceManager.
101.61 --class Range {
101.62 --public:
101.63 -- Range() : Offset(0), Length(0) {}
101.64 -- Range(unsigned Offset, unsigned Length) : Offset(Offset), Length(Length) {}
101.65 -+ enum Level {
101.66 -+ Warning = DiagnosticsEngine::Warning,
101.67 -+ Error = DiagnosticsEngine::Error
101.68 -+ };
101.69 -
101.70 -- /// \brief Accessors.
101.71 -- /// @{
101.72 -- unsigned getOffset() const { return Offset; }
101.73 -- unsigned getLength() const { return Length; }
101.74 -- /// @}
101.75 -+ Diagnostics();
101.76 -+ Diagnostics(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
101.77 -+ StringRef BuildDirectory);
101.78 -+ std::string CheckName;
101.79 -+ DiagnosticsMessage Message;
101.80 -+ tooling::Replacements Fix;
101.81 -+ SmallVector<DiagnosticsMessage, 1> Notes;
101.82 -
101.83 -- /// \name Range Predicates
101.84 -- /// @{
101.85 -- /// \brief Whether this range overlaps with \p RHS or not.
101.86 -- bool overlapsWith(Range RHS) const {
101.87 -- return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length;
101.88 -- }
101.89 -+ // A build directory of the diagnostic source file.
101.90 -+ //
101.91 -+ // It's an absolute path which is `directory` field of the source file in
101.92 -+ // compilation database. If users don't specify the compilation database
101.93 -+ // directory, it is the current directory where clang-tidy runs.
101.94 -+ //
101.95 -+ // Note: it is empty in unittest.
101.96 -+ std::string BuildDirectory;
101.97 -
101.98 -- /// \brief Whether this range contains \p RHS or not.
101.99 -- bool contains(Range RHS) const {
101.100 -- return RHS.Offset >= Offset &&
101.101 -- (RHS.Offset + RHS.Length) <= (Offset + Length);
101.102 -- }
101.103 -+ Level DiagLevel;
101.104 -+ bool IsWarningAsError;
101.105 -+ };
101.106 -
101.107 -- /// \brief Whether this range equals to \p RHS or not.
101.108 -- bool operator==(const Range &RHS) const {
101.109 -- return Offset == RHS.getOffset() && Length == RHS.getLength();
101.110 -- }
101.111 -- /// @}
101.112 --
101.113 --private:
101.114 -- unsigned Offset;
101.115 -- unsigned Length;
101.116 --};
101.117 --
101.118 --/// \brief A text replacement.
101.119 --///
101.120 --/// Represents a SourceManager independent replacement of a range of text in a
101.121 --/// specific file.
101.122 --class Replacement {
101.123 --public:
101.124 -- /// \brief Creates an invalid (not applicable) replacement.
101.125 -- Replacement();
101.126 --
101.127 -- /// \brief Creates a replacement of the range [Offset, Offset+Length) in
101.128 -- /// FilePath with ReplacementText.
101.129 -- ///
101.130 -- /// \param FilePath A source file accessible via a SourceManager.
101.131 -- /// \param Offset The byte offset of the start of the range in the file.
101.132 -- /// \param Length The length of the range in bytes.
101.133 -- Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
101.134 -- StringRef ReplacementText);
101.135 --
101.136 -- /// \brief Creates a Replacement of the range [Start, Start+Length) with
101.137 -- /// ReplacementText.
101.138 -- Replacement(const SourceManager &Sources, SourceLocation Start,
101.139 -- unsigned Length, StringRef ReplacementText);
101.140 --
101.141 -- /// \brief Creates a Replacement of the given range with ReplacementText.
101.142 -- Replacement(const SourceManager &Sources, const CharSourceRange &Range,
101.143 -- StringRef ReplacementText,
101.144 -- const LangOptions &LangOpts = LangOptions());
101.145 --
101.146 -- /// \brief Creates a Replacement of the node with ReplacementText.
101.147 -- template <typename Node>
101.148 -- Replacement(const SourceManager &Sources, const Node &NodeToReplace,
101.149 -- StringRef ReplacementText,
101.150 -- const LangOptions &LangOpts = LangOptions());
101.151 --
101.152 -- /// \brief Returns whether this replacement can be applied to a file.
101.153 -- ///
101.154 -- /// Only replacements that are in a valid file can be applied.
101.155 -- bool isApplicable() const;
101.156 --
101.157 -- /// \brief Accessors.
101.158 -- /// @{
101.159 -- StringRef getFilePath() const { return FilePath; }
101.160 -- unsigned getOffset() const { return ReplacementRange.getOffset(); }
101.161 -- unsigned getLength() const { return ReplacementRange.getLength(); }
101.162 -- StringRef getReplacementText() const { return ReplacementText; }
101.163 -- /// @}
101.164 --
101.165 -- /// \brief Applies the replacement on the Rewriter.
101.166 -- bool apply(Rewriter &Rewrite) const;
101.167 --
101.168 -- /// \brief Returns a human readable string representation.
101.169 -- std::string toString() const;
101.170 --
101.171 -- private:
101.172 -- void setFromSourceLocation(const SourceManager &Sources,
101.173 -- SourceLocation Start, unsigned Length,
101.174 -- StringRef ReplacementText);
101.175 -- void setFromSourceRange(const SourceManager &Sources,
101.176 -- const CharSourceRange &Range,
101.177 -- StringRef ReplacementText,
101.178 -- const LangOptions &LangOpts);
101.179 --
101.180 -- std::string FilePath;
101.181 -- Range ReplacementRange;
101.182 -- std::string ReplacementText;
101.183 --};
101.184 --
101.185 --/// \brief Less-than operator between two Replacements.
101.186 --bool operator<(const Replacement &LHS, const Replacement &RHS);
101.187 --
101.188 --/// \brief Equal-to operator between two Replacements.
101.189 --bool operator==(const Replacement &LHS, const Replacement &RHS);
101.190 --
101.191 --/// \brief A set of Replacements.
101.192 --/// FIXME: Change to a vector and deduplicate in the RefactoringTool.
101.193 --typedef std::set<Replacement> Replacements;
101.194 --
101.195 --/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite.
101.196 --///
101.197 --/// Replacement applications happen independently of the success of
101.198 --/// other applications.
101.199 --///
101.200 --/// \returns true if all replacements apply. false otherwise.
101.201 --bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite);
101.202 --
101.203 --/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite.
101.204 --///
101.205 --/// Replacement applications happen independently of the success of
101.206 --/// other applications.
101.207 --///
101.208 --/// \returns true if all replacements apply. false otherwise.
101.209 --bool applyAllReplacements(const std::vector<Replacement> &Replaces,
101.210 -- Rewriter &Rewrite);
101.211 --
101.212 --/// \brief Applies all replacements in \p Replaces to \p Code.
101.213 --///
101.214 --/// This completely ignores the path stored in each replacement. If all
101.215 --/// replacements are applied successfully, this returns the code with
101.216 --/// replacements applied; otherwise, an llvm::Error carrying llvm::StringError
101.217 --/// is returned (the Error message can be converted to string using
101.218 --/// `llvm::toString()` and 'std::error_code` in the `Error` should be ignored).
101.219 --llvm::Expected<std::string> applyAllReplacements(StringRef Code,
101.220 -- const Replacements &Replaces);
101.221 --
101.222 --/// \brief Calculates how a code \p Position is shifted when \p Replaces are
101.223 --/// applied.
101.224 --unsigned shiftedCodePosition(const Replacements& Replaces, unsigned Position);
101.225 --
101.226 --/// \brief Calculates how a code \p Position is shifted when \p Replaces are
101.227 --/// applied.
101.228 --///
101.229 --/// \pre Replaces[i].getOffset() <= Replaces[i+1].getOffset().
101.230 --unsigned shiftedCodePosition(const std::vector<Replacement> &Replaces,
101.231 -- unsigned Position);
101.232 --
101.233 --/// \brief Removes duplicate Replacements and reports if Replacements conflict
101.234 --/// with one another. All Replacements are assumed to be in the same file.
101.235 --///
101.236 --/// \post Replaces[i].getOffset() <= Replaces[i+1].getOffset().
101.237 --///
101.238 --/// This function sorts \p Replaces so that conflicts can be reported simply by
101.239 --/// offset into \p Replaces and number of elements in the conflict.
101.240 --void deduplicate(std::vector<Replacement> &Replaces,
101.241 -- std::vector<Range> &Conflicts);
101.242 --
101.243 --/// \brief Collection of Replacements generated from a single translation unit.
101.244 --struct TranslationUnitReplacements {
101.245 -- /// Name of the main source for the translation unit.
101.246 -- std::string MainSourceFile;
101.247 --
101.248 -- /// A freeform chunk of text to describe the context of the replacements.
101.249 -- /// Will be printed, for example, when detecting conflicts during replacement
101.250 -- /// deduplication.
101.251 -- std::string Context;
101.252 --
101.253 -- std::vector<Replacement> Replacements;
101.254 --};
101.255 --
101.256 --/// \brief Calculates the ranges in a single file that are affected by the
101.257 --/// Replacements. Overlapping ranges will be merged.
101.258 --///
101.259 --/// \pre Replacements must be for the same file.
101.260 --///
101.261 --/// \returns a non-overlapping and sorted ranges.
101.262 --std::vector<Range> calculateChangedRanges(const Replacements &Replaces);
101.263 --
101.264 --/// \brief Calculates the new ranges after \p Replaces are applied. These
101.265 --/// include both the original \p Ranges and the affected ranges of \p Replaces
101.266 --/// in the new code.
101.267 --///
101.268 --/// \pre Replacements must be for the same file.
101.269 --///
101.270 --/// \return The new ranges after \p Replaces are applied. The new ranges will be
101.271 --/// sorted and non-overlapping.
101.272 --std::vector<Range>
101.273 --calculateRangesAfterReplacements(const Replacements &Replaces,
101.274 -- const std::vector<Range> &Ranges);
101.275 --
101.276 --/// \brief Groups a random set of replacements by file path. Replacements
101.277 --/// related to the same file entry are put into the same vector.
101.278 --std::map<std::string, Replacements>
101.279 --groupReplacementsByFile(const Replacements &Replaces);
101.280 --
101.281 --/// \brief Merges two sets of replacements with the second set referring to the
101.282 --/// code after applying the first set. Within both 'First' and 'Second',
101.283 --/// replacements must not overlap.
101.284 --Replacements mergeReplacements(const Replacements &First,
101.285 -- const Replacements &Second);
101.286 --
101.287 --template <typename Node>
101.288 --Replacement::Replacement(const SourceManager &Sources,
101.289 -- const Node &NodeToReplace, StringRef ReplacementText,
101.290 -- const LangOptions &LangOpts) {
101.291 -- const CharSourceRange Range =
101.292 -- CharSourceRange::getTokenRange(NodeToReplace->getSourceRange());
101.293 -- setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
101.294 -+ struct TranslationUnitDiagnostics {
101.295 -+ std::string MainSourceFile;
101.296 -+ std::string Context;
101.297 -+ std::vector<Diagnostics> Diags;
101.298 -+ };
101.299 -+ }
101.300 - }
101.301 --
101.302 --} // end namespace tooling
101.303 --} // end namespace clang
101.304 --
101.305 --#endif // LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
101.306 -+#endif
101.307 -\ No newline at end of file
101.308 -Index: lib/Tooling/Core/CMakeLists.txt
101.309 -===================================================================
101.310 ---- lib/Tooling/Core/CMakeLists.txt (revision 278390)
101.311 -+++ lib/Tooling/Core/CMakeLists.txt (working copy)
101.312 -@@ -3,6 +3,7 @@
101.313 - add_clang_library(clangToolingCore
101.314 - Lookup.cpp
101.315 - Replacement.cpp
101.316 -+ Diagnostics.cpp
101.317 - QualTypeNames.cpp
101.318 -
101.319 - LINK_LIBS
101.320 -Index: lib/Tooling/Core/Diagnostics.cpp
101.321 -===================================================================
101.322 ---- lib/Tooling/Core/Diagnostics.cpp (revision 278390)
101.323 -+++ lib/Tooling/Core/Diagnostics.cpp (working copy)
101.324 -@@ -1,113 +1,30 @@
101.325 --//===--- Lookup.cpp - Framework for clang refactoring tools ---------------===//
101.326 --//
101.327 --// The LLVM Compiler Infrastructure
101.328 --//
101.329 --// This file is distributed under the University of Illinois Open Source
101.330 --// License. See LICENSE.TXT for details.
101.331 --//
101.332 --//===----------------------------------------------------------------------===//
101.333 --//
101.334 --// This file defines helper methods for clang tools performing name lookup.
101.335 --//
101.336 --//===----------------------------------------------------------------------===//
101.337 -+#include "clang/Tooling/Core/Diagnostics.h"
101.338 -+#include "clang/Basic/SourceManager.h"
101.339 -+namespace clang {
101.340 -+ namespace tooling {
101.341 -
101.342 --#include "clang/Tooling/Core/Lookup.h"
101.343 --#include "clang/AST/Decl.h"
101.344 --using namespace clang;
101.345 --using namespace clang::tooling;
101.346 -+ DiagnosticsMessage::DiagnosticsMessage(StringRef Message)
101.347 -+ : Message(Message), FileOffset(0) {
101.348 -+ }
101.349 -
101.350 --static bool isInsideDifferentNamespaceWithSameName(const DeclContext *DeclA,
101.351 -- const DeclContext *DeclB) {
101.352 -- while (true) {
101.353 -- // Look past non-namespaces on DeclA.
101.354 -- while (DeclA && !isa<NamespaceDecl>(DeclA))
101.355 -- DeclA = DeclA->getParent();
101.356 -+ DiagnosticsMessage::DiagnosticsMessage(StringRef Message,
101.357 -+ const SourceManager &Sources,
101.358 -+ SourceLocation Loc)
101.359 -+ : Message(Message) {
101.360 -+ assert(Loc.isValid() && Loc.isFileID());
101.361 -+ FilePath = Sources.getFilename(Loc);
101.362 -+ FileOffset = Sources.getFileOffset(Loc);
101.363 -+ }
101.364 -
101.365 -- // Look past non-namespaces on DeclB.
101.366 -- while (DeclB && !isa<NamespaceDecl>(DeclB))
101.367 -- DeclB = DeclB->getParent();
101.368 -+ Diagnostics::Diagnostics() {
101.369 -+ }
101.370 -
101.371 -- // We hit the root, no namespace collision.
101.372 -- if (!DeclA || !DeclB)
101.373 -- return false;
101.374 --
101.375 -- // Literally the same namespace, not a collision.
101.376 -- if (DeclA == DeclB)
101.377 -- return false;
101.378 --
101.379 -- // Now check the names. If they match we have a different namespace with the
101.380 -- // same name.
101.381 -- if (cast<NamespaceDecl>(DeclA)->getDeclName() ==
101.382 -- cast<NamespaceDecl>(DeclB)->getDeclName())
101.383 -- return true;
101.384 --
101.385 -- DeclA = DeclA->getParent();
101.386 -- DeclB = DeclB->getParent();
101.387 -- }
101.388 --}
101.389 --
101.390 --static StringRef getBestNamespaceSubstr(const DeclContext *DeclA,
101.391 -- StringRef NewName,
101.392 -- bool HadLeadingColonColon) {
101.393 -- while (true) {
101.394 -- while (DeclA && !isa<NamespaceDecl>(DeclA))
101.395 -- DeclA = DeclA->getParent();
101.396 --
101.397 -- // Fully qualified it is! Leave :: in place if it's there already.
101.398 -- if (!DeclA)
101.399 -- return HadLeadingColonColon ? NewName : NewName.substr(2);
101.400 --
101.401 -- // Otherwise strip off redundant namespace qualifications from the new name.
101.402 -- // We use the fully qualified name of the namespace and remove that part
101.403 -- // from NewName if it has an identical prefix.
101.404 -- std::string NS =
101.405 -- "::" + cast<NamespaceDecl>(DeclA)->getQualifiedNameAsString() + "::";
101.406 -- if (NewName.startswith(NS))
101.407 -- return NewName.substr(NS.size());
101.408 --
101.409 -- // No match yet. Strip of a namespace from the end of the chain and try
101.410 -- // again. This allows to get optimal qualifications even if the old and new
101.411 -- // decl only share common namespaces at a higher level.
101.412 -- DeclA = DeclA->getParent();
101.413 -- }
101.414 --}
101.415 --
101.416 --/// Check if the name specifier begins with a written "::".
101.417 --static bool isFullyQualified(const NestedNameSpecifier *NNS) {
101.418 -- while (NNS) {
101.419 -- if (NNS->getKind() == NestedNameSpecifier::Global)
101.420 -- return true;
101.421 -- NNS = NNS->getPrefix();
101.422 -- }
101.423 -- return false;
101.424 --}
101.425 --
101.426 --std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
101.427 -- const DeclContext *UseContext,
101.428 -- const NamedDecl *FromDecl,
101.429 -- StringRef ReplacementString) {
101.430 -- assert(ReplacementString.startswith("::") &&
101.431 -- "Expected fully-qualified name!");
101.432 --
101.433 -- // We can do a raw name replacement when we are not inside the namespace for
101.434 -- // the original function and it is not in the global namespace. The
101.435 -- // assumption is that outside the original namespace we must have a using
101.436 -- // statement that makes this work out and that other parts of this refactor
101.437 -- // will automatically fix using statements to point to the new function
101.438 -- const bool class_name_only = !Use;
101.439 -- const bool in_global_namespace =
101.440 -- isa<TranslationUnitDecl>(FromDecl->getDeclContext());
101.441 -- if (class_name_only && !in_global_namespace &&
101.442 -- !isInsideDifferentNamespaceWithSameName(FromDecl->getDeclContext(),
101.443 -- UseContext)) {
101.444 -- auto Pos = ReplacementString.rfind("::");
101.445 -- return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2)
101.446 -- : ReplacementString;
101.447 -- }
101.448 -- // We did not match this because of a using statement, so we will need to
101.449 -- // figure out how good a namespace match we have with our destination type.
101.450 -- // We work backwards (from most specific possible namespace to least
101.451 -- // specific).
101.452 -- return getBestNamespaceSubstr(UseContext, ReplacementString,
101.453 -- isFullyQualified(Use));
101.454 --}
101.455 -+ Diagnostics::Diagnostics(StringRef CheckName,
101.456 -+ Diagnostics::Level DiagLevel,
101.457 -+ bool IsWarningAsError,
101.458 -+ StringRef BuildDirectory)
101.459 -+ : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel),
101.460 -+ IsWarningAsError(IsWarningAsError) {
101.461 -+ }
101.462 -+ }
101.463 -+}
101.464 -\ No newline at end of file
102.1 --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/utils/AnalyticsTools.java Wed Jun 07 18:50:35 2017 +0300
102.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
102.3 @@ -1,208 +0,0 @@
102.4 -/*
102.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
102.6 - *
102.7 - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
102.8 - *
102.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
102.10 - * Other names may be trademarks of their respective owners.
102.11 - *
102.12 - * The contents of this file are subject to the terms of either the GNU
102.13 - * General Public License Version 2 only ("GPL") or the Common
102.14 - * Development and Distribution License("CDDL") (collectively, the
102.15 - * "License"). You may not use this file except in compliance with the
102.16 - * License. You can obtain a copy of the License at
102.17 - * http://www.netbeans.org/cddl-gplv2.html
102.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
102.19 - * specific language governing permissions and limitations under the
102.20 - * License. When distributing the software, include this License Header
102.21 - * Notice in each file and include the License file at
102.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
102.23 - * particular file as subject to the "Classpath" exception as provided
102.24 - * by Oracle in the GPL Version 2 section of the License file that
102.25 - * accompanied this code. If applicable, add the following below the
102.26 - * License Header, with the fields enclosed by brackets [] replaced by
102.27 - * your own identifying information:
102.28 - * "Portions Copyrighted [year] [name of copyright owner]"
102.29 - *
102.30 - * If you wish your version of this file to be governed by only the CDDL
102.31 - * or only the GPL Version 2, indicate your decision by adding
102.32 - * "[Contributor] elects to include this software in this distribution
102.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
102.34 - * single choice of license, a recipient has the option to distribute
102.35 - * your version of this file under either the CDDL, the GPL Version 2 or
102.36 - * to extend the choice of license to its licensees as provided above.
102.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
102.38 - * Version 2 license, then the option applies only if the new code is
102.39 - * made subject to such option by the copyright holder.
102.40 - *
102.41 - * Contributor(s): Ilia Gromov
102.42 - */
102.43 -package org.netbeans.modules.ide.analysis.modernize.utils;
102.44 -
102.45 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeErrorProvider;
102.46 -import java.util.ArrayList;
102.47 -import java.util.List;
102.48 -import org.netbeans.api.project.FileOwnerQuery;
102.49 -import org.netbeans.api.project.Project;
102.50 -import org.netbeans.modules.analysis.spi.Analyzer;
102.51 -import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse;
102.52 -import org.netbeans.modules.cnd.api.model.CsmFile;
102.53 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
102.54 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
102.55 -import org.netbeans.modules.cnd.api.project.NativeFileItem;
102.56 -import org.netbeans.modules.cnd.api.remote.RemoteProject;
102.57 -import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
102.58 -import org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind;
102.59 -import org.netbeans.modules.cnd.api.toolchain.Tool;
102.60 -import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider;
102.61 -import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
102.62 -import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
102.63 -import org.netbeans.modules.cnd.spi.toolchain.ToolchainProject;
102.64 -import org.netbeans.modules.cnd.utils.MIMENames;
102.65 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
102.66 -import org.openide.filesystems.FileObject;
102.67 -import org.openide.util.Lookup;
102.68 -
102.69 -/**
102.70 - *
102.71 - * @author Ilia Gromov
102.72 - */
102.73 -public class AnalyticsTools {
102.74 -
102.75 - public static ExecutionEnvironment detectEnvironment(Analyzer.Context context) {
102.76 - if (context.getScope() == null) {
102.77 - return null;
102.78 - }
102.79 - for (FileObject fo : context.getScope().getFiles()) {
102.80 - String mimeType = fo.getMIMEType();
102.81 - if (MIMENames.isHeaderOrCppOrC(mimeType)) {
102.82 - Project project = FileOwnerQuery.getOwner(fo);
102.83 - RemoteProject info = project.getLookup().lookup(RemoteProject.class);
102.84 - if (info != null) {
102.85 - ExecutionEnvironment dh = info.getDevelopmentHost();
102.86 - if (dh != null) {
102.87 - return dh;
102.88 - }
102.89 - }
102.90 - }
102.91 - }
102.92 - return null;
102.93 - }
102.94 -
102.95 - public static CompilerSet toolchain(Lookup.Provider project) {
102.96 - ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class);
102.97 - if (toolchain != null) {
102.98 - return toolchain.getCompilerSet();
102.99 - }
102.100 - return null;
102.101 - }
102.102 -
102.103 - public static MakeConfigurationDescriptor getConfigurationDescriptor(CsmFile file, Lookup.Provider project) {
102.104 - if (file != null) {
102.105 - ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class);
102.106 - if (pdp != null) {
102.107 - MakeConfigurationDescriptor makeConfigurationDescriptor = pdp.getConfigurationDescriptor();
102.108 - if (makeConfigurationDescriptor != null) {
102.109 - return makeConfigurationDescriptor;
102.110 - }
102.111 - }
102.112 - }
102.113 -
102.114 - return null;
102.115 - }
102.116 -
102.117 - public static Item findItem(CsmFile file, Lookup.Provider project) {
102.118 - return getConfigurationDescriptor(file, project).findProjectItemByPath(file.getAbsolutePath().toString());
102.119 - }
102.120 -
102.121 - public static void fatalError(AnalyzerResponse.AnalyzerSeverity severity, String id, String message, CsmFile file, CsmErrorProvider.Response response) {
102.122 - CsmErrorInfo fatal = new ModernizeErrorProvider.FatalErrorInfo(id, message);
102.123 - if (response instanceof AnalyzerResponse) {
102.124 - AnalyzerResponse ar = (AnalyzerResponse) response;
102.125 - ar.addError(severity, message, file.getFileObject(), fatal); //NOI18N
102.126 - } else {
102.127 - response.addError(fatal); //NOI18N
102.128 - }
102.129 - }
102.130 -
102.131 - public static String useTool(Item item, Lookup.Provider project) {
102.132 - ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class);
102.133 - if (toolchain != null) {
102.134 - CompilerSet set = toolchain.getCompilerSet();
102.135 - if (set != null) {
102.136 - if (set.getCompilerFlavor().isSunStudioCompiler()) {
102.137 - if (item.getLanguage() == NativeFileItem.Language.C) {
102.138 - return set.findTool(PredefinedToolKind.CCompiler).getPath();
102.139 - } else {
102.140 - return set.findTool(PredefinedToolKind.CCCompiler).getPath();
102.141 - }
102.142 - }
102.143 - }
102.144 - }
102.145 - return null;
102.146 - }
102.147 -
102.148 - public static Tool compiler(Item item, Lookup.Provider project) {
102.149 - CompilerSet set = toolchain(project);
102.150 - if (set != null) {
102.151 - if (item.getLanguage() == NativeFileItem.Language.C) {
102.152 - return set.findTool(PredefinedToolKind.CCompiler);
102.153 - } else {
102.154 - return set.findTool(PredefinedToolKind.CCCompiler);
102.155 - }
102.156 - }
102.157 - return null;
102.158 - }
102.159 -
102.160 - public static List<String> scanCommandLine(String line) {
102.161 - List<String> res = new ArrayList<String>();
102.162 - int i = 0;
102.163 - StringBuilder current = new StringBuilder();
102.164 - boolean isSingleQuoteMode = false;
102.165 - boolean isDoubleQuoteMode = false;
102.166 - while (i < line.length()) {
102.167 - char c = line.charAt(i);
102.168 - i++;
102.169 - switch (c) {
102.170 - case '\'': // NOI18N
102.171 - if (isSingleQuoteMode) {
102.172 - isSingleQuoteMode = false;
102.173 - } else if (!isDoubleQuoteMode) {
102.174 - isSingleQuoteMode = true;
102.175 - }
102.176 - current.append(c);
102.177 - break;
102.178 - case '\"': // NOI18N
102.179 - if (isDoubleQuoteMode) {
102.180 - isDoubleQuoteMode = false;
102.181 - } else if (!isSingleQuoteMode) {
102.182 - isDoubleQuoteMode = true;
102.183 - }
102.184 - current.append(c);
102.185 - break;
102.186 - case ' ': // NOI18N
102.187 - case '\t': // NOI18N
102.188 - case '\n': // NOI18N
102.189 - case '\r': // NOI18N
102.190 - if (isSingleQuoteMode || isDoubleQuoteMode) {
102.191 - current.append(c);
102.192 - break;
102.193 - } else {
102.194 - if (current.length() > 0) {
102.195 - res.add(current.toString());
102.196 - current.setLength(0);
102.197 - }
102.198 - }
102.199 - break;
102.200 - default:
102.201 - current.append(c);
102.202 - break;
102.203 - }
102.204 - }
102.205 - if (current.length() > 0) {
102.206 - res.add(current.toString());
102.207 - }
102.208 - return res;
102.209 - }
102.210 -
102.211 -}
103.1 --- a/ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt Wed Jun 07 18:50:35 2017 +0300
103.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
103.3 @@ -1,2 +0,0 @@
103.4 -File clang-tidy-3.9p should be placed in this directory before testing.
103.5 -(Won't commit large, ~25Mb binary file to Mercurial repo).
103.6 \ No newline at end of file
104.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt Wed Jun 07 18:50:35 2017 +0300
104.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
104.3 @@ -1,2 +0,0 @@
104.4 -project (HelloCMake CXX)
104.5 -add_subdirectory (src)
105.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml Wed Jun 07 18:50:35 2017 +0300
105.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
105.3 @@ -1,128 +0,0 @@
105.4 -<?xml version="1.0" encoding="UTF-8"?>
105.5 -<!--
105.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
105.7 -
105.8 -Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
105.9 -
105.10 -Oracle and Java are registered trademarks of Oracle and/or its affiliates.
105.11 -Other names may be trademarks of their respective owners.
105.12 -
105.13 -The contents of this file are subject to the terms of either the GNU
105.14 -General Public License Version 2 only ("GPL") or the Common
105.15 -Development and Distribution License("CDDL") (collectively, the
105.16 -"License"). You may not use this file except in compliance with the
105.17 -License. You can obtain a copy of the License at
105.18 -http://www.netbeans.org/cddl-gplv2.html
105.19 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
105.20 -specific language governing permissions and limitations under the
105.21 -License. When distributing the software, include this License Header
105.22 -Notice in each file and include the License file at
105.23 -nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
105.24 -particular file as subject to the "Classpath" exception as provided
105.25 -by Oracle in the GPL Version 2 section of the License file that
105.26 -accompanied this code. If applicable, add the following below the
105.27 -License Header, with the fields enclosed by brackets [] replaced by
105.28 -your own identifying information:
105.29 -"Portions Copyrighted [year] [name of copyright owner]"
105.30 -
105.31 -If you wish your version of this file to be governed by only the CDDL
105.32 -or only the GPL Version 2, indicate your decision by adding
105.33 -"[Contributor] elects to include this software in this distribution
105.34 -under the [CDDL or GPL Version 2] license." If you do not indicate a
105.35 -single choice of license, a recipient has the option to distribute
105.36 -your version of this file under either the CDDL, the GPL Version 2 or
105.37 -to extend the choice of license to its licensees as provided above.
105.38 -However, if you add GPL Version 2 code and therefore, elected the GPL
105.39 -Version 2 license, then the option applies only if the new code is
105.40 -made subject to such option by the copyright holder.
105.41 -
105.42 -Contributor(s):
105.43 --->
105.44 -<configurationDescriptor version="100">
105.45 - <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
105.46 - <df root="." name="0">
105.47 - <df name="src">
105.48 - <in>llvm-header-guard.cpp</in>
105.49 - </df>
105.50 - </df>
105.51 - <logicalFolder name="ExternalFiles"
105.52 - displayName="Important Files"
105.53 - projectFiles="false"
105.54 - kind="IMPORTANT_FILES_FOLDER">
105.55 - <itemPath>CMakeLists.txt</itemPath>
105.56 - <itemPath>build/Debug/Makefile</itemPath>
105.57 - <itemPath>build/Release/Makefile</itemPath>
105.58 - </logicalFolder>
105.59 - </logicalFolder>
105.60 - <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
105.61 - <sourceRootList>
105.62 - <Elem>.</Elem>
105.63 - </sourceRootList>
105.64 - <projectmakefile>build/Debug/Makefile</projectmakefile>
105.65 - <confs>
105.66 - <conf name="Debug" type="0">
105.67 - <toolsSet>
105.68 - <compilerSet>default</compilerSet>
105.69 - <dependencyChecking>false</dependencyChecking>
105.70 - <rebuildPropChanged>false</rebuildPropChanged>
105.71 - </toolsSet>
105.72 - <flagsDictionary>
105.73 - <element flagsID="0" commonFlags="-std=gnu++11"/>
105.74 - </flagsDictionary>
105.75 - <codeAssistance>
105.76 - </codeAssistance>
105.77 - <makefileType>
105.78 - <makeTool>
105.79 - <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
105.80 - <buildCommand>${MAKE} -f Makefile</buildCommand>
105.81 - <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
105.82 - <executablePath>build/Debug/src/welcome</executablePath>
105.83 - <ccTool flags="0">
105.84 - <incDir>
105.85 - <pElem>build/Debug/src</pElem>
105.86 - </incDir>
105.87 - </ccTool>
105.88 - </makeTool>
105.89 - <preBuild>
105.90 - <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
105.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>
105.92 - <preBuildFirst>true</preBuildFirst>
105.93 - </preBuild>
105.94 - </makefileType>
105.95 - <item path="src/llvm-header-guard.cpp" ex="false" tool="1" flavor2="8">
105.96 - <ccTool flags="0">
105.97 - </ccTool>
105.98 - </item>
105.99 - </conf>
105.100 - <conf name="Release" type="0">
105.101 - <toolsSet>
105.102 - <compilerSet>default</compilerSet>
105.103 - <dependencyChecking>false</dependencyChecking>
105.104 - <rebuildPropChanged>false</rebuildPropChanged>
105.105 - </toolsSet>
105.106 - <codeAssistance>
105.107 - </codeAssistance>
105.108 - <makefileType>
105.109 - <makeTool>
105.110 - <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
105.111 - <buildCommand>${MAKE} -f Makefile</buildCommand>
105.112 - <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
105.113 - <executablePath>build/Release/src/welcome</executablePath>
105.114 - <ccTool>
105.115 - <incDir>
105.116 - <pElem>build/Release/src</pElem>
105.117 - </incDir>
105.118 - <preprocessorList>
105.119 - <Elem>NDEBUG</Elem>
105.120 - </preprocessorList>
105.121 - </ccTool>
105.122 - </makeTool>
105.123 - <preBuild>
105.124 - <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
105.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>
105.126 - <preBuildFirst>true</preBuildFirst>
105.127 - </preBuild>
105.128 - </makefileType>
105.129 - </conf>
105.130 - </confs>
105.131 -</configurationDescriptor>
106.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml Wed Jun 07 18:50:35 2017 +0300
106.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
106.3 @@ -1,72 +0,0 @@
106.4 -<?xml version="1.0" encoding="UTF-8"?>
106.5 -<!--
106.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
106.7 -
106.8 -Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
106.9 -
106.10 -Oracle and Java are registered trademarks of Oracle and/or its affiliates.
106.11 -Other names may be trademarks of their respective owners.
106.12 -
106.13 -The contents of this file are subject to the terms of either the GNU
106.14 -General Public License Version 2 only ("GPL") or the Common
106.15 -Development and Distribution License("CDDL") (collectively, the
106.16 -"License"). You may not use this file except in compliance with the
106.17 -License. You can obtain a copy of the License at
106.18 -http://www.netbeans.org/cddl-gplv2.html
106.19 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
106.20 -specific language governing permissions and limitations under the
106.21 -License. When distributing the software, include this License Header
106.22 -Notice in each file and include the License file at
106.23 -nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
106.24 -particular file as subject to the "Classpath" exception as provided
106.25 -by Oracle in the GPL Version 2 section of the License file that
106.26 -accompanied this code. If applicable, add the following below the
106.27 -License Header, with the fields enclosed by brackets [] replaced by
106.28 -your own identifying information:
106.29 -"Portions Copyrighted [year] [name of copyright owner]"
106.30 -
106.31 -If you wish your version of this file to be governed by only the CDDL
106.32 -or only the GPL Version 2, indicate your decision by adding
106.33 -"[Contributor] elects to include this software in this distribution
106.34 -under the [CDDL or GPL Version 2] license." If you do not indicate a
106.35 -single choice of license, a recipient has the option to distribute
106.36 -your version of this file under either the CDDL, the GPL Version 2 or
106.37 -to extend the choice of license to its licensees as provided above.
106.38 -However, if you add GPL Version 2 code and therefore, elected the GPL
106.39 -Version 2 license, then the option applies only if the new code is
106.40 -made subject to such option by the copyright holder.
106.41 -
106.42 -Contributor(s):
106.43 --->
106.44 -<project xmlns="http://www.netbeans.org/ns/project/1">
106.45 - <type>org.netbeans.modules.cnd.makeproject</type>
106.46 - <configuration>
106.47 - <data xmlns="http://www.netbeans.org/ns/make-project/1">
106.48 - <name>hello-cmake-world</name>
106.49 - <c-extensions/>
106.50 - <cpp-extensions>cpp</cpp-extensions>
106.51 - <header-extensions>h</header-extensions>
106.52 - <sourceEncoding>UTF-8</sourceEncoding>
106.53 - <sourceRootList>
106.54 - <sourceRootElem>.</sourceRootElem>
106.55 - </sourceRootList>
106.56 - <make-dep-projects/>
106.57 - <sourceRootList>
106.58 - <sourceRootElem>.</sourceRootElem>
106.59 - </sourceRootList>
106.60 - <confList>
106.61 - <confElem>
106.62 - <name>Debug</name>
106.63 - <type>0</type>
106.64 - </confElem>
106.65 - <confElem>
106.66 - <name>Release</name>
106.67 - <type>0</type>
106.68 - </confElem>
106.69 - </confList>
106.70 - <formatting>
106.71 - <project-formatting-style>false</project-formatting-style>
106.72 - </formatting>
106.73 - </data>
106.74 - </configuration>
106.75 -</project>
107.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt Wed Jun 07 18:50:35 2017 +0300
107.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
107.3 @@ -1,2 +0,0 @@
107.4 -set(CMAKE_CXX_STANDARD 11)
107.5 -add_library (headers llvm-header-guard.cpp)
108.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp Wed Jun 07 18:50:35 2017 +0300
108.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
108.3 @@ -1,1 +0,0 @@
108.4 -#include "llvm-header-guard.h"
108.5 \ No newline at end of file
109.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt Wed Jun 07 18:50:35 2017 +0300
109.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
109.3 @@ -1,2 +0,0 @@
109.4 -project (HelloCMake)
109.5 -add_subdirectory (src)
110.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml Wed Jun 07 18:50:35 2017 +0300
110.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
110.3 @@ -1,143 +0,0 @@
110.4 -<?xml version="1.0" encoding="UTF-8"?>
110.5 -<!--
110.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
110.7 -
110.8 -Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
110.9 -
110.10 -Oracle and Java are registered trademarks of Oracle and/or its affiliates.
110.11 -Other names may be trademarks of their respective owners.
110.12 -
110.13 -The contents of this file are subject to the terms of either the GNU
110.14 -General Public License Version 2 only ("GPL") or the Common
110.15 -Development and Distribution License("CDDL") (collectively, the
110.16 -"License"). You may not use this file except in compliance with the
110.17 -License. You can obtain a copy of the License at
110.18 -http://www.netbeans.org/cddl-gplv2.html
110.19 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
110.20 -specific language governing permissions and limitations under the
110.21 -License. When distributing the software, include this License Header
110.22 -Notice in each file and include the License file at
110.23 -nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
110.24 -particular file as subject to the "Classpath" exception as provided
110.25 -by Oracle in the GPL Version 2 section of the License file that
110.26 -accompanied this code. If applicable, add the following below the
110.27 -License Header, with the fields enclosed by brackets [] replaced by
110.28 -your own identifying information:
110.29 -"Portions Copyrighted [year] [name of copyright owner]"
110.30 -
110.31 -If you wish your version of this file to be governed by only the CDDL
110.32 -or only the GPL Version 2, indicate your decision by adding
110.33 -"[Contributor] elects to include this software in this distribution
110.34 -under the [CDDL or GPL Version 2] license." If you do not indicate a
110.35 -single choice of license, a recipient has the option to distribute
110.36 -your version of this file under either the CDDL, the GPL Version 2 or
110.37 -to extend the choice of license to its licensees as provided above.
110.38 -However, if you add GPL Version 2 code and therefore, elected the GPL
110.39 -Version 2 license, then the option applies only if the new code is
110.40 -made subject to such option by the copyright holder.
110.41 -
110.42 -Contributor(s):
110.43 --->
110.44 -<configurationDescriptor version="100">
110.45 - <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
110.46 - <df root="." name="0">
110.47 - <df name="src">
110.48 - <in>modernize-loop-convert.cpp</in>
110.49 - <in>modernize-raw-string-literal.cpp</in>
110.50 - <in>modernize-use-nullptr.cpp</in>
110.51 - </df>
110.52 - </df>
110.53 - <logicalFolder name="ExternalFiles"
110.54 - displayName="Important Files"
110.55 - projectFiles="false"
110.56 - kind="IMPORTANT_FILES_FOLDER">
110.57 - <itemPath>CMakeLists.txt</itemPath>
110.58 - <itemPath>build/Debug/Makefile</itemPath>
110.59 - <itemPath>build/Release/Makefile</itemPath>
110.60 - </logicalFolder>
110.61 - </logicalFolder>
110.62 - <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
110.63 - <sourceRootList>
110.64 - <Elem>.</Elem>
110.65 - </sourceRootList>
110.66 - <projectmakefile>build/Debug/Makefile</projectmakefile>
110.67 - <confs>
110.68 - <conf name="Debug" type="0">
110.69 - <toolsSet>
110.70 - <compilerSet>default</compilerSet>
110.71 - <dependencyChecking>false</dependencyChecking>
110.72 - <rebuildPropChanged>false</rebuildPropChanged>
110.73 - </toolsSet>
110.74 - <flagsDictionary>
110.75 - <element flagsID="0" commonFlags="-std=gnu++11"/>
110.76 - </flagsDictionary>
110.77 - <codeAssistance>
110.78 - </codeAssistance>
110.79 - <makefileType>
110.80 - <makeTool>
110.81 - <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
110.82 - <buildCommand>${MAKE} -f Makefile</buildCommand>
110.83 - <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
110.84 - <executablePath>build/Debug/src/welcome</executablePath>
110.85 - <ccTool flags="0">
110.86 - <incDir>
110.87 - <pElem>build/Debug/src</pElem>
110.88 - </incDir>
110.89 - </ccTool>
110.90 - </makeTool>
110.91 - <preBuild>
110.92 - <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
110.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>
110.94 - <preBuildFirst>true</preBuildFirst>
110.95 - </preBuild>
110.96 - </makefileType>
110.97 - <item path="src/modernize-loop-convert.cpp" ex="false" tool="1" flavor2="8">
110.98 - <ccTool flags="0">
110.99 - </ccTool>
110.100 - </item>
110.101 - <item path="src/modernize-raw-string-literal.cpp"
110.102 - ex="false"
110.103 - tool="1"
110.104 - flavor2="8">
110.105 - <ccTool flags="0">
110.106 - </ccTool>
110.107 - </item>
110.108 - <item path="src/modernize-use-nullptr.cpp" ex="false" tool="1" flavor2="8">
110.109 - <ccTool flags="0">
110.110 - </ccTool>
110.111 - </item>
110.112 - </conf>
110.113 - <conf name="Release" type="0">
110.114 - <toolsSet>
110.115 - <compilerSet>default</compilerSet>
110.116 - <dependencyChecking>false</dependencyChecking>
110.117 - <rebuildPropChanged>false</rebuildPropChanged>
110.118 - </toolsSet>
110.119 - <codeAssistance>
110.120 - </codeAssistance>
110.121 - <makefileType>
110.122 - <makeTool>
110.123 - <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
110.124 - <buildCommand>${MAKE} -f Makefile</buildCommand>
110.125 - <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
110.126 - <executablePath>build/Release/src/welcome</executablePath>
110.127 - <ccTool>
110.128 - <incDir>
110.129 - <pElem>build/Release/src</pElem>
110.130 - </incDir>
110.131 - <preprocessorList>
110.132 - <Elem>NDEBUG</Elem>
110.133 - </preprocessorList>
110.134 - </ccTool>
110.135 - </makeTool>
110.136 - <preBuild>
110.137 - <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
110.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>
110.139 - <preBuildFirst>true</preBuildFirst>
110.140 - </preBuild>
110.141 - </makefileType>
110.142 - <item path="src/modernize-use-nullptr.cpp" ex="false" tool="1" flavor2="0">
110.143 - </item>
110.144 - </conf>
110.145 - </confs>
110.146 -</configurationDescriptor>
111.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml Wed Jun 07 18:50:35 2017 +0300
111.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
111.3 @@ -1,72 +0,0 @@
111.4 -<?xml version="1.0" encoding="UTF-8"?>
111.5 -<!--
111.6 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
111.7 -
111.8 -Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
111.9 -
111.10 -Oracle and Java are registered trademarks of Oracle and/or its affiliates.
111.11 -Other names may be trademarks of their respective owners.
111.12 -
111.13 -The contents of this file are subject to the terms of either the GNU
111.14 -General Public License Version 2 only ("GPL") or the Common
111.15 -Development and Distribution License("CDDL") (collectively, the
111.16 -"License"). You may not use this file except in compliance with the
111.17 -License. You can obtain a copy of the License at
111.18 -http://www.netbeans.org/cddl-gplv2.html
111.19 -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
111.20 -specific language governing permissions and limitations under the
111.21 -License. When distributing the software, include this License Header
111.22 -Notice in each file and include the License file at
111.23 -nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
111.24 -particular file as subject to the "Classpath" exception as provided
111.25 -by Oracle in the GPL Version 2 section of the License file that
111.26 -accompanied this code. If applicable, add the following below the
111.27 -License Header, with the fields enclosed by brackets [] replaced by
111.28 -your own identifying information:
111.29 -"Portions Copyrighted [year] [name of copyright owner]"
111.30 -
111.31 -If you wish your version of this file to be governed by only the CDDL
111.32 -or only the GPL Version 2, indicate your decision by adding
111.33 -"[Contributor] elects to include this software in this distribution
111.34 -under the [CDDL or GPL Version 2] license." If you do not indicate a
111.35 -single choice of license, a recipient has the option to distribute
111.36 -your version of this file under either the CDDL, the GPL Version 2 or
111.37 -to extend the choice of license to its licensees as provided above.
111.38 -However, if you add GPL Version 2 code and therefore, elected the GPL
111.39 -Version 2 license, then the option applies only if the new code is
111.40 -made subject to such option by the copyright holder.
111.41 -
111.42 -Contributor(s):
111.43 --->
111.44 -<project xmlns="http://www.netbeans.org/ns/project/1">
111.45 - <type>org.netbeans.modules.cnd.makeproject</type>
111.46 - <configuration>
111.47 - <data xmlns="http://www.netbeans.org/ns/make-project/1">
111.48 - <name>hello-cmake-world</name>
111.49 - <c-extensions/>
111.50 - <cpp-extensions>cpp</cpp-extensions>
111.51 - <header-extensions>h</header-extensions>
111.52 - <sourceEncoding>UTF-8</sourceEncoding>
111.53 - <sourceRootList>
111.54 - <sourceRootElem>.</sourceRootElem>
111.55 - </sourceRootList>
111.56 - <make-dep-projects/>
111.57 - <sourceRootList>
111.58 - <sourceRootElem>.</sourceRootElem>
111.59 - </sourceRootList>
111.60 - <confList>
111.61 - <confElem>
111.62 - <name>Debug</name>
111.63 - <type>0</type>
111.64 - </confElem>
111.65 - <confElem>
111.66 - <name>Release</name>
111.67 - <type>0</type>
111.68 - </confElem>
111.69 - </confList>
111.70 - <formatting>
111.71 - <project-formatting-style>false</project-formatting-style>
111.72 - </formatting>
111.73 - </data>
111.74 - </configuration>
111.75 -</project>
112.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt Wed Jun 07 18:50:35 2017 +0300
112.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
112.3 @@ -1,2 +0,0 @@
112.4 -set(CMAKE_CXX_STANDARD 11)
112.5 -add_library (single-cpp-file-check modernize-use-nullptr.cpp modernize-loop-convert.cpp modernize-raw-string-literal.cpp)
113.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp Wed Jun 07 18:50:35 2017 +0300
113.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
113.3 @@ -1,1 +0,0 @@
113.4 -#include "llvm-header-guard.h"
113.5 \ No newline at end of file
114.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp Wed Jun 07 18:50:35 2017 +0300
114.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
114.3 @@ -1,25 +0,0 @@
114.4 -#include <vector>
114.5 -#include <iostream>
114.6 -
114.7 -using namespace std;
114.8 -
114.9 -int loops() {
114.10 - const int N = 5;
114.11 - int arr[] = {1, 2, 3, 4, 5};
114.12 - vector<int> v;
114.13 - v.push_back(1);
114.14 - v.push_back(2);
114.15 - v.push_back(3);
114.16 -
114.17 - // safe conversion
114.18 - for (int i = 0; i < N; ++i)
114.19 - cout << arr[i];
114.20 -
114.21 - // reasonable conversion
114.22 - for (vector<int>::iterator it = v.begin(); it != v.end(); ++it)
114.23 - cout << *it;
114.24 -
114.25 - // reasonable conversion
114.26 - for (int i = 0; i < v.size(); ++i)
114.27 - cout << v[i];
114.28 -}
114.29 \ No newline at end of file
115.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp Wed Jun 07 18:50:35 2017 +0300
115.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
115.3 @@ -1,8 +0,0 @@
115.4 -const char *const Quotes{"embedded \"quotes\""};
115.5 -const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"};
115.6 -const char *const SingleLine{"Single line.\n"};
115.7 -const char *const TrailingSpace{"Look here -> \n"};
115.8 -const char *const Tab{"One\tTwo\n"};
115.9 -const char *const Bell{"Hello!\a And welcome!"};
115.10 -const char *const Path{"C:\\Program Files\\Vendor\\Application.exe"};
115.11 -const char *const RegEx{"\\w\\([a-z]\\)"};
116.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp Wed Jun 07 18:50:35 2017 +0300
116.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
116.3 @@ -1,11 +0,0 @@
116.4 -#include <cstddef>
116.5 -
116.6 -void assignment() {
116.7 - char *a = NULL;
116.8 - char *b = 0;
116.9 - char c = 0;
116.10 -}
116.11 -
116.12 -int *ret_ptr() {
116.13 - return 0;
116.14 -}
116.15 \ No newline at end of file
117.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/.dep.inc Wed Jun 07 18:50:35 2017 +0300
117.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
117.3 @@ -1,5 +0,0 @@
117.4 -# This code depends on make tool being used
117.5 -DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES}))
117.6 -ifneq (${DEPFILES},)
117.7 -include ${DEPFILES}
117.8 -endif
118.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/Makefile Wed Jun 07 18:50:35 2017 +0300
118.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
118.3 @@ -1,128 +0,0 @@
118.4 -#
118.5 -# There exist several targets which are by default empty and which can be
118.6 -# used for execution of your targets. These targets are usually executed
118.7 -# before and after some main targets. They are:
118.8 -#
118.9 -# .build-pre: called before 'build' target
118.10 -# .build-post: called after 'build' target
118.11 -# .clean-pre: called before 'clean' target
118.12 -# .clean-post: called after 'clean' target
118.13 -# .clobber-pre: called before 'clobber' target
118.14 -# .clobber-post: called after 'clobber' target
118.15 -# .all-pre: called before 'all' target
118.16 -# .all-post: called after 'all' target
118.17 -# .help-pre: called before 'help' target
118.18 -# .help-post: called after 'help' target
118.19 -#
118.20 -# Targets beginning with '.' are not intended to be called on their own.
118.21 -#
118.22 -# Main targets can be executed directly, and they are:
118.23 -#
118.24 -# build build a specific configuration
118.25 -# clean remove built files from a configuration
118.26 -# clobber remove all built files
118.27 -# all build all configurations
118.28 -# help print help mesage
118.29 -#
118.30 -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
118.31 -# .help-impl are implemented in nbproject/makefile-impl.mk.
118.32 -#
118.33 -# Available make variables:
118.34 -#
118.35 -# CND_BASEDIR base directory for relative paths
118.36 -# CND_DISTDIR default top distribution directory (build artifacts)
118.37 -# CND_BUILDDIR default top build directory (object files, ...)
118.38 -# CONF name of current configuration
118.39 -# CND_PLATFORM_${CONF} platform name (current configuration)
118.40 -# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
118.41 -# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
118.42 -# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
118.43 -# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
118.44 -# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
118.45 -# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
118.46 -#
118.47 -# NOCDDL
118.48 -
118.49 -
118.50 -# Environment
118.51 -MKDIR=mkdir
118.52 -CP=cp
118.53 -CCADMIN=CCadmin
118.54 -
118.55 -
118.56 -# build
118.57 -build: .build-post
118.58 -
118.59 -.build-pre:
118.60 -# Add your pre 'build' code here...
118.61 -
118.62 -.build-post: .build-impl
118.63 -# Add your post 'build' code here...
118.64 -
118.65 -
118.66 -# clean
118.67 -clean: .clean-post
118.68 -
118.69 -.clean-pre:
118.70 -# Add your pre 'clean' code here...
118.71 -
118.72 -.clean-post: .clean-impl
118.73 -# Add your post 'clean' code here...
118.74 -
118.75 -
118.76 -# clobber
118.77 -clobber: .clobber-post
118.78 -
118.79 -.clobber-pre:
118.80 -# Add your pre 'clobber' code here...
118.81 -
118.82 -.clobber-post: .clobber-impl
118.83 -# Add your post 'clobber' code here...
118.84 -
118.85 -
118.86 -# all
118.87 -all: .all-post
118.88 -
118.89 -.all-pre:
118.90 -# Add your pre 'all' code here...
118.91 -
118.92 -.all-post: .all-impl
118.93 -# Add your post 'all' code here...
118.94 -
118.95 -
118.96 -# build tests
118.97 -build-tests: .build-tests-post
118.98 -
118.99 -.build-tests-pre:
118.100 -# Add your pre 'build-tests' code here...
118.101 -
118.102 -.build-tests-post: .build-tests-impl
118.103 -# Add your post 'build-tests' code here...
118.104 -
118.105 -
118.106 -# run tests
118.107 -test: .test-post
118.108 -
118.109 -.test-pre: build-tests
118.110 -# Add your pre 'test' code here...
118.111 -
118.112 -.test-post: .test-impl
118.113 -# Add your post 'test' code here...
118.114 -
118.115 -
118.116 -# help
118.117 -help: .help-post
118.118 -
118.119 -.help-pre:
118.120 -# Add your pre 'help' code here...
118.121 -
118.122 -.help-post: .help-impl
118.123 -# Add your post 'help' code here...
118.124 -
118.125 -
118.126 -
118.127 -# include project implementation makefile
118.128 -include nbproject/Makefile-impl.mk
118.129 -
118.130 -# include project make variables
118.131 -include nbproject/Makefile-variables.mk
119.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk Wed Jun 07 18:50:35 2017 +0300
119.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
119.3 @@ -1,83 +0,0 @@
119.4 -#
119.5 -# Generated Makefile - do not edit!
119.6 -#
119.7 -# Edit the Makefile in the project folder instead (../Makefile). Each target
119.8 -# has a -pre and a -post target defined where you can add customized code.
119.9 -#
119.10 -# This makefile implements configuration specific macros and targets.
119.11 -
119.12 -
119.13 -# Environment
119.14 -MKDIR=mkdir
119.15 -CP=cp
119.16 -GREP=grep
119.17 -NM=nm
119.18 -CCADMIN=CCadmin
119.19 -RANLIB=ranlib
119.20 -CC=gcc
119.21 -CCC=g++
119.22 -CXX=g++
119.23 -FC=gfortran
119.24 -AS=as
119.25 -
119.26 -# Macros
119.27 -CND_PLATFORM=GNU-Linux
119.28 -CND_DLIB_EXT=so
119.29 -CND_CONF=Debug
119.30 -CND_DISTDIR=dist
119.31 -CND_BUILDDIR=build
119.32 -
119.33 -# Include project Makefile
119.34 -include Makefile
119.35 -
119.36 -# Object Directory
119.37 -OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
119.38 -
119.39 -# Object Files
119.40 -OBJECTFILES= \
119.41 - ${OBJECTDIR}/welcome.o
119.42 -
119.43 -
119.44 -# C Compiler Flags
119.45 -CFLAGS=
119.46 -
119.47 -# CC Compiler Flags
119.48 -CCFLAGS=
119.49 -CXXFLAGS=
119.50 -
119.51 -# Fortran Compiler Flags
119.52 -FFLAGS=
119.53 -
119.54 -# Assembler Flags
119.55 -ASFLAGS=
119.56 -
119.57 -# Link Libraries and Options
119.58 -LDLIBSOPTIONS=
119.59 -
119.60 -# Build Targets
119.61 -.build-conf: ${BUILD_SUBPROJECTS}
119.62 - "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
119.63 -
119.64 -${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES}
119.65 - ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
119.66 - ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS}
119.67 -
119.68 -${OBJECTDIR}/welcome.o: welcome.cc
119.69 - ${MKDIR} -p ${OBJECTDIR}
119.70 - ${RM} "$@.d"
119.71 - $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc
119.72 -
119.73 -# Subprojects
119.74 -.build-subprojects:
119.75 -
119.76 -# Clean Targets
119.77 -.clean-conf: ${CLEAN_SUBPROJECTS}
119.78 - ${RM} -r ${CND_BUILDDIR}/${CND_CONF}
119.79 -
119.80 -# Subprojects
119.81 -.clean-subprojects:
119.82 -
119.83 -# Enable dependency checking
119.84 -.dep.inc: .depcheck-impl
119.85 -
119.86 -include .dep.inc
120.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk Wed Jun 07 18:50:35 2017 +0300
120.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
120.3 @@ -1,83 +0,0 @@
120.4 -#
120.5 -# Generated Makefile - do not edit!
120.6 -#
120.7 -# Edit the Makefile in the project folder instead (../Makefile). Each target
120.8 -# has a -pre and a -post target defined where you can add customized code.
120.9 -#
120.10 -# This makefile implements configuration specific macros and targets.
120.11 -
120.12 -
120.13 -# Environment
120.14 -MKDIR=mkdir
120.15 -CP=cp
120.16 -GREP=grep
120.17 -NM=nm
120.18 -CCADMIN=CCadmin
120.19 -RANLIB=ranlib
120.20 -CC=gcc
120.21 -CCC=g++
120.22 -CXX=g++
120.23 -FC=gfortran
120.24 -AS=as
120.25 -
120.26 -# Macros
120.27 -CND_PLATFORM=GNU-Linux
120.28 -CND_DLIB_EXT=so
120.29 -CND_CONF=Release
120.30 -CND_DISTDIR=dist
120.31 -CND_BUILDDIR=build
120.32 -
120.33 -# Include project Makefile
120.34 -include Makefile
120.35 -
120.36 -# Object Directory
120.37 -OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
120.38 -
120.39 -# Object Files
120.40 -OBJECTFILES= \
120.41 - ${OBJECTDIR}/welcome.o
120.42 -
120.43 -
120.44 -# C Compiler Flags
120.45 -CFLAGS=
120.46 -
120.47 -# CC Compiler Flags
120.48 -CCFLAGS=
120.49 -CXXFLAGS=
120.50 -
120.51 -# Fortran Compiler Flags
120.52 -FFLAGS=
120.53 -
120.54 -# Assembler Flags
120.55 -ASFLAGS=
120.56 -
120.57 -# Link Libraries and Options
120.58 -LDLIBSOPTIONS=
120.59 -
120.60 -# Build Targets
120.61 -.build-conf: ${BUILD_SUBPROJECTS}
120.62 - "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
120.63 -
120.64 -${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES}
120.65 - ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
120.66 - ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS}
120.67 -
120.68 -${OBJECTDIR}/welcome.o: welcome.cc
120.69 - ${MKDIR} -p ${OBJECTDIR}
120.70 - ${RM} "$@.d"
120.71 - $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc
120.72 -
120.73 -# Subprojects
120.74 -.build-subprojects:
120.75 -
120.76 -# Clean Targets
120.77 -.clean-conf: ${CLEAN_SUBPROJECTS}
120.78 - ${RM} -r ${CND_BUILDDIR}/${CND_CONF}
120.79 -
120.80 -# Subprojects
120.81 -.clean-subprojects:
120.82 -
120.83 -# Enable dependency checking
120.84 -.dep.inc: .depcheck-impl
120.85 -
120.86 -include .dep.inc
121.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk Wed Jun 07 18:50:35 2017 +0300
121.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
121.3 @@ -1,133 +0,0 @@
121.4 -#
121.5 -# Generated Makefile - do not edit!
121.6 -#
121.7 -# Edit the Makefile in the project folder instead (../Makefile). Each target
121.8 -# has a pre- and a post- target defined where you can add customization code.
121.9 -#
121.10 -# This makefile implements macros and targets common to all configurations.
121.11 -#
121.12 -# NOCDDL
121.13 -
121.14 -
121.15 -# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
121.16 -# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
121.17 -# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
121.18 -# and .clean-reqprojects-conf unless SUB has the value 'no'
121.19 -SUB_no=NO
121.20 -SUBPROJECTS=${SUB_${SUB}}
121.21 -BUILD_SUBPROJECTS_=.build-subprojects
121.22 -BUILD_SUBPROJECTS_NO=
121.23 -BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
121.24 -CLEAN_SUBPROJECTS_=.clean-subprojects
121.25 -CLEAN_SUBPROJECTS_NO=
121.26 -CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
121.27 -
121.28 -
121.29 -# Project Name
121.30 -PROJECTNAME=hello-world
121.31 -
121.32 -# Active Configuration
121.33 -DEFAULTCONF=Debug
121.34 -CONF=${DEFAULTCONF}
121.35 -
121.36 -# All Configurations
121.37 -ALLCONFS=Debug Release
121.38 -
121.39 -
121.40 -# build
121.41 -.build-impl: .build-pre .validate-impl .depcheck-impl
121.42 - @#echo "=> Running $@... Configuration=$(CONF)"
121.43 - "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
121.44 -
121.45 -
121.46 -# clean
121.47 -.clean-impl: .clean-pre .validate-impl .depcheck-impl
121.48 - @#echo "=> Running $@... Configuration=$(CONF)"
121.49 - "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
121.50 -
121.51 -
121.52 -# clobber
121.53 -.clobber-impl: .clobber-pre .depcheck-impl
121.54 - @#echo "=> Running $@..."
121.55 - for CONF in ${ALLCONFS}; \
121.56 - do \
121.57 - "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
121.58 - done
121.59 -
121.60 -# all
121.61 -.all-impl: .all-pre .depcheck-impl
121.62 - @#echo "=> Running $@..."
121.63 - for CONF in ${ALLCONFS}; \
121.64 - do \
121.65 - "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
121.66 - done
121.67 -
121.68 -# build tests
121.69 -.build-tests-impl: .build-impl .build-tests-pre
121.70 - @#echo "=> Running $@... Configuration=$(CONF)"
121.71 - "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
121.72 -
121.73 -# run tests
121.74 -.test-impl: .build-tests-impl .test-pre
121.75 - @#echo "=> Running $@... Configuration=$(CONF)"
121.76 - "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
121.77 -
121.78 -# dependency checking support
121.79 -.depcheck-impl:
121.80 - @echo "# This code depends on make tool being used" >.dep.inc
121.81 - @if [ -n "${MAKE_VERSION}" ]; then \
121.82 - echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
121.83 - echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
121.84 - echo "include \$${DEPFILES}" >>.dep.inc; \
121.85 - echo "endif" >>.dep.inc; \
121.86 - else \
121.87 - echo ".KEEP_STATE:" >>.dep.inc; \
121.88 - echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
121.89 - fi
121.90 -
121.91 -# configuration validation
121.92 -.validate-impl:
121.93 - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
121.94 - then \
121.95 - echo ""; \
121.96 - echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
121.97 - echo "See 'make help' for details."; \
121.98 - echo "Current directory: " `pwd`; \
121.99 - echo ""; \
121.100 - fi
121.101 - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
121.102 - then \
121.103 - exit 1; \
121.104 - fi
121.105 -
121.106 -
121.107 -# help
121.108 -.help-impl: .help-pre
121.109 - @echo "This makefile supports the following configurations:"
121.110 - @echo " ${ALLCONFS}"
121.111 - @echo ""
121.112 - @echo "and the following targets:"
121.113 - @echo " build (default target)"
121.114 - @echo " clean"
121.115 - @echo " clobber"
121.116 - @echo " all"
121.117 - @echo " help"
121.118 - @echo ""
121.119 - @echo "Makefile Usage:"
121.120 - @echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
121.121 - @echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
121.122 - @echo " make [SUB=no] clobber"
121.123 - @echo " make [SUB=no] all"
121.124 - @echo " make help"
121.125 - @echo ""
121.126 - @echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
121.127 - @echo " also build subprojects."
121.128 - @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
121.129 - @echo " also clean subprojects."
121.130 - @echo "Target 'clobber' will remove all built files from all configurations and,"
121.131 - @echo " unless 'SUB=no', also from subprojects."
121.132 - @echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
121.133 - @echo " also build subprojects."
121.134 - @echo "Target 'help' prints this message."
121.135 - @echo ""
121.136 -
122.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk Wed Jun 07 18:50:35 2017 +0300
122.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
122.3 @@ -1,35 +0,0 @@
122.4 -#
122.5 -# Generated - do not edit!
122.6 -#
122.7 -# NOCDDL
122.8 -#
122.9 -CND_BASEDIR=`pwd`
122.10 -CND_BUILDDIR=build
122.11 -CND_DISTDIR=dist
122.12 -# Debug configuration
122.13 -CND_PLATFORM_Debug=GNU-Linux
122.14 -CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux
122.15 -CND_ARTIFACT_NAME_Debug=hello-world
122.16 -CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/hello-world
122.17 -CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
122.18 -CND_PACKAGE_NAME_Debug=hello-world.tar
122.19 -CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/hello-world.tar
122.20 -# Release configuration
122.21 -CND_PLATFORM_Release=GNU-Linux
122.22 -CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux
122.23 -CND_ARTIFACT_NAME_Release=hello-world
122.24 -CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/hello-world
122.25 -CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package
122.26 -CND_PACKAGE_NAME_Release=hello-world.tar
122.27 -CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/hello-world.tar
122.28 -#
122.29 -# include compiler specific variables
122.30 -#
122.31 -# dmake command
122.32 -ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
122.33 - (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
122.34 -#
122.35 -# gmake command
122.36 -.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
122.37 -#
122.38 -include nbproject/private/Makefile-variables.mk
123.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash Wed Jun 07 18:50:35 2017 +0300
123.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
123.3 @@ -1,76 +0,0 @@
123.4 -#!/bin/bash -x
123.5 -
123.6 -#
123.7 -# Generated - do not edit!
123.8 -#
123.9 -
123.10 -# Macros
123.11 -TOP=`pwd`
123.12 -CND_PLATFORM=GNU-Linux
123.13 -CND_CONF=Debug
123.14 -CND_DISTDIR=dist
123.15 -CND_BUILDDIR=build
123.16 -CND_DLIB_EXT=so
123.17 -NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
123.18 -TMPDIRNAME=tmp-packaging
123.19 -OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
123.20 -OUTPUT_BASENAME=hello-world
123.21 -PACKAGE_TOP_DIR=hello-world/
123.22 -
123.23 -# Functions
123.24 -function checkReturnCode
123.25 -{
123.26 - rc=$?
123.27 - if [ $rc != 0 ]
123.28 - then
123.29 - exit $rc
123.30 - fi
123.31 -}
123.32 -function makeDirectory
123.33 -# $1 directory path
123.34 -# $2 permission (optional)
123.35 -{
123.36 - mkdir -p "$1"
123.37 - checkReturnCode
123.38 - if [ "$2" != "" ]
123.39 - then
123.40 - chmod $2 "$1"
123.41 - checkReturnCode
123.42 - fi
123.43 -}
123.44 -function copyFileToTmpDir
123.45 -# $1 from-file path
123.46 -# $2 to-file path
123.47 -# $3 permission
123.48 -{
123.49 - cp "$1" "$2"
123.50 - checkReturnCode
123.51 - if [ "$3" != "" ]
123.52 - then
123.53 - chmod $3 "$2"
123.54 - checkReturnCode
123.55 - fi
123.56 -}
123.57 -
123.58 -# Setup
123.59 -cd "${TOP}"
123.60 -mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
123.61 -rm -rf ${NBTMPDIR}
123.62 -mkdir -p ${NBTMPDIR}
123.63 -
123.64 -# Copy files and create directories and links
123.65 -cd "${TOP}"
123.66 -makeDirectory "${NBTMPDIR}/hello-world/bin"
123.67 -copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
123.68 -
123.69 -
123.70 -# Generate tar file
123.71 -cd "${TOP}"
123.72 -rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar
123.73 -cd ${NBTMPDIR}
123.74 -tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar *
123.75 -checkReturnCode
123.76 -
123.77 -# Cleanup
123.78 -cd "${TOP}"
123.79 -rm -rf ${NBTMPDIR}
124.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash Wed Jun 07 18:50:35 2017 +0300
124.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
124.3 @@ -1,76 +0,0 @@
124.4 -#!/bin/bash -x
124.5 -
124.6 -#
124.7 -# Generated - do not edit!
124.8 -#
124.9 -
124.10 -# Macros
124.11 -TOP=`pwd`
124.12 -CND_PLATFORM=GNU-Linux
124.13 -CND_CONF=Release
124.14 -CND_DISTDIR=dist
124.15 -CND_BUILDDIR=build
124.16 -CND_DLIB_EXT=so
124.17 -NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
124.18 -TMPDIRNAME=tmp-packaging
124.19 -OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world
124.20 -OUTPUT_BASENAME=hello-world
124.21 -PACKAGE_TOP_DIR=hello-world/
124.22 -
124.23 -# Functions
124.24 -function checkReturnCode
124.25 -{
124.26 - rc=$?
124.27 - if [ $rc != 0 ]
124.28 - then
124.29 - exit $rc
124.30 - fi
124.31 -}
124.32 -function makeDirectory
124.33 -# $1 directory path
124.34 -# $2 permission (optional)
124.35 -{
124.36 - mkdir -p "$1"
124.37 - checkReturnCode
124.38 - if [ "$2" != "" ]
124.39 - then
124.40 - chmod $2 "$1"
124.41 - checkReturnCode
124.42 - fi
124.43 -}
124.44 -function copyFileToTmpDir
124.45 -# $1 from-file path
124.46 -# $2 to-file path
124.47 -# $3 permission
124.48 -{
124.49 - cp "$1" "$2"
124.50 - checkReturnCode
124.51 - if [ "$3" != "" ]
124.52 - then
124.53 - chmod $3 "$2"
124.54 - checkReturnCode
124.55 - fi
124.56 -}
124.57 -
124.58 -# Setup
124.59 -cd "${TOP}"
124.60 -mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
124.61 -rm -rf ${NBTMPDIR}
124.62 -mkdir -p ${NBTMPDIR}
124.63 -
124.64 -# Copy files and create directories and links
124.65 -cd "${TOP}"
124.66 -makeDirectory "${NBTMPDIR}/hello-world/bin"
124.67 -copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
124.68 -
124.69 -
124.70 -# Generate tar file
124.71 -cd "${TOP}"
124.72 -rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar
124.73 -cd ${NBTMPDIR}
124.74 -tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar *
124.75 -checkReturnCode
124.76 -
124.77 -# Cleanup
124.78 -cd "${TOP}"
124.79 -rm -rf ${NBTMPDIR}
125.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml Wed Jun 07 18:50:35 2017 +0300
125.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
125.3 @@ -1,71 +0,0 @@
125.4 -<?xml version="1.0" encoding="UTF-8"?>
125.5 -<configurationDescriptor version="100">
125.6 - <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
125.7 - <logicalFolder name="HeaderFiles"
125.8 - displayName="Header Files"
125.9 - projectFiles="true">
125.10 - <itemPath>welcome.h</itemPath>
125.11 - </logicalFolder>
125.12 - <logicalFolder name="ResourceFiles"
125.13 - displayName="Resource Files"
125.14 - projectFiles="true">
125.15 - </logicalFolder>
125.16 - <logicalFolder name="SourceFiles"
125.17 - displayName="Source Files"
125.18 - projectFiles="true">
125.19 - <itemPath>welcome.cc</itemPath>
125.20 - </logicalFolder>
125.21 - <logicalFolder name="TestFiles"
125.22 - displayName="Test Files"
125.23 - projectFiles="false"
125.24 - kind="TEST_LOGICAL_FOLDER">
125.25 - </logicalFolder>
125.26 - <logicalFolder name="ExternalFiles"
125.27 - displayName="Important Files"
125.28 - projectFiles="false"
125.29 - kind="IMPORTANT_FILES_FOLDER">
125.30 - <itemPath>Makefile</itemPath>
125.31 - </logicalFolder>
125.32 - </logicalFolder>
125.33 - <projectmakefile>Makefile</projectmakefile>
125.34 - <confs>
125.35 - <conf name="Debug" type="1">
125.36 - <toolsSet>
125.37 - <compilerSet>default</compilerSet>
125.38 - <dependencyChecking>true</dependencyChecking>
125.39 - <rebuildPropChanged>false</rebuildPropChanged>
125.40 - </toolsSet>
125.41 - <compileType>
125.42 - </compileType>
125.43 - <item path="welcome.cc" ex="false" tool="1" flavor2="0">
125.44 - </item>
125.45 - <item path="welcome.h" ex="false" tool="3" flavor2="0">
125.46 - </item>
125.47 - </conf>
125.48 - <conf name="Release" type="1">
125.49 - <toolsSet>
125.50 - <compilerSet>default</compilerSet>
125.51 - <dependencyChecking>true</dependencyChecking>
125.52 - <rebuildPropChanged>false</rebuildPropChanged>
125.53 - </toolsSet>
125.54 - <compileType>
125.55 - <cTool>
125.56 - <developmentMode>5</developmentMode>
125.57 - </cTool>
125.58 - <ccTool>
125.59 - <developmentMode>5</developmentMode>
125.60 - </ccTool>
125.61 - <fortranCompilerTool>
125.62 - <developmentMode>5</developmentMode>
125.63 - </fortranCompilerTool>
125.64 - <asmTool>
125.65 - <developmentMode>5</developmentMode>
125.66 - </asmTool>
125.67 - </compileType>
125.68 - <item path="welcome.cc" ex="false" tool="1" flavor2="0">
125.69 - </item>
125.70 - <item path="welcome.h" ex="false" tool="3" flavor2="0">
125.71 - </item>
125.72 - </conf>
125.73 - </confs>
125.74 -</configurationDescriptor>
126.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml Wed Jun 07 18:50:35 2017 +0300
126.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
126.3 @@ -1,28 +0,0 @@
126.4 -<?xml version="1.0" encoding="UTF-8"?>
126.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
126.6 - <type>org.netbeans.modules.cnd.makeproject</type>
126.7 - <configuration>
126.8 - <data xmlns="http://www.netbeans.org/ns/make-project/1">
126.9 - <name>hello-world2</name>
126.10 - <c-extensions/>
126.11 - <cpp-extensions>cc</cpp-extensions>
126.12 - <header-extensions>h</header-extensions>
126.13 - <sourceEncoding>UTF-8</sourceEncoding>
126.14 - <make-dep-projects/>
126.15 - <sourceRootList/>
126.16 - <confList>
126.17 - <confElem>
126.18 - <name>Debug</name>
126.19 - <type>1</type>
126.20 - </confElem>
126.21 - <confElem>
126.22 - <name>Release</name>
126.23 - <type>1</type>
126.24 - </confElem>
126.25 - </confList>
126.26 - <formatting>
126.27 - <project-formatting-style>false</project-formatting-style>
126.28 - </formatting>
126.29 - </data>
126.30 - </configuration>
126.31 -</project>
127.1 --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/welcome.cc Wed Jun 07 18:50:35 2017 +0300
127.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
127.3 @@ -1,38 +0,0 @@
127.4 -/*
127.5 - * Copyright (c) 2009-2014, Oracle and/or its affiliates. All rights reserved.
127.6 - *
127.7 - * Redistribution and use in source and binary forms, with or without
127.8 - * modification, are permitted provided that the following conditions are met:
127.9 - *
127.10 - * * Redistributions of source code must retain the above copyright notice,
127.11 - * this list of conditions and the following disclaimer.
127.12 - *
127.13 - * * Redistributions in binary form must reproduce the above copyright notice,
127.14 - * this list of conditions and the following disclaimer in the documentation
127.15 - * and/or other materials provided with the distribution.
127.16 - *
127.17 - * * Neither the name of Oracle nor the names of its contributors
127.18 - * may be used to endorse or promote products derived from this software without
127.19 - * specific prior written permission.
127.20 - *
127.21 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
127.22 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
127.23 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
127.24 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
127.25 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
127.26 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
127.27 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
127.28 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
127.29 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
127.30 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
127.31 - * THE POSSIBILITY OF SUCH DAMAGE.
127.32 - */
127.33 -
127.34 -#include <iostream>
127.35 -
127.36 -int main(int argc, char**argv) {
127.37 - // Prints hello message...
127.38 - std::cout << "Hello World!" << std::endl;
127.39 -
127.40 - return 0;
127.41 -}
128.1 --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h Wed Jun 07 18:50:35 2017 +0300
128.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
128.3 @@ -1,3 +0,0 @@
128.4 -#ifndef _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H
128.5 -#define _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H
128.6 -#endif
128.7 \ No newline at end of file
129.1 --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp Wed Jun 07 18:50:35 2017 +0300
129.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
129.3 @@ -1,24 +0,0 @@
129.4 -#include <vector>
129.5 -
129.6 -using namespace std;
129.7 -
129.8 -int loops() {
129.9 - const int N = 5;
129.10 - int arr[] = {1, 2, 3, 4, 5};
129.11 - vector<int> v;
129.12 - v.push_back(1);
129.13 - v.push_back(2);
129.14 - v.push_back(3);
129.15 -
129.16 - // safe conversion
129.17 - for (auto & elem : arr)
129.18 - cout << elem;
129.19 -
129.20 - // reasonable conversion
129.21 - for (auto & elem : v)
129.22 - cout << elem;
129.23 -
129.24 - // reasonable conversion
129.25 - for (auto & elem : v)
129.26 - cout << elem;
129.27 -}
129.28 \ No newline at end of file
130.1 --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp Wed Jun 07 18:50:35 2017 +0300
130.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
130.3 @@ -1,8 +0,0 @@
130.4 -const char *const Quotes{R"(embedded "quotes")"};
130.5 -const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"};
130.6 -const char *const SingleLine{"Single line.\n"};
130.7 -const char *const TrailingSpace{"Look here -> \n"};
130.8 -const char *const Tab{"One\tTwo\n"};
130.9 -const char *const Bell{"Hello!\a And welcome!"};
130.10 -const char *const Path{R"(C:\Program Files\Vendor\Application.exe)"};
130.11 -const char *const RegEx{R"(\w\([a-z]\))"};
130.12 \ No newline at end of file
131.1 --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp Wed Jun 07 18:50:35 2017 +0300
131.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
131.3 @@ -1,11 +0,0 @@
131.4 -#include <cstddef>
131.5 -
131.6 -void assignment() {
131.7 - char *a = nullptr;
131.8 - char *b = nullptr;
131.9 - char c = 0;
131.10 -}
131.11 -
131.12 -int *ret_ptr() {
131.13 - return nullptr;
131.14 -}
131.15 \ No newline at end of file
132.1 --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world.json Wed Jun 07 18:50:35 2017 +0300
132.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
132.3 @@ -1,25 +0,0 @@
132.4 ----
132.5 -MainSourceFile: ''
132.6 -Diagnostics:
132.7 - CheckName: misc-unused-parameters
132.8 - Level: Warning
132.9 - MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
132.10 - MessageFileOffset: 1615
132.11 - Message: 'parameter ''argc'' is unused'
132.12 - Replacements:
132.13 - - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
132.14 - Offset: 1615
132.15 - Length: 4
132.16 - ReplacementText: ' /*argc*/'
132.17 -Diagnostics:
132.18 - CheckName: misc-unused-parameters
132.19 - Level: Warning
132.20 - MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
132.21 - MessageFileOffset: 1627
132.22 - Message: 'parameter ''argv'' is unused'
132.23 - Replacements:
132.24 - - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc
132.25 - Offset: 1627
132.26 - Length: 4
132.27 - ReplacementText: ' /*argv*/'
132.28 -...
132.29 \ No newline at end of file
133.1 --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java Wed Jun 07 18:50:35 2017 +0300
133.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
133.3 @@ -1,62 +0,0 @@
133.4 -package ide.analysis.modernize;
133.5 -
133.6 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
133.7 -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser;
133.8 -import java.io.File;
133.9 -import java.nio.file.Files;
133.10 -import java.util.List;
133.11 -import static junit.framework.TestCase.fail;
133.12 -import org.netbeans.modules.cnd.test.CndCoreTestUtils;
133.13 -import static org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestCase.createTempFile;
133.14 -import org.openide.cookies.EditorCookie;
133.15 -import org.openide.filesystems.FileObject;
133.16 -import org.openide.filesystems.FileUtil;
133.17 -import org.openide.loaders.DataObject;
133.18 -
133.19 -/*
133.20 - * To change this license header, choose License Headers in Project Properties.
133.21 - * To change this template file, choose Tools | Templates
133.22 - * and open the template in the editor.
133.23 - */
133.24 -/**
133.25 - *
133.26 - * @author Ilia Gromov
133.27 - */
133.28 -public class HeaderTest extends TidyTestCase {
133.29 -
133.30 - private final String source = "src/llvm-header-guard.cpp";
133.31 - private final String header = "src/llvm-header-guard.h";
133.32 -
133.33 - public HeaderTest() {
133.34 - super("project-with-headers");
133.35 - }
133.36 -
133.37 - public void testLlvmHeaderGuard() {
133.38 - performTest(source, "llvm-header-guard", true);
133.39 - }
133.40 -
133.41 - @Override
133.42 - protected void processTestResults(List<ModernizeFix> fixes, String footerName) throws Exception {
133.43 - for (ModernizeFix fix : fixes) {
133.44 - fix.implement();
133.45 -
133.46 - for (YamlParser.Replacement replacement : fix.getReplacements()) {
133.47 - FileObject fo = FileUtil.toFileObject(new File(replacement.filePath));
133.48 -
133.49 - DataObject dObj = DataObject.find(fo);
133.50 - EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class);
133.51 - ec.saveDocument();
133.52 - }
133.53 - }
133.54 -
133.55 - File diffFile = createTempFile("diff", null, false);
133.56 -
133.57 - boolean diff = CndCoreTestUtils.diff(new File(FileUtil.toFile(getProjectDir()), header), getGoldenFile(header), diffFile);
133.58 -
133.59 - if (diff) {
133.60 - byte[] readAllBytes = Files.readAllBytes(diffFile.toPath());
133.61 - System.err.println(new String(readAllBytes));
133.62 - fail();
133.63 - }
133.64 - }
133.65 -}
134.1 --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java Wed Jun 07 18:50:35 2017 +0300
134.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
134.3 @@ -1,44 +0,0 @@
134.4 -/*
134.5 - * To change this license header, choose License Headers in Project Properties.
134.6 - * To change this template file, choose Tools | Templates
134.7 - * and open the template in the editor.
134.8 - */
134.9 -package ide.analysis.modernize;
134.10 -
134.11 -import javax.swing.text.Document;
134.12 -import org.netbeans.modules.cnd.api.model.CsmFile;
134.13 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
134.14 -
134.15 -/**
134.16 - *
134.17 - * @author Ilia Gromov
134.18 - */
134.19 -class RequestImpl implements CsmErrorProvider.Request {
134.20 -
134.21 - private final CsmFile csmFile;
134.22 -
134.23 - public RequestImpl(CsmFile csmFile) {
134.24 - this.csmFile = csmFile;
134.25 - }
134.26 -
134.27 - @Override
134.28 - public CsmFile getFile() {
134.29 - return csmFile;
134.30 - }
134.31 -
134.32 - @Override
134.33 - public boolean isCancelled() {
134.34 - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
134.35 - }
134.36 -
134.37 - @Override
134.38 - public Document getDocument() {
134.39 - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
134.40 - }
134.41 -
134.42 - @Override
134.43 - public CsmErrorProvider.EditorEvent getEvent() {
134.44 - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
134.45 - }
134.46 -
134.47 -}
135.1 --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java Wed Jun 07 18:50:35 2017 +0300
135.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
135.3 @@ -1,46 +0,0 @@
135.4 -/*
135.5 - * To change this license header, choose License Headers in Project Properties.
135.6 - * To change this template file, choose Tools | Templates
135.7 - * and open the template in the editor.
135.8 - */
135.9 -package ide.analysis.modernize;
135.10 -
135.11 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeErrorInfo;
135.12 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
135.13 -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser;
135.14 -import java.util.List;
135.15 -import junit.framework.TestCase;
135.16 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
135.17 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
135.18 -import org.openide.util.Exceptions;
135.19 -
135.20 -/**
135.21 - *
135.22 - * @author Ilia Gromov
135.23 - */
135.24 -class ResponseImpl implements CsmErrorProvider.Response {
135.25 -
135.26 - private final List<ModernizeFix> fixes;
135.27 -
135.28 - public ResponseImpl(List<ModernizeFix> fixes) {
135.29 - this.fixes = fixes;
135.30 - }
135.31 -
135.32 - @Override
135.33 - public void addError(CsmErrorInfo info) {
135.34 - try {
135.35 - TestCase.assertTrue(info instanceof ModernizeErrorInfo);
135.36 - final List<YamlParser.Replacement> replacements = ((ModernizeErrorInfo) info).getDiagnostics().getReplacements();
135.37 - final String id = ((ModernizeErrorInfo) info).getId();
135.38 - ModernizeFix fix = new ModernizeFix(replacements, id);
135.39 - fixes.add(fix);
135.40 - } catch (Exception ex) {
135.41 - Exceptions.printStackTrace(ex);
135.42 - }
135.43 - }
135.44 -
135.45 - @Override
135.46 - public void done() {
135.47 - }
135.48 -
135.49 -}
136.1 --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java Wed Jun 07 18:50:35 2017 +0300
136.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
136.3 @@ -1,64 +0,0 @@
136.4 -package ide.analysis.modernize;
136.5 -
136.6 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
136.7 -import java.io.File;
136.8 -import java.nio.file.Files;
136.9 -import java.util.List;
136.10 -import org.junit.Test;
136.11 -import org.netbeans.modules.cnd.test.CndCoreTestUtils;
136.12 -import org.openide.cookies.EditorCookie;
136.13 -import org.openide.filesystems.FileObject;
136.14 -import org.openide.filesystems.FileUtil;
136.15 -import org.openide.loaders.DataObject;
136.16 -
136.17 -/**
136.18 - *
136.19 - * @author Ilia Gromov
136.20 - */
136.21 -public class SingleCppFileCheckTest extends TidyTestCase {
136.22 -
136.23 - public SingleCppFileCheckTest() {
136.24 - super("hello-cmake-world");
136.25 - }
136.26 -
136.27 - @Override
136.28 - protected void setUp() throws Exception {
136.29 - super.setUp();
136.30 - }
136.31 -
136.32 - public void testModernizeUseNullptr() {
136.33 - performTest("src/modernize-use-nullptr.cpp", "modernize-use-nullptr", true);
136.34 - }
136.35 -
136.36 - public void testModernizeLoopConvert() {
136.37 - performTest("src/modernize-loop-convert.cpp", "modernize-loop-convert", true);
136.38 - }
136.39 -
136.40 - @Test
136.41 - public void testModernizeRawStringLiteral() {
136.42 - performTest("src/modernize-raw-string-literal.cpp", "modernize-raw-string-literal", true);
136.43 - }
136.44 -
136.45 - @Override
136.46 - protected void processTestResults(List<ModernizeFix> fixes, String startFileName) throws Exception {
136.47 - for (ModernizeFix fix : fixes) {
136.48 - fix.implement();
136.49 - }
136.50 -
136.51 - FileObject footer = getSourceFile(startFileName);
136.52 -
136.53 - DataObject dObj = DataObject.find(footer);
136.54 - EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class);
136.55 - ec.saveDocument();
136.56 -
136.57 - File diffFile = createTempFile("diff", null, false);
136.58 -
136.59 - boolean diff = CndCoreTestUtils.diff(FileUtil.toFile(footer), getGoldenFile(startFileName), diffFile);
136.60 -
136.61 - if (diff) {
136.62 - byte[] readAllBytes = Files.readAllBytes(diffFile.toPath());
136.63 - System.err.println(new String(readAllBytes));
136.64 - fail();
136.65 - }
136.66 - }
136.67 -}
137.1 --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java Wed Jun 07 18:50:35 2017 +0300
137.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
137.3 @@ -1,237 +0,0 @@
137.4 -/*
137.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
137.6 - *
137.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
137.8 - *
137.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
137.10 - * Other names may be trademarks of their respective owners.
137.11 - *
137.12 - * The contents of this file are subject to the terms of either the GNU
137.13 - * General Public License Version 2 only ("GPL") or the Common
137.14 - * Development and Distribution License("CDDL") (collectively, the
137.15 - * "License"). You may not use this file except in compliance with the
137.16 - * License. You can obtain a copy of the License at
137.17 - * http://www.netbeans.org/cddl-gplv2.html
137.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
137.19 - * specific language governing permissions and limitations under the
137.20 - * License. When distributing the software, include this License Header
137.21 - * Notice in each file and include the License file at
137.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
137.23 - * particular file as subject to the "Classpath" exception as provided
137.24 - * by Oracle in the GPL Version 2 section of the License file that
137.25 - * accompanied this code. If applicable, add the following below the
137.26 - * License Header, with the fields enclosed by brackets [] replaced by
137.27 - * your own identifying information:
137.28 - * "Portions Copyrighted [year] [name of copyright owner]"
137.29 - *
137.30 - * If you wish your version of this file to be governed by only the CDDL
137.31 - * or only the GPL Version 2, indicate your decision by adding
137.32 - * "[Contributor] elects to include this software in this distribution
137.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
137.34 - * single choice of license, a recipient has the option to distribute
137.35 - * your version of this file under either the CDDL, the GPL Version 2 or
137.36 - * to extend the choice of license to its licensees as provided above.
137.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
137.38 - * Version 2 license, then the option applies only if the new code is
137.39 - * made subject to such option by the copyright holder.
137.40 - *
137.41 - * Contributor(s):
137.42 - *
137.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
137.44 - */
137.45 -package ide.analysis.modernize;
137.46 -
137.47 -import org.netbeans.modules.ide.analysis.modernize.impl.DiagnosticsTool;
137.48 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl;
137.49 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix;
137.50 -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser;
137.51 -import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools;
137.52 -import java.io.File;
137.53 -import java.nio.file.Files;
137.54 -import java.nio.file.attribute.PosixFilePermissions;
137.55 -import java.util.ArrayList;
137.56 -import java.util.Arrays;
137.57 -import java.util.Collection;
137.58 -import java.util.Collections;
137.59 -import java.util.List;
137.60 -import java.util.logging.ConsoleHandler;
137.61 -import java.util.logging.Level;
137.62 -import java.util.logging.LogManager;
137.63 -import java.util.prefs.Preferences;
137.64 -import org.netbeans.api.progress.ProgressHandle;
137.65 -import org.netbeans.api.project.Project;
137.66 -import org.netbeans.api.project.ProjectManager;
137.67 -import org.netbeans.api.project.ui.OpenProjects;
137.68 -import org.netbeans.modules.analysis.SPIAccessor;
137.69 -import org.netbeans.modules.analysis.spi.Analyzer;
137.70 -import org.netbeans.modules.cnd.api.model.CsmFile;
137.71 -import org.netbeans.modules.cnd.api.model.CsmModel;
137.72 -import org.netbeans.modules.cnd.api.model.CsmModelAccessor;
137.73 -import org.netbeans.modules.cnd.api.model.CsmProject;
137.74 -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences;
137.75 -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit;
137.76 -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
137.77 -import org.netbeans.modules.cnd.api.project.NativeProject;
137.78 -import org.netbeans.modules.cnd.api.project.NativeProjectRegistry;
137.79 -import org.netbeans.modules.cnd.api.toolchain.CompilerSet;
137.80 -import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager;
137.81 -import org.netbeans.modules.cnd.makeproject.api.MakeProject;
137.82 -import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
137.83 -import org.netbeans.modules.cnd.modelutil.CsmUtilities;
137.84 -import org.netbeans.modules.cnd.test.CndBaseTestCase;
137.85 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
137.86 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
137.87 -import org.netbeans.modules.refactoring.api.Scope;
137.88 -import org.openide.filesystems.FileObject;
137.89 -import org.openide.filesystems.FileUtil;
137.90 -import org.openide.util.Exceptions;
137.91 -
137.92 -/**
137.93 - *
137.94 - * @author Ilia Gromov
137.95 - */
137.96 -public abstract class TidyTestCase extends CndBaseTestCase {
137.97 -
137.98 - private final String projectName;
137.99 -
137.100 - private List<FileObject> fileObjects;
137.101 - private MakeProject project;
137.102 - private FileObject projectDirFileObject;
137.103 -
137.104 - private final String CLANG_TIDY_PATH = "clang-tidy-3.9p";
137.105 -
137.106 - public TidyTestCase(String projectName) {
137.107 - super(projectName);
137.108 -
137.109 - this.projectName = projectName;
137.110 - }
137.111 -
137.112 - protected static CodeAudit findAudit(Collection<CodeAudit> audits, String id) {
137.113 - for (CodeAudit audit : audits) {
137.114 - if (audit.getID().equals(id)) {
137.115 - return audit;
137.116 - }
137.117 - }
137.118 - return null;
137.119 - }
137.120 -
137.121 - @Override
137.122 - protected void setUp() throws Exception {
137.123 - super.setUp();
137.124 - LogManager.getLogManager().reset();
137.125 -
137.126 - java.util.logging.Logger LOG = java.util.logging.Logger.getLogger("ide.analysis.tidy");
137.127 - LOG.setLevel(Level.ALL);
137.128 -
137.129 - ConsoleHandler consoleHandler = new ConsoleHandler();
137.130 - consoleHandler.setLevel(Level.ALL);
137.131 - LOG.addHandler(consoleHandler);
137.132 -
137.133 - File clangTidyFile = getBinaryFile();
137.134 - Files.setPosixFilePermissions(clangTidyFile.toPath(), PosixFilePermissions.fromString("rwxrwxrwx"));
137.135 -
137.136 - assertTrue(getBinaryFile().exists());
137.137 -
137.138 - File projectDirFile = getDataFile(projectName);
137.139 - projectDirFileObject = FileUtil.toFileObject(projectDirFile);
137.140 -
137.141 - fileObjects = new ArrayList<FileObject>();
137.142 -
137.143 - project = (MakeProject) ProjectManager.getDefault().findProject(projectDirFileObject);
137.144 -
137.145 - OpenProjects.getDefault().open(new Project[]{project}, false);
137.146 - while (!OpenProjects.getDefault().isProjectOpen(project)) {
137.147 - try {
137.148 - Thread.sleep(100);
137.149 - } catch (InterruptedException ex) {
137.150 - Exceptions.printStackTrace(ex);
137.151 - }
137.152 - }
137.153 -
137.154 - CsmModel model = CsmModelAccessor.getModel();
137.155 - assertNotNull(project);
137.156 -
137.157 - NativeProject np = project.getLookup().lookup(NativeProject.class);
137.158 - NativeProjectRegistry.getDefault().register(np);
137.159 - model.enableProject(np);
137.160 - assertNotNull(np);
137.161 -
137.162 - CsmProject csmProject = model.getProject(np);
137.163 - assertNotNull(csmProject);
137.164 -
137.165 - csmProject.waitParse();
137.166 -
137.167 - }
137.168 -
137.169 - public ExecutionEnvironment getExecEnv() {
137.170 - ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
137.171 - return execEnv;
137.172 - }
137.173 -
137.174 - public CompilerSet getCompilerSet() {
137.175 - CompilerSetManager csm = CompilerSetManager.get(getExecEnv());
137.176 - return csm.getDefaultCompilerSet();
137.177 - }
137.178 -
137.179 - public MakeProject getProject() {
137.180 - return project;
137.181 - }
137.182 -
137.183 - public FileObject getProjectDir() {
137.184 - return projectDirFileObject;
137.185 - }
137.186 -
137.187 - public FileObject getSourceFile(String name) {
137.188 - return FileUtil.toFileObject(new File(FileUtil.toFile(getProjectDir()), name));
137.189 - }
137.190 -
137.191 - public File getBinaryFile() {
137.192 - return new File(getDataDir(), CLANG_TIDY_PATH);
137.193 - }
137.194 -
137.195 - protected final void performTest(String startFileName, String checkName, boolean isStartFile) {
137.196 - try {
137.197 - FileObject startFile = getSourceFile(startFileName);
137.198 - assertTrue(startFile.isValid());
137.199 -
137.200 - Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{startFile}));
137.201 - Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0);
137.202 - Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl();
137.203 -
137.204 - ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context);
137.205 - ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
137.206 - final CsmFile csmFile = CsmUtilities.getCsmFile(startFile, true, false);
137.207 - Item item = AnalyticsTools.findItem(csmFile, getProject());
137.208 -
137.209 - Collection<CodeAudit> audits = DiagnosticsTool.getAudits(getBinaryFile().getAbsolutePath(), execEnv, new AuditPreferences(Preferences.userNodeForPackage(this.getClass())));
137.210 - CodeAudit audit = findAudit(audits, checkName);
137.211 - assertNotNull(audit);
137.212 -
137.213 - // ----- BEGIN diagnostics -----
137.214 - DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath());
137.215 -
137.216 - int exitCode = diagnosticsTool.process(Collections.singleton(audit.getID()), csmFile, true);
137.217 - if (exitCode != DiagnosticsTool.STATUS_OK) {
137.218 - fail();
137.219 - }
137.220 -
137.221 - List<YamlParser.Diagnostics> diags = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString());
137.222 - List<ModernizeFix> fixes = new ArrayList<ModernizeFix>();
137.223 -
137.224 - CsmErrorProvider.Request request = new RequestImpl(csmFile);
137.225 - CsmErrorProvider.Response response = new ResponseImpl(fixes);
137.226 -
137.227 - analyzer.getErrorProvider(null).postProcess(false, csmFile, getProject(), diags, request, response);
137.228 - // ----- END diagnostics -----
137.229 -
137.230 - processTestResults(fixes, startFileName);
137.231 - } catch (Exception ex) {
137.232 - ex.printStackTrace(System.err);
137.233 - fail(ex.toString());
137.234 - }
137.235 - }
137.236 -
137.237 - protected void processTestResults(List<ModernizeFix> fixes, String startFileName) throws Exception {
137.238 -
137.239 - }
137.240 -}
138.1 --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java Wed Jun 07 18:50:35 2017 +0300
138.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
138.3 @@ -1,117 +0,0 @@
138.4 -/*
138.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
138.6 - *
138.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
138.8 - *
138.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
138.10 - * Other names may be trademarks of their respective owners.
138.11 - *
138.12 - * The contents of this file are subject to the terms of either the GNU
138.13 - * General Public License Version 2 only ("GPL") or the Common
138.14 - * Development and Distribution License("CDDL") (collectively, the
138.15 - * "License"). You may not use this file except in compliance with the
138.16 - * License. You can obtain a copy of the License at
138.17 - * http://www.netbeans.org/cddl-gplv2.html
138.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
138.19 - * specific language governing permissions and limitations under the
138.20 - * License. When distributing the software, include this License Header
138.21 - * Notice in each file and include the License file at
138.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
138.23 - * particular file as subject to the "Classpath" exception as provided
138.24 - * by Oracle in the GPL Version 2 section of the License file that
138.25 - * accompanied this code. If applicable, add the following below the
138.26 - * License Header, with the fields enclosed by brackets [] replaced by
138.27 - * your own identifying information:
138.28 - * "Portions Copyrighted [year] [name of copyright owner]"
138.29 - *
138.30 - * If you wish your version of this file to be governed by only the CDDL
138.31 - * or only the GPL Version 2, indicate your decision by adding
138.32 - * "[Contributor] elects to include this software in this distribution
138.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
138.34 - * single choice of license, a recipient has the option to distribute
138.35 - * your version of this file under either the CDDL, the GPL Version 2 or
138.36 - * to extend the choice of license to its licensees as provided above.
138.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
138.38 - * Version 2 license, then the option applies only if the new code is
138.39 - * made subject to such option by the copyright holder.
138.40 - *
138.41 - * Contributor(s):
138.42 - *
138.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
138.44 - */
138.45 -package ide.analysis.modernize;
138.46 -
138.47 -import org.netbeans.modules.ide.analysis.modernize.impl.DiagnosticsTool;
138.48 -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl;
138.49 -import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools;
138.50 -import java.io.File;
138.51 -import java.io.IOException;
138.52 -import java.nio.file.Files;
138.53 -import java.util.Arrays;
138.54 -import java.util.Collections;
138.55 -import org.junit.Test;
138.56 -import org.netbeans.api.progress.ProgressHandle;
138.57 -import org.netbeans.modules.analysis.SPIAccessor;
138.58 -import org.netbeans.modules.analysis.spi.Analyzer;
138.59 -import org.netbeans.modules.cnd.api.model.CsmFile;
138.60 -import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
138.61 -import org.netbeans.modules.cnd.modelutil.CsmUtilities;
138.62 -import org.netbeans.modules.cnd.test.CndCoreTestUtils;
138.63 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
138.64 -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
138.65 -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
138.66 -import org.netbeans.modules.refactoring.api.Scope;
138.67 -import org.openide.filesystems.FileObject;
138.68 -
138.69 -/**
138.70 - *
138.71 - * @author Ilia Gromov
138.72 - */
138.73 -public class YamlTest extends TidyTestCase {
138.74 -
138.75 - public YamlTest() {
138.76 - super("hello-world");
138.77 - }
138.78 -
138.79 - @Test
138.80 - public void testYaml() throws IOException, ConnectionManager.CancellationException {
138.81 - FileObject singleFileObject = getSourceFile("welcome.cc");
138.82 -
138.83 - File goldenFile = getGoldenFile("hello-world.json");
138.84 - String goldenYaml = new String(Files.readAllBytes(goldenFile.toPath()), "UTF-8").replaceAll("\\$path", getDataDir().getAbsolutePath());
138.85 -
138.86 - Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{singleFileObject}));
138.87 - Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0);
138.88 -
138.89 - Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl();
138.90 - ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context);
138.91 -
138.92 - ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal();
138.93 -
138.94 - CsmFile csmFile = CsmUtilities.getCsmFile(singleFileObject, false, false);
138.95 - Item item = AnalyticsTools.findItem(csmFile, getProject());
138.96 -
138.97 - DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath());
138.98 -
138.99 - int exitCode = diagnosticsTool.process(Collections.singleton("*"), csmFile, true);
138.100 -
138.101 - if (exitCode != DiagnosticsTool.STATUS_OK) {
138.102 - fail();
138.103 - }
138.104 - String yamlAsString = diagnosticsTool.getYamlAsString();
138.105 -
138.106 - File real = File.createTempFile("test", null);
138.107 - Files.write(real.toPath(), yamlAsString.getBytes());
138.108 -
138.109 - File expected = File.createTempFile("test", null);
138.110 - Files.write(expected.toPath(), goldenYaml.getBytes());
138.111 -
138.112 - File diff = File.createTempFile("test", null);
138.113 - if (CndCoreTestUtils.diff(real, expected, diff)) {
138.114 - System.err.println("============DIFF============");
138.115 - System.err.println(new String(Files.readAllBytes(diff.toPath()), "UTF-8"));
138.116 - System.err.println("============DIFF============");
138.117 - fail();
138.118 - }
138.119 - }
138.120 -}