diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..f71fb86bf
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,7 @@
+version: 2
+updates:
+- package-ecosystem: maven
+ directory: "/"
+ schedule:
+ interval: daily
+ open-pull-requests-limit: 10
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..61866638c
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,68 @@
+# Contributing to Eclipse TM4E
+
+Welcome to the Eclipse TM4E contributor land, and thanks in advance for your help in making Eclipse TM4E better and better!
+
+🏠 Official Eclipse TM4E Git repo is [https://github.com/eclipse/tm4e](https://github.com/eclipse/tm4e) .
+
+## ⚖️ Legal and Eclipse Foundation terms
+
+The project license is available at [LICENSE](LICENSE).
+
+This Eclipse Foundation open project is governed by the Eclipse Foundation
+Development Process and operates under the terms of the Eclipse IP Policy.
+
+Before your contribution can be accepted by the project team,
+contributors must have an Eclipse Foundation account and
+must electronically sign the Eclipse Contributor Agreement (ECA).
+
+* [http://www.eclipse.org/legal/ECA.php](http://www.eclipse.org/legal/ECA.php)
+
+For more information, please see the Eclipse Committer Handbook:
+[https://www.eclipse.org/projects/handbook/#resources-commit](https://www.eclipse.org/projects/handbook/#resources-commit).
+
+## 💬 Get in touch with the community
+
+Eclipse TM4E use mainly 2 channels for strategical and technical discussions
+
+* 🐞 View and report issues through uses GitHub Issues at https://github.com/eclipse/m2e-tm4e/issues.
+* 📧 Join the tm4e-dev@eclipse.org mailing-list to get in touch with other contributors about project organization and planning, and browse archive at 📜 [https://accounts.eclipse.org/mailing-list/tm4e-dev](https://accounts.eclipse.org/mailing-list/tm4e-dev)
+
+## 🆕 Trying latest builds
+
+Latest builds, for testing, can usually be found at `https://download.eclipse.org/tm4e/snapshots/` .
+
+## 🧑💻 Developer resources
+
+### ⌨️ Setting up the Development Environment manually
+
+
+* Use Eclipse IDE with Plugin Development Environment installed.
+* Clone this repository
for m2e-core.
+* _File > Open Projects from Filesystem..._ , select the path to tm4e Git repo and the relevant children projects you want to import
+
+### 🏗️ Build
+
+Prerequisite: Latest Maven release or Eclipse m2e.
+
+then `mvn clean verify` from CLI or Right-click on the tm4e root folder > Run As > Maven build
+
+### ⬆️ Version bump
+
+tm4e tries to use OSGi Semantic Version (to properly expose its API contracts and breakage) and Reproducible Version Qualifiers (to minimize the avoid producing multiple equivalent artifacts for identical source). This requires the developer to manually bump version from time to time. Somes rules are that:
+
+* Versions are bumped on a __per module grain__ (bump version of individual bundles/features one by one when necessary), __DON'T bump version of parent pom, nor of other modules you don't change__
+* __Versions are bumped maximum once per release__ (don't bump versions that were already bumped since last release)
+* __Don't bump versions of what you don't change__
+* __Bump version of the bundles you're modifying only if it's their 1st change since last release__
+* Version bump may need to be cascaded to features that *include* the artifact you just changed, and then to features that *include* such features and so on (unless the version of those features were already bumped since last release).
+
+The delta for version bumps are:
+
+* `+0.0.1` (next micro) for a bugfix, or an internal change that doesn't surface to APIs
+* `+0.1.0` (next minor) for an API addition
+* `+1.0.0` (next major) for an API breakage (needs to be discussed on the mailing-list first)
+* If some "smaller" bump already took place, you can replace it with your "bigger one". Eg, if last release has org.eclipse.tm4e 0.4.1; and someone already bumped version to 0.4.2 (for an internal change) and you're adding a new API, then you need to change version to 0.5.0.
+
+### ➕ Submit changes
+
+TM4E only accepts contributions via GitHub Pull Requests against [https://github.com/eclipse/tm4e](https://github.com/eclipse/tm4e) repository.
diff --git a/LICENSE b/LICENSE
index 503284377..e23ece2c8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,203 +1,277 @@
-Eclipse Public License - v 1.0
+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.
+ 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 code and documentation
- distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
- i) changes to the Program, and
- ii) additions to the Program;
+ a) in the case of the initial Contributor, the initial content
+ Distributed under this Agreement, and
- 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 additions to the Program which: (i) are separate modules of
- software distributed in conjunction with the Program under their own
- license agreement, and (ii) are not derivative works of the Program.
+ 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.
+"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.
+"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
+"Program" means the Contributions Distributed in accordance with this
Agreement.
-"Recipient" means anyone who receives the Program under this Agreement,
-including all Contributors.
+"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, in source code and object code form.
- 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 and
- object code 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.
+
+ 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
-A Contributor may choose to distribute the Program in object code form under
-its own license agreement, provided that:
-
- a) it complies with the terms and conditions of this Agreement; and
- b) its license agreement:
- i) effectively disclaims on behalf of all 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 Contributors all liability for
- damages, including direct, indirect, special, incidental and
- consequential damages, such as lost profits;
- iii) states that any provisions which differ from this Agreement are
- offered by that Contributor alone and not by any other party; and
- iv) states that source code for the Program is available from such
- Contributor, and informs licensees how to obtain it in a reasonable
- manner on or through a medium customarily used for software exchange.
-
-When the Program is made available in source code form:
-
- a) it must be made available under this Agreement; and
- b) a copy of this Agreement must be included with each copy of the Program.
- Contributors may not remove or alter any copyright notices contained
- within the Program.
-
-Each Contributor must identify itself as the originator of its Contribution,
-if
-any, in a manner that reasonably allows subsequent Recipients to identify the
-originator of the Contribution.
+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.
+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, 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.
+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, 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
+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.
+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.
-
-This Agreement is governed by the laws of the State of New York and the
-intellectual property laws of the United States of America. No party to this
-Agreement will bring a legal action under this Agreement more than one year
-after the cause of action arose. Each party waives its rights to a jury trial in
-any resulting litigation.
\ No newline at end of file
+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 --git a/README.md b/README.md
index 4d20e2b72..d0b6e7172 100644
--- a/README.md
+++ b/README.md
@@ -35,16 +35,16 @@ Here a sample with TypeScript:
Here are some projects that use tm4e:
* Eclipse IDE languages and frameworks integrations
- ** [Eclipse Corrosion](https://github.com/eclipse/corrosion) Rust development tools in Eclipse IDE.
- ** [Eclipse aCute](https://github.com/eclipse/aCute) C# edition in Eclipse IDE.
- ** [Eclipse Wild Web Developer](https://github.com/eclipse/wildwebdeveloper) a simple and productive Web Development Tools in the Eclipse IDE.
- ** [Eclipse ShellWax](https://github.com/eclipse/shellwax) is a rich Bash script editor in the Eclipse IDE.
- ** [LiClipseText](http://www.liclipse.com/text/) enables Eclipse to be used as a general-purpose text editor, providing support for several languages out of the box.
- ** [typescript.java](https://github.com/angelozerr/typescript.java) (Deprecated) TypeScript IDE for Eclipse with JSDT & tsserver.
- ** [EditorConfig for Eclipse](https://github.com/angelozerr/ec4e) EditorConfig for Eclipse with GenericEditor.
- ** [Phaser Editor 2D](https://phasereditor2d.com) An IDE for the creation of HTML5 games.
- ** [Solargraph](https://github.com/PyvesB/eclipse-solargraph) Ruby edition in Eclipse IDE.
- ** [Dartboard](https://github.com/eclipse/dartboard) Dart language support in the Eclipse IDE.
+ * [Eclipse Corrosion](https://github.com/eclipse/corrosion) Rust development tools in Eclipse IDE.
+ * [Eclipse aCute](https://github.com/eclipse/aCute) C# edition in Eclipse IDE.
+ * [Eclipse Wild Web Developer](https://github.com/eclipse/wildwebdeveloper) a simple and productive Web Development Tools in the Eclipse IDE.
+ * [Eclipse ShellWax](https://github.com/eclipse/shellwax) is a rich Bash script editor in the Eclipse IDE.
+ * [LiClipseText](http://www.liclipse.com/text/) enables Eclipse to be used as a general-purpose text editor, providing support for several languages out of the box.
+ * [typescript.java](https://github.com/angelozerr/typescript.java) (Deprecated) TypeScript IDE for Eclipse with JSDT & tsserver.
+ * [EditorConfig for Eclipse](https://github.com/angelozerr/ec4e) EditorConfig for Eclipse with GenericEditor.
+ * [Phaser Editor 2D](https://phasereditor2d.com) An IDE for the creation of HTML5 games.
+ * [Solargraph](https://github.com/PyvesB/eclipse-solargraph) Ruby edition in Eclipse IDE.
+ * [Dartboard](https://github.com/eclipse/dartboard) Dart language support in the Eclipse IDE.
* [Apache NetBeans](https://github.com/apache/netbeans) is a multi-language IDE written in Java and uses TM4E core parts to support syntax highlighting based on TextMate grammars
## 👷 Get support and contribute
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 7ad59d6cc..cfb94193e 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -13,7 +13,7 @@ This page describes the noteworthy improvements provided by each release of Ecli
## 0.4.2
-* 📅 Release Date (tentative): ?
+* 📅 Release Date (tentative): 6th September 2021
* All changes: https://github.com/eclipse/tm4e/compare/0.4.1...0.4.2
No new feature, numerous bugfixes and code improvements.
diff --git a/org.eclipse.tm4e.core.tests/src/main/java/org/eclipse/tm4e/core/theme/ThemeMatchingTest.java b/org.eclipse.tm4e.core.tests/src/main/java/org/eclipse/tm4e/core/theme/ThemeMatchingTest.java
index 8f2219673..c7bc7b632 100644
--- a/org.eclipse.tm4e.core.tests/src/main/java/org/eclipse/tm4e/core/theme/ThemeMatchingTest.java
+++ b/org.eclipse.tm4e.core.tests/src/main/java/org/eclipse/tm4e/core/theme/ThemeMatchingTest.java
@@ -29,10 +29,10 @@
* @see https://github.com/Microsoft/vscode-textmate/blob/master/src/tests/themes.test.ts
*
*/
-public class ThemeMatchingTest {
+class ThemeMatchingTest {
@Test
- public void testGivesHigherPriorityToDeeperMatches() throws Exception {
+ void testGivesHigherPriorityToDeeperMatches() throws Exception {
Theme theme = loadTheme("{" +
"\"settings\": ["+
"{ \"settings\": { \"foreground\": \"#100000\", \"background\": \"#200000\" } },"+
@@ -58,7 +58,7 @@ public void testGivesHigherPriorityToDeeperMatches() throws Exception {
}
@Test
- public void testGivesHigherPriorityToParentMatches1() throws Exception {
+ void testGivesHigherPriorityToParentMatches1() throws Exception {
Theme theme = loadTheme("{" +
"\"settings\": ["+
"{ \"settings\": { \"foreground\": \"#100000\", \"background\": \"#200000\" } },"+
@@ -86,7 +86,7 @@ public void testGivesHigherPriorityToParentMatches1() throws Exception {
}
@Test
- public void testGivesHigherPriorityToParentMatches2() throws Exception {
+ void testGivesHigherPriorityToParentMatches2() throws Exception {
Theme theme = loadTheme("{" +
"\"settings\": ["+
"{ \"settings\": { \"foreground\": \"#100000\", \"background\": \"#200000\" } },"+
@@ -106,7 +106,7 @@ public void testGivesHigherPriorityToParentMatches2() throws Exception {
}
@Test
- public void testCanMatch() throws Exception {
+ void testCanMatch() throws Exception {
Theme theme = loadTheme("{" +
"\"settings\": ["+
"{ \"settings\": { \"foreground\": \"#F8F8F2\", \"background\": \"#272822\" } },"+
@@ -192,7 +192,7 @@ public void testCanMatch() throws Exception {
}
@Test
- public void testMicrosoft_vscode_23460() throws Exception {
+ void testMicrosoft_vscode_23460() throws Exception {
Theme theme = loadTheme("{" +
"\"settings\": ["+
"{" +
diff --git a/org.eclipse.tm4e.core/META-INF/MANIFEST.MF b/org.eclipse.tm4e.core/META-INF/MANIFEST.MF
index 70a4a6fbf..41cdec9dd 100644
--- a/org.eclipse.tm4e.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.tm4e.core/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tm4e.core
-Bundle-Version: 0.4.2.qualifier
+Bundle-Version: 0.4.3.qualifier
Require-Bundle: org.apache.batik.css;bundle-version="1.9.1";resolution:=optional,
org.apache.batik.util;bundle-version="1.9.1";resolution:=optional,
com.google.gson;resolution:=optional,
diff --git a/org.eclipse.tm4e.core/pom.xml b/org.eclipse.tm4e.core/pom.xml
index 8734ed670..c882d2ab5 100644
--- a/org.eclipse.tm4e.core/pom.xml
+++ b/org.eclipse.tm4e.core/pom.xml
@@ -2,47 +2,10 @@
4.0.0
org.eclipse.tm4e.core
eclipse-plugin
- 0.4.2-SNAPSHOT
+ 0.4.3-SNAPSHOT
org.eclipse
org.eclipse.tm4e
0.3.2-SNAPSHOT
-
-
-
-
- org.jruby.joni
- joni
- 2.1.11
-
-
- org.jruby.jcodings
- jcodings
- 1.0.18
-
-
- com.google.code.gson
- gson
- 2.8.6
-
-
- org.apache.xmlgraphics
- batik-css
- 1.14
-
-
- org.apache.xmlgraphics
- batik-util
- 1.14
-
-
- org.junit.jupiter
- junit-jupiter-api
- 5.7.1
- test
-
-
diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/rule/RuleFactory.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/rule/RuleFactory.java
index 9f8b2e8bc..c5dd96a44 100644
--- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/rule/RuleFactory.java
+++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/rule/RuleFactory.java
@@ -140,8 +140,6 @@ private static int parseInt(String string, int base) {
private static ICompilePatternsResult _compilePatterns(Collection patterns, IRuleFactoryHelper helper,
IRawRepository repository) {
Collection r = new ArrayList();
- int i;
- int len;
int patternId;
IRawGrammar externalGrammar;
Rule rule;
diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/theme/css/ISACParserFactory.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/theme/css/ISACParserFactory.java
index fd02f2cad..8768bfac0 100644
--- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/theme/css/ISACParserFactory.java
+++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/theme/css/ISACParserFactory.java
@@ -41,5 +41,5 @@ public Parser makeParser() throws ClassNotFoundException,
*/
public abstract Parser makeParser(String name)
throws ClassNotFoundException, IllegalAccessException,
- InstantiationException, NullPointerException, ClassCastException;;
+ InstantiationException, NullPointerException, ClassCastException;
}
diff --git a/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/GrammarTest2.java b/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/GrammarTest2.java
index fd80f2d9f..a69fd5f73 100644
--- a/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/GrammarTest2.java
+++ b/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/GrammarTest2.java
@@ -24,32 +24,25 @@
* Test for grammar tokenizer.
*
*/
-public class GrammarTest2 {
+class GrammarTest2 {
@Test
- public void tokenizeLines() throws Exception {
+ void tokenizeLines() throws Exception {
Registry registry = new Registry();
String path = "JavaScript.tmLanguage";
IGrammar grammar = registry.loadGrammarFromPathSync(path, Data.class.getResourceAsStream(path));
StackElement ruleStack = null;
int i = 0;
- int j = 0;
List lines = new ArrayList<>();
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(Data.class.getResourceAsStream("raytracer.ts")));
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(Data.class.getResourceAsStream("raytracer.ts")));){
String line = null;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} catch (Exception e) {
e.printStackTrace();
- } finally {
- if (reader != null) {
- reader.close();
- }
}
int t = 0;
@@ -70,7 +63,6 @@ public void tokenizeLines() throws Exception {
System.err.println(s);
// Assert.assertEquals(EXPECTED_MULTI_LINE_TOKENS[i + j], s);
}
- j = i;
}
System.out.println(System.currentTimeMillis() - start - t);
}
diff --git a/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/MarkDown.java b/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/MarkDown.java
index e2a842734..bc413b064 100644
--- a/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/MarkDown.java
+++ b/org.eclipse.tm4e.core/src/test/java/org/eclipse/tm4e/core/grammar/MarkDown.java
@@ -51,9 +51,9 @@ public static void main(String[] args) throws Exception {
ITokenizeLineResult lineTokens = grammar.tokenizeLine(line, ruleStack);
ruleStack = lineTokens.getRuleStack();
for (i = 0; i < lineTokens.getTokens().length; i++) {
- IToken token = lineTokens.getTokens()[i];
- String s = "Token from " + token.getStartIndex() + " to " + token.getEndIndex() + " with scopes "
- + token.getScopes();
+// IToken token = lineTokens.getTokens()[i];
+// String s = "Token from " + token.getStartIndex() + " to " + token.getEndIndex() + " with scopes "
+// + token.getScopes();
//System.err.println(s);
// Assert.assertEquals(EXPECTED_MULTI_LINE_TOKENS[i + j], s);
}
diff --git a/org.eclipse.tm4e.feature/feature.xml b/org.eclipse.tm4e.feature/feature.xml
index 051e936ef..3a72d29f5 100644
--- a/org.eclipse.tm4e.feature/feature.xml
+++ b/org.eclipse.tm4e.feature/feature.xml
@@ -2,7 +2,7 @@
diff --git a/org.eclipse.tm4e.feature/pom.xml b/org.eclipse.tm4e.feature/pom.xml
index 40490bb6e..3c1cc94e0 100644
--- a/org.eclipse.tm4e.feature/pom.xml
+++ b/org.eclipse.tm4e.feature/pom.xml
@@ -7,5 +7,5 @@
org.eclipse.tm4e.feature
eclipse-feature
- 0.4.3-SNAPSHOT
+ 0.4.4-SNAPSHOT
diff --git a/org.eclipse.tm4e.languageconfiguration/pom.xml b/org.eclipse.tm4e.languageconfiguration/pom.xml
index df1dab816..8726c136b 100644
--- a/org.eclipse.tm4e.languageconfiguration/pom.xml
+++ b/org.eclipse.tm4e.languageconfiguration/pom.xml
@@ -8,16 +8,4 @@
org.eclipse.tm4e
0.3.2-SNAPSHOT
-
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- 5.7.1
- test
-
-
diff --git a/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF b/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF
index a6050d1a2..9f7a22989 100644
--- a/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF
+++ b/org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tm4e.markdown;singleton:=true
-Bundle-Version: 0.3.4.qualifier
+Bundle-Version: 0.3.5.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.tm4e.core,
org.eclipse.tm4e.registry,
diff --git a/org.eclipse.tm4e.markdown/pom.xml b/org.eclipse.tm4e.markdown/pom.xml
index 2c68f9c3d..de99f8992 100644
--- a/org.eclipse.tm4e.markdown/pom.xml
+++ b/org.eclipse.tm4e.markdown/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.eclipse.tm4e.markdown
eclipse-plugin
- 0.3.4-SNAPSHOT
+ 0.3.5-SNAPSHOT
org.eclipse
org.eclipse.tm4e
diff --git a/org.eclipse.tm4e.markdown/src/main/java/org/eclipse/tm4e/markdown/marked/RegExp.java b/org.eclipse.tm4e.markdown/src/main/java/org/eclipse/tm4e/markdown/marked/RegExp.java
index d617bdae6..ff0e17bf9 100644
--- a/org.eclipse.tm4e.markdown/src/main/java/org/eclipse/tm4e/markdown/marked/RegExp.java
+++ b/org.eclipse.tm4e.markdown/src/main/java/org/eclipse/tm4e/markdown/marked/RegExp.java
@@ -68,6 +68,6 @@ public RegExp replaceAll(String name, String val) {
public static final RegExp noop() {
return new RegExp(null);
- };
+ }
}
diff --git a/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF b/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF
index 7bb0cae00..738661f85 100644
--- a/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF
+++ b/org.eclipse.tm4e.registry/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.tm4e.registry;singleton:=true
-Bundle-Version: 0.4.1.qualifier
+Bundle-Version: 0.5.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.tm4e.core,
org.eclipse.core.runtime,
diff --git a/org.eclipse.tm4e.registry/pom.xml b/org.eclipse.tm4e.registry/pom.xml
index 6beecc346..b06147cff 100644
--- a/org.eclipse.tm4e.registry/pom.xml
+++ b/org.eclipse.tm4e.registry/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.eclipse.tm4e.registry
eclipse-plugin
- 0.4.1-SNAPSHOT
+ 0.5.0-SNAPSHOT
org.eclipse
org.eclipse.tm4e
diff --git a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/IGrammarRegistryManager.java b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/IGrammarRegistryManager.java
index 3975ef3dc..79c8662f3 100644
--- a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/IGrammarRegistryManager.java
+++ b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/IGrammarRegistryManager.java
@@ -12,6 +12,7 @@
package org.eclipse.tm4e.registry;
import java.util.Collection;
+import java.util.List;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.tm4e.core.grammar.IGrammar;
@@ -60,13 +61,10 @@ public interface IGrammarRegistryManager {
// --------------- TextMate grammar queries methods.
/**
- * Returns the {@link IGrammar} for the given content types and null
- * otherwise.
- *
- * @param contentTypes
- * the content type.
- * @return the {@link IGrammar} for the given content type and null
- * otherwise.
+ * @param contentTypes the content types to lookup for grammar association.
+ * @return the first {@link IGrammar} that applies to given content-types, or
+ * null if no content-type has a grammar associated. Grammars associated
+ * with parent content-types will be returned if applicable.
*/
IGrammar getGrammarFor(IContentType[] contentTypes);
@@ -96,7 +94,7 @@ public interface IGrammarRegistryManager {
* @return the list of content types bound with the given scope name and
* null otherwise.
*/
- String[] getContentTypesForScope(String scopeName);
+ List getContentTypesForScope(String scopeName);
Collection getInjections(String scopeName);
}
diff --git a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/WorkingCopyGrammarRegistryManager.java b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/WorkingCopyGrammarRegistryManager.java
index 9dce1c385..632e0f507 100644
--- a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/WorkingCopyGrammarRegistryManager.java
+++ b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/WorkingCopyGrammarRegistryManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015-2017 Angelo ZERR.
+ * Copyright (c) 2015, 2021 Angelo ZERR and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -42,12 +42,7 @@ private void load() {
super.registerGrammarDefinition(definition);
// Copy binding scope/content types
String scopeName = definition.getScopeName();
- String[] contentTypes = manager.getContentTypesForScope(scopeName);
- if (contentTypes != null) {
- for (String contentTypeId : contentTypes) {
- super.registerContentTypeBinding(contentTypeId, scopeName);
- }
- }
+ manager.getContentTypesForScope(scopeName).forEach(contentType -> super.registerContentTypeBinding(contentType, scopeName));
// Copy injection
Collection injections = manager.getInjections(scopeName);
if (injections != null) {
diff --git a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/AbstractGrammarRegistryManager.java b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/AbstractGrammarRegistryManager.java
index ff2329738..e204b6188 100644
--- a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/AbstractGrammarRegistryManager.java
+++ b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/AbstractGrammarRegistryManager.java
@@ -16,6 +16,7 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.tm4e.core.grammar.IGrammar;
@@ -77,7 +78,7 @@ public IGrammar getGrammarFor(IContentType[] contentTypes) {
}
// Find grammar by content type
for (IContentType contentType : contentTypes) {
- String scopeName = getScopeNameForContentType(contentType.getId());
+ String scopeName = getScopeNameForContentType(contentType);
if (scopeName != null) {
IGrammar grammar = getGrammarForScope(scopeName);
if (grammar != null) {
@@ -191,22 +192,28 @@ public void registerInjection(String scopeName, String injectTo) {
}
/**
- * Returns scope name bound with the given content type and null otherwise.
- *
- * @param contentTypeId
- * @return scope name bound with the given content type and null otherwise.
+ * @param contentType
+ * @return scope name bound with the given content type (or its base type) and
+ * null otherwise.
*/
- public String getScopeNameForContentType(String contentTypeId) {
- return pluginCache.getScopeNameForContentType(contentTypeId);
+ public String getScopeNameForContentType(IContentType contentType) {
+ while (contentType != null) {
+ String scopeName = pluginCache.getScopeNameForContentType(contentType);
+ if (scopeName != null) {
+ return scopeName;
+ }
+ contentType = contentType.getBaseType();
+ }
+ return null;
}
@Override
- public String[] getContentTypesForScope(String scopeName) {
+ public List getContentTypesForScope(String scopeName) {
return pluginCache.getContentTypesForScope(scopeName);
}
- public void registerContentTypeBinding(String contentTypeId, String scopeName) {
- pluginCache.registerContentTypeBinding(contentTypeId, scopeName);
+ public void registerContentTypeBinding(IContentType contentType, String scopeName) {
+ pluginCache.registerContentTypeBinding(contentType, scopeName);
}
@Override
diff --git a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarCache.java b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarCache.java
index ecf2e1f2b..51d8a7cc8 100644
--- a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarCache.java
+++ b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarCache.java
@@ -14,9 +14,12 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.stream.Collectors;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.tm4e.registry.IGrammarDefinition;
/**
@@ -27,7 +30,7 @@ public class GrammarCache {
private final Map definitions;
private final Map> injections;
- private final Map scopeNameBindings;
+ private final Map scopeNameBindings;
public GrammarCache() {
this.definitions = new HashMap<>();
@@ -101,23 +104,23 @@ public void registerInjection(String scopeName, String injectTo) {
/**
* Returns scope name bound with the given content type and null otherwise.
*
- * @param contentTypeId
+ * @param contentType
* @return scope name bound with the given content type and null otherwise.
*/
- public String getScopeNameForContentType(String contentTypeId) {
- return scopeNameBindings.get(contentTypeId);
+ public String getScopeNameForContentType(IContentType contentType) {
+ return scopeNameBindings.get(contentType);
}
- public String[] getContentTypesForScope(String scopeName) {
+ public List getContentTypesForScope(String scopeName) {
if (scopeName == null) {
- return null;
+ return List.of();
}
return scopeNameBindings.entrySet().stream().filter(map -> scopeName.equals(map.getValue()))
- .map(map -> map.getKey()).collect(Collectors.toList()).toArray(new String[0]);
+ .map(Entry::getKey).collect(Collectors.toList());
}
- public void registerContentTypeBinding(String contentTypeId, String scopeName) {
- scopeNameBindings.put(contentTypeId, scopeName);
+ public void registerContentTypeBinding(IContentType contentType, String scopeName) {
+ scopeNameBindings.put(contentType, scopeName);
}
}
diff --git a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarRegistryManager.java b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarRegistryManager.java
index e68c4ace9..9ba7d5429 100644
--- a/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarRegistryManager.java
+++ b/org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/GrammarRegistryManager.java
@@ -13,6 +13,7 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.tm4e.registry.GrammarDefinition;
@@ -73,8 +74,13 @@ private void loadGrammarsFromExtensionPoints() {
super.registerInjection(scopeName, injectTo);
} else if (XMLConstants.SCOPE_NAME_CONTENT_TYPE_BINDING_ELT.equals(extensionName)) {
String contentTypeId = ce.getAttribute(XMLConstants.CONTENT_TYPE_ID_ATTR);
- String scopeName = ce.getAttribute(XMLConstants.SCOPE_NAME_ATTR);
- super.registerContentTypeBinding(contentTypeId, scopeName);
+ IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
+ if (contentType == null) {
+ Platform.getLog(getClass()).warn("No content-type found with id='" + contentTypeId + "', ignoring TM4E association.");
+ } else {
+ String scopeName = ce.getAttribute(XMLConstants.SCOPE_NAME_ATTR);
+ super.registerContentTypeBinding(contentType, scopeName);
+ }
}
}
}
diff --git a/org.eclipse.tm4e.repository/pom.xml b/org.eclipse.tm4e.repository/pom.xml
index 0410128fd..d903e9b9c 100644
--- a/org.eclipse.tm4e.repository/pom.xml
+++ b/org.eclipse.tm4e.repository/pom.xml
@@ -13,7 +13,7 @@
org.apache.maven.wagon
wagon-ftp
- 2.8
+ 3.4.3
diff --git a/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF b/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF
index 37d2a624a..c4426f2fd 100644
--- a/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF
+++ b/org.eclipse.tm4e.samples/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tm4e.samples;singleton:=true
-Bundle-Version: 0.3.5.qualifier
+Bundle-Version: 0.3.6.qualifier
Require-Bundle: org.eclipse.jface.text,
org.eclipse.core.runtime,
org.eclipse.ui,
diff --git a/org.eclipse.tm4e.samples/plugin.xml b/org.eclipse.tm4e.samples/plugin.xml
index 8771b462b..0389e2321 100644
--- a/org.eclipse.tm4e.samples/plugin.xml
+++ b/org.eclipse.tm4e.samples/plugin.xml
@@ -160,7 +160,6 @@
point="org.eclipse.ui.editors">
4.0.0
org.eclipse.tm4e.samples
eclipse-plugin
- 0.3.5-SNAPSHOT
+ 0.3.6-SNAPSHOT
org.eclipse
org.eclipse.tm4e
diff --git a/org.eclipse.tm4e.ui.tests/plugin.xml b/org.eclipse.tm4e.ui.tests/plugin.xml
index bc52e7e06..24219afb9 100644
--- a/org.eclipse.tm4e.ui.tests/plugin.xml
+++ b/org.eclipse.tm4e.ui.tests/plugin.xml
@@ -20,6 +20,13 @@
name="Test Content Type for TM4E (typescipt)"
priority="normal">
+
+
diff --git a/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/RegistryTest.java b/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/RegistryTest.java
index 09cd6e9d2..87fbde3c1 100644
--- a/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/RegistryTest.java
+++ b/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/RegistryTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015-2017 Angelo ZERR.
+ * Copyright (c) 2015-2021 Angelo ZERR.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -26,4 +26,11 @@ public void testGrammarRegistered() {
IGrammar grammar = TMEclipseRegistryPlugin.getGrammarRegistryManager().getGrammarFor(new IContentType[] { contentType });
Assertions.assertNotNull(grammar);
}
+
+ @Test
+ public void testThemeAppliesToSubtypes() {
+ IContentType contentType = Platform.getContentTypeManager().getContentType("org.eclipse.tm4e.ui.tests.testContentType.child");
+ IGrammar grammar = TMEclipseRegistryPlugin.getGrammarRegistryManager().getGrammarFor(new IContentType[] { contentType });
+ Assertions.assertNotNull(grammar);
+ }
}
diff --git a/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/Command.java b/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/Command.java
index 2bd11eaaf..bd33112df 100644
--- a/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/Command.java
+++ b/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/Command.java
@@ -17,7 +17,6 @@ public abstract class Command implements ICommand {
private final String name;
private String styleRanges;
- private Integer line;
private boolean done;
public Command(String name) {
diff --git a/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/StyleRangesCollector.java b/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/StyleRangesCollector.java
index c7832f665..f343ee66d 100644
--- a/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/StyleRangesCollector.java
+++ b/org.eclipse.tm4e.ui.tests/src/test/java/org/eclipse/tm4e/ui/internal/text/StyleRangesCollector.java
@@ -23,7 +23,6 @@
public class StyleRangesCollector implements ITMPresentationReconcilerListener {
- private ITextViewer viewer;
private IDocument document;
private Command command;
private Integer waitForToLineNumber;
@@ -39,13 +38,11 @@ public StyleRangesCollector() {
@Override
public void install(ITextViewer viewer, IDocument document) {
- this.viewer = viewer;
this.document = document;
}
@Override
public void uninstall() {
- this.viewer = null;
this.document = null;
}
diff --git a/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF b/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF
index c2164afa1..9ebf3cd00 100644
--- a/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tm4e.ui;singleton:=true
-Bundle-Version: 0.4.2.qualifier
+Bundle-Version: 0.5.0.qualifier
Require-Bundle: org.eclipse.tm4e.core,
org.eclipse.jface.text,
org.eclipse.core.runtime,
diff --git a/org.eclipse.tm4e.ui/pom.xml b/org.eclipse.tm4e.ui/pom.xml
index 11aa5462a..d93101e23 100644
--- a/org.eclipse.tm4e.ui/pom.xml
+++ b/org.eclipse.tm4e.ui/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.eclipse.tm4e.ui
eclipse-plugin
- 0.4.2-SNAPSHOT
+ 0.5.0-SNAPSHOT
org.eclipse
org.eclipse.tm4e
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/DocumentLineList.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/DocumentLineList.java
index b70955c77..5e0a86d6b 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/DocumentLineList.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/DocumentLineList.java
@@ -66,7 +66,6 @@ private void removeLine(DocumentEvent event) throws BadLocationException {
@Override
public void documentChanged(DocumentEvent event) {
- IDocument document = event.getDocument();
try {
int startLine = DocumentHelper.getStartLine(event);
if (!DocumentHelper.isRemove(event)) {
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java
index cb3c8c964..a1a1a1412 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java
@@ -267,8 +267,7 @@ private void fillGeneralTab(String scopeName) {
private void fillContentTypeTab(String scopeName) {
// Load the content type binding for the given grammar
- String[] contentTypes = grammarRegistryManager.getContentTypesForScope(scopeName);
- contentTypesWidget.setInput(contentTypes);
+ contentTypesWidget.setInput(grammarRegistryManager.getContentTypesForScope(scopeName));
}
private IThemeAssociation fillThemeTab(IGrammarDefinition definition) {
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/text/TMPresentationReconcilerTestGenerator.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/text/TMPresentationReconcilerTestGenerator.java
index 7eb1ffa39..b654f665a 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/text/TMPresentationReconcilerTestGenerator.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/text/TMPresentationReconcilerTestGenerator.java
@@ -18,7 +18,6 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.swt.custom.StyleRange;
import org.eclipse.tm4e.ui.text.ITMPresentationReconcilerListener;
public class TMPresentationReconcilerTestGenerator
@@ -155,17 +154,6 @@ public void uninstall() {
}
- private String toString(StyleRange[] ranges) {
- if (ranges == null) {
- return "";
- }
- StringBuilder s = new StringBuilder();
- for (StyleRange range : ranges) {
- s.append(range);
- }
- return s.toString();
- }
-
@Override
public void colorize(TextPresentation presentation, Throwable e) {
// Command command = commands.get(commands.size() - 1);
@@ -187,10 +175,6 @@ private void write(String s) {
write(s, false);
}
- private void write(int i) {
- write(String.valueOf(i), false);
- }
-
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java
index f51687ddd..43c68e4e0 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015-2017 Angelo ZERR.
+ * Copyright (c) 2015, 2021 Angelo ZERR and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -18,9 +18,11 @@
import java.util.Map;
import java.util.stream.Collectors;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.tm4e.ui.themes.ITheme;
import org.eclipse.tm4e.ui.themes.IThemeAssociation;
import org.eclipse.tm4e.ui.themes.IThemeManager;
+import org.eclipse.tm4e.ui.themes.ITokenProvider;
import org.eclipse.tm4e.ui.themes.ThemeAssociation;
import org.eclipse.tm4e.ui.utils.PreferenceUtils;
@@ -139,4 +141,9 @@ public IThemeAssociation[] getAllThemeAssociations() {
return associations.toArray(new IThemeAssociation[associations.size()]);
}
+ @Override
+ public ITokenProvider getThemeForScope(String scopeName, RGB background) {
+ return getThemeForScope(scopeName, 0.299 * background.red + 0.587 * background.green + 0.114 * background.blue < 128);
+ }
+
}
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/BaseThemeAssociationRegistry.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/BaseThemeAssociationRegistry.java
index a806a2c79..60f816bcb 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/BaseThemeAssociationRegistry.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/BaseThemeAssociationRegistry.java
@@ -51,26 +51,6 @@ public void register(IThemeAssociation association) {
allAssociations.clear();
}
- private void register(IThemeAssociation association, String eclipseThemeId) {
- List associations = eclipseThemeIds.get(eclipseThemeId);
- if (associations == null) {
- associations = new ArrayList<>();
- eclipseThemeIds.put(eclipseThemeId, associations);
- }
- /*if (association.isDefault()) {
- // remove the default from the list
- for (IThemeAssociation a : associations) {
- if (a.isDefault()) {
- a.setDefault(false);
- }
- }
- }*/
-
- if (!associations.contains(association)) {
- associations.add(association);
- }
- }
-
public void unregister(IThemeAssociation association) {
//String eclipseThemeId = association.getEclipseThemeId();
/*if (association.isDefault()) {
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/ThemeManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/ThemeManager.java
index f6f2cc732..e2e78db22 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/ThemeManager.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/ThemeManager.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015-2017 Angelo ZERR.
+ * Copyright (c) 2015, 2021 Angelo ZERR and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/widgets/TMViewer.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/widgets/TMViewer.java
index 9815a948c..1dbd8cc4a 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/widgets/TMViewer.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/widgets/TMViewer.java
@@ -67,7 +67,7 @@ public void setGrammar(IGrammar grammar) {
}
public void setTheme(ITheme theme) {
- reconciler.setThemeId(theme.getId());
+ reconciler.setTheme(theme);
StyledText styledText = getTextWidget();
styledText.setForeground(null);
styledText.setBackground(null);
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/text/TMPresentationReconciler.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/text/TMPresentationReconciler.java
index 998c2ce89..e9168969d 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/text/TMPresentationReconciler.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/text/TMPresentationReconciler.java
@@ -9,6 +9,7 @@
* Contributors:
* Angelo Zerr - initial API and implementation
* Pierre-Yves B. - Issue #220 Switch to theme only works once for open editor
+ * IBM Corporation Gerald Mitchell - bug fix
*/
package org.eclipse.tm4e.ui.text;
@@ -228,7 +229,7 @@ public void inputDocumentChanged(IDocument oldDocument, IDocument newDocument) {
if (localGrammar != null) {
String scopeName = localGrammar.getScopeName();
if (tokenProvider == null) {
- tokenProvider = TMUIPlugin.getThemeManager().getThemeForScope(scopeName);
+ tokenProvider = TMUIPlugin.getThemeManager().getThemeForScope(scopeName, viewer.getTextWidget().getBackground().getRGB());
}
if (tokenProvider != null) {
applyThemeEditor();
@@ -449,15 +450,6 @@ public void setTheme(final ITokenProvider newTheme) {
}
}
- /**
- * Force the TextMate theme id to use for the editor.
- *
- * @param themeId
- */
- public void setThemeId(String themeId) {
- setTheme(TMUIPlugin.getThemeManager().getThemeById(themeId));
- }
-
@Override
public void install(ITextViewer viewer) {
Assert.isNotNull(viewer);
@@ -755,14 +747,22 @@ public static TMPresentationReconciler getTMPresentationReconciler(ITextViewer t
Field field = SourceViewer.class.getDeclaredField("fPresentationReconciler");
if (field != null) {
field.setAccessible(true);
- IPresentationReconciler presentationReconciler = (IPresentationReconciler) field.get(textViewer);
+ Object presentationReconciler = field.get(textViewer);
+ //field is IPresentationRecounciler, looking for TMPresentationReconciler implementation
return presentationReconciler instanceof TMPresentationReconciler
? (TMPresentationReconciler) presentationReconciler
: null;
}
- } catch (Exception e) {
+ } catch (SecurityException | NoSuchFieldException e) {
+ // if SourceViewer class no longer has fPresentationReconciler or changes access level
TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
- }
+ } catch (IllegalArgumentException | IllegalAccessException | NullPointerException | ExceptionInInitializerError iae) {
+ //This should not be logged as an error. This is an expected possible outcome of field.get(textViewer).
+ //The method assumes ITextViewer is actually ISourceViewer, and specifically the SourceViewer implementation
+ // that was available at the current build. This code also works with any implementation that follows the
+ // internal structure if also an ITextViewer.
+ //If these assumptions are false, the method should return null. Logging causes repeat noise.
+ }
return null;
}
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/IThemeManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/IThemeManager.java
index d334486b7..20e09c006 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/IThemeManager.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/themes/IThemeManager.java
@@ -11,6 +11,7 @@
*/
package org.eclipse.tm4e.ui.themes;
+import org.eclipse.swt.graphics.RGB;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -131,4 +132,12 @@ public interface IThemeManager {
boolean isDarkEclipseTheme();
boolean isDarkEclipseTheme(String eclipseThemeId);
+
+ /**
+ *
+ * @param scopeName
+ * @param background
+ * @return the theme that will fit best for the defined background color
+ */
+ ITokenProvider getThemeForScope(String scopeName, RGB background);
}
diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/utils/ContentTypeHelper.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/utils/ContentTypeHelper.java
index 470420cea..eff03af33 100644
--- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/utils/ContentTypeHelper.java
+++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/utils/ContentTypeHelper.java
@@ -1,9 +1,9 @@
/**
* Copyright (c) 2015-2017 Angelo ZERR.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -13,6 +13,9 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
@@ -23,6 +26,7 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
@@ -97,37 +101,29 @@ private static ContentTypeInfo findContentTypesFromFileBuffers(IDocument documen
private static ContentTypeInfo getContentTypes(ITextFileBuffer buffer) throws CoreException {
try {
String fileName = buffer.getFileStore().getName();
+ Collection contentTypes = new LinkedHashSet<>();
+ IContentType bufferContentType = buffer.getContentType();
+ if (bufferContentType != null) {
+ contentTypes.add(bufferContentType);
+ }
if (buffer.isDirty()) {
// Buffer is dirty (content of the filesystem is not synch with
// the editor content), use IDocument content.
- InputStream input = null;
- try {
- input = new DocumentInputStream(buffer.getDocument());
- IContentType[] contentTypes = Platform.getContentTypeManager().findContentTypesFor(input, fileName);
- if (contentTypes != null) {
- return new ContentTypeInfo(fileName, contentTypes);
- }
- } finally {
- try {
- if (input != null)
- input.close();
- } catch (IOException x) {
+ try (InputStream input = new DocumentInputStream(buffer.getDocument())){
+ IContentType[] contentTypesForInput = Platform.getContentTypeManager().findContentTypesFor(input, fileName);
+ if (contentTypesForInput != null) {
+ contentTypes.addAll(Arrays.asList(contentTypesForInput));
+ return new ContentTypeInfo(fileName, contentTypes.toArray(IContentType[]::new));
}
}
}
// Buffer is synchronized with filesystem content
- InputStream contents = null;
- try {
- contents = getContents(buffer);
- return new ContentTypeInfo(fileName,
- Platform.getContentTypeManager().findContentTypesFor(contents, fileName));
+ try (InputStream contents = getContents(buffer)){
+ contentTypes.addAll(Arrays.asList(Platform.getContentTypeManager().findContentTypesFor(contents, fileName)));
+ return new ContentTypeInfo(fileName, contentTypes.toArray(IContentType[]::new));
} catch (Throwable e) {
return null;
- } finally {
- if (contents != null) {
- contents.close();
- }
}
} catch (IOException x) {
x.printStackTrace();
@@ -143,10 +139,13 @@ private static ContentTypeInfo getContentTypes(ITextFileBuffer buffer) throws Co
* @throws CoreException
*/
private static InputStream getContents(ITextFileBuffer buffer) throws CoreException {
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = workspaceRoot.getFile(buffer.getLocation());
- if (file.exists() && buffer.isSynchronized()) {
- return file.getContents();
+ IPath path = buffer.getLocation();
+ if (path != null) {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IFile file = workspaceRoot.getFile(path);
+ if (file.exists() && buffer.isSynchronized()) {
+ return file.getContents();
+ }
}
return buffer.getFileStore().openInputStream(EFS.NONE, null);
}
diff --git a/pom.xml b/pom.xml
index 247c1a46c..93a59b253 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
UTF-8
- 2.4.0
+ 2.5.0
../target/jacoco.exec
scm:git:https://github.com/eclipse/tm4e.git
true
@@ -61,7 +61,6 @@
true
p2
- true
consider
@@ -206,7 +205,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.2.0
+ 3.3.1
true
@@ -214,7 +213,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.6
+ 0.8.7
prepare-agent
diff --git a/target-platform/tm4e-target.target b/target-platform/tm4e-target.target
index f703f4bfc..6b50e5689 100644
--- a/target-platform/tm4e-target.target
+++ b/target-platform/tm4e-target.target
@@ -7,7 +7,7 @@
-
+
@@ -21,7 +21,7 @@
-
+