From 2625f156ad3408c77e650f7387847a9533f4c4f3 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Mon, 6 Sep 2021 18:04:09 +0200 Subject: [PATCH 01/26] [RELEASE_NOTES] add date for 0.4.2 --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 4da812dff2b1c359dcf7fdd23bda1fe4b85ee3e1 Mon Sep 17 00:00:00 2001 From: Gerald Mitchell <55747427+GeraldMit@users.noreply.github.com> Date: Mon, 27 Sep 2021 10:05:23 -0400 Subject: [PATCH 02/26] Fixes: Issue #281 (#282) Remove error for textViewer not an instance of SourceViewer --- org.eclipse.tm4e.feature/feature.xml | 2 +- org.eclipse.tm4e.feature/pom.xml | 2 +- org.eclipse.tm4e.ui/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.ui/pom.xml | 2 +- .../tm4e/ui/text/TMPresentationReconciler.java | 15 ++++++++++++--- 5 files changed, 16 insertions(+), 7 deletions(-) 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.ui/META-INF/MANIFEST.MF b/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF index c2164afa1..41a24a0c4 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.4.3.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..bbdc06f1e 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.4.3-SNAPSHOT org.eclipse org.eclipse.tm4e 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..2ee1af6a4 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; @@ -755,14 +756,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; } From da136dab59526d3f878a02eea5e20d672f3da6ca Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Thu, 14 Oct 2021 11:47:21 +0200 Subject: [PATCH 03/26] Remove duplicated deps in MANIFEST/pom Since Tycho 2.4 does configure the test classpath directly with the dependencies from MANIFEST.MF + JUnit configuration and does run embedded tests with maven-surefire-plugin, we don't need to duplicate dependencies any more. Actually, duplicating dependencies can cause problems because of signatures not being available on all artifacts. --- org.eclipse.tm4e.core/pom.xml | 37 ------------------- .../pom.xml | 12 ------ 2 files changed, 49 deletions(-) diff --git a/org.eclipse.tm4e.core/pom.xml b/org.eclipse.tm4e.core/pom.xml index 8734ed670..1c56e603b 100644 --- a/org.eclipse.tm4e.core/pom.xml +++ b/org.eclipse.tm4e.core/pom.xml @@ -8,41 +8,4 @@ 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.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 - - From 81aa82225784e8d120f94e3562a7cec38d8795b5 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Wed, 13 Oct 2021 22:59:11 +0300 Subject: [PATCH 04/26] Build against 4.21 platform. --- target-platform/tm4e-target.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-platform/tm4e-target.target b/target-platform/tm4e-target.target index f703f4bfc..dd5465555 100644 --- a/target-platform/tm4e-target.target +++ b/target-platform/tm4e-target.target @@ -21,7 +21,7 @@ - + From 74c80fecf8aebd5846f803309e2338a56a31704d Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Wed, 13 Oct 2021 22:59:37 +0300 Subject: [PATCH 05/26] Build with Tycho 2.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 247c1a46c..d35e57ec3 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 From 1517a15375555d7991d674756b3a713af5e48ca9 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:15:56 +0300 Subject: [PATCH 06/26] Do not refer non-existing icons in tm4e.samples --- org.eclipse.tm4e.samples/plugin.xml | 3 --- 1 file changed, 3 deletions(-) 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"> Date: Thu, 14 Oct 2021 14:18:58 +0300 Subject: [PATCH 07/26] Remove not used private methods. --- ...TMPresentationReconcilerTestGenerator.java | 16 --------------- .../themes/BaseThemeAssociationRegistry.java | 20 ------------------- 2 files changed, 36 deletions(-) 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/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()) { From ebf113f506eabb9d1bd7d1413a81abaa149c46b1 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:19:46 +0300 Subject: [PATCH 08/26] Remove not used private member --- .../src/test/java/org/eclipse/tm4e/ui/internal/text/Command.java | 1 - 1 file changed, 1 deletion(-) 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) { From 61ad156b524072bed393c1a970dc5d35b807223c Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:20:42 +0300 Subject: [PATCH 09/26] Remove one more unused private member --- .../eclipse/tm4e/ui/internal/text/StyleRangesCollector.java | 3 --- 1 file changed, 3 deletions(-) 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; } From aa77731cb4059d18ad6d757fb19deb8ce38a2729 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:22:50 +0300 Subject: [PATCH 10/26] Remove unused local variables. --- .../org/eclipse/tm4e/core/internal/rule/RuleFactory.java | 2 -- .../java/org/eclipse/tm4e/core/grammar/GrammarTest2.java | 2 -- .../test/java/org/eclipse/tm4e/core/grammar/MarkDown.java | 6 +++--- .../eclipse/tm4e/ui/internal/model/DocumentLineList.java | 1 - 4 files changed, 3 insertions(+), 8 deletions(-) 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/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..40f5cd333 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 @@ -34,7 +34,6 @@ public void tokenizeLines() throws Exception { StackElement ruleStack = null; int i = 0; - int j = 0; List lines = new ArrayList<>(); BufferedReader reader = null; @@ -70,7 +69,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.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)) { From 7816de80c7ef39f38ee3dfd2e9d58edf2b46afe3 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:26:39 +0300 Subject: [PATCH 11/26] Modernize tests * Remove public - not needed in JUnit 5 * Use try with resources --- .../eclipse/tm4e/core/theme/ThemeMatchingTest.java | 12 ++++++------ .../org/eclipse/tm4e/core/grammar/GrammarTest2.java | 12 +++--------- 2 files changed, 9 insertions(+), 15 deletions(-) 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/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 40f5cd333..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,10 +24,10 @@ * 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)); @@ -36,19 +36,13 @@ public void tokenizeLines() throws Exception { int i = 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; From 28c3965e2e11eddf0c5cad8997ebaf6d27d3cfdd Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:39:20 +0300 Subject: [PATCH 12/26] Use try-with-resources --- .../tm4e/ui/utils/ContentTypeHelper.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) 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..f6f6585d9 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 @@ -100,34 +100,20 @@ private static ContentTypeInfo getContentTypes(ITextFileBuffer buffer) throws Co 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()); + try (InputStream 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) { - } } } // Buffer is synchronized with filesystem content - InputStream contents = null; - try { - contents = getContents(buffer); + try (InputStream contents = getContents(buffer)){ return new ContentTypeInfo(fileName, Platform.getContentTypeManager().findContentTypesFor(contents, fileName)); } catch (Throwable e) { return null; - } finally { - if (contents != null) { - contents.close(); - } } } catch (IOException x) { x.printStackTrace(); From 298477c9ea9b4acb703c9a39639a62ef0bfc66dd Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:42:46 +0300 Subject: [PATCH 13/26] Remove useless semicolons --- .../java/org/eclipse/tm4e/core/theme/css/ISACParserFactory.java | 2 +- .../src/main/java/org/eclipse/tm4e/markdown/marked/RegExp.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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.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); - }; + } } From 1e8dc5bd09ed380fad3cb7b96afc80a57a0564f2 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 14:46:06 +0300 Subject: [PATCH 14/26] Version bumps --- org.eclipse.tm4e.core/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.core/pom.xml | 2 +- org.eclipse.tm4e.markdown/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.markdown/pom.xml | 2 +- org.eclipse.tm4e.samples/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.samples/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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 1c56e603b..c882d2ab5 100644 --- a/org.eclipse.tm4e.core/pom.xml +++ b/org.eclipse.tm4e.core/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.eclipse.tm4e.core eclipse-plugin - 0.4.2-SNAPSHOT + 0.4.3-SNAPSHOT org.eclipse org.eclipse.tm4e 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.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/pom.xml b/org.eclipse.tm4e.samples/pom.xml index b79af5b0d..d302e4f6c 100644 --- a/org.eclipse.tm4e.samples/pom.xml +++ b/org.eclipse.tm4e.samples/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.eclipse.tm4e.samples eclipse-plugin - 0.3.5-SNAPSHOT + 0.3.6-SNAPSHOT org.eclipse org.eclipse.tm4e From 4c5659b0837143568d7252fd6e7512941fa11487 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 15:25:23 +0300 Subject: [PATCH 15/26] Fix lists in README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 From a0377e43f0bbfb1d780988104f4a802e50c9b3ee Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 14 Oct 2021 15:30:48 +0300 Subject: [PATCH 16/26] Do not include packed artifacts. Prevents pack.gz files to be download for the target platform. --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index d35e57ec3..2dc6a9114 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,6 @@ true p2 - true consider From 3c1ea60fa4f8996deb01627235da1b3b02406629 Mon Sep 17 00:00:00 2001 From: rubenporras <43636626+rubenporras@users.noreply.github.com> Date: Thu, 21 Oct 2021 11:35:41 +0200 Subject: [PATCH 17/26] Support locations outside a local file system Support locations outside a local file system by giving buffer.getContentType() precedence. In addition fix a NPE in getContents() if the location is null (always the case for remote resources). --- .../tm4e/ui/utils/ContentTypeHelper.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) 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 f6f6585d9..619b7da0c 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: @@ -23,6 +23,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,6 +98,11 @@ private static ContentTypeInfo findContentTypesFromFileBuffers(IDocument documen private static ContentTypeInfo getContentTypes(ITextFileBuffer buffer) throws CoreException { try { String fileName = buffer.getFileStore().getName(); + IContentType bufferContentType = buffer.getContentType(); + if (bufferContentType != null) { + IContentType[] contentTypes = {bufferContentType}; + return new ContentTypeInfo(fileName, contentTypes); + } if (buffer.isDirty()) { // Buffer is dirty (content of the filesystem is not synch with // the editor content), use IDocument content. @@ -129,10 +135,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); } From 153ce677d0cbfce4a0860534981174ca0c27a6c4 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Thu, 28 Oct 2021 09:42:15 +0200 Subject: [PATCH 18/26] Fix LICENSE and add CONTRIBUTING --- CONTRIBUTING.md | 68 ++++++++ LICENSE | 416 ++++++++++++++++++++++++++++-------------------- 2 files changed, 313 insertions(+), 171 deletions(-) create mode 100644 CONTRIBUTING.md 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 Clone to Eclipse IDE 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 From b6bef9f86931680aaf89adb60fd91901f057cd4f Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Thu, 28 Oct 2021 21:08:25 +0200 Subject: [PATCH 19/26] Fix content-type detection Some files/buffers may have multiple unrelated content-type. Put buffer content-type first to give it some priority if applicable, and then add other possible content-type. --- .../tm4e/ui/utils/ContentTypeHelper.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 619b7da0c..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 @@ -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; @@ -98,26 +101,27 @@ 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) { - IContentType[] contentTypes = {bufferContentType}; - return new ContentTypeInfo(fileName, contentTypes); + contentTypes.add(bufferContentType); } if (buffer.isDirty()) { // Buffer is dirty (content of the filesystem is not synch with // the editor content), use IDocument content. try (InputStream input = new DocumentInputStream(buffer.getDocument())){ - IContentType[] contentTypes = Platform.getContentTypeManager().findContentTypesFor(input, fileName); - if (contentTypes != null) { - return new ContentTypeInfo(fileName, contentTypes); + 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 try (InputStream contents = getContents(buffer)){ - return new ContentTypeInfo(fileName, - Platform.getContentTypeManager().findContentTypesFor(contents, fileName)); + contentTypes.addAll(Arrays.asList(Platform.getContentTypeManager().findContentTypesFor(contents, fileName))); + return new ContentTypeInfo(fileName, contentTypes.toArray(IContentType[]::new)); } catch (Throwable e) { return null; } From e6454d50ea65f8610ea0e6d33b896868061e3b6b Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Mon, 15 Nov 2021 10:09:22 +0100 Subject: [PATCH 20/26] Detect grammars for base content-types This prevent from having to duplicate grammar associations for all children types --- .../META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.registry/pom.xml | 2 +- .../registry/IGrammarRegistryManager.java | 14 +++++----- .../WorkingCopyGrammarRegistryManager.java | 8 ++---- .../AbstractGrammarRegistryManager.java | 27 ++++++++++++------- .../tm4e/registry/internal/GrammarCache.java | 21 ++++++++------- .../internal/GrammarRegistryManager.java | 10 +++++-- org.eclipse.tm4e.ui.tests/plugin.xml | 7 +++++ .../org/eclipse/tm4e/ui/RegistryTest.java | 9 ++++++- .../preferences/GrammarPreferencePage.java | 3 +-- target-platform/tm4e-target.target | 2 +- 11 files changed, 64 insertions(+), 41 deletions(-) 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..48130ed23 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 @@ -15,6 +15,7 @@ import java.util.Collection; import java.util.List; +import org.eclipse.core.runtime.content.IContentType; import org.eclipse.tm4e.registry.internal.AbstractGrammarRegistryManager; import org.osgi.service.prefs.BackingStoreException; @@ -42,12 +43,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.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/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/target-platform/tm4e-target.target b/target-platform/tm4e-target.target index dd5465555..6b50e5689 100644 --- a/target-platform/tm4e-target.target +++ b/target-platform/tm4e-target.target @@ -7,7 +7,7 @@ - + From e305ff18afbf408232a74af01aba4907e7732f36 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Mon, 15 Nov 2021 12:42:31 +0100 Subject: [PATCH 21/26] Issue #256 - Choose Theme according to background color --- org.eclipse.tm4e.ui/META-INF/MANIFEST.MF | 2 +- org.eclipse.tm4e.ui/pom.xml | 2 +- .../tm4e/ui/internal/themes/AbstractThemeManager.java | 8 ++++++++ .../eclipse/tm4e/ui/internal/themes/ThemeManager.java | 3 +++ .../eclipse/tm4e/ui/internal/widgets/TMViewer.java | 2 +- .../tm4e/ui/text/TMPresentationReconciler.java | 11 +---------- .../org/eclipse/tm4e/ui/themes/IThemeManager.java | 9 +++++++++ 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF b/org.eclipse.tm4e.ui/META-INF/MANIFEST.MF index 41a24a0c4..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.3.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 bbdc06f1e..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.3-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/themes/AbstractThemeManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/AbstractThemeManager.java index f51687ddd..965e0b1e6 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 @@ -18,9 +18,12 @@ import java.util.Map; import java.util.stream.Collectors; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.RGBA; 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 +142,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/ThemeManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/themes/ThemeManager.java index f6f2cc732..fe6b2e5a6 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 @@ -20,10 +20,13 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGBA; import org.eclipse.tm4e.ui.TMUIPlugin; import org.eclipse.tm4e.ui.internal.preferences.PreferenceConstants; import org.eclipse.tm4e.ui.internal.preferences.PreferenceHelper; import org.eclipse.tm4e.ui.themes.IThemeAssociation; +import org.eclipse.tm4e.ui.themes.ITokenProvider; import org.eclipse.tm4e.ui.themes.Theme; import org.eclipse.tm4e.ui.themes.ThemeAssociation; import org.eclipse.tm4e.ui.utils.PreferenceUtils; 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 2ee1af6a4..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 @@ -229,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(); @@ -450,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); 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); } From e5282ee77a38e4ab236a4baa2fa15e50825bea56 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 18 Nov 2021 08:40:40 +0200 Subject: [PATCH 22/26] Enable dependabot --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml 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 From 3e3586ff79386bf64490b576f2fd94dd4d858012 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Nov 2021 06:50:50 +0000 Subject: [PATCH 23/26] Bump maven-javadoc-plugin from 3.2.0 to 3.3.1 Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.2.0...maven-javadoc-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2dc6a9114..88fea4da1 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 + 3.3.1 true From 118bc326e92593113b6f99361ce3aa9c8cff08e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Nov 2021 06:50:59 +0000 Subject: [PATCH 24/26] Bump wagon-ftp from 2.8 to 3.4.3 Bumps wagon-ftp from 2.8 to 3.4.3. --- updated-dependencies: - dependency-name: org.apache.maven.wagon:wagon-ftp dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- org.eclipse.tm4e.repository/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From a9f404bdfa6ac4a2a954413f4c68b045ded41d66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Nov 2021 06:50:54 +0000 Subject: [PATCH 25/26] Bump jacoco-maven-plugin from 0.8.6 to 0.8.7 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.6 to 0.8.7. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.6...v0.8.7) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88fea4da1..93a59b253 100644 --- a/pom.xml +++ b/pom.xml @@ -213,7 +213,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.7 prepare-agent From eb1611654e9d6ef624d5ad393340b8ab0f2819a6 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 18 Nov 2021 10:41:06 +0200 Subject: [PATCH 26/26] Remove useless import packages. --- .../tm4e/registry/WorkingCopyGrammarRegistryManager.java | 3 +-- .../tm4e/ui/internal/themes/AbstractThemeManager.java | 3 +-- .../org/eclipse/tm4e/ui/internal/themes/ThemeManager.java | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) 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 48130ed23..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/ @@ -15,7 +15,6 @@ import java.util.Collection; import java.util.List; -import org.eclipse.core.runtime.content.IContentType; import org.eclipse.tm4e.registry.internal.AbstractGrammarRegistryManager; import org.osgi.service.prefs.BackingStoreException; 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 965e0b1e6..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/ @@ -19,7 +19,6 @@ import java.util.stream.Collectors; import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.RGBA; import org.eclipse.tm4e.ui.themes.ITheme; import org.eclipse.tm4e.ui.themes.IThemeAssociation; import org.eclipse.tm4e.ui.themes.IThemeManager; 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 fe6b2e5a6..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/ @@ -20,13 +20,10 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGBA; import org.eclipse.tm4e.ui.TMUIPlugin; import org.eclipse.tm4e.ui.internal.preferences.PreferenceConstants; import org.eclipse.tm4e.ui.internal.preferences.PreferenceHelper; import org.eclipse.tm4e.ui.themes.IThemeAssociation; -import org.eclipse.tm4e.ui.themes.ITokenProvider; import org.eclipse.tm4e.ui.themes.Theme; import org.eclipse.tm4e.ui.themes.ThemeAssociation; import org.eclipse.tm4e.ui.utils.PreferenceUtils;