# HG changeset patch # User Julien Enselme # Date 1498407905 -7200 # Node ID 47444533169ef0016b20fe116535c84a94519b69 # Parent 1520ed2e78e3bd0aa7f8694ef872804fb115e08a# Parent 853976f2c6166dbb19b482e2247ec824b7183371 Automated merge with https://hg.netbeans.org/main/contrib diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/build.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.tools.ide.analysis.modernize. + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/l10n.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/l10n.list Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +src/**/Bundle.properties + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/license.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/license.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,565 @@ +NetBeans IDE Dual License Header and License Notice + +Oracle elects to use only the GNU Lesser General Public License version 2.1 +(LGPL) for any software where a choice of LGPL/GPL license versions are made +available with the language indicating that LGPLv2.1/GPLv2 or any later version +may be used, or where a choice of which version of the LGPL/GPL is applied is +unspecified. +For more information on the license please see: the NetBeans License FAQs. + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + +1. Definitions. +1.1. "Contributor" means each individual or entity that creates or contributes +to the creation of Modifications. +1.2. "Contributor Version" means the combination of the Original Software, +prior Modifications used by a Contributor (if any), and the Modifications made +by that particular Contributor. +1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, +or (c) the combination of files containing Original Software with files +containing Modifications, in each case including portions thereof. +1.4. "Executable" means the Covered Software in any form other than Source Code. +1.5. "Initial Developer" means the individual or entity that first makes +Original Software available under this License. +1.6. "Larger Work" means a work which combines Covered Software or portions +thereof with code not governed by the terms of this License. +1.7. "License" means this document. +1.8. "Licensable" means having the right to grant, to the maximum extent +possible, whether at the time of the initial grant or subsequently acquired, +any and all of the rights conveyed herein. +1.9 "Modifications" means the Source Code and Executable form of any of the +following: +A. Any file that results from an addition to, deletion from or modification of +the contents of a file containing Original Software or previous Modifications; +B. Any new file that contains any part of the Original Software or previous +Modification; or +C. Any new file that is contributed or otherwise made available under the terms +of this License. +1.10. "Original Software" means the Source Code and Executable form of computer +software code that is originally released under this License. +1.11. "Patent Claims" means any patent claim(s), now owned or hereafter +acquired, including without limitation, method, process, and apparatus claims, +in any patent Licensable by grantor. +1.12. "Source Code" means (a) the common form of computer software code in +which modifications are made and (b) associated documentation included in or +with such code. +1.13. "You" (or "Your") means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal +entities, "You" includes any entity which controls, is controlled by, or is +under common control with You. For purposes of this definition, "control" means +(a) the power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (b) ownership of more than fifty +percent (50%) of the outstanding shares or beneficial ownership of such entity. +2. License Grants. +2.1. The Initial Developer Grant. +Conditioned upon Your compliance with Section 3.1 below and subject to third +party intellectual property claims, the Initial Developer hereby grants You a +world-wide, royalty-free, non-exclusive license: +(a) under intellectual property rights (other than patent or trademark) +Licensable by Initial Developer, to use, reproduce, modify, display, perform, +sublicense and distribute the Original Software (or portions thereof), with or +without Modifications, and/or as part of a Larger Work; and +(b) under Patent Claims infringed by the making, using or selling of Original +Software, to make, have made, use, practice, sell, and offer for sale, and/or +otherwise dispose of the Original Software (or portions thereof). +(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date +Initial Developer first distributes or otherwise makes the Original Software +available to a third party under the terms of this License. +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for +code that You delete from the Original Software, or (2) for infringements +caused by: (i) the modification of the Original Software, or (ii) the +combination of the Original Software with other software or devices. +2.2. Contributor Grant. +Conditioned upon Your compliance with Section 3.1 below and subject to third +party intellectual property claims, each Contributor hereby grants You a +world-wide, royalty-free, non-exclusive license: +(a) under intellectual property rights (other than patent or trademark) +Licensable by Contributor to use, reproduce, modify, display, perform, +sublicense and distribute the Modifications created by such Contributor (or +portions thereof), either on an unmodified basis, with other Modifications, as +Covered Software and/or as part of a Larger Work; and +(b) under Patent Claims infringed by the making, using, or selling of +Modifications made by that Contributor either alone and/or in combination with +its Contributor Version (or portions of such combination), to make, use, sell, +offer for sale, have made, and/or otherwise dispose of: (1) Modifications made +by that Contributor (or portions thereof); and (2) the combination of +Modifications made by that Contributor with its Contributor Version (or +portions of such combination). +(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the +date Contributor first distributes or otherwise makes the Modifications +available to a third party. +(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for +any code that Contributor has deleted from the Contributor Version; (2) for +infringements caused by: (i) third party modifications of Contributor Version, +or (ii) the combination of Modifications made by that Contributor with other +software (except as part of the Contributor Version) or other devices; or (3) +under Patent Claims infringed by Covered Software in the absence of +Modifications made by that Contributor. +3. Distribution Obligations. +3.1. Availability of Source Code. +Any Covered Software that You distribute or otherwise make available in +Executable form must also be made available in Source Code form and that Source +Code form must be distributed only under the terms of this License. You must +include a copy of this License with every copy of the Source Code form of the +Covered Software You distribute or otherwise make available. You must inform +recipients of any such Covered Software in Executable form as to how they can +obtain such Covered Software in Source Code form in a reasonable manner on or +through a medium customarily used for software exchange. +3.2. Modifications. +The Modifications that You create or to which You contribute are governed by +the terms of this License. You represent that You believe Your Modifications +are Your original creation(s) and/or You have sufficient rights to grant the +rights conveyed by this License. +3.3. Required Notices. +You must include a notice in each of Your Modifications that identifies You as +the Contributor of the Modification. You may not remove or alter any copyright, +patent or trademark notices contained within the Covered Software, or any +notices of licensing or any descriptive text giving attribution to any +Contributor or the Initial Developer. +3.4. Application of Additional Terms. +You may not offer or impose any terms on any Covered Software in Source Code +form that alters or restricts the applicable version of this License or the +recipients� rights hereunder. You may choose to offer, and to charge a fee +for, warranty, support, indemnity or liability obligations to one or more +recipients of Covered Software. However, you may do so only on Your own behalf, +and not on behalf of the Initial Developer or any Contributor. You must make it +absolutely clear that any such warranty, support, indemnity or liability +obligation is offered by You alone, and You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of warranty, support, +indemnity or liability terms You offer. +3.5. Distribution of Executable Versions. +You may distribute the Executable form of the Covered Software under the terms +of this License or under the terms of a license of Your choice, which may +contain terms different from this License, provided that You are in compliance +with the terms of this License and that the license for the Executable form +does not attempt to limit or alter the recipient�s rights in the Source Code +form from the rights set forth in this License. If You distribute the Covered +Software in Executable form under a different license, You must make it +absolutely clear that any terms which differ from this License are offered by +You alone, not by the Initial Developer or Contributor. You hereby agree to +indemnify the Initial Developer and every Contributor for any liability +incurred by the Initial Developer or such Contributor as a result of any such +terms You offer. +3.6. Larger Works. +You may create a Larger Work by combining Covered Software with other code not +governed by the terms of this License and distribute the Larger Work as a +single product. In such a case, You must make sure the requirements of this +License are fulfilled for the Covered Software. +4. Versions of the License. +4.1. New Versions. +Oracle Corp. is the initial license steward and may publish revised and/or new +versions of this License from time to time. Each version will be given a +distinguishing version number. Except as provided in Section 4.3, no one other +than the license steward has the right to modify this License. +4.2. Effect of New Versions. +You may always continue to use, distribute or otherwise make the Covered +Software available under the terms of the version of the License under which +You originally received the Covered Software. If the Initial Developer includes +a notice in the Original Software prohibiting it from being distributed or +otherwise made available under any subsequent version of the License, You must +distribute and make the Covered Software available under the terms of the +version of the License under which You originally received the Covered +Software. Otherwise, You may also choose to use, distribute or otherwise make +the Covered Software available under the terms of any subsequent version of the +License published by the license steward. +4.3. Modified Versions. +When You are an Initial Developer and You want to create a new license for Your +Original Software, You may create and use a modified version of this License if +You: (a) rename the license and remove any references to the name of the +license steward (except to note that the license differs from this License); +and (b) otherwise make it clear that the license contains terms which differ +from this License. +5. DISCLAIMER OF WARRANTY. +COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, +MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK +AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD +ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL +DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, +REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART +OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT +UNDER THIS DISCLAIMER. +6. TERMINATION. +6.1. This License and the rights granted hereunder will terminate automatically +if You fail to comply with terms herein and fail to cure such breach within 30 +days of becoming aware of the breach. Provisions which, by their nature, must +remain in effect beyond the termination of this License shall survive. +6.2. If You assert a patent infringement claim (excluding declaratory judgment +actions) against Initial Developer or a Contributor (the Initial Developer or +Contributor against whom You assert such claim is referred to as "Participant") +alleging that the Participant Software (meaning the Contributor Version where +the Participant is a Contributor or the Original Software where the Participant +is the Initial Developer) directly or indirectly infringes any patent, then any +and all rights granted directly or indirectly to You by such Participant, the +Initial Developer (if the Initial Developer is not the Participant) and all +Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days +notice from Participant terminate prospectively and automatically at the +expiration of such 60 day notice period, unless if within such 60 day period +You withdraw Your claim with respect to the Participant Software against such +Participant either unilaterally or pursuant to a written agreement with +Participant. +6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user +licenses that have been validly granted by You or any distributor hereunder +prior to termination (excluding licenses granted to You by any distributor) +shall survive termination. +7. LIMITATION OF LIABILITY. +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING +NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY +OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF +ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, +INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT +LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN +IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS +LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL +INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW +PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR +LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND +LIMITATION MAY NOT APPLY TO YOU. +8. U.S. GOVERNMENT END USERS. +The Covered Software is a "commercial item," as that term is defined in 48 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that +term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer +software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. +1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through +227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software +with only those rights set forth herein. This U.S. Government Rights clause is +in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision +that addresses Government rights in computer software under this License. +9. MISCELLANEOUS. +This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it +enforceable. This License shall be governed by the law of the jurisdiction +specified in a notice contained within the Original Software (except to the +extent applicable law, if any, provides otherwise), excluding such +jurisdiction�s conflict-of-law provisions. Any litigation relating to this +License shall be subject to the jurisdiction of the courts located in the +jurisdiction and venue specified in a notice contained within the Original +Software, with the losing party responsible for costs, including, without +limitation, court costs and reasonable attorneys� fees and expenses. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any law or regulation which provides that +the language of a contract shall be construed against the drafter shall not +apply to this License. You agree that You alone are responsible for compliance +with the United States export administration regulations (and the export +control laws and regulation of any other countries) when You use, distribute or +otherwise make available any Covered Software. +10. RESPONSIBILITY FOR CLAIMS. +As between Initial Developer and the Contributors, each party is responsible +for claims and damages arising, directly or indirectly, out of its utilization +of rights under this License and You agree to work with Initial Developer and +Contributors to distribute such responsibility on an equitable basis. Nothing +herein is intended or shall be deemed to constitute any admission of liability. +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE +(CDDL) +The code released under the CDDL shall be governed by the laws of the State of +California (excluding conflict-of-law provisions). Any litigation relating to +this License shall be subject to the jurisdiction of the Federal Courts of the +Northern District of California and the state courts of the State of +California, with venue lying in Santa Clara County, California. +The GNU General Public License (GPL) Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite +330, Boston, MA 02111-1307 USA +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. +Preamble +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to most +of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom to +distribute copies of free software (and charge for this service if you wish), +that you receive source code or can get it if you want it, that you can change +the software or use pieces of it in new free programs; and that you know you +can do these things. +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must make +sure that they, too, receive or can get the source code. And you must show them +these terms so they know their rights. +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. +Finally, any free program is threatened constantly by software patents. We wish +to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. +The precise terms and conditions for copying, distribution and modification +follow. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is included without +limitation in the term "modification".) Each licensee is addressed as "you". +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is not +restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. +You may charge a fee for the physical act of transferring a copy, and you may +at your option offer warranty protection in exchange for a fee. +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all of +these conditions: +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. +b) You must cause any work that you distribute or publish, that in whole or in +part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. +c) If the modified program normally reads commands interactively when run, you +must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under these +conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print +such an announcement, your work based on the Program is not required to print +an announcement.) +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, and +its terms, do not apply to those sections when you distribute them as separate +works. But when you distribute the same sections as part of a whole which is a +work based on the Program, the distribution of the whole must be on the terms +of this License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based on +the Program. +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and +2 above provided that you also do one of the following: +a) Accompany it with the complete corresponding machine-readable source code, +which must be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange; or, +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all the +source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so +long as such parties remain in full compliance. +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not +accept this License. Therefore, by modifying or distributing the Program (or +any work based on the Program), you indicate your acceptance of this License to +do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to +copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of the +rights granted herein. You are not responsible for enforcing compliance by +third parties to this License. +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose that +choice. +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In such +case, this License incorporates the limitation as if written in the body of +this License. +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems +or concerns. +Each version is given a distinguishing version number. If the Program specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that +version or of any later version published by the Free Software Foundation. If +the Program does not specify a version number of this License, you may choose +any version ever published by the Free Software Foundation. +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of +all derivatives of our free software and of promoting the sharing and reuse of +software generally. +NO WARRANTY +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU +ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA +BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. +One line to give the program's name and a brief idea of what it does. +Copyright (C) +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +Also add information on how to contact you by electronic and paper mail. +If the program is interactive, make it output a short notice like this when it +starts in an interactive mode: +Gnomovision version 69, Copyright (C) year name of author +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This +is free software, and you are welcome to redistribute it under certain +conditions; type `show c' for details. +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here is +a sample; alter the names: +Yoyodyne, Inc., hereby disclaims all copyright interest in the program +`Gnomovision' (which makes passes at compilers) written by James Hacker. +signature of Ty Coon, 1 April 1989 +Ty Coon, President of Vice +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may consider +it more useful to permit linking proprietary applications with the library. If +this is what you want to do, use the GNU Library General Public License instead +of this License. +"CLASSPATH" EXCEPTION TO THE GPL VERSION 2 +Certain source files distributed by Oracle America, Inc. and/or its affiliates +are subject to the following clarification and special exception to the GPLv2, +based on the GNU Project exception for its Classpath libraries, known as the +GNU Classpath Exception, but only where Oracle has expressly included in the +particular source file's header the words "Oracle designates this particular +file as subject to the "Classpath" exception as provided by Oracle in the +LICENSE file that accompanied this code." +You should also note that Oracle includes multiple, independent programs in +this software package. Some of those programs are provided under licenses +deemed incompatible with the GPLv2 by the Free Software Foundation and others. +For example, the package includes programs licensed under the Apache License, +Version 2.0. Such programs are licensed to you under their original licenses. +Oracle facilitates your further distribution of this package by adding the +Classpath Exception to the necessary parts of its GPLv2 code, which permits you +to use that code in combination with other independent modules not licensed +under the GPLv2. However, note that this would not permit you to commingle code +under an incompatible license with Oracle's GPLv2 licensed code by, for +example, cutting and pasting such code into a file also containing Oracle's +GPLv2 licensed code and then distributing the result. +Additionally, if you were to remove the Classpath Exception from any of the +files to which it applies and distribute the result, you would likely be +required to license some or all of the other code in that distribution under +the GPLv2 as well, and since the GPLv2 is incompatible with the license terms +of some items included in the distribution by Oracle, removing the Classpath +Exception could therefore effectively compromise your ability to further +distribute the package. +Proceed with caution and we recommend that you obtain the advice of a lawyer +skilled in open source matters before removing the Classpath Exception or +making modifications to this package which may subsequently be redistributed +and/or involve the use of third party software. +CLASSPATH EXCEPTION +Linking this library statically or dynamically with other modules is making a +combined work based on this library. Thus, the terms and conditions of the GNU +General Public License version 2 cover the whole combination. +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent modules, and +to copy and distribute the resulting executable under terms of your choice, +provided that you also meet, for each linked independent module, the terms and +conditions of the license of that module. An independent module is a module +which is not derived from or based on this library. If you modify this library, +you may extend this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this exception +statement from your version. diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/manifest.mf Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: true +OpenIDE-Module: com.sun.tools.ide.analysis.modernize +OpenIDE-Module-Layer: com/sun/tools/ide/analysis/modernize/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/tools/ide/analysis/modernize/Bundle.properties +OpenIDE-Module-Specification-Version: 1.1.2 diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/nbproject/project.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,15 @@ +javac.source=1.8 +javac.compilerargs=-Xlint -Xlint:-serial + +license.file=license.txt +nbm.module.author=Ilia Gromov +nbm.needs.restart=true +test.unit.cp.extra=../../cnd.modelimpl/build/test/unit/classes:\ +../../cnd/build/test/unit/classes:\ +../../dlight.nativeexecution/build/test/unit/classes:\ +../../editor.mimelookup/build/test/unit/classes:\ +../../cnd.classview/build/test/unit/classes +keystore=nbproject/private/keystore +nbm_alias=myself + +test.unit.run.cp.extra=../../editor.mimelookup/build/test/unit/classes diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/nbproject/project.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,334 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.tools.ide.analysis.modernize + + + org.netbeans.api.progress + + + + 1 + 1.46.1 + + + + org.netbeans.api.progress.nb + + + + 1.46.1 + + + + org.netbeans.modules.cnd.analysis.api + + + + 1.3.1 + + + + org.netbeans.modules.cnd.api.model + + + + 1 + 1.13.1.1 + + + + org.netbeans.modules.cnd.api.project + + + + 1 + 1.31.4 + + + + org.netbeans.modules.cnd.api.remote + + + + 1 + 1.22.2 + + + + org.netbeans.modules.cnd.kit + + 1.30.5.1 + + + + org.netbeans.modules.cnd.makeproject + + + + 2 + 1.15.0.1 + + + + org.netbeans.modules.cnd.model.services + + + + 1 + 1.42.16 + + + + org.netbeans.modules.cnd.modelutil + + + + 1 + 1.14.0.1 + + + + org.netbeans.modules.cnd.toolchain + + + + 1.5.0.1 + + + + org.netbeans.modules.cnd.utils + + + + 1.17.1 + + + + org.netbeans.modules.cnd.utils.ui + + + + 1.0 + + + + org.netbeans.modules.code.analysis + + + + 0 + 1.8 + + + + org.netbeans.modules.dlight.nativeexecution + + + + 1.10.3 + + + + org.netbeans.modules.dlight.remote + + + + 1.28.7.1 + + + + org.netbeans.modules.dlight.remote.ui + + + + 1.1.0 + + + + org.netbeans.modules.editor.document + + + + 1.6.0.1 + + + + org.netbeans.modules.editor.lib + + + + 3 + 4.3.1.22.1.44 + + + + org.netbeans.modules.options.api + + + + 1 + 1.22 + + + + org.netbeans.modules.projectapi + + + + 1 + 1.36 + + + + org.netbeans.modules.refactoring.api + + + + 1.47.1.1 + + + + org.netbeans.spi.editor.hints + + + + 0-1 + 1.18.0.7.9 + + + + org.openide.awt + + + + 7.31 + + + + org.openide.filesystems + + + + 9.8.1 + + + + org.openide.filesystems.nb + + + + 9.7.1 + + + + org.openide.loaders + + + + 7.61 + + + + org.openide.modules + + + + 7.47.1 + + + + org.openide.text + + + + 6.66.1 + + + + org.openide.util + + + + 9.3 + + + + org.openide.util.lookup + + + + 8.23 + + + + org.openide.util.ui + + + + 9.3 + + + + org.openide.windows + + + + 6.74.1 + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.cnd.classview + + + + org.netbeans.modules.cnd.kit + + + + + + org.netbeans.modules.cnd.makeproject + + + + + + org.netbeans.modules.cnd.modelimpl + + + + + + org.netbeans.modules.editor.mimelookup + + + + + + org.netbeans.modules.nbjunit + + + + + org.netbeans.modules.projectapi.nb + + + + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/Bundle.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,8 @@ +OpenIDE-Module-Display-Category=Analysis tools +OpenIDE-Module-Long-Description=\ + This plugin enables clang-tidy analysis on C/C++ projects and files via Source->Inspect or right in the Editor.\n\ + Works only with "Clang-tidy wrapper for " plugin.\n\n\ + Please note that in order to have clang-tidy hints in the Editor you should run Source->Inspect on your whole project.\n\ + You can view list of checks and enable/disable them in Options->Editor->Hints. +OpenIDE-Module-Name=Clang-tidy integration +OpenIDE-Module-Short-Description=Clang-tidy analyzer integration diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/AnalyzedFiles.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/AnalyzedFiles.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,114 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.netbeans.modules.cnd.api.model.CsmFile; + +/** + * This cache is designed to help Editor showing correct checks for included + * files. + * + * @param + */ +public class AnalyzedFiles { + + private final Map> hierarchyCache = new HashMap>(); +// private final Map> diagnosticsCache = new HashMap>(); + +// public void cacheDiagnostics(FileObject fo, CsmErrorInfo info) { +// Set alreadyMapped = diagnosticsCache.get(fo); +// +// if (alreadyMapped == null) { +// alreadyMapped = new HashSet(); +// diagnosticsCache.put(fo, alreadyMapped); +// } +// +// alreadyMapped.add(info); +// } + public void cacheHierarchy(CsmFile startFile, Collection includedFiles) { + Set alreadyMapped = hierarchyCache.get(startFile); + + if (alreadyMapped == null) { + alreadyMapped = new HashSet(); + hierarchyCache.put(startFile, alreadyMapped); + } + + alreadyMapped.addAll(includedFiles); + } + +// public Set getDiagnostics(FileObject fo) { +// return diagnosticsCache.get(fo); +// } + + public Collection getStartFiles(CsmFile includedFile) { + Set result = new HashSet(); + for (Map.Entry> entry : hierarchyCache.entrySet()) { + CsmFile key = entry.getKey(); + Set value = entry.getValue(); + + if (value.contains(includedFile)) { + result.add(key); + } + } + return result; + } + + public boolean isStartFile(CsmFile file) { + return hierarchyCache.containsKey(file); + } + + public void clear() { + hierarchyCache.clear(); + } + + public static AnalyzedFiles getDefault() { + return HOLDER.INSTANCE; + } + + private static class HOLDER { + + public static final AnalyzedFiles INSTANCE = new AnalyzedFiles(); + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/AnalyzerResponseMerger.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/AnalyzerResponseMerger.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,105 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl.ModernizeResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; +import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse; +import org.netbeans.spi.editor.hints.ErrorDescription; +import org.openide.filesystems.FileObject; + +/** + * + * @author Ilia Gromov + */ +public class AnalyzerResponseMerger { + + private static class ErrorDesc { + + final ModernizeErrorInfo info; + final FileObject fo; + + public ErrorDesc(ModernizeErrorInfo info, FileObject fo) { + this.info = info; + this.fo = fo; + } + + public boolean isSame(ErrorDesc o2) { + return isSame(this.info, o2.info) && this.fo.equals(o2.fo); + } + + public boolean isSame(ModernizeErrorInfo o1, ModernizeErrorInfo o2) { + return o1.getStartOffset() == o2.getStartOffset() + && o1.getEndOffset() == o2.getEndOffset() + && o1.getDiagnostics().getCheckName().equals(o2.getDiagnostics().getCheckName()); + } + } + + private final List errors = new ArrayList<>(); + private final ModernizeResponse delegate; + + public AnalyzerResponseMerger(ModernizeResponse delegate) { + this.delegate = delegate; + } + + public void addError(ModernizeErrorInfo info, FileObject fo) { + ErrorDesc errorDesc = new ErrorDesc(info, fo); + Optional found = errors.stream() + .filter(o1 -> o1.isSame(errorDesc)) + .findAny(); + + if (found.isPresent()) { + found.get().info.addMessageInfixes(errorDesc.info.getMessageInfixes()); + } else { + errors.add(errorDesc); + } + } + + public List done() { + return errors.stream() + .map(error -> delegate.addErrorImpl(error.info, error.fo)) + .collect(Collectors.toList()); + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/Bundle.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,59 @@ +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this +# particular file as subject to the "Classpath" exception as provided +# by Sun in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# Contributor(s): +# +# The Original Software is NetBeans. The Initial Developer of the Original +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun +# Microsystems, Inc. All Rights Reserved. +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. +# + +LBL_ProviderName=C/C++ Errors +LBL_ProviderDescription=C/C++ errors and warnings + +#Previse errors +Modernize_NAME=Clang-Tidy analyzer +Modernize_DESCRIPTION=Show warnings identified by clang-tidy.\ +
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. \ +
Expand the node to specify which static checks you want to be displayed. +DisableHint=Configure clang-tidy analyzer - {0} + +#internal error +tool.error=Oracle Developer Studio compilers not found +remote.mode.error=Unsupported remote mode +remote.mode.error.info=Mode {0} +temporary.file.error=Cannot create temporary file +compile.file.error=Clang-tidy was unable to analyze file +fatal.analyze.error=Clang-tidy was unable to analyze file +compile.file.error.info=Exit code: {0} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ConfigureHintsFix.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ConfigureHintsFix.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,80 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import org.netbeans.api.options.OptionsDisplayer; +import org.netbeans.spi.editor.hints.ChangeInfo; +import org.netbeans.spi.editor.hints.EnhancedFix; +import org.openide.util.NbBundle; + +class ConfigureHintsFix implements EnhancedFix { + + private final ModernizeErrorInfo error; + private final String text; + + ConfigureHintsFix(ModernizeErrorInfo error) { + this.error = error; + String id = error.getId(); + this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N + } + + @Override + public String getText() { + return NbBundle.getMessage(ModernizeErrorProvider.class, "DisableHint", text); // NOI18N + } + + @Override + public ChangeInfo implement() throws Exception { + String provider = ModernizeErrorProvider.NAME; + String name = error.getId(); + OptionsDisplayer.getDefault().open("Editor/Hints/text/x-cnd+sourcefile/" + provider + "/" + name); // NOI18N + return null; + } + + @Override + public CharSequence getSortText() { + //Hint opening options dialog should always be the lastest in offered list + return Integer.toString(Integer.MAX_VALUE); + } + + public ModernizeErrorInfo getError() { + return error; + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/CsmResponseMerger.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/CsmResponseMerger.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,87 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; + +/** + * + * @author Ilia Gromov + */ +public class CsmResponseMerger implements CsmErrorProvider.Response { + + private final List bag = new ArrayList<>(); + private final CsmErrorProvider.Response delegate; + + public CsmResponseMerger(CsmErrorProvider.Response delegate) { + this.delegate = delegate; + } + + @Override + public void addError(CsmErrorInfo errorInfo) { + ModernizeErrorInfo o2 = (ModernizeErrorInfo) errorInfo; + Optional found = bag.stream() + .filter(o1 -> isSame(o1, o2)) + .findAny(); + + if (found.isPresent()) { + found.get().addMessageInfixes(o2.getMessageInfixes()); + } else { + bag.add(o2); + } + } + + @Override + public void done() { + bag.forEach(delegate::addError); + delegate.done(); + bag.clear(); + } + + public boolean isSame(ModernizeErrorInfo o1, ModernizeErrorInfo o2) { + return o1.getStartOffset() == o2.getStartOffset() + && o1.getEndOffset() == o2.getEndOffset() + && o1.getDiagnostics().getCheckName().equals(o2.getDiagnostics().getCheckName()); + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/DiagnosticsTool.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/DiagnosticsTool.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,307 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; +import org.netbeans.modules.cnd.api.toolchain.AbstractCompiler; +import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCCompiler; +import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCompiler; +import org.netbeans.modules.cnd.api.toolchain.Tool; +import org.netbeans.modules.cnd.makeproject.api.MakeProject; +import org.netbeans.modules.cnd.makeproject.api.configurations.CCCCompilerConfiguration; +import org.netbeans.modules.cnd.makeproject.api.configurations.CCCompilerConfiguration; +import org.netbeans.modules.cnd.makeproject.api.configurations.CCompilerConfiguration; +import org.netbeans.modules.cnd.makeproject.api.configurations.Item; +import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration; +import org.netbeans.modules.cnd.makeproject.api.support.MakeProjectOptionsFormat; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.netbeans.modules.nativeexecution.api.HostInfo; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; +import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * + * @author Ilia Gromov + */ +public class DiagnosticsTool { + + public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N + public static final String CACHE_ID = "TIDY-CACHE"; //NOI18N + + public static final int STATUS_OK = 0; + public static final int STATUS_IO_ERROR = -1; + + public static List getAudits(String path, ExecutionEnvironment env, AuditPreferences preferences) { + List res = new ArrayList<>(); + + ProcessUtils.ExitStatus status = ProcessUtils.execute(env, path, new String[]{"-checks=*", "-list-checks", "dummy", "--"}); // NOI18N + + if (status.exitCode == 0) { + String out = status.getOutputString(); + out = out.substring(status.getOutputString().indexOf('\n') + 1); + String[] checks = out.split("\n"); // NOI18N + + FileObject disabledChecksFolder = FileUtil.getConfigFile("Analysis/Clang-Tidy/Disabled_Default"); // NOI18N + + List disabledChecks = new ArrayList<>(); + for (FileObject fileObject : disabledChecksFolder.getChildren()) { + disabledChecks.add(fileObject.getName()); + } + + for (String check : checks) { + check = check.trim(); + ModernizeCodeAudit myCodeAudit = new ModernizeCodeAudit( + check, + check, + check, + "warning", //NOI18N + !disabledChecks.contains(check), + preferences); + res.add(myCodeAudit); + } + } + + return res; + } + + private final ExecutionEnvironment execEnv; + private final Item item; + private final MakeProject project; + private final String binaryPath; + + private StringBuilder buf; + + public DiagnosticsTool(ExecutionEnvironment execEnv, Item item, MakeProject project, String binaryPath) { + this.execEnv = execEnv; + this.item = item; + this.project = project; + this.binaryPath = binaryPath; + } + + /** + * @return clang-tidy's exit code or negative code if some other problem has + * occurred. + */ + public int process(Collection checks, CsmFile csmFile, boolean isStartFile) throws ConnectionManager.CancellationException, IOException { + // TODO: can we split analyzer (Source -> Inspect) ant editor error providing? + + final String directoryMacro = "xDIRx"; //NOI18N + + File tmpDir = null; + try { + List args = new ArrayList(); + + HostInfo hostInfo = HostInfoUtils.getHostInfo(execEnv); + + try { + if (execEnv.isRemote()) { + tmpDir = Files.createTempDirectory(hostInfo.getTempDirFile().toPath(), "tidy").toFile(); //NOI18N + } else { + tmpDir = Files.createTempDirectory("tidy").toFile(); //NOI18N + } + } catch (IOException ex) { + return -1; + } + + Path tmpFile = Files.createTempFile(tmpDir.toPath(), null, null); + + args.add("-header-filter=.*"); //NOI18N + StringBuilder sb = new StringBuilder("-checks=");// NOI18N + for (String check : checks) { + sb.append(check); + sb.append(","); // NOI18N + } + args.add(sb.toString().substring(0, sb.length() - 1)); + + args.add("-export-fixes=" + tmpFile); // NOI18N + int directoryIdx = args.size() - 1; + + Collection startFiles = Collections.EMPTY_LIST; + args.add(csmFile.getFileObject().getPath()); + + args.add("--"); //NOI18N + args.addAll(getAdditionalFlags(csmFile)); + + List copy = new ArrayList(args); + + copy.set(directoryIdx, copy.get(directoryIdx).replace(directoryMacro, tmpDir.getAbsolutePath())); + + // TODO: execute in the ${WORKING_DIR} ? Because we can have relative path includes (-Isrc/libs/abcd) + ProcessUtils.ExitStatus executeStatus = ProcessUtils.executeInDir(tmpDir.getAbsolutePath(), + execEnv, + binaryPath, + copy.toArray(new String[copy.size()])); + + if (executeStatus.exitCode != STATUS_OK) { + LOG.log(Level.INFO, "clang-tidy exit code {0}: {1}", new Object[]{executeStatus.exitCode, arrayAsString(binaryPath, copy)}); + LOG.fine(executeStatus.getOutputString()); + LOG.fine(executeStatus.getErrorString()); + return executeStatus.exitCode; + } else { + LOG.log(Level.FINEST, "{0}", arrayAsString(binaryPath, copy)); + LOG.finest(executeStatus.getOutputString()); + LOG.finest(executeStatus.getErrorString()); + } + + File[] listFiles = tmpDir.listFiles(); + + if (listFiles.length != 1) { + return STATUS_IO_ERROR; + } + + File yamlFile = listFiles[0]; + + BufferedReader in = new BufferedReader(new FileReader(yamlFile)); + buf = new StringBuilder(); + while (true) { + String s = in.readLine(); + if (s == null) { + break; + } + buf.append(s).append('\n'); //NOI18N + } + + } finally { + try { + tmpDir.delete(); + } catch (Exception x) { + + } + } + + return STATUS_OK; + } + + private List getAdditionalFlags(CsmFile csmFile) { + List all = new ArrayList(); + + Tool tool = AnalyticsTools.compiler(item, project); + + if (tool instanceof AbstractCompiler) { + AbstractCompiler compiler = (AbstractCompiler) tool; + + for (String systemIncludeDirectory : compiler.getSystemIncludeDirectories()) { + all.add("-I" + systemIncludeDirectory); //NOI18N + } + + MakeConfiguration activeConfiguration = AnalyticsTools.getConfigurationDescriptor(csmFile, project).getActiveConfiguration(); + + String options = ""; +// // compileSingleUnmanage as reference +// // don't use getAllOptions - we need not -w flag + if (tool.getKind() == CCCompiler) { + CCCompilerConfiguration ccc = activeConfiguration.getCCCompilerConfiguration(); + options += ccc.getPreprocessorOptions(compiler.getCompilerSet()); + options += ccc.getIncludeDirectoriesOptions(compiler.getCompilerSet()); +// options += getLibrariesFlags(); + options += compiler.getCppStandardOptions(ccc.getInheritedCppStandard()); + if (!options.contains("-std=")) { //NOI18N + switch (item.getLanguageFlavor()) { + case CPP98: + options += " -std=c++98"; //NOI18N + break; + case CPP11: + options += " -std=c++11"; //NOI18N + break; + case CPP14: + options += " -std=c++14"; //NOI18N + break; + } + } + } else if (tool.getKind() == CCompiler) { + CCompilerConfiguration cc = activeConfiguration.getCCompilerConfiguration(); + options += cc.getPreprocessorOptions(compiler.getCompilerSet()); + options += cc.getIncludeDirectoriesOptions(compiler.getCompilerSet()); + options += compiler.getCStandardOptions(cc.getInheritedCStandard()); + if (!options.contains("-std=")) { //NOI18N + switch (item.getLanguageFlavor()) { + case C11: + options += " -std=c11"; //NOI18N + break; + case C89: + options += " -std=c89"; //NOI18N + break; + case C99: + options += " -std=c99"; //NOI18N + break; + } + } + } + + List optionsList = AnalyticsTools.scanCommandLine(MakeProjectOptionsFormat.reformatWhitespaces(options)); + all.addAll(optionsList); + } + + return all; + } + + public String getYamlAsString() { + if (buf == null) { + throw new IllegalStateException(); + } + return buf.toString(); + } + + private static String arrayAsString(String binary, List list) { + StringBuilder sb = new StringBuilder(binary).append(" "); //NOI18N + for (String string : list) { + sb.append(string).append(" "); //NOI18N + } + return sb.toString(); + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,227 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import com.sun.tools.ide.analysis.modernize.options.ClangAnalyzerOptions; +import com.sun.tools.ide.analysis.modernize.resources.BundleUtilities; +import java.io.CharConversionException; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.prefs.Preferences; +import org.netbeans.modules.analysis.spi.Analyzer; +import org.netbeans.modules.cnd.analysis.api.AbstractAnalyzer; +import org.netbeans.modules.cnd.analysis.api.AbstractHintsPanel; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; +import org.netbeans.modules.cnd.modelutil.CsmUtilities; +import org.netbeans.modules.cnd.utils.CndPathUtilities; +import org.netbeans.spi.editor.hints.ErrorDescription; +import org.netbeans.spi.editor.hints.ErrorDescriptionFactory; +import org.netbeans.spi.editor.hints.LazyFixList; +import org.netbeans.spi.editor.hints.Severity; +import org.openide.filesystems.FileObject; +import org.openide.util.ImageUtilities; +import org.openide.util.NbBundle; +import org.openide.util.lookup.ServiceProvider; +import org.openide.xml.XMLUtil; + +public class ModernizeAnalyzerImpl extends AbstractAnalyzer { + + private static final String PREFIX = "tidy-"; //NOI18N + + private ModernizeErrorProvider currentErrorProvider; + + private ModernizeAnalyzerImpl(Context ctx) { + super(ctx); + } + + @Override + public ModernizeErrorProvider getErrorProvider(Preferences preferences) { + return ModernizeErrorProvider.getInstance(); + } + + @Override + protected boolean isCompileUnitBased() { + return true; + } + + @Override + protected Collection done() { + if (currentErrorProvider != null) { + Collection results = currentErrorProvider.done(); + currentErrorProvider = null; + return results; + } + return Collections.emptyList(); + } + + @Override + protected Collection doRunImpl(final FileObject sr, final Context ctx, final CsmErrorProvider provider, final AtomicBoolean cancel) { + final CsmFile csmFile = CsmUtilities.getCsmFile(sr, false, false); + if (csmFile == null) { + return Collections.emptyList(); + } + CsmErrorProvider.Request request = new RequestImpl(csmFile, ctx, cancel); + final ArrayList res = new ArrayList<>(); + CsmErrorProvider.Response response = new ModernizeResponse(sr, res, cancel); + this.currentErrorProvider = (ModernizeErrorProvider) provider; + provider.getErrors(request, response); + return res; + } + + protected static class ModernizeResponse extends AbstractResponse { + + public ModernizeResponse(FileObject sr, ArrayList res, AtomicBoolean cancel) { + super(sr, res, cancel); + } + + @Override + public ErrorDescription addErrorImpl(CsmErrorInfo errorInfo, FileObject fo) { + String messages[] = errorInfo.getMessage().split("\n"); //NOI18N + if (messages.length > 0) { + StringBuilder sb = new StringBuilder(); + if (errorInfo instanceof ModernizeErrorInfo) { + ModernizeErrorInfo mei = (ModernizeErrorInfo) errorInfo; + sb.append("
"); //NOI18N
+                    sb.append("["); //NOI18N
+                    sb.append(mei.getId());
+                    sb.append("]"); //NOI18N
+                    sb.append("\n"); //NOI18N
+                    List replacements = mei.getDiagnostics().getReplacements();
+                    if (replacements.isEmpty()) {
+                        sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), mei.getDiagnostics().getMessageFilePath())).append(" "); //NOI18N
+                        sb.append(mei.getDiagnostics().getMessageFileOffset()).append("\n");
+                    } else {
+                        for (YamlParser.Replacement replacement : replacements) {
+                            sb.append("\n"); //NOI18N
+                            sb.append("Replacement: "); //NOI18N
+                            sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), replacement.filePath)).append(" "); //NOI18N
+                            sb.append(replacement.offset).append("-").append(replacement.offset + replacement.length).append("\n"); //NOI18N
+                            String attributeValue = replacement.replacementText;
+                            try {
+                                attributeValue = XMLUtil.toAttributeValue(replacement.replacementText);
+                            } catch (CharConversionException ex) {
+                            }
+                            sb.append(attributeValue).append("\n"); //NOI18N
+                        }
+                    }
+                    sb.append(mei.getMessage());
+                    sb.append("
"); //NOI18N + + LazyFixList list = new LazyFixListImpl(); + + return ErrorDescriptionFactory.createErrorDescription(PREFIX + mei.getId(), Severity.valueOf(mei.getSeverity().toString().toUpperCase()), + messages[0], sb.toString(), list, fo, errorInfo.getStartOffset(), errorInfo.getStartOffset()); + } + } + return null; + } + } + + @ServiceProvider(service = AnalyzerFactory.class) + public static final class AnalyzerFactoryImpl extends AnalyzerFactory { + + public AnalyzerFactoryImpl() { + super(ModernizeErrorProvider.NAME, + NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"), //NOI18N + ImageUtilities.loadImage("com/sun/tools/ide/analysis/modernize/impl/bugs.png")); //NOI18N + } + + @Override + public Iterable getWarnings() { + List result = new ArrayList<>(); + final ModernizeErrorProvider provider = ModernizeErrorProvider.getInstance(); + for (CodeAudit audit : provider.getAudits()) { + result.add(WarningDescription.create(PREFIX + audit.getID(), audit.getName(), ModernizeErrorProvider.NAME, provider.getDisplayName())); + } + String[] fatals = BundleUtilities.getFatalErrors(); + for (String id : fatals) { //NOI18N + if (!id.isEmpty()) { + result.add(WarningDescription.create(PREFIX + id, BundleUtilities.getDescription(id), ModernizeErrorProvider.NAME, provider.getDisplayName())); + } + } + return result; + } + + @Override + public CustomizerProvider getCustomizerProvider() { + return new CustomizerProvider() { + + @Override + public Void initialize() { + return null; + } + + @Override + public AbstractHintsPanel createComponent(CustomizerContext context) { + return AbstractAnalyzer.createComponent(ModernizeErrorProvider.getInstance()); + } + }; + } + + @Override + public Collection requiredPlugins(Context context) { +// ExecutionEnvironment env = detectEnvironment(context); +// if (env == null) { +// env = ExecutionEnvironmentFactory.getLocal(); +// } + String installedTool = ClangAnalyzerOptions.getClangAnalyzerPath(); + if (installedTool == null || !new File(installedTool).exists()) { + String codeBase = ClangAnalyzerOptions.getMissingModuleName(); + if (codeBase != null) { + return Arrays.asList(new MissingPlugin(codeBase, NbBundle.getMessage(ModernizeAnalyzerImpl.class, "Modernize_NAME"))); //NOI18N + } + } + return Collections.emptyList(); + } + + @Override + public Analyzer createAnalyzer(Context context) { + return new ModernizeAnalyzerImpl(context); + } + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeCodeAudit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeCodeAudit.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,120 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit; +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; + +final class ModernizeCodeAudit extends AbstractCodeAudit { + + private final String id; + private final String name; + private final String description; + private final String defaultSeverity; + private final boolean defaultEnabled; + private final AuditPreferences myPreferences; + + public ModernizeCodeAudit(String id, String name, String description, String defaultSeverity, boolean defaultEnabled, AuditPreferences myPreferences) { + super(id, name, description, defaultSeverity, defaultEnabled, myPreferences); + this.id = id; + this.name = name; + this.description = description; + this.defaultSeverity = defaultSeverity; + this.defaultEnabled = defaultEnabled; + this.myPreferences = myPreferences; + } + + @Override + public String getID() { + return id; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + public static CsmErrorInfo.Severity toSeverity(String severity) { + if ("error".equals(severity)) { // NOI18N + return CsmErrorInfo.Severity.ERROR; + } else if ("warning".equals(severity)) { // NOI18N + return CsmErrorInfo.Severity.WARNING; + } else { + return CsmErrorInfo.Severity.HINT; + } + } + + @Override + public String getKind() { + return "inspection"; //NOI18N + } + + @Override + public AuditPreferences getPreferences() { + return myPreferences; + } + + @Override + public boolean getDefaultEnabled() { + return defaultEnabled; + } + + @Override + public String getDefaultSeverity() { + return defaultSeverity; + } + + @Override + public boolean isSupportedEvent(CsmErrorProvider.EditorEvent kind) { + return true; + } + + @Override + public void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) { + throw new UnsupportedOperationException("Not supported yet."); //NOI18N + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorInfo.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,147 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.project.NativeProject; +import org.openide.util.Lookup; + +public class ModernizeErrorInfo implements CsmErrorInfo, ModernizeErrorProvider.ErrorInfoWithId { + + private final YamlParser.Diagnostics diag; + private final String messagePrefix; + private final List messageInfixes; + private final String messageBody; + private final NativeProject project; + + private final int startOffset; + private final int endOffset; + + public ModernizeErrorInfo(YamlParser.Diagnostics diag, String messagePrefix, List messageInfixes, String messageBody, Lookup.Provider project) { + this.diag = diag; + this.messagePrefix = messagePrefix; + this.messageInfixes = messageInfixes; + this.messageBody = messageBody; + this.project = project.getLookup().lookup(NativeProject.class); + + if (diag.getReplacements().isEmpty()) { + startOffset = diag.getMessageFileOffset(); + endOffset = diag.getMessageFileOffset(); + } else { + YamlParser.Replacement first = diag.getReplacements().get(0); + startOffset = first.offset; + endOffset = first.offset + first.length; + } + } + + public static ModernizeErrorInfo withFixedMessage(YamlParser.Diagnostics diag, String messageBody, Lookup.Provider project) { + return new ModernizeErrorInfo(diag, "", new ArrayList<>(), messageBody, project); + } + + public static ModernizeErrorInfo withMutableMessage(YamlParser.Diagnostics diag, String messagePrefix, String messageInfix, String messageBody, Lookup.Provider project) { + List list = new ArrayList<>(); + list.add(messageInfix); + return new ModernizeErrorInfo(diag, messagePrefix, list, messageBody, project); + } + + public static ModernizeErrorInfo withMutableMessage(YamlParser.Diagnostics diag, String messagePrefix, List messageInfixes, String messageBody, Lookup.Provider project) { + return new ModernizeErrorInfo(diag, messagePrefix, messageInfixes, messageBody, project); + } + + public void addMessageInfixes(List infix) { + messageInfixes.addAll(infix); + } + + public List getMessageInfixes() { + return Collections.unmodifiableList(messageInfixes); + } + + public NativeProject getProject() { + return project; + } + + @Override + public String getMessage() { + StringBuilder sb = new StringBuilder(); + sb.append(messagePrefix).append(' '); + if (messageInfixes.size() < 4) { + sb.append(messageInfixes.toString()); + } else { + ArrayList list = new ArrayList<>(messageInfixes.subList(0, 2)); + list.add(String.format("... (%s more)", messageInfixes.size() - 2)); + sb.append(list.toString()); + } + sb.append(": "); //NOI18N + sb.append(messageBody); + return sb.toString(); + } + + @Override + public Severity getSeverity() { + return Severity.valueOf(diag.getLevel().toString().toUpperCase()); + } + + @Override + public int getStartOffset() { + return startOffset; + } + + @Override + public int getEndOffset() { + return endOffset; + } + + public YamlParser.Diagnostics getDiagnostics() { + return diag; + } + + @Override + public String getId() { + return diag.getCheckName(); + } + + public boolean isNeedConfigureHint() { + return true; + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,425 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import com.sun.tools.ide.analysis.modernize.impl.YamlParser.Replacement; +import com.sun.tools.ide.analysis.modernize.options.AnalyzerPreferences; +import com.sun.tools.ide.analysis.modernize.options.ClangAnalyzerOptions; +import static com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools.fatalError; +import static com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools.findItem; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; +import javax.swing.JComponent; +import javax.swing.JLabel; +import org.netbeans.modules.cnd.analysis.api.AbstractCustomizerProvider; +import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit; +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditFactory; +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditProvider; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo.Severity; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfoHintProvider; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; +import org.netbeans.modules.cnd.api.project.NativeFileItem.Language; +import org.netbeans.modules.cnd.api.project.NativeProject; +import org.netbeans.modules.cnd.api.remote.RemoteProject; +import org.netbeans.modules.cnd.makeproject.api.MakeProject; +import org.netbeans.modules.cnd.makeproject.api.configurations.Item; +import org.netbeans.modules.cnd.modelutil.CsmUtilities; +import org.netbeans.modules.cnd.utils.MIMENames; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.spi.editor.hints.ErrorDescription; +import org.netbeans.spi.editor.hints.Fix; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; +import org.openide.util.NbBundle; +import org.openide.util.lookup.ServiceProvider; +import org.openide.util.lookup.ServiceProviders; + +@ServiceProviders({ + @ServiceProvider(service = CsmErrorProvider.class, position = 2100) + , + @ServiceProvider(service = CodeAuditProvider.class, position = 2100) +}) +public final class ModernizeErrorProvider extends CsmErrorProvider implements CodeAuditProvider, AbstractCustomizerProvider { + + public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N + public static final String NAME = "Modernize"; //NOI18N + + private Collection audits; + private AnalyzerResponseMerger analyzerResponseMerger; + + public static ModernizeErrorProvider getInstance() { + for (CsmErrorProvider provider : Lookup.getDefault().lookupAll(CsmErrorProvider.class)) { + if (NAME.equals(provider.getName()) && provider instanceof ModernizeErrorProvider) { + return (ModernizeErrorProvider) provider; + } + } + return null; + } + + @Override + protected boolean validate(Request request) { + CsmFile file = request.getFile(); + return file != null; + } + + @Override + public boolean hasHintControlPanel() { + return true; + } + + @Override + public String getName() { + return NAME; + } + + @Override + public String getDisplayName() { + return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"); //NOI18N + } + + @Override + public String getDescription() { + return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_DESCRIPTION"); //NOI18N + } + + @Override + public String getMimeType() { + return MIMENames.SOURCES_MIME_TYPE; + } + + @Override + public boolean isSupportedEvent(EditorEvent kind) { + return kind == EditorEvent.FileBased; + } + + @Override + protected void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) { + CsmFile file = request.getFile(); + if (file != null) { + if (request.isCancelled()) { + return; + } + Object platformProject = file.getProject().getPlatformProject(); + if (platformProject instanceof NativeProject) { + Lookup.Provider project = ((NativeProject) platformProject).getProject(); + if (project != null) { + if (request.isCancelled()) { + return; + } + Thread currentThread = Thread.currentThread(); + currentThread.setName("Provider " + getName() + " prosess " + file.getAbsolutePath()); // NOI18N + RemoteProject info = project.getLookup().lookup(RemoteProject.class); + if (info != null) { + ExecutionEnvironment execEnv = info.getDevelopmentHost(); + if (execEnv != null) { + if (request.isCancelled()) { + return; + } + if (ConnectionManager.getInstance().isConnectedTo(execEnv)) { + Item item = findItem(file, project); + if (item != null) { + if (request.isCancelled()) { + return; + } + // Temporarily analyzing even excluded items + if (/* !item.isExcluded() && */(item.getLanguage() == Language.C || item.getLanguage() == Language.CPP || item.getLanguage() == Language.C_HEADER)) { + analyze(execEnv, item, project, request, response); + } + } + } + } + } + } + } + } + } + + public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) { + String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath(); + boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ModernizeResponse; + if (binaryPath == null) { + Level level = isAnalyzer ? Level.INFO : Level.FINE; + LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N + return; + } + + if (isAnalyzer && isNewRun()) { + AnalyzedFiles.getDefault().clear(); + analyzerResponseMerger = new AnalyzerResponseMerger((ModernizeAnalyzerImpl.ModernizeResponse) response); + } + + DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath); + try { + CsmFile csmFile = request.getFile(); + Collection checks = /*isAnalyzer ? Collections.singleton("*") : */ getEnabledChecks(); //NOI18N + + Collection tu = new ArrayList(); + if (isAnalyzer) { + tu.add(csmFile); + } else { + if (AnalyzedFiles.getDefault().isStartFile(csmFile)) { + tu.add(csmFile); + } else { + tu.addAll(AnalyzedFiles.getDefault().getStartFiles(csmFile)); + } + } + + if (!isAnalyzer) { + response = new CsmResponseMerger(response); + } + + for (CsmFile startFile : tu) { + int exitCode = diagnosticsTool.process(checks, startFile, true); + if (exitCode != DiagnosticsTool.STATUS_OK) { + String error = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error"); //NOI18N + String info = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error.info", "" + exitCode); //NOI18N + fatalError(AnalyzerResponse.AnalyzerSeverity.FileError, "fatal.analyze.error", error + "\n" + info, csmFile, response); //NOI18N + return; + } + List results = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString()); + postProcess(isAnalyzer, startFile, project, results, request, response); + } + + if (!isAnalyzer) { + response.done(); + } + + } catch (ConnectionManager.CancellationException | IOException ex) { + Exceptions.printStackTrace(ex); + } + } + + private static CsmErrorProvider last; + + private boolean isNewRun() { + if (last == null || this != last) { + last = this; + return true; + } + return false; + } + + public Collection done() { + return analyzerResponseMerger.done(); + } + + public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) { + CsmFile file = request.getFile(); + List otherCsmFiles = new ArrayList<>(); + + for (YamlParser.Diagnostics diag : results) { + // TODO: don't add "Configure Hint" fix multiple times for one line + FileObject fo = FileUtil.toFileObject(new File(diag.getMessageFilePath())); + CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false); + + // Composing a preview message. Showing a start file for compilation unit + // in case we analysing a header file + ModernizeErrorInfo info; + if (startFile.equals(file) && csmFile.equals(file)) { + String message = String.format("[%s]: %s", diag.getCheckName(), diag.getMessage()); //NOI18N + info = ModernizeErrorInfo.withFixedMessage(diag, message, project); + } else { + info = ModernizeErrorInfo.withMutableMessage(diag, diag.getCheckName(), startFile.getName().toString(), diag.getMessage(), project); + } + + if (isAnalyzer) { + // Add found errors for all files (can be other files from compileUnit) + analyzerResponseMerger.addError(info, fo); + + if (!csmFile.equals(file)) { + // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... ) + otherCsmFiles.add(csmFile); + } + } else if (fo.equals(file.getFileObject())) { + // Add found errors only for file displayed in Editor + response.addError(info); + } + } + + if (isAnalyzer /* and not empty? */) { + AnalyzedFiles.getDefault().cacheHierarchy(file, otherCsmFiles); + } + } + + @ServiceProvider(path = CodeAuditFactory.REGISTRATION_PATH + ModernizeErrorProvider.NAME, service = CodeAuditFactory.class, position = 4000) + public static final class Factory implements CodeAuditFactory { + + @Override + public AbstractCodeAudit create(AuditPreferences preferences) { + String id = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderName"); // NOI18N + String description = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderDescription"); // NOI18N + return new ModernizeCodeAudit(id, id, description, "error", false, preferences); // NOI18N + } + } + + private String oldPath; + + @Override + public synchronized Collection getAudits() { + String path = ClangAnalyzerOptions.getClangAnalyzerPath(); + + if (path == null) { + return Collections.emptyList(); + } + + if (oldPath == null) { + oldPath = path; + } + + if (audits == null || !oldPath.equals(path)) { + List res = DiagnosticsTool.getAudits(path, ExecutionEnvironmentFactory.getLocal(), AnalyzerPreferences.getAuditPreferences()); + + audits = res; + oldPath = path; + } + return audits; + } + + public Collection getEnabledChecks() { + Collection auditList = getAudits(); + List enabled = new ArrayList(); + for (CodeAudit codeAudit : auditList) { + if (codeAudit.isEnabled()) { + enabled.add(codeAudit.getID()); + } + } + return enabled.size() == auditList.size() ? Collections.singleton("*") : enabled; //NOI18N + } + + @Override + public AuditPreferences getPreferences() { + return AnalyzerPreferences.getAuditPreferences(); + } + + @Override + public JComponent createComponent(Preferences context) { + return new JLabel(); + } + + public static interface ErrorInfoWithId { + + String getId(); + } + + public static final class FatalErrorInfo implements CsmErrorInfo, ErrorInfoWithId { + + private final String id; + private final String message; + + public FatalErrorInfo(String id, String message) { + this.id = id; + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + + @Override + public Severity getSeverity() { + return Severity.WARNING; + } + + @Override + public int getStartOffset() { + return 0; + } + + @Override + public int getEndOffset() { + return 1; + } + + @Override + public String getId() { + return id; + } + } + + @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 9100) + public final static class ModerinzeHintProvider extends CsmErrorInfoHintProvider { + + @Override + protected List doGetFixes(CsmErrorInfo info, List alreadyFound) { + if (info instanceof ModernizeErrorInfo) { + alreadyFound.add(new ConfigureHintsFix((ModernizeErrorInfo) info)); + } + return alreadyFound; + } + } + + @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 1600) + public static final class ModernizeFixProvider extends CsmErrorInfoHintProvider { + + @Override + protected List doGetFixes(CsmErrorInfo info, List alreadyFound) { + alreadyFound.addAll(createFixes(info)); + return alreadyFound; + } + } + + private static List createFixes(CsmErrorInfo info) { + if (info instanceof ModernizeErrorInfo) { + ModernizeErrorInfo mei = (ModernizeErrorInfo) info; + List replacements = mei.getDiagnostics().getReplacements(); + if (!replacements.isEmpty()) { + return Collections.singletonList(new ModernizeFix(replacements, mei.getId())); + } + } + return Collections.EMPTY_LIST; + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeFix.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeFix.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,133 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import java.io.File; +import java.util.List; +import javax.swing.text.Document; +import javax.swing.text.Position; +import org.netbeans.editor.BaseDocument; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.modelutil.CsmUtilities; +import org.netbeans.spi.editor.hints.ChangeInfo; +import org.netbeans.spi.editor.hints.EnhancedFix; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.text.CloneableEditorSupport; +import org.openide.text.PositionRef; + +/** + * + * @author Ilia Gromov + */ +public class ModernizeFix implements EnhancedFix { + + private final YamlParser.Replacement[] replacements; + private final String text; + private CloneableEditorSupport ces; + private final PositionRef[] beg; + private final PositionRef[] end; + + public ModernizeFix(List replacementList, String id) { + this.beg = new PositionRef[replacementList.size()]; + this.end = new PositionRef[replacementList.size()]; + this.replacements = replacementList.toArray(new YamlParser.Replacement[replacementList.size()]); + this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N + for (int i = 0; i < replacements.length; i++) { + YamlParser.Replacement replacement = replacements[i]; + FileObject fo = FileUtil.toFileObject(new File(replacement.filePath)); + CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false); + if (csmFile != null) { + ces = CsmUtilities.findCloneableEditorSupport(csmFile); + if (ces != null) { + beg[i] = ces.createPositionRef(replacement.offset, Position.Bias.Forward); + end[i] = ces.createPositionRef(replacement.offset + replacement.length, Position.Bias.Backward); + } else { + } + } + } + } //NOI18N + + @Override + public String getText() { + return "Apply replacement - " + text; //NOI18N + } + + @Override + public ChangeInfo implement() throws Exception { + Document doc = CsmUtilities.openDocument(ces); + if (doc instanceof BaseDocument) { + Position min = beg[0]; + Position max = end[0]; + for (int i = 0; i < replacements.length; i++) { + YamlParser.Replacement replacement = replacements[i]; + PositionRef b = beg[i]; + PositionRef e = end[i]; + if (b != null && e != null) { + int newBeg = b.getOffset(); + int newLength = e.getOffset() - b.getOffset(); + if (b.getOffset() < min.getOffset()) { + min = b; + } + if (e.getOffset() > max.getOffset()) { + max = e; + } + if (newLength < 1) { + // TODO: temp fix + newLength = 0; + } + ((BaseDocument) doc).replace(newBeg, newLength, replacement.replacementText, null); + } + } + return new ChangeInfo(min, max); + } + return null; + } + + @Override + public CharSequence getSortText() { + return Integer.toString(Integer.MIN_VALUE); + } + + public YamlParser.Replacement[] getReplacements() { + return replacements; + } + +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/YamlParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/YamlParser.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,357 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.impl; + +import static com.sun.tools.ide.analysis.modernize.impl.YamlParser.Diagnostics.UNDEFINED; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.StringTokenizer; +import java.util.logging.Level; + +/** + * + * @author Ilia Gromov + */ +public class YamlParser { + // TODO check for no-replacements case + + private static final YamlParser INSTANCE = new YamlParser(); + + public static YamlParser getDefault() { + return INSTANCE; + } + + private static final String OPEN_TAG = "---"; //NOI18N + private static final String CLOSE_TAG = "..."; //NOI18N + + private static final String MAIN_SOURCE_FILE = "MainSourceFile"; //NOI18N + private static final String CHECK_NAME = "CheckName"; //NOI18N + private static final String LEVEL = "Level"; //NOI18N + private static final String MESSAGE_FILE_PATH = "MessageFilePath"; //NOI18N + private static final String MESSAGE_FILE_OFFSET = "MessageFileOffset"; //NOI18N + private static final String MESSAGE = "Message"; //NOI18N + private static final String REPLACEMENTS = "Replacements"; //NOI18N + private static final String DIAGNOSTICS = "Diagnostics"; //NOI18N + + private static final String FILE_PATH = "FilePath"; //NOI18N + private static final String OFFSET = "Offset"; //NOI18N + private static final String LENGTH = "Length"; //NOI18N + private static final String REPLACEMENT_TEXT = "ReplacementText"; //NOI18N + + // clang-modernize: +// --- +// MainSourceFile: /home/ilia/NetBeansProjects/CppApplication_46/main.cpp +// Replacements: +// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/newfile.h +// Offset: 101 +// Length: 1 +// ReplacementText: nullptr +// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/newfile1.h +// Offset: 380 +// Length: 1 +// ReplacementText: nullptr +// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/main.cpp +// Offset: 152 +// Length: 1 +// ReplacementText: nullptr +// ... + // clang-tidy: +// --- +// MainSourceFile: '' +// Diagnostics: +// CheckName: misc-macro-parentheses +// Replacements: +// - FilePath: /media/SSD_/code/zdoom/main_1.cpp +// Offset: 1352 +// Length: 0 +// ReplacementText: '(' +// - FilePath: /media/SSD_/code/zdoom/main_1.cpp +// Offset: 1353 +// Length: 0 +// ReplacementText: ')' +// Diagnostics: +// CheckName: misc-macro-parentheses +// Replacements: +// - FilePath: /media/SSD_/code/zdoom/main_1.cpp +// Offset: 1446 +// Length: 0 +// ReplacementText: '(' +// - FilePath: /media/SSD_/code/zdoom/main_1.cpp +// Offset: 1447 +// Length: 0 +// ReplacementText: ')' +// ... + public List parseYaml(String output) { + try { + if (output.isEmpty()) { + // No warnings in header = no 'Main Source File' element + return Collections.EMPTY_LIST; + } + StringTokenizer st = new StringTokenizer(output, "\n"); //NOI18N + String line; + + // --- + line = st.nextToken(); + + line = st.nextToken(); + String mainSourceFile = getValue(MAIN_SOURCE_FILE, line); + + // Replacements: + line = st.nextToken(); + ClangTidyVersion version = line.contains(REPLACEMENTS) + ? ClangTidyVersion.OLD_FORMAT + : ClangTidyVersion.NEW_FORMAT; + + List list = version.parser.parse(st); + + return list; + } catch (Exception ex) { + ModernizeErrorProvider.LOG.log(Level.INFO, "Can't parse output line"); + return Collections.EMPTY_LIST; + } + } + + private static List parseReplacements(StringTokenizer st) { + List replacements = new ArrayList(); + String line; + + // eat Replacements: + line = st.nextToken(); + + if (!line.contains(REPLACEMENTS)) { + return replacements; + } + + while (st.hasMoreTokens()) { + line = st.nextToken(); + + if (line.equals(CLOSE_TAG) || !line.contains(FILE_PATH)) { + break; + } + + String filePath = getValue(FILE_PATH, line); + + line = st.nextToken(); + int offset = Integer.parseInt(getValue(OFFSET, line)); + + line = st.nextToken(); + int length = Integer.parseInt(getValue(LENGTH, line)); + + line = st.nextToken(); + String replacementText = getValue(REPLACEMENT_TEXT, line); + while (replacementText == null && st.hasMoreElements()) { + line = line + "\n" + st.nextElement(); //NOI18N + replacementText = getValue(REPLACEMENT_TEXT, line); + } + + Replacement replacement = new Replacement(filePath, offset, length, replacementText); + replacements.add(replacement); + + } + return replacements; + } + + private static String getValue(String key, String line) { + int keyStart = line.indexOf(key); + assert keyStart != -1; + int keyEnd = keyStart + key.length() + 1; + String trimmed = line.substring(keyEnd).trim(); + boolean isTextValue = trimmed.charAt(0) == '\''; + if (isTextValue) { + if (trimmed.length() == 1) { + // ' + // abcd' + return null; + } else if (trimmed.charAt(trimmed.length() - 1) == '\'') { + trimmed = trimmed.substring(1, trimmed.length() - 1); + } else { + return null; + } + } + return trimmed; + } + + public static class TranslationUnitDiagnostics { + + private final String mainSourceFilePath; + private final String context; + private final List diags; + + public TranslationUnitDiagnostics(String mainSourceFilePath, String context, List diags) { + this.mainSourceFilePath = mainSourceFilePath; + this.context = context; + this.diags = diags; + } + + public String getMainSourceFilePath() { + return mainSourceFilePath; + } + + public String getContext() { + return context; + } + + public List getDiags() { + return diags; + } + } + + public static class Diagnostics { + + public static final String UNDEFINED = "undefined"; // NOI18N + + public enum Level { + warning, error + } + + private final String checkName; + private final Diagnostics.Level level; + private final String messageFilePath; + private final int messageFileOffset; + private final String message; + private final List replacements; + + public Diagnostics(String checkName, Diagnostics.Level level, String messageFilePath, int messageFileOffset, String message, List replacements) { + this.checkName = checkName; + this.level = level; + this.messageFilePath = messageFilePath; + this.messageFileOffset = messageFileOffset; + this.message = message; + this.replacements = replacements; + } + + public String getCheckName() { + return checkName; + } + + public Level getLevel() { + return level; + } + + public String getMessageFilePath() { + return messageFilePath; + } + + public int getMessageFileOffset() { + return messageFileOffset; + } + + public String getMessage() { + return message; + } + + public List getReplacements() { + return replacements; + } + } + + public static class Replacement { + + public final String filePath; + public final int offset; + public final int length; + public final String replacementText; + + public Replacement(String FilePath, int offset, int length, String replacementText) { + this.filePath = FilePath; + this.offset = offset; + this.length = length; + this.replacementText = replacementText; + } + } + + private static enum ClangTidyVersion { + NEW_FORMAT(new NewFormatParser()), + OLD_FORMAT(new OldFormatParser()); + + public final TidyParser parser; + + private ClangTidyVersion(TidyParser parser) { + this.parser = parser; + } + } + + private static abstract class TidyParser { + + abstract List parse(StringTokenizer st); + } + + private static class NewFormatParser extends TidyParser { + + @Override + public List parse(StringTokenizer st) { + List list = new ArrayList(); + + String line; + while (st.hasMoreElements()) { + line = st.nextToken(); + String checkName = getValue(CHECK_NAME, line); + + line = st.nextToken(); + Diagnostics.Level level = Diagnostics.Level.valueOf(getValue(LEVEL, line).toLowerCase()); + + line = st.nextToken(); + String messageFilePath = getValue(MESSAGE_FILE_PATH, line); + + line = st.nextToken(); + int messageFileOffset = Integer.parseInt(getValue(MESSAGE_FILE_OFFSET, line)); + + line = st.nextToken(); + String message = getValue(MESSAGE, line); + + List replacements = parseReplacements(st); + + list.add(new Diagnostics(checkName, level, messageFilePath, messageFileOffset, message, replacements)); + } + return list; + } + + } + + private static class OldFormatParser extends TidyParser { + + @Override + public List parse(StringTokenizer st) { + List parseReplacements = parseReplacements(st); + return Collections.singletonList(new Diagnostics(UNDEFINED, Diagnostics.Level.warning, "", -1, "", parseReplacements)); //NOI18N + } + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/bugs.png Binary file c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/bugs.png has changed diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/layer.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/AnalyzerPreferences.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/AnalyzerPreferences.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,66 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ + +package com.sun.tools.ide.analysis.modernize.options; + +import java.util.prefs.Preferences; +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; + +/** + * + * @author Ilia Gromov + */ +public class AnalyzerPreferences { + + private static final String NODE_NAME = "clang-tidy"; //NOI18N + + public static AuditPreferences getAuditPreferences() { + return Holder.PREFS; + } + + public static Preferences getPreferences() { + return Holder.PREFS.getPreferences(); + } + + private static final class Holder { + + static final AuditPreferences PREFS = new AuditPreferences(AuditPreferences.AUDIT_PREFERENCES_ROOT.node(NODE_NAME)); + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/Bundle.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,15 @@ +PreviseOptions.confidenceLabel.text=&Confidence: + +SURE_CONFIDENCE=Sure +HIGH_CONFIDENCE=High +MEDIUM_CONFIDENCE=Medium +LOW_CONFIDENCE=Low +Parfait.tool.collection= +ParfaitOptions.pathToParfait.notfound=Not Found +ParfaitOptions.browse.text=... +SELECT_TOOL_TITLE=Select Clang Binary Folder +ParfaitOptions.connect.text=Connect to host {0} +Parfait.tool.collection_1=clang-tidy +ModernizeOptions.browseButton.text=... +ModernizeOptions.jLabel2.text=build host +ModernizeOptions.pathToAnalyzer.text= diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/ClangAnalyzerOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/options/ClangAnalyzerOptions.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,169 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ + +package com.sun.tools.ide.analysis.modernize.options; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; +import org.netbeans.modules.nativeexecution.api.HostInfo; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; +import org.openide.modules.InstalledFileLocator; + +/** + * + * @author Ilia Gromov + */ +public class ClangAnalyzerOptions { + + public static final String CLANG_BINARY_NAME = "clang-tidy"; //NOI18N + public static final String CLANG_BINARY_PATH = "clang-tidy-path"; //NOI18N + + private static String findInPaths() { + String binaryName = CLANG_BINARY_NAME + "-" + getCodeBase(); //NOI18N + String result = HostInfoUtils.searchFile(ExecutionEnvironmentFactory.getLocal(), Collections.emptyList(), binaryName, true); // NOI18N + return result; + } + + public static String getClangAnalyzerPath() { + String result = AnalyzerPreferences.getPreferences().get(CLANG_BINARY_PATH, ""); //NOI18N + String oldValue = result; + if (result.isEmpty()) { + String toolPath = System.getProperty("devstudio.clangtidy.path"); //NOI18N + if (toolPath != null) { + result = toolPath; + } + } + if (result.isEmpty()) { + final String codeBase = getCodeBase(); + String relativePath = String.format("%s/%s-%s", CLANG_BINARY_NAME, CLANG_BINARY_NAME, codeBase); //NOI18N + File toolFile = InstalledFileLocator.getDefault().locate(relativePath, codeBase, false); + if (toolFile != null && toolFile.exists()) { + toolFile.setExecutable(true); + System.out.println(toolFile.canExecute()); + result = toolFile.getAbsolutePath(); + } + } + if (result.isEmpty()) { + String toolPath = findInPaths(); + if (toolPath != null) { + result = toolPath; + } + } + if (result.isEmpty()) { + return null; + } else { + if (!oldValue.equals(result)) { + AnalyzerPreferences.getPreferences().put(CLANG_BINARY_PATH, result); + } + } + return result; + } + + public static String getMissingModuleName() { + return "org.netbeans.modules.analysis.clangtidy." + getCodeBase(); //NOI18N + } + + public static String getCodeBase() { + HostInfo hostInfo = null; + try { + hostInfo = HostInfoUtils.getHostInfo(ExecutionEnvironmentFactory.getLocal()); + } catch (IOException ex) { + ex.printStackTrace(System.err); + } catch (ConnectionManager.CancellationException ex) { + ex.printStackTrace(System.err); + } + String module = null; + if (hostInfo != null) { + switch (hostInfo.getOS().getFamily()) { + case SUNOS: + switch (hostInfo.getCpuFamily()) { + case X86: + switch (hostInfo.getOS().getBitness()) { + case _32: + module = "SunOS_x86"; // NOI18N + break; + case _64: + module = "SunOS_x86_64"; // NOI18N + break; + } + break; + case SPARC: + module = "SunOS_sparc"; // NOI18N + break; + } + break; + case LINUX: + switch (hostInfo.getOS().getBitness()) { + case _32: + module = "Linux_x86"; // NOI18N + break; + case _64: + module = "Linux_x86_64"; // NOI18N + break; + } + break; + case WINDOWS: + switch (hostInfo.getOS().getBitness()) { + case _32: + module = "Windows_x86"; // NOI18N + break; + case _64: + module = "Windows_x86_64"; // NOI18N + break; + } + break; + case MACOSX: + switch (hostInfo.getOS().getBitness()) { + case _32: + module = "MacOSX_x86"; // NOI18N + break; + case _64: + module = "MacOSX_x86_64"; // NOI18N + break; + } + break; + } + } + return module; + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/resources/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/resources/Bundle.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,6 @@ +fatals=fatal.unsupported.remote;fatal.tmp;fatal.analyze.error;fatal.language.flavor + +fatal.unsupported.remote= fatal: Unsupported remote mode +fatal.tmp= fatal: Cannot create temporary file +fatal.analyze.error= fatal: Unable to analyze file +fatal.language.flavor= fatal: Clang-tidy can be used with C++11 or later standard only \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/resources/BundleUtilities.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/resources/BundleUtilities.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.resources; + +import org.openide.util.NbBundle; + +/** + * + * @author Ilia Gromov + */ +public class BundleUtilities { + + public static String[] getFlags() { + return NbBundle.getMessage(BundleUtilities.class, "flags").split(";"); + } + + public static String getDescription(String key) { + return NbBundle.getMessage(BundleUtilities.class, key); + } + + public static String[] getFatalErrors() { + return NbBundle.getMessage(BundleUtilities.class, "fatals").split(";"); + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang-tools-extra.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang-tools-extra.patch Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,139 @@ +Index: clang-tidy/ClangTidy.cpp +=================================================================== +--- clang-tidy/ClangTidy.cpp (revision 278390) ++++ clang-tidy/ClangTidy.cpp (working copy) +@@ -35,6 +35,7 @@ + #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h" + #include "clang/Tooling/Refactoring.h" + #include "clang/Tooling/ReplacementsYaml.h" ++#include "clang/Tooling/DiagnosticsYaml.h" + #include "clang/Tooling/Tooling.h" + #include "llvm/Support/Process.h" + #include "llvm/Support/Signals.h" +@@ -509,13 +510,10 @@ + + void exportReplacements(const std::vector &Errors, + raw_ostream &OS) { +- tooling::TranslationUnitReplacements TUR; +- for (const ClangTidyError &Error : Errors) +- TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(), +- Error.Fix.end()); +- + yaml::Output YAML(OS); +- YAML << TUR; ++ TranslationUnitDiagnostics TUD; ++ TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end()); ++ YAML << TUD; + } + + } // namespace tidy +Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp +=================================================================== +--- clang-tidy/ClangTidyDiagnosticConsumer.cpp (revision 278390) ++++ clang-tidy/ClangTidyDiagnosticConsumer.cpp (working copy) +@@ -102,25 +102,6 @@ + }; + } // end anonymous namespace + +-ClangTidyMessage::ClangTidyMessage(StringRef Message) +- : Message(Message), FileOffset(0) {} +- +-ClangTidyMessage::ClangTidyMessage(StringRef Message, +- const SourceManager &Sources, +- SourceLocation Loc) +- : Message(Message) { +- assert(Loc.isValid() && Loc.isFileID()); +- FilePath = Sources.getFilename(Loc); +- FileOffset = Sources.getFileOffset(Loc); +-} +- +-ClangTidyError::ClangTidyError(StringRef CheckName, +- ClangTidyError::Level DiagLevel, +- bool IsWarningAsError, +- StringRef BuildDirectory) +- : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel), +- IsWarningAsError(IsWarningAsError) {} +- + // Returns true if GlobList starts with the negative indicator ('-'), removes it + // from the GlobList. + static bool ConsumeNegativeIndicator(StringRef &GlobList) { +Index: clang-tidy/ClangTidyDiagnosticConsumer.h +=================================================================== +--- clang-tidy/ClangTidyDiagnosticConsumer.h (revision 278390) ++++ clang-tidy/ClangTidyDiagnosticConsumer.h (working copy) +@@ -14,6 +14,7 @@ + #include "clang/Basic/Diagnostic.h" + #include "clang/Basic/SourceManager.h" + #include "clang/Tooling/Refactoring.h" ++#include "clang/Tooling/Core/Diagnostics.h" + #include "llvm/ADT/DenseMap.h" + #include "llvm/ADT/StringMap.h" + #include "llvm/Support/Regex.h" +@@ -32,52 +33,9 @@ + + namespace tidy { + +-/// \brief A message from a clang-tidy check. +-/// +-/// Note that this is independent of a \c SourceManager. +-struct ClangTidyMessage { +- ClangTidyMessage(StringRef Message = ""); +- ClangTidyMessage(StringRef Message, const SourceManager &Sources, +- SourceLocation Loc); +- std::string Message; +- std::string FilePath; +- unsigned FileOffset; +-}; ++typedef clang::tooling::DiagnosticsMessage ClangTidyMessage; ++typedef clang::tooling::Diagnostics ClangTidyError; + +-/// \brief A detected error complete with information to display diagnostic and +-/// automatic fix. +-/// +-/// This is used as an intermediate format to transport Diagnostics without a +-/// dependency on a SourceManager. +-/// +-/// FIXME: Make Diagnostics flexible enough to support this directly. +-struct ClangTidyError { +- enum Level { +- Warning = DiagnosticsEngine::Warning, +- Error = DiagnosticsEngine::Error +- }; +- +- ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, +- StringRef BuildDirectory); +- +- std::string CheckName; +- ClangTidyMessage Message; +- tooling::Replacements Fix; +- SmallVector Notes; +- +- // A build directory of the diagnostic source file. +- // +- // It's an absolute path which is `directory` field of the source file in +- // compilation database. If users don't specify the compilation database +- // directory, it is the current directory where clang-tidy runs. +- // +- // Note: it is empty in unittest. +- std::string BuildDirectory; +- +- Level DiagLevel; +- bool IsWarningAsError; +-}; +- + /// \brief Read-only set of strings represented as a list of positive and + /// negative globs. Positive globs add all matched strings to the set, negative + /// globs remove them in the order of appearance in the list. +Index: clang-tidy/tool/ClangTidyMain.cpp +=================================================================== +--- clang-tidy/tool/ClangTidyMain.cpp (revision 278390) ++++ clang-tidy/tool/ClangTidyMain.cpp (working copy) +@@ -389,7 +389,7 @@ + + // -fix-errors implies -fix. + handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount); +- ++ + if (!ExportFixes.empty() && !Errors.empty()) { + std::error_code EC; + llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None); diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/tools-clang.patch Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,461 @@ +Index: include/clang/Tooling/Core/Diagnostics.h +=================================================================== +--- include/clang/Tooling/Core/Diagnostics.h (revision 278390) ++++ include/clang/Tooling/Core/Diagnostics.h (working copy) +@@ -1,254 +1,54 @@ +-//===--- Replacement.h - Framework for clang refactoring tools --*- C++ -*-===// +-// +-// The LLVM Compiler Infrastructure +-// +-// This file is distributed under the University of Illinois Open Source +-// License. See LICENSE.TXT for details. +-// +-//===----------------------------------------------------------------------===// +-// +-// Classes supporting refactorings that span multiple translation units. +-// While single translation unit refactorings are supported via the Rewriter, +-// when refactoring multiple translation units changes must be stored in a +-// SourceManager independent form, duplicate changes need to be removed, and +-// all changes must be applied at once at the end of the refactoring so that +-// the code is always parseable. +-// +-//===----------------------------------------------------------------------===// +- +-#ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H +-#define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H +- +-#include "clang/Basic/LangOptions.h" +-#include "clang/Basic/SourceLocation.h" +-#include "llvm/ADT/StringRef.h" +-#include "llvm/Support/Error.h" +-#include +-#include ++#ifndef LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H ++#define LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H ++#include "clang/Basic/Diagnostic.h" ++#include "llvm/ADT/SmallVector.h" ++#include "Replacement.h" + #include +-#include +- + namespace clang { ++ namespace tooling { + +-class Rewriter; ++ struct DiagnosticsMessage { ++ DiagnosticsMessage(StringRef Message = ""); ++ DiagnosticsMessage(StringRef Message, const SourceManager &Sources, ++ SourceLocation Loc); ++ std::string Message; ++ std::string FilePath; ++ unsigned FileOffset; ++ }; + +-namespace tooling { ++ struct Diagnostics { + +-/// \brief A source range independent of the \c SourceManager. +-class Range { +-public: +- Range() : Offset(0), Length(0) {} +- Range(unsigned Offset, unsigned Length) : Offset(Offset), Length(Length) {} ++ enum Level { ++ Warning = DiagnosticsEngine::Warning, ++ Error = DiagnosticsEngine::Error ++ }; + +- /// \brief Accessors. +- /// @{ +- unsigned getOffset() const { return Offset; } +- unsigned getLength() const { return Length; } +- /// @} ++ Diagnostics(); ++ Diagnostics(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, ++ StringRef BuildDirectory); ++ std::string CheckName; ++ DiagnosticsMessage Message; ++ tooling::Replacements Fix; ++ SmallVector Notes; + +- /// \name Range Predicates +- /// @{ +- /// \brief Whether this range overlaps with \p RHS or not. +- bool overlapsWith(Range RHS) const { +- return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length; +- } ++ // A build directory of the diagnostic source file. ++ // ++ // It's an absolute path which is `directory` field of the source file in ++ // compilation database. If users don't specify the compilation database ++ // directory, it is the current directory where clang-tidy runs. ++ // ++ // Note: it is empty in unittest. ++ std::string BuildDirectory; + +- /// \brief Whether this range contains \p RHS or not. +- bool contains(Range RHS) const { +- return RHS.Offset >= Offset && +- (RHS.Offset + RHS.Length) <= (Offset + Length); +- } ++ Level DiagLevel; ++ bool IsWarningAsError; ++ }; + +- /// \brief Whether this range equals to \p RHS or not. +- bool operator==(const Range &RHS) const { +- return Offset == RHS.getOffset() && Length == RHS.getLength(); +- } +- /// @} +- +-private: +- unsigned Offset; +- unsigned Length; +-}; +- +-/// \brief A text replacement. +-/// +-/// Represents a SourceManager independent replacement of a range of text in a +-/// specific file. +-class Replacement { +-public: +- /// \brief Creates an invalid (not applicable) replacement. +- Replacement(); +- +- /// \brief Creates a replacement of the range [Offset, Offset+Length) in +- /// FilePath with ReplacementText. +- /// +- /// \param FilePath A source file accessible via a SourceManager. +- /// \param Offset The byte offset of the start of the range in the file. +- /// \param Length The length of the range in bytes. +- Replacement(StringRef FilePath, unsigned Offset, unsigned Length, +- StringRef ReplacementText); +- +- /// \brief Creates a Replacement of the range [Start, Start+Length) with +- /// ReplacementText. +- Replacement(const SourceManager &Sources, SourceLocation Start, +- unsigned Length, StringRef ReplacementText); +- +- /// \brief Creates a Replacement of the given range with ReplacementText. +- Replacement(const SourceManager &Sources, const CharSourceRange &Range, +- StringRef ReplacementText, +- const LangOptions &LangOpts = LangOptions()); +- +- /// \brief Creates a Replacement of the node with ReplacementText. +- template +- Replacement(const SourceManager &Sources, const Node &NodeToReplace, +- StringRef ReplacementText, +- const LangOptions &LangOpts = LangOptions()); +- +- /// \brief Returns whether this replacement can be applied to a file. +- /// +- /// Only replacements that are in a valid file can be applied. +- bool isApplicable() const; +- +- /// \brief Accessors. +- /// @{ +- StringRef getFilePath() const { return FilePath; } +- unsigned getOffset() const { return ReplacementRange.getOffset(); } +- unsigned getLength() const { return ReplacementRange.getLength(); } +- StringRef getReplacementText() const { return ReplacementText; } +- /// @} +- +- /// \brief Applies the replacement on the Rewriter. +- bool apply(Rewriter &Rewrite) const; +- +- /// \brief Returns a human readable string representation. +- std::string toString() const; +- +- private: +- void setFromSourceLocation(const SourceManager &Sources, +- SourceLocation Start, unsigned Length, +- StringRef ReplacementText); +- void setFromSourceRange(const SourceManager &Sources, +- const CharSourceRange &Range, +- StringRef ReplacementText, +- const LangOptions &LangOpts); +- +- std::string FilePath; +- Range ReplacementRange; +- std::string ReplacementText; +-}; +- +-/// \brief Less-than operator between two Replacements. +-bool operator<(const Replacement &LHS, const Replacement &RHS); +- +-/// \brief Equal-to operator between two Replacements. +-bool operator==(const Replacement &LHS, const Replacement &RHS); +- +-/// \brief A set of Replacements. +-/// FIXME: Change to a vector and deduplicate in the RefactoringTool. +-typedef std::set Replacements; +- +-/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite. +-/// +-/// Replacement applications happen independently of the success of +-/// other applications. +-/// +-/// \returns true if all replacements apply. false otherwise. +-bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite); +- +-/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite. +-/// +-/// Replacement applications happen independently of the success of +-/// other applications. +-/// +-/// \returns true if all replacements apply. false otherwise. +-bool applyAllReplacements(const std::vector &Replaces, +- Rewriter &Rewrite); +- +-/// \brief Applies all replacements in \p Replaces to \p Code. +-/// +-/// This completely ignores the path stored in each replacement. If all +-/// replacements are applied successfully, this returns the code with +-/// replacements applied; otherwise, an llvm::Error carrying llvm::StringError +-/// is returned (the Error message can be converted to string using +-/// `llvm::toString()` and 'std::error_code` in the `Error` should be ignored). +-llvm::Expected applyAllReplacements(StringRef Code, +- const Replacements &Replaces); +- +-/// \brief Calculates how a code \p Position is shifted when \p Replaces are +-/// applied. +-unsigned shiftedCodePosition(const Replacements& Replaces, unsigned Position); +- +-/// \brief Calculates how a code \p Position is shifted when \p Replaces are +-/// applied. +-/// +-/// \pre Replaces[i].getOffset() <= Replaces[i+1].getOffset(). +-unsigned shiftedCodePosition(const std::vector &Replaces, +- unsigned Position); +- +-/// \brief Removes duplicate Replacements and reports if Replacements conflict +-/// with one another. All Replacements are assumed to be in the same file. +-/// +-/// \post Replaces[i].getOffset() <= Replaces[i+1].getOffset(). +-/// +-/// This function sorts \p Replaces so that conflicts can be reported simply by +-/// offset into \p Replaces and number of elements in the conflict. +-void deduplicate(std::vector &Replaces, +- std::vector &Conflicts); +- +-/// \brief Collection of Replacements generated from a single translation unit. +-struct TranslationUnitReplacements { +- /// Name of the main source for the translation unit. +- std::string MainSourceFile; +- +- /// A freeform chunk of text to describe the context of the replacements. +- /// Will be printed, for example, when detecting conflicts during replacement +- /// deduplication. +- std::string Context; +- +- std::vector Replacements; +-}; +- +-/// \brief Calculates the ranges in a single file that are affected by the +-/// Replacements. Overlapping ranges will be merged. +-/// +-/// \pre Replacements must be for the same file. +-/// +-/// \returns a non-overlapping and sorted ranges. +-std::vector calculateChangedRanges(const Replacements &Replaces); +- +-/// \brief Calculates the new ranges after \p Replaces are applied. These +-/// include both the original \p Ranges and the affected ranges of \p Replaces +-/// in the new code. +-/// +-/// \pre Replacements must be for the same file. +-/// +-/// \return The new ranges after \p Replaces are applied. The new ranges will be +-/// sorted and non-overlapping. +-std::vector +-calculateRangesAfterReplacements(const Replacements &Replaces, +- const std::vector &Ranges); +- +-/// \brief Groups a random set of replacements by file path. Replacements +-/// related to the same file entry are put into the same vector. +-std::map +-groupReplacementsByFile(const Replacements &Replaces); +- +-/// \brief Merges two sets of replacements with the second set referring to the +-/// code after applying the first set. Within both 'First' and 'Second', +-/// replacements must not overlap. +-Replacements mergeReplacements(const Replacements &First, +- const Replacements &Second); +- +-template +-Replacement::Replacement(const SourceManager &Sources, +- const Node &NodeToReplace, StringRef ReplacementText, +- const LangOptions &LangOpts) { +- const CharSourceRange Range = +- CharSourceRange::getTokenRange(NodeToReplace->getSourceRange()); +- setFromSourceRange(Sources, Range, ReplacementText, LangOpts); ++ struct TranslationUnitDiagnostics { ++ std::string MainSourceFile; ++ std::string Context; ++ std::vector Diags; ++ }; ++ } + } +- +-} // end namespace tooling +-} // end namespace clang +- +-#endif // LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H ++#endif +\ No newline at end of file +Index: lib/Tooling/Core/CMakeLists.txt +=================================================================== +--- lib/Tooling/Core/CMakeLists.txt (revision 278390) ++++ lib/Tooling/Core/CMakeLists.txt (working copy) +@@ -3,6 +3,7 @@ + add_clang_library(clangToolingCore + Lookup.cpp + Replacement.cpp ++ Diagnostics.cpp + QualTypeNames.cpp + + LINK_LIBS +Index: lib/Tooling/Core/Diagnostics.cpp +=================================================================== +--- lib/Tooling/Core/Diagnostics.cpp (revision 278390) ++++ lib/Tooling/Core/Diagnostics.cpp (working copy) +@@ -1,113 +1,30 @@ +-//===--- Lookup.cpp - Framework for clang refactoring tools ---------------===// +-// +-// The LLVM Compiler Infrastructure +-// +-// This file is distributed under the University of Illinois Open Source +-// License. See LICENSE.TXT for details. +-// +-//===----------------------------------------------------------------------===// +-// +-// This file defines helper methods for clang tools performing name lookup. +-// +-//===----------------------------------------------------------------------===// ++#include "clang/Tooling/Core/Diagnostics.h" ++#include "clang/Basic/SourceManager.h" ++namespace clang { ++ namespace tooling { + +-#include "clang/Tooling/Core/Lookup.h" +-#include "clang/AST/Decl.h" +-using namespace clang; +-using namespace clang::tooling; ++ DiagnosticsMessage::DiagnosticsMessage(StringRef Message) ++ : Message(Message), FileOffset(0) { ++ } + +-static bool isInsideDifferentNamespaceWithSameName(const DeclContext *DeclA, +- const DeclContext *DeclB) { +- while (true) { +- // Look past non-namespaces on DeclA. +- while (DeclA && !isa(DeclA)) +- DeclA = DeclA->getParent(); ++ DiagnosticsMessage::DiagnosticsMessage(StringRef Message, ++ const SourceManager &Sources, ++ SourceLocation Loc) ++ : Message(Message) { ++ assert(Loc.isValid() && Loc.isFileID()); ++ FilePath = Sources.getFilename(Loc); ++ FileOffset = Sources.getFileOffset(Loc); ++ } + +- // Look past non-namespaces on DeclB. +- while (DeclB && !isa(DeclB)) +- DeclB = DeclB->getParent(); ++ Diagnostics::Diagnostics() { ++ } + +- // We hit the root, no namespace collision. +- if (!DeclA || !DeclB) +- return false; +- +- // Literally the same namespace, not a collision. +- if (DeclA == DeclB) +- return false; +- +- // Now check the names. If they match we have a different namespace with the +- // same name. +- if (cast(DeclA)->getDeclName() == +- cast(DeclB)->getDeclName()) +- return true; +- +- DeclA = DeclA->getParent(); +- DeclB = DeclB->getParent(); +- } +-} +- +-static StringRef getBestNamespaceSubstr(const DeclContext *DeclA, +- StringRef NewName, +- bool HadLeadingColonColon) { +- while (true) { +- while (DeclA && !isa(DeclA)) +- DeclA = DeclA->getParent(); +- +- // Fully qualified it is! Leave :: in place if it's there already. +- if (!DeclA) +- return HadLeadingColonColon ? NewName : NewName.substr(2); +- +- // Otherwise strip off redundant namespace qualifications from the new name. +- // We use the fully qualified name of the namespace and remove that part +- // from NewName if it has an identical prefix. +- std::string NS = +- "::" + cast(DeclA)->getQualifiedNameAsString() + "::"; +- if (NewName.startswith(NS)) +- return NewName.substr(NS.size()); +- +- // No match yet. Strip of a namespace from the end of the chain and try +- // again. This allows to get optimal qualifications even if the old and new +- // decl only share common namespaces at a higher level. +- DeclA = DeclA->getParent(); +- } +-} +- +-/// Check if the name specifier begins with a written "::". +-static bool isFullyQualified(const NestedNameSpecifier *NNS) { +- while (NNS) { +- if (NNS->getKind() == NestedNameSpecifier::Global) +- return true; +- NNS = NNS->getPrefix(); +- } +- return false; +-} +- +-std::string tooling::replaceNestedName(const NestedNameSpecifier *Use, +- const DeclContext *UseContext, +- const NamedDecl *FromDecl, +- StringRef ReplacementString) { +- assert(ReplacementString.startswith("::") && +- "Expected fully-qualified name!"); +- +- // We can do a raw name replacement when we are not inside the namespace for +- // the original function and it is not in the global namespace. The +- // assumption is that outside the original namespace we must have a using +- // statement that makes this work out and that other parts of this refactor +- // will automatically fix using statements to point to the new function +- const bool class_name_only = !Use; +- const bool in_global_namespace = +- isa(FromDecl->getDeclContext()); +- if (class_name_only && !in_global_namespace && +- !isInsideDifferentNamespaceWithSameName(FromDecl->getDeclContext(), +- UseContext)) { +- auto Pos = ReplacementString.rfind("::"); +- return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2) +- : ReplacementString; +- } +- // We did not match this because of a using statement, so we will need to +- // figure out how good a namespace match we have with our destination type. +- // We work backwards (from most specific possible namespace to least +- // specific). +- return getBestNamespaceSubstr(UseContext, ReplacementString, +- isFullyQualified(Use)); +-} ++ Diagnostics::Diagnostics(StringRef CheckName, ++ Diagnostics::Level DiagLevel, ++ bool IsWarningAsError, ++ StringRef BuildDirectory) ++ : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel), ++ IsWarningAsError(IsWarningAsError) { ++ } ++ } ++} +\ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/utils/AnalyticsTools.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/utils/AnalyticsTools.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,208 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): Ilia Gromov + */ +package com.sun.tools.ide.analysis.modernize.utils; + +import com.sun.tools.ide.analysis.modernize.impl.ModernizeErrorProvider; +import java.util.ArrayList; +import java.util.List; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.analysis.spi.Analyzer; +import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; +import org.netbeans.modules.cnd.api.project.NativeFileItem; +import org.netbeans.modules.cnd.api.remote.RemoteProject; +import org.netbeans.modules.cnd.api.toolchain.CompilerSet; +import org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind; +import org.netbeans.modules.cnd.api.toolchain.Tool; +import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider; +import org.netbeans.modules.cnd.makeproject.api.configurations.Item; +import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor; +import org.netbeans.modules.cnd.spi.toolchain.ToolchainProject; +import org.netbeans.modules.cnd.utils.MIMENames; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.openide.filesystems.FileObject; +import org.openide.util.Lookup; + +/** + * + * @author Ilia Gromov + */ +public class AnalyticsTools { + + public static ExecutionEnvironment detectEnvironment(Analyzer.Context context) { + if (context.getScope() == null) { + return null; + } + for (FileObject fo : context.getScope().getFiles()) { + String mimeType = fo.getMIMEType(); + if (MIMENames.isHeaderOrCppOrC(mimeType)) { + Project project = FileOwnerQuery.getOwner(fo); + RemoteProject info = project.getLookup().lookup(RemoteProject.class); + if (info != null) { + ExecutionEnvironment dh = info.getDevelopmentHost(); + if (dh != null) { + return dh; + } + } + } + } + return null; + } + + public static CompilerSet toolchain(Lookup.Provider project) { + ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class); + if (toolchain != null) { + return toolchain.getCompilerSet(); + } + return null; + } + + public static MakeConfigurationDescriptor getConfigurationDescriptor(CsmFile file, Lookup.Provider project) { + if (file != null) { + ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class); + if (pdp != null) { + MakeConfigurationDescriptor makeConfigurationDescriptor = pdp.getConfigurationDescriptor(); + if (makeConfigurationDescriptor != null) { + return makeConfigurationDescriptor; + } + } + } + + return null; + } + + public static Item findItem(CsmFile file, Lookup.Provider project) { + return getConfigurationDescriptor(file, project).findProjectItemByPath(file.getAbsolutePath().toString()); + } + + public static void fatalError(AnalyzerResponse.AnalyzerSeverity severity, String id, String message, CsmFile file, CsmErrorProvider.Response response) { + CsmErrorInfo fatal = new ModernizeErrorProvider.FatalErrorInfo(id, message); + if (response instanceof AnalyzerResponse) { + AnalyzerResponse ar = (AnalyzerResponse) response; + ar.addError(severity, message, file.getFileObject(), fatal); //NOI18N + } else { + response.addError(fatal); //NOI18N + } + } + + public static String useTool(Item item, Lookup.Provider project) { + ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class); + if (toolchain != null) { + CompilerSet set = toolchain.getCompilerSet(); + if (set != null) { + if (set.getCompilerFlavor().isSunStudioCompiler()) { + if (item.getLanguage() == NativeFileItem.Language.C) { + return set.findTool(PredefinedToolKind.CCompiler).getPath(); + } else { + return set.findTool(PredefinedToolKind.CCCompiler).getPath(); + } + } + } + } + return null; + } + + public static Tool compiler(Item item, Lookup.Provider project) { + CompilerSet set = toolchain(project); + if (set != null) { + if (item.getLanguage() == NativeFileItem.Language.C) { + return set.findTool(PredefinedToolKind.CCompiler); + } else { + return set.findTool(PredefinedToolKind.CCCompiler); + } + } + return null; + } + + public static List scanCommandLine(String line) { + List res = new ArrayList(); + int i = 0; + StringBuilder current = new StringBuilder(); + boolean isSingleQuoteMode = false; + boolean isDoubleQuoteMode = false; + while (i < line.length()) { + char c = line.charAt(i); + i++; + switch (c) { + case '\'': // NOI18N + if (isSingleQuoteMode) { + isSingleQuoteMode = false; + } else if (!isDoubleQuoteMode) { + isSingleQuoteMode = true; + } + current.append(c); + break; + case '\"': // NOI18N + if (isDoubleQuoteMode) { + isDoubleQuoteMode = false; + } else if (!isSingleQuoteMode) { + isDoubleQuoteMode = true; + } + current.append(c); + break; + case ' ': // NOI18N + case '\t': // NOI18N + case '\n': // NOI18N + case '\r': // NOI18N + if (isSingleQuoteMode || isDoubleQuoteMode) { + current.append(c); + break; + } else { + if (current.length() > 0) { + res.add(current.toString()); + current.setLength(0); + } + } + break; + default: + current.append(c); + break; + } + } + if (current.length() > 0) { + res.add(current.toString()); + } + return res; + } + +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +File clang-tidy-3.9p should be placed in this directory before testing. +(Won't commit large, ~25Mb binary file to Mercurial repo). \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,3 @@ +#ifndef _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H +#define _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H +#endif \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int loops() { + const int N = 5; + int arr[] = {1, 2, 3, 4, 5}; + vector v; + v.push_back(1); + v.push_back(2); + v.push_back(3); + + // safe conversion + for (auto & elem : arr) + cout << elem; + + // reasonable conversion + for (auto & elem : v) + cout << elem; + + // reasonable conversion + for (auto & elem : v) + cout << elem; +} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,8 @@ +const char *const Quotes{R"(embedded "quotes")"}; +const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"}; +const char *const SingleLine{"Single line.\n"}; +const char *const TrailingSpace{"Look here -> \n"}; +const char *const Tab{"One\tTwo\n"}; +const char *const Bell{"Hello!\a And welcome!"}; +const char *const Path{R"(C:\Program Files\Vendor\Application.exe)"}; +const char *const RegEx{R"(\w\([a-z]\))"}; \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,11 @@ +#include + +void assignment() { + char *a = nullptr; + char *b = nullptr; + char c = 0; +} + +int *ret_ptr() { + return nullptr; +} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/YamlTest/hello-world.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/goldenfiles/ide/analysis/modernize/YamlTest/hello-world.json Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,25 @@ +--- +MainSourceFile: '' +Diagnostics: + CheckName: misc-unused-parameters + Level: Warning + MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc + MessageFileOffset: 1615 + Message: 'parameter ''argc'' is unused' + Replacements: + - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc + Offset: 1615 + Length: 4 + ReplacementText: ' /*argc*/' +Diagnostics: + CheckName: misc-unused-parameters + Level: Warning + MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc + MessageFileOffset: 1627 + Message: 'parameter ''argv'' is unused' + Replacements: + - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc + Offset: 1627 + Length: 4 + ReplacementText: ' /*argv*/' +... \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +project (HelloCMake CXX) +add_subdirectory (src) diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,128 @@ + + + + + + + llvm-header-guard.cpp + + + + CMakeLists.txt + build/Debug/Makefile + build/Release/Makefile + + + ^(nbproject|build)$ + + . + + build/Debug/Makefile + + + + default + false + false + + + + + + + + + build/Debug + ${MAKE} -f Makefile + ${MAKE} -f Makefile clean + build/Debug/src/welcome + + + build/Debug/src + + + + + build/Debug + ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. + true + + + + + + + + + + default + false + false + + + + + + build/Release + ${MAKE} -f Makefile + ${MAKE} -f Makefile clean + build/Release/src/welcome + + + build/Release/src + + + NDEBUG + + + + + build/Release + ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. + true + + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,72 @@ + + + + org.netbeans.modules.cnd.makeproject + + + hello-cmake-world + + cpp + h + UTF-8 + + . + + + + . + + + + Debug + 0 + + + Release + 0 + + + + false + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +set(CMAKE_CXX_STANDARD 11) +add_library (headers llvm-header-guard.cpp) diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +#include "llvm-header-guard.h" \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/CMakeLists.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +project (HelloCMake CXX) +add_subdirectory (src) diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/nbproject/configurations.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/nbproject/configurations.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,145 @@ + + + + + + + header.h + source_1.cpp + source_2.cpp + source_3.cpp + source_4.cpp + + + + CMakeLists.txt + build/Debug/Makefile + build/Release/Makefile + + + ^(nbproject|build)$ + + . + + build/Debug/Makefile + + + + default + false + false + + + + + + build/Debug + ${MAKE} -f Makefile + ${MAKE} -f Makefile clean + build/Debug/src/welcome + + + build/Debug/src + + + + + build/Debug + ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. + true + + + + + + + + + + + + + + + + default + false + false + + + + + + build/Release + ${MAKE} -f Makefile + ${MAKE} -f Makefile clean + build/Release/src/welcome + + + build/Release/src + + + NDEBUG + + + + + build/Release + ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. + true + + + + + + + + + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/nbproject/project.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,72 @@ + + + + org.netbeans.modules.cnd.makeproject + + + hello-cmake-world + + cpp + h + UTF-8 + + . + + + + . + + + + Debug + 0 + + + Release + 0 + + + + false + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/CMakeLists.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,4 @@ +set(CMAKE_CXX_STANDARD 11) +add_library (tu_1 source_1.cpp) +add_library (tu_2 source_2.cpp) +add_library (tu_3 source_3.cpp) diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/header.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/header.h Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,8 @@ +#ifndef HEADER_H +#define HEADER_H + +using namespace std; + +#endif /* HEADER_H */ + + \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_1.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +#include "header.h" diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_2.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +#include "header.h" diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_3.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_3.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +#include "header.h" diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_4.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/MultipleFileTest/project-with-headers/src/source_4.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +#include "header.h" diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +project (HelloCMake) +add_subdirectory (src) diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,143 @@ + + + + + + + modernize-loop-convert.cpp + modernize-raw-string-literal.cpp + modernize-use-nullptr.cpp + + + + CMakeLists.txt + build/Debug/Makefile + build/Release/Makefile + + + ^(nbproject|build)$ + + . + + build/Debug/Makefile + + + + default + false + false + + + + + + + + + build/Debug + ${MAKE} -f Makefile + ${MAKE} -f Makefile clean + build/Debug/src/welcome + + + build/Debug/src + + + + + build/Debug + ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. + true + + + + + + + + + + + + + + + + + + default + false + false + + + + + + build/Release + ${MAKE} -f Makefile + ${MAKE} -f Makefile clean + build/Release/src/welcome + + + build/Release/src + + + NDEBUG + + + + + build/Release + ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. + true + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,72 @@ + + + + org.netbeans.modules.cnd.makeproject + + + hello-cmake-world + + cpp + h + UTF-8 + + . + + + + . + + + + Debug + 0 + + + Release + 0 + + + + false + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,2 @@ +set(CMAKE_CXX_STANDARD 11) +add_library (single-cpp-file-check modernize-use-nullptr.cpp modernize-loop-convert.cpp modernize-raw-string-literal.cpp) diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +#include "llvm-header-guard.h" \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,25 @@ +#include +#include + +using namespace std; + +int loops() { + const int N = 5; + int arr[] = {1, 2, 3, 4, 5}; + vector v; + v.push_back(1); + v.push_back(2); + v.push_back(3); + + // safe conversion + for (int i = 0; i < N; ++i) + cout << arr[i]; + + // reasonable conversion + for (vector::iterator it = v.begin(); it != v.end(); ++it) + cout << *it; + + // reasonable conversion + for (int i = 0; i < v.size(); ++i) + cout << v[i]; +} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,8 @@ +const char *const Quotes{"embedded \"quotes\""}; +const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"}; +const char *const SingleLine{"Single line.\n"}; +const char *const TrailingSpace{"Look here -> \n"}; +const char *const Tab{"One\tTwo\n"}; +const char *const Bell{"Hello!\a And welcome!"}; +const char *const Path{"C:\\Program Files\\Vendor\\Application.exe"}; +const char *const RegEx{"\\w\\([a-z]\\)"}; diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,11 @@ +#include + +void assignment() { + char *a = NULL; + char *b = 0; + char c = 0; +} + +int *ret_ptr() { + return 0; +} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/.dep.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/.dep.inc Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,5 @@ +# This code depends on make tool being used +DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES})) +ifneq (${DEPFILES},) +include ${DEPFILES} +endif diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/Makefile Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,128 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_PLATFORM_${CONF} platform name (current configuration) +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# build tests +build-tests: .build-tests-post + +.build-tests-pre: +# Add your pre 'build-tests' code here... + +.build-tests-post: .build-tests-impl +# Add your post 'build-tests' code here... + + +# run tests +test: .test-post + +.test-pre: build-tests +# Add your pre 'test' code here... + +.test-post: .test-impl +# Add your post 'test' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,83 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Environment +MKDIR=mkdir +CP=cp +GREP=grep +NM=nm +CCADMIN=CCadmin +RANLIB=ranlib +CC=gcc +CCC=g++ +CXX=g++ +FC=gfortran +AS=as + +# Macros +CND_PLATFORM=GNU-Linux +CND_DLIB_EXT=so +CND_CONF=Debug +CND_DISTDIR=dist +CND_BUILDDIR=build + +# Include project Makefile +include Makefile + +# Object Directory +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} + +# Object Files +OBJECTFILES= \ + ${OBJECTDIR}/welcome.o + + +# C Compiler Flags +CFLAGS= + +# CC Compiler Flags +CCFLAGS= +CXXFLAGS= + +# Fortran Compiler Flags +FFLAGS= + +# Assembler Flags +ASFLAGS= + +# Link Libraries and Options +LDLIBSOPTIONS= + +# Build Targets +.build-conf: ${BUILD_SUBPROJECTS} + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world + +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES} + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS} + +${OBJECTDIR}/welcome.o: welcome.cc + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc + +# Subprojects +.build-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} + +# Subprojects +.clean-subprojects: + +# Enable dependency checking +.dep.inc: .depcheck-impl + +include .dep.inc diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,83 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Environment +MKDIR=mkdir +CP=cp +GREP=grep +NM=nm +CCADMIN=CCadmin +RANLIB=ranlib +CC=gcc +CCC=g++ +CXX=g++ +FC=gfortran +AS=as + +# Macros +CND_PLATFORM=GNU-Linux +CND_DLIB_EXT=so +CND_CONF=Release +CND_DISTDIR=dist +CND_BUILDDIR=build + +# Include project Makefile +include Makefile + +# Object Directory +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} + +# Object Files +OBJECTFILES= \ + ${OBJECTDIR}/welcome.o + + +# C Compiler Flags +CFLAGS= + +# CC Compiler Flags +CCFLAGS= +CXXFLAGS= + +# Fortran Compiler Flags +FFLAGS= + +# Assembler Flags +ASFLAGS= + +# Link Libraries and Options +LDLIBSOPTIONS= + +# Build Targets +.build-conf: ${BUILD_SUBPROJECTS} + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world + +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES} + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS} + +${OBJECTDIR}/welcome.o: welcome.cc + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc + +# Subprojects +.build-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} + +# Subprojects +.clean-subprojects: + +# Enable dependency checking +.dep.inc: .depcheck-impl + +include .dep.inc diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,133 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a pre- and a post- target defined where you can add customization code. +# +# This makefile implements macros and targets common to all configurations. +# +# NOCDDL + + +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf +# and .clean-reqprojects-conf unless SUB has the value 'no' +SUB_no=NO +SUBPROJECTS=${SUB_${SUB}} +BUILD_SUBPROJECTS_=.build-subprojects +BUILD_SUBPROJECTS_NO= +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} +CLEAN_SUBPROJECTS_=.clean-subprojects +CLEAN_SUBPROJECTS_NO= +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} + + +# Project Name +PROJECTNAME=hello-world + +# Active Configuration +DEFAULTCONF=Debug +CONF=${DEFAULTCONF} + +# All Configurations +ALLCONFS=Debug Release + + +# build +.build-impl: .build-pre .validate-impl .depcheck-impl + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf + + +# clean +.clean-impl: .clean-pre .validate-impl .depcheck-impl + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf + + +# clobber +.clobber-impl: .clobber-pre .depcheck-impl + @#echo "=> Running $@..." + for CONF in ${ALLCONFS}; \ + do \ + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ + done + +# all +.all-impl: .all-pre .depcheck-impl + @#echo "=> Running $@..." + for CONF in ${ALLCONFS}; \ + do \ + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ + done + +# build tests +.build-tests-impl: .build-impl .build-tests-pre + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf + +# run tests +.test-impl: .build-tests-impl .test-pre + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf + +# dependency checking support +.depcheck-impl: + @echo "# This code depends on make tool being used" >.dep.inc + @if [ -n "${MAKE_VERSION}" ]; then \ + echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \ + echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ + echo "include \$${DEPFILES}" >>.dep.inc; \ + echo "endif" >>.dep.inc; \ + else \ + echo ".KEEP_STATE:" >>.dep.inc; \ + echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ + fi + +# configuration validation +.validate-impl: + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ + then \ + echo ""; \ + echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ + echo "See 'make help' for details."; \ + echo "Current directory: " `pwd`; \ + echo ""; \ + fi + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ + then \ + exit 1; \ + fi + + +# help +.help-impl: .help-pre + @echo "This makefile supports the following configurations:" + @echo " ${ALLCONFS}" + @echo "" + @echo "and the following targets:" + @echo " build (default target)" + @echo " clean" + @echo " clobber" + @echo " all" + @echo " help" + @echo "" + @echo "Makefile Usage:" + @echo " make [CONF=] [SUB=no] build" + @echo " make [CONF=] [SUB=no] clean" + @echo " make [SUB=no] clobber" + @echo " make [SUB=no] all" + @echo " make help" + @echo "" + @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," + @echo " also build subprojects." + @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," + @echo " also clean subprojects." + @echo "Target 'clobber' will remove all built files from all configurations and," + @echo " unless 'SUB=no', also from subprojects." + @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," + @echo " also build subprojects." + @echo "Target 'help' prints this message." + @echo "" + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,35 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +CND_BASEDIR=`pwd` +CND_BUILDDIR=build +CND_DISTDIR=dist +# Debug configuration +CND_PLATFORM_Debug=GNU-Linux +CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux +CND_ARTIFACT_NAME_Debug=hello-world +CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/hello-world +CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package +CND_PACKAGE_NAME_Debug=hello-world.tar +CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/hello-world.tar +# Release configuration +CND_PLATFORM_Release=GNU-Linux +CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux +CND_ARTIFACT_NAME_Release=hello-world +CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/hello-world +CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package +CND_PACKAGE_NAME_Release=hello-world.tar +CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/hello-world.tar +# +# include compiler specific variables +# +# dmake command +ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ + (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) +# +# gmake command +.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) +# +include nbproject/private/Makefile-variables.mk diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,76 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_PLATFORM=GNU-Linux +CND_CONF=Debug +CND_DISTDIR=dist +CND_BUILDDIR=build +CND_DLIB_EXT=so +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world +OUTPUT_BASENAME=hello-world +PACKAGE_TOP_DIR=hello-world/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package +rm -rf ${NBTMPDIR} +mkdir -p ${NBTMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory "${NBTMPDIR}/hello-world/bin" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar +cd ${NBTMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${NBTMPDIR} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,76 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_PLATFORM=GNU-Linux +CND_CONF=Release +CND_DISTDIR=dist +CND_BUILDDIR=build +CND_DLIB_EXT=so +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world +OUTPUT_BASENAME=hello-world +PACKAGE_TOP_DIR=hello-world/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package +rm -rf ${NBTMPDIR} +mkdir -p ${NBTMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory "${NBTMPDIR}/hello-world/bin" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar +cd ${NBTMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${NBTMPDIR} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,71 @@ + + + + + welcome.h + + + + + welcome.cc + + + + + Makefile + + + Makefile + + + + default + true + false + + + + + + + + + + + default + true + false + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,28 @@ + + + org.netbeans.modules.cnd.makeproject + + + hello-world2 + + cc + h + UTF-8 + + + + + Debug + 1 + + + Release + 1 + + + + false + + + + diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2009-2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of Oracle nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +int main(int argc, char**argv) { + // Prints hello message... + std::cout << "Hello World!" << std::endl; + + return 0; +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,62 @@ +package ide.analysis.modernize; + +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix; +import com.sun.tools.ide.analysis.modernize.impl.YamlParser; +import java.io.File; +import java.nio.file.Files; +import java.util.List; +import static junit.framework.TestCase.fail; +import org.netbeans.modules.cnd.test.CndCoreTestUtils; +import static org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestCase.createTempFile; +import org.openide.cookies.EditorCookie; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.loaders.DataObject; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author Ilia Gromov + */ +public class HeaderTest extends TidyTestCase { + + private final String source = "src/llvm-header-guard.cpp"; + private final String header = "src/llvm-header-guard.h"; + + public HeaderTest() { + super("project-with-headers"); + } + + public void testLlvmHeaderGuard() { + performTest(source, "llvm-header-guard", true); + } + + @Override + protected void processTestResults(List fixes, String footerName) throws Exception { + for (ModernizeFix fix : fixes) { + fix.implement(); + + for (YamlParser.Replacement replacement : fix.getReplacements()) { + FileObject fo = FileUtil.toFileObject(new File(replacement.filePath)); + + DataObject dObj = DataObject.find(fo); + EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class); + ec.saveDocument(); + } + } + + File diffFile = createTempFile("diff", null, false); + + boolean diff = CndCoreTestUtils.diff(new File(FileUtil.toFile(getProjectDir()), header), getGoldenFile(header), diffFile); + + if (diff) { + byte[] readAllBytes = Files.readAllBytes(diffFile.toPath()); + System.err.println(new String(readAllBytes)); + fail(); + } + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ide.analysis.modernize; + +import javax.swing.text.Document; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; + +/** + * + * @author Ilia Gromov + */ +class RequestImpl implements CsmErrorProvider.Request { + + private final CsmFile csmFile; + + public RequestImpl(CsmFile csmFile) { + this.csmFile = csmFile; + } + + @Override + public CsmFile getFile() { + return csmFile; + } + + @Override + public boolean isCancelled() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Document getDocument() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public CsmErrorProvider.EditorEvent getEvent() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ide.analysis.modernize; + +import com.sun.tools.ide.analysis.modernize.impl.ModernizeErrorInfo; +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix; +import com.sun.tools.ide.analysis.modernize.impl.YamlParser; +import java.util.List; +import junit.framework.TestCase; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; +import org.openide.util.Exceptions; + +/** + * + * @author Ilia Gromov + */ +class ResponseImpl implements CsmErrorProvider.Response { + + private final List fixes; + + public ResponseImpl(List fixes) { + this.fixes = fixes; + } + + @Override + public void addError(CsmErrorInfo info) { + try { + TestCase.assertTrue(info instanceof ModernizeErrorInfo); + final List replacements = ((ModernizeErrorInfo) info).getDiagnostics().getReplacements(); + final String id = ((ModernizeErrorInfo) info).getId(); + ModernizeFix fix = new ModernizeFix(replacements, id); + fixes.add(fix); + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + } + } + + @Override + public void done() { + } + +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,64 @@ +package ide.analysis.modernize; + +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix; +import java.io.File; +import java.nio.file.Files; +import java.util.List; +import org.junit.Test; +import org.netbeans.modules.cnd.test.CndCoreTestUtils; +import org.openide.cookies.EditorCookie; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.loaders.DataObject; + +/** + * + * @author Ilia Gromov + */ +public class SingleCppFileCheckTest extends TidyTestCase { + + public SingleCppFileCheckTest() { + super("hello-cmake-world"); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + public void testModernizeUseNullptr() { + performTest("src/modernize-use-nullptr.cpp", "modernize-use-nullptr", true); + } + + public void testModernizeLoopConvert() { + performTest("src/modernize-loop-convert.cpp", "modernize-loop-convert", true); + } + + @Test + public void testModernizeRawStringLiteral() { + performTest("src/modernize-raw-string-literal.cpp", "modernize-raw-string-literal", true); + } + + @Override + protected void processTestResults(List fixes, String startFileName) throws Exception { + for (ModernizeFix fix : fixes) { + fix.implement(); + } + + FileObject footer = getSourceFile(startFileName); + + DataObject dObj = DataObject.find(footer); + EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class); + ec.saveDocument(); + + File diffFile = createTempFile("diff", null, false); + + boolean diff = CndCoreTestUtils.diff(FileUtil.toFile(footer), getGoldenFile(startFileName), diffFile); + + if (diff) { + byte[] readAllBytes = Files.readAllBytes(diffFile.toPath()); + System.err.println(new String(readAllBytes)); + fail(); + } + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,237 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package ide.analysis.modernize; + +import com.sun.tools.ide.analysis.modernize.impl.DiagnosticsTool; +import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl; +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix; +import com.sun.tools.ide.analysis.modernize.impl.YamlParser; +import com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.prefs.Preferences; +import org.netbeans.api.progress.ProgressHandle; +import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectManager; +import org.netbeans.api.project.ui.OpenProjects; +import org.netbeans.modules.analysis.SPIAccessor; +import org.netbeans.modules.analysis.spi.Analyzer; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.api.model.CsmModel; +import org.netbeans.modules.cnd.api.model.CsmModelAccessor; +import org.netbeans.modules.cnd.api.model.CsmProject; +import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; +import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; +import org.netbeans.modules.cnd.api.project.NativeProject; +import org.netbeans.modules.cnd.api.project.NativeProjectRegistry; +import org.netbeans.modules.cnd.api.toolchain.CompilerSet; +import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager; +import org.netbeans.modules.cnd.makeproject.api.MakeProject; +import org.netbeans.modules.cnd.makeproject.api.configurations.Item; +import org.netbeans.modules.cnd.modelutil.CsmUtilities; +import org.netbeans.modules.cnd.test.CndBaseTestCase; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; +import org.netbeans.modules.refactoring.api.Scope; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; + +/** + * + * @author Ilia Gromov + */ +public abstract class TidyTestCase extends CndBaseTestCase { + + private final String projectName; + + private List fileObjects; + private MakeProject project; + private FileObject projectDirFileObject; + + private final String CLANG_TIDY_PATH = "clang-tidy-3.9p"; + + public TidyTestCase(String projectName) { + super(projectName); + + this.projectName = projectName; + } + + protected static CodeAudit findAudit(Collection audits, String id) { + for (CodeAudit audit : audits) { + if (audit.getID().equals(id)) { + return audit; + } + } + return null; + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + LogManager.getLogManager().reset(); + + java.util.logging.Logger LOG = java.util.logging.Logger.getLogger("ide.analysis.tidy"); + LOG.setLevel(Level.ALL); + + ConsoleHandler consoleHandler = new ConsoleHandler(); + consoleHandler.setLevel(Level.ALL); + LOG.addHandler(consoleHandler); + + File clangTidyFile = getBinaryFile(); + Files.setPosixFilePermissions(clangTidyFile.toPath(), PosixFilePermissions.fromString("rwxrwxrwx")); + + assertTrue(getBinaryFile().exists()); + + File projectDirFile = getDataFile(projectName); + projectDirFileObject = FileUtil.toFileObject(projectDirFile); + + fileObjects = new ArrayList(); + + project = (MakeProject) ProjectManager.getDefault().findProject(projectDirFileObject); + + OpenProjects.getDefault().open(new Project[]{project}, false); + while (!OpenProjects.getDefault().isProjectOpen(project)) { + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } + } + + CsmModel model = CsmModelAccessor.getModel(); + assertNotNull(project); + + NativeProject np = project.getLookup().lookup(NativeProject.class); + NativeProjectRegistry.getDefault().register(np); + model.enableProject(np); + assertNotNull(np); + + CsmProject csmProject = model.getProject(np); + assertNotNull(csmProject); + + csmProject.waitParse(); + + } + + public ExecutionEnvironment getExecEnv() { + ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal(); + return execEnv; + } + + public CompilerSet getCompilerSet() { + CompilerSetManager csm = CompilerSetManager.get(getExecEnv()); + return csm.getDefaultCompilerSet(); + } + + public MakeProject getProject() { + return project; + } + + public FileObject getProjectDir() { + return projectDirFileObject; + } + + public FileObject getSourceFile(String name) { + return FileUtil.toFileObject(new File(FileUtil.toFile(getProjectDir()), name)); + } + + public File getBinaryFile() { + return new File(getDataDir(), CLANG_TIDY_PATH); + } + + protected final void performTest(String startFileName, String checkName, boolean isStartFile) { + try { + FileObject startFile = getSourceFile(startFileName); + assertTrue(startFile.isValid()); + + Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{startFile})); + Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0); + Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl(); + + ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context); + ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal(); + final CsmFile csmFile = CsmUtilities.getCsmFile(startFile, true, false); + Item item = AnalyticsTools.findItem(csmFile, getProject()); + + Collection audits = DiagnosticsTool.getAudits(getBinaryFile().getAbsolutePath(), execEnv, new AuditPreferences(Preferences.userNodeForPackage(this.getClass()))); + CodeAudit audit = findAudit(audits, checkName); + assertNotNull(audit); + + // ----- BEGIN diagnostics ----- + DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath()); + + int exitCode = diagnosticsTool.process(Collections.singleton(audit.getID()), csmFile, true); + if (exitCode != DiagnosticsTool.STATUS_OK) { + fail(); + } + + List diags = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString()); + List fixes = new ArrayList(); + + CsmErrorProvider.Request request = new RequestImpl(csmFile); + CsmErrorProvider.Response response = new ResponseImpl(fixes); + + analyzer.getErrorProvider(null).postProcess(false, csmFile, getProject(), diags, request, response); + // ----- END diagnostics ----- + + processTestResults(fixes, startFileName); + } catch (Exception ex) { + ex.printStackTrace(System.err); + fail(ex.toString()); + } + } + + protected void processTestResults(List fixes, String startFileName) throws Exception { + + } +} diff -r 1520ed2e78e3 -r 47444533169e c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,117 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package ide.analysis.modernize; + +import com.sun.tools.ide.analysis.modernize.impl.DiagnosticsTool; +import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl; +import com.sun.tools.ide.analysis.modernize.utils.AnalyticsTools; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.Collections; +import org.junit.Test; +import org.netbeans.api.progress.ProgressHandle; +import org.netbeans.modules.analysis.SPIAccessor; +import org.netbeans.modules.analysis.spi.Analyzer; +import org.netbeans.modules.cnd.api.model.CsmFile; +import org.netbeans.modules.cnd.makeproject.api.configurations.Item; +import org.netbeans.modules.cnd.modelutil.CsmUtilities; +import org.netbeans.modules.cnd.test.CndCoreTestUtils; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.refactoring.api.Scope; +import org.openide.filesystems.FileObject; + +/** + * + * @author Ilia Gromov + */ +public class YamlTest extends TidyTestCase { + + public YamlTest() { + super("hello-world"); + } + + @Test + public void testYaml() throws IOException, ConnectionManager.CancellationException { + FileObject singleFileObject = getSourceFile("welcome.cc"); + + File goldenFile = getGoldenFile("hello-world.json"); + String goldenYaml = new String(Files.readAllBytes(goldenFile.toPath()), "UTF-8").replaceAll("\\$path", getDataDir().getAbsolutePath()); + + Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{singleFileObject})); + Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0); + + Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl(); + ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context); + + ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal(); + + CsmFile csmFile = CsmUtilities.getCsmFile(singleFileObject, false, false); + Item item = AnalyticsTools.findItem(csmFile, getProject()); + + DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath()); + + int exitCode = diagnosticsTool.process(Collections.singleton("*"), csmFile, true); + + if (exitCode != DiagnosticsTool.STATUS_OK) { + fail(); + } + String yamlAsString = diagnosticsTool.getYamlAsString(); + + File real = File.createTempFile("test", null); + Files.write(real.toPath(), yamlAsString.getBytes()); + + File expected = File.createTempFile("test", null); + Files.write(expected.toPath(), goldenYaml.getBytes()); + + File diff = File.createTempFile("test", null); + if (CndCoreTestUtils.diff(real, expected, diff)) { + System.err.println("============DIFF============"); + System.err.println(new String(Files.readAllBytes(diff.toPath()), "UTF-8")); + System.err.println("============DIFF============"); + fail(); + } + } +} diff -r 1520ed2e78e3 -r 47444533169e callgraph/src/main/java/org/netbeans/lib/callgraph/Arguments.java --- a/callgraph/src/main/java/org/netbeans/lib/callgraph/Arguments.java Sun Jun 25 18:17:37 2017 +0200 +++ b/callgraph/src/main/java/org/netbeans/lib/callgraph/Arguments.java Sun Jun 25 18:25:05 2017 +0200 @@ -43,7 +43,6 @@ */ package org.netbeans.lib.callgraph; -import com.sun.javafx.scene.traversal.WeightedClosestCorner; import java.io.File; import java.io.IOException; import java.util.Arrays; diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/build.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project analysis.clangtidy.Linux_x86_64. + + diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/manifest.mf Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: true +OpenIDE-Module: org.netbeans.modules.analysis.clangtidy.Linux_x86_64 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/analysis/clangtidy/Linux_x86_64/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0.2 + diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/build-impl.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/platform.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/platform.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,16 @@ +cluster.path=\ + ${nbplatform.active.dir}/profiler:\ + ${nbplatform.active.dir}/nb:\ + ${nbplatform.active.dir}/websvccommon:\ + ${nbplatform.active.dir}/java:\ + ${nbplatform.active.dir}/platform:\ + ${nbplatform.active.dir}/cnd:\ + ${nbplatform.active.dir}/ergonomics:\ + ${nbplatform.active.dir}/cndext:\ + ${nbplatform.active.dir}/apisupport:\ + ${nbplatform.active.dir}/extide:\ + ${nbplatform.active.dir}/javafx:\ + ${nbplatform.active.dir}/ide:\ + ${nbplatform.active.dir}/dlight:\ + ${nbplatform.active.dir}/harness +nbplatform.active=default diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/project.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,9 @@ +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial +license.file=src/org/netbeans/modules/analysis/clangtidy/Linux_x86_64/LICENSE.TXT +nbm.executable.files=clang-tidy/** +nbm.homepage=http://clang.llvm.org/extra/clang-tidy/ +nbm.module.author=Ilia Gromov +nbm.needs.restart=true +keystore=nbproject/private/keystore +nbm_alias=myself \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/nbproject/project.xml Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,12 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.analysis.clangtidy.Linux_x86_64 + + + + + + diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/release/clang-tidy/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/release/clang-tidy/README.txt Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,1 @@ +Place clang-tidy binary near this file diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/src/org/netbeans/modules/analysis/clangtidy/Linux_x86_64/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/src/org/netbeans/modules/analysis/clangtidy/Linux_x86_64/Bundle.properties Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,3 @@ +OpenIDE-Module-Display-Category=Analysis tools +OpenIDE-Module-Name=Linux x86_64 clang-tidy +OpenIDE-Module-Short-Description=Bundled clang-tidy binaries for Linux x86-64 diff -r 1520ed2e78e3 -r 47444533169e clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/src/org/netbeans/modules/analysis/clangtidy/Linux_x86_64/LICENSE.TXT --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clang-tidy.wrappers/analysis.clangtidy.Linux_x86_64/src/org/netbeans/modules/analysis/clangtidy/Linux_x86_64/LICENSE.TXT Sun Jun 25 18:25:05 2017 +0200 @@ -0,0 +1,157 @@ +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2016 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with LLVM: +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +Autoconf llvm/autoconf + llvm/projects/ModuleMaker/autoconf +Google Test llvm/utils/unittest/googletest +OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} +pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} +ARM contributions llvm/lib/Target/ARM/LICENSE.TXT +md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h + +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2007-2016 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +clang-tidy clang-tidy/cert + +------------------------------------------------------------------------------ +clang-tidy CERT Files +------------------------------------------------------------------------------ +All clang-tidy files are licensed under the LLVM license with the following +additions: + +Any file referencing a CERT Secure Coding guideline: +Please allow this letter to serve as confirmation that open source projects on +http://llvm.org are permitted to link via hypertext to the CERT(R) secure coding +guidelines available at https://www.securecoding.cert.org. + +The foregoing is permitted by the Terms of Use as follows: +"Linking to the Service +Because we update many of our Web documents regularly, we would prefer that you +link to our Web pages whenever possible rather than reproduce them. It is not +necessary to request permission to make referential hypertext links to The +Service." +http://www.sei.cmu.edu/legal/ip/index.cfm. + +Please allow this letter to also confirm that no formal permission is required +to reproduce the title of the content being linked to, nor to reproduce any +de Minimis description of such content. + diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/build.xml --- a/ide.analysis.modernize/build.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - Builds, tests, and runs the project org.netbeans.modules.ide.analysis.modernize. - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/l10n.list --- a/ide.analysis.modernize/l10n.list Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -src/**/Bundle.properties - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/license.txt --- a/ide.analysis.modernize/license.txt Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,565 +0,0 @@ -NetBeans IDE Dual License Header and License Notice - -Oracle elects to use only the GNU Lesser General Public License version 2.1 -(LGPL) for any software where a choice of LGPL/GPL license versions are made -available with the language indicating that LGPLv2.1/GPLv2 or any later version -may be used, or where a choice of which version of the LGPL/GPL is applied is -unspecified. -For more information on the license please see: the NetBeans License FAQs. - -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. -1.1. "Contributor" means each individual or entity that creates or contributes -to the creation of Modifications. -1.2. "Contributor Version" means the combination of the Original Software, -prior Modifications used by a Contributor (if any), and the Modifications made -by that particular Contributor. -1.3. "Covered Software" means (a) the Original Software, or (b) Modifications, -or (c) the combination of files containing Original Software with files -containing Modifications, in each case including portions thereof. -1.4. "Executable" means the Covered Software in any form other than Source Code. -1.5. "Initial Developer" means the individual or entity that first makes -Original Software available under this License. -1.6. "Larger Work" means a work which combines Covered Software or portions -thereof with code not governed by the terms of this License. -1.7. "License" means this document. -1.8. "Licensable" means having the right to grant, to the maximum extent -possible, whether at the time of the initial grant or subsequently acquired, -any and all of the rights conveyed herein. -1.9 "Modifications" means the Source Code and Executable form of any of the -following: -A. Any file that results from an addition to, deletion from or modification of -the contents of a file containing Original Software or previous Modifications; -B. Any new file that contains any part of the Original Software or previous -Modification; or -C. Any new file that is contributed or otherwise made available under the terms -of this License. -1.10. "Original Software" means the Source Code and Executable form of computer -software code that is originally released under this License. -1.11. "Patent Claims" means any patent claim(s), now owned or hereafter -acquired, including without limitation, method, process, and apparatus claims, -in any patent Licensable by grantor. -1.12. "Source Code" means (a) the common form of computer software code in -which modifications are made and (b) associated documentation included in or -with such code. -1.13. "You" (or "Your") means an individual or a legal entity exercising rights -under, and complying with all of the terms of, this License. For legal -entities, "You" includes any entity which controls, is controlled by, or is -under common control with You. For purposes of this definition, "control" means -(a) the power, direct or indirect, to cause the direction or management of such -entity, whether by contract or otherwise, or (b) ownership of more than fifty -percent (50%) of the outstanding shares or beneficial ownership of such entity. -2. License Grants. -2.1. The Initial Developer Grant. -Conditioned upon Your compliance with Section 3.1 below and subject to third -party intellectual property claims, the Initial Developer hereby grants You a -world-wide, royalty-free, non-exclusive license: -(a) under intellectual property rights (other than patent or trademark) -Licensable by Initial Developer, to use, reproduce, modify, display, perform, -sublicense and distribute the Original Software (or portions thereof), with or -without Modifications, and/or as part of a Larger Work; and -(b) under Patent Claims infringed by the making, using or selling of Original -Software, to make, have made, use, practice, sell, and offer for sale, and/or -otherwise dispose of the Original Software (or portions thereof). -(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date -Initial Developer first distributes or otherwise makes the Original Software -available to a third party under the terms of this License. -(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for -code that You delete from the Original Software, or (2) for infringements -caused by: (i) the modification of the Original Software, or (ii) the -combination of the Original Software with other software or devices. -2.2. Contributor Grant. -Conditioned upon Your compliance with Section 3.1 below and subject to third -party intellectual property claims, each Contributor hereby grants You a -world-wide, royalty-free, non-exclusive license: -(a) under intellectual property rights (other than patent or trademark) -Licensable by Contributor to use, reproduce, modify, display, perform, -sublicense and distribute the Modifications created by such Contributor (or -portions thereof), either on an unmodified basis, with other Modifications, as -Covered Software and/or as part of a Larger Work; and -(b) under Patent Claims infringed by the making, using, or selling of -Modifications made by that Contributor either alone and/or in combination with -its Contributor Version (or portions of such combination), to make, use, sell, -offer for sale, have made, and/or otherwise dispose of: (1) Modifications made -by that Contributor (or portions thereof); and (2) the combination of -Modifications made by that Contributor with its Contributor Version (or -portions of such combination). -(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the -date Contributor first distributes or otherwise makes the Modifications -available to a third party. -(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for -any code that Contributor has deleted from the Contributor Version; (2) for -infringements caused by: (i) third party modifications of Contributor Version, -or (ii) the combination of Modifications made by that Contributor with other -software (except as part of the Contributor Version) or other devices; or (3) -under Patent Claims infringed by Covered Software in the absence of -Modifications made by that Contributor. -3. Distribution Obligations. -3.1. Availability of Source Code. -Any Covered Software that You distribute or otherwise make available in -Executable form must also be made available in Source Code form and that Source -Code form must be distributed only under the terms of this License. You must -include a copy of this License with every copy of the Source Code form of the -Covered Software You distribute or otherwise make available. You must inform -recipients of any such Covered Software in Executable form as to how they can -obtain such Covered Software in Source Code form in a reasonable manner on or -through a medium customarily used for software exchange. -3.2. Modifications. -The Modifications that You create or to which You contribute are governed by -the terms of this License. You represent that You believe Your Modifications -are Your original creation(s) and/or You have sufficient rights to grant the -rights conveyed by this License. -3.3. Required Notices. -You must include a notice in each of Your Modifications that identifies You as -the Contributor of the Modification. You may not remove or alter any copyright, -patent or trademark notices contained within the Covered Software, or any -notices of licensing or any descriptive text giving attribution to any -Contributor or the Initial Developer. -3.4. Application of Additional Terms. -You may not offer or impose any terms on any Covered Software in Source Code -form that alters or restricts the applicable version of this License or the -recipients� rights hereunder. You may choose to offer, and to charge a fee -for, warranty, support, indemnity or liability obligations to one or more -recipients of Covered Software. However, you may do so only on Your own behalf, -and not on behalf of the Initial Developer or any Contributor. You must make it -absolutely clear that any such warranty, support, indemnity or liability -obligation is offered by You alone, and You hereby agree to indemnify the -Initial Developer and every Contributor for any liability incurred by the -Initial Developer or such Contributor as a result of warranty, support, -indemnity or liability terms You offer. -3.5. Distribution of Executable Versions. -You may distribute the Executable form of the Covered Software under the terms -of this License or under the terms of a license of Your choice, which may -contain terms different from this License, provided that You are in compliance -with the terms of this License and that the license for the Executable form -does not attempt to limit or alter the recipient�s rights in the Source Code -form from the rights set forth in this License. If You distribute the Covered -Software in Executable form under a different license, You must make it -absolutely clear that any terms which differ from this License are offered by -You alone, not by the Initial Developer or Contributor. You hereby agree to -indemnify the Initial Developer and every Contributor for any liability -incurred by the Initial Developer or such Contributor as a result of any such -terms You offer. -3.6. Larger Works. -You may create a Larger Work by combining Covered Software with other code not -governed by the terms of this License and distribute the Larger Work as a -single product. In such a case, You must make sure the requirements of this -License are fulfilled for the Covered Software. -4. Versions of the License. -4.1. New Versions. -Oracle Corp. is the initial license steward and may publish revised and/or new -versions of this License from time to time. Each version will be given a -distinguishing version number. Except as provided in Section 4.3, no one other -than the license steward has the right to modify this License. -4.2. Effect of New Versions. -You may always continue to use, distribute or otherwise make the Covered -Software available under the terms of the version of the License under which -You originally received the Covered Software. If the Initial Developer includes -a notice in the Original Software prohibiting it from being distributed or -otherwise made available under any subsequent version of the License, You must -distribute and make the Covered Software available under the terms of the -version of the License under which You originally received the Covered -Software. Otherwise, You may also choose to use, distribute or otherwise make -the Covered Software available under the terms of any subsequent version of the -License published by the license steward. -4.3. Modified Versions. -When You are an Initial Developer and You want to create a new license for Your -Original Software, You may create and use a modified version of this License if -You: (a) rename the license and remove any references to the name of the -license steward (except to note that the license differs from this License); -and (b) otherwise make it clear that the license contains terms which differ -from this License. -5. DISCLAIMER OF WARRANTY. -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT -WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT -LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, -MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK -AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD -ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL -DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, -REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART -OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT -UNDER THIS DISCLAIMER. -6. TERMINATION. -6.1. This License and the rights granted hereunder will terminate automatically -if You fail to comply with terms herein and fail to cure such breach within 30 -days of becoming aware of the breach. Provisions which, by their nature, must -remain in effect beyond the termination of this License shall survive. -6.2. If You assert a patent infringement claim (excluding declaratory judgment -actions) against Initial Developer or a Contributor (the Initial Developer or -Contributor against whom You assert such claim is referred to as "Participant") -alleging that the Participant Software (meaning the Contributor Version where -the Participant is a Contributor or the Original Software where the Participant -is the Initial Developer) directly or indirectly infringes any patent, then any -and all rights granted directly or indirectly to You by such Participant, the -Initial Developer (if the Initial Developer is not the Participant) and all -Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days -notice from Participant terminate prospectively and automatically at the -expiration of such 60 day notice period, unless if within such 60 day period -You withdraw Your claim with respect to the Participant Software against such -Participant either unilaterally or pursuant to a written agreement with -Participant. -6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user -licenses that have been validly granted by You or any distributor hereunder -prior to termination (excluding licenses granted to You by any distributor) -shall survive termination. -7. LIMITATION OF LIABILITY. -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING -NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY -OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF -ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, -INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT -LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER -FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN -IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS -LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY�S NEGLIGENCE TO THE EXTENT APPLICABLE LAW -PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR -LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND -LIMITATION MAY NOT APPLY TO YOU. -8. U.S. GOVERNMENT END USERS. -The Covered Software is a "commercial item," as that term is defined in 48 -C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" (as that -term is defined at 48 C.F.R. �252.227-7014(a)(1)) and "commercial computer -software documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through -227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software -with only those rights set forth herein. This U.S. Government Rights clause is -in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision -that addresses Government rights in computer software under this License. -9. MISCELLANEOUS. -This License represents the complete agreement concerning subject matter -hereof. If any provision of this License is held to be unenforceable, such -provision shall be reformed only to the extent necessary to make it -enforceable. This License shall be governed by the law of the jurisdiction -specified in a notice contained within the Original Software (except to the -extent applicable law, if any, provides otherwise), excluding such -jurisdiction�s conflict-of-law provisions. Any litigation relating to this -License shall be subject to the jurisdiction of the courts located in the -jurisdiction and venue specified in a notice contained within the Original -Software, with the losing party responsible for costs, including, without -limitation, court costs and reasonable attorneys� fees and expenses. The -application of the United Nations Convention on Contracts for the International -Sale of Goods is expressly excluded. Any law or regulation which provides that -the language of a contract shall be construed against the drafter shall not -apply to this License. You agree that You alone are responsible for compliance -with the United States export administration regulations (and the export -control laws and regulation of any other countries) when You use, distribute or -otherwise make available any Covered Software. -10. RESPONSIBILITY FOR CLAIMS. -As between Initial Developer and the Contributors, each party is responsible -for claims and damages arising, directly or indirectly, out of its utilization -of rights under this License and You agree to work with Initial Developer and -Contributors to distribute such responsibility on an equitable basis. Nothing -herein is intended or shall be deemed to constitute any admission of liability. -NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE -(CDDL) -The code released under the CDDL shall be governed by the laws of the State of -California (excluding conflict-of-law provisions). Any litigation relating to -this License shall be subject to the jurisdiction of the Federal Courts of the -Northern District of California and the state courts of the State of -California, with venue lying in Santa Clara County, California. -The GNU General Public License (GPL) Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite -330, Boston, MA 02111-1307 USA -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. -Preamble -The licenses for most software are designed to take away your freedom to share -and change it. By contrast, the GNU General Public License is intended to -guarantee your freedom to share and change free software--to make sure the -software is free for all its users. This General Public License applies to most -of the Free Software Foundation's software and to any other program whose -authors commit to using it. (Some other Free Software Foundation software is -covered by the GNU Library General Public License instead.) You can apply it to -your programs, too. -When we speak of free software, we are referring to freedom, not price. Our -General Public Licenses are designed to make sure that you have the freedom to -distribute copies of free software (and charge for this service if you wish), -that you receive source code or can get it if you want it, that you can change -the software or use pieces of it in new free programs; and that you know you -can do these things. -To protect your rights, we need to make restrictions that forbid anyone to deny -you these rights or to ask you to surrender the rights. These restrictions -translate to certain responsibilities for you if you distribute copies of the -software, or if you modify it. -For example, if you distribute copies of such a program, whether gratis or for -a fee, you must give the recipients all the rights that you have. You must make -sure that they, too, receive or can get the source code. And you must show them -these terms so they know their rights. -We protect your rights with two steps: (1) copyright the software, and (2) -offer you this license which gives you legal permission to copy, distribute -and/or modify the software. -Also, for each author's protection and ours, we want to make certain that -everyone understands that there is no warranty for this free software. If the -software is modified by someone else and passed on, we want its recipients to -know that what they have is not the original, so that any problems introduced -by others will not reflect on the original authors' reputations. -Finally, any free program is threatened constantly by software patents. We wish -to avoid the danger that redistributors of a free program will individually -obtain patent licenses, in effect making the program proprietary. To prevent -this, we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. -The precise terms and conditions for copying, distribution and modification -follow. -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -0. This License applies to any program or other work which contains a notice -placed by the copyright holder saying it may be distributed under the terms of -this General Public License. The "Program", below, refers to any such program -or work, and a "work based on the Program" means either the Program or any -derivative work under copyright law: that is to say, a work containing the -Program or a portion of it, either verbatim or with modifications and/or -translated into another language. (Hereinafter, translation is included without -limitation in the term "modification".) Each licensee is addressed as "you". -Activities other than copying, distribution and modification are not covered by -this License; they are outside its scope. The act of running the Program is not -restricted, and the output from the Program is covered only if its contents -constitute a work based on the Program (independent of having been made by -running the Program). Whether that is true depends on what the Program does. -1. You may copy and distribute verbatim copies of the Program's source code as -you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this License -and to the absence of any warranty; and give any other recipients of the -Program a copy of this License along with the Program. -You may charge a fee for the physical act of transferring a copy, and you may -at your option offer warranty protection in exchange for a fee. -2. You may modify your copy or copies of the Program or any portion of it, thus -forming a work based on the Program, and copy and distribute such modifications -or work under the terms of Section 1 above, provided that you also meet all of -these conditions: -a) You must cause the modified files to carry prominent notices stating that -you changed the files and the date of any change. -b) You must cause any work that you distribute or publish, that in whole or in -part contains or is derived from the Program or any part thereof, to be -licensed as a whole at no charge to all third parties under the terms of this -License. -c) If the modified program normally reads commands interactively when run, you -must cause it, when started running for such interactive use in the most -ordinary way, to print or display an announcement including an appropriate -copyright notice and a notice that there is no warranty (or else, saying that -you provide a warranty) and that users may redistribute the program under these -conditions, and telling the user how to view a copy of this License. -(Exception: if the Program itself is interactive but does not normally print -such an announcement, your work based on the Program is not required to print -an announcement.) -These requirements apply to the modified work as a whole. If identifiable -sections of that work are not derived from the Program, and can be reasonably -considered independent and separate works in themselves, then this License, and -its terms, do not apply to those sections when you distribute them as separate -works. But when you distribute the same sections as part of a whole which is a -work based on the Program, the distribution of the whole must be on the terms -of this License, whose permissions for other licensees extend to the entire -whole, and thus to each and every part regardless of who wrote it. -Thus, it is not the intent of this section to claim rights or contest your -rights to work written entirely by you; rather, the intent is to exercise the -right to control the distribution of derivative or collective works based on -the Program. -In addition, mere aggregation of another work not based on the Program with the -Program (or with a work based on the Program) on a volume of a storage or -distribution medium does not bring the other work under the scope of this -License. -3. You may copy and distribute the Program (or a work based on it, under -Section 2) in object code or executable form under the terms of Sections 1 and -2 above provided that you also do one of the following: -a) Accompany it with the complete corresponding machine-readable source code, -which must be distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, -b) Accompany it with a written offer, valid for at least three years, to give -any third party, for a charge no more than your cost of physically performing -source distribution, a complete machine-readable copy of the corresponding -source code, to be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange; or, -c) Accompany it with the information you received as to the offer to distribute -corresponding source code. (This alternative is allowed only for noncommercial -distribution and only if you received the program in object code or executable -form with such an offer, in accord with Subsection b above.) -The source code for a work means the preferred form of the work for making -modifications to it. For an executable work, complete source code means all the -source code for all modules it contains, plus any associated interface -definition files, plus the scripts used to control compilation and installation -of the executable. However, as a special exception, the source code distributed -need not include anything that is normally distributed (in either source or -binary form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component itself -accompanies the executable. -If distribution of executable or object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the source -code from the same place counts as distribution of the source code, even though -third parties are not compelled to copy the source along with the object code. -4. You may not copy, modify, sublicense, or distribute the Program except as -expressly provided under this License. Any attempt otherwise to copy, modify, -sublicense or distribute the Program is void, and will automatically terminate -your rights under this License. However, parties who have received copies, or -rights, from you under this License will not have their licenses terminated so -long as such parties remain in full compliance. -5. You are not required to accept this License, since you have not signed it. -However, nothing else grants you permission to modify or distribute the Program -or its derivative works. These actions are prohibited by law if you do not -accept this License. Therefore, by modifying or distributing the Program (or -any work based on the Program), you indicate your acceptance of this License to -do so, and all its terms and conditions for copying, distributing or modifying -the Program or works based on it. -6. Each time you redistribute the Program (or any work based on the Program), -the recipient automatically receives a license from the original licensor to -copy, distribute or modify the Program subject to these terms and conditions. -You may not impose any further restrictions on the recipients' exercise of the -rights granted herein. You are not responsible for enforcing compliance by -third parties to this License. -7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), conditions -are imposed on you (whether by court order, agreement or otherwise) that -contradict the conditions of this License, they do not excuse you from the -conditions of this License. If you cannot distribute so as to satisfy -simultaneously your obligations under this License and any other pertinent -obligations, then as a consequence you may not distribute the Program at all. -For example, if a patent license would not permit royalty-free redistribution -of the Program by all those who receive copies directly or indirectly through -you, then the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply and -the section as a whole is intended to apply in other circumstances. -It is not the purpose of this section to induce you to infringe any patents or -other property right claims or to contest validity of any such claims; this -section has the sole purpose of protecting the integrity of the free software -distribution system, which is implemented by public license practices. Many -people have made generous contributions to the wide range of software -distributed through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing to -distribute software through any other system and a licensee cannot impose that -choice. -This section is intended to make thoroughly clear what is believed to be a -consequence of the rest of this License. -8. If the distribution and/or use of the Program is restricted in certain -countries either by patents or by copyrighted interfaces, the original -copyright holder who places the Program under this License may add an explicit -geographical distribution limitation excluding those countries, so that -distribution is permitted only in or among countries not thus excluded. In such -case, this License incorporates the limitation as if written in the body of -this License. -9. The Free Software Foundation may publish revised and/or new versions of the -General Public License from time to time. Such new versions will be similar in -spirit to the present version, but may differ in detail to address new problems -or concerns. -Each version is given a distinguishing version number. If the Program specifies -a version number of this License which applies to it and "any later version", -you have the option of following the terms and conditions either of that -version or of any later version published by the Free Software Foundation. If -the Program does not specify a version number of this License, you may choose -any version ever published by the Free Software Foundation. -10. If you wish to incorporate parts of the Program into other free programs -whose distribution conditions are different, write to the author to ask for -permission. For software which is copyrighted by the Free Software Foundation, -write to the Free Software Foundation; we sometimes make exceptions for this. -Our decision will be guided by the two goals of preserving the free status of -all derivatives of our free software and of promoting the sharing and reuse of -software generally. -NO WARRANTY -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR -THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE -STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE -PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU -ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE -PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR -INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA -BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER -OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -END OF TERMS AND CONDITIONS -How to Apply These Terms to Your New Programs -If you develop a new program, and you want it to be of the greatest possible -use to the public, the best way to achieve this is to make it free software -which everyone can redistribute and change under these terms. -To do so, attach the following notices to the program. It is safest to attach -them to the start of each source file to most effectively convey the exclusion -of warranty; and each file should have at least the "copyright" line and a -pointer to where the full notice is found. -One line to give the program's name and a brief idea of what it does. -Copyright (C) -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA -Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this when it -starts in an interactive mode: -Gnomovision version 69, Copyright (C) year name of author -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This -is free software, and you are welcome to redistribute it under certain -conditions; type `show c' for details. -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may be -called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. -You should also get your employer (if you work as a programmer) or your school, -if any, to sign a "copyright disclaimer" for the program, if necessary. Here is -a sample; alter the names: -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. -signature of Ty Coon, 1 April 1989 -Ty Coon, President of Vice -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may consider -it more useful to permit linking proprietary applications with the library. If -this is what you want to do, use the GNU Library General Public License instead -of this License. -"CLASSPATH" EXCEPTION TO THE GPL VERSION 2 -Certain source files distributed by Oracle America, Inc. and/or its affiliates -are subject to the following clarification and special exception to the GPLv2, -based on the GNU Project exception for its Classpath libraries, known as the -GNU Classpath Exception, but only where Oracle has expressly included in the -particular source file's header the words "Oracle designates this particular -file as subject to the "Classpath" exception as provided by Oracle in the -LICENSE file that accompanied this code." -You should also note that Oracle includes multiple, independent programs in -this software package. Some of those programs are provided under licenses -deemed incompatible with the GPLv2 by the Free Software Foundation and others. -For example, the package includes programs licensed under the Apache License, -Version 2.0. Such programs are licensed to you under their original licenses. -Oracle facilitates your further distribution of this package by adding the -Classpath Exception to the necessary parts of its GPLv2 code, which permits you -to use that code in combination with other independent modules not licensed -under the GPLv2. However, note that this would not permit you to commingle code -under an incompatible license with Oracle's GPLv2 licensed code by, for -example, cutting and pasting such code into a file also containing Oracle's -GPLv2 licensed code and then distributing the result. -Additionally, if you were to remove the Classpath Exception from any of the -files to which it applies and distribute the result, you would likely be -required to license some or all of the other code in that distribution under -the GPLv2 as well, and since the GPLv2 is incompatible with the license terms -of some items included in the distribution by Oracle, removing the Classpath -Exception could therefore effectively compromise your ability to further -distribute the package. -Proceed with caution and we recommend that you obtain the advice of a lawyer -skilled in open source matters before removing the Classpath Exception or -making modifications to this package which may subsequently be redistributed -and/or involve the use of third party software. -CLASSPATH EXCEPTION -Linking this library statically or dynamically with other modules is making a -combined work based on this library. Thus, the terms and conditions of the GNU -General Public License version 2 cover the whole combination. -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent modules, and -to copy and distribute the resulting executable under terms of your choice, -provided that you also meet, for each linked independent module, the terms and -conditions of the license of that module. An independent module is a module -which is not derived from or based on this library. If you modify this library, -you may extend this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this exception -statement from your version. diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/manifest.mf --- a/ide.analysis.modernize/manifest.mf Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: true -OpenIDE-Module: org.netbeans.modules.ide.analysis.modernize -OpenIDE-Module-Layer: org/netbeans/modules/ide/analysis/modernize/layer.xml -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/ide/analysis/modernize/Bundle.properties -OpenIDE-Module-Specification-Version: 1.1.1 diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/nbproject/project.properties --- a/ide.analysis.modernize/nbproject/project.properties Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -javac.source=1.7 -javac.compilerargs=-Xlint -Xlint:-serial - -license.file=license.txt -nbm.module.author=Ilia Gromov -nbm.needs.restart=true -test.unit.cp.extra=../../cnd.modelimpl/build/test/unit/classes:\ -../../cnd/build/test/unit/classes:\ -../../dlight.nativeexecution/build/test/unit/classes:\ -../../editor.mimelookup/build/test/unit/classes:\ -../../cnd.classview/build/test/unit/classes - -test.unit.run.cp.extra=../../editor.mimelookup/build/test/unit/classes diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/nbproject/project.xml --- a/ide.analysis.modernize/nbproject/project.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,334 +0,0 @@ - - - org.netbeans.modules.apisupport.project - - - org.netbeans.modules.ide.analysis.modernize - - - org.netbeans.api.progress - - - - 1 - 1.46.1 - - - - org.netbeans.api.progress.nb - - - - 1.46.1 - - - - org.netbeans.modules.cnd.analysis.api - - - - 1.3.1 - - - - org.netbeans.modules.cnd.api.model - - - - 1 - 1.13.1.1 - - - - org.netbeans.modules.cnd.api.project - - - - 1 - 1.31.4 - - - - org.netbeans.modules.cnd.api.remote - - - - 1 - 1.22.2 - - - - org.netbeans.modules.cnd.kit - - 1.30.5.1 - - - - org.netbeans.modules.cnd.makeproject - - - - 2 - 1.15.0.1 - - - - org.netbeans.modules.cnd.model.services - - - - 1 - 1.42.16 - - - - org.netbeans.modules.cnd.modelutil - - - - 1 - 1.14.0.1 - - - - org.netbeans.modules.cnd.toolchain - - - - 1.5.0.1 - - - - org.netbeans.modules.cnd.utils - - - - 1.17.1 - - - - org.netbeans.modules.cnd.utils.ui - - - - 1.0 - - - - org.netbeans.modules.code.analysis - - - - 0 - 1.8 - - - - org.netbeans.modules.dlight.nativeexecution - - - - 1.10.3 - - - - org.netbeans.modules.dlight.remote - - - - 1.28.7.1 - - - - org.netbeans.modules.dlight.remote.ui - - - - 1.1.0 - - - - org.netbeans.modules.editor.document - - - - 1.6.0.1 - - - - org.netbeans.modules.editor.lib - - - - 3 - 4.3.1.22.1.44 - - - - org.netbeans.modules.options.api - - - - 1 - 1.22 - - - - org.netbeans.modules.projectapi - - - - 1 - 1.36 - - - - org.netbeans.modules.refactoring.api - - - - 1.47.1.1 - - - - org.netbeans.spi.editor.hints - - - - 0-1 - 1.18.0.7.9 - - - - org.openide.awt - - - - 7.31 - - - - org.openide.filesystems - - - - 9.8.1 - - - - org.openide.filesystems.nb - - - - 9.7.1 - - - - org.openide.loaders - - - - 7.61 - - - - org.openide.modules - - - - 7.47.1 - - - - org.openide.text - - - - 6.66.1 - - - - org.openide.util - - - - 9.3 - - - - org.openide.util.lookup - - - - 8.23 - - - - org.openide.util.ui - - - - 9.3 - - - - org.openide.windows - - - - 6.74.1 - - - - - - unit - - org.netbeans.libs.junit4 - - - - org.netbeans.modules.cnd.classview - - - - org.netbeans.modules.cnd.kit - - - - - - org.netbeans.modules.cnd.makeproject - - - - - - org.netbeans.modules.cnd.modelimpl - - - - - - org.netbeans.modules.editor.mimelookup - - - - - - org.netbeans.modules.nbjunit - - - - - org.netbeans.modules.projectapi.nb - - - - - - - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/Bundle.properties --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/Bundle.properties Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -OpenIDE-Module-Display-Category=Oracle Developer Studio -OpenIDE-Module-Long-Description=\ - This plugin enables clang-tidy analysis on C/C++ projects and files via Source->Inspect or right in the Editor.\n\ - Works only with "Clang-tidy wrapper for " plugin.\n\n\ - Please note that in order to have clang-tidy hints in the Editor you should run Source->Inspect on your whole project.\n\ - You can view list of checks and enable/disable them in Options->Editor->Hints. -OpenIDE-Module-Name=Clang-TIdy integration -OpenIDE-Module-Short-Description=clang-tidy analyzer integration diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/AnalyzedFiles.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/AnalyzedFiles.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.netbeans.modules.cnd.api.model.CsmFile; - -/** - * This cache is designed to help Editor showing correct checks for included - * files. - * - * @param - */ -public class AnalyzedFiles { - - private final Map> hierarchyCache = new HashMap>(); -// private final Map> diagnosticsCache = new HashMap>(); - -// public void cacheDiagnostics(FileObject fo, CsmErrorInfo info) { -// Set alreadyMapped = diagnosticsCache.get(fo); -// -// if (alreadyMapped == null) { -// alreadyMapped = new HashSet(); -// diagnosticsCache.put(fo, alreadyMapped); -// } -// -// alreadyMapped.add(info); -// } - public void cacheHierarchy(CsmFile startFile, Collection includedFiles) { - Set alreadyMapped = hierarchyCache.get(startFile); - - if (alreadyMapped == null) { - alreadyMapped = new HashSet(); - hierarchyCache.put(startFile, alreadyMapped); - } - - alreadyMapped.addAll(includedFiles); - } - -// public Set getDiagnostics(FileObject fo) { -// return diagnosticsCache.get(fo); -// } - - public Collection getStartFiles(CsmFile includedFile) { - Set result = new HashSet(); - for (Map.Entry> entry : hierarchyCache.entrySet()) { - CsmFile key = entry.getKey(); - Set value = entry.getValue(); - - if (value.contains(includedFile)) { - result.add(key); - } - } - return result; - } - - public boolean isStartFile(CsmFile file) { - return hierarchyCache.containsKey(file); - } - - public void clear() { - hierarchyCache.clear(); - } - - public static AnalyzedFiles getDefault() { - return HOLDER.INSTANCE; - } - - private static class HOLDER { - - public static final AnalyzedFiles INSTANCE = new AnalyzedFiles(); - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/Bundle.properties --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/Bundle.properties Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -# -# Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. -# -# The contents of this file are subject to the terms of either the GNU -# General Public License Version 2 only ("GPL") or the Common -# Development and Distribution License("CDDL") (collectively, the -# "License"). You may not use this file except in compliance with the -# License. You can obtain a copy of the License at -# http://www.netbeans.org/cddl-gplv2.html -# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the -# specific language governing permissions and limitations under the -# License. When distributing the software, include this License Header -# Notice in each file and include the License file at -# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun in the GPL Version 2 section of the License file that -# accompanied this code. If applicable, add the following below the -# License Header, with the fields enclosed by brackets [] replaced by -# your own identifying information: -# "Portions Copyrighted [year] [name of copyright owner]" -# -# Contributor(s): -# -# The Original Software is NetBeans. The Initial Developer of the Original -# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun -# Microsystems, Inc. All Rights Reserved. -# -# If you wish your version of this file to be governed by only the CDDL -# or only the GPL Version 2, indicate your decision by adding -# "[Contributor] elects to include this software in this distribution -# under the [CDDL or GPL Version 2] license." If you do not indicate a -# single choice of license, a recipient has the option to distribute -# your version of this file under either the CDDL, the GPL Version 2 or -# to extend the choice of license to its licensees as provided above. -# However, if you add GPL Version 2 code and therefore, elected the GPL -# Version 2 license, then the option applies only if the new code is -# made subject to such option by the copyright holder. -# - -LBL_ProviderName=C/C++ Errors -LBL_ProviderDescription=C/C++ errors and warnings - -#Previse errors -Modernize_NAME=Clang-Tidy analyzer -Modernize_DESCRIPTION=Show warnings identified by clang-tidy.\ -
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. \ -
Expand the node to specify which static checks you want to be displayed. -DisableHint=Configure clang-tidy analyzer - {0} - -#internal error -tool.error=Oracle Developer Studio compilers not found -remote.mode.error=Unsupported remote mode -remote.mode.error.info=Mode {0} -temporary.file.error=Cannot create temporary file -compile.file.error=Clang-tidy was unable to analyze file -fatal.analyze.error=Clang-tidy was unable to analyze file -compile.file.error.info=Exit code: {0} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ConfigureHintsFix.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ConfigureHintsFix.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import org.netbeans.api.options.OptionsDisplayer; -import org.netbeans.spi.editor.hints.ChangeInfo; -import org.netbeans.spi.editor.hints.EnhancedFix; -import org.openide.util.NbBundle; - -class ConfigureHintsFix implements EnhancedFix { - - private final ModernizeErrorInfo error; - private final String text; - - ConfigureHintsFix(ModernizeErrorInfo error) { - this.error = error; - String id = error.getId(); - this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N - } - - @Override - public String getText() { - return NbBundle.getMessage(ModernizeErrorProvider.class, "DisableHint", text); // NOI18N - } - - @Override - public ChangeInfo implement() throws Exception { - String provider = ModernizeErrorProvider.NAME; - String name = error.getId(); - OptionsDisplayer.getDefault().open("Editor/Hints/text/x-cnd+sourcefile/" + provider + "/" + name); // NOI18N - return null; - } - - @Override - public CharSequence getSortText() { - //Hint opening options dialog should always be the lastest in offered list - return Integer.toString(Integer.MAX_VALUE); - } - - public ModernizeErrorInfo getError() { - return error; - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/DiagnosticsTool.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/DiagnosticsTool.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,307 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; -import org.netbeans.modules.cnd.api.toolchain.AbstractCompiler; -import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCCompiler; -import static org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind.CCompiler; -import org.netbeans.modules.cnd.api.toolchain.Tool; -import org.netbeans.modules.cnd.makeproject.api.MakeProject; -import org.netbeans.modules.cnd.makeproject.api.configurations.CCCCompilerConfiguration; -import org.netbeans.modules.cnd.makeproject.api.configurations.CCCompilerConfiguration; -import org.netbeans.modules.cnd.makeproject.api.configurations.CCompilerConfiguration; -import org.netbeans.modules.cnd.makeproject.api.configurations.Item; -import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfiguration; -import org.netbeans.modules.cnd.makeproject.api.support.MakeProjectOptionsFormat; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; -import org.netbeans.modules.nativeexecution.api.HostInfo; -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; -import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; -import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; - -/** - * - * @author Ilia Gromov - */ -public class DiagnosticsTool { - - public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N - public static final String CACHE_ID = "TIDY-CACHE"; //NOI18N - - public static final int STATUS_OK = 0; - public static final int STATUS_IO_ERROR = -1; - - public static List getAudits(String path, ExecutionEnvironment env, AuditPreferences preferences) { - List res = new ArrayList<>(); - - ProcessUtils.ExitStatus status = ProcessUtils.execute(env, path, new String[]{"-checks=*", "-list-checks", "dummy", "--"}); // NOI18N - - if (status.exitCode == 0) { - String out = status.getOutputString(); - out = out.substring(status.getOutputString().indexOf('\n') + 1); - String[] checks = out.split("\n"); // NOI18N - - FileObject disabledChecksFolder = FileUtil.getConfigFile("Analysis/Clang-Tidy/Disabled_Default"); // NOI18N - - List disabledChecks = new ArrayList<>(); - for (FileObject fileObject : disabledChecksFolder.getChildren()) { - disabledChecks.add(fileObject.getName()); - } - - for (String check : checks) { - check = check.trim(); - ModernizeCodeAudit myCodeAudit = new ModernizeCodeAudit( - check, - check, - check, - "warning", //NOI18N - !disabledChecks.contains(check), - preferences); - res.add(myCodeAudit); - } - } - - return res; - } - - private final ExecutionEnvironment execEnv; - private final Item item; - private final MakeProject project; - private final String binaryPath; - - private StringBuilder buf; - - public DiagnosticsTool(ExecutionEnvironment execEnv, Item item, MakeProject project, String binaryPath) { - this.execEnv = execEnv; - this.item = item; - this.project = project; - this.binaryPath = binaryPath; - } - - /** - * @return clang-tidy's exit code or negative code if some other problem has - * occurred. - */ - public int process(Collection checks, CsmFile csmFile, boolean isStartFile) throws ConnectionManager.CancellationException, IOException { - // TODO: can we split analyzer (Source -> Inspect) ant editor error providing? - - final String directoryMacro = "xDIRx"; //NOI18N - - File tmpDir = null; - try { - List args = new ArrayList(); - - HostInfo hostInfo = HostInfoUtils.getHostInfo(execEnv); - - try { - if (execEnv.isRemote()) { - tmpDir = Files.createTempDirectory(hostInfo.getTempDirFile().toPath(), "tidy").toFile(); //NOI18N - } else { - tmpDir = Files.createTempDirectory("tidy").toFile(); //NOI18N - } - } catch (IOException ex) { - return -1; - } - - Path tmpFile = Files.createTempFile(tmpDir.toPath(), null, null); - - args.add("-header-filter=.*"); //NOI18N - StringBuilder sb = new StringBuilder("-checks=");// NOI18N - for (String check : checks) { - sb.append(check); - sb.append(","); // NOI18N - } - args.add(sb.toString().substring(0, sb.length() - 1)); - - args.add("-export-fixes=" + tmpFile); // NOI18N - int directoryIdx = args.size() - 1; - - Collection startFiles = Collections.EMPTY_LIST; - args.add(csmFile.getFileObject().getPath()); - - args.add("--"); //NOI18N - args.addAll(getAdditionalFlags(csmFile)); - - List copy = new ArrayList(args); - - copy.set(directoryIdx, copy.get(directoryIdx).replace(directoryMacro, tmpDir.getAbsolutePath())); - - // TODO: execute in the ${WORKING_DIR} ? Because we can have relative path includes (-Isrc/libs/abcd) - ProcessUtils.ExitStatus executeStatus = ProcessUtils.executeInDir(tmpDir.getAbsolutePath(), - execEnv, - binaryPath, - copy.toArray(new String[copy.size()])); - - if (executeStatus.exitCode != STATUS_OK) { - LOG.log(Level.INFO, "clang-tidy exit code {0}: {1}", new Object[]{executeStatus.exitCode, arrayAsString(binaryPath, copy)}); - LOG.fine(executeStatus.getOutputString()); - LOG.fine(executeStatus.getErrorString()); - return executeStatus.exitCode; - } else { - LOG.log(Level.FINEST, "{0}", arrayAsString(binaryPath, copy)); - LOG.finest(executeStatus.getOutputString()); - LOG.finest(executeStatus.getErrorString()); - } - - File[] listFiles = tmpDir.listFiles(); - - if (listFiles.length != 1) { - return STATUS_IO_ERROR; - } - - File yamlFile = listFiles[0]; - - BufferedReader in = new BufferedReader(new FileReader(yamlFile)); - buf = new StringBuilder(); - while (true) { - String s = in.readLine(); - if (s == null) { - break; - } - buf.append(s).append('\n'); //NOI18N - } - - } finally { - try { - tmpDir.delete(); - } catch (Exception x) { - - } - } - - return STATUS_OK; - } - - private List getAdditionalFlags(CsmFile csmFile) { - List all = new ArrayList(); - - Tool tool = AnalyticsTools.compiler(item, project); - - if (tool instanceof AbstractCompiler) { - AbstractCompiler compiler = (AbstractCompiler) tool; - - for (String systemIncludeDirectory : compiler.getSystemIncludeDirectories()) { - all.add("-I" + systemIncludeDirectory); //NOI18N - } - - MakeConfiguration activeConfiguration = AnalyticsTools.getConfigurationDescriptor(csmFile, project).getActiveConfiguration(); - - String options = ""; -// // compileSingleUnmanage as reference -// // don't use getAllOptions - we need not -w flag - if (tool.getKind() == CCCompiler) { - CCCompilerConfiguration ccc = activeConfiguration.getCCCompilerConfiguration(); - options += ccc.getPreprocessorOptions(compiler.getCompilerSet()); - options += ccc.getIncludeDirectoriesOptions(compiler.getCompilerSet()); -// options += getLibrariesFlags(); - options += compiler.getCppStandardOptions(ccc.getInheritedCppStandard()); - if (!options.contains("-std=")) { //NOI18N - switch (item.getLanguageFlavor()) { - case CPP98: - options += " -std=c++98"; //NOI18N - break; - case CPP11: - options += " -std=c++11"; //NOI18N - break; - case CPP14: - options += " -std=c++14"; //NOI18N - break; - } - } - } else if (tool.getKind() == CCompiler) { - CCompilerConfiguration cc = activeConfiguration.getCCompilerConfiguration(); - options += cc.getPreprocessorOptions(compiler.getCompilerSet()); - options += cc.getIncludeDirectoriesOptions(compiler.getCompilerSet()); - options += compiler.getCStandardOptions(cc.getInheritedCStandard()); - if (!options.contains("-std=")) { //NOI18N - switch (item.getLanguageFlavor()) { - case C11: - options += " -std=c11"; //NOI18N - break; - case C89: - options += " -std=c89"; //NOI18N - break; - case C99: - options += " -std=c99"; //NOI18N - break; - } - } - } - - List optionsList = AnalyticsTools.scanCommandLine(MakeProjectOptionsFormat.reformatWhitespaces(options)); - all.addAll(optionsList); - } - - return all; - } - - public String getYamlAsString() { - if (buf == null) { - throw new IllegalStateException(); - } - return buf.toString(); - } - - private static String arrayAsString(String binary, List list) { - StringBuilder sb = new StringBuilder(binary).append(" "); //NOI18N - for (String string : list) { - sb.append(string).append(" "); //NOI18N - } - return sb.toString(); - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeAnalyzerImpl.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import org.netbeans.modules.ide.analysis.modernize.options.ClangAnalyzerOptions; -import org.netbeans.modules.ide.analysis.modernize.resources.BundleUtilities; -import java.io.CharConversionException; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.prefs.Preferences; -import org.netbeans.modules.analysis.spi.Analyzer; -import org.netbeans.modules.cnd.analysis.api.AbstractAnalyzer; -import org.netbeans.modules.cnd.analysis.api.AbstractHintsPanel; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; -import org.netbeans.modules.cnd.modelutil.CsmUtilities; -import org.netbeans.modules.cnd.utils.CndPathUtilities; -import org.netbeans.spi.editor.hints.ErrorDescription; -import org.netbeans.spi.editor.hints.ErrorDescriptionFactory; -import org.netbeans.spi.editor.hints.LazyFixList; -import org.netbeans.spi.editor.hints.Severity; -import org.openide.filesystems.FileObject; -import org.openide.util.ImageUtilities; -import org.openide.util.NbBundle; -import org.openide.util.lookup.ServiceProvider; -import org.openide.xml.XMLUtil; - -public class ModernizeAnalyzerImpl extends AbstractAnalyzer { - - private static final String PREFIX = "tidy-"; //NOI18N - - private ModernizeAnalyzerImpl(Context ctx) { - super(ctx); - } - - @Override - public ModernizeErrorProvider getErrorProvider(Preferences preferences) { - return ModernizeErrorProvider.getInstance(); - } - - @Override - protected boolean isCompileUnitBased() { - return true; - } - - @Override - protected Collection doRunImpl(final FileObject sr, final Context ctx, final CsmErrorProvider provider, final AtomicBoolean cancel) { - final CsmFile csmFile = CsmUtilities.getCsmFile(sr, false, false); - if (csmFile == null) { - return Collections.emptyList(); - } - CsmErrorProvider.Request request = new RequestImpl(csmFile, ctx, cancel); - final ArrayList res = new ArrayList(); - CsmErrorProvider.Response responce = new ResponseImpl(sr, res, cancel); - provider.getErrors(request, responce); - return res; - } - - protected static class ResponseImpl extends AbstractResponse { - - public ResponseImpl(FileObject sr, ArrayList res, AtomicBoolean cancel) { - super(sr, res, cancel); - } - - @Override - protected ErrorDescription addErrorImpl(CsmErrorInfo errorInfo, FileObject fo) { - String messages[] = errorInfo.getMessage().split("\n"); //NOI18N - if (messages.length > 0) { - StringBuilder sb = new StringBuilder(); - if (errorInfo instanceof ModernizeErrorInfo) { - ModernizeErrorInfo mei = (ModernizeErrorInfo) errorInfo; - sb.append("
"); //NOI18N
-                    sb.append("["); //NOI18N
-                    sb.append(mei.getId());
-                    sb.append("]"); //NOI18N
-                    sb.append("\n"); //NOI18N
-                    List replacements = mei.getDiagnostics().getReplacements();
-                    if (replacements.isEmpty()) {
-                        sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), mei.getDiagnostics().getMessageFilePath())).append(" "); //NOI18N
-                        sb.append(mei.getDiagnostics().getMessageFileOffset()).append("\n");
-                    } else {
-                        for (YamlParser.Replacement replacement : replacements) {
-                            sb.append("\n"); //NOI18N
-                            sb.append("Replacement: "); //NOI18N
-                            sb.append(CndPathUtilities.getRelativePath(mei.getProject().getProjectRoot(), replacement.filePath)).append(" "); //NOI18N
-                            sb.append(replacement.offset).append("-").append(replacement.offset + replacement.length).append("\n"); //NOI18N
-                            String attributeValue = replacement.replacementText;
-                            try {
-                                attributeValue = XMLUtil.toAttributeValue(replacement.replacementText);
-                            } catch (CharConversionException ex) {
-                            }
-                            sb.append(attributeValue).append("\n"); //NOI18N
-                        }
-                    }
-                    sb.append(mei.getMessage());
-                    sb.append("
"); //NOI18N - - LazyFixList list = new LazyFixListImpl(); - - return ErrorDescriptionFactory.createErrorDescription(PREFIX + mei.getId(), Severity.valueOf(mei.getSeverity().toString().toUpperCase()), - messages[0], sb.toString(), list, fo, errorInfo.getStartOffset(), errorInfo.getStartOffset()); - } - } - return null; - } - } - - @ServiceProvider(service = AnalyzerFactory.class) - public static final class AnalyzerFactoryImpl extends AnalyzerFactory { - - public AnalyzerFactoryImpl() { - super(ModernizeErrorProvider.NAME, - NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"), //NOI18N - ImageUtilities.loadImage("ide/analysis/modernize/impl/bugs.png")); //NOI18N - } - - @Override - public Iterable getWarnings() { - List result = new ArrayList(); - final ModernizeErrorProvider provider = ModernizeErrorProvider.getInstance(); - for (CodeAudit audit : provider.getAudits()) { - result.add(WarningDescription.create(PREFIX + audit.getID(), audit.getName(), ModernizeErrorProvider.NAME, provider.getDisplayName())); - } - String[] fatals = BundleUtilities.getFatalErrors(); - for (String id : fatals) { //NOI18N - if (!id.isEmpty()) { - result.add(WarningDescription.create(PREFIX + id, BundleUtilities.getDescription(id), ModernizeErrorProvider.NAME, provider.getDisplayName())); - } - } - return result; - } - - @Override - public CustomizerProvider getCustomizerProvider() { - return new CustomizerProvider() { - - @Override - public Void initialize() { - return null; - } - - @Override - public AbstractHintsPanel createComponent(CustomizerContext context) { - return AbstractAnalyzer.createComponent(ModernizeErrorProvider.getInstance()); - } - }; - } - - @Override - public Collection requiredPlugins(Context context) { -// ExecutionEnvironment env = detectEnvironment(context); -// if (env == null) { -// env = ExecutionEnvironmentFactory.getLocal(); -// } - String installedTool = ClangAnalyzerOptions.getClangAnalyzerPath(); - if (installedTool == null || !new File(installedTool).exists()) { - String codeBase = ClangAnalyzerOptions.getMissingModuleName(); - if (codeBase != null) { - return Arrays.asList(new MissingPlugin(codeBase, NbBundle.getMessage(ModernizeAnalyzerImpl.class, "Modernize_NAME"))); //NOI18N - } - } - return Collections.emptyList(); - } - - @Override - public Analyzer createAnalyzer(Context context) { - return new ModernizeAnalyzerImpl(context); - } - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeCodeAudit.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeCodeAudit.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit; -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; - -final class ModernizeCodeAudit extends AbstractCodeAudit { - - private final String id; - private final String name; - private final String description; - private final String defaultSeverity; - private final boolean defaultEnabled; - private final AuditPreferences myPreferences; - - public ModernizeCodeAudit(String id, String name, String description, String defaultSeverity, boolean defaultEnabled, AuditPreferences myPreferences) { - super(id, name, description, defaultSeverity, defaultEnabled, myPreferences); - this.id = id; - this.name = name; - this.description = description; - this.defaultSeverity = defaultSeverity; - this.defaultEnabled = defaultEnabled; - this.myPreferences = myPreferences; - } - - @Override - public String getID() { - return id; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getDescription() { - return description; - } - - public static CsmErrorInfo.Severity toSeverity(String severity) { - if ("error".equals(severity)) { // NOI18N - return CsmErrorInfo.Severity.ERROR; - } else if ("warning".equals(severity)) { // NOI18N - return CsmErrorInfo.Severity.WARNING; - } else { - return CsmErrorInfo.Severity.HINT; - } - } - - @Override - public String getKind() { - return "inspection"; //NOI18N - } - - @Override - public AuditPreferences getPreferences() { - return myPreferences; - } - - @Override - public boolean getDefaultEnabled() { - return defaultEnabled; - } - - @Override - public String getDefaultSeverity() { - return defaultSeverity; - } - - @Override - public boolean isSupportedEvent(CsmErrorProvider.EditorEvent kind) { - return true; - } - - @Override - public void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) { - throw new UnsupportedOperationException("Not supported yet."); //NOI18N - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorInfo.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorInfo.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import java.util.Objects; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.project.NativeProject; -import org.openide.util.Lookup; - -public class ModernizeErrorInfo implements CsmErrorInfo, ModernizeErrorProvider.ErrorInfoWithId { - - private final YamlParser.Diagnostics diag; - private final String message; - private final NativeProject project; - - private final int startOffset; - private final int endOffset; - - public ModernizeErrorInfo(YamlParser.Diagnostics diag, String message, Lookup.Provider project) { - this.diag = diag; - this.message = message; - this.project = project.getLookup().lookup(NativeProject.class); - - if (diag.getReplacements().isEmpty()) { - startOffset = diag.getMessageFileOffset(); - endOffset = diag.getMessageFileOffset(); - } else { - YamlParser.Replacement first = diag.getReplacements().get(0); - startOffset = first.offset; - endOffset = first.offset + first.length; - } - } - - public NativeProject getProject() { - return project; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public Severity getSeverity() { - return Severity.valueOf(diag.getLevel().toString().toUpperCase()); - } - - @Override - public int getStartOffset() { - return startOffset; - } - - @Override - public int getEndOffset() { - return endOffset; - } - - public YamlParser.Diagnostics getDiagnostics() { - return diag; - } - - @Override - public String getId() { - return diag.getCheckName(); - } - - public boolean isNeedConfigureHint() { - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 19 * hash + this.diag.getCheckName().hashCode(); - hash = 19 * hash + this.startOffset; - hash = 19 * hash + this.endOffset; - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ModernizeErrorInfo other = (ModernizeErrorInfo) obj; - if (this.startOffset != other.startOffset) { - return false; - } - if (this.endOffset != other.endOffset) { - return false; - } - if (!(this.diag.getCheckName().equals(other.diag.getCheckName()))) { - return false; - } - return true; - } - -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorProvider.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeErrorProvider.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,422 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl.ResponseImpl; -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser.Replacement; -import org.netbeans.modules.ide.analysis.modernize.options.AnalyzerPreferences; -import org.netbeans.modules.ide.analysis.modernize.options.ClangAnalyzerOptions; -import static org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools.fatalError; -import static org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools.findItem; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.prefs.Preferences; -import javax.swing.JComponent; -import javax.swing.JLabel; -import org.netbeans.modules.cnd.analysis.api.AbstractCustomizerProvider; -import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.api.model.syntaxerr.AbstractCodeAudit; -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditFactory; -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAuditProvider; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo.Severity; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfoHintProvider; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; -import org.netbeans.modules.cnd.api.project.NativeFileItem.Language; -import org.netbeans.modules.cnd.api.project.NativeProject; -import org.netbeans.modules.cnd.api.remote.RemoteProject; -import org.netbeans.modules.cnd.makeproject.api.MakeProject; -import org.netbeans.modules.cnd.makeproject.api.configurations.Item; -import org.netbeans.modules.cnd.modelutil.CsmUtilities; -import org.netbeans.modules.cnd.utils.MIMENames; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; -import org.netbeans.spi.editor.hints.Fix; -import org.openide.awt.Actions; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.util.Exceptions; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.openide.util.lookup.ServiceProvider; -import org.openide.util.lookup.ServiceProviders; - -@ServiceProviders({ - @ServiceProvider(service = CsmErrorProvider.class, position = 2100) - , - @ServiceProvider(service = CodeAuditProvider.class, position = 2100) -}) -public final class ModernizeErrorProvider extends CsmErrorProvider implements CodeAuditProvider, AbstractCustomizerProvider { - - public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N - private Collection audits; - public static final String NAME = "Modernize"; //NOI18N - - public static ModernizeErrorProvider getInstance() { - for (CsmErrorProvider provider : Lookup.getDefault().lookupAll(CsmErrorProvider.class)) { - if (NAME.equals(provider.getName()) && provider instanceof ModernizeErrorProvider) { - return (ModernizeErrorProvider) provider; - } - } - return null; - } - - @Override - protected boolean validate(Request request) { - CsmFile file = request.getFile(); - return file != null; - } - - @Override - public boolean hasHintControlPanel() { - return true; - } - - @Override - public String getName() { - return NAME; - } - - @Override - public String getDisplayName() { - return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_NAME"); //NOI18N - } - - @Override - public String getDescription() { - return NbBundle.getMessage(ModernizeErrorProvider.class, "Modernize_DESCRIPTION"); //NOI18N - } - - @Override - public String getMimeType() { - return MIMENames.SOURCES_MIME_TYPE; - } - - @Override - public boolean isSupportedEvent(EditorEvent kind) { - return kind == EditorEvent.FileBased; - } - - @Override - protected void doGetErrors(CsmErrorProvider.Request request, CsmErrorProvider.Response response) { - CsmFile file = request.getFile(); - if (file != null) { - if (request.isCancelled()) { - return; - } - Object platformProject = file.getProject().getPlatformProject(); - if (platformProject instanceof NativeProject) { - Lookup.Provider project = ((NativeProject) platformProject).getProject(); - if (project != null) { - if (request.isCancelled()) { - return; - } - Thread currentThread = Thread.currentThread(); - currentThread.setName("Provider " + getName() + " prosess " + file.getAbsolutePath()); // NOI18N - RemoteProject info = project.getLookup().lookup(RemoteProject.class); - if (info != null) { - ExecutionEnvironment execEnv = info.getDevelopmentHost(); - if (execEnv != null) { - if (request.isCancelled()) { - return; - } - if (ConnectionManager.getInstance().isConnectedTo(execEnv)) { - Item item = findItem(file, project); - if (item != null) { - if (request.isCancelled()) { - return; - } - // Temporarily analyzing even excluded items - if (/* !item.isExcluded() && */(item.getLanguage() == Language.C || item.getLanguage() == Language.CPP || item.getLanguage() == Language.C_HEADER)) { - analyze(execEnv, item, project, request, response); - } - } - } - } - } - } - } - } - } - - public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) { - String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath(); - boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ResponseImpl; - if (binaryPath == null) { - Level level = isAnalyzer ? Level.INFO : Level.FINE; - LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N - return; - } - - if (isAnalyzer && isNewRun()) { - AnalyzedFiles.getDefault().clear(); - } - - DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath); - try { - CsmFile csmFile = request.getFile(); - Collection checks = /*isAnalyzer ? Collections.singleton("*") : */ getEnabledChecks(); //NOI18N - - Collection tu = new ArrayList(); - if (isAnalyzer) { - tu.add(csmFile); - } else { - if (AnalyzedFiles.getDefault().isStartFile(csmFile)) { - tu.add(csmFile); - } else { - tu.addAll(AnalyzedFiles.getDefault().getStartFiles(csmFile)); - } - } - - if (!isAnalyzer) { - response = new ResponseMerger(response); - } - - for (CsmFile startFile : tu) { - int exitCode = diagnosticsTool.process(checks, startFile, true); - if (exitCode != DiagnosticsTool.STATUS_OK) { - String error = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error"); //NOI18N - String info = NbBundle.getMessage(ModernizeErrorProvider.class, "compile.file.error.info", "" + exitCode); //NOI18N - fatalError(AnalyzerResponse.AnalyzerSeverity.FileError, "fatal.analyze.error", error + "\n" + info, csmFile, response); //NOI18N - return; - } - List results = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString()); - postProcess(isAnalyzer, startFile, project, results, request, response); - } - - if (!isAnalyzer) { - response.done(); - } - - } catch (ConnectionManager.CancellationException ex) { - Exceptions.printStackTrace(ex); - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } - } - - private static CsmErrorProvider last; - - private boolean isNewRun() { - if (last == null || this != last) { - last = this; - return true; - } - return false; - } - - public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) { - CsmFile file = request.getFile(); - List otherCsmFiles = new ArrayList(); - - for (YamlParser.Diagnostics diag : results) { - // TODO: don't add "Configure Hint" fix multiple times for one line - FileObject fo = FileUtil.toFileObject(new File(diag.getMessageFilePath())); - CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false); - - // Composing a preview message. Showing a start file for compilation unit - // in case we analysing a header file - String message; - if (startFile.equals(file) && csmFile.equals(file)) { - message = String.format("[%s]: %s", diag.getCheckName(), diag.getMessage()); //NOI18N - } else { - message = String.format("[%s; %s]: %s", diag.getCheckName(), startFile.getName(), diag.getMessage()); //NOI18N - } - - ModernizeErrorInfo info = new ModernizeErrorInfo(diag, message, project); //NOI18N - - if (isAnalyzer) { - // Add found errors for all files (can be other files from compileUnit) - ((ResponseImpl) response).addError(AnalyzerResponse.AnalyzerSeverity.DetectedError, null, fo, info); - - if (!csmFile.equals(file)) { - // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... ) - otherCsmFiles.add(csmFile); - } - } else if (fo.equals(file.getFileObject())) { - // Add found errors only for file displayed in Editor - response.addError(info); - } - } - - if (isAnalyzer /* and not empty? */) { - AnalyzedFiles.getDefault().cacheHierarchy(file, otherCsmFiles); - } - } - - @ServiceProvider(path = CodeAuditFactory.REGISTRATION_PATH + ModernizeErrorProvider.NAME, service = CodeAuditFactory.class, position = 4000) - public static final class Factory implements CodeAuditFactory { - - @Override - public AbstractCodeAudit create(AuditPreferences preferences) { - String id = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderName"); // NOI18N - String description = NbBundle.getMessage(ModernizeCodeAudit.class, "LBL_ProviderDescription"); // NOI18N - return new ModernizeCodeAudit(id, id, description, "error", false, preferences); // NOI18N - } - } - - private String oldPath; - - @Override - public synchronized Collection getAudits() { - String path = ClangAnalyzerOptions.getClangAnalyzerPath(); - - if (path == null) { - return Collections.emptyList(); - } - - if (oldPath == null) { - oldPath = path; - } - - if (audits == null || !oldPath.equals(path)) { - List res = DiagnosticsTool.getAudits(path, ExecutionEnvironmentFactory.getLocal(), AnalyzerPreferences.getAuditPreferences()); - - audits = res; - oldPath = path; - } - return audits; - } - - public Collection getEnabledChecks() { - Collection auditList = getAudits(); - List enabled = new ArrayList(); - for (CodeAudit codeAudit : auditList) { - if (codeAudit.isEnabled()) { - enabled.add(codeAudit.getID()); - } - } - return enabled.size() == auditList.size() ? Collections.singleton("*") : enabled; //NOI18N - } - - @Override - public AuditPreferences getPreferences() { - return AnalyzerPreferences.getAuditPreferences(); - } - - @Override - public JComponent createComponent(Preferences context) { - return new JLabel(); - } - - public static interface ErrorInfoWithId { - - String getId(); - } - - public static final class FatalErrorInfo implements CsmErrorInfo, ErrorInfoWithId { - - private final String id; - private final String message; - - public FatalErrorInfo(String id, String message) { - this.id = id; - this.message = message; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public Severity getSeverity() { - return Severity.WARNING; - } - - @Override - public int getStartOffset() { - return 0; - } - - @Override - public int getEndOffset() { - return 1; - } - - @Override - public String getId() { - return id; - } - } - - @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 9100) - public final static class ModerinzeHintProvider extends CsmErrorInfoHintProvider { - - @Override - protected List doGetFixes(CsmErrorInfo info, List alreadyFound) { - if (info instanceof ModernizeErrorInfo) { - alreadyFound.add(new ConfigureHintsFix((ModernizeErrorInfo) info)); - } - return alreadyFound; - } - } - - @ServiceProvider(service = CsmErrorInfoHintProvider.class, position = 1600) - public static final class ModernizeFixProvider extends CsmErrorInfoHintProvider { - - @Override - protected List doGetFixes(CsmErrorInfo info, List alreadyFound) { - alreadyFound.addAll(createFixes(info)); - return alreadyFound; - } - } - - private static List createFixes(CsmErrorInfo info) { - if (info instanceof ModernizeErrorInfo) { - ModernizeErrorInfo mei = (ModernizeErrorInfo) info; - List replacements = mei.getDiagnostics().getReplacements(); - if (!replacements.isEmpty()) { - return Collections.singletonList(new ModernizeFix(replacements, mei.getId())); - } - } - return Collections.EMPTY_LIST; - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeFix.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ModernizeFix.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import java.io.File; -import java.util.List; -import javax.swing.text.Document; -import javax.swing.text.Position; -import org.netbeans.editor.BaseDocument; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.modelutil.CsmUtilities; -import org.netbeans.spi.editor.hints.ChangeInfo; -import org.netbeans.spi.editor.hints.EnhancedFix; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.text.CloneableEditorSupport; -import org.openide.text.PositionRef; - -/** - * - * @author Ilia Gromov - */ -public class ModernizeFix implements EnhancedFix { - - private final YamlParser.Replacement[] replacements; - private final String text; - private CloneableEditorSupport ces; - private final PositionRef[] beg; - private final PositionRef[] end; - - public ModernizeFix(List replacementList, String id) { - this.beg = new PositionRef[replacementList.size()]; - this.end = new PositionRef[replacementList.size()]; - this.replacements = replacementList.toArray(new YamlParser.Replacement[replacementList.size()]); - this.text = (id.startsWith("-")) ? id.substring(1) : id; //NOI18N - for (int i = 0; i < replacements.length; i++) { - YamlParser.Replacement replacement = replacements[i]; - FileObject fo = FileUtil.toFileObject(new File(replacement.filePath)); - CsmFile csmFile = CsmUtilities.getCsmFile(fo, false, false); - if (csmFile != null) { - ces = CsmUtilities.findCloneableEditorSupport(csmFile); - if (ces != null) { - beg[i] = ces.createPositionRef(replacement.offset, Position.Bias.Forward); - end[i] = ces.createPositionRef(replacement.offset + replacement.length, Position.Bias.Backward); - } else { - } - } - } - } //NOI18N - - @Override - public String getText() { - return "Apply replacement - " + text; //NOI18N - } - - @Override - public ChangeInfo implement() throws Exception { - Document doc = CsmUtilities.openDocument(ces); - if (doc instanceof BaseDocument) { - Position min = beg[0]; - Position max = end[0]; - for (int i = 0; i < replacements.length; i++) { - YamlParser.Replacement replacement = replacements[i]; - PositionRef b = beg[i]; - PositionRef e = end[i]; - if (b != null && e != null) { - int newBeg = b.getOffset(); - int newLength = e.getOffset() - b.getOffset(); - if (b.getOffset() < min.getOffset()) { - min = b; - } - if (e.getOffset() > max.getOffset()) { - max = e; - } - if (newLength < 1) { - // TODO: temp fix - newLength = 0; - } - ((BaseDocument) doc).replace(newBeg, newLength, replacement.replacementText, null); - } - } - return new ChangeInfo(min, max); - } - return null; - } - - @Override - public CharSequence getSortText() { - return Integer.toString(Integer.MIN_VALUE); - } - - public YamlParser.Replacement[] getReplacements() { - return replacements; - } - -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ResponseMerger.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/ResponseMerger.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import java.util.HashSet; -import java.util.Set; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; - -/** - * - * @author Ilia Gromov - */ -public class ResponseMerger implements CsmErrorProvider.Response { - - private final Set bag = new HashSet<>(); - private final CsmErrorProvider.Response delegate; - - public ResponseMerger(CsmErrorProvider.Response delegate) { - this.delegate = delegate; - } - - @Override - public void addError(CsmErrorInfo errorInfo) { - bag.add(errorInfo); - } - - @Override - public void done() { - for (CsmErrorInfo modernizeErrorInfo : bag) { - delegate.addError(modernizeErrorInfo); - } - delegate.done(); - bag.clear(); - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/YamlParser.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/YamlParser.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,357 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.impl; - -import static org.netbeans.modules.ide.analysis.modernize.impl.YamlParser.Diagnostics.UNDEFINED; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; -import java.util.logging.Level; - -/** - * - * @author Ilia Gromov - */ -public class YamlParser { - // TODO check for no-replacements case - - private static final YamlParser INSTANCE = new YamlParser(); - - public static YamlParser getDefault() { - return INSTANCE; - } - - private static final String OPEN_TAG = "---"; //NOI18N - private static final String CLOSE_TAG = "..."; //NOI18N - - private static final String MAIN_SOURCE_FILE = "MainSourceFile"; //NOI18N - private static final String CHECK_NAME = "CheckName"; //NOI18N - private static final String LEVEL = "Level"; //NOI18N - private static final String MESSAGE_FILE_PATH = "MessageFilePath"; //NOI18N - private static final String MESSAGE_FILE_OFFSET = "MessageFileOffset"; //NOI18N - private static final String MESSAGE = "Message"; //NOI18N - private static final String REPLACEMENTS = "Replacements"; //NOI18N - private static final String DIAGNOSTICS = "Diagnostics"; //NOI18N - - private static final String FILE_PATH = "FilePath"; //NOI18N - private static final String OFFSET = "Offset"; //NOI18N - private static final String LENGTH = "Length"; //NOI18N - private static final String REPLACEMENT_TEXT = "ReplacementText"; //NOI18N - - // clang-modernize: -// --- -// MainSourceFile: /home/ilia/NetBeansProjects/CppApplication_46/main.cpp -// Replacements: -// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/newfile.h -// Offset: 101 -// Length: 1 -// ReplacementText: nullptr -// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/newfile1.h -// Offset: 380 -// Length: 1 -// ReplacementText: nullptr -// - FilePath: /home/ilia/NetBeansProjects/CppApplication_46/main.cpp -// Offset: 152 -// Length: 1 -// ReplacementText: nullptr -// ... - // clang-tidy: -// --- -// MainSourceFile: '' -// Diagnostics: -// CheckName: misc-macro-parentheses -// Replacements: -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp -// Offset: 1352 -// Length: 0 -// ReplacementText: '(' -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp -// Offset: 1353 -// Length: 0 -// ReplacementText: ')' -// Diagnostics: -// CheckName: misc-macro-parentheses -// Replacements: -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp -// Offset: 1446 -// Length: 0 -// ReplacementText: '(' -// - FilePath: /media/SSD_/code/zdoom/main_1.cpp -// Offset: 1447 -// Length: 0 -// ReplacementText: ')' -// ... - public List parseYaml(String output) { - try { - if (output.isEmpty()) { - // No warnings in header = no 'Main Source File' element - return Collections.EMPTY_LIST; - } - StringTokenizer st = new StringTokenizer(output, "\n"); //NOI18N - String line; - - // --- - line = st.nextToken(); - - line = st.nextToken(); - String mainSourceFile = getValue(MAIN_SOURCE_FILE, line); - - // Replacements: - line = st.nextToken(); - ClangTidyVersion version = line.contains(REPLACEMENTS) - ? ClangTidyVersion.OLD_FORMAT - : ClangTidyVersion.NEW_FORMAT; - - List list = version.parser.parse(st); - - return list; - } catch (Exception ex) { - ModernizeErrorProvider.LOG.log(Level.INFO, "Can't parse output line"); - return Collections.EMPTY_LIST; - } - } - - private static List parseReplacements(StringTokenizer st) { - List replacements = new ArrayList(); - String line; - - // eat Replacements: - line = st.nextToken(); - - if (!line.contains(REPLACEMENTS)) { - return replacements; - } - - while (st.hasMoreTokens()) { - line = st.nextToken(); - - if (line.equals(CLOSE_TAG) || !line.contains(FILE_PATH)) { - break; - } - - String filePath = getValue(FILE_PATH, line); - - line = st.nextToken(); - int offset = Integer.parseInt(getValue(OFFSET, line)); - - line = st.nextToken(); - int length = Integer.parseInt(getValue(LENGTH, line)); - - line = st.nextToken(); - String replacementText = getValue(REPLACEMENT_TEXT, line); - while (replacementText == null && st.hasMoreElements()) { - line = line + "\n" + st.nextElement(); //NOI18N - replacementText = getValue(REPLACEMENT_TEXT, line); - } - - Replacement replacement = new Replacement(filePath, offset, length, replacementText); - replacements.add(replacement); - - } - return replacements; - } - - private static String getValue(String key, String line) { - int keyStart = line.indexOf(key); - assert keyStart != -1; - int keyEnd = keyStart + key.length() + 1; - String trimmed = line.substring(keyEnd).trim(); - boolean isTextValue = trimmed.charAt(0) == '\''; - if (isTextValue) { - if (trimmed.length() == 1) { - // ' - // abcd' - return null; - } else if (trimmed.charAt(trimmed.length() - 1) == '\'') { - trimmed = trimmed.substring(1, trimmed.length() - 1); - } else { - return null; - } - } - return trimmed; - } - - public static class TranslationUnitDiagnostics { - - private final String mainSourceFilePath; - private final String context; - private final List diags; - - public TranslationUnitDiagnostics(String mainSourceFilePath, String context, List diags) { - this.mainSourceFilePath = mainSourceFilePath; - this.context = context; - this.diags = diags; - } - - public String getMainSourceFilePath() { - return mainSourceFilePath; - } - - public String getContext() { - return context; - } - - public List getDiags() { - return diags; - } - } - - public static class Diagnostics { - - public static final String UNDEFINED = "undefined"; // NOI18N - - public enum Level { - warning, error - } - - private final String checkName; - private final Diagnostics.Level level; - private final String messageFilePath; - private final int messageFileOffset; - private final String message; - private final List replacements; - - public Diagnostics(String checkName, Diagnostics.Level level, String messageFilePath, int messageFileOffset, String message, List replacements) { - this.checkName = checkName; - this.level = level; - this.messageFilePath = messageFilePath; - this.messageFileOffset = messageFileOffset; - this.message = message; - this.replacements = replacements; - } - - public String getCheckName() { - return checkName; - } - - public Level getLevel() { - return level; - } - - public String getMessageFilePath() { - return messageFilePath; - } - - public int getMessageFileOffset() { - return messageFileOffset; - } - - public String getMessage() { - return message; - } - - public List getReplacements() { - return replacements; - } - } - - public static class Replacement { - - public final String filePath; - public final int offset; - public final int length; - public final String replacementText; - - public Replacement(String FilePath, int offset, int length, String replacementText) { - this.filePath = FilePath; - this.offset = offset; - this.length = length; - this.replacementText = replacementText; - } - } - - private static enum ClangTidyVersion { - NEW_FORMAT(new NewFormatParser()), - OLD_FORMAT(new OldFormatParser()); - - public final TidyParser parser; - - private ClangTidyVersion(TidyParser parser) { - this.parser = parser; - } - } - - private static abstract class TidyParser { - - abstract List parse(StringTokenizer st); - } - - private static class NewFormatParser extends TidyParser { - - @Override - public List parse(StringTokenizer st) { - List list = new ArrayList(); - - String line; - while (st.hasMoreElements()) { - line = st.nextToken(); - String checkName = getValue(CHECK_NAME, line); - - line = st.nextToken(); - Diagnostics.Level level = Diagnostics.Level.valueOf(getValue(LEVEL, line).toLowerCase()); - - line = st.nextToken(); - String messageFilePath = getValue(MESSAGE_FILE_PATH, line); - - line = st.nextToken(); - int messageFileOffset = Integer.parseInt(getValue(MESSAGE_FILE_OFFSET, line)); - - line = st.nextToken(); - String message = getValue(MESSAGE, line); - - List replacements = parseReplacements(st); - - list.add(new Diagnostics(checkName, level, messageFilePath, messageFileOffset, message, replacements)); - } - return list; - } - - } - - private static class OldFormatParser extends TidyParser { - - @Override - public List parse(StringTokenizer st) { - List parseReplacements = parseReplacements(st); - return Collections.singletonList(new Diagnostics(UNDEFINED, Diagnostics.Level.warning, "", -1, "", parseReplacements)); //NOI18N - } - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/bugs.png Binary file ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/impl/bugs.png has changed diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/layer.xml --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/layer.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/AnalyzerPreferences.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/AnalyzerPreferences.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ - -package org.netbeans.modules.ide.analysis.modernize.options; - -import java.util.prefs.Preferences; -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; - -/** - * - * @author Ilia Gromov - */ -public class AnalyzerPreferences { - - private static final String NODE_NAME = "clang-tidy"; //NOI18N - - public static AuditPreferences getAuditPreferences() { - return Holder.PREFS; - } - - public static Preferences getPreferences() { - return Holder.PREFS.getPreferences(); - } - - private static final class Holder { - - static final AuditPreferences PREFS = new AuditPreferences(AuditPreferences.AUDIT_PREFERENCES_ROOT.node(NODE_NAME)); - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/Bundle.properties --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/Bundle.properties Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -PreviseOptions.confidenceLabel.text=&Confidence: - -SURE_CONFIDENCE=Sure -HIGH_CONFIDENCE=High -MEDIUM_CONFIDENCE=Medium -LOW_CONFIDENCE=Low -Parfait.tool.collection= -ParfaitOptions.pathToParfait.notfound=Not Found -ParfaitOptions.browse.text=... -SELECT_TOOL_TITLE=Select Clang Binary Folder -ParfaitOptions.connect.text=Connect to host {0} -Parfait.tool.collection_1=clang-tidy -ModernizeOptions.browseButton.text=... -ModernizeOptions.jLabel2.text=build host -ModernizeOptions.pathToAnalyzer.text= diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/ClangAnalyzerOptions.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/options/ClangAnalyzerOptions.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ - -package org.netbeans.modules.ide.analysis.modernize.options; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; -import org.netbeans.modules.nativeexecution.api.HostInfo; -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; -import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; -import org.openide.modules.InstalledFileLocator; - -/** - * - * @author Ilia Gromov - */ -public class ClangAnalyzerOptions { - - public static final String CLANG_BINARY_NAME = "clang-tidy"; //NOI18N - public static final String CLANG_BINARY_PATH = "clang-tidy-path"; //NOI18N - - private static String findInPaths() { - String binaryName = CLANG_BINARY_NAME + "-" + getCodeBase(); //NOI18N - String result = HostInfoUtils.searchFile(ExecutionEnvironmentFactory.getLocal(), Collections.emptyList(), binaryName, true); // NOI18N - return result; - } - - public static String getClangAnalyzerPath() { - String result = AnalyzerPreferences.getPreferences().get(CLANG_BINARY_PATH, ""); //NOI18N - String oldValue = result; - if (result.isEmpty()) { - String toolPath = System.getProperty("devstudio.clangtidy.path"); //NOI18N - if (toolPath != null) { - result = toolPath; - } - } - if (result.isEmpty()) { - final String codeBase = getCodeBase(); - String relativePath = String.format("%s/%s-%s", CLANG_BINARY_NAME, CLANG_BINARY_NAME, codeBase); //NOI18N - File toolFile = InstalledFileLocator.getDefault().locate(relativePath, codeBase, false); - if (toolFile != null && toolFile.exists()) { - result = toolFile.getAbsolutePath(); - } - } - if (result.isEmpty()) { - String toolPath = findInPaths(); - if (toolPath != null) { - result = toolPath; - } - } - if (result.isEmpty()) { - return null; - } else { - if (!oldValue.equals(result)) { - AnalyzerPreferences.getPreferences().put(CLANG_BINARY_PATH, result); - } - } - return result; - } - - public static String getMissingModuleName() { - return "com.oracle.tools.analysis.clangtidy." + getCodeBase(); //NOI18N - } - - public static String getCodeBase() { - HostInfo hostInfo = null; - try { - hostInfo = HostInfoUtils.getHostInfo(ExecutionEnvironmentFactory.getLocal()); - } catch (IOException ex) { - ex.printStackTrace(System.err); - } catch (ConnectionManager.CancellationException ex) { - ex.printStackTrace(System.err); - } - String module = null; - if (hostInfo != null) { - switch (hostInfo.getOS().getFamily()) { - case SUNOS: - switch (hostInfo.getCpuFamily()) { - case X86: - switch (hostInfo.getOS().getBitness()) { - case _32: - module = "SunOS_x86"; // NOI18N - break; - case _64: - module = "SunOS_x86_64"; // NOI18N - break; - } - break; - case SPARC: - module = "SunOS_sparc"; // NOI18N - break; - } - break; - case LINUX: - switch (hostInfo.getOS().getBitness()) { - case _32: - module = "Linux_x86"; // NOI18N - break; - case _64: - module = "Linux_x86_64"; // NOI18N - break; - } - break; - case WINDOWS: - switch (hostInfo.getOS().getBitness()) { - case _32: - module = "Windows_x86"; // NOI18N - break; - case _64: - module = "Windows_x86_64"; // NOI18N - break; - } - break; - case MACOSX: - switch (hostInfo.getOS().getBitness()) { - case _32: - module = "MacOSX_x86"; // NOI18N - break; - case _64: - module = "MacOSX_x86_64"; // NOI18N - break; - } - break; - } - } - return module; - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/Bundle.properties --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/Bundle.properties Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -fatals=fatal.unsupported.remote;fatal.tmp;fatal.analyze.error;fatal.language.flavor - -fatal.unsupported.remote= fatal: Unsupported remote mode -fatal.tmp= fatal: Cannot create temporary file -fatal.analyze.error= fatal: Unable to analyze file -fatal.language.flavor= fatal: Clang-tidy can be used with C++11 or later standard only \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/BundleUtilities.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/resources/BundleUtilities.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.resources; - -import org.openide.util.NbBundle; - -/** - * - * @author Ilia Gromov - */ -public class BundleUtilities { - - public static String[] getFlags() { - return NbBundle.getMessage(BundleUtilities.class, "flags").split(";"); - } - - public static String getDescription(String key) { - return NbBundle.getMessage(BundleUtilities.class, key); - } - - public static String[] getFatalErrors() { - return NbBundle.getMessage(BundleUtilities.class, "fatals").split(";"); - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang-tools-extra.patch --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang-tools-extra.patch Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -Index: clang-tidy/ClangTidy.cpp -=================================================================== ---- clang-tidy/ClangTidy.cpp (revision 278390) -+++ clang-tidy/ClangTidy.cpp (working copy) -@@ -35,6 +35,7 @@ - #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h" - #include "clang/Tooling/Refactoring.h" - #include "clang/Tooling/ReplacementsYaml.h" -+#include "clang/Tooling/DiagnosticsYaml.h" - #include "clang/Tooling/Tooling.h" - #include "llvm/Support/Process.h" - #include "llvm/Support/Signals.h" -@@ -509,13 +510,10 @@ - - void exportReplacements(const std::vector &Errors, - raw_ostream &OS) { -- tooling::TranslationUnitReplacements TUR; -- for (const ClangTidyError &Error : Errors) -- TUR.Replacements.insert(TUR.Replacements.end(), Error.Fix.begin(), -- Error.Fix.end()); -- - yaml::Output YAML(OS); -- YAML << TUR; -+ TranslationUnitDiagnostics TUD; -+ TUD.Diags.insert(TUD.Diags.end(), Errors.begin(), Errors.end()); -+ YAML << TUD; - } - - } // namespace tidy -Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp -=================================================================== ---- clang-tidy/ClangTidyDiagnosticConsumer.cpp (revision 278390) -+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp (working copy) -@@ -102,25 +102,6 @@ - }; - } // end anonymous namespace - --ClangTidyMessage::ClangTidyMessage(StringRef Message) -- : Message(Message), FileOffset(0) {} -- --ClangTidyMessage::ClangTidyMessage(StringRef Message, -- const SourceManager &Sources, -- SourceLocation Loc) -- : Message(Message) { -- assert(Loc.isValid() && Loc.isFileID()); -- FilePath = Sources.getFilename(Loc); -- FileOffset = Sources.getFileOffset(Loc); --} -- --ClangTidyError::ClangTidyError(StringRef CheckName, -- ClangTidyError::Level DiagLevel, -- bool IsWarningAsError, -- StringRef BuildDirectory) -- : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel), -- IsWarningAsError(IsWarningAsError) {} -- - // Returns true if GlobList starts with the negative indicator ('-'), removes it - // from the GlobList. - static bool ConsumeNegativeIndicator(StringRef &GlobList) { -Index: clang-tidy/ClangTidyDiagnosticConsumer.h -=================================================================== ---- clang-tidy/ClangTidyDiagnosticConsumer.h (revision 278390) -+++ clang-tidy/ClangTidyDiagnosticConsumer.h (working copy) -@@ -14,6 +14,7 @@ - #include "clang/Basic/Diagnostic.h" - #include "clang/Basic/SourceManager.h" - #include "clang/Tooling/Refactoring.h" -+#include "clang/Tooling/Core/Diagnostics.h" - #include "llvm/ADT/DenseMap.h" - #include "llvm/ADT/StringMap.h" - #include "llvm/Support/Regex.h" -@@ -32,52 +33,9 @@ - - namespace tidy { - --/// \brief A message from a clang-tidy check. --/// --/// Note that this is independent of a \c SourceManager. --struct ClangTidyMessage { -- ClangTidyMessage(StringRef Message = ""); -- ClangTidyMessage(StringRef Message, const SourceManager &Sources, -- SourceLocation Loc); -- std::string Message; -- std::string FilePath; -- unsigned FileOffset; --}; -+typedef clang::tooling::DiagnosticsMessage ClangTidyMessage; -+typedef clang::tooling::Diagnostics ClangTidyError; - --/// \brief A detected error complete with information to display diagnostic and --/// automatic fix. --/// --/// This is used as an intermediate format to transport Diagnostics without a --/// dependency on a SourceManager. --/// --/// FIXME: Make Diagnostics flexible enough to support this directly. --struct ClangTidyError { -- enum Level { -- Warning = DiagnosticsEngine::Warning, -- Error = DiagnosticsEngine::Error -- }; -- -- ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, -- StringRef BuildDirectory); -- -- std::string CheckName; -- ClangTidyMessage Message; -- tooling::Replacements Fix; -- SmallVector Notes; -- -- // A build directory of the diagnostic source file. -- // -- // It's an absolute path which is `directory` field of the source file in -- // compilation database. If users don't specify the compilation database -- // directory, it is the current directory where clang-tidy runs. -- // -- // Note: it is empty in unittest. -- std::string BuildDirectory; -- -- Level DiagLevel; -- bool IsWarningAsError; --}; -- - /// \brief Read-only set of strings represented as a list of positive and - /// negative globs. Positive globs add all matched strings to the set, negative - /// globs remove them in the order of appearance in the list. -Index: clang-tidy/tool/ClangTidyMain.cpp -=================================================================== ---- clang-tidy/tool/ClangTidyMain.cpp (revision 278390) -+++ clang-tidy/tool/ClangTidyMain.cpp (working copy) -@@ -389,7 +389,7 @@ - - // -fix-errors implies -fix. - handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount); -- -+ - if (!ExportFixes.empty() && !Errors.empty()) { - std::error_code EC; - llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None); diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang.patch --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/tools-clang.patch Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,461 +0,0 @@ -Index: include/clang/Tooling/Core/Diagnostics.h -=================================================================== ---- include/clang/Tooling/Core/Diagnostics.h (revision 278390) -+++ include/clang/Tooling/Core/Diagnostics.h (working copy) -@@ -1,254 +1,54 @@ --//===--- Replacement.h - Framework for clang refactoring tools --*- C++ -*-===// --// --// The LLVM Compiler Infrastructure --// --// This file is distributed under the University of Illinois Open Source --// License. See LICENSE.TXT for details. --// --//===----------------------------------------------------------------------===// --// --// Classes supporting refactorings that span multiple translation units. --// While single translation unit refactorings are supported via the Rewriter, --// when refactoring multiple translation units changes must be stored in a --// SourceManager independent form, duplicate changes need to be removed, and --// all changes must be applied at once at the end of the refactoring so that --// the code is always parseable. --// --//===----------------------------------------------------------------------===// -- --#ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H --#define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H -- --#include "clang/Basic/LangOptions.h" --#include "clang/Basic/SourceLocation.h" --#include "llvm/ADT/StringRef.h" --#include "llvm/Support/Error.h" --#include --#include -+#ifndef LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H -+#define LLVM_CLANG_TOOLING_CORE_DIAGNOSTICS_H -+#include "clang/Basic/Diagnostic.h" -+#include "llvm/ADT/SmallVector.h" -+#include "Replacement.h" - #include --#include -- - namespace clang { -+ namespace tooling { - --class Rewriter; -+ struct DiagnosticsMessage { -+ DiagnosticsMessage(StringRef Message = ""); -+ DiagnosticsMessage(StringRef Message, const SourceManager &Sources, -+ SourceLocation Loc); -+ std::string Message; -+ std::string FilePath; -+ unsigned FileOffset; -+ }; - --namespace tooling { -+ struct Diagnostics { - --/// \brief A source range independent of the \c SourceManager. --class Range { --public: -- Range() : Offset(0), Length(0) {} -- Range(unsigned Offset, unsigned Length) : Offset(Offset), Length(Length) {} -+ enum Level { -+ Warning = DiagnosticsEngine::Warning, -+ Error = DiagnosticsEngine::Error -+ }; - -- /// \brief Accessors. -- /// @{ -- unsigned getOffset() const { return Offset; } -- unsigned getLength() const { return Length; } -- /// @} -+ Diagnostics(); -+ Diagnostics(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, -+ StringRef BuildDirectory); -+ std::string CheckName; -+ DiagnosticsMessage Message; -+ tooling::Replacements Fix; -+ SmallVector Notes; - -- /// \name Range Predicates -- /// @{ -- /// \brief Whether this range overlaps with \p RHS or not. -- bool overlapsWith(Range RHS) const { -- return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length; -- } -+ // A build directory of the diagnostic source file. -+ // -+ // It's an absolute path which is `directory` field of the source file in -+ // compilation database. If users don't specify the compilation database -+ // directory, it is the current directory where clang-tidy runs. -+ // -+ // Note: it is empty in unittest. -+ std::string BuildDirectory; - -- /// \brief Whether this range contains \p RHS or not. -- bool contains(Range RHS) const { -- return RHS.Offset >= Offset && -- (RHS.Offset + RHS.Length) <= (Offset + Length); -- } -+ Level DiagLevel; -+ bool IsWarningAsError; -+ }; - -- /// \brief Whether this range equals to \p RHS or not. -- bool operator==(const Range &RHS) const { -- return Offset == RHS.getOffset() && Length == RHS.getLength(); -- } -- /// @} -- --private: -- unsigned Offset; -- unsigned Length; --}; -- --/// \brief A text replacement. --/// --/// Represents a SourceManager independent replacement of a range of text in a --/// specific file. --class Replacement { --public: -- /// \brief Creates an invalid (not applicable) replacement. -- Replacement(); -- -- /// \brief Creates a replacement of the range [Offset, Offset+Length) in -- /// FilePath with ReplacementText. -- /// -- /// \param FilePath A source file accessible via a SourceManager. -- /// \param Offset The byte offset of the start of the range in the file. -- /// \param Length The length of the range in bytes. -- Replacement(StringRef FilePath, unsigned Offset, unsigned Length, -- StringRef ReplacementText); -- -- /// \brief Creates a Replacement of the range [Start, Start+Length) with -- /// ReplacementText. -- Replacement(const SourceManager &Sources, SourceLocation Start, -- unsigned Length, StringRef ReplacementText); -- -- /// \brief Creates a Replacement of the given range with ReplacementText. -- Replacement(const SourceManager &Sources, const CharSourceRange &Range, -- StringRef ReplacementText, -- const LangOptions &LangOpts = LangOptions()); -- -- /// \brief Creates a Replacement of the node with ReplacementText. -- template -- Replacement(const SourceManager &Sources, const Node &NodeToReplace, -- StringRef ReplacementText, -- const LangOptions &LangOpts = LangOptions()); -- -- /// \brief Returns whether this replacement can be applied to a file. -- /// -- /// Only replacements that are in a valid file can be applied. -- bool isApplicable() const; -- -- /// \brief Accessors. -- /// @{ -- StringRef getFilePath() const { return FilePath; } -- unsigned getOffset() const { return ReplacementRange.getOffset(); } -- unsigned getLength() const { return ReplacementRange.getLength(); } -- StringRef getReplacementText() const { return ReplacementText; } -- /// @} -- -- /// \brief Applies the replacement on the Rewriter. -- bool apply(Rewriter &Rewrite) const; -- -- /// \brief Returns a human readable string representation. -- std::string toString() const; -- -- private: -- void setFromSourceLocation(const SourceManager &Sources, -- SourceLocation Start, unsigned Length, -- StringRef ReplacementText); -- void setFromSourceRange(const SourceManager &Sources, -- const CharSourceRange &Range, -- StringRef ReplacementText, -- const LangOptions &LangOpts); -- -- std::string FilePath; -- Range ReplacementRange; -- std::string ReplacementText; --}; -- --/// \brief Less-than operator between two Replacements. --bool operator<(const Replacement &LHS, const Replacement &RHS); -- --/// \brief Equal-to operator between two Replacements. --bool operator==(const Replacement &LHS, const Replacement &RHS); -- --/// \brief A set of Replacements. --/// FIXME: Change to a vector and deduplicate in the RefactoringTool. --typedef std::set Replacements; -- --/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite. --/// --/// Replacement applications happen independently of the success of --/// other applications. --/// --/// \returns true if all replacements apply. false otherwise. --bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite); -- --/// \brief Apply all replacements in \p Replaces to the Rewriter \p Rewrite. --/// --/// Replacement applications happen independently of the success of --/// other applications. --/// --/// \returns true if all replacements apply. false otherwise. --bool applyAllReplacements(const std::vector &Replaces, -- Rewriter &Rewrite); -- --/// \brief Applies all replacements in \p Replaces to \p Code. --/// --/// This completely ignores the path stored in each replacement. If all --/// replacements are applied successfully, this returns the code with --/// replacements applied; otherwise, an llvm::Error carrying llvm::StringError --/// is returned (the Error message can be converted to string using --/// `llvm::toString()` and 'std::error_code` in the `Error` should be ignored). --llvm::Expected applyAllReplacements(StringRef Code, -- const Replacements &Replaces); -- --/// \brief Calculates how a code \p Position is shifted when \p Replaces are --/// applied. --unsigned shiftedCodePosition(const Replacements& Replaces, unsigned Position); -- --/// \brief Calculates how a code \p Position is shifted when \p Replaces are --/// applied. --/// --/// \pre Replaces[i].getOffset() <= Replaces[i+1].getOffset(). --unsigned shiftedCodePosition(const std::vector &Replaces, -- unsigned Position); -- --/// \brief Removes duplicate Replacements and reports if Replacements conflict --/// with one another. All Replacements are assumed to be in the same file. --/// --/// \post Replaces[i].getOffset() <= Replaces[i+1].getOffset(). --/// --/// This function sorts \p Replaces so that conflicts can be reported simply by --/// offset into \p Replaces and number of elements in the conflict. --void deduplicate(std::vector &Replaces, -- std::vector &Conflicts); -- --/// \brief Collection of Replacements generated from a single translation unit. --struct TranslationUnitReplacements { -- /// Name of the main source for the translation unit. -- std::string MainSourceFile; -- -- /// A freeform chunk of text to describe the context of the replacements. -- /// Will be printed, for example, when detecting conflicts during replacement -- /// deduplication. -- std::string Context; -- -- std::vector Replacements; --}; -- --/// \brief Calculates the ranges in a single file that are affected by the --/// Replacements. Overlapping ranges will be merged. --/// --/// \pre Replacements must be for the same file. --/// --/// \returns a non-overlapping and sorted ranges. --std::vector calculateChangedRanges(const Replacements &Replaces); -- --/// \brief Calculates the new ranges after \p Replaces are applied. These --/// include both the original \p Ranges and the affected ranges of \p Replaces --/// in the new code. --/// --/// \pre Replacements must be for the same file. --/// --/// \return The new ranges after \p Replaces are applied. The new ranges will be --/// sorted and non-overlapping. --std::vector --calculateRangesAfterReplacements(const Replacements &Replaces, -- const std::vector &Ranges); -- --/// \brief Groups a random set of replacements by file path. Replacements --/// related to the same file entry are put into the same vector. --std::map --groupReplacementsByFile(const Replacements &Replaces); -- --/// \brief Merges two sets of replacements with the second set referring to the --/// code after applying the first set. Within both 'First' and 'Second', --/// replacements must not overlap. --Replacements mergeReplacements(const Replacements &First, -- const Replacements &Second); -- --template --Replacement::Replacement(const SourceManager &Sources, -- const Node &NodeToReplace, StringRef ReplacementText, -- const LangOptions &LangOpts) { -- const CharSourceRange Range = -- CharSourceRange::getTokenRange(NodeToReplace->getSourceRange()); -- setFromSourceRange(Sources, Range, ReplacementText, LangOpts); -+ struct TranslationUnitDiagnostics { -+ std::string MainSourceFile; -+ std::string Context; -+ std::vector Diags; -+ }; -+ } - } -- --} // end namespace tooling --} // end namespace clang -- --#endif // LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H -+#endif -\ No newline at end of file -Index: lib/Tooling/Core/CMakeLists.txt -=================================================================== ---- lib/Tooling/Core/CMakeLists.txt (revision 278390) -+++ lib/Tooling/Core/CMakeLists.txt (working copy) -@@ -3,6 +3,7 @@ - add_clang_library(clangToolingCore - Lookup.cpp - Replacement.cpp -+ Diagnostics.cpp - QualTypeNames.cpp - - LINK_LIBS -Index: lib/Tooling/Core/Diagnostics.cpp -=================================================================== ---- lib/Tooling/Core/Diagnostics.cpp (revision 278390) -+++ lib/Tooling/Core/Diagnostics.cpp (working copy) -@@ -1,113 +1,30 @@ --//===--- Lookup.cpp - Framework for clang refactoring tools ---------------===// --// --// The LLVM Compiler Infrastructure --// --// This file is distributed under the University of Illinois Open Source --// License. See LICENSE.TXT for details. --// --//===----------------------------------------------------------------------===// --// --// This file defines helper methods for clang tools performing name lookup. --// --//===----------------------------------------------------------------------===// -+#include "clang/Tooling/Core/Diagnostics.h" -+#include "clang/Basic/SourceManager.h" -+namespace clang { -+ namespace tooling { - --#include "clang/Tooling/Core/Lookup.h" --#include "clang/AST/Decl.h" --using namespace clang; --using namespace clang::tooling; -+ DiagnosticsMessage::DiagnosticsMessage(StringRef Message) -+ : Message(Message), FileOffset(0) { -+ } - --static bool isInsideDifferentNamespaceWithSameName(const DeclContext *DeclA, -- const DeclContext *DeclB) { -- while (true) { -- // Look past non-namespaces on DeclA. -- while (DeclA && !isa(DeclA)) -- DeclA = DeclA->getParent(); -+ DiagnosticsMessage::DiagnosticsMessage(StringRef Message, -+ const SourceManager &Sources, -+ SourceLocation Loc) -+ : Message(Message) { -+ assert(Loc.isValid() && Loc.isFileID()); -+ FilePath = Sources.getFilename(Loc); -+ FileOffset = Sources.getFileOffset(Loc); -+ } - -- // Look past non-namespaces on DeclB. -- while (DeclB && !isa(DeclB)) -- DeclB = DeclB->getParent(); -+ Diagnostics::Diagnostics() { -+ } - -- // We hit the root, no namespace collision. -- if (!DeclA || !DeclB) -- return false; -- -- // Literally the same namespace, not a collision. -- if (DeclA == DeclB) -- return false; -- -- // Now check the names. If they match we have a different namespace with the -- // same name. -- if (cast(DeclA)->getDeclName() == -- cast(DeclB)->getDeclName()) -- return true; -- -- DeclA = DeclA->getParent(); -- DeclB = DeclB->getParent(); -- } --} -- --static StringRef getBestNamespaceSubstr(const DeclContext *DeclA, -- StringRef NewName, -- bool HadLeadingColonColon) { -- while (true) { -- while (DeclA && !isa(DeclA)) -- DeclA = DeclA->getParent(); -- -- // Fully qualified it is! Leave :: in place if it's there already. -- if (!DeclA) -- return HadLeadingColonColon ? NewName : NewName.substr(2); -- -- // Otherwise strip off redundant namespace qualifications from the new name. -- // We use the fully qualified name of the namespace and remove that part -- // from NewName if it has an identical prefix. -- std::string NS = -- "::" + cast(DeclA)->getQualifiedNameAsString() + "::"; -- if (NewName.startswith(NS)) -- return NewName.substr(NS.size()); -- -- // No match yet. Strip of a namespace from the end of the chain and try -- // again. This allows to get optimal qualifications even if the old and new -- // decl only share common namespaces at a higher level. -- DeclA = DeclA->getParent(); -- } --} -- --/// Check if the name specifier begins with a written "::". --static bool isFullyQualified(const NestedNameSpecifier *NNS) { -- while (NNS) { -- if (NNS->getKind() == NestedNameSpecifier::Global) -- return true; -- NNS = NNS->getPrefix(); -- } -- return false; --} -- --std::string tooling::replaceNestedName(const NestedNameSpecifier *Use, -- const DeclContext *UseContext, -- const NamedDecl *FromDecl, -- StringRef ReplacementString) { -- assert(ReplacementString.startswith("::") && -- "Expected fully-qualified name!"); -- -- // We can do a raw name replacement when we are not inside the namespace for -- // the original function and it is not in the global namespace. The -- // assumption is that outside the original namespace we must have a using -- // statement that makes this work out and that other parts of this refactor -- // will automatically fix using statements to point to the new function -- const bool class_name_only = !Use; -- const bool in_global_namespace = -- isa(FromDecl->getDeclContext()); -- if (class_name_only && !in_global_namespace && -- !isInsideDifferentNamespaceWithSameName(FromDecl->getDeclContext(), -- UseContext)) { -- auto Pos = ReplacementString.rfind("::"); -- return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2) -- : ReplacementString; -- } -- // We did not match this because of a using statement, so we will need to -- // figure out how good a namespace match we have with our destination type. -- // We work backwards (from most specific possible namespace to least -- // specific). -- return getBestNamespaceSubstr(UseContext, ReplacementString, -- isFullyQualified(Use)); --} -+ Diagnostics::Diagnostics(StringRef CheckName, -+ Diagnostics::Level DiagLevel, -+ bool IsWarningAsError, -+ StringRef BuildDirectory) -+ : CheckName(CheckName), BuildDirectory(BuildDirectory), DiagLevel(DiagLevel), -+ IsWarningAsError(IsWarningAsError) { -+ } -+ } -+} -\ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/utils/AnalyticsTools.java --- a/ide.analysis.modernize/src/org/netbeans/modules/ide/analysis/modernize/utils/AnalyticsTools.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): Ilia Gromov - */ -package org.netbeans.modules.ide.analysis.modernize.utils; - -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeErrorProvider; -import java.util.ArrayList; -import java.util.List; -import org.netbeans.api.project.FileOwnerQuery; -import org.netbeans.api.project.Project; -import org.netbeans.modules.analysis.spi.Analyzer; -import org.netbeans.modules.cnd.analysis.api.AnalyzerResponse; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; -import org.netbeans.modules.cnd.api.project.NativeFileItem; -import org.netbeans.modules.cnd.api.remote.RemoteProject; -import org.netbeans.modules.cnd.api.toolchain.CompilerSet; -import org.netbeans.modules.cnd.api.toolchain.PredefinedToolKind; -import org.netbeans.modules.cnd.api.toolchain.Tool; -import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider; -import org.netbeans.modules.cnd.makeproject.api.configurations.Item; -import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor; -import org.netbeans.modules.cnd.spi.toolchain.ToolchainProject; -import org.netbeans.modules.cnd.utils.MIMENames; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; -import org.openide.filesystems.FileObject; -import org.openide.util.Lookup; - -/** - * - * @author Ilia Gromov - */ -public class AnalyticsTools { - - public static ExecutionEnvironment detectEnvironment(Analyzer.Context context) { - if (context.getScope() == null) { - return null; - } - for (FileObject fo : context.getScope().getFiles()) { - String mimeType = fo.getMIMEType(); - if (MIMENames.isHeaderOrCppOrC(mimeType)) { - Project project = FileOwnerQuery.getOwner(fo); - RemoteProject info = project.getLookup().lookup(RemoteProject.class); - if (info != null) { - ExecutionEnvironment dh = info.getDevelopmentHost(); - if (dh != null) { - return dh; - } - } - } - } - return null; - } - - public static CompilerSet toolchain(Lookup.Provider project) { - ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class); - if (toolchain != null) { - return toolchain.getCompilerSet(); - } - return null; - } - - public static MakeConfigurationDescriptor getConfigurationDescriptor(CsmFile file, Lookup.Provider project) { - if (file != null) { - ConfigurationDescriptorProvider pdp = project.getLookup().lookup(ConfigurationDescriptorProvider.class); - if (pdp != null) { - MakeConfigurationDescriptor makeConfigurationDescriptor = pdp.getConfigurationDescriptor(); - if (makeConfigurationDescriptor != null) { - return makeConfigurationDescriptor; - } - } - } - - return null; - } - - public static Item findItem(CsmFile file, Lookup.Provider project) { - return getConfigurationDescriptor(file, project).findProjectItemByPath(file.getAbsolutePath().toString()); - } - - public static void fatalError(AnalyzerResponse.AnalyzerSeverity severity, String id, String message, CsmFile file, CsmErrorProvider.Response response) { - CsmErrorInfo fatal = new ModernizeErrorProvider.FatalErrorInfo(id, message); - if (response instanceof AnalyzerResponse) { - AnalyzerResponse ar = (AnalyzerResponse) response; - ar.addError(severity, message, file.getFileObject(), fatal); //NOI18N - } else { - response.addError(fatal); //NOI18N - } - } - - public static String useTool(Item item, Lookup.Provider project) { - ToolchainProject toolchain = project.getLookup().lookup(ToolchainProject.class); - if (toolchain != null) { - CompilerSet set = toolchain.getCompilerSet(); - if (set != null) { - if (set.getCompilerFlavor().isSunStudioCompiler()) { - if (item.getLanguage() == NativeFileItem.Language.C) { - return set.findTool(PredefinedToolKind.CCompiler).getPath(); - } else { - return set.findTool(PredefinedToolKind.CCCompiler).getPath(); - } - } - } - } - return null; - } - - public static Tool compiler(Item item, Lookup.Provider project) { - CompilerSet set = toolchain(project); - if (set != null) { - if (item.getLanguage() == NativeFileItem.Language.C) { - return set.findTool(PredefinedToolKind.CCompiler); - } else { - return set.findTool(PredefinedToolKind.CCCompiler); - } - } - return null; - } - - public static List scanCommandLine(String line) { - List res = new ArrayList(); - int i = 0; - StringBuilder current = new StringBuilder(); - boolean isSingleQuoteMode = false; - boolean isDoubleQuoteMode = false; - while (i < line.length()) { - char c = line.charAt(i); - i++; - switch (c) { - case '\'': // NOI18N - if (isSingleQuoteMode) { - isSingleQuoteMode = false; - } else if (!isDoubleQuoteMode) { - isSingleQuoteMode = true; - } - current.append(c); - break; - case '\"': // NOI18N - if (isDoubleQuoteMode) { - isDoubleQuoteMode = false; - } else if (!isSingleQuoteMode) { - isDoubleQuoteMode = true; - } - current.append(c); - break; - case ' ': // NOI18N - case '\t': // NOI18N - case '\n': // NOI18N - case '\r': // NOI18N - if (isSingleQuoteMode || isDoubleQuoteMode) { - current.append(c); - break; - } else { - if (current.length() > 0) { - res.add(current.toString()); - current.setLength(0); - } - } - break; - default: - current.append(c); - break; - } - } - if (current.length() > 0) { - res.add(current.toString()); - } - return res; - } - -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt --- a/ide.analysis.modernize/test/unit/data/clang-tidy-3.9-README.txt Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -File clang-tidy-3.9p should be placed in this directory before testing. -(Won't commit large, ~25Mb binary file to Mercurial repo). \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/CMakeLists.txt Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -project (HelloCMake CXX) -add_subdirectory (src) diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/configurations.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ - - - - - - - llvm-header-guard.cpp - - - - CMakeLists.txt - build/Debug/Makefile - build/Release/Makefile - - - ^(nbproject|build)$ - - . - - build/Debug/Makefile - - - - default - false - false - - - - - - - - - build/Debug - ${MAKE} -f Makefile - ${MAKE} -f Makefile clean - build/Debug/src/welcome - - - build/Debug/src - - - - - build/Debug - ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. - true - - - - - - - - - - default - false - false - - - - - - build/Release - ${MAKE} -f Makefile - ${MAKE} -f Makefile clean - build/Release/src/welcome - - - build/Release/src - - - NDEBUG - - - - - build/Release - ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. - true - - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/nbproject/project.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ - - - - org.netbeans.modules.cnd.makeproject - - - hello-cmake-world - - cpp - h - UTF-8 - - . - - - - . - - - - Debug - 0 - - - Release - 0 - - - - false - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/CMakeLists.txt Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -set(CMAKE_CXX_STANDARD 11) -add_library (headers llvm-header-guard.cpp) diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/HeaderTest/project-with-headers/src/llvm-header-guard.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -#include "llvm-header-guard.h" \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/CMakeLists.txt Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -project (HelloCMake) -add_subdirectory (src) diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/configurations.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ - - - - - - - modernize-loop-convert.cpp - modernize-raw-string-literal.cpp - modernize-use-nullptr.cpp - - - - CMakeLists.txt - build/Debug/Makefile - build/Release/Makefile - - - ^(nbproject|build)$ - - . - - build/Debug/Makefile - - - - default - false - false - - - - - - - - - build/Debug - ${MAKE} -f Makefile - ${MAKE} -f Makefile clean - build/Debug/src/welcome - - - build/Debug/src - - - - - build/Debug - ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. - true - - - - - - - - - - - - - - - - - - default - false - false - - - - - - build/Release - ${MAKE} -f Makefile - ${MAKE} -f Makefile clean - build/Release/src/welcome - - - build/Release/src - - - NDEBUG - - - - - build/Release - ${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. - true - - - - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/nbproject/project.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ - - - - org.netbeans.modules.cnd.makeproject - - - hello-cmake-world - - cpp - h - UTF-8 - - . - - - - . - - - - Debug - 0 - - - Release - 0 - - - - false - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/CMakeLists.txt Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -set(CMAKE_CXX_STANDARD 11) -add_library (single-cpp-file-check modernize-use-nullptr.cpp modernize-loop-convert.cpp modernize-raw-string-literal.cpp) diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/llvm-header-guard.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -#include "llvm-header-guard.h" \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-loop-convert.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#include -#include - -using namespace std; - -int loops() { - const int N = 5; - int arr[] = {1, 2, 3, 4, 5}; - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - - // safe conversion - for (int i = 0; i < N; ++i) - cout << arr[i]; - - // reasonable conversion - for (vector::iterator it = v.begin(); it != v.end(); ++it) - cout << *it; - - // reasonable conversion - for (int i = 0; i < v.size(); ++i) - cout << v[i]; -} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-raw-string-literal.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -const char *const Quotes{"embedded \"quotes\""}; -const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"}; -const char *const SingleLine{"Single line.\n"}; -const char *const TrailingSpace{"Look here -> \n"}; -const char *const Tab{"One\tTwo\n"}; -const char *const Bell{"Hello!\a And welcome!"}; -const char *const Path{"C:\\Program Files\\Vendor\\Application.exe"}; -const char *const RegEx{"\\w\\([a-z]\\)"}; diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/hello-cmake-world/src/modernize-use-nullptr.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -#include - -void assignment() { - char *a = NULL; - char *b = 0; - char c = 0; -} - -int *ret_ptr() { - return 0; -} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/.dep.inc --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/.dep.inc Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# This code depends on make tool being used -DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES})) -ifneq (${DEPFILES},) -include ${DEPFILES} -endif diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/Makefile --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/Makefile Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# -# Available make variables: -# -# CND_BASEDIR base directory for relative paths -# CND_DISTDIR default top distribution directory (build artifacts) -# CND_BUILDDIR default top build directory (object files, ...) -# CONF name of current configuration -# CND_PLATFORM_${CONF} platform name (current configuration) -# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) -# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) -# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) -# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) -# CND_PACKAGE_NAME_${CONF} name of package (current configuration) -# CND_PACKAGE_PATH_${CONF} path to package (current configuration) -# -# NOCDDL - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin - - -# build -build: .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: .build-impl -# Add your post 'build' code here... - - -# clean -clean: .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: .clean-impl -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: .clobber-impl -# Add your post 'clobber' code here... - - -# all -all: .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: .all-impl -# Add your post 'all' code here... - - -# build tests -build-tests: .build-tests-post - -.build-tests-pre: -# Add your pre 'build-tests' code here... - -.build-tests-post: .build-tests-impl -# Add your post 'build-tests' code here... - - -# run tests -test: .test-post - -.test-pre: build-tests -# Add your pre 'test' code here... - -.test-post: .test-impl -# Add your post 'test' code here... - - -# help -help: .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: .help-impl -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk - -# include project make variables -include nbproject/Makefile-variables.mk diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Debug.mk Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a -pre and a -post target defined where you can add customized code. -# -# This makefile implements configuration specific macros and targets. - - -# Environment -MKDIR=mkdir -CP=cp -GREP=grep -NM=nm -CCADMIN=CCadmin -RANLIB=ranlib -CC=gcc -CCC=g++ -CXX=g++ -FC=gfortran -AS=as - -# Macros -CND_PLATFORM=GNU-Linux -CND_DLIB_EXT=so -CND_CONF=Debug -CND_DISTDIR=dist -CND_BUILDDIR=build - -# Include project Makefile -include Makefile - -# Object Directory -OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} - -# Object Files -OBJECTFILES= \ - ${OBJECTDIR}/welcome.o - - -# C Compiler Flags -CFLAGS= - -# CC Compiler Flags -CCFLAGS= -CXXFLAGS= - -# Fortran Compiler Flags -FFLAGS= - -# Assembler Flags -ASFLAGS= - -# Link Libraries and Options -LDLIBSOPTIONS= - -# Build Targets -.build-conf: ${BUILD_SUBPROJECTS} - "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world - -${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES} - ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} - ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS} - -${OBJECTDIR}/welcome.o: welcome.cc - ${MKDIR} -p ${OBJECTDIR} - ${RM} "$@.d" - $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc - -# Subprojects -.build-subprojects: - -# Clean Targets -.clean-conf: ${CLEAN_SUBPROJECTS} - ${RM} -r ${CND_BUILDDIR}/${CND_CONF} - -# Subprojects -.clean-subprojects: - -# Enable dependency checking -.dep.inc: .depcheck-impl - -include .dep.inc diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-Release.mk Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a -pre and a -post target defined where you can add customized code. -# -# This makefile implements configuration specific macros and targets. - - -# Environment -MKDIR=mkdir -CP=cp -GREP=grep -NM=nm -CCADMIN=CCadmin -RANLIB=ranlib -CC=gcc -CCC=g++ -CXX=g++ -FC=gfortran -AS=as - -# Macros -CND_PLATFORM=GNU-Linux -CND_DLIB_EXT=so -CND_CONF=Release -CND_DISTDIR=dist -CND_BUILDDIR=build - -# Include project Makefile -include Makefile - -# Object Directory -OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} - -# Object Files -OBJECTFILES= \ - ${OBJECTDIR}/welcome.o - - -# C Compiler Flags -CFLAGS= - -# CC Compiler Flags -CCFLAGS= -CXXFLAGS= - -# Fortran Compiler Flags -FFLAGS= - -# Assembler Flags -ASFLAGS= - -# Link Libraries and Options -LDLIBSOPTIONS= - -# Build Targets -.build-conf: ${BUILD_SUBPROJECTS} - "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world - -${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world: ${OBJECTFILES} - ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} - ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world ${OBJECTFILES} ${LDLIBSOPTIONS} - -${OBJECTDIR}/welcome.o: welcome.cc - ${MKDIR} -p ${OBJECTDIR} - ${RM} "$@.d" - $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/welcome.o welcome.cc - -# Subprojects -.build-subprojects: - -# Clean Targets -.clean-conf: ${CLEAN_SUBPROJECTS} - ${RM} -r ${CND_BUILDDIR}/${CND_CONF} - -# Subprojects -.clean-subprojects: - -# Enable dependency checking -.dep.inc: .depcheck-impl - -include .dep.inc diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-impl.mk Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -# -# Generated Makefile - do not edit! -# -# Edit the Makefile in the project folder instead (../Makefile). Each target -# has a pre- and a post- target defined where you can add customization code. -# -# This makefile implements macros and targets common to all configurations. -# -# NOCDDL - - -# Building and Cleaning subprojects are done by default, but can be controlled with the SUB -# macro. If SUB=no, subprojects will not be built or cleaned. The following macro -# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf -# and .clean-reqprojects-conf unless SUB has the value 'no' -SUB_no=NO -SUBPROJECTS=${SUB_${SUB}} -BUILD_SUBPROJECTS_=.build-subprojects -BUILD_SUBPROJECTS_NO= -BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} -CLEAN_SUBPROJECTS_=.clean-subprojects -CLEAN_SUBPROJECTS_NO= -CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} - - -# Project Name -PROJECTNAME=hello-world - -# Active Configuration -DEFAULTCONF=Debug -CONF=${DEFAULTCONF} - -# All Configurations -ALLCONFS=Debug Release - - -# build -.build-impl: .build-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf - - -# clean -.clean-impl: .clean-pre .validate-impl .depcheck-impl - @#echo "=> Running $@... Configuration=$(CONF)" - "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf - - -# clobber -.clobber-impl: .clobber-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ - done - -# all -.all-impl: .all-pre .depcheck-impl - @#echo "=> Running $@..." - for CONF in ${ALLCONFS}; \ - do \ - "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ - done - -# build tests -.build-tests-impl: .build-impl .build-tests-pre - @#echo "=> Running $@... Configuration=$(CONF)" - "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf - -# run tests -.test-impl: .build-tests-impl .test-pre - @#echo "=> Running $@... Configuration=$(CONF)" - "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf - -# dependency checking support -.depcheck-impl: - @echo "# This code depends on make tool being used" >.dep.inc - @if [ -n "${MAKE_VERSION}" ]; then \ - echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \ - echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ - echo "include \$${DEPFILES}" >>.dep.inc; \ - echo "endif" >>.dep.inc; \ - else \ - echo ".KEEP_STATE:" >>.dep.inc; \ - echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ - fi - -# configuration validation -.validate-impl: - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - echo ""; \ - echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ - echo "See 'make help' for details."; \ - echo "Current directory: " `pwd`; \ - echo ""; \ - fi - @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ - then \ - exit 1; \ - fi - - -# help -.help-impl: .help-pre - @echo "This makefile supports the following configurations:" - @echo " ${ALLCONFS}" - @echo "" - @echo "and the following targets:" - @echo " build (default target)" - @echo " clean" - @echo " clobber" - @echo " all" - @echo " help" - @echo "" - @echo "Makefile Usage:" - @echo " make [CONF=] [SUB=no] build" - @echo " make [CONF=] [SUB=no] clean" - @echo " make [SUB=no] clobber" - @echo " make [SUB=no] all" - @echo " make help" - @echo "" - @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," - @echo " also clean subprojects." - @echo "Target 'clobber' will remove all built files from all configurations and," - @echo " unless 'SUB=no', also from subprojects." - @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," - @echo " also build subprojects." - @echo "Target 'help' prints this message." - @echo "" - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Makefile-variables.mk Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# -# Generated - do not edit! -# -# NOCDDL -# -CND_BASEDIR=`pwd` -CND_BUILDDIR=build -CND_DISTDIR=dist -# Debug configuration -CND_PLATFORM_Debug=GNU-Linux -CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux -CND_ARTIFACT_NAME_Debug=hello-world -CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/hello-world -CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package -CND_PACKAGE_NAME_Debug=hello-world.tar -CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/hello-world.tar -# Release configuration -CND_PLATFORM_Release=GNU-Linux -CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux -CND_ARTIFACT_NAME_Release=hello-world -CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/hello-world -CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package -CND_PACKAGE_NAME_Release=hello-world.tar -CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/hello-world.tar -# -# include compiler specific variables -# -# dmake command -ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ - (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) -# -# gmake command -.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) -# -include nbproject/private/Makefile-variables.mk diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Debug.bash Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -CND_PLATFORM=GNU-Linux -CND_CONF=Debug -CND_DISTDIR=dist -CND_BUILDDIR=build -CND_DLIB_EXT=so -NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world -OUTPUT_BASENAME=hello-world -PACKAGE_TOP_DIR=hello-world/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package -rm -rf ${NBTMPDIR} -mkdir -p ${NBTMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory "${NBTMPDIR}/hello-world/bin" -copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 - - -# Generate tar file -cd "${TOP}" -rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar -cd ${NBTMPDIR} -tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${NBTMPDIR} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/Package-Release.bash Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -#!/bin/bash -x - -# -# Generated - do not edit! -# - -# Macros -TOP=`pwd` -CND_PLATFORM=GNU-Linux -CND_CONF=Release -CND_DISTDIR=dist -CND_BUILDDIR=build -CND_DLIB_EXT=so -NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging -TMPDIRNAME=tmp-packaging -OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/hello-world -OUTPUT_BASENAME=hello-world -PACKAGE_TOP_DIR=hello-world/ - -# Functions -function checkReturnCode -{ - rc=$? - if [ $rc != 0 ] - then - exit $rc - fi -} -function makeDirectory -# $1 directory path -# $2 permission (optional) -{ - mkdir -p "$1" - checkReturnCode - if [ "$2" != "" ] - then - chmod $2 "$1" - checkReturnCode - fi -} -function copyFileToTmpDir -# $1 from-file path -# $2 to-file path -# $3 permission -{ - cp "$1" "$2" - checkReturnCode - if [ "$3" != "" ] - then - chmod $3 "$2" - checkReturnCode - fi -} - -# Setup -cd "${TOP}" -mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package -rm -rf ${NBTMPDIR} -mkdir -p ${NBTMPDIR} - -# Copy files and create directories and links -cd "${TOP}" -makeDirectory "${NBTMPDIR}/hello-world/bin" -copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 - - -# Generate tar file -cd "${TOP}" -rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar -cd ${NBTMPDIR} -tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/hello-world.tar * -checkReturnCode - -# Cleanup -cd "${TOP}" -rm -rf ${NBTMPDIR} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/configurations.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ - - - - - welcome.h - - - - - welcome.cc - - - - - Makefile - - - Makefile - - - - default - true - false - - - - - - - - - - - default - true - false - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/nbproject/project.xml Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - org.netbeans.modules.cnd.makeproject - - - hello-world2 - - cc - h - UTF-8 - - - - - Debug - 1 - - - Release - 1 - - - - false - - - - diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/welcome.cc --- a/ide.analysis.modernize/test/unit/data/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world/welcome.cc Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2009-2014, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of Oracle nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -int main(int argc, char**argv) { - // Prints hello message... - std::cout << "Hello World!" << std::endl; - - return 0; -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/HeaderTest/src/llvm-header-guard.h Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -#ifndef _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H -#define _IDE_ANALYSIS_MODERNIZE_HEADERTEST_PROJECT_WITH_HEADERS_SRC_LLVM_HEADER_GUARD_H -#endif \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-loop-convert.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#include - -using namespace std; - -int loops() { - const int N = 5; - int arr[] = {1, 2, 3, 4, 5}; - vector v; - v.push_back(1); - v.push_back(2); - v.push_back(3); - - // safe conversion - for (auto & elem : arr) - cout << elem; - - // reasonable conversion - for (auto & elem : v) - cout << elem; - - // reasonable conversion - for (auto & elem : v) - cout << elem; -} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-raw-string-literal.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -const char *const Quotes{R"(embedded "quotes")"}; -const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"}; -const char *const SingleLine{"Single line.\n"}; -const char *const TrailingSpace{"Look here -> \n"}; -const char *const Tab{"One\tTwo\n"}; -const char *const Bell{"Hello!\a And welcome!"}; -const char *const Path{R"(C:\Program Files\Vendor\Application.exe)"}; -const char *const RegEx{R"(\w\([a-z]\))"}; \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/SingleCppFileCheckTest/src/modernize-use-nullptr.cpp Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -#include - -void assignment() { - char *a = nullptr; - char *b = nullptr; - char c = 0; -} - -int *ret_ptr() { - return nullptr; -} \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world.json --- a/ide.analysis.modernize/test/unit/data/goldenfiles/com/sun/tools/ide/analysis/modernize/YamlTest/hello-world.json Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ ---- -MainSourceFile: '' -Diagnostics: - CheckName: misc-unused-parameters - Level: Warning - MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc - MessageFileOffset: 1615 - Message: 'parameter ''argc'' is unused' - Replacements: - - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc - Offset: 1615 - Length: 4 - ReplacementText: ' /*argc*/' -Diagnostics: - CheckName: misc-unused-parameters - Level: Warning - MessageFilePath: /media/ilia/SSD/code/sputnik/modules/ide.analysis.modernize/build/test/unit/data/ide/analysis/modernize/YamlTest/hello-world/welcome.cc - MessageFileOffset: 1627 - Message: 'parameter ''argv'' is unused' - Replacements: - - FilePath: $path/ide/analysis/modernize/YamlTest/hello-world/welcome.cc - Offset: 1627 - Length: 4 - ReplacementText: ' /*argv*/' -... \ No newline at end of file diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/HeaderTest.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -package ide.analysis.modernize; - -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix; -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser; -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import static junit.framework.TestCase.fail; -import org.netbeans.modules.cnd.test.CndCoreTestUtils; -import static org.netbeans.modules.nativeexecution.test.NativeExecutionBaseTestCase.createTempFile; -import org.openide.cookies.EditorCookie; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.loaders.DataObject; - -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -/** - * - * @author Ilia Gromov - */ -public class HeaderTest extends TidyTestCase { - - private final String source = "src/llvm-header-guard.cpp"; - private final String header = "src/llvm-header-guard.h"; - - public HeaderTest() { - super("project-with-headers"); - } - - public void testLlvmHeaderGuard() { - performTest(source, "llvm-header-guard", true); - } - - @Override - protected void processTestResults(List fixes, String footerName) throws Exception { - for (ModernizeFix fix : fixes) { - fix.implement(); - - for (YamlParser.Replacement replacement : fix.getReplacements()) { - FileObject fo = FileUtil.toFileObject(new File(replacement.filePath)); - - DataObject dObj = DataObject.find(fo); - EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class); - ec.saveDocument(); - } - } - - File diffFile = createTempFile("diff", null, false); - - boolean diff = CndCoreTestUtils.diff(new File(FileUtil.toFile(getProjectDir()), header), getGoldenFile(header), diffFile); - - if (diff) { - byte[] readAllBytes = Files.readAllBytes(diffFile.toPath()); - System.err.println(new String(readAllBytes)); - fail(); - } - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/RequestImpl.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package ide.analysis.modernize; - -import javax.swing.text.Document; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; - -/** - * - * @author Ilia Gromov - */ -class RequestImpl implements CsmErrorProvider.Request { - - private final CsmFile csmFile; - - public RequestImpl(CsmFile csmFile) { - this.csmFile = csmFile; - } - - @Override - public CsmFile getFile() { - return csmFile; - } - - @Override - public boolean isCancelled() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Document getDocument() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public CsmErrorProvider.EditorEvent getEvent() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package ide.analysis.modernize; - -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeErrorInfo; -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix; -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser; -import java.util.List; -import junit.framework.TestCase; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; -import org.openide.util.Exceptions; - -/** - * - * @author Ilia Gromov - */ -class ResponseImpl implements CsmErrorProvider.Response { - - private final List fixes; - - public ResponseImpl(List fixes) { - this.fixes = fixes; - } - - @Override - public void addError(CsmErrorInfo info) { - try { - TestCase.assertTrue(info instanceof ModernizeErrorInfo); - final List replacements = ((ModernizeErrorInfo) info).getDiagnostics().getReplacements(); - final String id = ((ModernizeErrorInfo) info).getId(); - ModernizeFix fix = new ModernizeFix(replacements, id); - fixes.add(fix); - } catch (Exception ex) { - Exceptions.printStackTrace(ex); - } - } - - @Override - public void done() { - } - -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/SingleCppFileCheckTest.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -package ide.analysis.modernize; - -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix; -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import org.junit.Test; -import org.netbeans.modules.cnd.test.CndCoreTestUtils; -import org.openide.cookies.EditorCookie; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.loaders.DataObject; - -/** - * - * @author Ilia Gromov - */ -public class SingleCppFileCheckTest extends TidyTestCase { - - public SingleCppFileCheckTest() { - super("hello-cmake-world"); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - public void testModernizeUseNullptr() { - performTest("src/modernize-use-nullptr.cpp", "modernize-use-nullptr", true); - } - - public void testModernizeLoopConvert() { - performTest("src/modernize-loop-convert.cpp", "modernize-loop-convert", true); - } - - @Test - public void testModernizeRawStringLiteral() { - performTest("src/modernize-raw-string-literal.cpp", "modernize-raw-string-literal", true); - } - - @Override - protected void processTestResults(List fixes, String startFileName) throws Exception { - for (ModernizeFix fix : fixes) { - fix.implement(); - } - - FileObject footer = getSourceFile(startFileName); - - DataObject dObj = DataObject.find(footer); - EditorCookie ec = dObj.getLookup().lookup(EditorCookie.class); - ec.saveDocument(); - - File diffFile = createTempFile("diff", null, false); - - boolean diff = CndCoreTestUtils.diff(FileUtil.toFile(footer), getGoldenFile(startFileName), diffFile); - - if (diff) { - byte[] readAllBytes = Files.readAllBytes(diffFile.toPath()); - System.err.println(new String(readAllBytes)); - fail(); - } - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/TidyTestCase.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,237 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2011 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2011 Sun Microsystems, Inc. - */ -package ide.analysis.modernize; - -import org.netbeans.modules.ide.analysis.modernize.impl.DiagnosticsTool; -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl; -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeFix; -import org.netbeans.modules.ide.analysis.modernize.impl.YamlParser; -import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.attribute.PosixFilePermissions; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.prefs.Preferences; -import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.api.project.Project; -import org.netbeans.api.project.ProjectManager; -import org.netbeans.api.project.ui.OpenProjects; -import org.netbeans.modules.analysis.SPIAccessor; -import org.netbeans.modules.analysis.spi.Analyzer; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.api.model.CsmModel; -import org.netbeans.modules.cnd.api.model.CsmModelAccessor; -import org.netbeans.modules.cnd.api.model.CsmProject; -import org.netbeans.modules.cnd.api.model.syntaxerr.AuditPreferences; -import org.netbeans.modules.cnd.api.model.syntaxerr.CodeAudit; -import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider; -import org.netbeans.modules.cnd.api.project.NativeProject; -import org.netbeans.modules.cnd.api.project.NativeProjectRegistry; -import org.netbeans.modules.cnd.api.toolchain.CompilerSet; -import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager; -import org.netbeans.modules.cnd.makeproject.api.MakeProject; -import org.netbeans.modules.cnd.makeproject.api.configurations.Item; -import org.netbeans.modules.cnd.modelutil.CsmUtilities; -import org.netbeans.modules.cnd.test.CndBaseTestCase; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; -import org.netbeans.modules.refactoring.api.Scope; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.util.Exceptions; - -/** - * - * @author Ilia Gromov - */ -public abstract class TidyTestCase extends CndBaseTestCase { - - private final String projectName; - - private List fileObjects; - private MakeProject project; - private FileObject projectDirFileObject; - - private final String CLANG_TIDY_PATH = "clang-tidy-3.9p"; - - public TidyTestCase(String projectName) { - super(projectName); - - this.projectName = projectName; - } - - protected static CodeAudit findAudit(Collection audits, String id) { - for (CodeAudit audit : audits) { - if (audit.getID().equals(id)) { - return audit; - } - } - return null; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - LogManager.getLogManager().reset(); - - java.util.logging.Logger LOG = java.util.logging.Logger.getLogger("ide.analysis.tidy"); - LOG.setLevel(Level.ALL); - - ConsoleHandler consoleHandler = new ConsoleHandler(); - consoleHandler.setLevel(Level.ALL); - LOG.addHandler(consoleHandler); - - File clangTidyFile = getBinaryFile(); - Files.setPosixFilePermissions(clangTidyFile.toPath(), PosixFilePermissions.fromString("rwxrwxrwx")); - - assertTrue(getBinaryFile().exists()); - - File projectDirFile = getDataFile(projectName); - projectDirFileObject = FileUtil.toFileObject(projectDirFile); - - fileObjects = new ArrayList(); - - project = (MakeProject) ProjectManager.getDefault().findProject(projectDirFileObject); - - OpenProjects.getDefault().open(new Project[]{project}, false); - while (!OpenProjects.getDefault().isProjectOpen(project)) { - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); - } - } - - CsmModel model = CsmModelAccessor.getModel(); - assertNotNull(project); - - NativeProject np = project.getLookup().lookup(NativeProject.class); - NativeProjectRegistry.getDefault().register(np); - model.enableProject(np); - assertNotNull(np); - - CsmProject csmProject = model.getProject(np); - assertNotNull(csmProject); - - csmProject.waitParse(); - - } - - public ExecutionEnvironment getExecEnv() { - ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal(); - return execEnv; - } - - public CompilerSet getCompilerSet() { - CompilerSetManager csm = CompilerSetManager.get(getExecEnv()); - return csm.getDefaultCompilerSet(); - } - - public MakeProject getProject() { - return project; - } - - public FileObject getProjectDir() { - return projectDirFileObject; - } - - public FileObject getSourceFile(String name) { - return FileUtil.toFileObject(new File(FileUtil.toFile(getProjectDir()), name)); - } - - public File getBinaryFile() { - return new File(getDataDir(), CLANG_TIDY_PATH); - } - - protected final void performTest(String startFileName, String checkName, boolean isStartFile) { - try { - FileObject startFile = getSourceFile(startFileName); - assertTrue(startFile.isValid()); - - Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{startFile})); - Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0); - Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl(); - - ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context); - ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal(); - final CsmFile csmFile = CsmUtilities.getCsmFile(startFile, true, false); - Item item = AnalyticsTools.findItem(csmFile, getProject()); - - Collection audits = DiagnosticsTool.getAudits(getBinaryFile().getAbsolutePath(), execEnv, new AuditPreferences(Preferences.userNodeForPackage(this.getClass()))); - CodeAudit audit = findAudit(audits, checkName); - assertNotNull(audit); - - // ----- BEGIN diagnostics ----- - DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath()); - - int exitCode = diagnosticsTool.process(Collections.singleton(audit.getID()), csmFile, true); - if (exitCode != DiagnosticsTool.STATUS_OK) { - fail(); - } - - List diags = YamlParser.getDefault().parseYaml(diagnosticsTool.getYamlAsString()); - List fixes = new ArrayList(); - - CsmErrorProvider.Request request = new RequestImpl(csmFile); - CsmErrorProvider.Response response = new ResponseImpl(fixes); - - analyzer.getErrorProvider(null).postProcess(false, csmFile, getProject(), diags, request, response); - // ----- END diagnostics ----- - - processTestResults(fixes, startFileName); - } catch (Exception ex) { - ex.printStackTrace(System.err); - fail(ex.toString()); - } - } - - protected void processTestResults(List fixes, String startFileName) throws Exception { - - } -} diff -r 1520ed2e78e3 -r 47444533169e ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java --- a/ide.analysis.modernize/test/unit/src/ide/analysis/modernize/YamlTest.java Sun Jun 25 18:17:37 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2011 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2011 Sun Microsystems, Inc. - */ -package ide.analysis.modernize; - -import org.netbeans.modules.ide.analysis.modernize.impl.DiagnosticsTool; -import org.netbeans.modules.ide.analysis.modernize.impl.ModernizeAnalyzerImpl; -import org.netbeans.modules.ide.analysis.modernize.utils.AnalyticsTools; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.Collections; -import org.junit.Test; -import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.modules.analysis.SPIAccessor; -import org.netbeans.modules.analysis.spi.Analyzer; -import org.netbeans.modules.cnd.api.model.CsmFile; -import org.netbeans.modules.cnd.makeproject.api.configurations.Item; -import org.netbeans.modules.cnd.modelutil.CsmUtilities; -import org.netbeans.modules.cnd.test.CndCoreTestUtils; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; -import org.netbeans.modules.refactoring.api.Scope; -import org.openide.filesystems.FileObject; - -/** - * - * @author Ilia Gromov - */ -public class YamlTest extends TidyTestCase { - - public YamlTest() { - super("hello-world"); - } - - @Test - public void testYaml() throws IOException, ConnectionManager.CancellationException { - FileObject singleFileObject = getSourceFile("welcome.cc"); - - File goldenFile = getGoldenFile("hello-world.json"); - String goldenYaml = new String(Files.readAllBytes(goldenFile.toPath()), "UTF-8").replaceAll("\\$path", getDataDir().getAbsolutePath()); - - Scope scope = Scope.create(null, null, Arrays.asList(new FileObject[]{singleFileObject})); - Analyzer.Context context = SPIAccessor.ACCESSOR.createContext(scope, null, null, ProgressHandle.createHandle("dummy"), 0, 0); - - Analyzer.AnalyzerFactory factory = new ModernizeAnalyzerImpl.AnalyzerFactoryImpl(); - ModernizeAnalyzerImpl analyzer = (ModernizeAnalyzerImpl) factory.createAnalyzer(context); - - ExecutionEnvironment execEnv = ExecutionEnvironmentFactory.getLocal(); - - CsmFile csmFile = CsmUtilities.getCsmFile(singleFileObject, false, false); - Item item = AnalyticsTools.findItem(csmFile, getProject()); - - DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, getProject(), getBinaryFile().getAbsolutePath()); - - int exitCode = diagnosticsTool.process(Collections.singleton("*"), csmFile, true); - - if (exitCode != DiagnosticsTool.STATUS_OK) { - fail(); - } - String yamlAsString = diagnosticsTool.getYamlAsString(); - - File real = File.createTempFile("test", null); - Files.write(real.toPath(), yamlAsString.getBytes()); - - File expected = File.createTempFile("test", null); - Files.write(expected.toPath(), goldenYaml.getBytes()); - - File diff = File.createTempFile("test", null); - if (CndCoreTestUtils.diff(real, expected, diff)) { - System.err.println("============DIFF============"); - System.err.println(new String(Files.readAllBytes(diff.toPath()), "UTF-8")); - System.err.println("============DIFF============"); - fail(); - } - } -} diff -r 1520ed2e78e3 -r 47444533169e ssinstaller/engine/nbproject/build-impl.xml --- a/ssinstaller/engine/nbproject/build-impl.xml Sun Jun 25 18:17:37 2017 +0200 +++ b/ssinstaller/engine/nbproject/build-impl.xml Sun Jun 25 18:25:05 2017 +0200 @@ -12,14 +12,21 @@ - execution - debugging - javadoc - - junit compilation - - junit execution - - junit debugging + - test compilation + - test execution + - test debugging - applet - cleanup --> + + + + + + + - - + + + - + - + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -87,6 +144,7 @@ + @@ -98,6 +156,8 @@ + + @@ -113,12 +173,58 @@ - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -146,26 +252,81 @@ - + + + - + + - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -182,44 +343,390 @@ Must set javac.includes - + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + @@ -270,10 +777,14 @@ - + + + + + @@ -289,12 +800,18 @@ + + - + + + + + - + @@ -305,22 +822,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -337,15 +937,26 @@ - + + + + + + - - + + + + + + + + @@ -358,13 +969,13 @@ Must select some files in the IDE or set javac.includes - + - + - - + + + - - + + + - - - - - - - To run this application from the command line without Ant, try: + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + - java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" + + + + + + - + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + - + - + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + @@ -506,7 +1265,7 @@ @@ -519,8 +1278,8 @@ - - + + @@ -534,10 +1293,10 @@ - + Must select some files in the IDE or set javac.includes - + @@ -549,17 +1308,17 @@ - + - Some tests failed; see details above. + Some tests failed; see details above. @@ -569,39 +1328,40 @@ Must select some files in the IDE or set test.includes - + - Some tests failed; see details above. + Some tests failed; see details above. - + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + - + Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + - + + @@ -638,17 +1398,64 @@ CLEANUP SECTION =============== --> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + diff -r 1520ed2e78e3 -r 47444533169e ssinstaller/engine/nbproject/genfiles.properties --- a/ssinstaller/engine/nbproject/genfiles.properties Sun Jun 25 18:17:37 2017 +0200 +++ b/ssinstaller/engine/nbproject/genfiles.properties Sun Jun 25 18:25:05 2017 +0200 @@ -4,5 +4,5 @@ # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=5ec25142 -nbproject/build-impl.xml.script.CRC32=c8bb3874 -nbproject/build-impl.xml.stylesheet.CRC32=61b4e419 +nbproject/build-impl.xml.script.CRC32=e32f5d42 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff -r 1520ed2e78e3 -r 47444533169e ssinstaller/engine/nbproject/project.properties --- a/ssinstaller/engine/nbproject/project.properties Sun Jun 25 18:17:37 2017 +0200 +++ b/ssinstaller/engine/nbproject/project.properties Sun Jun 25 18:25:05 2017 +0200 @@ -41,6 +41,7 @@ # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes