Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-01-20 14:49:40 +0000
committerTom Schindl2015-01-20 14:49:40 +0000
commit869b1b59acbcc608fc8b1176c2e9f5eb6c877ca7 (patch)
tree97877a09ec69915e8f5ca106fc8b5445ecd70813
parent3b94ef31c532b0d367ef296bcfb076897e1cbe97 (diff)
downloadorg.eclipse.efxclipse-869b1b59acbcc608fc8b1176c2e9f5eb6c877ca7.tar.gz
org.eclipse.efxclipse-869b1b59acbcc608fc8b1176c2e9f5eb6c877ca7.tar.xz
org.eclipse.efxclipse-869b1b59acbcc608fc8b1176c2e9f5eb6c877ca7.zip
use more DI
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/META-INF/MANIFEST.MF6
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/OSGI-INF/services/proposalcomputercf.xml9
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/build.properties3
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ProposalComputerContextFunction.java41
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ServiceCollector.java4
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/SourceViewerConfigurationContextFunction.java4
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/OSGI-INF/services/hslcomponent.xml3
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/HSLConfiguration.java38
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/internal/HSLComponent.java18
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.java/META-INF/MANIFEST.MF7
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.java/OSGI-INF/services/javacomponent.xml1
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaComponent.java9
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaSourceConfiguration.java7
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.js/META-INF/MANIFEST.MF4
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptComponent.java6
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptSourceConfiguration.java23
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/ProposalComputerFactory.java2
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/SourceViewerConfigurationFactory.java2
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/spi/BaseLanguageComponent.java33
-rw-r--r--experimental/compensator/org.eclipse.fx.code.compensator.project.jdt/src/org/eclipse/fx/code/compensator/project/jdt/internal/JDTProposalComputerFactory.java51
20 files changed, 160 insertions, 111 deletions
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/META-INF/MANIFEST.MF b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/META-INF/MANIFEST.MF
index 5e80530f6..dc25c8621 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/META-INF/MANIFEST.MF
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/META-INF/MANIFEST.MF
@@ -12,6 +12,8 @@ Require-Bundle: org.eclipse.fx.code.compensator.editor;bundle-version="1.0.0",
org.eclipse.fx.text.ui;bundle-version="1.0.0",
org.eclipse.fx.code.compensator.model;bundle-version="0.1.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.10.0",
- org.eclipse.fx.ui.services
-Service-Component: OSGI-INF/services/servicecollector.xml,OSGI-INF/services/inputcf.xml,OSGI-INF/services/documentcf.xml,OSGI-INF/services/partitionercf.xml,OSGI-INF/services/sourceconfigcf.xml,OSGI-INF/services/workbenchmodelcf.xml,OSGI-INF/services/activeOutline.xml
+ org.eclipse.fx.ui.services,
+ org.eclipse.e4.core.di;bundle-version="1.4.0"
+Service-Component: OSGI-INF/services/servicecollector.xml,OSGI-INF/services/inputcf.xml,OSGI-INF/services/documentcf.xml,OSGI-INF/services/partitionercf.xml,OSGI-INF/services/sourceconfigcf.xml,OSGI-INF/services/workbenchmodelcf.xml,OSGI-INF/services/activeOutline.xml,
+ OSGI-INF/services/proposalcomputercf.xml
Bundle-ActivationPolicy: lazy
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/OSGI-INF/services/proposalcomputercf.xml b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/OSGI-INF/services/proposalcomputercf.xml
new file mode 100644
index 000000000..631b972fe
--- /dev/null
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/OSGI-INF/services/proposalcomputercf.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.code.compensator.editor.contrib.proposalcomputercf">
+ <implementation class="org.eclipse.fx.code.compensator.editor.contrib.ProposalComputerContextFunction"/>
+ <service>
+ <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
+ </service>
+ <property name="service.context.key" type="String" value="org.eclipse.fx.code.compensator.editor.ProposalComputer"/>
+ <reference bind="registerProposalComputerFactory" cardinality="0..n" interface="org.eclipse.fx.code.compensator.editor.services.ProposalComputerFactory" name="ProposalComputerFactory" policy="dynamic" unbind="unregisterProposalComputerFactory"/>
+</scr:component>
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/build.properties b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/build.properties
index f9bacbe62..32b757214 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/build.properties
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/build.properties
@@ -4,5 +4,6 @@ bin.includes = META-INF/,\
OSGI-INF/,\
OSGI-INF/services/workbenchmodelcf.xml,\
OSGI-INF/services/activeOutline.xml,\
- OSGI-INF/services/contentassistcf.xml
+ OSGI-INF/services/contentassistcf.xml,\
+ OSGI-INF/services/proposalcomputercf.xml
source.. = src/
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ProposalComputerContextFunction.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ProposalComputerContextFunction.java
new file mode 100644
index 000000000..dcab2ea55
--- /dev/null
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ProposalComputerContextFunction.java
@@ -0,0 +1,41 @@
+package org.eclipse.fx.code.compensator.editor.contrib;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import org.eclipse.e4.core.contexts.ContextFunction;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.fx.code.compensator.editor.Input;
+import org.eclipse.fx.code.compensator.editor.ProposalComputer;
+import org.eclipse.fx.code.compensator.editor.services.ProposalComputerFactory;
+
+public class ProposalComputerContextFunction extends ContextFunction {
+ private List<ProposalComputerFactory> proposalComputerFactoryList = new ArrayList<ProposalComputerFactory>();
+
+ public void registerProposalComputerFactory(ProposalComputerFactory factory) {
+ synchronized (proposalComputerFactoryList) {
+ proposalComputerFactoryList.add(factory);
+ }
+ }
+
+ public void unregisterProposalComputerFactory(ProposalComputerFactory factory) {
+ synchronized (proposalComputerFactoryList) {
+ proposalComputerFactoryList.remove(factory);
+ }
+ }
+
+ @Override
+ public Object compute(IEclipseContext context, String contextKey) {
+ Input<?> input = context.get(Input.class);
+ // need to split up because of bug in JDT
+ Stream<Class<? extends ProposalComputer>> map = proposalComputerFactoryList.stream().filter(c -> c.applies(input)).map(c -> c.createProposalComputer());
+ Optional<Class<? extends ProposalComputer>> findFirst = map.findFirst();
+ if( findFirst.isPresent() ) {
+ return ContextInjectionFactory.make(findFirst.get(), context);
+ }
+ return null;
+ }
+}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ServiceCollector.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ServiceCollector.java
index 9eaa7d576..84ad3a809 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ServiceCollector.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/ServiceCollector.java
@@ -124,8 +124,8 @@ public class ServiceCollector implements DocumentPersitenceService, FileIconLook
return null;
}
- public SourceViewerConfiguration createConfiguration(Input<?> input, GraphicsLoader graphicsLoader) {
- Optional<SourceViewerConfiguration> map = configurationProvider.stream().filter((p) -> p.applies(input)).findFirst().map((p) -> p.createConfiguration(input,graphicsLoader));
+ public Class<? extends SourceViewerConfiguration> createConfiguration(Input<?> input, GraphicsLoader graphicsLoader) {
+ Optional<Class<? extends SourceViewerConfiguration>> map = configurationProvider.stream().filter((p) -> p.applies(input)).findFirst().map((p) -> p.createConfiguration(input));
return map.get();
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/SourceViewerConfigurationContextFunction.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/SourceViewerConfigurationContextFunction.java
index a99dc1ae1..bcbd3fccd 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/SourceViewerConfigurationContextFunction.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.contrib/src/org/eclipse/fx/code/compensator/editor/contrib/SourceViewerConfigurationContextFunction.java
@@ -11,6 +11,7 @@
package org.eclipse.fx.code.compensator.editor.contrib;
import org.eclipse.e4.core.contexts.ContextFunction;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.fx.code.compensator.editor.Input;
import org.eclipse.fx.ui.services.resources.GraphicsLoader;
@@ -21,7 +22,8 @@ public class SourceViewerConfigurationContextFunction extends ContextFunction {
public Object compute(IEclipseContext context) {
SourceViewerConfiguration config = (SourceViewerConfiguration) context.get("localSourceConfig");
if( config == null ) {
- config = context.get(ServiceCollector.class).createConfiguration(context.get(Input.class),context.get(GraphicsLoader.class));
+ Class<? extends SourceViewerConfiguration> cl = context.get(ServiceCollector.class).createConfiguration(context.get(Input.class),context.get(GraphicsLoader.class));
+ config = ContextInjectionFactory.make(cl, context);
context.set("localSourceConfig", config);
}
return config;
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/OSGI-INF/services/hslcomponent.xml b/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/OSGI-INF/services/hslcomponent.xml
index ae83843c2..1f0dd7151 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/OSGI-INF/services/hslcomponent.xml
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/OSGI-INF/services/hslcomponent.xml
@@ -4,5 +4,6 @@
<service>
<provide interface="org.eclipse.fx.code.compensator.editor.services.PartitionerFactory"/>
<provide interface="org.eclipse.fx.code.compensator.editor.services.SourceViewerConfigurationFactory"/>
+ <provide interface="org.eclipse.fx.code.compensator.editor.hsl.internal.HSLComponent"/>
</service>
-</scr:component> \ No newline at end of file
+</scr:component>
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/HSLConfiguration.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/HSLConfiguration.java
index 679416712..7bd99beb9 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/HSLConfiguration.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/HSLConfiguration.java
@@ -14,10 +14,14 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import javax.inject.Inject;
+
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.ReadOnlyProperty;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.fx.code.compensator.editor.Input;
+import org.eclipse.fx.code.compensator.editor.hsl.internal.HSLComponent;
import org.eclipse.fx.code.compensator.editor.hsl.internal.JavaScriptHelper;
import org.eclipse.fx.code.compensator.hsl.hSL.Damager;
import org.eclipse.fx.code.compensator.hsl.hSL.JSDamager;
@@ -34,15 +38,19 @@ import org.eclipse.jface.text.source.SourceViewerConfiguration;
public class HSLConfiguration extends SourceViewerConfiguration {
private Model model;
private ClassLoader cl;
-
- public HSLConfiguration(ClassLoader cl, Model model) {
- this.cl = cl;
- this.model = model;
+
+ private final HSLComponent component;
+
+ @Inject
+ public HSLConfiguration(HSLComponent component, Input<?> input) {
+ this.component = component;
+ this.cl = getClass().getClassLoader();
+ this.model = component.getModelForInput(input);
}
-
+
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new PresentationReconciler();
-
+
for( Damager sc : model.getDamagers() ) {
if( sc instanceof RuleDamager ) {
RuleDamager rs = (RuleDamager) sc;
@@ -60,7 +68,7 @@ public class HSLConfiguration extends SourceViewerConfiguration {
return reconciler;
}
-
+
@Override
public void setThemeId(String themeId) {
super.setThemeId(themeId);
@@ -70,12 +78,12 @@ public class HSLConfiguration extends SourceViewerConfiguration {
if( url != null ) {
defaultStylesheet.set(url);
} else {
- defaultStylesheet.set(_getDefaultStylesheet(null));
+ defaultStylesheet.set(_getDefaultStylesheet(null));
}
}
-
+
private ReadOnlyObjectWrapper<URL> defaultStylesheet;
-
+
@Override
public ReadOnlyProperty<URL> getDefaultStylesheet() {
if( defaultStylesheet == null ) {
@@ -83,12 +91,12 @@ public class HSLConfiguration extends SourceViewerConfiguration {
}
return defaultStylesheet.getReadOnlyProperty();
}
-
+
private URL _getDefaultStylesheet(String themeId) {
URI uri = model.eResource().getURI();
uri = uri.trimSegments(1);
uri = uri.appendSegment(model.getName()+(themeId != null ? "-"+themeId : "")+"-highlight.css");
-
+
if( uri.isPlatform() ) {
System.err.println(cl.getResource(getPluginPath(uri)));
return cl.getResource(getPluginPath(uri));
@@ -98,13 +106,13 @@ public class HSLConfiguration extends SourceViewerConfiguration {
} catch (MalformedURLException e) {
return null;
}
- }
+ }
}
-
+
private static String getPluginPath(URI uri) {
String[] parts = uri.segments();
StringBuffer b = new StringBuffer(parts[2]);
-
+
for( int i = 3; i < parts.length; i++ ) {
b.append("/" + parts[i]);
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/internal/HSLComponent.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/internal/HSLComponent.java
index acbbe76bd..babcaa633 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/internal/HSLComponent.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.hsl/src/org/eclipse/fx/code/compensator/editor/hsl/internal/HSLComponent.java
@@ -27,7 +27,6 @@ import org.eclipse.fx.code.compensator.hsl.hSL.JavaLikeParitioner;
import org.eclipse.fx.code.compensator.hsl.hSL.Model;
import org.eclipse.fx.code.compensator.hsl.hSL.Partitioner;
import org.eclipse.fx.code.compensator.hsl.hSL.RulePartitioner;
-import org.eclipse.fx.ui.services.resources.GraphicsLoader;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
@@ -49,13 +48,14 @@ public class HSLComponent implements PartitionerFactory, SourceViewerConfigurati
}
@Override
- public SourceViewerConfiguration createConfiguration(Input<?> input, GraphicsLoader graphicsLoader) {
- Model m = getModelForInput(input);
- if( m == null ) {
- throw new IllegalArgumentException("Unsupported input '"+input+"'");
- }
-
- return new HSLConfiguration(getClass().getClassLoader(), m);
+ public Class<? extends SourceViewerConfiguration> createConfiguration(Input<?> input) {
+// Model m = getModelForInput(input);
+// if( m == null ) {
+// throw new IllegalArgumentException("Unsupported input '"+input+"'");
+// }
+//
+// return new HSLConfiguration(getClass().getClassLoader(), m);
+ return HSLConfiguration.class;
}
private void registerHslConfig(URI uri) {
@@ -78,7 +78,7 @@ public class HSLComponent implements PartitionerFactory, SourceViewerConfigurati
return false;
}
- private Model getModelForInput(Input<?> input) {
+ public Model getModelForInput(Input<?> input) {
if( input instanceof ContentTypeProvider ) {
return contentTypeMappings.get(((ContentTypeProvider) input).getContentType());
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/META-INF/MANIFEST.MF b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/META-INF/MANIFEST.MF
index 11df98574..cec6983b7 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/META-INF/MANIFEST.MF
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.text;bundle-version="3.5.300",
org.eclipse.fx.code.compensator.editor;bundle-version="1.0.0",
org.eclipse.fx.text.ui;bundle-version="1.0.0",
org.eclipse.fx.ui.controls;bundle-version="1.0.0",
- org.eclipse.fx.ui.services
+ org.eclipse.fx.ui.services,
+ org.eclipse.e4.core.di;bundle-version="1.4.0"
Service-Component: OSGI-INF/services/javacomponent.xml
Bundle-ActivationPolicy: lazy
Import-Package: javafx.animation;version="2.2.0",
@@ -47,4 +48,6 @@ Import-Package: javafx.animation;version="2.2.0",
javafx.scene.web;version="2.2.0",
javafx.stage;version="2.2.0",
javafx.util;version="2.2.0",
- javafx.util.converter;version="2.2.0"
+ javafx.util.converter;version="2.2.0",
+ javax.annotation;version="1.2.0",
+ javax.inject;version="1.0.0"
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/OSGI-INF/services/javacomponent.xml b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/OSGI-INF/services/javacomponent.xml
index 1aa1c13d4..0734876f1 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/OSGI-INF/services/javacomponent.xml
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/OSGI-INF/services/javacomponent.xml
@@ -6,5 +6,4 @@
<provide interface="org.eclipse.fx.code.compensator.editor.services.SourceViewerConfigurationFactory"/>
<provide interface="org.eclipse.fx.code.compensator.editor.services.FileIconProvider"/>
</service>
- <reference bind="registerProposalComputerFactory" cardinality="0..n" interface="org.eclipse.fx.code.compensator.editor.services.ProposalComputerFactory" name="ProposalComputerFactory" policy="static" unbind="unregisterProposalComputerFactory"/>
</scr:component>
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaComponent.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaComponent.java
index 11319f59b..60cb6f3ab 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaComponent.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaComponent.java
@@ -17,13 +17,11 @@ import org.eclipse.fx.code.compensator.editor.java.scanner.IJavaPartitions;
import org.eclipse.fx.code.compensator.editor.services.FileIconProvider;
import org.eclipse.fx.code.compensator.editor.services.PartitionerFactory;
import org.eclipse.fx.code.compensator.editor.services.SourceViewerConfigurationFactory;
-import org.eclipse.fx.code.compensator.editor.spi.BaseLanguageComponent;
-import org.eclipse.fx.ui.services.resources.GraphicsLoader;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
-public class JavaComponent extends BaseLanguageComponent implements PartitionerFactory, SourceViewerConfigurationFactory, FileIconProvider {
+public class JavaComponent implements PartitionerFactory, SourceViewerConfigurationFactory, FileIconProvider {
private final static String[] LEGAL_CONTENT_TYPES= new String[] {
IJavaPartitions.JAVA_DOC,
IJavaPartitions.JAVA_MULTI_LINE_COMMENT,
@@ -33,8 +31,9 @@ public class JavaComponent extends BaseLanguageComponent implements PartitionerF
};
@Override
- public SourceViewerConfiguration createConfiguration(Input<?> input, GraphicsLoader graphicsLoader) {
- return new JavaSourceConfiguration(input, createProposalComputer(input,graphicsLoader));
+ public Class<? extends SourceViewerConfiguration> createConfiguration(Input<?> input) {
+// return new JavaSourceConfiguration(input, createProposalComputer(input,graphicsLoader));
+ return JavaSourceConfiguration.class;
}
@Override
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaSourceConfiguration.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaSourceConfiguration.java
index 19c01696d..39c6401ec 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaSourceConfiguration.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.java/src/org/eclipse/fx/code/compensator/editor/java/JavaSourceConfiguration.java
@@ -17,6 +17,8 @@ import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.inject.Inject;
+
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.ReadOnlyProperty;
@@ -50,8 +52,9 @@ public class JavaSourceConfiguration extends SourceViewerConfiguration {
private final Optional<ProposalComputer> computer;
private Input<?> input;
- public JavaSourceConfiguration(Input<?> input, Optional<ProposalComputer> computer) {
- this.computer = computer;
+ @Inject
+ public JavaSourceConfiguration(Input<?> input, @org.eclipse.e4.core.di.annotations.Optional ProposalComputer computer) {
+ this.computer = Optional.of(computer);
this.input = input;
initializeScanners();
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/META-INF/MANIFEST.MF b/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/META-INF/MANIFEST.MF
index 068d8efe6..1231cf81f 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/META-INF/MANIFEST.MF
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/META-INF/MANIFEST.MF
@@ -46,4 +46,6 @@ Import-Package: javafx.animation;version="2.2.0",
javafx.scene.web;version="2.2.0",
javafx.stage;version="2.2.0",
javafx.util;version="2.2.0",
- javafx.util.converter;version="2.2.0"
+ javafx.util.converter;version="2.2.0",
+ javax.annotation;version="1.2.0",
+ javax.inject;version="1.0.0"
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptComponent.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptComponent.java
index b4e5d2813..2cd9633f1 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptComponent.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptComponent.java
@@ -17,7 +17,6 @@ import org.eclipse.fx.code.compensator.editor.js.scanner.IJavaScriptPartitions;
import org.eclipse.fx.code.compensator.editor.services.FileIconProvider;
import org.eclipse.fx.code.compensator.editor.services.PartitionerFactory;
import org.eclipse.fx.code.compensator.editor.services.SourceViewerConfigurationFactory;
-import org.eclipse.fx.ui.services.resources.GraphicsLoader;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
@@ -31,8 +30,9 @@ public class JavaScriptComponent implements PartitionerFactory, SourceViewerConf
IJavaScriptPartitions.JAVA_CHARACTER
};
@Override
- public SourceViewerConfiguration createConfiguration(Input<?> input, GraphicsLoader graphicsLoader) {
- return new JavaScriptSourceConfiguration();
+ public Class<? extends SourceViewerConfiguration> createConfiguration(Input<?> input) {
+// return new JavaScriptSourceConfiguration();
+ return JavaScriptSourceConfiguration.class;
}
@Override
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptSourceConfiguration.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptSourceConfiguration.java
index 369989f45..dde7816ab 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptSourceConfiguration.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor.js/src/org/eclipse/fx/code/compensator/editor/js/JavaScriptSourceConfiguration.java
@@ -12,6 +12,8 @@ package org.eclipse.fx.code.compensator.editor.js;
import java.net.URL;
+import javax.inject.Inject;
+
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.ReadOnlyProperty;
@@ -30,17 +32,18 @@ import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
public class JavaScriptSourceConfiguration extends SourceViewerConfiguration {
-
+
private JavaScriptCodeScanner fCodeScanner;
private JavaScriptDocScanner fJavaDocScanner;
private JavaScriptCommentScanner fMultilineCommentScanner;
private JavaScriptCommentScanner fSinglelineCommentScanner;
private SingleTokenJavaScriptScanner fStringScanner;
+ @Inject
public JavaScriptSourceConfiguration() {
initializeScanners();
}
-
+
private void initializeScanners() {
fCodeScanner= new JavaScriptCodeScanner();
fMultilineCommentScanner= new JavaScriptCommentScanner(IJavaScriptColorConstants.JAVA_MULTI_LINE_COMMENT);
@@ -48,16 +51,16 @@ public class JavaScriptSourceConfiguration extends SourceViewerConfiguration {
fStringScanner= new SingleTokenJavaScriptScanner(IJavaScriptColorConstants.JAVA_STRING);
fJavaDocScanner= new JavaScriptDocScanner();
}
-
+
@Override
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
return IJavaScriptPartitions.JAVA_PARTITIONING;
}
-
+
@Override
public IPresentationReconciler getPresentationReconciler(
ISourceViewer sourceViewer) {
- PresentationReconciler reconciler= new /*JavaPresentationReconciler*/ PresentationReconciler();
+ PresentationReconciler reconciler= new /*JavaPresentationReconciler*/ PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
DefaultDamagerRepairer dr= new DefaultDamagerRepairer(getCodeScanner());
@@ -83,7 +86,7 @@ public class JavaScriptSourceConfiguration extends SourceViewerConfiguration {
dr= new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, IJavaScriptPartitions.JAVA_CHARACTER);
reconciler.setRepairer(dr, IJavaScriptPartitions.JAVA_CHARACTER);
-
+
return reconciler;
}
@@ -106,7 +109,7 @@ public class JavaScriptSourceConfiguration extends SourceViewerConfiguration {
private ITokenScanner getCodeScanner() {
return fCodeScanner;
}
-
+
@Override
public void setThemeId(String themeId) {
super.setThemeId(themeId);
@@ -114,12 +117,12 @@ public class JavaScriptSourceConfiguration extends SourceViewerConfiguration {
if( url != null ) {
defaultStylesheet.set(url);
} else {
- defaultStylesheet.set(getClass().getClassLoader().getResource("css/highlight.css"));
+ defaultStylesheet.set(getClass().getClassLoader().getResource("css/highlight.css"));
}
}
-
+
private ReadOnlyObjectWrapper<URL> defaultStylesheet = new ReadOnlyObjectWrapper<>(this, "defaultStylesheet", getClass().getClassLoader().getResource("css/highlight.css"));
-
+
@Override
public ReadOnlyProperty<URL> getDefaultStylesheet() {
return defaultStylesheet.getReadOnlyProperty();
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/ProposalComputerFactory.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/ProposalComputerFactory.java
index 2a403eda4..9a5f454d9 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/ProposalComputerFactory.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/ProposalComputerFactory.java
@@ -16,5 +16,5 @@ import org.eclipse.fx.ui.services.resources.GraphicsLoader;
public interface ProposalComputerFactory {
public boolean applies(Input<?> input);
- public ProposalComputer createProposalComputer(GraphicsLoader graphicsLoader);
+ public Class<? extends ProposalComputer> createProposalComputer();
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/SourceViewerConfigurationFactory.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/SourceViewerConfigurationFactory.java
index 7f7d6a1c0..5f75d43f1 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/SourceViewerConfigurationFactory.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/services/SourceViewerConfigurationFactory.java
@@ -28,5 +28,5 @@ public interface SourceViewerConfigurationFactory {
}
public boolean applies(Input<?> input);
- public SourceViewerConfiguration createConfiguration(Input<?> input, GraphicsLoader graphicsLoader);
+ public Class<? extends SourceViewerConfiguration> createConfiguration(Input<?> input);
}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/spi/BaseLanguageComponent.java b/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/spi/BaseLanguageComponent.java
deleted file mode 100644
index 7ea2d2359..000000000
--- a/experimental/compensator/org.eclipse.fx.code.compensator.editor/src/org/eclipse/fx/code/compensator/editor/spi/BaseLanguageComponent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.eclipse.fx.code.compensator.editor.spi;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.eclipse.fx.code.compensator.editor.Input;
-import org.eclipse.fx.code.compensator.editor.ProposalComputer;
-import org.eclipse.fx.code.compensator.editor.services.FileIconProvider;
-import org.eclipse.fx.code.compensator.editor.services.PartitionerFactory;
-import org.eclipse.fx.code.compensator.editor.services.ProposalComputerFactory;
-import org.eclipse.fx.code.compensator.editor.services.SourceViewerConfigurationFactory;
-import org.eclipse.fx.ui.services.resources.GraphicsLoader;
-
-public abstract class BaseLanguageComponent implements PartitionerFactory, SourceViewerConfigurationFactory, FileIconProvider {
- private List<ProposalComputerFactory> proposalComputerFactoryList = new ArrayList<ProposalComputerFactory>();
-
- public void registerProposalComputerFactory(ProposalComputerFactory factory) {
- synchronized (proposalComputerFactoryList) {
- proposalComputerFactoryList.add(factory);
- }
- }
-
- public void unregisterProposalComputerFactory(ProposalComputerFactory factory) {
- synchronized (proposalComputerFactoryList) {
- proposalComputerFactoryList.remove(factory);
- }
- }
-
- protected Optional<ProposalComputer> createProposalComputer(Input<?> input, GraphicsLoader graphicsLoader) {
- return proposalComputerFactoryList.stream().filter(c -> c.applies(input)).map(c -> c.createProposalComputer(graphicsLoader)).findFirst();
- }
-}
diff --git a/experimental/compensator/org.eclipse.fx.code.compensator.project.jdt/src/org/eclipse/fx/code/compensator/project/jdt/internal/JDTProposalComputerFactory.java b/experimental/compensator/org.eclipse.fx.code.compensator.project.jdt/src/org/eclipse/fx/code/compensator/project/jdt/internal/JDTProposalComputerFactory.java
index 9c7689d78..eba7c2edb 100644
--- a/experimental/compensator/org.eclipse.fx.code.compensator.project.jdt/src/org/eclipse/fx/code/compensator/project/jdt/internal/JDTProposalComputerFactory.java
+++ b/experimental/compensator/org.eclipse.fx.code.compensator.project.jdt/src/org/eclipse/fx/code/compensator/project/jdt/internal/JDTProposalComputerFactory.java
@@ -9,6 +9,8 @@ import java.util.concurrent.Future;
import java.util.function.Supplier;
import java.util.stream.Collectors;
+import javax.inject.Inject;
+
import javafx.scene.Node;
import org.eclipse.fx.code.compensator.editor.Input;
@@ -49,28 +51,35 @@ public class JDTProposalComputerFactory implements ProposalComputerFactory {
}
@Override
- public ProposalComputer createProposalComputer(GraphicsLoader graphicsLoader) {
- return new ProposalComputer() {
-
- @Override
- public Future<List<ICompletionProposal>> compute(ProposalContext context) {
- try {
- JDTServerInput i = (JDTServerInput) context.input;
- Future<List<org.eclipse.fx.code.server.jdt.shared.Proposal>> proposals = i.server.getProposals(i.openFile.get(), context.location);
- return CompletableFuture.supplyAsync(() -> {
- try {
- return proposals.get().stream().map((p) -> createProposal(context,p,graphicsLoader)).collect(Collectors.toList());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- });
- } catch (InterruptedException | ExecutionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return CompletableFuture.supplyAsync(() -> Collections.emptyList());
+ public Class<? extends ProposalComputer> createProposalComputer() {
+ return JDTProposalComputer.class;
+ }
+
+ static class JDTProposalComputer implements ProposalComputer {
+ private GraphicsLoader graphicsLoader;
+
+ @Inject
+ public JDTProposalComputer(GraphicsLoader graphicsLoader) {
+ this.graphicsLoader = graphicsLoader;
+ }
+
+ public Future<List<ICompletionProposal>> compute(ProposalContext context) {
+ try {
+ JDTServerInput i = (JDTServerInput) context.input;
+ Future<List<org.eclipse.fx.code.server.jdt.shared.Proposal>> proposals = i.server.getProposals(i.openFile.get(), context.location);
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ return proposals.get().stream().map((p) -> createProposal(context,p,graphicsLoader)).collect(Collectors.toList());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+ } catch (InterruptedException | ExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- };
+ return CompletableFuture.supplyAsync(() -> Collections.emptyList());
+ }
}
static ICompletionProposal createProposal(ProposalContext context, org.eclipse.fx.code.server.jdt.shared.Proposal proposal, GraphicsLoader graphicsLoader) {

Back to the top