diff -Nru eclipse-jdt-ui-4.9/CONTRIBUTING eclipse-jdt-ui-4.10/CONTRIBUTING --- eclipse-jdt-ui-4.9/CONTRIBUTING 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/CONTRIBUTING 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,59 @@ +# Contributing to Eclipse Java development tools + +Thanks for your interest in this project. + +## Project description + +The JDT project provides the tool plug-ins that implement a Java IDE supporting +the development of any Java application, including Eclipse plug-ins. It adds a +Java project nature and Java perspective to the Eclipse Workbench as well as a +number of views, editors, wizards, builders, and code merging and refactoring +tools. The JDT project allows Eclipse to be a development environment for +itself. + +* https://projects.eclipse.org/projects/eclipse.jdt + +## Developer resources + +Information regarding source code management, builds, coding standards, and +more. + +* https://projects.eclipse.org/projects/eclipse.jdt/developer + +The project maintains the following source code repositories + +* http://git.eclipse.org/c/jdt/eclipse.jdt.core.binaries.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.core.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git + +This project uses Bugzilla to track ongoing development and issues. + +* Search for issues: https://eclipse.org/bugs/buglist.cgi?product=JDT +* Create a new report: https://eclipse.org/bugs/enter_bug.cgi?product=JDT + +Be sure to search for existing bugs before you create another one. Remember that +contributions are always welcome! + +## Eclipse Contributor Agreement + +Before your contribution can be accepted by the project team contributors must +electronically sign the Eclipse Contributor Agreement (ECA). + +* http://www.eclipse.org/legal/ECA.php + +Commits that are provided by non-committers must have a Signed-off-by field in +the footer indicating that the author is aware of the terms by which the +contribution has been provided to the project. The non-committer must +additionally have an Eclipse Foundation account and must have a signed Eclipse +Contributor Agreement (ECA) on file. + +For more information, please see the Eclipse Committer Handbook: +https://www.eclipse.org/projects/handbook/#resources-commit + +## Contact + +Contact the project developers via the project's "dev" list. + +* https://dev.eclipse.org/mailman/listinfo/jdt-dev \ No newline at end of file diff -Nru eclipse-jdt-ui-4.9/debian/build.xml eclipse-jdt-ui-4.10/debian/build.xml --- eclipse-jdt-ui-4.9/debian/build.xml 2018-12-03 12:13:31.000000000 +0000 +++ eclipse-jdt-ui-4.10/debian/build.xml 2018-12-28 14:06:37.000000000 +0000 @@ -4,8 +4,8 @@ - - + + @@ -27,6 +27,8 @@ + + diff -Nru eclipse-jdt-ui-4.9/debian/changelog eclipse-jdt-ui-4.10/debian/changelog --- eclipse-jdt-ui-4.9/debian/changelog 2018-12-10 21:54:03.000000000 +0000 +++ eclipse-jdt-ui-4.10/debian/changelog 2018-12-28 14:32:30.000000000 +0000 @@ -1,3 +1,14 @@ +eclipse-jdt-ui (4.10-1) unstable; urgency=medium + + * New upstream release + - Depend on libeclipse-jdt-core-java (>= 3.16) + - Depend on libeclipse-jface-text-java (>= 3.15) + - Depend on libeclipse-text-java (>= 3.8) + - Updated the bundle dependencies + * Standards-Version updated to 4.3.0 + + -- Emmanuel Bourg Fri, 28 Dec 2018 15:32:30 +0100 + eclipse-jdt-ui (4.9-1) unstable; urgency=medium * New upstream release diff -Nru eclipse-jdt-ui-4.9/debian/control eclipse-jdt-ui-4.10/debian/control --- eclipse-jdt-ui-4.9/debian/control 2018-12-10 21:52:09.000000000 +0000 +++ eclipse-jdt-ui-4.10/debian/control 2018-12-28 14:31:55.000000000 +0000 @@ -23,14 +23,14 @@ libeclipse-debug-core-java, libeclipse-debug-ui-java, libeclipse-help-java, - libeclipse-jdt-core-java (>= 3.15), + libeclipse-jdt-core-java (>= 3.16), libeclipse-jdt-launching-java (>= 3.11), libeclipse-jface-java (>= 3.14), - libeclipse-jface-text-java (>= 3.13), + libeclipse-jface-text-java (>= 3.15), libeclipse-search-java, libeclipse-team-core-java, libeclipse-team-ui-java, - libeclipse-text-java, + libeclipse-text-java (>= 3.8), libeclipse-ui-console-java, libeclipse-ui-editors-java, libeclipse-ui-forms-java, @@ -48,7 +48,7 @@ libicu4j-java, libswt-gtk-4-java, eclipse-debian-helper -Standards-Version: 4.2.1 +Standards-Version: 4.3.0 Vcs-Git: https://salsa.debian.org/java-team/eclipse-jdt-ui.git Vcs-Browser: https://salsa.debian.org/java-team/eclipse-jdt-ui Homepage: https://www.eclipse.org/jdt/ui/ @@ -62,7 +62,7 @@ libeclipse-core-filebuffers-java, libeclipse-core-resources-java, libeclipse-core-runtime-java, - libeclipse-jdt-core-java (>= 3.14), + libeclipse-jdt-core-java (>= 3.15), libeclipse-jface-java, libeclipse-jface-text-java, libeclipse-text-java, @@ -106,12 +106,14 @@ ${misc:Depends}, ${bundle:Depends}, libeclipse-core-expressions-java, + libeclipse-core-filebuffers-java, + libeclipse-core-filesystem-java, libeclipse-core-jobs-java, libeclipse-core-resources-java, libeclipse-core-runtime-java, - libeclipse-jdt-core-java, + libeclipse-jdt-core-java (>= 3.16), libeclipse-jdt-launching-java, - libeclipse-text-java, + libeclipse-text-java (>= 3.8), libequinox-common-java, libequinox-preferences-java, libicu4j-java @@ -269,10 +271,10 @@ libeclipse-debug-core-java, libeclipse-debug-ui-java, libeclipse-help-java, - libeclipse-jdt-core-java (>= 3.15), + libeclipse-jdt-core-java (>= 3.16), libeclipse-jdt-launching-java (>= 3.11), libeclipse-jface-java (>= 3.14), - libeclipse-jface-text-java (>= 3.13), + libeclipse-jface-text-java (>= 3.15), libeclipse-search-java, libeclipse-team-core-java, libeclipse-team-ui-java, diff -Nru eclipse-jdt-ui-4.9/LICENSE eclipse-jdt-ui-4.10/LICENSE --- eclipse-jdt-ui-4.9/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/LICENSE 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,277 @@ +Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + +3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. \ No newline at end of file diff -Nru eclipse-jdt-ui-4.9/NOTICE eclipse-jdt-ui-4.10/NOTICE --- eclipse-jdt-ui-4.9/NOTICE 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/NOTICE 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,35 @@ +# Notices for Eclipse Java development tools + +This content is produced and maintained by the Eclipse Java development tools +project. + +* Project home: https://projects.eclipse.org/projects/eclipse.jdt + +## Trademarks + +Eclipse Java development tools, Java development tools, Eclipse JDT, and JDT are +trademarks of the Eclipse Foundation. + +## Copyright + +All content is the property of the respective authors or their employers. For +more information regarding authorship of content, please consult the listed +source code repository logs. + +## Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License v. 2.0 which is available at +http://www.eclipse.org/legal/epl-2.0. + +SPDX-License-Identifier: EPL-2.0 + +## Source Code + +The project maintains the following source code repositories: + +* http://git.eclipse.org/c/jdt/eclipse.jdt.core.binaries.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.core.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.git +* http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git \ No newline at end of file diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.astview/META-INF/MANIFEST.MF eclipse-jdt-ui-4.10/org.eclipse.jdt.astview/META-INF/MANIFEST.MF --- eclipse-jdt-ui-4.9/org.eclipse.jdt.astview/META-INF/MANIFEST.MF 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.astview/META-INF/MANIFEST.MF 2018-12-03 12:49:27.000000000 +0000 @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.astview; singleton:=true -Bundle-Version: 1.3.200.qualifier +Bundle-Version: 1.3.300.qualifier Eclipse-SourceReferences: scm:git:git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui.git;path="org.eclipse.jdt.astview";tag=R4_4 Bundle-Activator: org.eclipse.jdt.astview.ASTViewPlugin Bundle-Vendor: %providerName @@ -11,7 +11,7 @@ Export-Package: org.eclipse.jdt.astview;x-internal:=true, org.eclipse.jdt.astview.views;x-internal:=true Require-Bundle: org.eclipse.core.runtime, - org.eclipse.jdt.core;bundle-version="[3.14.0,4.0.0)", + org.eclipse.jdt.core;bundle-version="[3.15.0,4.0.0)", org.eclipse.jdt.ui;bundle-version="[3.14.0,4.0.0)", org.eclipse.ui.ide, org.eclipse.ui.views, @@ -24,3 +24,4 @@ org.eclipse.core.expressions Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.eclipse.jdt.core.manipulation diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.astview/pom.xml eclipse-jdt-ui-4.10/org.eclipse.jdt.astview/pom.xml --- eclipse-jdt-ui-4.9/org.eclipse.jdt.astview/pom.xml 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.astview/pom.xml 2018-12-03 12:49:27.000000000 +0000 @@ -1,6 +1,6 @@ @@ -1740,8 +1741,15 @@ id="org.eclipse.jdt.ui.preferences.MembersOrderPreferencePage"> + + + - + - - + + @@ -4982,7 +4992,7 @@ point="org.eclipse.ui.ide.markerResolution"> + class="org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildpathProblemMarkerResolutionGenerator"> @@ -5512,6 +5522,12 @@ registryId="org.eclipse.jdt.ui.CompilationUnitEditor"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/pom.xml eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/pom.xml --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/pom.xml 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/pom.xml 2018-12-03 12:49:27.000000000 +0000 @@ -14,11 +14,11 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.9.0-SNAPSHOT + 4.10.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.ui - 3.15.0-SNAPSHOT + 3.16.0-SNAPSHOT eclipse-plugin -warn:-deprecation,unavoidableGenericProblems diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/preview/formatter.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/preview/formatter.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/preview/formatter.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/preview/formatter.java 2018-12-03 12:49:27.000000000 +0000 @@ -594,10 +594,10 @@ { @SuppressWarnings("unused") final @Positive int k; } - void foo() { ;; do {} while (false); for (;;) {} } + void foo() { ;; } void empty(@SuppressWarnings("unused") final int i) { }} -enum MyEnum { @Deprecated UNDEFINED(0) { }}enum EmptyEnum { }@interface EmptyAnnotation { -}//--PREVIEW--END--section-newlines +enum MyEnum { @Deprecated UNDEFINED(0) { }} +//--PREVIEW--END--section-newlines //--PREVIEW--START--section-newlines-controlstatements class Example { @@ -606,7 +606,6 @@ try { } catch (Exception e) { } finally { } } void foo2() { - if (true) { return; } if (true) { return; } else if (false) { return; } else { return; } } void foo(int state) { @@ -625,6 +624,112 @@ //--PREVIEW--END--section-newlines-controlstatements-simpleloops //--PREVIEW--END--section-newlines-controlstatements +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line +class Example{ + public void example() { + for (int i = 0; i < 10; i++) { + } + int a = 10; + while (a-- > 0) { System.out.println(a); } + do { a += 2; + System.out.println(a); } while(a < 50); + } +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line +class Example { + public String example(int a) { + if (a < 0) { + throw new IllegalArgumentException(); } + if (a == 0) { return null; } + if (false) {} + if (a % 3 == 0) { + System.out.println("fizz"); } + if (a % 5 == 0) { System.out.println("buzz"); return ""; } + return Integer.toString(a); + } +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line +class Example { + Runnable emptyLambda = () -> {}; + Runnable emptyLambda2 = () -> { + }; + Runnable tinyLambda = () -> { doSomething(); }; + Runnable smallLambda = () -> { doFirstThing(); doSecondThing(); }; +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_code_block_on_one_line +class Example { + static { + } + + void foo() { + if (true) {} else {} + synchronized(this) {} + try {} finally {} + + labeled:{} + } +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_code_block_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_method_body_on_one_line +public class Example { + private int something; + public int getSomething() { return something; } + public void setSomehing(int something) { this.something = something; } + public void doNoting() {} + public void doOneThing() { System.out.println(); + } + public void doMoreThings() { something = 4; doOneThing(); doOneThing(); } +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_method_body_on_one_line + + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line +public class EmptyClass{} +public class TinyClass{ + int a; } +public class SmallClass{ int a; String b; } +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line +public class AnonymousClasses { + EmptyClass emptyAnonymous = new EmptyClass() { + }; + TinyClass tinyAnonymous = new TinyClass() { String b; }; + Object o = new SmallClass() { int a; int getA() { return a; } }; +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line +public enum EmptyEnum {} +public enum TinyEnum{ A; +} +public enum SmallEnum{ VALUE(0); SmallEnum(int val) {}; } +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line +public enum EnumConstants { + EMPTY { + }, + TINY { int getVal() { return 2; }}, + SMALL { int val = 3; int getVal() { return 3; }}; + int getVal() { return 1; } +} +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line + +//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line +public @interface EmptyInterface {} +public @interface TinyInterface { + void run(); } +public @interface SmallInteface { int toA(); String toB(); } +//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line + } class LINE_WRAPING { diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/templates/default-templates.properties eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/templates/default-templates.properties --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/templates/default-templates.properties 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/templates/default-templates.properties 2018-12-03 12:49:27.000000000 +0000 @@ -68,6 +68,7 @@ Templates.arraymerge= merge two arrays into one Templates.arrayadd= add an element to an array Templates.static_final=static final field +Templates.new_module=create module declaration # Java Only stuff CompilationUnitContextType.variable.description.file=Filename of compilation unit @@ -187,4 +188,4 @@ SWTTemplates.griddata=new GridData for a Control SWTTemplates.griddatafactory=using GridDataFactory for a Control SWTTemplates.toolbar=new ToolBar -SWTTemplates.toolitem=new ToolItem for a ToolBar \ No newline at end of file +SWTTemplates.toolitem=new ToolItem for a ToolBar diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/templates/default-templates.xml eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/templates/default-templates.xml --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/templates/default-templates.xml 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/templates/default-templates.xml 2018-12-03 12:49:27.000000000 +0000 @@ -226,4 +226,8 @@ + + diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Mateusz Matela - [code manipulation] [dcr] toString() builder wizard - https://bugs.eclipse.org/bugs/show_bug.cgi?id=26070 + * Pierre-Yves B. - Check whether enclosing instance implements hashCode and equals - https://bugs.eclipse.org/539900 *******************************************************************************/ package org.eclipse.jdt.internal.ui.actions; @@ -173,6 +174,7 @@ public static String GenerateMethodAbstractAction_final_method_in_superclass_error; public static String GenerateMethodAbstractAction_already_has_this_method_error; public static String GenerateMethodAbstractAction_super_class; + public static String GenerateMethodAbstractAction_enclosing_class; public static String GenerateHashCodeEqualsAction_field_type; public static String GenerateHashCodeEqualsAction_equals; public static String GenerateHashCodeEqualsAction_hashCode; @@ -281,7 +283,7 @@ /** * DO NOT REMOVE, used in a product, see https://bugs.eclipse.org/296836 . - * @deprecated As of 3.6, replaced by {@link #OrganizeImportsAction_summary_added_singular} and {@link #OrganizeImportsAction_summary_added_plural} + * @deprecated As of 3.6, replaced by {@link #OrganizeImportsAction_summary_added_singular} and {@link #OrganizeImportsAction_summary_added_plural} */ @Deprecated public static String OrganizeImportsAction_summary_added; @@ -439,6 +441,8 @@ public static String CollapsAllAction_tooltip; public static String CollapsAllAction_description; + public static String CreateModuleInfoAction_convert_message_compliance; + public static String CreateModuleInfoAction_convert_title; public static String CreateModuleInfoAction_error_message_compliance; public static String CreateModuleInfoAction_error_message_no_source_folder; public static String CreateModuleInfoAction_error_title; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2017 IBM Corporation and others. +# Copyright (c) 2000, 2018 IBM Corporation and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -12,6 +12,7 @@ # IBM Corporation - initial API and implementation # Sebastian Davids - Bug 114276 # Mateusz Matela - [code manipulation] [dcr] toString() builder wizard - https://bugs.eclipse.org/bugs/show_bug.cgi?id=26070 +# Pierre-Yves B. - Check whether enclosing instance implements hashCode and equals - https://bugs.eclipse.org/539900 ############################################################################### OccurrencesSearchMenuAction_break_continue_target_label=&Break/Continue Targets @@ -403,6 +404,7 @@ GenerateHashCodeEqualsAction_error_caption=Generate hashCode() and equals() GenerateHashCodeEqualsAction_description=Generate implementations for hashCode() and equals() GenerateMethodAbstractAction_super_class=super class ''{0}'' +GenerateMethodAbstractAction_enclosing_class=enclosing class ''{0}'' GenerateHashCodeEqualsAction_field_type=field type ''{0}'' GenerateHashCodeEqualsAction_tooltip=Generate implementations for hashCode() and equals() GenerateHashCodeEqualsAction_equals=equals() @@ -468,6 +470,8 @@ CollapsAllAction_tooltip= Collapse All CollapsAllAction_description= Collapse All +CreateModuleInfoAction_convert_message_compliance=Project requires compliance level of 9 or above. Do you want to change project compliance and JRE to {0}? +CreateModuleInfoAction_convert_title=Create module-info.java CreateModuleInfoAction_error_message_compliance=Project requires compliance level of 9 or above. CreateModuleInfoAction_error_message_no_source_folder=No source folder exists in the project. CreateModuleInfoAction_error_title=Create module-info.java diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddBlockCommentAction.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddBlockCommentAction.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddBlockCommentAction.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddBlockCommentAction.java 2018-12-03 12:49:27.000000000 +0000 @@ -19,6 +19,8 @@ import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.action.IAction; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPartitioningException; import org.eclipse.jface.text.IDocument; @@ -39,17 +41,19 @@ */ public class AddBlockCommentAction extends BlockCommentAction { + private IAction action; + /** * Creates a new instance. * * @param bundle the resource bundle - * @param prefix a prefix to be prepended to the various resource keys - * (described in ResourceAction constructor), or - * null if none + * @param prefix a prefix to be prepended to the various resource keys (described in + * ResourceAction constructor), or null if none * @param editor the text editor */ public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix, editor); + action= editor.getAction("Format"); //$NON-NLS-1$ } /* @@ -71,6 +75,10 @@ handleLastPartition(partition, edits, factory, selectionEndOffset); executeEdits(edits); + + if (action != null) { + action.run(); + } } /** @@ -79,8 +87,9 @@ * @param partition the partition under the start of the selection * @param edits the list of edits to later execute * @param factory the factory for edits - * @param offset the start of the selection, which must lie inside - * partition + * @param offset the start of the selection, which must lie inside partition + * @throws BadLocationException if accessing the document fails - this can only happen if the + * document gets modified concurrently */ private void handleFirstPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int offset) throws BadLocationException { @@ -96,19 +105,18 @@ } else if (isSpecialPartition(partType)) { // special types: include the entire partition edits.add(factory.createEdit(partOffset, 0, getCommentStart())); - } // javadoc: no mark, will only start after comment + } // javadoc: no mark, will only start after comment } /** - * Handles partition boundaries within the selection. The end of the current - * partition and the start of the next partition are examined for whether - * they contain comment tokens that interfere with the created comment. + * Handles partition boundaries within the selection. The end of the current partition and the start + * of the next partition are examined for whether they contain comment tokens that interfere with + * the created comment. *

- * Comment tokens are removed from interior multi-line comments. Javadoc - * comments are left as is; instead, multi-line comment tokens are inserted - * before and after Javadoc partitions to ensure that the entire selected - * area is commented. + * Comment tokens are removed from interior multi-line comments. Javadoc comments are left as is; + * instead, multi-line comment tokens are inserted before and after Javadoc partitions to ensure + * that the entire selected area is commented. *

*

* The next partition is returned. @@ -119,12 +127,12 @@ * @param factory the edit factory * @param docExtension the document to get the partitions from * @return the next partition after the current - * @throws BadLocationException if accessing the document fails - this can - * only happen if the document gets modified concurrently - * @throws BadPartitioningException if the document does not have a Java - * partitioning + * @throws BadLocationException if accessing the document fails - this can only happen if the + * document gets modified concurrently + * @throws BadPartitioningException if the document does not have a Java partitioning */ - private ITypedRegion handleInteriorPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, IDocumentExtension3 docExtension) throws BadPartitioningException, BadLocationException { + private ITypedRegion handleInteriorPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, IDocumentExtension3 docExtension) + throws BadPartitioningException, BadLocationException { // end of previous partition String partType= partition.getType(); @@ -173,15 +181,16 @@ } /** - * Handles the partition under the end of the selection. For normal java - * code, the comment end token is inserted at the selection end; if the - * selection ends inside a special (i.e. string, character, line comment) - * partition, the entire partition is included inside the comment. + * Handles the partition under the end of the selection. For normal java code, the comment end token + * is inserted at the selection end; if the selection ends inside a special (i.e. string, character, + * line comment) partition, the entire partition is included inside the comment. * * @param partition the partition under the selection end offset * @param edits the list of edits to add to * @param factory the edit factory * @param endOffset the end offset of the selection + * @throws BadLocationException if accessing the document fails - this can only happen if the + * document gets modified concurrently */ private void handleLastPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int endOffset) throws BadLocationException { @@ -199,12 +208,10 @@ /** * Returns whether partType is special, i.e. a Java - * String,Character, or - * Line End Comment partition. + * String,Character, or Line End Comment partition. * * @param partType the partition type to check - * @return true if partType is special, - * false otherwise + * @return true if partType is special, false otherwise */ private boolean isSpecialPartition(String partType) { return partType == IJavaPartitions.JAVA_CHARACTER diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CopyQualifiedNameAction.java 2018-12-03 12:49:27.000000000 +0000 @@ -73,12 +73,12 @@ import org.eclipse.jdt.core.dom.TypeDeclaration; import org.eclipse.jdt.core.dom.TypeParameter; import org.eclipse.jdt.core.dom.VariableDeclaration; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.corext.dom.ASTNodes; import org.eclipse.jdt.ui.JavaElementLabels; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.ui.actions.SelectionDispatchAction; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; @@ -302,7 +302,7 @@ if (element == null) return null; - CompilationUnit ast= SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, null); + CompilationUnit ast= SharedASTProviderCore.getAST(element, SharedASTProviderCore.WAIT_YES, null); if (ast == null) return null; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CreateModuleInfoAction.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CreateModuleInfoAction.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CreateModuleInfoAction.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CreateModuleInfoAction.java 2018-12-03 12:49:27.000000000 +0000 @@ -15,7 +15,11 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; @@ -24,6 +28,8 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -43,11 +49,17 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; +import org.eclipse.jdt.launching.IVMInstall; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jdt.launching.environments.IExecutionEnvironment; + import org.eclipse.jdt.internal.ui.JavaPlugin; +import org.eclipse.jdt.internal.ui.util.ClasspathVMUtil; import org.eclipse.jdt.internal.ui.wizards.NewModuleInfoWizard; public class CreateModuleInfoAction implements IObjectActionDelegate { @@ -116,8 +128,27 @@ try { if (!JavaModelUtil.is9OrHigher(javaProject)) { - MessageDialog.openError(getDisplay().getActiveShell(), ActionMessages.CreateModuleInfoAction_error_title, ActionMessages.CreateModuleInfoAction_error_message_compliance); - return; + IVMInstall install= ClasspathVMUtil.findRequiredOrGreaterVMInstall(JavaCore.VERSION_9, true, true); + if (install == null) { + MessageDialog.openError(getDisplay().getActiveShell(), ActionMessages.CreateModuleInfoAction_error_title, ActionMessages.CreateModuleInfoAction_error_message_compliance); + return; + } else { + String compliance= ClasspathVMUtil.getVMInstallCompliance(install, false); + if (compliance != null) { + boolean val= MessageDialog.openQuestion(getDisplay().getActiveShell(), ActionMessages.CreateModuleInfoAction_convert_title, + Messages.format(ActionMessages.CreateModuleInfoAction_convert_message_compliance, compliance)); + if (!val) { + return; + } else { + updateJRE(javaProject, compliance); + updateComplianceSettings(javaProject, compliance); + } + } + else { + MessageDialog.openError(getDisplay().getActiveShell(), ActionMessages.CreateModuleInfoAction_error_title, ActionMessages.CreateModuleInfoAction_error_message_compliance); + return; + } + } } IPackageFragmentRoot[] packageFragmentRoots= javaProject.getPackageFragmentRoots(); @@ -166,4 +197,24 @@ display= Display.getDefault(); return display; } + + private boolean updateJRE(IJavaProject project, String compliance) throws CoreException, JavaModelException { + IExecutionEnvironment bestEE= ClasspathVMUtil.findBestMatchingEE(compliance); + if (bestEE != null) { + IPath newPath= JavaRuntime.newJREContainerPath(bestEE); + boolean classpathUpdated= ClasspathVMUtil.updateClasspath(newPath, project, new NullProgressMonitor()); + return !classpathUpdated; + } + return true; + } + + private void updateComplianceSettings(IJavaProject project, String compliance) { + HashMap defaultOptions= new HashMap<>(); + JavaCore.setComplianceOptions(compliance, defaultOptions); + Iterator> it= defaultOptions.entrySet().iterator(); + while (it.hasNext()) { + Entry pair= it.next(); + project.setOption(pair.getKey(), pair.getValue()); + } + } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/GenerateConstructorUsingFieldsSelectionDialog.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -47,7 +47,7 @@ import org.eclipse.jdt.core.dom.IMethodBinding; import org.eclipse.jdt.core.dom.Modifier; -import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/BuildpathIndicatorLabelDecorator.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/BuildpathIndicatorLabelDecorator.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/BuildpathIndicatorLabelDecorator.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/BuildpathIndicatorLabelDecorator.java 2018-12-03 12:49:27.000000000 +0000 @@ -43,19 +43,19 @@ IResource resource= (IResource) element; IProject project= resource.getProject(); if (project != null) { - IJavaProject javaProject= JavaCore.create(project); - if (javaProject != null) { - if (javaProject.isOnClasspath(resource)) { - IJavaElement javaElement= JavaCore.create(resource, javaProject); - try { + try { + IJavaProject javaProject= JavaCore.create(project); + if (javaProject != null) { + if (javaProject.isOnClasspath(resource)) { + IJavaElement javaElement= JavaCore.create(resource, javaProject); if (javaElement instanceof IPackageFragmentRoot && ((IPackageFragmentRoot)javaElement).getKind() != IPackageFragmentRoot.K_SOURCE) { return JavaPluginImages.DESC_OVR_LIBRARY; } - } catch (JavaModelException e) { - return null; } } + } catch (JavaModelException | IllegalStateException e) { + return null; } } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/CompatibilityTemplateStore.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/CompatibilityTemplateStore.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/CompatibilityTemplateStore.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/CompatibilityTemplateStore.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -19,11 +19,12 @@ import java.util.Iterator; import java.util.List; +import org.eclipse.text.templates.TemplatePersistenceData; + import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.templates.ContextTypeRegistry; import org.eclipse.jface.text.templates.Template; -import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; import org.eclipse.jface.text.templates.persistence.TemplateStore; import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/OverrideMethodDialog.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/OverrideMethodDialog.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/OverrideMethodDialog.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/OverrideMethodDialog.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -50,12 +50,12 @@ import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.Modifier; -import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2; +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; +import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2Core; import org.eclipse.jdt.internal.corext.dom.ASTNodes; import org.eclipse.jdt.internal.corext.dom.Bindings; import org.eclipse.jdt.internal.corext.dom.IASTSharedValues; import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser; -import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; @@ -302,7 +302,7 @@ IMethodBinding[] overridable= null; if (binding != null) { final IPackageBinding pack= binding.getPackage(); - final IMethodBinding[] methods= StubUtility2.getOverridableMethods(fUnit.getAST(), binding, false); + final IMethodBinding[] methods= StubUtility2Core.getOverridableMethods(fUnit.getAST(), binding, false); List list= new ArrayList<>(methods.length); for (int index= 0; index < methods.length; index++) { final IMethodBinding cur= methods[index]; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Inc. - modified to use JdtViewerDropAdapterConstants *******************************************************************************/ package org.eclipse.jdt.internal.ui.dnd; @@ -27,6 +28,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jdt.internal.ui.JdtViewerDropAdapterConstants; + /** * This adapter class provides generic drag-and-drop support for a viewer. *

@@ -51,7 +54,7 @@ * slightly before the target. * @see #getCurrentLocation() */ - public static final int LOCATION_BEFORE = 1; + public static final int LOCATION_BEFORE = JdtViewerDropAdapterConstants.LOCATION_BEFORE; /** * Constant describing the position of the cursor relative @@ -59,7 +62,7 @@ * slightly after the target. * @see #getCurrentLocation() */ - public static final int LOCATION_AFTER = 2; + public static final int LOCATION_AFTER = JdtViewerDropAdapterConstants.LOCATION_AFTER; /** * Constant describing the position of the cursor relative @@ -67,7 +70,7 @@ * directly on the target. * @see #getCurrentLocation() */ - public static final int LOCATION_ON = 3; + public static final int LOCATION_ON = JdtViewerDropAdapterConstants.LOCATION_ON; /** * Constant describing the position of the cursor relative @@ -75,7 +78,7 @@ * over or near any valid target. * @see #getCurrentLocation() */ - public static final int LOCATION_NONE = 4; + public static final int LOCATION_NONE = JdtViewerDropAdapterConstants.LOCATION_NONE; /** * The viewer to which this drop support has been added. diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java 2018-12-03 12:49:27.000000000 +0000 @@ -25,6 +25,7 @@ import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.AnonymousClassDeclaration; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.EnumDeclaration; import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.Modifier; @@ -139,7 +140,7 @@ TypeDeclaration typeDecl= ASTNodes.getParent(node, TypeDeclaration.class); if (typeDecl != null && typeDecl.isInterface()) { rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.ABSTRACT)); - if (!AnonymousClassDeclaration.class.isInstance(node.getParent())) { + if (!AnonymousClassDeclaration.class.isInstance(node.getParent()) && !EnumDeclaration.class.isInstance(node.getParent())) { rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.PUBLIC)); } } else if (typeDecl != null && Modifier.isFinal(typeDecl.getModifiers()) && Modifier.isFinal(node.getModifiers())) { @@ -155,6 +156,15 @@ rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.STATIC)); } return true; + } + + @Override + public boolean visit(EnumDeclaration node) { + TypeDeclaration typeDecl= ASTNodes.getParent(node, TypeDeclaration.class); + if (typeDecl != null && Modifier.isStatic(node.getModifiers())) { + rewriteOperations.add(new RemoveModifiersOperation(node, Modifier.STATIC)); + } + return true; } }); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java 2018-12-03 12:49:27.000000000 +0000 @@ -36,6 +36,7 @@ import org.eclipse.jdt.core.dom.EmptyStatement; import org.eclipse.jdt.core.dom.EnumDeclaration; import org.eclipse.jdt.core.dom.FieldDeclaration; +import org.eclipse.jdt.core.dom.LambdaExpression; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.PackageDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; @@ -178,7 +179,9 @@ @Override public boolean visit(Block node) { - searchNode(node, contents, label, textedits); + if (!(node.getParent() instanceof LambdaExpression)) { + searchNode(node, contents, label, textedits); + } return true; } }); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -28,10 +28,10 @@ import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContext; +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; import org.eclipse.jdt.internal.corext.fix.UnimplementedCodeFix; -import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext; -import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.cleanup.CleanUpRequirements; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaHelpContextIds.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaHelpContextIds.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaHelpContextIds.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaHelpContextIds.java 2018-12-03 12:49:27.000000000 +0000 @@ -349,6 +349,7 @@ public static final String JAVA_BASE_PREFERENCE_PAGE= PREFIX + "java_base_preference_page_context"; //$NON-NLS-1$ public static final String REFACTORING_PREFERENCE_PAGE= PREFIX + "refactoring_preference_page_context"; //$NON-NLS-1$ public static final String JAVA_EDITOR_PREFERENCE_PAGE= PREFIX + "java_editor_preference_page_context"; //$NON-NLS-1$ + public static final String CODE_MINING_PREFERENCE_PAGE= PREFIX + "code_mining_preference_page_context"; //$NON-NLS-1$ public static final String SPELLING_CONFIGURATION_BLOCK= PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$ public static final String PROPERTIES_FILE_EDITOR_PREFERENCE_PAGE= PREFIX + "properties_file_editor_preference_page_context"; //$NON-NLS-1$ public static final String COMPILER_PREFERENCE_PAGE= PREFIX + "compiler_preference_page_context"; //$NON-NLS-1$ diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jdt.internal.ui; - -import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider; -import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; -import org.eclipse.jdt.internal.ui.javaeditor.saveparticipant.IPostSaveListener; - -/** - * Defines status codes relevant to the Java UI plug-in. When a - * Core exception is thrown, it contain a status object describing - * the cause of the exception. The status objects originating from the - * Java UI plug-in use the codes defined in this interface. - */ -public interface IJavaStatusConstants { - - // Java UI status constants start at 10000 to make sure that we don't - // collide with resource and java model constants. - - public static final int INTERNAL_ERROR= 10001; - - /** - * Status constant indicating that an exception occurred on - * storing or loading templates. - */ - public static final int TEMPLATE_IO_EXCEPTION = 10002; - - /** - * Status constant indicating that an validateEdit call has changed the - * content of a file on disk. - */ - public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003; - - /** - * Status constant indicating that a ChangeAbortException has been - * caught. - */ - public static final int CHANGE_ABORTED= 10004; - - /** - * Status constant indicating that an exception occurred while - * parsing template file. - */ - public static final int TEMPLATE_PARSE_EXCEPTION = 10005; - - /** - * Status constant indicating that a problem occurred while notifying a post - * save listener. - * - * @see IPostSaveListener - * @since 3.3 - */ - public static final int EDITOR_POST_SAVE_NOTIFICATION= 10006; - - /** - * Status constant indication that a problem occurred while calculating - * the changed region during a save. - * - * @see CompilationUnitDocumentProvider - * @since 3.4 - */ - public static final int EDITOR_CHANGED_REGION_CALCULATION= 10007; - - /** - * Status constant indication that a problem occurred while opening an editor: - * no editor input could be created. See {@link EditorUtility#openInEditor(Object, boolean)}. - * @since 3.4 - */ - public static final int EDITOR_NO_EDITOR_INPUT= 10008; - - } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/JavadocView.java 2018-12-03 12:49:27.000000000 +0000 @@ -128,6 +128,7 @@ import org.eclipse.jdt.core.dom.IVariableBinding; import org.eclipse.jdt.core.dom.NodeFinder; import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.dom.IASTSharedValues; @@ -140,7 +141,6 @@ import org.eclipse.jdt.ui.JavaElementLabels; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; import org.eclipse.jdt.ui.actions.JdtActionConstants; import org.eclipse.jdt.ui.actions.OpenAttachedJavadocAction; @@ -1348,7 +1348,7 @@ if (monitor != null && monitor.isCanceled()) return null; - CompilationUnit ast= SharedASTProvider.getAST(constantField.getTypeRoot(), SharedASTProvider.WAIT_NO, monitor); + CompilationUnit ast= SharedASTProviderCore.getAST(constantField.getTypeRoot(), SharedASTProviderCore.WAIT_NO, monitor); if (ast != null) { try { if (constantField.isEnumConstant()) @@ -1399,7 +1399,7 @@ * @since 3.4 */ private static Object getConstantValueFromActiveEditor(ITypeRoot activeType, IField field, ITextSelection selection, IProgressMonitor monitor) { - CompilationUnit unit= SharedASTProvider.getAST(activeType, SharedASTProvider.WAIT_ACTIVE_ONLY, monitor); + CompilationUnit unit= SharedASTProviderCore.getAST(activeType, SharedASTProviderCore.WAIT_ACTIVE_ONLY, monitor); if (unit == null) return null; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/SourceView.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/SourceView.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/SourceView.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/SourceView.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -62,8 +62,8 @@ import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.internal.core.manipulation.util.Strings; -import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.ui.IContextMenuConstants; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java 2018-12-03 12:49:27.000000000 +0000 @@ -44,7 +44,6 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Monitor; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.Tree; @@ -59,8 +58,8 @@ import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.util.Geometry; import org.eclipse.jface.util.OpenStrategy; +import org.eclipse.jface.util.Util; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; @@ -695,7 +694,7 @@ Point pt= new Point(x, rect.y + rect.height); pt= fParentComposite.toDisplay(pt); - Rectangle monitor= getClosestMonitor(shell.getDisplay(), pt).getClientArea(); + Rectangle monitor= Util.getClosestMonitor(shell.getDisplay(), pt).getClientArea(); int overlap= (pt.x + width) - (monitor.x + monitor.width); if (overlap > 0) pt.x-= overlap; @@ -707,41 +706,6 @@ } /** - * Returns the monitor whose client area contains the given point. If no monitor contains the - * point, returns the monitor that is closest to the point. - *

- * Copied from org.eclipse.jface.window.Window.getClosestMonitor(Display, Point) - *

- * - * @param display the display showing the monitors - * @param point point to find (display coordinates) - * @return the monitor closest to the given point - */ - private static Monitor getClosestMonitor(Display display, Point point) { - int closest= Integer.MAX_VALUE; - - Monitor[] monitors= display.getMonitors(); - Monitor result= monitors[0]; - - for (int i= 0; i < monitors.length; i++) { - Monitor current= monitors[i]; - - Rectangle clientArea= current.getClientArea(); - - if (clientArea.contains(point)) - return current; - - int distance= Geometry.distanceSquared(Geometry.centerPoint(clientArea), point); - if (distance < closest) { - closest= distance; - result= current; - } - } - - return result; - } - - /** * Set the size of the given shell such that more content can be shown. The shell size does not * exceed a user-configurable maximum. * diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java 2018-12-03 12:49:27.000000000 +0000 @@ -87,14 +87,15 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.ToolFactory; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; import org.eclipse.jdt.core.util.ClassFormatException; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.JavaElementLabels; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; import org.eclipse.jdt.ui.actions.RefactorActionGroup; import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; @@ -103,7 +104,6 @@ import org.eclipse.jdt.internal.ui.JavaUIStatus; import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock; @@ -736,7 +736,7 @@ */ @Override protected IStatus run(IProgressMonitor monitor) { - CompilationUnit ast= SharedASTProvider.getAST(getInputJavaElement(), SharedASTProvider.WAIT_YES, null); + CompilationUnit ast= SharedASTProviderCore.getAST(getInputJavaElement(), SharedASTProviderCore.WAIT_YES, null); if (fOverrideIndicatorManager != null) fOverrideIndicatorManager.reconciled(ast, true, monitor); if (fSemanticManager != null) { diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java 2018-12-03 12:49:27.000000000 +0000 @@ -78,14 +78,14 @@ import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; import org.eclipse.jdt.core.manipulation.ImportReferencesCollector; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; -import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; +import org.eclipse.jdt.internal.core.manipulation.StubUtility; import org.eclipse.jdt.internal.corext.dom.Bindings; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.internal.ui.IJavaStatusConstants; import org.eclipse.jdt.internal.ui.JavaPlugin; @@ -444,7 +444,7 @@ private ClipboardData getClipboardData(ITypeRoot inputElement, int offset, int length) { - CompilationUnit astRoot= SharedASTProvider.getAST(inputElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null); + CompilationUnit astRoot= SharedASTProviderCore.getAST(inputElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, null); if (astRoot == null) { return null; } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/AbstractJavaElementLineHeaderCodeMining.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/AbstractJavaElementLineHeaderCodeMining.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/AbstractJavaElementLineHeaderCodeMining.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/AbstractJavaElementLineHeaderCodeMining.java 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2018 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - [CodeMining] Provide Java References/Implementation CodeMinings - Bug 529127 + */ +package org.eclipse.jdt.internal.ui.javaeditor.codemining; + +import java.util.function.Consumer; + +import org.eclipse.swt.events.MouseEvent; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.codemining.ICodeMiningProvider; +import org.eclipse.jface.text.codemining.LineHeaderCodeMining; + +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.ISourceReference; +import org.eclipse.jdt.core.JavaModelException; + +/** + * Abstract class for Java code mining. + * + * @since 3.16 + */ +public abstract class AbstractJavaElementLineHeaderCodeMining extends LineHeaderCodeMining { + + private final IJavaElement element; + + public AbstractJavaElementLineHeaderCodeMining(IJavaElement element, IDocument document, ICodeMiningProvider provider, + Consumer action) throws JavaModelException, BadLocationException { + super(getLineNumber(element, document), document, provider, action); + this.element= element; + } + + private static int getLineNumber(IJavaElement element, IDocument document) + throws JavaModelException, BadLocationException { + ISourceRange r= ((ISourceReference) element).getNameRange(); + int offset= r.getOffset(); + return document.getLineOfOffset(offset); + } + + /** + * Returns the java element. + * + * @return the java element. + */ + public IJavaElement getElement() { + return element; + } + +} diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.java 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2018 Angelo ZERR. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Angelo Zerr - [code mining] 0 reference / implementation - Bug 541396 + */ +package org.eclipse.jdt.internal.ui.javaeditor.codemining; + +import org.eclipse.osgi.util.NLS; + +/** + * Helper class to get NLSed messages. + */ +final class JavaCodeMiningMessages extends NLS { + + private static final String BUNDLE_NAME= JavaCodeMiningMessages.class.getName(); + + + private JavaCodeMiningMessages() { + // Do not instantiate + } + + public static String JavaReferenceCodeMining_label; + + public static String JavaImplementationCodeMining_label; + + static { + NLS.initializeMessages(BUNDLE_NAME, JavaCodeMiningMessages.class); + } + +} diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.properties eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.properties --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.properties 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaCodeMiningMessages.properties 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,16 @@ +############################################################################### +# Copyright (c) 2018 Angelo ZERR. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Angelo Zerr - [code mining] 0 reference / implementation - Bug 541396 +############################################################################### + +JavaReferenceCodeMining_label={0,choice,0#0 references|1#1 reference|1<{0} references} +JavaImplementationCodeMining_label={0,choice,0#0 implementations|1#1 implementation|1<{0} implementations} \ No newline at end of file diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaElementCodeMiningProvider.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaElementCodeMiningProvider.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaElementCodeMiningProvider.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaElementCodeMiningProvider.java 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2018 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - [CodeMining] Provide Java References/Implementation CodeMinings - Bug 529127 + */ +package org.eclipse.jdt.internal.ui.javaeditor.codemining; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.codemining.AbstractCodeMiningProvider; +import org.eclipse.jface.text.codemining.ICodeMining; + +import org.eclipse.ui.texteditor.ITextEditor; + +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ITypeRoot; +import org.eclipse.jdt.core.JavaModelException; + +import org.eclipse.jdt.ui.PreferenceConstants; + +import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; +import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; +import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesPropertyTester; + +/** + * Java code mining provider to show code minings by using {@link IJavaElement}: + * + *
    + *
  • Show references
  • + *
  • Show implementations
  • + *
+ * + * @since 3.16 + */ +public class JavaElementCodeMiningProvider extends AbstractCodeMiningProvider { + + private final boolean showAtLeastOne; + + private final boolean showReferences; + + private final boolean showReferencesOnTypes; + + private final boolean showReferencesOnFields; + + private final boolean showReferencesOnMethods; + + private final boolean showImplementations; + + private final boolean editorEnabled; + + public JavaElementCodeMiningProvider() { + editorEnabled= JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_CODEMINING_ENABLED); + showAtLeastOne= editorEnabled && JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_CODEMINING_AT_LEAST_ONE); + showReferences= editorEnabled && JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES); + showReferencesOnTypes= editorEnabled && JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES_ON_TYPES); + showReferencesOnFields= editorEnabled && JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES_ON_FIELDS); + showReferencesOnMethods= editorEnabled && JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES_ON_METHODS); + showImplementations= editorEnabled && JavaPreferencesPropertyTester.isEnabled(PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_IMPLEMENTATIONS); + } + + @Override + public CompletableFuture> provideCodeMinings(ITextViewer viewer, + IProgressMonitor monitor) { + if (!editorEnabled) { + return CompletableFuture.completedFuture(Collections.emptyList()); + } + return CompletableFuture.supplyAsync(() -> { + monitor.isCanceled(); + ITextEditor textEditor= super.getAdapter(ITextEditor.class); + ITypeRoot unit= EditorUtility.getEditorInputJavaElement(textEditor, true); + if (unit == null) { + return Collections.emptyList(); + } + try { + IJavaElement[] elements= unit.getChildren(); + List minings= new ArrayList<>(elements.length); + collectMinings(unit, textEditor, unit.getChildren(), minings, viewer, monitor); + monitor.isCanceled(); + return minings; + } catch (JavaModelException e) { + // Should never occur + } + return Collections.emptyList(); + }); + } + + /** + * Collect java code minings. + * + * @param unit the compilation unit + * @param textEditor the Java editor + * @param elements the java elements to track + * @param minings the current list of minings to update + * @param viewer the viewer + * @param monitor the monitor + * @throws JavaModelException thrown when java model error + */ + private void collectMinings(ITypeRoot unit, ITextEditor textEditor, IJavaElement[] elements, + List minings, ITextViewer viewer, IProgressMonitor monitor) throws JavaModelException { + + // Only Java editor is supported, see bug 541811 + if(!(textEditor instanceof JavaEditor)) { + return; + } + + // Don't worth to loop if none of mining types are requested + if (!(showReferences || showImplementations)) { + return; + } + + for (IJavaElement element : elements) { + if (monitor.isCanceled()) { + return; + } + if (element.getElementType() == IJavaElement.TYPE) { + collectMinings(unit, textEditor, ((IType) element).getChildren(), minings, viewer, monitor); + } else if (!(element.getElementType() == IJavaElement.METHOD || element.getElementType() == IJavaElement.FIELD)) { + continue; + } + if (showReferences) { + try { + if ((showReferencesOnTypes && (element.getElementType() == IJavaElement.TYPE)) // Show references on types + || (showReferencesOnMethods && (element.getElementType() == IJavaElement.METHOD)) // Show references on methods + || (showReferencesOnFields && (element.getElementType() == IJavaElement.FIELD)) // Show references on fields + ) { + minings.add(new JavaReferenceCodeMining(element, (JavaEditor) textEditor, viewer.getDocument(), + this, showAtLeastOne)); + } + } catch (BadLocationException e) { + // Should never occur + } + } + if (showImplementations) { + if (element instanceof IType) { + IType type= (IType) element; + if (type.isInterface() || type.isClass()) { + try { + minings.add(new JavaImplementationCodeMining(type, (JavaEditor) textEditor, viewer.getDocument(), this, + showAtLeastOne)); + } catch (BadLocationException e) { + // Should never occur + } + } + } + } + } + } +} diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaImplementationCodeMining.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaImplementationCodeMining.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaImplementationCodeMining.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaImplementationCodeMining.java 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2018 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - [CodeMining] Provide Java References/Implementation CodeMinings - Bug 529127 + */ +package org.eclipse.jdt.internal.ui.javaeditor.codemining; + +import java.text.MessageFormat; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import java.util.stream.Stream; + +import org.eclipse.swt.events.MouseEvent; + +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.jface.viewers.StructuredSelection; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.codemining.ICodeMiningProvider; + +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaModelException; + +import org.eclipse.jdt.ui.actions.OpenTypeHierarchyAction; + +import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; + +/** + * Java implementation code mining. + * + * @since 3.16 + */ +public class JavaImplementationCodeMining extends AbstractJavaElementLineHeaderCodeMining { + + private final JavaEditor editor; + + private final boolean showImplementationsAtLeastOne; + + private Consumer action; + + public JavaImplementationCodeMining(IType element, JavaEditor editor, IDocument document, ICodeMiningProvider provider, + boolean showImplementationsAtLeastOne) throws JavaModelException, BadLocationException { + super(element, document, provider, null); + this.editor= editor; + this.showImplementationsAtLeastOne= showImplementationsAtLeastOne; + } + + @SuppressWarnings("boxing") + @Override + protected CompletableFuture doResolve(ITextViewer viewer, IProgressMonitor monitor) { + return CompletableFuture.runAsync(() -> { + try { + IJavaElement element= super.getElement(); + long implCount= countImplementations((IType) element, monitor); + action= implCount > 0 ? e -> new OpenTypeHierarchyAction(editor).run(new StructuredSelection(element)) : null; + if (implCount == 0 && showImplementationsAtLeastOne) { + super.setLabel(""); //$NON-NLS-1$ + } else { + super.setLabel(MessageFormat.format(JavaCodeMiningMessages.JavaImplementationCodeMining_label, implCount)); + } + } catch (JavaModelException e) { + // Should never occur + } + }); + } + + @Override + public Consumer getAction() { + return action; + } + + /** + * Return the count of implementation for the given java element type. + * + * @param type the java element type. + * @param monitor the monitor + * @return the count of implementation for the given java element type. + * @throws JavaModelException throws when Java error + */ + private static long countImplementations(IType type, IProgressMonitor monitor) throws JavaModelException { + IType[] results= type.newTypeHierarchy(monitor).getAllSubtypes(type); + return Stream.of(results).filter(t -> t.getAncestor(IJavaElement.COMPILATION_UNIT) != null).count(); + } + +} diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaReferenceCodeMining.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaReferenceCodeMining.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaReferenceCodeMining.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/JavaReferenceCodeMining.java 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,142 @@ +/** + * Copyright (c) 2018 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - [CodeMining] Provide Java References/Implementation CodeMinings - Bug 529127 + */ +package org.eclipse.jdt.internal.ui.javaeditor.codemining; + +import java.text.MessageFormat; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Consumer; + +import org.eclipse.swt.events.MouseEvent; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.codemining.ICodeMiningProvider; + +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.search.IJavaSearchConstants; +import org.eclipse.jdt.core.search.IJavaSearchScope; +import org.eclipse.jdt.core.search.SearchEngine; +import org.eclipse.jdt.core.search.SearchMatch; +import org.eclipse.jdt.core.search.SearchParticipant; +import org.eclipse.jdt.core.search.SearchPattern; +import org.eclipse.jdt.core.search.SearchRequestor; + +import org.eclipse.jdt.ui.actions.FindReferencesAction; + +import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; +import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; + +/** + * Java reference code mining. + * + * @since 3.16 + */ +public class JavaReferenceCodeMining extends AbstractJavaElementLineHeaderCodeMining { + + private final JavaEditor editor; + + private final boolean showReferencesAtLeastOne; + + private Consumer action; + + public JavaReferenceCodeMining(IJavaElement element, JavaEditor editor, IDocument document, + ICodeMiningProvider provider, boolean showReferencesAtLeastOne) + throws JavaModelException, BadLocationException { + super(element, document, provider, null); + this.editor= editor; + this.showReferencesAtLeastOne= showReferencesAtLeastOne; + } + + @SuppressWarnings("boxing") + @Override + protected CompletableFuture doResolve(ITextViewer viewer, IProgressMonitor monitor) { + return CompletableFuture.runAsync(() -> { + try { + monitor.isCanceled(); + IJavaElement element = super.getElement(); + long refCount= countReferences(element, monitor); + monitor.isCanceled(); + action= refCount > 0 ? e -> new FindReferencesAction(editor).run(element) : null; + if (refCount == 0 && showReferencesAtLeastOne) { + super.setLabel(""); //$NON-NLS-1$ + } else { + super.setLabel(MessageFormat.format(JavaCodeMiningMessages.JavaReferenceCodeMining_label, refCount)); + } + } catch (JavaModelException e) { + // Should never occur + } catch (CoreException e) { + // Should never occur + } + }); + } + + @Override + public Consumer getAction() { + return action; + } + + /** + * Return the number of references for the given java element. + * + * @param element the java element. + * @param monitor the monitor + * @return he number of references for the given java element. + * @throws JavaModelException throws when java error. + * @throws CoreException throws when java error. + */ + private static long countReferences(IJavaElement element, IProgressMonitor monitor) + throws JavaModelException, CoreException { + if (element == null) { + return 0; + } + final AtomicLong count= new AtomicLong(0); + SearchPattern pattern= SearchPattern.createPattern(element, IJavaSearchConstants.REFERENCES); + SearchEngine engine= new SearchEngine(); + engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, + createSearchScope(element), new SearchRequestor() { + + @Override + public void acceptSearchMatch(SearchMatch match) throws CoreException { + Object o= match.getElement(); + if (o instanceof IJavaElement) { + IJavaElement e= (IJavaElement)o; + if (e.getAncestor(IJavaElement.COMPILATION_UNIT) != null + || e.getAncestor(IJavaElement.CLASS_FILE) != null) { + count.incrementAndGet(); + } + } + } + }, monitor); + + return count.get(); + } + + /** + * Create Java workspace scope. + * + * @param element IJavaElement to search references for + * + * @return the Java workspace scope. + * @throws JavaModelException when java error. + */ + private static IJavaSearchScope createSearchScope(IJavaElement element) throws JavaModelException { + JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); + boolean isInsideJRE = factory.isInsideJRE(element); + IJavaSearchScope scope= factory.createWorkspaceScope(isInsideJRE); + return scope; + } +} diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningManager.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningManager.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningManager.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningManager.java 2018-12-03 12:49:27.000000000 +0000 @@ -58,8 +58,12 @@ */ private void enable() { if (fEditor != null) { - fReconciler= new JavaCodeMiningReconciler(); - fReconciler.install(fEditor, fSourceViewer); + if (fReconciler != null) { + fReconciler.updateCodeMinings(); + } else { + fReconciler= new JavaCodeMiningReconciler(); + fReconciler.install(fEditor, fSourceViewer); + } } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningReconciler.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningReconciler.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningReconciler.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaCodeMiningReconciler.java 2018-12-03 12:49:27.000000000 +0000 @@ -16,7 +16,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.ISourceViewerExtension5; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -45,8 +44,8 @@ /** * Install this reconciler on the given editor. - * - * @param editor the editor + * + * @param editor the editor * @param sourceViewer the source viewer */ public void install(JavaEditor editor, ISourceViewer sourceViewer) { @@ -55,8 +54,8 @@ if (fEditor instanceof CompilationUnitEditor) { ((CompilationUnitEditor) fEditor).addReconcileListener(this); - updateCodeMinings(); } + updateCodeMinings(); } /** @@ -73,9 +72,9 @@ /** * Update Java code mining in the Java editor. */ - private void updateCodeMinings() { - if (fSourceViewer instanceof ISourceViewerExtension5) { - ((ISourceViewerExtension5) fSourceViewer).updateCodeMinings(); + void updateCodeMinings() { + if (fSourceViewer instanceof JavaSourceViewer) { + ((JavaSourceViewer) fSourceViewer).doUpdateCodeMinings(); } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 2018-12-03 12:49:27.000000000 +0000 @@ -189,6 +189,7 @@ import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.NodeFinder; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.core.util.IModifierConstants; import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder; @@ -199,7 +200,6 @@ import org.eclipse.jdt.ui.IContextMenuConstants; import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jdt.ui.PreferenceConstants; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; @@ -1219,7 +1219,7 @@ if (inputJavaElement != null) { IProgressMonitor monitor = getProgressMonitor(); try { - updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, SharedASTProvider.getAST(inputJavaElement, SharedASTProvider.WAIT_NO, monitor)); + updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, SharedASTProviderCore.getAST(inputJavaElement, SharedASTProviderCore.WAIT_NO, monitor)); } finally { monitor.done(); } @@ -2426,7 +2426,7 @@ IProgressMonitor monitor = getProgressMonitor(); CompilationUnit ast; try { - ast= SharedASTProvider.getAST(inputJavaElement, SharedASTProvider.WAIT_NO /* DO NOT USE WAIT_ACTIVE_ONLY */ , monitor); + ast= SharedASTProviderCore.getAST(inputJavaElement, SharedASTProviderCore.WAIT_NO /* DO NOT USE WAIT_ACTIVE_ONLY */ , monitor); } finally { monitor.done(); } @@ -2948,6 +2948,8 @@ } if (affectsJavaCodeMining(event)) { + // It's a code mining preference, recompute the list of code mining providers. + installCodeMiningProviders(); if (isJavaCodeMiningEnabled()) { installJavaCodeMining(); } else { @@ -3402,7 +3404,7 @@ if (inputJavaElement != null) { IProgressMonitor monitor = getProgressMonitor(); try { - updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, SharedASTProvider.getAST(inputJavaElement, SharedASTProvider.WAIT_NO, monitor)); + updateOccurrenceAnnotations((ITextSelection)fForcedMarkOccurrencesSelection, SharedASTProviderCore.getAST(inputJavaElement, SharedASTProviderCore.WAIT_NO, monitor)); } finally { monitor.done(); } @@ -3528,7 +3530,7 @@ IProgressMonitor monitor = getProgressMonitor(); try { SubMonitor subMonitor= SubMonitor.convert(monitor, 2); - CompilationUnit ast= SharedASTProvider.getAST(inputElement, SharedASTProvider.WAIT_ACTIVE_ONLY, + CompilationUnit ast= SharedASTProviderCore.getAST(inputElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); fOverrideIndicatorManager.reconciled(ast, true, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE)); } finally { @@ -4284,6 +4286,15 @@ } } + @Override + protected void installCodeMiningProviders() { + if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CODEMINING_ENABLED)) { + super.installCodeMiningProviders(); + } else { + ((JavaSourceViewer) getSourceViewer()).resetCodeMinings(); + } + } + /** * Install Java code mining. * @@ -4314,6 +4325,9 @@ * @since 3.14 */ boolean isJavaCodeMiningEnabled() { + if (!JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CODEMINING_ENABLED)) { + return false; + } // check if there is a registered Java code mining. ISourceViewer viewer= getViewer(); if (viewer instanceof ISourceViewerExtension5) { @@ -4330,12 +4344,7 @@ * @since 3.14 */ protected boolean affectsJavaCodeMining(PropertyChangeEvent event) { - boolean isJavaCodeMiningPreference= isJavaCodeMiningPreference(event.getProperty()); - if (isJavaCodeMiningPreference) { - // It's a code mining preference, recompute the list of code mining providers. - installCodeMiningProviders(); - } - return isJavaCodeMiningPreference; + return isJavaCodeMiningPreference(event.getProperty()); } /** @@ -4351,7 +4360,7 @@ * @since 3.14 */ private boolean isJavaCodeMiningPreference(String property) { - return property.startsWith(PreferenceConstants.EDITOR_JAVA_CODEMINING_PREFIX); + return PreferenceConstants.EDITOR_CODEMINING_ENABLED.equals(property) || property.startsWith(PreferenceConstants.EDITOR_JAVA_CODEMINING_PREFIX); } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java 2018-12-03 12:49:27.000000000 +0000 @@ -43,6 +43,7 @@ import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; import org.eclipse.jdt.core.dom.SwitchCase; import org.eclipse.jdt.core.dom.SwitchStatement; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder.OccurrenceLocation; import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; @@ -50,7 +51,6 @@ import org.eclipse.jdt.internal.corext.util.CollectionsUtil; import org.eclipse.jdt.internal.corext.util.Messages; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.ui.actions.SelectionDispatchAction; import org.eclipse.jdt.internal.ui.search.BreakContinueTargetFinder; @@ -214,7 +214,7 @@ * @since 3.7 */ public static OccurrenceLocation findBreakOrContinueTarget(ITypeRoot input, IRegion region) { - CompilationUnit astRoot= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_NO, null); + CompilationUnit astRoot= SharedASTProviderCore.getAST(input, SharedASTProviderCore.WAIT_NO, null); if (astRoot == null) return null; @@ -255,7 +255,7 @@ * @since 3.14 */ public static OccurrenceLocation findSwitchCaseTarget(ITypeRoot input, IRegion region) { - CompilationUnit astRoot= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_NO, null); + CompilationUnit astRoot= SharedASTProviderCore.getAST(input, SharedASTProviderCore.WAIT_NO, null); if (astRoot == null) { return null; } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementImplementationHyperlink.java 2018-12-03 12:49:27.000000000 +0000 @@ -54,6 +54,7 @@ import org.eclipse.jdt.core.dom.NodeFinder; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.SuperMethodInvocation; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; @@ -68,7 +69,6 @@ import org.eclipse.jdt.internal.corext.util.MethodOverrideTester; import org.eclipse.jdt.ui.JavaElementLabels; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.ui.actions.SelectionDispatchAction; import org.eclipse.jdt.internal.ui.JavaPlugin; @@ -178,7 +178,7 @@ } ITypeRoot editorInput= EditorUtility.getEditorInputJavaElement(editor, false); - CompilationUnit ast= SharedASTProvider.getAST(editorInput, SharedASTProvider.WAIT_ACTIVE_ONLY, null); + CompilationUnit ast= SharedASTProviderCore.getAST(editorInput, SharedASTProviderCore.WAIT_ACTIVE_ONLY, null); if (ast == null) { openQuickHierarchy(editor); return; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java 2018-12-03 12:49:27.000000000 +0000 @@ -715,4 +715,31 @@ return null; } + @Override + public void updateCodeMinings() { + // Here we disable this method which is called by AbstractTextEditor#installCodeMiningProviders which updates code mining (draw minings in the UI) + // In JDT code mining case, the update code mining must be done when ICompilationUnit is reconciled (and not when editor is opened). + // The update code mining is done by JavaCodeMiningReconciler which calls doUpdateCodeMinings: + // - on install + // - when compilation unit is reconciled + } + + /** + * Update java code minings. + * + * @since 3.16 + */ + void doUpdateCodeMinings() { + super.updateCodeMinings(); + } + + /** + * Reset the registered code mining providers. + * + * @since 3.16 + */ + void resetCodeMinings() { + super.setCodeMiningProviders(null); + doUpdateCodeMinings(); + } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTemplatesPage.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTemplatesPage.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTemplatesPage.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTemplatesPage.java 2018-12-03 12:49:27.000000000 +0000 @@ -44,6 +44,7 @@ import org.eclipse.ui.texteditor.templates.AbstractTemplatesPage; import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.internal.corext.template.java.CompilationUnitContextType; import org.eclipse.jdt.internal.corext.template.java.JavaContext; @@ -51,6 +52,7 @@ import org.eclipse.jdt.internal.corext.template.java.JavaDocContext; import org.eclipse.jdt.internal.corext.template.java.JavaDocContextType; import org.eclipse.jdt.internal.corext.template.java.SWTContextType; +import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.text.IJavaPartitions; @@ -344,6 +346,10 @@ String[] ids= new String[] { JavaContextType.ID_ALL, JavaContextType.ID_MEMBERS, JavaContextType.ID_STATEMENTS, SWTContextType.ID_ALL, SWTContextType.ID_STATEMENTS, SWTContextType.ID_MEMBERS}; if (partition.equals(IJavaPartitions.JAVA_DOC)) ids= new String[] { JavaDocContextType.ID }; + IJavaElement elem= EditorUtility.getEditorInputJavaElement(fJavaEditor, true); + if (elem != null && JavaModelUtil.MODULE_INFO_JAVA.equals(elem.getElementName())) { + ids= new String[] { JavaContextType.ID_MODULE }; + } return ids; } catch (BadLocationException e) { return new String[0]; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTextSelection.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTextSelection.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTextSelection.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaTextSelection.java 2018-12-03 12:49:27.000000000 +0000 @@ -27,12 +27,11 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.VariableDeclarationFragment; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.corext.dom.Selection; import org.eclipse.jdt.internal.corext.dom.SelectionAnalyzer; -import org.eclipse.jdt.ui.SharedASTProvider; - import org.eclipse.jdt.internal.ui.actions.SelectionConverter; /** @@ -119,7 +118,7 @@ return fPartialAST; fPartialASTRequested= true; // long start= System.currentTimeMillis(); - fPartialAST= SharedASTProvider.getAST(fElement, SharedASTProvider.WAIT_YES, null); + fPartialAST= SharedASTProviderCore.getAST(fElement, SharedASTProviderCore.WAIT_YES, null); // System.out.println("Time requesting partial AST: " + (System.currentTimeMillis() - start)); return fPartialAST; } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlinkDetector.java 2018-12-03 12:49:27.000000000 +0000 @@ -31,12 +31,12 @@ import org.eclipse.jdt.core.dom.QualifiedName; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.StringLiteral; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.corext.refactoring.nls.AccessorClassReference; import org.eclipse.jdt.internal.corext.refactoring.nls.NLSHintHelper; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.SharedASTProvider; @@ -65,7 +65,7 @@ if (javaElement == null) return null; - CompilationUnit ast= SharedASTProvider.getAST(javaElement, SharedASTProvider.WAIT_NO, null); + CompilationUnit ast= SharedASTProviderCore.getAST(javaElement, SharedASTProviderCore.WAIT_NO, null); if (ast == null) return null; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/OverrideIndicatorManager.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/OverrideIndicatorManager.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/OverrideIndicatorManager.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/OverrideIndicatorManager.java 2018-12-03 12:49:27.000000000 +0000 @@ -41,18 +41,18 @@ import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.SimpleName; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.dom.Bindings; import org.eclipse.jdt.internal.corext.util.JdtFlags; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jdt.ui.SharedASTProvider; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; /** * Manages the override and overwrite indicators for @@ -100,7 +100,7 @@ * Opens and reveals the defining method. */ public void open() { - CompilationUnit ast= SharedASTProvider.getAST(fJavaElement, SharedASTProvider.WAIT_ACTIVE_ONLY, null); + CompilationUnit ast= SharedASTProviderCore.getAST(fJavaElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, null); if (ast != null) { ASTNode node= ast.findDeclaringNode(fAstNodeKey); if (node instanceof MethodDeclaration) { diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/selectionactions/StructureSelectionAction.java 2018-12-03 12:49:27.000000000 +0000 @@ -32,13 +32,12 @@ import org.eclipse.jdt.core.dom.ChildListPropertyDescriptor; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.corext.dom.ASTNodes; import org.eclipse.jdt.internal.corext.dom.Selection; import org.eclipse.jdt.internal.corext.dom.SelectionAnalyzer; -import org.eclipse.jdt.ui.SharedASTProvider; - import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; @@ -155,7 +154,7 @@ } private static CompilationUnit getAST(ITypeRoot sr) { - return SharedASTProvider.getAST(sr, SharedASTProvider.WAIT_YES, null); + return SharedASTProviderCore.getAST(sr, SharedASTProviderCore.WAIT_YES, null); } //-- helper methods for this class and subclasses diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlighting.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlighting.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlighting.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlighting.java 2018-12-03 12:49:27.000000000 +0000 @@ -25,7 +25,7 @@ /** * Semantic highlighting */ -public abstract class SemanticHighlighting { +public abstract class SemanticHighlighting extends SemanticHighlightingCore { /** * @return the preference key, will be augmented by a prefix and a suffix for each preference @@ -76,41 +76,6 @@ */ public abstract boolean isEnabledByDefault(); - /** - * @return the display name - */ - public abstract String getDisplayName(); - - /** - * Returns true iff the semantic highlighting consumes the semantic token. - *

- * NOTE: Implementors are not allowed to keep a reference on the token or on any object - * retrieved from the token. - *

- * - * @param token the semantic token for a {@link org.eclipse.jdt.core.dom.SimpleName} - * @return true iff the semantic highlighting consumes the semantic token - */ - public abstract boolean consumes(SemanticToken token); - - /** - * Returns true iff the semantic highlighting consumes the - * semantic token. - *

- * NOTE: Implementors are not allowed to keep a reference on the token or on - * any object retrieved from the token. - *

- * @param token the semantic token for a - * {@link org.eclipse.jdt.core.dom.NumberLiteral}, - * {@link org.eclipse.jdt.core.dom.BooleanLiteral} or - * {@link org.eclipse.jdt.core.dom.CharacterLiteral} - * @return true iff the semantic highlighting consumes the - * semantic token - */ - public boolean consumesLiteral(SemanticToken token) { - return false; - } - private String getThemeColorKey() { return JavaUI.ID_PLUGIN + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$ } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingManager.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingManager.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingManager.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingManager.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Inc. - use HighlightedPositionCore *******************************************************************************/ package org.eclipse.jdt.internal.ui.javaeditor; @@ -28,7 +29,6 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextAttribute; @@ -97,13 +97,7 @@ /** * Highlighted Positions. */ - static class HighlightedPosition extends Position { - - /** Highlighting of the position */ - private Highlighting fStyle; - - /** Lock object */ - private Object fLock; + static class HighlightedPosition extends HighlightedPositionCore { /** * Initialize the styled positions with the given offset, length and foreground color. @@ -114,9 +108,7 @@ * @param lock The lock object */ public HighlightedPosition(int offset, int length, Highlighting highlighting, Object lock) { - super(offset, length); - fStyle= highlighting; - fLock= lock; + super(offset, length, highlighting, lock); } /** @@ -124,10 +116,10 @@ */ public StyleRange createStyleRange() { int len= 0; - if (fStyle.isEnabled()) + if (getHighlighting().isEnabled()) len= getLength(); - TextAttribute textAttribute= fStyle.getTextAttribute(); + TextAttribute textAttribute= getHighlighting().getTextAttribute(); int style= textAttribute.getStyle(); int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange styleRange= new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle); @@ -146,9 +138,7 @@ * @return true iff the given offset, length and highlighting are equal to the internal ones. */ public boolean isEqual(int off, int len, Highlighting highlighting) { - synchronized (fLock) { - return !isDeleted() && getOffset() == off && getLength() == len && fStyle == highlighting; - } + return super.isEqual(off, len, highlighting); } /** @@ -158,17 +148,14 @@ * @param len The range length * @return true iff this position is not delete and contained in the given range. */ + @Override public boolean isContained(int off, int len) { - synchronized (fLock) { - return !isDeleted() && off <= getOffset() && off + len >= getOffset() + getLength(); - } + return super.isContained(off, len); } + @Override public void update(int off, int len) { - synchronized (fLock) { - super.setOffset(off); - super.setLength(len); - } + super.update(off, len); } /* @@ -176,9 +163,7 @@ */ @Override public void setLength(int length) { - synchronized (fLock) { - super.setLength(length); - } + super.setLength(length); } /* @@ -186,9 +171,7 @@ */ @Override public void setOffset(int offset) { - synchronized (fLock) { - super.setOffset(offset); - } + super.setOffset(offset); } /* @@ -196,9 +179,7 @@ */ @Override public void delete() { - synchronized (fLock) { - super.delete(); - } + super.delete(); } /* @@ -206,16 +187,15 @@ */ @Override public void undelete() { - synchronized (fLock) { - super.undelete(); - } + super.undelete(); } /** * @return Returns the highlighting. */ + @Override public Highlighting getHighlighting() { - return fStyle; + return (Highlighting)super.getHighlighting(); } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java 2018-12-03 12:49:27.000000000 +0000 @@ -25,7 +25,6 @@ import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.IPositionUpdater; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ISynchronizable; import org.eclipse.jface.text.ITextInputListener; @@ -45,206 +44,14 @@ * * @since 3.0 */ -public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener { - - /** - * Semantic highlighting position updater. - */ - private class HighlightingPositionUpdater implements IPositionUpdater { - - /** The position category. */ - private final String fCategory; - - /** - * Creates a new updater for the given category. - * - * @param category the new category. - */ - public HighlightingPositionUpdater(String category) { - fCategory= category; - } - - /* - * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent) - */ - @Override - public void update(DocumentEvent event) { - - int eventOffset= event.getOffset(); - int eventOldLength= event.getLength(); - int eventEnd= eventOffset + eventOldLength; - - try { - Position[] positions= event.getDocument().getPositions(fCategory); - - for (int i= 0; i != positions.length; i++) { - - HighlightedPosition position= (HighlightedPosition) positions[i]; - - // Also update deleted positions because they get deleted by the background thread and removed/invalidated only in the UI runnable -// if (position.isDeleted()) -// continue; - - int offset= position.getOffset(); - int length= position.getLength(); - int end= offset + length; - - if (offset > eventEnd) - updateWithPrecedingEvent(position, event); - else if (end < eventOffset) - updateWithSucceedingEvent(position, event); - else if (offset <= eventOffset && end >= eventEnd) - updateWithIncludedEvent(position, event); - else if (offset <= eventOffset) - updateWithOverEndEvent(position, event); - else if (end >= eventEnd) - updateWithOverStartEvent(position, event); - else - updateWithIncludingEvent(position, event); - } - } catch (BadPositionCategoryException e) { - // ignore and return - } - } - - /** - * Update the given position with the given event. The event precedes the position. - * - * @param position The position - * @param event The event - */ - private void updateWithPrecedingEvent(HighlightedPosition position, DocumentEvent event) { - String newText= event.getText(); - int eventNewLength= newText != null ? newText.length() : 0; - int deltaLength= eventNewLength - event.getLength(); - - position.setOffset(position.getOffset() + deltaLength); - } - - /** - * Update the given position with the given event. The event succeeds the position. - * - * @param position The position - * @param event The event - */ - private void updateWithSucceedingEvent(HighlightedPosition position, DocumentEvent event) { - } - - /** - * Update the given position with the given event. The event is included by the position. - * - * @param position The position - * @param event The event - */ - private void updateWithIncludedEvent(HighlightedPosition position, DocumentEvent event) { - int eventOffset= event.getOffset(); - String newText= event.getText(); - if (newText == null) - newText= ""; //$NON-NLS-1$ - int eventNewLength= newText.length(); - - int deltaLength= eventNewLength - event.getLength(); - - int offset= position.getOffset(); - int length= position.getLength(); - int end= offset + length; - - int includedLength= 0; - while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength))) - includedLength++; - if (includedLength == eventNewLength) - position.setLength(length + deltaLength); - else { - int newLeftLength= eventOffset - offset + includedLength; - - int excludedLength= eventNewLength; - while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1))) - excludedLength--; - int newRightOffset= eventOffset + excludedLength; - int newRightLength= end + deltaLength - newRightOffset; - - if (newRightLength == 0) { - position.setLength(newLeftLength); - } else { - if (newLeftLength == 0) { - position.update(newRightOffset, newRightLength); - } else { - position.setLength(newLeftLength); - addPositionFromUI(newRightOffset, newRightLength, position.getHighlighting()); - } - } - } - } - - /** - * Update the given position with the given event. The event overlaps with the end of the position. - * - * @param position The position - * @param event The event - */ - private void updateWithOverEndEvent(HighlightedPosition position, DocumentEvent event) { - String newText= event.getText(); - if (newText == null) - newText= ""; //$NON-NLS-1$ - int eventNewLength= newText.length(); - - int includedLength= 0; - while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength))) - includedLength++; - position.setLength(event.getOffset() - position.getOffset() + includedLength); - } - - /** - * Update the given position with the given event. The event overlaps with the start of the position. - * - * @param position The position - * @param event The event - */ - private void updateWithOverStartEvent(HighlightedPosition position, DocumentEvent event) { - int eventOffset= event.getOffset(); - int eventEnd= eventOffset + event.getLength(); - - String newText= event.getText(); - if (newText == null) - newText= ""; //$NON-NLS-1$ - int eventNewLength= newText.length(); - - int excludedLength= eventNewLength; - while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1))) - excludedLength--; - int deleted= eventEnd - position.getOffset(); - int inserted= eventNewLength - excludedLength; - position.update(eventOffset + excludedLength, position.getLength() - deleted + inserted); - } - - /** - * Update the given position with the given event. The event includes the position. - * - * @param position The position - * @param event The event - */ - private void updateWithIncludingEvent(HighlightedPosition position, DocumentEvent event) { - position.delete(); - position.update(event.getOffset(), 0); - } - } - - /** Position updater */ - private IPositionUpdater fPositionUpdater= new HighlightingPositionUpdater(getPositionCategory()); +public class SemanticHighlightingPresenter extends SemanticHighlightingPresenterCore + implements ITextPresentationListener, ITextInputListener, IDocumentListener { /** The source viewer this semantic highlighting reconciler is installed on */ private JavaSourceViewer fSourceViewer; /** The background presentation reconciler */ private JavaPresentationReconciler fPresentationReconciler; - /** UI's current highlighted positions - can contain null elements */ - private List fPositions= new ArrayList<>(); - /** UI position lock */ - private Object fPositionLock= new Object(); - - /** true iff the current reconcile is canceled. */ - private boolean fIsCanceled= false; - /** * Creates and returns a new highlighted position with the given offset, length and highlighting. *

@@ -261,20 +68,15 @@ return new HighlightedPosition(offset, length, highlighting, fPositionUpdater); } - /** - * Adds all current positions to the given list. - *

- * NOTE: Called from background thread. - *

- * - * @param list The list + /* + * @see org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingPresenterCore#addPositionForEvent() */ - public void addAllPositions(List list) { - synchronized (fPositionLock) { - list.addAll(fPositions); - } + @Override + protected void addPositionForEvent(DocumentEvent event, String category, int offset, int length, Object highlighting) { + addPositionFromUI(offset, length, (Highlighting)highlighting); } + /** * Create a text presentation in the background. *

@@ -465,33 +267,6 @@ // } /** - * Returns true iff the positions contain the position. - * @param positions the positions, must be ordered by offset but may overlap - * @param position the position - * @return true iff the positions contain the position - */ - private boolean contain(List positions, Position position) { - return indexOf(positions, position) != -1; - } - - /** - * Returns index of the position in the positions, -1 if not found. - * @param positions the positions, must be ordered by offset but may overlap - * @param position the position - * @return the index - */ - private int indexOf(List positions, Position position) { - int index= computeIndexAtOffset(positions, position.getOffset()); - int size= positions.size(); - while (index < size) { - if (positions.get(index) == position) - return index; - index++; - } - return -1; - } - - /** * Insert the given position in fPositions, s.t. the offsets remain in linear order. * * @param position The position for insertion @@ -522,27 +297,6 @@ return j; } - /** - * Returns the index of the first position with an offset equal or greater than the given offset. - * - * @param positions the positions, must be ordered by offset and must not overlap - * @param offset the offset - * @return the index of the last position with an offset equal or greater than the given offset - */ - private int computeIndexAtOffset(List positions, int offset) { - int i= -1; - int j= positions.size(); - while (j - i > 1) { - int k= (i + j) >> 1; - Position position= positions.get(k); - if (position.getOffset() >= offset) - j= k; - else - i= k; - } - return j; - } - /* * @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation) */ @@ -608,6 +362,7 @@ * NOTE: Also called from background thread. *

*/ + @Override public boolean isCanceled() { IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null; if (document == null) @@ -623,6 +378,7 @@ * * @param isCanceled true iff the current reconcile is canceled */ + @Override public void setCanceled(boolean isCanceled) { IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null; if (document == null) { @@ -779,7 +535,8 @@ /** * @return The semantic reconciler position's category. */ - private String getPositionCategory() { + @Override + public String getPositionCategory() { return toString(); } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java 2018-12-03 12:49:27.000000000 +0000 @@ -36,20 +36,14 @@ import org.eclipse.jdt.core.ITypeRoot; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.BooleanLiteral; -import org.eclipse.jdt.core.dom.CharacterLiteral; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.ConstructorInvocation; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.IMethodBinding; -import org.eclipse.jdt.core.dom.NumberLiteral; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.SimpleType; import org.eclipse.jdt.core.dom.SuperConstructorInvocation; - -import org.eclipse.jdt.internal.corext.dom.GenericVisitor; - -import org.eclipse.jdt.ui.SharedASTProvider; +import org.eclipse.jdt.core.manipulation.SharedASTProviderCore; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingManager.HighlightedPosition; @@ -69,48 +63,14 @@ /** * Collects positions from the AST. */ - private class PositionCollector extends GenericVisitor { + private class PositionCollector extends PositionCollectorCore { /** The semantic token */ private SemanticToken fToken= new SemanticToken(); - /* - * @see org.eclipse.jdt.internal.corext.dom.GenericVisitor#visitNode(org.eclipse.jdt.core.dom.ASTNode) - */ - @Override - protected boolean visitNode(ASTNode node) { - if ((node.getFlags() & ASTNode.MALFORMED) == ASTNode.MALFORMED) { - retainPositions(node.getStartPosition(), node.getLength()); - return false; - } - return true; - } - /* - * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.BooleanLiteral) - */ @Override - public boolean visit(BooleanLiteral node) { - return visitLiteral(node); - } - - /* - * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.CharacterLiteral) - */ - @Override - public boolean visit(CharacterLiteral node) { - return visitLiteral(node); - } - - /* - * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.NumberLiteral) - */ - @Override - public boolean visit(NumberLiteral node) { - return visitLiteral(node); - } - - private boolean visitLiteral(Expression node) { + protected boolean visitLiteral(Expression node) { fToken.update(node); for (int i= 0, n= fJobSemanticHighlightings.length; i < n; i++) { SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i]; @@ -234,7 +194,8 @@ * @param offset The range offset * @param length The range length */ - private void retainPositions(int offset, int length) { + @Override + protected void retainPositions(int offset, int length) { // TODO: use binary search for (int i= 0, n= fRemovedPositions.size(); i < n; i++) { HighlightedPosition position= (HighlightedPosition) fRemovedPositions.get(i); @@ -517,7 +478,7 @@ } if (monitor.isCanceled()) return Status.CANCEL_STATUS; - CompilationUnit ast= SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, monitor); + CompilationUnit ast= SharedASTProviderCore.getAST(element, SharedASTProviderCore.WAIT_YES, monitor); reconciled(ast, false, monitor); synchronized (fJobLock) { // allow the job to be gc'ed diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightings.java 2018-12-03 12:49:27.000000000 +0000 @@ -66,69 +66,69 @@ /** * A named preference part that controls the highlighting of static final fields. */ - public static final String STATIC_FINAL_FIELD="staticFinalField"; //$NON-NLS-1$ + public static final String STATIC_FINAL_FIELD= SemanticHighlightingsCore.STATIC_FINAL_FIELD; /** * A named preference part that controls the highlighting of static fields. */ - public static final String STATIC_FIELD="staticField"; //$NON-NLS-1$ + public static final String STATIC_FIELD= SemanticHighlightingsCore.STATIC_FIELD; /** * A named preference part that controls the highlighting of fields. */ - public static final String FIELD="field"; //$NON-NLS-1$ + public static final String FIELD= SemanticHighlightingsCore.FIELD; /** * A named preference part that controls the highlighting of method declarations. */ - public static final String METHOD_DECLARATION="methodDeclarationName"; //$NON-NLS-1$ + public static final String METHOD_DECLARATION= SemanticHighlightingsCore.METHOD_DECLARATION; /** * A named preference part that controls the highlighting of static method invocations. */ - public static final String STATIC_METHOD_INVOCATION="staticMethodInvocation"; //$NON-NLS-1$ + public static final String STATIC_METHOD_INVOCATION= SemanticHighlightingsCore.STATIC_METHOD_INVOCATION; /** * A named preference part that controls the highlighting of inherited method invocations. */ - public static final String INHERITED_METHOD_INVOCATION="inheritedMethodInvocation"; //$NON-NLS-1$ + public static final String INHERITED_METHOD_INVOCATION= SemanticHighlightingsCore.INHERITED_METHOD_INVOCATION; /** * A named preference part that controls the highlighting of annotation element references. * @since 3.1 */ - public static final String ANNOTATION_ELEMENT_REFERENCE="annotationElementReference"; //$NON-NLS-1$ + public static final String ANNOTATION_ELEMENT_REFERENCE= SemanticHighlightingsCore.ANNOTATION_ELEMENT_REFERENCE; /** * A named preference part that controls the highlighting of abstract method invocations. */ - public static final String ABSTRACT_METHOD_INVOCATION="abstractMethodInvocation"; //$NON-NLS-1$ + public static final String ABSTRACT_METHOD_INVOCATION= SemanticHighlightingsCore.ABSTRACT_METHOD_INVOCATION; /** * A named preference part that controls the highlighting of local variables. */ - public static final String LOCAL_VARIABLE_DECLARATION="localVariableDeclaration"; //$NON-NLS-1$ + public static final String LOCAL_VARIABLE_DECLARATION= SemanticHighlightingsCore.LOCAL_VARIABLE_DECLARATION; /** * A named preference part that controls the highlighting of local variables. */ - public static final String LOCAL_VARIABLE="localVariable"; //$NON-NLS-1$ + public static final String LOCAL_VARIABLE= SemanticHighlightingsCore.LOCAL_VARIABLE; /** * A named preference part that controls the highlighting of parameter variables. */ - public static final String PARAMETER_VARIABLE="parameterVariable"; //$NON-NLS-1$ + public static final String PARAMETER_VARIABLE= SemanticHighlightingsCore.PARAMETER_VARIABLE; /** * A named preference part that controls the highlighting of deprecated members. */ - public static final String DEPRECATED_MEMBER="deprecatedMember"; //$NON-NLS-1$ + public static final String DEPRECATED_MEMBER= SemanticHighlightingsCore.DEPRECATED_MEMBER; /** * A named preference part that controls the highlighting of type parameters. * @since 3.1 */ - public static final String TYPE_VARIABLE="typeParameter"; //$NON-NLS-1$ + public static final String TYPE_VARIABLE= SemanticHighlightingsCore.TYPE_VARIABLE; /** * A named preference part that controls the highlighting of methods @@ -136,7 +136,7 @@ * * @since 3.1 */ - public static final String METHOD="method"; //$NON-NLS-1$ + public static final String METHOD= SemanticHighlightingsCore.METHOD; /** * A named preference part that controls the highlighting of auto(un)boxed @@ -144,68 +144,68 @@ * * @since 3.1 */ - public static final String AUTOBOXING="autoboxing"; //$NON-NLS-1$ + public static final String AUTOBOXING= SemanticHighlightingsCore.AUTOBOXING; /** * A named preference part that controls the highlighting of classes. * * @since 3.2 */ - public static final String CLASS="class"; //$NON-NLS-1$ + public static final String CLASS= SemanticHighlightingsCore.CLASS; /** * A named preference part that controls the highlighting of enums. * * @since 3.2 */ - public static final String ENUM="enum"; //$NON-NLS-1$ + public static final String ENUM= SemanticHighlightingsCore.ENUM; /** * A named preference part that controls the highlighting of interfaces. * * @since 3.2 */ - public static final String INTERFACE="interface"; //$NON-NLS-1$ + public static final String INTERFACE= SemanticHighlightingsCore.INTERFACE; /** * A named preference part that controls the highlighting of annotations. * * @since 3.2 */ - public static final String ANNOTATION="annotation"; //$NON-NLS-1$ + public static final String ANNOTATION= SemanticHighlightingsCore.ANNOTATION; /** * A named preference part that controls the highlighting of type arguments. * * @since 3.2 */ - public static final String TYPE_ARGUMENT="typeArgument"; //$NON-NLS-1$ + public static final String TYPE_ARGUMENT= SemanticHighlightingsCore.TYPE_ARGUMENT; /** * A named preference part that controls the highlighting of numbers. * * @since 3.4 */ - public static final String NUMBER="number"; //$NON-NLS-1$ + public static final String NUMBER= SemanticHighlightingsCore.NUMBER; /** * A named preference part that controls the highlighting of abstract classes. * * @since 3.7 */ - public static final String ABSTRACT_CLASS="abstractClass"; //$NON-NLS-1$ + public static final String ABSTRACT_CLASS= SemanticHighlightingsCore.ABSTRACT_CLASS; /** * A named preference part that controls the highlighting of inherited fields. * * @since 3.8 */ - public static final String INHERITED_FIELD="inheritedField"; //$NON-NLS-1$ + public static final String INHERITED_FIELD= SemanticHighlightingsCore.INHERITED_FIELD; /** * A named preference part that controls the highlighting of 'var' keywords. */ - public static final String VAR_KEYWORD= "varKeyword"; //$NON-NLS-1$ + public static final String VAR_KEYWORD= SemanticHighlightingsCore.VAR_KEYWORD; /** * Semantic highlightings diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticToken.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticToken.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticToken.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticToken.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jdt.internal.ui.javaeditor; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.IBinding; -import org.eclipse.jdt.core.dom.SimpleName; - -/** - * Semantic token - */ -public final class SemanticToken { - - /** AST node */ - private SimpleName fNode; - private Expression fLiteral; - - /** Binding */ - private IBinding fBinding; - /** Is the binding resolved? */ - private boolean fIsBindingResolved= false; - - /** AST root */ - private CompilationUnit fRoot; - private boolean fIsRootResolved= false; - - /** - * @return Returns the binding, can be null. - */ - public IBinding getBinding() { - if (!fIsBindingResolved) { - fIsBindingResolved= true; - if (fNode != null) - fBinding= fNode.resolveBinding(); - } - - return fBinding; - } - - /** - * @return the AST node (a {@link SimpleName}) - */ - public SimpleName getNode() { - return fNode; - } - - /** - * @return the AST node (a Boolean-, Character- or NumberLiteral) - */ - public Expression getLiteral() { - return fLiteral; - } - - /** - * @return the AST root - */ - public CompilationUnit getRoot() { - if (!fIsRootResolved) { - fIsRootResolved= true; - fRoot= (CompilationUnit) (fNode != null ? fNode : fLiteral).getRoot(); - } - - return fRoot; - } - - /** - * Update this token with the given AST node. - *

- * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only. - *

- * - * @param node the AST simple name - */ - void update(SimpleName node) { - clear(); - fNode= node; - } - - /** - * Update this token with the given AST node. - *

- * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only. - *

- * - * @param literal the AST literal - */ - void update(Expression literal) { - clear(); - fLiteral= literal; - } - - /** - * Clears this token. - *

- * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only. - *

- */ - void clear() { - fNode= null; - fLiteral= null; - fBinding= null; - fIsBindingResolved= false; - fRoot= null; - fIsRootResolved= false; - } -} diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java 2018-12-03 12:49:27.000000000 +0000 @@ -143,6 +143,7 @@ public static final String IMG_OBJS_CLASSFOLDER_WSRC= NAME_PREFIX + "cf_src_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_CLASSFOLDER_WSRC_TEST= NAME_PREFIX + "cf_src_test_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_PROJECT_TEST= NAME_PREFIX + "project_test_obj.png"; //$NON-NLS-1$ + public static final String IMG_OBJS_TEST_CASE= NAME_PREFIX + "new_testcase.png"; //$NON-NLS-1$ public static final String IMG_OBJS_ENV_VAR= NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ENV_VAR_TEST= NAME_PREFIX + "envvar_test_obj.gif"; //$NON-NLS-1$ @@ -252,6 +253,7 @@ public static final ImageDescriptor DESC_OBJS_PACKFRAG_ROOT_TESTSOURCES= createManagedFromKey(T_OBJ, IMG_OBJS_PACKFRAG_ROOT_TESTSOURCES); public static final ImageDescriptor DESC_OBJS_PROJECT_SETTINGS= createManagedFromKey(T_OBJ, IMG_OBJS_PROJECT_SETTINGS); public static final ImageDescriptor DESC_OBJS_PROJECT_TEST= createManagedFromKey(T_OBJ, IMG_OBJS_PROJECT_TEST); + public static final ImageDescriptor DESC_OBJS_TEST_CASE= createManagedFromKey(T_ETOOL, IMG_OBJS_TEST_CASE); public static final ImageDescriptor DESC_OBJS_JAVA_MODEL= createManagedFromKey(T_OBJ, IMG_OBJS_JAVA_MODEL); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java 2018-12-03 12:49:27.000000000 +0000 @@ -87,9 +87,9 @@ import org.eclipse.jdt.core.WorkingCopyOwner; import org.eclipse.jdt.core.manipulation.JavaManipulation; +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; import org.eclipse.jdt.internal.corext.fix.CleanUpRegistry; import org.eclipse.jdt.internal.corext.template.java.AbstractJavaContextType; -import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.internal.corext.template.java.JavaContextType; import org.eclipse.jdt.internal.corext.template.java.SWTContextType; import org.eclipse.jdt.internal.corext.util.OpenTypeHistory; @@ -120,8 +120,8 @@ import org.eclipse.jdt.internal.ui.viewsupport.ImagesOnFileSystemRegistry; import org.eclipse.jdt.internal.ui.viewsupport.ProblemMarkerManager; import org.eclipse.jdt.internal.ui.wizards.buildpaths.ClasspathAttributeConfigurationDescriptors; -import org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs; import org.eclipse.jdt.internal.ui.workingsets.DynamicSourcesWorkingSetUpdater; +import org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs; import org.eclipse.jdt.internal.ui.workingsets.WorkingSetMessages; @@ -432,6 +432,8 @@ new InitializeAfterLoadJob().schedule(); // last call in start, see bug 191193 } + JavaManipulation.setCodeTemplateStore(getCodeTemplateStore()); + JavaManipulation.setCodeTemplateContextRegistry(getCodeTemplateContextRegistry()); } private void createOrUpdateWorkingSet(String name, String oldname, String label, final String id) { @@ -757,6 +759,7 @@ registerJavaContext(registry, JavaContextType.ID_MEMBERS, all_contextType); registerJavaContext(registry, JavaContextType.ID_STATEMENTS, all_contextType); + registerJavaContext(registry, JavaContextType.ID_MODULE, all_contextType); registerJavaContext(registry, SWTContextType.ID_ALL, all_contextType); all_contextType= registry.getContextType(SWTContextType.ID_ALL); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaUIStatus.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaUIStatus.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaUIStatus.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaUIStatus.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jdt.internal.ui; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * Convenience class for error exceptions thrown inside JavaUI plugin. - */ -public class JavaUIStatus extends Status { - - private JavaUIStatus(int severity, int code, String message, Throwable throwable) { - super(severity, JavaPlugin.getPluginId(), code, message, throwable); - } - - public static IStatus createError(int code, Throwable throwable) { - String message= throwable.getMessage(); - if (message == null) { - message= throwable.getClass().getName(); - } - return new JavaUIStatus(IStatus.ERROR, code, message, throwable); - } - - public static IStatus createError(int code, String message, Throwable throwable) { - return new JavaUIStatus(IStatus.ERROR, code, message, throwable); - } - - public static IStatus createWarning(int code, String message, Throwable throwable) { - return new JavaUIStatus(IStatus.WARNING, code, message, throwable); - } - - public static IStatus createInfo(int code, String message, Throwable throwable) { - return new JavaUIStatus(IStatus.INFO, code, message, throwable); - } -} - diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/NonEssentialElementsFilter.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/NonEssentialElementsFilter.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/NonEssentialElementsFilter.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/NonEssentialElementsFilter.java 2018-12-03 12:49:27.000000000 +0000 @@ -79,9 +79,18 @@ Object[] children= getRawChildren(viewer, element); ViewerFilter[] filters= viewer.getFilters(); for (int i= 0; i < filters.length; i++) { - children= filters[i].filter(viewer, element, children); - if (children.length == 0) + boolean hasSelectedChildren= false; + // next lines are identical to ViewerFilter.filter(Viewer, Object, Object[]), but exit early when first child is found + int size = children.length; + for (int j = 0; j < size; ++j) { + if (filters[i].select(viewer, element, children[j])) { + hasSelectedChildren = true; + break; + } + } + if (!hasSelectedChildren) { return false; + } } return true; } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java 2018-12-03 12:49:27.000000000 +0000 @@ -67,6 +67,7 @@ private static final Key PREF_CODEASSIST_AUTOACTIVATION= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION); private static final Key PREF_CODEASSIST_AUTOACTIVATION_DELAY= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY); private static final Key PREF_CODEASSIST_AUTOINSERT= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOINSERT); + private static final Key PREF_CODEASSIST_DISABLE_COMPLETION_PROPOSAL_TRIGGER_CHARS= getJDTUIKey(PreferenceConstants.CODEASSIST_DISABLE_COMPLETION_PROPOSAL_TRIGGER_CHARS); private static final Key PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA); private static final Key PREF_CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC= getJDTUIKey(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC); private static final Key PREF_CODEASSIST_SHOW_VISIBLE_PROPOSALS= getJDTUIKey(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS); @@ -100,7 +101,8 @@ PREF_CODEASSIST_PREFIX_COMPLETION, PREF_CODEASSIST_DEPRECATION_CHECK, PREF_CODEASSIST_CAMEL_CASE_MATCH, - PREF_CODEASSIST_SUBSTRING_MATCH + PREF_CODEASSIST_SUBSTRING_MATCH, + PREF_CODEASSIST_DISABLE_COMPLETION_PROPOSAL_TRIGGER_CHARS }; } @@ -169,6 +171,8 @@ label= PreferencesMessages.JavaEditorPreferencePage_completePrefixes; addCheckBox(composite, label, PREF_CODEASSIST_PREFIX_COMPLETION, trueFalse, 0); + addCheckBox(composite, PreferencesMessages.JavaEditorPreferencePage_disableCompletionProposalTriggerChars, PREF_CODEASSIST_DISABLE_COMPLETION_PROPOSAL_TRIGGER_CHARS, trueFalse, 0); + label= PreferencesMessages.JavaEditorPreferencePage_automaticallyAddImportInsteadOfQualifiedName; Button master= addCheckBox(composite, label, PREF_CODEASSIST_ADDIMPORT, trueFalse, 0); @@ -238,7 +242,7 @@ */ protected static void createSelectionDependency(final Button master, final Control slave) { master.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent event) { deepSetEnabled(slave, master.getSelection()); @@ -278,10 +282,10 @@ label= PreferencesMessages.CodeAssistConfigurationBlock_matchCamelCase_label; addCheckBox(composite, label, PREF_CODEASSIST_CAMEL_CASE_MATCH, enabledDisabled, 0); - + label= PreferencesMessages.CodeAssistConfigurationBlock_matchSubstring_label; addCheckBox(composite, label, PREF_CODEASSIST_SUBSTRING_MATCH, enabledDisabled, 0); - + label= PreferencesMessages.JavaEditorPreferencePage_showOnlyProposalsVisibleInTheInvocationContext; addCheckBox(composite, label, PREF_CODEASSIST_SHOW_VISIBLE_PROPOSALS, trueFalse, 0); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -43,6 +43,9 @@ import org.eclipse.core.resources.IProject; +import org.eclipse.text.templates.TemplatePersistenceData; +import org.eclipse.text.templates.TemplateReaderWriter; + import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.layout.PixelConverter; import org.eclipse.jface.preference.IPreferenceStore; @@ -57,12 +60,12 @@ import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.templates.Template; import org.eclipse.jface.text.templates.TemplateContextType; -import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; -import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; -import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; +import org.eclipse.jdt.internal.core.manipulation.ProjectTemplateStore; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.PreferenceConstants; @@ -72,8 +75,6 @@ import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer; import org.eclipse.jdt.internal.ui.text.template.preferences.TemplateVariableProcessor; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; -import org.eclipse.jdt.internal.ui.viewsupport.ProjectTemplateStore; import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplatePreferencePage.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplatePreferencePage.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplatePreferencePage.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplatePreferencePage.java 2018-12-03 12:49:27.000000000 +0000 @@ -22,7 +22,7 @@ import org.eclipse.core.resources.IProject; -import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; +import org.eclipse.text.templates.TemplatePersistenceData; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java 2018-12-03 12:49:27.000000000 +0000 @@ -132,6 +132,7 @@ private static final String VERSION_1_8= JavaCore.VERSION_1_8; private static final String VERSION_9= JavaCore.VERSION_9; private static final String VERSION_10= JavaCore.VERSION_10; + private static final String VERSION_11= JavaCore.VERSION_11; private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$ private static final String ERROR= JavaCore.ERROR; @@ -274,7 +275,7 @@ private Composite createComplianceTabContent(Composite folder) { final String[] complianceVersions= new String[] { VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10 }; + VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11 }; final String[] complianceLabels= new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13, PreferencesMessages.ComplianceConfigurationBlock_version14, @@ -284,10 +285,11 @@ PreferencesMessages.ComplianceConfigurationBlock_version18, PreferencesMessages.ComplianceConfigurationBlock_version9, PreferencesMessages.ComplianceConfigurationBlock_version10, + PreferencesMessages.ComplianceConfigurationBlock_version_11, }; String[] targetVersions= new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10 }; + VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11 }; String[] targetLabels= new String[] { PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11, PreferencesMessages.ComplianceConfigurationBlock_version11, @@ -300,6 +302,7 @@ PreferencesMessages.ComplianceConfigurationBlock_version18, PreferencesMessages.ComplianceConfigurationBlock_version9, PreferencesMessages.ComplianceConfigurationBlock_version10, + PreferencesMessages.ComplianceConfigurationBlock_version_11, }; if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) { targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14); @@ -307,7 +310,7 @@ } String[] sourceVersions= new String[] { VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10 }; + VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11 }; String[] sourceLabels= new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13, PreferencesMessages.ComplianceConfigurationBlock_version14, @@ -317,6 +320,7 @@ PreferencesMessages.ComplianceConfigurationBlock_version18, PreferencesMessages.ComplianceConfigurationBlock_version9, PreferencesMessages.ComplianceConfigurationBlock_version10, + PreferencesMessages.ComplianceConfigurationBlock_version_11, }; final ScrolledPageContent sc1 = new ScrolledPageContent(folder); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java 2018-12-03 12:49:27.000000000 +0000 @@ -266,7 +266,7 @@ * The scrolled area of the tree. */ protected ReflowControlScrolledPageContent fScrolledPageContent; - + /** * Job to update the UI in a separate thread. */ @@ -282,16 +282,31 @@ */ private Label fNoMatchFoundLabel; + /** + * The description which can be null + */ + private Label fDescription; + + /** + * The filter text control. + */ + private FilterTextControl fFilterTextControl; + private ToolItem fExpandAllItem; private ToolItem fCollapseAllItem; + public FilteredPreferenceTree(Composite parentComposite, String label, String hint) { + this(parentComposite, label, hint, true); + } + + public FilteredPreferenceTree(Composite parentComposite, String label, String hint, boolean showVerticalBar) { fParentComposite= parentComposite; fRoot= new PreferenceTreeNode<>(null, null, false); createDescription(label); createFilterBox(hint); - createScrolledArea(); + createScrolledArea(showVerticalBar); createNoMatchFoundLabel(); fRefreshJob= doCreateRefreshJob(); @@ -308,10 +323,10 @@ if (label == null) return; - Label description= new Label(fParentComposite, SWT.LEFT | SWT.WRAP); - description.setFont(fParentComposite.getFont()); - description.setText(label); - description.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + fDescription= new Label(fParentComposite, SWT.LEFT | SWT.WRAP); + fDescription.setFont(fParentComposite.getFont()); + fDescription.setText(label); + fDescription.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); } private void createFilterBox(String hint) { @@ -325,9 +340,9 @@ composite.setFont(fParentComposite.getFont()); //TODO: Directly use the hint flags once Bug 293230 is fixed - FilterTextControl filterTextControl= new FilterTextControl(composite); + fFilterTextControl= new FilterTextControl(composite); - final Text filterBox= filterTextControl.getFilterControl(); + Text filterBox= fFilterTextControl.getFilterControl(); filterBox.setMessage(hint); filterBox.addModifyListener(new ModifyListener() { @@ -376,13 +391,13 @@ return item; } - private void createScrolledArea() { + private void createScrolledArea(boolean showVerticalBar) { fScrolledPageContent= new ReflowControlScrolledPageContent(fParentComposite); fScrolledPageContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, ((GridLayout) fParentComposite.getLayout()).numColumns, 0)); fScrolledPageContent.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { - fScrolledPageContent.getVerticalBar().setVisible(true); + fScrolledPageContent.getVerticalBar().setVisible(showVerticalBar); } }); } @@ -529,4 +544,22 @@ fScrolledPageContent.setReflow(true); Display.getCurrent().asyncExec(() -> fScrolledPageContent.setRedraw(true)); } + + /** + * Enables the filtered preference tree if the argument is true, and disables it + * otherwise. + * + * @param enabled the new enabled state + * + * @since 3.16 + */ + public void setEnabled(boolean enabled) { + if (fDescription != null) { + fDescription.setEnabled(enabled); + } + fFilterTextControl.setEnabled(enabled); + fCollapseAllItem.setEnabled(enabled); + fExpandAllItem.setEnabled(enabled); + fRoot.getChildren().forEach(node -> node.setEnabled(enabled)); + } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilterTextControl.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilterTextControl.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilterTextControl.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilterTextControl.java 2018-12-03 12:49:27.000000000 +0000 @@ -271,4 +271,26 @@ fClearButton.setVisible(visible); } } + + /** + * Enables the filter text control if the argument is true, and disables it + * otherwise. + * + * @param enabled the new enabled state + * + * @since 3.16 + */ + public void setEnabled(boolean enabled) { + if (fTextControl != null) { + fTextControl.setEnabled(enabled); + } + if (fClearButton != null) { + fClearButton.setEnabled(enabled); + } + boolean nativeField= fgUseNativeSearchField.booleanValue(); + if (!nativeField) { + // in the case of native field, composite is initialized with blank, we need to manage background to avoid having a blank square on the right when the control is disabled. + fComposite.setBackground(enabled ? fComposite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND) : null); + } + } } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 2018-12-03 12:49:27.000000000 +0000 @@ -183,13 +183,6 @@ public static String FormatterModifyDialog_newLines_pref_before_else_statements; public static String FormatterModifyDialog_newLines_pref_before_finally_statements; public static String FormatterModifyDialog_newLines_pref_before_while_in_do_statements; - public static String FormatterModifyDialog_newLines_pref_empty_annotation_decl; - public static String FormatterModifyDialog_newLines_pref_empty_anonymous_class_body; - public static String FormatterModifyDialog_newLines_pref_empty_block; - public static String FormatterModifyDialog_newLines_pref_empty_class_body; - public static String FormatterModifyDialog_newLines_pref_empty_enum_constant; - public static String FormatterModifyDialog_newLines_pref_empty_enum_declaration; - public static String FormatterModifyDialog_newLines_pref_empty_method_body; public static String FormatterModifyDialog_newLines_pref_empty_statement; public static String FormatterModifyDialog_newLines_pref_end_of_file; public static String FormatterModifyDialog_newLines_pref_enum_constants; @@ -202,6 +195,17 @@ public static String FormatterModifyDialog_newLines_pref_keep_simple_if_on_one_line; public static String FormatterModifyDialog_newLines_pref_keep_simple_while_body_on_one_line; public static String FormatterModifyDialog_newLines_pref_keep_then_on_same_line; + public static String FormatterModifyDialog_newLines_pref_keep_annotation_declaration_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_anonymous_type_declaration_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_code_block_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_enum_constant_declaration_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_enum_declaration_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_if_then_body_block_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_lambda_body_block_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_loop_body_block_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_method_body_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_simple_getter_setter_on_one_line; + public static String FormatterModifyDialog_newLines_pref_keep_type_declaration_on_one_line; public static String FormatterModifyDialog_newLines_pref_local_variables; public static String FormatterModifyDialog_newLines_pref_methods; public static String FormatterModifyDialog_newLines_pref_packages; @@ -209,11 +213,16 @@ public static String FormatterModifyDialog_newLines_pref_type_annotations; public static String FormatterModifyDialog_newLines_pref_types; public static String FormatterModifyDialog_newLines_tree_after_annotations; - public static String FormatterModifyDialog_newLines_tree_between_empty_braces; public static String FormatterModifyDialog_newLines_tree_control_statements; public static String FormatterModifyDialog_newLines_tree_if_else; + public static String FormatterModifyDialog_newLines_tree_keep_braced_code_on_one_line; public static String FormatterModifyDialog_newLines_tree_new_lines; public static String FormatterModifyDialog_newLines_tree_simple_loops; + public static String FormatterModifyDialog_newLines_val_one_line_always; + public static String FormatterModifyDialog_newLines_val_one_line_if_empty; + public static String FormatterModifyDialog_newLines_val_one_line_if_single_item; + public static String FormatterModifyDialog_newLines_val_one_line_never; + public static String FormatterModifyDialog_newLines_val_one_line_preserve; public static String FormatterModifyDialog_offOn_description; public static String FormatterModifyDialog_offOn_error_endsWithWhitespace; public static String FormatterModifyDialog_offOn_error_startsWithWhitespace; diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 2018-12-03 12:49:27.000000000 +0000 @@ -348,32 +348,36 @@ FormatterModifyDialog_newLines_tree_new_lines=New Lines FormatterModifyDialog_newLines_tree_after_annotations=After annotations -FormatterModifyDialog_newLines_tree_between_empty_braces=Between empty braces FormatterModifyDialog_newLines_tree_control_statements=In control statements +FormatterModifyDialog_newLines_tree_if_else='if else' +FormatterModifyDialog_newLines_tree_simple_loops=Simple loops +FormatterModifyDialog_newLines_tree_keep_braced_code_on_one_line=Keep braced code on one line FormatterModifyDialog_newLines_pref_before_else_statements=Before 'else' in an 'if' statement FormatterModifyDialog_newLines_pref_before_catch_statements=Before 'catch' in a 'try' statement FormatterModifyDialog_newLines_pref_before_finally_statements=Before 'finally' in a 'try' statement FormatterModifyDialog_newLines_pref_before_while_in_do_statements=Before 'while' in a 'do' statement -FormatterModifyDialog_newLines_tree_if_else='if else' -FormatterModifyDialog_newLines_tree_simple_loops=Simple loops FormatterModifyDialog_newLines_pref_keep_then_on_same_line=Keep 'then' statement on same line -FormatterModifyDialog_newLines_pref_keep_simple_do_while_body_on_one_line=Keep simple 'do-while' loop body on same line +FormatterModifyDialog_newLines_pref_keep_simple_do_while_body_on_one_line=Keep simple 'do while' loop body on same line FormatterModifyDialog_newLines_pref_keep_simple_for_body_on_one_line=Keep simple 'for' loop body on same line FormatterModifyDialog_newLines_pref_keep_simple_if_on_one_line=Keep simple 'if' on one line FormatterModifyDialog_newLines_pref_keep_simple_while_body_on_one_line=Keep simple 'while' loop body on same line FormatterModifyDialog_newLines_pref_keep_else_on_same_line=Keep 'else' statement on same line FormatterModifyDialog_newLines_pref_keep_else_if_on_one_line=Keep 'else if' on one line FormatterModifyDialog_newLines_pref_keep_guardian_clause_on_one_line=Keep 'return' or 'throw' clause on one line +FormatterModifyDialog_newLines_pref_keep_annotation_declaration_on_one_line=Annotation declaration +FormatterModifyDialog_newLines_pref_keep_anonymous_type_declaration_on_one_line=Anonymous class declaration +FormatterModifyDialog_newLines_pref_keep_code_block_on_one_line=Other code blocks in statements +FormatterModifyDialog_newLines_pref_keep_enum_constant_declaration_on_one_line=Enum constant declaration +FormatterModifyDialog_newLines_pref_keep_enum_declaration_on_one_line=Enum declaration +FormatterModifyDialog_newLines_pref_keep_if_then_body_block_on_one_line='if then' statement body +FormatterModifyDialog_newLines_pref_keep_lambda_body_block_on_one_line=Lambda body +FormatterModifyDialog_newLines_pref_keep_loop_body_block_on_one_line=Loop body ('for', 'while', 'do while') +FormatterModifyDialog_newLines_pref_keep_method_body_on_one_line=Method declaration +FormatterModifyDialog_newLines_pref_keep_simple_getter_setter_on_one_line=Keep simple getters and setters on one line +FormatterModifyDialog_newLines_pref_keep_type_declaration_on_one_line=Class declaration -FormatterModifyDialog_newLines_pref_empty_class_body=In empty class body -FormatterModifyDialog_newLines_pref_empty_annotation_decl=In empty annotation body -FormatterModifyDialog_newLines_pref_empty_anonymous_class_body=In empty anonymous class body -FormatterModifyDialog_newLines_pref_empty_enum_declaration=In empty enum declaration -FormatterModifyDialog_newLines_pref_empty_enum_constant=In empty enum constant body -FormatterModifyDialog_newLines_pref_empty_method_body=In empty method body -FormatterModifyDialog_newLines_pref_empty_block=In empty block FormatterModifyDialog_newLines_pref_end_of_file=At end of file FormatterModifyDialog_newLines_pref_after_labels=After labels FormatterModifyDialog_newLines_pref_empty_statement=Before empty statement @@ -389,6 +393,11 @@ FormatterModifyDialog_newLines_pref_enum_constants=On enum constants FormatterModifyDialog_newLines_pref_fields=On fields FormatterModifyDialog_newLines_pref_methods=On methods +FormatterModifyDialog_newLines_val_one_line_always=If fits in width limit +FormatterModifyDialog_newLines_val_one_line_if_empty=If empty +FormatterModifyDialog_newLines_val_one_line_if_single_item=If at most one item +FormatterModifyDialog_newLines_val_one_line_never=Never +FormatterModifyDialog_newLines_val_one_line_preserve=Preserve state FormatterModifyDialog_offOn_description=Off/On tags can be used in any comments to turn the formatter off and on in a source file.\n- At the beginning of each file, the formatter is enabled.\n- Each time the formatter sees an off tag, it disables formatting for that comment and the source after it.\n- Each time the formatter sees an on tag, it enables formatting for the source after that comment.\n FormatterModifyDialog_offOn_pref_enable=Enable Off/On tags diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java 2018-12-03 12:49:27.000000000 +0000 @@ -66,6 +66,7 @@ import org.eclipse.jdt.internal.ui.preferences.FilteredPreferenceTree; import org.eclipse.jdt.internal.ui.preferences.FilteredPreferenceTree.PreferenceTreeNode; import org.eclipse.jdt.internal.ui.preferences.PreferenceHighlight; +import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog.ProfilePreferenceTree.SectionBuilder; import org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog.ProfilePreferenceTree.SimpleTreeBuilder; import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile; import org.eclipse.jdt.internal.ui.util.SWTUtil; @@ -471,10 +472,17 @@ @Override protected Composite createPreviewPane(Composite parent) { Composite previewPane= super.createPreviewPane(parent); - ((GridLayout) previewPane.getLayout()).makeColumnsEqualWidth= true; - fPreviewRawButton= new Button(previewPane, SWT.TOGGLE | SWT.WRAP); - fPreviewRawButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + Composite controlPane= new Composite(previewPane, SWT.NONE); + controlPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + createGridLayout(controlPane, 2, false); + Composite buttonsPane= new Composite(controlPane, SWT.NONE); + buttonsPane.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); + createGridLayout(buttonsPane, 3, false); + ((GridLayout) buttonsPane.getLayout()).makeColumnsEqualWidth= true; + + fPreviewRawButton= new Button(buttonsPane, SWT.TOGGLE | SWT.WRAP); + fPreviewRawButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); fPreviewRawButton.setText(FormatterMessages.FormatterModifyDialog_preview_show_raw_source_toggle); fPreviewRawButton.setFont(previewPane.getFont()); fPreviewRawButton.addSelectionListener(new SelectionAdapter() { @@ -484,8 +492,8 @@ } }); - Button customPreviewButton= new Button(previewPane, SWT.TOGGLE | SWT.WRAP); - customPreviewButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + Button customPreviewButton= new Button(buttonsPane, SWT.TOGGLE | SWT.WRAP); + customPreviewButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); customPreviewButton.setText(FormatterMessages.FormatterModifyDialog_preview_custom_contents_toggle); customPreviewButton.setFont(previewPane.getFont()); customPreviewButton.setSelection(fDialogSettings.getBoolean(CUSTOM_PREVIEW_TOGGLE_PREFERENCE_KEY)); @@ -501,8 +509,8 @@ fDialogSettings.put(CUSTOM_PREVIEW_CONTENT_PREFERENCE_KEY, ((StyledText) e.getSource()).getText()); }); - final Button showInvisibleButton= new Button(previewPane, SWT.TOGGLE | SWT.WRAP); - showInvisibleButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + final Button showInvisibleButton= new Button(buttonsPane, SWT.TOGGLE | SWT.WRAP); + showInvisibleButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); showInvisibleButton.setText(FormatterMessages.FormatterModifyDialog_preview_show_whitespace_toggle); showInvisibleButton.setFont(previewPane.getFont()); showInvisibleButton.addSelectionListener(new SelectionAdapter() { @@ -516,8 +524,9 @@ fPreview.showInvisibleCharacters(showInvisible); showInvisibleButton.setSelection(showInvisible); - Composite lineWidthPane= new Composite(previewPane, SWT.NONE); - lineWidthPane.setLayoutData(new GridData(SWT.TRAIL, SWT.FILL, true, false, 1, 1)); + Composite lineWidthPane= new Composite(controlPane, SWT.NONE); + GridData lineWidthPaneLayoutData= new GridData(SWT.END, SWT.CENTER, true, false); + lineWidthPane.setLayoutData(lineWidthPaneLayoutData); RowLayout layout= new RowLayout(); layout.center= true; layout.justify= true; @@ -529,6 +538,8 @@ Spinner lineWidthSpinner= NumberPreference.createSpinner(lineWidthPane, 0, 9999); lineWidthSpinner.setFont(previewPane.getFont()); lineWidthSpinner.setLayoutData(null); + lineWidthPaneLayoutData.minimumWidth= lineWidthSpinner.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; + int previewLineSplit; try { previewLineSplit= fDialogSettings.getInt(PREVIEW_LINE_WIDTH_PREFERENCE_KEY); @@ -1097,14 +1108,14 @@ private void createNewLinesTree() { Consumer
modAll= s -> CheckboxPreference.addModifyAll(s, fImages); fTree.builder(FormatterMessages.FormatterModifyDialog_newLines_tree_new_lines, "section-newlines") //$NON-NLS-1$ - .node(fTree.builder(FormatterMessages.FormatterModifyDialog_newLines_tree_between_empty_braces, "-declarations", modAll) //$NON-NLS-1$ - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_anonymous_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_method_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_enum_constant, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_annotation_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION)) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_statement, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE) + .gap() + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_after_opening_brace_of_array_initializer, + DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_before_closing_brace_of_array_initializer, + DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER) + .gap() + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_end_of_file, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING) .node(fTree.builder(FormatterMessages.FormatterModifyDialog_newLines_tree_control_statements, "-controlstatements", modAll) //$NON-NLS-1$ .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_before_else_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT) .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_before_catch_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT) @@ -1118,8 +1129,7 @@ pref.addDependant(child, valueAcceptor(DefaultCodeFormatterConstants.FALSE)); }) .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_else_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_else_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_guardian_clause_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE)) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_else_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF)) .node(fTree.builder(FormatterMessages.FormatterModifyDialog_newLines_tree_simple_loops, "-simpleloops", modAll) //$NON-NLS-1$ .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_simple_for_body_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_FOR_BODY_ON_SAME_LINE) .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_simple_while_body_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_WHILE_BODY_ON_SAME_LINE) @@ -1133,13 +1143,7 @@ .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_local_variables, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE) .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_paramters, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER) .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_type_annotations, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_TYPE_ANNOTATION)) - .gap() - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_empty_statement, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE) - .gap() - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_after_opening_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER) - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_before_closing_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER) - .gap() - .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_end_of_file, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING) + .node(createKeepOnOneLineSection()) .build(null, (parent, label, key) -> { String[] values= CheckboxPreference.DO_NOT_INSERT_INSERT; if (parent.getKey().endsWith("-ifelse") || parent.getKey().endsWith("-simpleloops") //$NON-NLS-1$ //$NON-NLS-2$ @@ -1150,6 +1154,60 @@ }); } + private SimpleTreeBuilder createKeepOnOneLineSection() { + String[] oneLineOptions= { + DefaultCodeFormatterConstants.ONE_LINE_NEVER, + DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY, + DefaultCodeFormatterConstants.ONE_LINE_IF_SINGLE_ITEM, + DefaultCodeFormatterConstants.ONE_LINE_ALWAYS, + DefaultCodeFormatterConstants.ONE_LINE_PRESERVE, + }; + String[] oneLineLabels= { + FormatterMessages.FormatterModifyDialog_newLines_val_one_line_never, + FormatterMessages.FormatterModifyDialog_newLines_val_one_line_if_empty, + FormatterMessages.FormatterModifyDialog_newLines_val_one_line_if_single_item, + FormatterMessages.FormatterModifyDialog_newLines_val_one_line_always, + FormatterMessages.FormatterModifyDialog_newLines_val_one_line_preserve, + }; + PreferenceBuilder prefBuilder= (parent, label, key) -> { + String[] values= oneLineOptions; + String[] items= oneLineLabels; + if (DefaultCodeFormatterConstants.FORMATTER_KEEP_CODE_BLOCK_ON_ONE_LINE.equals(key)) { + values= Arrays.copyOf(values, 2); + items= Arrays.copyOf(items, 2); + } + return fTree.addComboPref(parent, label, key, values, items); + }; + SectionBuilder sectionBuilder= fTree + .builder(FormatterMessages.FormatterModifyDialog_newLines_tree_keep_braced_code_on_one_line, "-keepononeline", s -> ComboPreference.addModifyAll(s, fImages)) //$NON-NLS-1$ + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_loop_body_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_LOOP_BODY_BLOCK_ON_ONE_LINE) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_if_then_body_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_IF_THEN_BODY_BLOCK_ON_ONE_LINE, pref -> { + CheckboxPreference guardianPref= fTree.addCheckbox(pref, FormatterMessages.FormatterModifyDialog_newLines_pref_keep_guardian_clause_on_one_line, + DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, CheckboxPreference.FALSE_TRUE); + pref.addDependant(guardianPref, valueAcceptor(oneLineOptions[0], oneLineOptions[1], oneLineOptions[4])); + }) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_lambda_body_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_LAMBDA_BODY_BLOCK_ON_ONE_LINE) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_code_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_CODE_BLOCK_ON_ONE_LINE) + .gap() + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_method_body_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_METHOD_BODY_ON_ONE_LINE, pref -> { + CheckboxPreference getterSetterPref= fTree.addCheckbox(pref, FormatterMessages.FormatterModifyDialog_newLines_pref_keep_simple_getter_setter_on_one_line, + DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_GETTER_SETTER_ON_ONE_LINE, CheckboxPreference.FALSE_TRUE); + pref.addDependant(getterSetterPref, valueAcceptor(oneLineOptions[0], oneLineOptions[1], oneLineOptions[4])); + }) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_type_declaration_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_TYPE_DECLARATION_ON_ONE_LINE) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_anonymous_type_declaration_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ANONYMOUS_TYPE_DECLARATION_ON_ONE_LINE) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_enum_declaration_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ENUM_DECLARATION_ON_ONE_LINE) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_enum_constant_declaration_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ENUM_CONSTANT_DECLARATION_ON_ONE_LINE) + .pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_annotation_declaration_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ANNOTATION_DECLARATION_ON_ONE_LINE); + + return fTree.new SimpleTreeBuilder>(null, null, null) { + @Override + protected PreferenceTreeNode build(Section parent, PreferenceBuilder ignored) { + return sectionBuilder.build(parent, prefBuilder); + } + }; + } + private void createLineWrapTree() { final Section globalSection= fTree.addSection(null, FormatterMessages.FormatterModifyDialog_lineWrap_tree_line_wrapping, "section-linewrap"); //$NON-NLS-1$ fTree.addNumberPref(globalSection, diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ModifyDialog.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ModifyDialog.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ModifyDialog.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ModifyDialog.java 2018-12-03 12:49:27.000000000 +0000 @@ -1518,13 +1518,13 @@ protected Composite createPreviewPane(Composite parent) { final Composite previewPane= new Composite(parent, SWT.NONE); - createGridLayout(previewPane, GRID_COLUMNS, true); + createGridLayout(previewPane, 1, true); previewPane.setFont(parent.getFont()); - createLabel(GRID_COLUMNS, previewPane, FormatterMessages.ModifyDialogTabPage_preview_label_text, 0); + createLabel(1, previewPane, FormatterMessages.ModifyDialogTabPage_preview_label_text, 0); fPreview= new JavaPreview(fWorkingValues, previewPane); - fPreview.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, GRID_COLUMNS, 1)); + fPreview.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); return previewPane; } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileVersioner.java 2018-12-03 12:49:27.000000000 +0000 @@ -44,7 +44,9 @@ private static final int VERSION_13= 13; // https://bugs.eclipse.org/514019 private static final int VERSION_14= 14; // https://bugs.eclipse.org/128653, https://bugs.eclipse.org/531826 - private static final int CURRENT_VERSION= VERSION_14; + private static final int VERSION_15= 15; // https://bugs.eclipse.org/205973 + + private static final int CURRENT_VERSION= VERSION_15; @Override public int getFirstVersion() { @@ -109,6 +111,9 @@ case VERSION_13 : version13to14(oldSettings); //$FALL-THROUGH$ + case VERSION_14: + version14to15(oldSettings); + //$FALL-THROUGH$ default: for (final Iterator iter= oldSettings.keySet().iterator(); iter.hasNext(); ) { final String key= iter.next(); @@ -580,8 +585,8 @@ private static void version9to10(Map oldSettings) { checkAndReplace(oldSettings, - DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, - DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION); + FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, + FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION); checkAndReplace(oldSettings, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER); @@ -632,6 +637,26 @@ oldSettings.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_ALIGN_TAGS_DESCREIPTIONS_GROUPED, DefaultCodeFormatterConstants.FALSE); } + private static void version14to15(Map oldSettings) { + String[][] transitions= { + { DefaultCodeFormatterConstants.FORMATTER_KEEP_ANNOTATION_DECLARATION_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_ANONYMOUS_TYPE_DECLARATION_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_IF_THEN_BODY_BLOCK_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_LOOP_BODY_BLOCK_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_LAMBDA_BODY_BLOCK_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_CODE_BLOCK_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_ENUM_CONSTANT_DECLARATION_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_ENUM_DECLARATION_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_METHOD_BODY_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY }, + { DefaultCodeFormatterConstants.FORMATTER_KEEP_TYPE_DECLARATION_ON_ONE_LINE, FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION }, + }; + for (String[] transition : transitions) { + String value= oldSettings.get(transition[1]); + if (JavaCore.DO_NOT_INSERT.equals(value)) + oldSettings.put(transition[0], DefaultCodeFormatterConstants.ONE_LINE_IF_EMPTY); + } + } + /* old format constant values */ private static final String FORMATTER_METHOD_DECLARATION_ARGUMENTS_ALIGNMENT = JavaCore.PLUGIN_ID + ".formatter.method_declaration_arguments_alignment"; //$NON-NLS-1$ @@ -772,4 +797,55 @@ @Deprecated private static final String FORMATTER_COMMENT_FORMATHTML= PreferenceConstants.FORMATTER_COMMENT_FORMATHTML; + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_ANNOTATION_DECLARATION_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION; + + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_ANONYMOUS_TYPE_DECLARATION_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION; + + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_IF_THEN_BODY_BLOCK_ON_ONE_LINE}, + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_LOOP_BODY_BLOCK_ON_ONE_LINE}, + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_LAMBDA_BODY_BLOCK_ON_ONE_LINE}, + * and {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_CODE_BLOCK_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK; + + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_ENUM_CONSTANT_DECLARATION_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT; + + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_ENUM_DECLARATION_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION; + + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_METHOD_BODY_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY; + + /** + * @deprecated As of 3.16 replaced by + * {@link DefaultCodeFormatterConstants#FORMATTER_KEEP_TYPE_DECLARATION_ON_ONE_LINE} + */ + @Deprecated + private static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION= DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION; } diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildConfigurationBlock.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildConfigurationBlock.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildConfigurationBlock.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildConfigurationBlock.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -61,6 +61,7 @@ private static final Key PREF_PB_INCOMPLETE_BUILDPATH= getJDTCoreKey(JavaCore.CORE_INCOMPLETE_CLASSPATH); private static final Key PREF_PB_CIRCULAR_BUILDPATH= getJDTCoreKey(JavaCore.CORE_CIRCULAR_CLASSPATH); private static final Key PREF_PB_INCOMPATIBLE_JDK_LEVEL= getJDTCoreKey(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL); + private static final Key PREF_PB_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY= getJDTCoreKey(JavaCore.CORE_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY); private static final Key PREF_PB_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE= getJDTCoreKey(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE); private static final Key PREF_PB_DUPLICATE_RESOURCE= getJDTCoreKey(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE); private static final Key PREF_RECREATE_MODIFIED_CLASS_FILES= getJDTCoreKey(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER); @@ -91,12 +92,13 @@ fResourceFilterStatus= new StatusInfo(); } - private static Key[] getKeys() { + public static Key[] getKeys() { Key[] keys= new Key[] { PREF_PB_MAX_PER_UNIT, PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_INCOMPLETE_BUILDPATH, PREF_PB_CIRCULAR_BUILDPATH, PREF_BUILD_CLEAN_OUTPUT_FOLDER, PREF_PB_DUPLICATE_RESOURCE, PREF_PB_INCOMPATIBLE_JDK_LEVEL, PREF_PB_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, - PREF_RECREATE_MODIFIED_CLASS_FILES, PREF_PB_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE, PREF_PB_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE + PREF_RECREATE_MODIFIED_CLASS_FILES, PREF_PB_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE, PREF_PB_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE, + PREF_PB_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY }; return keys; } @@ -141,6 +143,13 @@ PreferencesMessages.JavaBuildConfigurationBlock_warning }; + String[] errorIgnore= new String[] { ERROR, IGNORE }; + + String[] errorIgnoreLabels= new String[] { + PreferencesMessages.JavaBuildConfigurationBlock_error, + PreferencesMessages.JavaBuildConfigurationBlock_ignore + }; + String[] errorWarningInfoIgnore= new String[] { ERROR, WARNING, INFO, IGNORE }; String[] errorWarningInfoIgnoreLabels= new String[] { PreferencesMessages.JavaBuildConfigurationBlock_error, @@ -209,6 +218,9 @@ label= PreferencesMessages.JavaBuildConfigurationBlock_pb_compiler_compliance_does_not_match_jre_label; addComboBox(othersComposite, label, PREF_PB_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE, errorWarningInfoIgnore, errorWarningInfoIgnoreLabels, 0); + label= PreferencesMessages.JavaBuildConfigurationBlock_pb_main_only_project_has_test_only_dependency_label; + addComboBox(othersComposite, label, PREF_PB_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY, errorIgnore, errorIgnoreLabels, 0); + label= PreferencesMessages.JavaBuildConfigurationBlock_section_output_folder; excomposite= createStyleSection(composite, label, nColumns); diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildPreferencePage.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildPreferencePage.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildPreferencePage.java 2018-08-30 10:15:15.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaBuildPreferencePage.java 2018-12-03 12:49:27.000000000 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; +import java.util.Map; + import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -34,6 +36,14 @@ public static final String PREF_ID= "org.eclipse.jdt.ui.preferences.JavaBuildPreferencePage"; //$NON-NLS-1$ public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.JavaBuildPreferencePage"; //$NON-NLS-1$ + public static final String DATA_SELECT_OPTION_KEY= "select_option_key"; //$NON-NLS-1$ + public static final String DATA_SELECT_OPTION_QUALIFIER= "select_option_qualifier"; //$NON-NLS-1$ + + /** + * Key for a Boolean value defining if 'use project specific settings' should be enabled or not. + */ + public static final String USE_PROJECT_SPECIFIC_OPTIONS= "use_project_specific_key"; //$NON-NLS-1$ + private JavaBuildConfigurationBlock fConfigurationBlock; public JavaBuildPreferencePage() { @@ -129,6 +139,26 @@ } @Override + public void applyData(Object data) { + super.applyData(data); + if (data instanceof Map && fConfigurationBlock != null) { + @SuppressWarnings("unchecked") + Map map= (Map) data; + if (isProjectPreferencePage()) { + Boolean useProjectOptions= (Boolean) map.get(USE_PROJECT_SPECIFIC_OPTIONS); + if (useProjectOptions != null) { + enableProjectSpecificSettings(useProjectOptions.booleanValue()); + } + } + + Object key= map.get(DATA_SELECT_OPTION_KEY); + Object qualifier= map.get(DATA_SELECT_OPTION_QUALIFIER); + if (key instanceof String && qualifier instanceof String) { + fConfigurationBlock.selectOption((String) key, (String) qualifier); + } + } + } + @Override public void setElement(IAdaptable element) { super.setElement(element); setDescription(null); // no description for property page diff -Nru eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java --- eclipse-jdt-ui-4.9/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java 1970-01-01 00:00:00.000000000 +0000 +++ eclipse-jdt-ui-4.10/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java 2018-12-03 12:49:27.000000000 +0000 @@ -0,0 +1,236 @@ +/** + * Copyright (c) 2018 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - [CodeMining] Provide Java References/Implementation CodeMinings - Bug 529127 + */ +package org.eclipse.jdt.internal.ui.preferences; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.layout.PixelConverter; + +import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; + +import org.eclipse.jdt.ui.PreferenceConstants; + +import org.eclipse.jdt.internal.ui.JavaPlugin; +import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.jdt.internal.ui.preferences.FilteredPreferenceTree.PreferenceTreeNode; +import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; +import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; + +/** + * Configures Java Editor code mining preferences. + * + * @since 3.16 + */ +public class JavaEditorCodeMiningConfigurationBlock extends OptionsConfigurationBlock { + + // Preference store keys + + // --------------------- General + + private static final Key PREF_CODEMINING_ENABLED= getJDTUIKey( + PreferenceConstants.EDITOR_CODEMINING_ENABLED); + + private static final Key PREF_SHOW_CODEMINING_AT_LEAST_ONE= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_CODEMINING_AT_LEAST_ONE); + + private static final Key PREF_SHOW_REFERENCES= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES); + + private static final Key PREF_SHOW_REFERENCES_ON_TYPES= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES_ON_TYPES); + + private static final Key PREF_SHOW_REFERENCES_ON_FIELDS= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES_ON_FIELDS); + + private static final Key PREF_SHOW_REFERENCES_ON_METHODS= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_REFERENCES_ON_METHODS); + + private static final Key PREF_SHOW_IMPLEMENTATIONS= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_CODEMINING_SHOW_IMPLEMENTATIONS); + + private static final String SETTINGS_SECTION_NAME= "JavaEditorCodeMiningConfigurationBlock"; //$NON-NLS-1$ + + private static final String[] TRUE_FALSE= new String[] { "true", "false" }; //$NON-NLS-1$ //$NON-NLS-2$ + + private PixelConverter fPixelConverter; + + private Button atLeastOneCheckBox; + + private PreferenceTree fFilteredPrefTree; + + public JavaEditorCodeMiningConfigurationBlock(IStatusChangeListener context, + IWorkbenchPreferenceContainer container) { + super(context, null, getAllKeys(), container); + } + + public static Key[] getAllKeys() { + return new Key[] { PREF_CODEMINING_ENABLED, PREF_SHOW_CODEMINING_AT_LEAST_ONE, PREF_SHOW_REFERENCES, PREF_SHOW_REFERENCES_ON_TYPES, PREF_SHOW_REFERENCES_ON_FIELDS, + PREF_SHOW_REFERENCES_ON_METHODS, + PREF_SHOW_IMPLEMENTATIONS }; + } + + @Override + protected Control createContents(Composite parent) { + fPixelConverter= new PixelConverter(parent); + setShell(parent.getShell()); + + Composite mainComp= new Composite(parent, SWT.NONE); + mainComp.setFont(parent.getFont()); + GridLayout layout= new GridLayout(); + layout.marginHeight= 0; + layout.marginWidth= 0; + mainComp.setLayout(layout); + + // Add enabled code mining checkbox + Button codeMiningEnabledCheckBox= addCheckBox(mainComp, PreferencesMessages.JavaEditorCodeMiningConfigurationBlock_enableCodeMining_label, PREF_CODEMINING_ENABLED, + TRUE_FALSE, 0); + + // - Only if there is at least one result + atLeastOneCheckBox= addCheckBox(mainComp, + PreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showCodeMining_atLeastOne_label, + PREF_SHOW_CODEMINING_AT_LEAST_ONE, TRUE_FALSE, LayoutUtil.getIndent()); + + Composite commonComposite= createCodeMiningContent(mainComp); + GridData gridData= new GridData(GridData.FILL, GridData.FILL, true, true); + gridData.heightHint= fPixelConverter.convertHeightInCharsToPixels(20); + commonComposite.setLayoutData(gridData); + + codeMiningEnabledCheckBox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + atLeastOneCheckBox.setEnabled(codeMiningEnabledCheckBox.getSelection()); + fFilteredPrefTree.setEnabled(codeMiningEnabledCheckBox.getSelection()); + updateEnableStates(); + } + }); + atLeastOneCheckBox.setEnabled(codeMiningEnabledCheckBox.getSelection()); + fFilteredPrefTree.setEnabled(codeMiningEnabledCheckBox.getSelection()); + validateSettings(null, null, null); + return mainComp; + } + + private Composite createCodeMiningContent(Composite parent) { + // Create filtered tree which contains code minings + fFilteredPrefTree= new PreferenceTree(this, parent, + PreferencesMessages.JavaEditorCodeMiningConfigurationBlock_common_description, false); + final ScrolledPageContent sc1= fFilteredPrefTree.getScrolledPageContent(); + + int nColumns= 1; + Composite composite= sc1.getBody(); + GridLayout layout= new GridLayout(nColumns, false); + layout.marginHeight= 0; + layout.marginWidth= 0; + composite.setLayout(layout); + + // --- General + createGeneralSection(nColumns, composite); + + IDialogSettings settingsSection= JavaPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME); + restoreSectionExpansionStates(settingsSection); + + return sc1; + } + + private void createGeneralSection(int nColumns, Composite parent) { + int defaultIndent= 0; + int extraIndent= LayoutUtil.getIndent(); + String label= PreferencesMessages.JavaEditorCodeMiningConfigurationBlock_section_general; + Key twistieKey= OptionsConfigurationBlock.getLocalKey("JavaEditorCodeMiningPreferencePage_section_general"); //$NON-NLS-1$ + PreferenceTreeNode section= fFilteredPrefTree.addExpandableComposite(parent, label, nColumns, twistieKey, + null, false); + ExpandableComposite excomposite= getExpandableComposite(twistieKey); + + Composite inner= createInnerComposite(excomposite, nColumns, parent.getFont()); + + // - Show references + PreferenceTreeNode