...
 
Commits (7)
# Contributing to Eclipse Platform
Thanks for your interest in this project.
## Project description
Eclipse Platform defines the set of frameworks and common services that
collectively make up infrastructure required to support the use of Eclipse as a
component model, as a Rich Client Platform (RCP) and as a comprehensive tool
integration platform. These services and frameworks include a standard workbench
user interface model and portable native widget toolkit, a project model for
managing resources, automatic resource delta management for incremental
compilers and builders, language-independent debug infrastructure, and
infrastructure for distributed multi-user versioned resource management.
* https://projects.eclipse.org/projects/eclipse.platform
## Developer resources
Information regarding source code management, builds, coding standards, and
more.
* https://projects.eclipse.org/projects/eclipse.platform/developer
The project maintains the following source code repositories
* http://git.eclipse.org/c/platform/eclipse.platform.common.git
* http://git.eclipse.org/c/platform/eclipse.platform.debug.git
* http://git.eclipse.org/c/platform/eclipse.platform.git
* http://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git
* http://git.eclipse.org/c/platform/eclipse.platform.releng.buildtools.git
* http://git.eclipse.org/c/platform/eclipse.platform.releng.git
* http://git.eclipse.org/c/platform/eclipse.platform.resources.git
* http://git.eclipse.org/c/platform/eclipse.platform.runtime.git
* http://git.eclipse.org/c/platform/eclipse.platform.swt.git
* http://git.eclipse.org/c/platform/eclipse.platform.swt.binaries.git
* http://git.eclipse.org/c/platform/eclipse.platform.team.git
* http://git.eclipse.org/c/platform/eclipse.platform.text.git
* http://git.eclipse.org/c/platform/eclipse.platform.ua.git
* http://git.eclipse.org/c/platform/eclipse.platform.ui.git
* http://git.eclipse.org/c/platform/eclipse.platform.ui.tools.git
This project uses Bugzilla to track ongoing development and issues.
* Search for issues: https://eclipse.org/bugs/buglist.cgi?product=Platform
* Create a new report: https://eclipse.org/bugs/enter_bug.cgi?product=Platform
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/platform-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 Platform
This content is produced and maintained by the Eclipse Platform project.
* Project home: https://projects.eclipse.org/projects/eclipse.platform
## Trademarks
Eclipse Platform is a trademark 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/platform/eclipse.platform.common.git
* http://git.eclipse.org/c/platform/eclipse.platform.debug.git
* http://git.eclipse.org/c/platform/eclipse.platform.git
* http://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git
* http://git.eclipse.org/c/platform/eclipse.platform.releng.buildtools.git
* http://git.eclipse.org/c/platform/eclipse.platform.releng.git
* http://git.eclipse.org/c/platform/eclipse.platform.resources.git
* http://git.eclipse.org/c/platform/eclipse.platform.runtime.git
* http://git.eclipse.org/c/platform/eclipse.platform.swt.git
* http://git.eclipse.org/c/platform/eclipse.platform.swt.binaries.git
* http://git.eclipse.org/c/platform/eclipse.platform.team.git
* http://git.eclipse.org/c/platform/eclipse.platform.text.git
* http://git.eclipse.org/c/platform/eclipse.platform.ua.git
* http://git.eclipse.org/c/platform/eclipse.platform.ui.git
* http://git.eclipse.org/c/platform/eclipse.platform.ui.tools.git
\ No newline at end of file
eclipse-platform-text (4.10-1) unstable; urgency=medium
* New upstream release
- Refreshed the patch
- Depend on libeclipse-jface-java (>= 3.15)
- Depend on libswt-gtk-4-java (>= 4.10)
* Standards-Version updated to 4.3.0
-- Emmanuel Bourg <ebourg@apache.org> Fri, 28 Dec 2018 14:15:23 +0100
eclipse-platform-text (4.9-1) unstable; urgency=medium
* New upstream release
......
......@@ -15,7 +15,7 @@ Build-Depends:
libeclipse-core-jobs-java,
libeclipse-core-resources-java,
libeclipse-core-runtime-java,
libeclipse-jface-java,
libeclipse-jface-java (>= 3.15),
libeclipse-ltk-core-refactoring-java,
libeclipse-ltk-ui-refactoring-java,
libeclipse-osgi-java,
......@@ -26,9 +26,9 @@ Build-Depends:
libequinox-preferences-java,
libequinox-registry-java,
libicu4j-java,
libswt-gtk-4-java (>= 4.8),
libswt-gtk-4-java (>= 4.10),
eclipse-debian-helper
Standards-Version: 4.2.1
Standards-Version: 4.3.0
Vcs-Git: https://salsa.debian.org/java-team/eclipse-platform-text.git
Vcs-Browser: https://salsa.debian.org/java-team/eclipse-platform-text
Homepage: http://www.eclipse.org/eclipse/platform-text/
......@@ -55,14 +55,14 @@ Architecture: all
Depends:
${misc:Depends},
${bundle:Depends},
libeclipse-jface-java,
libeclipse-jface-java (>= 3.15),
libeclipse-core-commands-java,
libeclipse-core-jobs-java,
libeclipse-core-runtime-java,
libequinox-common-java,
libequinox-preferences-java,
libicu4j-java,
libswt-gtk-4-java (>= 4.8)
libswt-gtk-4-java (>= 4.10)
Description: Eclipse JFace Text
Eclipse Platform Text is part of the Platform UI project and provides
the basic building blocks for text and text editors within Eclipse and
......
......@@ -3,7 +3,7 @@ Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
@@ -185,8 +185,10 @@
@@ -220,8 +220,10 @@
return 0;
}
});
......
......@@ -14,7 +14,7 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.core</groupId>
......
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.filebuffers; singleton:=true
Bundle-Version: 3.6.300.qualifier
Bundle-Version: 3.6.400.qualifier
Bundle-Activator: org.eclipse.core.internal.filebuffers.FileBuffersPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
......
......@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.platform.text</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.filebuffers</artifactId>
<version>3.6.300-SNAPSHOT</version>
<version>3.6.400-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
......@@ -45,7 +45,7 @@
<element name="factory">
<annotation>
<documentation>
The specification of a annotation model factory. In order to find a factory for a given file the attributes of each factory specification are consulted in the following sequence: contentTypeId, fileNames, extensions. If multiple, equally specific factory specifications are found for a given file it is not specified which factory is used.
The specification of an annotation model factory. In order to find a factory for a given file the attributes of each factory specification are consulted in the following sequence: contentTypeId, fileNames, extensions. If multiple, equally specific factory specifications are found for a given file it is not specified which factory is used.
</documentation>
</annotation>
<complexType>
......
......@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.platform.text</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.jface.text.examples</artifactId>
......
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jface.text.tests
Bundle-Version: 3.11.300.qualifier
Bundle-Version: 3.11.400.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
......@@ -10,6 +10,7 @@ Export-Package:
org.eclipse.jface.text.tests.reconciler,
org.eclipse.jface.text.tests.rules,
org.eclipse.jface.text.tests.source,
org.eclipse.jface.text.tests.templates.persistence,
org.eclipse.jface.text.tests.util
Require-Bundle:
org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
......
......@@ -14,12 +14,12 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.jface</groupId>
<artifactId>org.eclipse.jface.text.tests</artifactId>
<version>3.11.300-SNAPSHOT</version>
<version>3.11.400-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
......
......@@ -24,6 +24,7 @@ import org.eclipse.jface.text.tests.rules.FastPartitionerTest;
import org.eclipse.jface.text.tests.rules.ScannerColumnTest;
import org.eclipse.jface.text.tests.rules.WordRuleTest;
import org.eclipse.jface.text.tests.source.LineNumberRulerColumnTest;
import org.eclipse.jface.text.tests.templates.persistence.TemplatePersistenceDataTest;
/**
......@@ -49,7 +50,9 @@ import org.eclipse.jface.text.tests.source.LineNumberRulerColumnTest;
DefaultPartitionerZeroLengthTest.class,
FastPartitionerTest.class,
ScannerColumnTest.class,
WordRuleTest.class
WordRuleTest.class,
TemplatePersistenceDataTest.class,
})
public class JFaceTextTestSuite {
// see @SuiteClasses
......
/*******************************************************************************
* Copyright (c) 2018 SAP SE 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:
* SAP SE - initial API and implementation
*******************************************************************************/
package org.eclipse.jface.text.tests.templates.persistence;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
@SuppressWarnings("deprecation")
public class TemplatePersistenceDataTest {
@Test
public void testEquals() throws Exception {
Template template= new Template();
org.eclipse.text.templates.TemplatePersistenceData persistenceData1= new org.eclipse.text.templates.TemplatePersistenceData(template, false);
org.eclipse.text.templates.TemplatePersistenceData persistenceData2= new org.eclipse.text.templates.TemplatePersistenceData(template, false);
TemplatePersistenceData deprPersistenceData1A= new TemplatePersistenceData(persistenceData1);
TemplatePersistenceData deprPersistenceData1B= new TemplatePersistenceData(persistenceData1);
TemplatePersistenceData deprPersistenceData1X= new TemplatePersistenceData(deprPersistenceData1A);
TemplatePersistenceData deprPersistenceData2= new TemplatePersistenceData(persistenceData2);
TemplatePersistenceData deprPersistenceData3= new TemplatePersistenceData(template, false);
// deprecated type <-> deprecated type
assertTrue(deprPersistenceData1A.equals(deprPersistenceData1B));
assertFalse(deprPersistenceData1A.equals(deprPersistenceData2));
assertFalse(deprPersistenceData1A.equals(deprPersistenceData3));
assertTrue(deprPersistenceData3.equals(deprPersistenceData3));
assertTrue(deprPersistenceData1X.equals(deprPersistenceData1A));
// super type <-> super type
assertTrue(persistenceData1.equals(persistenceData1));
assertFalse(persistenceData1.equals(persistenceData2));
// super type <-> deprecated type
assertTrue(persistenceData1.equals(deprPersistenceData1A));
assertTrue(deprPersistenceData1A.equals(persistenceData1));
assertFalse(persistenceData1.equals(deprPersistenceData2));
assertFalse(deprPersistenceData2.equals(persistenceData1));
}
}
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jface.text
Bundle-Version: 3.14.0.qualifier
Bundle-Version: 3.15.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
......@@ -34,9 +34,9 @@ Export-Package:
org.eclipse.jface.text.templates.persistence
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.text;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.text;bundle-version="[3.8.0,4.0.0)";visibility:=reexport,
org.eclipse.swt;bundle-version="[3.107.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.5.0,4.0.0)"
org.eclipse.jface;bundle-version="[3.15.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ibm.icu.text
Automatic-Module-Name: org.eclipse.jface.text
......@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.platform.text</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.9.0-SNAPSHOT</version>
<version>4.10.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jface</groupId>
<artifactId>org.eclipse.jface.text</artifactId>
<version>3.14.0-SNAPSHOT</version>
<version>3.15.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
/**
* Copyright (c) 2017 Angelo ZERR.
*
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
......@@ -20,14 +20,21 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.osgi.framework.Bundle;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
......@@ -89,6 +96,10 @@ public class CodeMiningManager implements Runnable {
* @param codeMiningProviders the codemining providers.
*/
public void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders) {
cancel();
if (fCodeMiningProviders != null) {
fCodeMiningProviders.stream().forEach(ICodeMiningProvider::dispose);
}
fCodeMiningProviders= Arrays.asList(codeMiningProviders);
}
......@@ -97,6 +108,9 @@ public class CodeMiningManager implements Runnable {
*/
public void uninstall() {
cancel();
if (fInlinedAnnotationSupport != null) {
fInlinedAnnotationSupport.updateAnnotations(Collections.emptySet());
}
}
/**
......@@ -143,6 +157,22 @@ public class CodeMiningManager implements Runnable {
}
}
private static void logCodeMiningProviderException(Throwable e) {
if (e != null && (e instanceof CancellationException || (e.getCause() != null && e.getCause() instanceof CancellationException))) {
return;
}
String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$
Bundle plugin= Platform.getBundle(PLUGIN_ID);
if (plugin != null) {
// In OSGi context, uses Platform Text log
ILog log= Platform.getLog(plugin);
log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, e.getMessage(), e));
} else {
// In java main context, print stack trace
System.err.println("Error while code mining process: " + e.getMessage()); //$NON-NLS-1$
}
}
/**
* Return the list of {@link CompletableFuture} which provides the list of {@link ICodeMining}
* for the given <code>viewer</code> by using the given providers.
......@@ -156,7 +186,12 @@ public class CodeMiningManager implements Runnable {
private static CompletableFuture<List<? extends ICodeMining>> getCodeMinings(ITextViewer viewer,
List<ICodeMiningProvider> providers, IProgressMonitor monitor) {
List<CompletableFuture<List<? extends ICodeMining>>> com= providers.stream()
.map(provider -> provider.provideCodeMinings(viewer, monitor)).filter(c -> c != null)
.map(provider -> provider.provideCodeMinings(viewer, monitor))
.filter(c -> c != null)
.map(future -> future.exceptionally(e -> {
logCodeMiningProviderException(e);
return Collections.emptyList();
}))
.collect(Collectors.toList());
return CompletableFuture.allOf(com.toArray(new CompletableFuture[com.size()])).thenApply(
v -> com.stream().map(CompletableFuture::join).flatMap(l -> l.stream()).collect(Collectors.toList()));
......
......@@ -32,6 +32,7 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.internal.text.InformationControlReplacer;
import org.eclipse.jface.internal.text.InternalAccessor;
import org.eclipse.jface.util.Geometry;
import org.eclipse.jface.util.Util;
import org.eclipse.jface.text.ITextViewerExtension8.EnrichMode;
......@@ -1077,41 +1078,7 @@ abstract public class AbstractInformationControlManager {
center= Geometry.centerPoint(area);
else
center= Geometry.centerPoint(Geometry.getExtrudedEdge(area, 0, anchor.getSWTFlag()));
return getClosestMonitor(fSubjectControl.getDisplay(), Geometry.createRectangle(center, new Point(0, 0)));
}
/**
* Copied from org.eclipse.jface.window.Window. Returns the monitor whose client area contains
* the given point. If no monitor contains the point, returns the monitor that is closest to the
* point. If this is ever made public, it should be moved into a separate utility class.
*
* @param display the display to search for monitors
* @param rectangle the rectangle to find the closest monitor for (display coordinates)
* @return the monitor closest to the given point
* @since 3.3
*/
private Monitor getClosestMonitor(Display display, Rectangle rectangle) {
int closest = Integer.MAX_VALUE;
Point toFind= Geometry.centerPoint(rectangle);
Monitor[] monitors = display.getMonitors();
Monitor result = monitors[0];
for (Monitor current : monitors) {
Rectangle clientArea = current.getClientArea();
if (clientArea.contains(toFind)) {
return current;
}
int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
if (distance < closest) {
closest = distance;
result = current;
}
}
return result;
return Util.getClosestMonitor(fSubjectControl.getDisplay(), center);
}
/**
......@@ -1232,7 +1199,7 @@ abstract public class AbstractInformationControlManager {
* @since 3.4
*/
void cropToClosestMonitor(Rectangle bounds) {
Rectangle monitorBounds= getClosestMonitor(fSubjectControl.getDisplay(), bounds).getClientArea();
Rectangle monitorBounds= Util.getClosestMonitor(fSubjectControl.getDisplay(), Geometry.centerPoint(bounds)).getClientArea();
bounds.intersect(monitorBounds);
}
......
......@@ -15,6 +15,7 @@
package org.eclipse.jface.text;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.fieldassist.ContentProposal;
import org.eclipse.jface.fieldassist.IContentProposal;
......@@ -54,11 +55,11 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
/**
* The high-priority proposals.
*/
private final ArrayList<ContentProposal> fPriorityProposals;
private final List<ContentProposal> fPriorityProposals;
/**
* The low-priority proposals.
*/
private final ArrayList<ContentProposal> fProposals;
private final List<ContentProposal> fProposals;
/**
* <code>true</code> iff <code>fExpression</code> ends with an open escape.
*/
......
......@@ -72,7 +72,8 @@ public interface IFindReplaceTarget {
int findAndSelect(int widgetOffset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord);
/**
* Returns the currently selected range of characters as a offset and length in widget coordinates.
* Returns the currently selected range of characters as an offset and length in widget
* coordinates.
*
* @return the currently selected character range in widget coordinates
*/
......
......@@ -305,12 +305,21 @@ public final class JFaceTextUtil {
* be vertically scrolled, <code>false</code> otherwise
*/
public static boolean isShowingEntireContents(StyledText widget) {
if (widget.getTopPixel() != 0) // more efficient shortcut
if (widget.getTopPixel() != 0) {
// more efficient shortcut
return false;
}
int lastVisiblePixel= computeLastVisiblePixel(widget);
int lastPossiblePixel= widget.getLinePixel(widget.getLineCount());
return lastPossiblePixel <= lastVisiblePixel;
int bottom= widget.getLineIndex(lastVisiblePixel);
if (bottom + 1 < widget.getLineCount()) {
// There's definitely more lines below
return false;
}
// Check whether the last line is fully visible
int bottomLastPixel= getLinePixel(widget, bottom + 1) - 1;
return bottomLastPixel <= lastVisiblePixel;
}
/**
......
......@@ -15,8 +15,10 @@ package org.eclipse.jface.text.contentassist;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
......@@ -33,6 +35,9 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
import org.eclipse.jface.text.BadLocationException;
......@@ -341,11 +346,18 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
List<CompletableFuture<List<ICompletionProposal>>> futures = new ArrayList<>(processors.size());
for (IContentAssistProcessor processor : processors) {
futures.add(CompletableFuture.supplyAsync(() -> {
ICompletionProposal[] proposals= processor.computeCompletionProposals(fViewer, invocationOffset);
if (proposals == null) {
return Collections.emptyList();
}
return Arrays.asList(proposals);
final Collection<List<ICompletionProposal>> result= new LinkedList<>();
SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws Exception {
ICompletionProposal[] proposals= processor.computeCompletionProposals(fViewer, invocationOffset);
if (proposals == null) {
result.add(Collections.emptyList());
}
result.add(Arrays.asList(proposals));
}
});
return result.iterator().next();
}));
}
return futures;
......
......@@ -355,9 +355,10 @@ class CompletionProposalPopup implements IContentAssistListener {
int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
List<ICompletionProposal> proposals= null;
DocumentEvent event= null;
try {
if (offset > -1) {
DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
event= TextUtilities.mergeProcessedDocumentEvents(fDocumentEvents);
proposals= computeFilteredProposals(offset, event);
}
} catch (BadLocationException x) {
......@@ -368,8 +369,19 @@ class CompletionProposalPopup implements IContentAssistListener {
if (proposals != null && proposals.size() > 0)
setProposals(proposals, fIsFilteredSubset);
else
else {
hide();
if (fContentAssistant.isAutoActivation() && offset > 0 && event != null) {
try {
char charBeforeOffset= event.getDocument().getChar(offset - 1);
if (fContentAssistant.isAutoActivationTriggerChar(charBeforeOffset)) {
fContentAssistant.fireSessionBeginEvent(true);
showProposals(true);
}
} catch (BadLocationException e) {
}
}
}
}
};
/**
......@@ -1369,16 +1381,18 @@ class CompletionProposalPopup implements IContentAssistListener {
return false;
default:
ICompletionProposal p= getSelectedProposal();
if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension t= (ICompletionProposalExtension) p;
char[] triggers= t.getTriggerCharacters();
if (contains(triggers, key)) {
e.doit= false;
hide();
insertProposal(p, key, e.stateMask, fContentAssistSubjectControlAdapter.getSelectedRange().x);
if (fContentAssistant.isCompletionProposalTriggerCharsEnabled()) {
ICompletionProposal p= getSelectedProposal();
if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension t= (ICompletionProposalExtension) p;
char[] triggers= t.getTriggerCharacters();
if (contains(triggers, key)) {
e.doit= false;
hide();
insertProposal(p, key, e.stateMask, fContentAssistSubjectControlAdapter.getSelectedRange().x);
}
}
}
}
}
return true;
......
......@@ -323,7 +323,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
// Only act on characters that are trigger candidates. This
// avoids computing the model selection on every keystroke
if (computeAllAutoActivationTriggers().indexOf(e.character) < 0) {
if (!isAutoActivationTriggerChar(e.character)) {
stop();
return;
}
......@@ -935,7 +935,8 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private Closer fCloser;
LayoutManager fLayoutManager;
private AutoAssistListener fAutoAssistListener;
AutoAssistListener fAutoAssistListener;
private InternalListener fInternalListener;
private CompletionProposalPopup fProposalPopup;
private ContextInformationPopup fContextInfoPopup;
......@@ -1055,6 +1056,8 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*/
private boolean fAsynchronous;
private boolean fCompletionProposalTriggerCharsEnabled= true;
/**
* Creates a new content assistant. The content assistant is not automatically activated,
* overlays the completion proposals with context information list if necessary, and shows the
......@@ -1181,27 +1184,26 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
/**
* Computes the sorted set of all auto activation trigger characters.
*
* @return the sorted set of all auto activation trigger characters
* @since 3.1
* @return whether the given char is an auto-activation trigger char
* @since 3.15
*/
private String computeAllAutoActivationTriggers() {
boolean isAutoActivationTriggerChar(char c) {
if (fProcessors == null)
return ""; //$NON-NLS-1$
return false;
StringBuilder buf= new StringBuilder(5);
for (Set<IContentAssistProcessor> processorsForContentType : fProcessors.values()) {
for (IContentAssistProcessor processor : processorsForContentType) {
char[] triggers= processor.getCompletionProposalAutoActivationCharacters();
if (triggers != null)
buf.append(triggers);
if (triggers != null && new String(triggers).indexOf(c) >= 0) {
return true;
}
triggers= processor.getContextInformationAutoActivationCharacters();
if (triggers != null)
buf.append(triggers);
if (triggers != null && new String(triggers).indexOf(c) >= 0) {
return true;
}
}
}
return buf.toString();
return false;
}
/**
......@@ -2757,4 +2759,32 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
fProposalPopup.setSorter(fSorter);
}
}
/**
* Returns whether completion trigger char are enabled. If false, completion proposal trigger
* chars are ignored and only Enter key can be used to select a proposal.
*
* @return whether completion trigger char are enabled.
* @see ICompletionProposalExtension#getTriggerCharacters()
* @since 3.15
*/
public boolean isCompletionProposalTriggerCharsEnabled() {
return fCompletionProposalTriggerCharsEnabled;
}
/**
* Set whether completion trigger chars are enabled. If set to false, completion proposal
* trigger chars are ignored and only Enter key can be used to select a proposal.
*
* @param enable whether current content assistant should consider completion trigger chars.
* @see ICompletionProposalExtension#getTriggerCharacters()
* @since 3.15
*/
public void enableCompletionProposalTriggerChars(boolean enable) {
fCompletionProposalTriggerCharsEnabled= enable;
}
boolean isAutoActivation() {
return fIsAutoActivated;
}
}
......@@ -802,13 +802,11 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
r.height= textBounds.height;
r.y = textBounds.y;
}
// adjust the annotation position at the bottom of the line if line height has custom line height
int defaultLineHeight= fCachedTextWidget.getLineHeight();
int lineHeight= fCachedTextWidget.getLineHeight(offset);
if (lineHeight > defaultLineHeight) {
int adjust= lineHeight - defaultLineHeight;
r.y+= adjust;
r.height-= adjust;
// adjust the annotation position at the bottom of the line if line height has custom vertical line indent
int verticalIndent= fCachedTextViewer.getTextWidget().getLineVerticalIndent(startLine);
if (verticalIndent > 0) {
r.y+= verticalIndent;
r.height-= verticalIndent;
}
if (r.y < dimension.y && fAnnotationAccessExtension != null) // annotation within visible area
fAnnotationAccessExtension.paint(annotation, gc, fCanvas, r);
......
......@@ -941,7 +941,8 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
}
int indentation= fIndentation[index];
int baselineBias= getBaselineBias(gc, widgetLine);
gc.drawString(s, indentation * fZoom / 100, (y + baselineBias) * fZoom / 100, true);
int verticalIndent= fCachedTextViewer.getTextWidget().getLineVerticalIndent(widgetLine);
gc.drawString(s, indentation * fZoom / 100, (y + baselineBias + verticalIndent) * fZoom / 100, true);
}
/**
......
......@@ -1267,11 +1267,6 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
@Override
public void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders) {
if (fCodeMiningProviders != null) {
for (ICodeMiningProvider contentMiningProvider : fCodeMiningProviders) {
contentMiningProvider.dispose();
}
}
boolean enable= codeMiningProviders != null && codeMiningProviders.length > 0;
fCodeMiningProviders= codeMiningProviders;
if (enable) {
......@@ -1299,7 +1294,9 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
fInlinedAnnotationSupport= new InlinedAnnotationSupport();
fInlinedAnnotationSupport.install(this, fAnnotationPainter);
}
fCodeMiningManager= new CodeMiningManager(this, fInlinedAnnotationSupport, fCodeMiningProviders);
if (fCodeMiningManager == null) {
fCodeMiningManager= new CodeMiningManager(this, fInlinedAnnotationSupport, fCodeMiningProviders);
}
// now trigger an update
updateCodeMinings();
}
......
......@@ -76,18 +76,11 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
*/
private static void draw(LineHeaderAnnotation annotation, GC gc, StyledText textWidget, int offset, int length,
Color color) {
StyleRange style= null;
try {
style= textWidget.getStyleRangeAtOffset(offset);
} catch (Exception e) {
return;
}
int line= textWidget.getLineAtOffset(offset);
if (isDeleted(annotation)) {
// When annotation is deleted, update metrics to null to remove extra spaces of the line header annotation.
if (style != null && style.metrics != null) {
style.metrics= null;
textWidget.setStyleRange(style);
}
if (textWidget.getLineVerticalIndent(line) > 0)
textWidget.setLineVerticalIndent(line, 0);
return;
}
if (gc != null) {
......@@ -96,63 +89,27 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
int x= bounds.x;
int y= bounds.y;
// Colorize line spacing area with the background of StyledText to avoid having highlighted line color
gc.setBackground(textWidget.getBackground());
Rectangle client= textWidget.getClientArea();
gc.fillRectangle(0, y, client.width, annotation.getHeight());
// Draw the line header annotation
annotation.setLocation(x, y);
annotation.draw(gc, textWidget, offset, length, color, x, y);
int height= annotation.getHeight();
if (height != 0) {
// The inline annotation replaces one character by taking a place width
// GlyphMetrics
// Here we need to redraw this first character because GlyphMetrics clip this
// character.
// FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
// START TO REMOVE
String s= textWidget.getText(offset, offset);
Point charBounds= gc.stringExtent(s);
int charWidth= charBounds.x;
int charHeight= charBounds.y;
annotation.setRedrawnCharacterWidth(charWidth);
annotation.setRedrawnCharacterHeight(charHeight);
// END TO REMOVE
StyleRange newStyle= updateStyle(annotation, style);
if (newStyle != null) {
textWidget.setStyleRange(newStyle);
return;
}
// FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
// START TO REMOVE
int charX= x + bounds.width - charWidth;
int charY= y + bounds.height - textWidget.getLineHeight();
if (style != null) {
if (style.background != null) {
gc.setBackground(style.background);
gc.fillRectangle(charX, charY, charWidth + 1, bounds.height);
}
if (style.foreground != null) {
gc.setForeground(style.foreground);
} else {
gc.setForeground(textWidget.getForeground());
if (height != textWidget.getLineVerticalIndent(line)) {
if (annotation.oldLine != -1 && annotation.oldLine < textWidget.getLineCount()) {
textWidget.setLineVerticalIndent(annotation.oldLine, 0);
}
gc.setFont(annotation.getFont(style.fontStyle));
textWidget.setLineVerticalIndent(line, height);
}
gc.drawString(s, charX, charY, true);
// END TO REMOVE
} else if (style != null && style.metrics != null && style.metrics.ascent != 0) {
// line header annotation had an height, reset it
style.metrics= null;
textWidget.setStyleRange(style);
annotation.oldLine= line;
return;
} else if (textWidget.getLineVerticalIndent(line) > 0) {
textWidget.setLineVerticalIndent(line, 0);
}
} else {
if (style != null && style.metrics != null) {
// Here GlyphMetrics ascent is done, the redraw of the full line width is done to avoid annotation clipping
if (textWidget.getLineVerticalIndent(line) > 0) {
// Here vertical indent is done, the redraw of the full line width is done to avoid annotation clipping
Rectangle bounds= textWidget.getTextBounds(offset, offset);
Rectangle client= textWidget.getClientArea();
textWidget.redraw(0, bounds.y, client.width, bounds.height, false);
......@@ -162,52 +119,6 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
}
}
/**
* Returns the style to apply with GlyphMetrics ascent only if needed.
*
* @param annotation the line header annotation
* @param style the current style and null otherwise.
* @return the style to apply with GlyphMetrics ascent only if needed.
*/
static StyleRange updateStyle(LineHeaderAnnotation annotation, StyleRange style) {
int width= annotation.getRedrawnCharacterWidth();
if (width == 0) {
// Update GlyphMetrics only when mining was already drawn
return null;
}
int height= annotation.getHeight();
if (height == 0) {
return null;
}
int fullHeight= height + annotation.getRedrawnCharacterHeight();
if (style == null) {
style= new StyleRange();
Position position= annotation.getPosition();
style.start= position.getOffset();
style.length= 1;
}
GlyphMetrics metrics= style.metrics;
if (!annotation.isMarkedDeleted()) {
if (metrics == null) {
metrics= new GlyphMetrics(fullHeight, 0, width);
} else {
if (metrics.ascent == fullHeight) {
return null;
}
/**
* We must create a new GlyphMetrics instance because comparison with similarTo used
* later in StyledText#setStyleRange will compare the same (modified) and won't
* realize an update happened.
*/
metrics= new GlyphMetrics(fullHeight, 0, width);
}
} else {
metrics= null;
}
style.metrics= metrics;
return style;
}
/**
* Draw the line content annotation inside line in the empty area computed by
* {@link GlyphMetrics}.
......@@ -236,16 +147,14 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
return;
}
if (gc != null) {
String s= textWidget.getText(offset, offset);
boolean isEndOfLine= ("\r".equals(s) || "\n".equals(s)); //$NON-NLS-1$ //$NON-NLS-2$
// Compute the location of the annotation
Rectangle bounds= textWidget.getTextBounds(offset, offset);
int x= bounds.x;
int x= bounds.x + (isEndOfLine ? bounds.width * 2 : 0);
int y= bounds.y;
// Get size of the character where GlyphMetrics width is added
String s= textWidget.getText(offset, offset);
Point charBounds= gc.stringExtent(s);
int charWidth= charBounds.x;
// When line text has line header annotation, there is a space on the top, adjust the y by using char height
y+= bounds.height - textWidget.getLineHeight();
......@@ -254,25 +163,35 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
annotation.draw(gc, textWidget, offset, length, color, x, y);
int width= annotation.getWidth();
if (width != 0) {
// FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
// START TO REMOVE
annotation.setRedrawnCharacterWidth(charWidth);
// END TO REMOVE
if (isEndOfLine) {
if (!gc.getClipping().contains(x, y)) {
// The draw of mining is not inside the gc clipping, redraw the area which contains the mining to draw.
Rectangle client= textWidget.getClientArea();
textWidget.redraw(x, y, client.width, bounds.height, false);
}
} else {
// Get size of the character where GlyphMetrics width is added
Point charBounds= gc.stringExtent(s);
int charWidth= charBounds.x;
// Annotation takes place, add GlyphMetrics width to the style
StyleRange newStyle= updateStyle(annotation, style);
if (newStyle != null) {
textWidget.setStyleRange(newStyle);
return;
}
// FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
// START TO REMOVE
annotation.setRedrawnCharacterWidth(charWidth);
// END TO REMOVE
// Annotation takes place, add GlyphMetrics width to the style
StyleRange newStyle= updateStyle(annotation, style);
if (newStyle != null) {
textWidget.setStyleRange(newStyle);
return;
}
// FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
// START TO REMOVE
// The inline annotation replaces one character by taking a place width
// GlyphMetrics
// Here we need to redraw this first character (if it's not a line delimiter) because GlyphMetrics clip this
// character.
if (!("\r".equals(s) || "\n".equals(s))) { //$NON-NLS-1$ //$NON-NLS-2$
// FIXME: remove this code when we need not redraw the character (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=531769)
// START TO REMOVE
// The inline annotation replaces one character by taking a place width
// GlyphMetrics
// Here we need to redraw this first character because GlyphMetrics clip this
// character.
int charX= x + bounds.width - charWidth;
int charY= y;
if (style != null) {
......@@ -309,7 +228,7 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
*/
static StyleRange updateStyle(LineContentAnnotation annotation, StyleRange style) {
int width= annotation.getWidth();
if (width == 0) {
if (width == 0 || annotation.getRedrawnCharacterWidth() == 0) {
return null;
}
int fullWidth= width + annotation.getRedrawnCharacterWidth();
......
......@@ -111,12 +111,6 @@ public class InlinedAnnotationSupport {
if (style != null) {
textPresentation.mergeStyleRange(style);
}
} else if (annotation instanceof LineHeaderAnnotation) {
LineHeaderAnnotation ann= (LineHeaderAnnotation) annotation;
StyleRange style= InlinedAnnotationDrawingStrategy.updateStyle(ann, null);
if (style != null) {
textPresentation.mergeStyleRange(style);
}
}
});
}
......
/**
* Copyright (c) 2017, 2018 Angelo ZERR.
*
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
......@@ -25,18 +25,17 @@ import org.eclipse.jface.text.source.ISourceViewer;
*/
public class LineHeaderAnnotation extends AbstractInlinedAnnotation {
private int redrawnCharacterHeight;
private int redrawnCharacterWidth;
int oldLine;
/**
* Line header annotation constructor.
*
* @param position the position where the annotation must be drawn.
* @param viewer the {@link ISourceViewer} where the annotation must be drawn.
* @param viewer the {@link ISourceViewer} where the annotation must be drawn.
*/
public LineHeaderAnnotation(Position position, ISourceViewer viewer) {
super(position, viewer);
oldLine= -1;
}
/**
......@@ -49,22 +48,6 @@ public class LineHeaderAnnotation extends AbstractInlinedAnnotation {
return styledText.getLineHeight();
}
int getRedrawnCharacterHeight() {
return redrawnCharacterHeight;
}
void setRedrawnCharacterHeight(int redrawnCharacterHeight) {
this.redrawnCharacterHeight= redrawnCharacterHeight;
}
int getRedrawnCharacterWidth() {
return redrawnCharacterWidth;
}
void setRedrawnCharacterWidth(int redrawnCharacterWidth) {
this.redrawnCharacterWidth= redrawnCharacterWidth;
}
@Override
boolean contains(int x, int y) {
return (x >= this.fX && y >= this.fY && y <= this.fY + getHeight());
......
......@@ -16,15 +16,15 @@ package org.eclipse.jface.text.templates;
import java.util.Iterator;
/**
* A registry for context types. Editor implementors will usually instantiate a
* registry and configure the context types available in their editor.
* A registry for context types. Editor implementors will usually instantiate a registry and
* configure the context types available in their editor.
* <p>
* In order to pick up templates contributed using the <code>org.eclipse.ui.editors.templates</code>
* extension point, use a <code>ContributionContextTypeRegistry</code>.
* </p>
*
* @since 3.0
* @deprecated See {@link ContextTypeRegistry} from org.eclipse.text
* @deprecated See {@link org.eclipse.text.templates.ContextTypeRegistry}
*/
@Deprecated
public class ContextTypeRegistry extends org.eclipse.text.templates.ContextTypeRegistry {
......
......@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jface.text.templates.persistence;
import java.util.UUID;
import org.eclipse.jface.text.templates.Template;
......@@ -33,7 +35,7 @@ import org.eclipse.jface.text.templates.Template;
@Deprecated
public class TemplatePersistenceData extends org.eclipse.text.templates.TemplatePersistenceData {
org.eclipse.text.templates.TemplatePersistenceData ref;
private final org.eclipse.text.templates.TemplatePersistenceData ref;
/**
* In some cases, we must continue to respect the deprecated TemplatePresistenceData
......@@ -45,96 +47,85 @@ public class TemplatePersistenceData extends org.eclipse.text.templates.Template
*/
public TemplatePersistenceData(org.eclipse.text.templates.TemplatePersistenceData data) {
super(data.getTemplate(), data.isEnabled(), data.getId()); // these are ignored
this.ref= data;
this.ref= data instanceof TemplatePersistenceData ? ((TemplatePersistenceData) data).ref : data; // no double wrapping
}
public TemplatePersistenceData(Template template, boolean enabled) {
super(template, enabled);
this(new org.eclipse.text.templates.TemplatePersistenceData(template, enabled));
}
public TemplatePersistenceData(Template template, boolean enabled, String id) {
super(template, enabled, id);
this(new org.eclipse.text.templates.TemplatePersistenceData(template, enabled, id));
}
@Override
public String getId() {
return (ref != null) ? ref.getId() : super.getId();
return ref.getId();
}
@Override
public boolean isDeleted() {
return (ref != null) ? ref.isDeleted() : super.isDeleted();
return ref.isDeleted();
}
@Override
public void setDeleted(boolean isDeleted) {
if (ref != null) {