Skip to content
Commits on Source (8)
# 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
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
# 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
......@@ -4,8 +4,8 @@
<include file="/usr/share/eclipse-debian-helper/build-eclipse-bundle.xml"/>
<!-- Eclipse AST View Plug-in -->
<target name="org.eclipse.jdt.astview" depends="org.eclipse.jdt.ui">
<make-bundle name="org.eclipse.jdt.astview" basedir="." depends="org.eclipse.jdt.ui">
<target name="org.eclipse.jdt.astview" depends="org.eclipse.jdt.ui,org.eclipse.jdt.core.manipulation">
<make-bundle name="org.eclipse.jdt.astview" basedir="." depends="org.eclipse.jdt.ui,org.eclipse.jdt.core.manipulation">
<pathelement path="/usr/share/java/eclipse-core-commands.jar"/>
<pathelement path="/usr/share/java/eclipse-core-filebuffers.jar"/>
<pathelement path="/usr/share/java/eclipse-core-resources.jar"/>
......@@ -27,6 +27,8 @@
<target name="org.eclipse.jdt.core.manipulation" depends="org.eclipse.ltk.core.refactoring">
<make-bundle name="org.eclipse.jdt.core.manipulation" basedir="." depends="org.eclipse.ltk.core.refactoring">
<pathelement path="/usr/share/java/eclipse-core-expressions.jar"/>
<pathelement path="/usr/share/java/eclipse-core-filebuffers.jar"/>
<pathelement path="/usr/share/java/eclipse-core-filesystem.jar"/>
<pathelement path="/usr/share/java/eclipse-core-jobs.jar"/>
<pathelement path="/usr/share/java/eclipse-core-resources.jar"/>
<pathelement path="/usr/share/java/eclipse-core-runtime.jar"/>
......
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 <ebourg@apache.org> Fri, 28 Dec 2018 15:32:30 +0100
eclipse-jdt-ui (4.9-1) unstable; urgency=medium
* New upstream release
......
......@@ -23,14 +23,14 @@ Build-Depends:
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 @@ Build-Depends:
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 @@ Depends:
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 @@ Depends:
${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 @@ Depends:
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,
......
......@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt.feature</groupId>
<artifactId>org.eclipse.jdt.astview.feature</artifactId>
......
......@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.astview
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 @@ Bundle-Localization: plugin
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 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.jdt.core.manipulation
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2017 Eclipse Foundation and others.
Copyright (c) 2012, 2018 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
......@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.astview</artifactId>
<version>1.3.200-SNAPSHOT</version>
<version>1.3.300-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
......@@ -122,15 +122,20 @@ import org.eclipse.jdt.core.dom.ASTRequestor;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.manipulation.SharedASTProviderCore;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.SharedASTProvider;
public class ASTView extends ViewPart implements IShowInSource, IShowInTargetList {
static final int JLS_LATEST= AST.JLS10;
static final int JLS_LATEST= AST.JLS11;
private static final int JLS11= AST.JLS11;
/**
* @deprecated to get rid of deprecation warnings in code
*/
@Deprecated
private static final int JLS10= AST.JLS10;
/**
......@@ -463,6 +468,7 @@ public class ASTView extends ViewPart implements IShowInSource, IShowInTargetLis
case JLS8:
case JLS9:
case JLS10:
case JLS11:
fCurrentASTLevel= level;
}
} catch (NumberFormatException e) {
......@@ -626,7 +632,7 @@ public class ASTView extends ViewPart implements IShowInSource, IShowInTargetLis
} else if (input instanceof ICompilationUnit && (getCurrentInputKind() == ASTInputKindAction.USE_CACHE)) {
ICompilationUnit cu= (ICompilationUnit) input;
startTime= System.currentTimeMillis();
root= SharedASTProvider.getAST(cu, SharedASTProvider.WAIT_NO, null);
root= SharedASTProviderCore.getAST(cu, SharedASTProviderCore.WAIT_NO, null);
endTime= System.currentTimeMillis();
} else {
......@@ -1091,6 +1097,7 @@ public class ASTView extends ViewPart implements IShowInSource, IShowInTargetLis
new ASTLevelToggle("AST Level &8 (1.8)", JLS8), //$NON-NLS-1$
new ASTLevelToggle("AST Level &9 (9)", JLS9), //$NON-NLS-1$
new ASTLevelToggle("AST Level 1&0 (10)", JLS10), //$NON-NLS-1$
new ASTLevelToggle("AST Level 1&1 (11)", JLS11), //$NON-NLS-1$
};
fAddToTrayAction= new Action() {
......
......@@ -13,4 +13,4 @@
###############################################################################
# Prints debug information
org.eclipse.jdt.core.manipulation/debug=true
\ No newline at end of file
org.eclipse.jdt.core.manipulation/debug=false
\ No newline at end of file
......@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.core.manipulation
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.manipulation; singleton:=true
Bundle-Version: 1.10.100.qualifier
Bundle-Version: 1.11.0.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin
Bundle-Localization: plugin
......@@ -13,28 +13,40 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.8.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)",
org.eclipse.text;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="3.9.0"
org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.filesystem;bundle-version="1.7.200",
org.eclipse.core.filebuffers;bundle-version="3.6.300"
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.jdt.core.manipulation,
org.eclipse.jdt.core.refactoring,
org.eclipse.jdt.core.refactoring.descriptors,
org.eclipse.jdt.core.refactoring.participants,
org.eclipse.jdt.internal.core.manipulation;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.core.manipulation;x-friends:="org.eclipse.jdt.ui,org.eclipse.jdt.junit",
org.eclipse.jdt.internal.core.manipulation.dom;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.core.manipulation.search;x-friends:="org.eclipse.jdt.ui,org.eclipse.jdt.text.tests",
org.eclipse.jdt.internal.core.manipulation.util;x-friends:="org.eclipse.jdt.junit,org.eclipse.jdt.text.tests,org.eclipse.jdt.ui",
org.eclipse.jdt.internal.core.refactoring.descriptors;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.codemanipulation;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.dom;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.ui,org.eclipse.jdt.junit",
org.eclipse.jdt.internal.corext.fix;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.base;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.changes;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.ui.examples.javafamily,org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.code;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.rename;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.reorg;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.structure;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.tagging;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.refactoring.util;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.template.java;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.corext.util;manipulation=split;mandatory:=manipulation;x-friends:="org.eclipse.jdt.ui,org.eclipse.jdt.junit",
org.eclipse.jdt.internal.ui;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.javaeditor;x-friends:="org.eclipse.jdt.debug.ui,org.eclipse.jdt.junit,org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.preferences;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.text;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.text.correction;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.preferences;x-friends:="org.eclipse.jdt.ui"
org.eclipse.jdt.internal.ui.text.correction.proposals;x-friends:="org.eclipse.jdt.ui"
Import-Package: com.ibm.icu.text
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
/*******************************************************************************
* Copyright (c) 2018 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
* Red Hat Inc. - created from CUCorrectionProposal
*******************************************************************************/
package org.eclipse.jdt.core.manipulation;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.DocumentChange;
import org.eclipse.ltk.core.refactoring.TextChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.ui.text.correction.proposals.EditAnnotator;
/**
* A proposal for quick fixes and quick assists that work on a single compilation unit. Either a
* {@link TextChange text change} is directly passed in the constructor or method
* {@link #addEdits(IDocument, TextEdit)} is overridden to provide the text edits that are applied
* to the document when the proposal is evaluated.
* <p>
* The proposal takes care of the preview of the changes as proposal information.
* </p>
*
* @since 1.11
*/
public class CUCorrectionProposalCore extends ChangeCorrectionProposalCore implements ICUCorrectionProposal {
private ICompilationUnit fCompilationUnit;
private ICUCorrectionProposal fCUProposal;
/**
* Constructs a correction proposal working on a compilation unit with a given text change.
*
* @param proposal ICUCorrectionProposal to use
* @param name the name that is displayed in the proposal selection dialog
* @param cu the compilation unit to which the change can be applied
* @param change the change that is executed when the proposal is applied or <code>null</code>
* if implementors override {@link #addEdits(IDocument, TextEdit)} to provide the
* text edits or {@link #createTextChange()} to provide a text change
* @param relevance the relevance of this proposal
*/
public CUCorrectionProposalCore(ICUCorrectionProposal proposal, String name, ICompilationUnit cu, TextChange change, int relevance) {
super(name, change, relevance);
if (cu == null) {
throw new IllegalArgumentException("Compilation unit must not be null"); //$NON-NLS-1$
}
fCompilationUnit= cu;
fCUProposal= proposal;
}
/**
* Constructs a correction proposal working on a compilation unit with a given text change.
*
* @param name the name that is displayed in the proposal selection dialog
* @param cu the compilation unit to which the change can be applied
* @param change the change that is executed when the proposal is applied or <code>null</code>
* if implementors override {@link #addEdits(IDocument, TextEdit)} to provide the
* text edits or {@link #createTextChange()} to provide a text change
* @param relevance the relevance of this proposal
*/
public CUCorrectionProposalCore(String name, ICompilationUnit cu, TextChange change, int relevance) {
super(name, change, relevance);
if (cu == null) {
throw new IllegalArgumentException("Compilation unit must not be null"); //$NON-NLS-1$
}
fCompilationUnit= cu;
fCUProposal= this;
}
/**
* Constructs a correction proposal working on a compilation unit.
* <p>
* Users have to override {@link #addEdits(IDocument, TextEdit)} to provide the text edits or
* {@link #createTextChange()} to provide a text change.
* </p>
*
* @param name the name that is displayed in the proposal selection dialog
* @param cu the compilation unit on that the change works
* @param relevance the relevance of this proposal
*/
protected CUCorrectionProposalCore(String name, ICompilationUnit cu, int relevance) {
this(name, cu, null, relevance);
}
/**
* Called when the {@link CompilationUnitChange} is initialized. Subclasses can override to add
* text edits to the root edit of the change. Implementors must not access the proposal, e.g.
* not call {@link #getChange()}.
* <p>
* The default implementation does not add any edits
* </p>
*
* @param document content of the underlying compilation unit. To be accessed read only.
* @param editRoot The root edit to add all edits to
* @throws CoreException can be thrown if adding the edits is failing.
*/
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
// empty default implementation
}
@Override
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
StringBuffer buf= new StringBuffer();
try {
TextChange change= fCUProposal.getTextChange();
change.setKeepPreviewEdits(true);
IDocument previewDocument= change.getPreviewDocument(monitor);
TextEdit rootEdit= change.getPreviewEdit(change.getEdit());
EditAnnotator ea= new EditAnnotator(buf, previewDocument);
rootEdit.accept(ea);
ea.unchangedUntil(previewDocument.getLength()); // Final pre-existing region
} catch (CoreException e) {
JavaManipulationPlugin.log(e);
}
return buf.toString();
}
@Override
public void apply() throws CoreException {
performChange();
}
public TextChange getNewChange() {
ICompilationUnit cu= getCompilationUnit();
String name= getName();
TextChange change;
if (!cu.getResource().exists()) {
String source;
try {
source= cu.getSource();
} catch (JavaModelException e) {
JavaManipulationPlugin.log(e);
source= new String(); // empty
}
Document document= new Document(source);
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu));
change= new DocumentChange(name, document);
} else {
CompilationUnitChange cuChange = new CompilationUnitChange(name, cu);
cuChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
change= cuChange;
}
TextEdit rootEdit= new MultiTextEdit();
change.setEdit(rootEdit);
return change;
}
/**
* Creates the text change for this proposal.
* This method is only called once and only when no text change has been passed in
* {see #CUCorrectionProposal(String, ICompilationUnit, TextChange, int, Image)}.
*
* @return the created text change
* @throws CoreException if the creation of the text change failed
*/
public TextChange createTextChange() throws CoreException {
TextChange change = getNewChange();
// initialize text change
IDocument document= change.getCurrentDocument(new NullProgressMonitor());
addEdits(document, change.getEdit());
return change;
}
@Override
protected Change createChange() throws CoreException {
return createTextChange(); // make sure that only text changes are allowed here
}
/**
* Returns the text change that is invoked when the change is applied.
*
* @return the text change that is invoked when the change is applied
* @throws CoreException if accessing the change failed
*/
@Override
public final TextChange getTextChange() throws CoreException {
return (TextChange) getChange();
}
/**
* The compilation unit on which the change works.
*
* @return the compilation unit on which the change works
*/
public ICompilationUnit getCompilationUnit() {
return fCompilationUnit;
}
/**
* Creates a preview of the content of the compilation unit after applying the change.
*
* @return the preview of the changed compilation unit
* @throws CoreException if the creation of the change failed
*
* @noreference This method is not intended to be referenced by clients.
*/
public String getPreviewContent() throws CoreException {
return getTextChange().getPreviewContent(new NullProgressMonitor());
}
@Override
public String toString() {
try {
return getPreviewContent();
} catch (CoreException e) {
// didn't work out
}
return super.toString();
}
}
/*******************************************************************************
* Copyright (c) 2018 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
*
* Copied from /org.eclipse.jdt.ui/src/org/eclipse/jdt/ui/text/java/correction/ChangeCorrectionProposal.java
*
* Contributors:
* IBM Corporation - initial API and implementation
* Red Hat Inc. - copy and modify to be used as ChangeCorrectionProposalCore
*******************************************************************************/
package org.eclipse.jdt.core.manipulation;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.IUndoManager;
import org.eclipse.ltk.core.refactoring.NullChange;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
/**
* @since 1.11
*/
public class ChangeCorrectionProposalCore {
protected Change fChange;
protected String fName;
protected int fRelevance;
/**
* Constructs a change correction proposal.
*
* @param name the name that is displayed in the proposal selection dialog
* @param change the change that is executed when the proposal is applied or <code>null</code>
* if the change will be created by implementors of {@link #createChange()}
* @param relevance the relevance of this proposal
*/
public ChangeCorrectionProposalCore(String name, Change change, int relevance) {
if (name == null) {
throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
}
fName= name;
fChange= change;
fRelevance= relevance;
}
public void apply() throws CoreException {
performChange();
}
/**
* Performs the change associated with this proposal.
* <p>
* Subclasses may extend, but must call the super implementation.
*
* @throws CoreException
* when the invocation of the change failed
*/
protected void performChange() throws CoreException {
Change change= null;
try {
change= getChange();
if (change != null) {
change.initializeValidationData(new NullProgressMonitor());
RefactoringStatus valid= change.isValid(new NullProgressMonitor());
if (valid.hasFatalError()) {
IStatus status = new Status(IStatus.ERROR, JavaManipulation.getPreferenceNodeId(), IStatus.ERROR,
valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null);
throw new CoreException(status);
} else {
IUndoManager manager= RefactoringCore.getUndoManager();
Change undoChange;
boolean successful= false;
try {
manager.aboutToPerformChange(change);
undoChange= change.perform(new NullProgressMonitor());
successful= true;
} finally {
manager.changePerformed(change, successful);
}
if (undoChange != null) {
undoChange.initializeValidationData(new NullProgressMonitor());
manager.addUndo(getName(), undoChange);
}
}
}
} finally {
if (change != null) {
change.dispose();
}
change= null;
}
}
@SuppressWarnings("unused")
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
StringBuffer buf= new StringBuffer();
buf.append("<p>"); //$NON-NLS-1$
try {
Change change= getChange();
if (change != null) {
String name= change.getName();
if (name.length() == 0) {
return null;
}
buf.append(name);
} else {
return null;
}
} catch (CoreException e) {
buf.append("Unexpected error when accessing this proposal:<p><pre>"); //$NON-NLS-1$
buf.append(e.getLocalizedMessage());
buf.append("</pre>"); //$NON-NLS-1$
}
buf.append("</p>"); //$NON-NLS-1$
return buf.toString();
}
/**
* Returns the name of the proposal.
*
* @return the name of the proposal
*/
public String getName() {
return fName;
}
/**
* Returns the change that will be executed when the proposal is applied.
* This method calls {@link #createChange()} to compute the change.
*
* @return the change for this proposal, can be <code>null</code> in rare cases if creation of
* the change failed
* @throws CoreException when the change could not be created
*/
public Change getChange() throws CoreException {
synchronized (this) {
if (fChange == null) {
fChange = createChange();
}
}
return fChange;
}
/**
* Creates the change for this proposal.
* This method is only called once and only when no change has been passed in
* {#ChangeCorrectionProposal(String, Change, int, Image)}.
*
* Subclasses may override.
*
* @return the created change
* @throws CoreException if the creation of the change failed
*/
protected Change createChange() throws CoreException {
return new NullChange();
}
/**
* Sets the display name.
*
* @param name the name to set
*/
public void setDisplayName(String name) {
if (name == null) {
throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
}
fName= name;
}
public int getRelevance() {
return fRelevance;
}
/**
* Sets the relevance.
*
* @param relevance the relevance to set
*
* @see #getRelevance()
*/
public void setRelevance(int relevance) {
fRelevance= relevance;
}
}
/*******************************************************************************
* Copyright (c) 2018 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
* Red Hat Inc. - created from CUCorrectionProposal
*******************************************************************************/
package org.eclipse.jdt.core.manipulation;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ltk.core.refactoring.TextChange;
/**
* @since 1.11
*/
public interface ICUCorrectionProposal {
/**
* Returns the text change that is invoked when the change is applied.
*
* @return the text change that is invoked when the change is applied
* @throws CoreException if accessing the change failed
*/
public TextChange getTextChange() throws CoreException;
}
......@@ -19,6 +19,9 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.text.templates.ContextTypeRegistry;
import org.eclipse.text.templates.TemplateStoreCore;
import org.eclipse.jdt.core.IJavaProject;
/**
......@@ -38,6 +41,10 @@ public class JavaManipulation {
*/
private static String fgPreferenceNodeId;
private static TemplateStoreCore fTemplateStore;
private static ContextTypeRegistry fCodeTemplateContextTypeRegistry;
/**
* @return The id of the preference node for some basic Java preferences.
* Generally this will be <code>"org.eclipse.jdt.ui"</code> but some
......@@ -61,6 +68,34 @@ public class JavaManipulation {
fgPreferenceNodeId= id;
}
/**
* @since 1.11
*/
public static final TemplateStoreCore getCodeTemplateStore () {
return fTemplateStore;
}
/**
* @since 1.11
*/
public static final void setCodeTemplateStore (TemplateStoreCore in) {
fTemplateStore= in;
}
/**
* @since 1.11
*/
public static final ContextTypeRegistry getCodeTemplateContextRegistry () {
return fCodeTemplateContextTypeRegistry;
}
/**
* @since 1.11
*/
public static final void setCodeTemplateContextRegistry (ContextTypeRegistry in) {
fCodeTemplateContextTypeRegistry= in;
}
/**
* Returns the value for the given key in the given context for the JDT UI plug-in.
* @param key The preference key
......
/*******************************************************************************
* 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
* 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.core.manipulation;
import org.eclipse.core.runtime.IProgressMonitor;
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.CompilationUnit;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.manipulation.CoreASTProvider;
/**
* The {@link SharedASTProviderCore} provides access to the {@link CompilationUnit AST root} used by
* the current active Java editor.
*
* <p>For performance reasons, not more than one AST should be kept in memory at a time. Therefore, clients must
* not keep any references to the shared AST or its nodes or bindings.
* </p>
* <p>Clients can make the following assumptions about the AST:
* <dl>
* <li>the AST has a {@link ITypeRoot} as source: {@link CompilationUnit#getTypeRoot()} is not null.</li>
* <li>the {@link AST#apiLevel() AST API level} is {@link AST#JLS11 API level 11} or higher</li>
* <li>the AST has bindings resolved ({@link AST#hasResolvedBindings()})</li>
* <li>{@link AST#hasStatementsRecovery() statement} and {@link AST#hasBindingsRecovery() bindings}
* recovery are enabled
* </li>
* </dl>
* It is possible that in the future a higher API level is used, or that future options will be enabled.
* </p>
* <p>
* The returned AST is shared. It is marked as {@link ASTNode#PROTECT} and must not be modified. Clients are advised to use
* the non-modifying {@link ASTRewrite} to get update scripts.
* </p>
*
* <p>
* This class is not intended to be subclassed or instantiated by clients.
* </p>
*
* @since 1.11
*
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class SharedASTProviderCore {
/**
* Wait flag class.
*/
public static final class WAIT_FLAG {
private String fName;
private WAIT_FLAG(String name) {
fName= name;
}
/*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return fName;
}
}
/**
* Wait flag indicating that a client requesting an AST
* wants to wait until an AST is ready.
* <p>
* An AST will be created by this AST provider if the shared
* AST is not for the given Java element.
* </p>
*/
public static final WAIT_FLAG WAIT_YES= new WAIT_FLAG("wait yes"); //$NON-NLS-1$
/**
* Wait flag indicating that a client requesting an AST
* only wants to wait for the shared AST of the active editor.
* <p>
* No AST will be created by the AST provider.
* </p>
*/
public static final WAIT_FLAG WAIT_ACTIVE_ONLY= new WAIT_FLAG("wait active only"); //$NON-NLS-1$
/**
* Wait flag indicating that a client requesting an AST
* only wants the already available shared AST.
* <p>
* No AST will be created by the AST provider.
* </p>
*/
public static final WAIT_FLAG WAIT_NO= new WAIT_FLAG("don't wait"); //$NON-NLS-1$
/**
* Returns a compilation unit AST for the given Java element. If the element is the input of the
* active Java editor, the AST is the shared AST.
* <p>
* Clients are not allowed to modify the AST and must not keep any references.
* </p>
*
* @param element the {@link ITypeRoot}, must not be <code>null</code>
* @param waitFlag {@link #WAIT_YES}, {@link #WAIT_NO} or {@link #WAIT_ACTIVE_ONLY}
* @param progressMonitor the progress monitor or <code>null</code>
* @return the AST or <code>null</code>.
* <dl>
* <li>If {@link #WAIT_NO} has been specified <code>null</code> is returned if the
* element is not input of the current Java editor or no AST is available</li>
* <li>If {@link #WAIT_ACTIVE_ONLY} has been specified <code>null</code> is returned if
* the element is not input of the current Java editor</li>
* <li>If {@link #WAIT_YES} has been specified either the shared AST is returned or a
* new AST is created.</li>
* <li><code>null</code> will be returned if the operation gets canceled.</li>
* </dl>
*/
public static CompilationUnit getAST(ITypeRoot element, WAIT_FLAG waitFlag, IProgressMonitor progressMonitor) {
CoreASTProvider.WAIT_FLAG finalWaitFlag = null;
if (waitFlag == WAIT_ACTIVE_ONLY) {
finalWaitFlag = CoreASTProvider.WAIT_ACTIVE_ONLY;
} else if (waitFlag == WAIT_NO) {
finalWaitFlag= CoreASTProvider.WAIT_NO;
} else if (waitFlag == WAIT_YES) {
finalWaitFlag= CoreASTProvider.WAIT_YES;
}
return CoreASTProvider.getInstance().getAST(element, finalWaitFlag, progressMonitor);
}
protected SharedASTProviderCore() {
// Prevent instantiation.
}
}
/*******************************************************************************
* 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
......@@ -11,12 +11,14 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.corext.template.java;
package org.eclipse.jdt.internal.core.manipulation;
import java.util.Iterator;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultLineTracker;
import org.eclipse.jface.text.ILineTracker;
......@@ -30,8 +32,7 @@ import org.eclipse.jface.text.templates.TemplateVariableResolver;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.core.manipulation.JavaManipulation;
public class CodeTemplateContext extends TemplateContext {
......@@ -39,11 +40,19 @@ public class CodeTemplateContext extends TemplateContext {
private IJavaProject fProject;
public CodeTemplateContext(String contextTypeName, IJavaProject project, String lineDelim) {
super(JavaPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(contextTypeName));
super(JavaManipulation.getCodeTemplateContextRegistry().getContextType(contextTypeName));
fLineDelimiter= lineDelim;
fProject= project;
}
@Override
public <T> T getAdapter(Class<T> adapter) {
if(adapter == IProject.class) {
return adapter.cast(getJavaProject().getProject());
}
return super.getAdapter(adapter);
}
public IJavaProject getJavaProject() {
return fProject;
}
......