summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-02-18 09:58:03 (EST)
committer sefftinge2009-02-18 09:58:03 (EST)
commit7f358470479febadffca840e255cc53449dced72 (patch)
tree9e4a350f5e2b916520fddf014ac62e188247b81e
parent7d5ca8bd4b1f2b5fb8674f422af300d8d78dc78d (diff)
downloadorg.eclipse.xtext-7f358470479febadffca840e255cc53449dced72.zip
org.eclipse.xtext-7f358470479febadffca840e255cc53449dced72.tar.gz
org.eclipse.xtext-7f358470479febadffca840e255cc53449dced72.tar.bz2
Fix: weakened dependency to XtextResourceSet: use guice Provider instead of constructor call (see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=265287)
-rw-r--r--devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.java15
-rw-r--r--examples/org.eclipse.xtext.example.domainmodel/src/xtext/example/GenerateGrammar.java10
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl.ui/plugin.xml4
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreDslHandler.java19
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreHandler.java18
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/EcoreDsl.java15
-rw-r--r--examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/FowlerDsl.java8
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextEditor.java12
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java8
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java8
-rwxr-xr-xtests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java6
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/AbstractParserComparingTest.java4
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/ParserTestHelper.java12
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/datatyperules/PackratParserTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/keywords/ParserTest.java26
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/terminalrules/PackratParserTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/XtextGrammarReconcilationTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/resource/metamodel/Xtext2EcoreTransformerTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/valueconverter/Bug250313.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextGrammarSerializationTest.java2
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java26
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformerTest.java11
-rwxr-xr-xtests/org.eclipse.xtext.ui.integration.tests/src/org/eclipse/xtext/ui/integration/GenerateAllTestGrammars.java8
-rw-r--r--tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext42
-rw-r--r--tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/tests/GenerateAllTestGrammarsWithXtendServices.java16
27 files changed, 166 insertions, 118 deletions
diff --git a/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.java b/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.java
index 832da61..2f6f83d 100644
--- a/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.java
+++ b/devtools/org.eclipse.xtext.reference/src/org/eclipse/xtext/reference/ReferenceGrammar.java
@@ -12,16 +12,18 @@ import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.resource.ClassloaderClasspathUriResolver;
import org.eclipse.xtext.resource.XtextResourceSet;
+import com.google.inject.Injector;
+
import ReferenceModel.ReferenceModelPackage;
/**
* Run this class in order to generate the Reference grammar.
- *
+ *
* @author Sven Efftinge - Initial contribution and API
* @author Peter Friese
*/
public class ReferenceGrammar {
- private Logger log = Logger.getLogger(ReferenceGrammar.class);
+ private final Logger log = Logger.getLogger(ReferenceGrammar.class);
private static final String RUNTIME_PATH = ".";
private static final String UI_PATH = "../org.eclipse.xtext.reference.ui";
@@ -35,9 +37,10 @@ public class ReferenceGrammar {
uiPath = args[0] + "/" + UI_PATH;
}
}
-
+
public void generate() throws IOException {
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
+
ReferenceModelPackage.eINSTANCE.getCustomType(); // initialize
GeneratorFacade.cleanFolder(runtimePath + "/src-gen");
@@ -45,7 +48,7 @@ public class ReferenceGrammar {
String classpathUri = "classpath:/" + getClass().getName().replace('.', '/') + ".xtext";
log.info("loading " + classpathUri);
- ResourceSet rs = new XtextResourceSet();
+ ResourceSet rs = injector.getInstance(XtextResourceSet.class);
Resource resource = rs.createResource(new ClassloaderClasspathUriResolver().resolve(null, URI
.createURI(classpathUri)));
resource.load(null);
@@ -55,7 +58,7 @@ public class ReferenceGrammar {
log.info("Done.");
}
- public static void main(String... args) throws IOException {
+ public static void main(String... args) {
try {
ReferenceGrammar generator = new ReferenceGrammar(args);
generator.generate();
diff --git a/examples/org.eclipse.xtext.example.domainmodel/src/xtext/example/GenerateGrammar.java b/examples/org.eclipse.xtext.example.domainmodel/src/xtext/example/GenerateGrammar.java
index ec404cf..ecf9adb 100644
--- a/examples/org.eclipse.xtext.example.domainmodel/src/xtext/example/GenerateGrammar.java
+++ b/examples/org.eclipse.xtext.example.domainmodel/src/xtext/example/GenerateGrammar.java
@@ -12,11 +12,13 @@ import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.resource.ClassloaderClasspathUriResolver;
import org.eclipse.xtext.resource.XtextResourceSet;
+import com.google.inject.Injector;
+
/**
* Run this class in order to generate the domain model grammar.
*/
public class GenerateGrammar {
- private Logger log = Logger.getLogger( GenerateGrammar.class);
+ private final Logger log = Logger.getLogger(GenerateGrammar.class);
private static final String RUNTIME_PATH = ".";
private static final String UI_PATH = "../org.eclipse.xtext.example.domainmodel.ui";
@@ -31,16 +33,16 @@ public class GenerateGrammar {
uiPath = args[0] + "/" + UI_PATH;
}
}
-
+
public void generate() throws IOException {
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
GeneratorFacade.cleanFolder(runtimePath + "/src-gen");
GeneratorFacade.cleanFolder(uiPath + "/src-gen");
String classpathUri = "classpath:/xtext/example/Domainmodel.xtext";
log.info("loading " + classpathUri);
- ResourceSet rs = new XtextResourceSet();
+ ResourceSet rs = injector.getInstance(XtextResourceSet.class);
Resource resource = rs
.createResource(new ClassloaderClasspathUriResolver().resolve(
null, URI.createURI(classpathUri)));
diff --git a/examples/org.eclipse.xtext.example.ecoredsl.ui/plugin.xml b/examples/org.eclipse.xtext.example.ecoredsl.ui/plugin.xml
index c6c8fda..d14195d 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl.ui/plugin.xml
+++ b/examples/org.eclipse.xtext.example.ecoredsl.ui/plugin.xml
@@ -97,11 +97,11 @@
<extension
point="org.eclipse.ui.handlers">
<handler
- class="org.eclipse.xtext.example.handler.GenerateEcoreDslHandler"
+ class="guice.Aware:org.eclipse.xtext.example.handler.GenerateEcoreDslHandler"
commandId="org.eclipse.xtext.ecore.dsl.GenerateEcoreDsl">
</handler>
<handler
- class="org.eclipse.xtext.example.handler.GenerateEcoreHandler"
+ class="guice.Aware:org.eclipse.xtext.example.handler.GenerateEcoreHandler"
commandId="org.eclipse.xtext.ecore.dsl.GenerateEcore">
</handler>
</extension>
diff --git a/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreDslHandler.java b/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreDslHandler.java
index f0bc9a1..3415e35 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreDslHandler.java
+++ b/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreDslHandler.java
@@ -20,29 +20,34 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
/**
* Experimental to test the serialization from .ecore to .dsl
- *
- * TODO: pls clean up and doc me
+ *
+ * TODO: pls clean up and doc me
* @author Michael Clay - Initial contribution and API
- *
+ *
*/
public class GenerateEcoreDslHandler extends AbstractHandler {
+ @Inject
+ private Provider<XtextResourceSet> resourceSetProvider;
+
@SuppressWarnings( { "unchecked" })
public Object execute(ExecutionEvent event) throws ExecutionException {
EvaluationContext applicationContext = (EvaluationContext) event.getApplicationContext();
List fileList = (List) applicationContext.getDefaultVariable();
IFile ecoreFile = (IFile) fileList.get(0);
- ResourceSet xtextResourceSet = new ResourceSetImpl();
+ ResourceSet xtextResourceSet = resourceSetProvider.get();
Resource ecoreResource = xtextResourceSet.getResource(URI.createFileURI(ecoreFile.getLocation().toFile()
.getAbsolutePath()), true);
- EObject ecorePackage = (EObject) ecoreResource.getContents().get(0);
+ EObject ecorePackage = ecoreResource.getContents().get(0);
- XtextResourceSet resourceSet = new XtextResourceSet();
+ XtextResourceSet resourceSet = resourceSetProvider.get();
String fileNameWithExtension = ecoreFile.getName();
URI fileURI = URI.createFileURI(new java.io.File(ecoreFile.getParent().getLocation().toFile(),
fileNameWithExtension.substring(0, fileNameWithExtension.indexOf(".")) + "_test.ecoredsl")
diff --git a/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreHandler.java b/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreHandler.java
index fe1b44d..41a5831 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreHandler.java
+++ b/examples/org.eclipse.xtext.example.ecoredsl.ui/src/org/eclipse/xtext/example/handler/GenerateEcoreHandler.java
@@ -31,16 +31,22 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.core.util.JdtClasspathUriResolver;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
/**
* Execution handler used to generate an ecore model file based on an existing ecore dsl file.
- *
+ *
* @author Michael Clay - Initial contribution and API
- *
+ *
*/
public class GenerateEcoreHandler extends AbstractHandler {
// logger available to subclasses
protected final Logger logger = Logger.getLogger(getClass());
-
+
+ @Inject
+ private Provider<XtextResourceSet> resourceSetProvider;
+
public Object execute(ExecutionEvent event) throws ExecutionException {
IFile ecoreDslFile = getEcoreDslFileName(event);
EPackage ePackage = loadRootEPackage(ecoreDslFile);
@@ -61,17 +67,17 @@ public class GenerateEcoreHandler extends AbstractHandler {
}
private EPackage loadRootEPackage(IFile ecoreDslFile) {
- XtextResourceSet xtextResourceSet = new XtextResourceSet();
+ XtextResourceSet xtextResourceSet = resourceSetProvider.get();
xtextResourceSet.setClasspathUriResolver(new JdtClasspathUriResolver());
xtextResourceSet.setClasspathURIContext(JavaCore.create(ecoreDslFile.getProject()));
Resource ecoreResource = xtextResourceSet.getResource(URI.createFileURI(ecoreDslFile.getLocation().toFile()
.getAbsolutePath()), true);
- EObject ecoreDsl = (EObject) ecoreResource.getContents().get(0);
+ EObject ecoreDsl = ecoreResource.getContents().get(0);
EList<EReference> references = ecoreDsl.eClass().getEReferences();
EPackage ePackage = (EPackage) ecoreDsl.eGet(references.get(1));
return ePackage;
}
-
+
private void createAndSaveNewEcoreResource(IFile ecoreDslFile, EPackage ePackage) throws ExecutionException {
Resource ecoreModelResource = newEcoreResource(ecoreDslFile);
ecoreModelResource.getContents().add(ePackage);
diff --git a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/EcoreDsl.java b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/EcoreDsl.java
index adbb69e..b8b1fe6 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/EcoreDsl.java
+++ b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/EcoreDsl.java
@@ -20,36 +20,39 @@ import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.resource.ClassloaderClasspathUriResolver;
import org.eclipse.xtext.resource.XtextResourceSet;
+import com.google.inject.Injector;
+
/**
* Run this class in order to generate the EmfaticDsl grammar.
- *
+ *
* @author Michael Clay - Initial contribution and API
*/
public class EcoreDsl {
- private Logger log = Logger.getLogger(EcoreDsl.class);
+ private final Logger log = Logger.getLogger(EcoreDsl.class);
private static final String RUNTIME_PATH = ".";
private static final String UI_PATH = "../org.eclipse.xtext.example.ecoredsl.ui";
private String uiPath = UI_PATH;
private String runtimePath = RUNTIME_PATH;
-
+
private EcoreDsl(String... args) {
if (args.length > 0) {
runtimePath = args[0];
uiPath = args[0] + "/" + UI_PATH;
}
}
-
+
public void generate() throws IOException {
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
+
GeneratorFacade.cleanFolder(runtimePath + "/src-gen");
GeneratorFacade.cleanFolder(uiPath + "/src-gen");
String classpathUri = "classpath:/org/eclipse/xtext/example/EcoreDsl.xtext";
log.info("loading " + classpathUri);
- ResourceSet rs = new XtextResourceSet();
+ ResourceSet rs = injector.getInstance(XtextResourceSet.class);
Resource resource = rs.createResource(
new ClassloaderClasspathUriResolver().resolve(null, URI.createURI(classpathUri)));
resource.load(null);
diff --git a/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/FowlerDsl.java b/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/FowlerDsl.java
index 20cfff0..f414d77 100644
--- a/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/FowlerDsl.java
+++ b/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/FowlerDsl.java
@@ -15,11 +15,13 @@ import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.resource.ClassloaderClasspathUriResolver;
import org.eclipse.xtext.resource.XtextResourceSet;
+import com.google.inject.Injector;
+
/**
* Run this class in order to generate the MyDsl grammar.
*/
public class FowlerDsl {
- private Logger log = Logger.getLogger(FowlerDsl.class);
+ private final Logger log = Logger.getLogger(FowlerDsl.class);
private static final String RUNTIME_PATH = ".";
private static final String UI_PATH = "../org.eclipse.xtext.example.fowlerdsl.ui";
@@ -35,14 +37,14 @@ public class FowlerDsl {
}
public void generate() throws IOException {
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
GeneratorFacade.cleanFolder(runtimePath + "/src-gen");
GeneratorFacade.cleanFolder(uiPath + "/src-gen");
String classpathUri = "classpath:/org/eclipse/xtext/example/FowlerDsl.xtext";
log.info("loading " + classpathUri);
- ResourceSet rs = new XtextResourceSet();
+ ResourceSet rs = injector.getInstance(XtextResourceSet.class);
Resource resource = rs.createResource(new ClassloaderClasspathUriResolver().resolve(null, URI
.createURI(classpathUri)));
resource.load(null);
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextEditor.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextEditor.java
index 0209f3c..a741fe2 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextEditor.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextEditor.java
@@ -33,6 +33,7 @@ import org.eclipse.xtext.ui.core.editor.model.XtextDocumentUtil;
import org.eclipse.xtext.ui.core.internal.Activator;
import com.google.inject.Inject;
+import com.google.inject.Provider;
/**
* @author Dennis Huebner - Initial contribution and API
@@ -51,6 +52,9 @@ public class XtextEditor extends TextEditor {
@Inject(optional = true)
private IContentOutlinePage outlinePage;
+ @Inject
+ private Provider<XtextDocumentProvider> documentProvider;
+
// TODO private IFoldingUpdater foldingSupport;
public XtextEditor() {
@@ -75,12 +79,12 @@ public class XtextEditor extends TextEditor {
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
if (log.isDebugEnabled())
log.debug("init:" + input);
-
+
if (!(input instanceof IURIEditorInput))
throw new IllegalArgumentException("Can only handle IURIEditorInputs");
// do document provider setup
- setDocumentProvider(new XtextDocumentProvider());
+ setDocumentProvider(documentProvider.get());
// source viewer setup
setSourceViewerConfiguration(sourceViewerConfiguration);
@@ -138,7 +142,7 @@ public class XtextEditor extends TextEditor {
/**
* @return true if content assist is available
- *
+ *
*/
public boolean isContentAssistAvailable() {
return getSourceViewerConfiguration().getContentAssistant(getSourceViewer()) != null;
@@ -148,7 +152,7 @@ public class XtextEditor extends TextEditor {
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
if (log.isDebugEnabled())
log.debug("Creating Xtext source viewer.");
-
+
// overwrite superclass implementation to allow folding
fAnnotationAccess = createAnnotationAccess();
fOverviewRuler = createOverviewRuler(getSharedColors());
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java
index 59b3117..37dac8c 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java
@@ -48,6 +48,9 @@ import org.eclipse.xtext.ui.core.editor.model.IXtextDocumentContentObserver.Proc
import org.eclipse.xtext.ui.core.util.JdtClasspathUriResolver;
import org.eclipse.xtext.util.StringInputStream;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
public class XtextDocument extends Document implements IXtextDocument {
private XtextResourceSet resourceSet = null;
@@ -55,13 +58,16 @@ public class XtextDocument extends Document implements IXtextDocument {
private IEditorInput editorInput;
private IFile file;
+ @Inject
+ private Provider<XtextResourceSet> resourceSetProvider;
+
public void setInput(IEditorInput editorInput) {
file = ResourceUtil.getFile(editorInput);
Assert.isTrue(file != null && this.editorInput == null || this.editorInput.equals(editorInput));
if (this.editorInput != null)
return;
this.editorInput = editorInput;
- resourceSet = new XtextResourceSet();
+ resourceSet = resourceSetProvider.get();
IJavaProject javaProject = getIJavaProject(file);
if (javaProject != null) {
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java
index 353f8f6..19b5891 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java
@@ -31,6 +31,9 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.FileDocumentProvider;
import org.eclipse.xtext.resource.XtextResource;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
/**
* @author Peter Friese - Initial contribution and API
* @author Sven Efftinge
@@ -39,6 +42,9 @@ public class XtextDocumentProvider extends FileDocumentProvider {
private static final Logger log = Logger.getLogger(XtextDocumentProvider.class);
+ @Inject
+ private Provider<XtextDocument> document;
+
/**
* @author Sven Efftinge - Initial contribution and API
*
@@ -143,7 +149,7 @@ public class XtextDocumentProvider extends FileDocumentProvider {
@Override
protected IDocument createEmptyDocument() {
- return new XtextDocument();
+ return document.get();
}
@Override
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java
index 744df7d..636236f 100755
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/GenerateAllTestGrammars.java
@@ -50,6 +50,8 @@ import org.eclipse.xtext.testlanguages.TestLanguage;
import org.eclipse.xtext.testlanguages.TreeTestLanguage;
import org.eclipse.xtext.valueconverter.Bug250313;
+import com.google.inject.Injector;
+
/**
* @author Sven Efftinge - Initial contribution and API
*
@@ -98,7 +100,7 @@ public class GenerateAllTestGrammars {
public static void main(String... args) throws Exception {
try {
- new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
if (args.length > 0) {
path = args[0];
}
@@ -106,7 +108,7 @@ public class GenerateAllTestGrammars {
for (Class<?> c : testclasses) {
String filename = getGrammarFileNameAsURI(c);
log.info("loading " + filename);
- ResourceSetImpl rs = new XtextResourceSet();
+ ResourceSetImpl rs = injector.getInstance(XtextResourceSet.class);
URI uri = URI.createURI(filename);
Resource resource = rs.createResource(uri);
resource.load(null);
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java
index a4a36b4..d41dbde 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java
@@ -85,7 +85,7 @@ public class ToEcoreTrafoTest extends AbstractGeneratorTest {
}
private XtextResource getResource(String uri) {
- XtextResourceSet set = new XtextResourceSet();
+ XtextResourceSet set = get(XtextResourceSet.class);
set.setClasspathURIContext(getClass().getClassLoader());
// if(AllTests.isPluginContext) {
// set.setClasspathUriResolver(new BundleClasspathUriResolver());
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/AbstractParserComparingTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/AbstractParserComparingTest.java
index ef10566..149bd92 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/AbstractParserComparingTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/AbstractParserComparingTest.java
@@ -33,8 +33,8 @@ public abstract class AbstractParserComparingTest extends AbstractGeneratorTest
with(getStandaloneSetupClass());
firstParser = createFirstParser();
secondParser = createSecondParser();
- firstHelper = new ParserTestHelper(getResourceFactory(), firstParser);
- secondHelper = new ParserTestHelper(getResourceFactory(), secondParser);
+ firstHelper = new ParserTestHelper(getResourceFactory(), firstParser, get(Keys.RESOURCE_SET_KEY));
+ secondHelper = new ParserTestHelper(getResourceFactory(), secondParser, get(Keys.RESOURCE_SET_KEY));
}
protected abstract Class<? extends ISetup> getStandaloneSetupClass();
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/ParserTestHelper.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/ParserTestHelper.java
index 30002eb..159ea1d 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/ParserTestHelper.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/ParserTestHelper.java
@@ -17,6 +17,8 @@ import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.util.StringInputStream;
+import com.google.inject.Provider;
+
/**
* @author Sebastian Zarnekow - Initial contribution and API
*/
@@ -24,14 +26,16 @@ public class ParserTestHelper {
private final IResourceFactory factory;
private final IParser parser;
+ private final Provider<XtextResourceSet> resourceSet;
- public ParserTestHelper(IResourceFactory factory, IParser parser) {
+ public ParserTestHelper(IResourceFactory factory, IParser parser, Provider<XtextResourceSet> resourceSet) {
this.factory = factory;
this.parser = parser;
+ this.resourceSet = resourceSet;
}
-
+
public XtextResource getResourceFromStream(InputStream in) throws IOException {
- XtextResourceSet rs = new XtextResourceSet();
+ XtextResourceSet rs = resourceSet.get();
rs.setClasspathURIContext(getClass());
URI uri = URI.createURI("mytestmodel.test");
XtextResource resource = createResource(uri);
@@ -46,7 +50,7 @@ public class ParserTestHelper {
return resource;
}
-
+
public XtextResource getResourceFromString(String in) throws IOException {
return getResourceFromStream(new StringInputStream(in));
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/datatyperules/PackratParserTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/datatyperules/PackratParserTest.java
index df76eae..2022879 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/datatyperules/PackratParserTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/datatyperules/PackratParserTest.java
@@ -56,7 +56,7 @@ public class PackratParserTest extends ParserTest {
@Override
protected XtextResource getResource(InputStream in) throws Exception {
- ParserTestHelper helper = new ParserTestHelper(getResourceFactory(), parser);
+ ParserTestHelper helper = new ParserTestHelper(getResourceFactory(), parser, get(Keys.RESOURCE_SET_KEY));
return helper.getResourceFromStream(in);
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/keywords/ParserTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/keywords/ParserTest.java
index 39f9ff6..0c504d9 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/keywords/ParserTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/keywords/ParserTest.java
@@ -32,13 +32,13 @@ public abstract class ParserTest extends AbstractGeneratorTest {
@Override
protected void setUp() throws Exception {
with(KeywordsTestLanguageStandaloneSetup.class);
- helper = new ParserTestHelper(getResourceFactory(), getParserUnderTest());
+ helper = new ParserTestHelper(getResourceFactory(), getParserUnderTest(), get(Keys.RESOURCE_SET_KEY));
EPackage pack = getMetamodelAccess().getGeneratedEPackages()[0];
EClass clazz = (EClass) pack.getEClassifier("Model");
- first = clazz.getEStructuralFeature("first");
- second = clazz.getEStructuralFeature("second");
- third = clazz.getEStructuralFeature("third");
- forth = clazz.getEStructuralFeature("forth");
+ first = clazz.getEStructuralFeature("first");
+ second = clazz.getEStructuralFeature("second");
+ third = clazz.getEStructuralFeature("third");
+ forth = clazz.getEStructuralFeature("forth");
}
protected abstract IParser getParserUnderTest();
@@ -49,46 +49,46 @@ public abstract class ParserTest extends AbstractGeneratorTest {
boolean value = (Boolean) model.eGet(feature);
assertTrue(value);
}
-
+
public void testFooBar() throws Exception {
XtextResource resource = helper.getResourceFromString("foo\\bar");
assertTrue(resource.getErrors().isEmpty());
checkModel(resource, first);
}
-
+
public void testFoo() throws Exception {
XtextResource resource = helper.getResourceFromString("foo\\");
assertTrue(resource.getErrors().isEmpty());
checkModel(resource, second);
}
-
+
public void testBar() throws Exception {
XtextResource resource = helper.getResourceFromString("\\bar");
assertTrue(resource.getErrors().isEmpty());
checkModel(resource, third);
}
-
+
public void testBackslash() throws Exception {
XtextResource resource = helper.getResourceFromString("\\");
assertTrue(resource.getErrors().isEmpty());
checkModel(resource, forth);
}
-
+
public static class Antlr extends ParserTest {
@Override
protected IAntlrParser getParserUnderTest() {
return getAntlrParser();
}
-
+
}
-
+
public static class Packrat extends ParserTest {
@Override
protected IPackratParser getParserUnderTest() {
return getPackratParser();
}
-
+
}
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/terminalrules/PackratParserTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/terminalrules/PackratParserTest.java
index e7fb5dd..e2d9e9a 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/terminalrules/PackratParserTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parser/terminalrules/PackratParserTest.java
@@ -28,7 +28,7 @@ public class PackratParserTest extends ParserTest {
@Override
protected XtextResource getResource(InputStream in) throws Exception {
- ParserTestHelper helper = new ParserTestHelper(getResourceFactory(), parser);
+ ParserTestHelper helper = new ParserTestHelper(getResourceFactory(), parser, get(Keys.RESOURCE_SET_KEY));
return helper.getResourceFromStream(in);
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java
index 165bfa2..954ffa1 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.java
@@ -28,7 +28,7 @@ public class ComplexReconstrTest extends AbstractGeneratorTest {
}
public void testPrintGrammar() {
- XtextResourceSet rs = new XtextResourceSet();
+ XtextResourceSet rs = get(XtextResourceSet.class);
rs.setClasspathURIContext(getClass());
URI u = URI.createURI("classpath:/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTestLanguage.xmi");
EObject o = rs.getResource(u, true).getContents().get(0);
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/XtextGrammarReconcilationTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/XtextGrammarReconcilationTest.java
index e7cf91d..7362eca 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/XtextGrammarReconcilationTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/parsetree/reconstr/XtextGrammarReconcilationTest.java
@@ -23,7 +23,7 @@ public class XtextGrammarReconcilationTest extends AbstractGeneratorTest {
String model = "language foo Honolulu : name=ID;";
// load grammar model
- XtextResourceSet rs = new XtextResourceSet();
+ XtextResourceSet rs = get(XtextResourceSet.class);
Resource resource = rs.createResource(URI.createURI("foo.xtext"));
resource.load(new StringInputStream(model), null);
Grammar object = (Grammar) resource.getContents().get(0);
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/resource/metamodel/Xtext2EcoreTransformerTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/resource/metamodel/Xtext2EcoreTransformerTest.java
index da1b78c..817ab0a 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/resource/metamodel/Xtext2EcoreTransformerTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/resource/metamodel/Xtext2EcoreTransformerTest.java
@@ -93,7 +93,7 @@ public class Xtext2EcoreTransformerTest extends AbstractGeneratorTest {
@Override
protected XtextResource getResource(InputStream in) throws Exception {
- ResourceSet rs = new XtextResourceSet();
+ ResourceSet rs = get(XtextResourceSet.class);
XtextResource resource = (XtextResource) getResourceFactory().createResource(URI.createURI("mytestmodel.test"));
rs.getResources().add(resource);
XtextLinker linker = new XtextLinker() {
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/valueconverter/Bug250313.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/valueconverter/Bug250313.java
index 75edb57..5df0012 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/valueconverter/Bug250313.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/valueconverter/Bug250313.java
@@ -40,7 +40,7 @@ public abstract class Bug250313 extends AbstractGeneratorTest {
return Guice.createInjector(new MyBug250313RuntimeModule(Bug250313.this));
}
});
- helper = new ParserTestHelper(getResourceFactory(), getParserUnderTest());
+ helper = new ParserTestHelper(getResourceFactory(), getParserUnderTest(), get(Keys.RESOURCE_SET_KEY));
}
@Override
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextGrammarSerializationTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextGrammarSerializationTest.java
index 219fb93..120c757 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextGrammarSerializationTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextGrammarSerializationTest.java
@@ -69,7 +69,7 @@ public class XtextGrammarSerializationTest extends AbstractGeneratorTest {
}
public void _testXtestSerializationSelfTest() throws Exception {
- Resource res = new XtextResourceSet().createResource(URI
+ Resource res = get(XtextResourceSet.class).createResource(URI
.createURI("myfile.xtext"));
res.getContents().add(get(XtextGrammarAccess.class).getGrammar());
OutputStream outputStream = new ByteArrayOutputStream();
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java
index 4f1b762..cf72f8e 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/GenerateAllTestGrammarsWithUiConfig.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * __ ___ _
+ * __ ___ _
* \ \/ / |_ _____ __ |_
* \ /| __/ _ \ \/ / __|
* / \| |_ __/> <| |_
* /_/\_\\__\___/_/\_\\__|
- *
+ *
* Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -29,15 +29,17 @@ import org.eclipse.xtext.testlanguages.ContentAssistTestLanguage;
import org.eclipse.xtext.testlanguages.ReferenceGrammarTestLanguage;
import org.eclipse.xtext.testlanguages.TreeTestLanguage;
+import com.google.inject.Injector;
+
/**
* Generates all required testgrammars with UI configuration for this test project.
- *
+ *
* This code was copied from class <code>GenerateAllTestGrammars</code> within project
- * 'org.eclipse.xtext[.generator.]tests'.
+ * 'org.eclipse.xtext[.generator.]tests'.
* <p/>
* The duplication of this class was required because tests in this project rely on an existing UIConfig in
* addition to the standalone RuntimeConfig.
- *
+ *
* @author Michael Clay - Initial contribution and API
*/
public class GenerateAllTestGrammarsWithUiConfig {
@@ -47,15 +49,15 @@ public class GenerateAllTestGrammarsWithUiConfig {
private static Logger logger = Logger.getLogger(GenerateAllTestGrammarsWithUiConfig.class);
- private final static Class<?>[] testClasses = new Class[] {
+ private final static Class<?>[] testClasses = new Class[] {
AbstractTestLanguage.class,
- ReferenceGrammarTestLanguage.class,
+ ReferenceGrammarTestLanguage.class,
TreeTestLanguage.class,
- XtextGrammarTestLanguage.class,
+ XtextGrammarTestLanguage.class,
ContentAssistTestLanguage.class,
- KeywordsTestLanguage.class
+ KeywordsTestLanguage.class
};
-
+
/**
* @return the testclasses
*/
@@ -68,12 +70,12 @@ public class GenerateAllTestGrammarsWithUiConfig {
String uiPath = (args.length >0) ? args[0]: UI_PATH;
String runtimePath = ((args.length >0) ? args[0] + "/": "") + RUNTIME_PATH;
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
GeneratorFacade.cleanFolder(uiPath + "/src-gen");
for (Class<?> clazz : testClasses) {
String filename = GenerateAllTestGrammars.getGrammarFileNameAsURI(clazz);
logger.info("loading " + filename);
- ResourceSetImpl rs = new XtextResourceSet();
+ ResourceSetImpl rs = injector.getInstance(XtextResourceSet.class);
URI uri = URI.createURI(filename);
Resource resource = rs.createResource(uri);
resource.load(null);
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformerTest.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformerTest.java
index 6526c54..9405777 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformerTest.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/outline/impl/DefaultSemanticModelTransformerTest.java
@@ -1,16 +1,15 @@
package org.eclipse.xtext.ui.common.editor.outline.impl;
-import junit.framework.TestCase;
-
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.xtext.junit.AbstractXtextTests;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.core.DefaultLabelProvider;
import org.eclipse.xtext.ui.core.DefaultLocationInFileProvider;
-public class DefaultSemanticModelTransformerTest extends TestCase {
+public class DefaultSemanticModelTransformerTest extends AbstractXtextTests {
private EObject root;
private EObject a1;
@@ -19,7 +18,7 @@ public class DefaultSemanticModelTransformerTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- XtextResourceSet resourceSet = new XtextResourceSet();
+ XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
@@ -30,11 +29,11 @@ public class DefaultSemanticModelTransformerTest extends TestCase {
a1 = root.eContents().get(0);
a2 = root.eContents().get(1);
}
-
+
protected DefaultSemanticModelTransformer getSemanticModelTransformer() {
return new DefaultSemanticModelTransformer(new DefaultLocationInFileProvider(), new DefaultLabelProvider());
}
-
+
public void testNullSafety() {
DefaultSemanticModelTransformer transformer = getSemanticModelTransformer();
assertFalse(transformer.consumeSemanticChildNodes(null));
diff --git a/tests/org.eclipse.xtext.ui.integration.tests/src/org/eclipse/xtext/ui/integration/GenerateAllTestGrammars.java b/tests/org.eclipse.xtext.ui.integration.tests/src/org/eclipse/xtext/ui/integration/GenerateAllTestGrammars.java
index dc6f538..60c2aaf 100755
--- a/tests/org.eclipse.xtext.ui.integration.tests/src/org/eclipse/xtext/ui/integration/GenerateAllTestGrammars.java
+++ b/tests/org.eclipse.xtext.ui.integration.tests/src/org/eclipse/xtext/ui/integration/GenerateAllTestGrammars.java
@@ -17,9 +17,11 @@ import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.resource.XtextResourceSet;
+import com.google.inject.Injector;
+
/**
* @author Sven Efftinge - Initial contribution and API
- *
+ *
*/
public class GenerateAllTestGrammars {
private static String path = ".";
@@ -31,7 +33,7 @@ public class GenerateAllTestGrammars {
public static void main(String... args) throws Exception {
try {
log.info(Thread.currentThread().getContextClassLoader());
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
if (args.length > 0) {
path = args[0] + "/" + path;
}
@@ -39,7 +41,7 @@ public class GenerateAllTestGrammars {
for (Class<?> c : testclasses) {
String filename = "classpath:/" + c.getName().replace('.', '/') + ".xtext";
log.info("loading " + filename);
- ResourceSetImpl rs = new XtextResourceSet();
+ ResourceSetImpl rs = injector.getInstance(XtextResourceSet.class);
URI uri = URI.createURI(filename);
Resource resource = rs.createResource(uri);
resource.load(null);
diff --git a/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext b/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
index 1eae9b4..e2777ba 100644
--- a/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
+++ b/tests/org.eclipse.xtext.xtend.tests/src-gen/org/eclipse/xtext/GenXtextGrammarTestLanguageScopeProvider.ext
@@ -17,34 +17,22 @@ extension org::eclipse::xtend::util::stdlib::io;
*/
-List[IScopedElement] scope_rule(CrossReference this):
- allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_rule(emf::EObject this) :
- allElements().collect(x | createScopedElement(x.referenceName(), x));
-
List[IScopedElement] scope_superGrammar(Grammar this):
allElements().typeSelect(Grammar).collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_superGrammar(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_ePackage(AbstractMetamodelDeclaration this):
- allElements().typeSelect(ecore::EPackage).collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_ePackage(emf::EObject this) :
- allElements().collect(x | createScopedElement(x.referenceName(), x));
-
-List[IScopedElement] scope_hiddenTokens(Grammar this):
+List[IScopedElement] scope_hiddenTokens(ParserRule this):
allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_metamodel(TypeRef this):
- allElements().typeSelect(AbstractMetamodelDeclaration).collect(x | createScopedElement(x.referenceName(), x));
+List[IScopedElement] scope_type(TypeRef this):
+ allElements().typeSelect(ecore::EClassifier).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_metamodel(emf::EObject this) :
+List[IScopedElement] scope_type(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
List[IScopedElement] scope_rule(RuleCall this):
@@ -53,15 +41,27 @@ List[IScopedElement] scope_rule(RuleCall this):
List[IScopedElement] scope_rule(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_hiddenTokens(ParserRule this):
+List[IScopedElement] scope_rule(CrossReference this):
allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
+List[IScopedElement] scope_rule(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_type(TypeRef this):
- allElements().typeSelect(ecore::EClassifier).collect(x | createScopedElement(x.referenceName(), x));
+List[IScopedElement] scope_ePackage(AbstractMetamodelDeclaration this):
+ allElements().typeSelect(ecore::EPackage).collect(x | createScopedElement(x.referenceName(), x));
-List[IScopedElement] scope_type(emf::EObject this) :
+List[IScopedElement] scope_ePackage(emf::EObject this) :
+ allElements().collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_metamodel(TypeRef this):
+ allElements().typeSelect(AbstractMetamodelDeclaration).collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_metamodel(emf::EObject this) :
+ allElements().collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_hiddenTokens(Grammar this):
+ allElements().typeSelect(AbstractRule).collect(x | createScopedElement(x.referenceName(), x));
+
+List[IScopedElement] scope_hiddenTokens(emf::EObject this) :
allElements().collect(x | createScopedElement(x.referenceName(), x));
diff --git a/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/tests/GenerateAllTestGrammarsWithXtendServices.java b/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/tests/GenerateAllTestGrammarsWithXtendServices.java
index 0d012d3..fef7894 100644
--- a/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/tests/GenerateAllTestGrammarsWithXtendServices.java
+++ b/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/tests/GenerateAllTestGrammarsWithXtendServices.java
@@ -1,10 +1,10 @@
/*******************************************************************************
- * __ ___ _
+ * __ ___ _
* \ \/ / |_ _____ __ |_
* \ /| __/ _ \ \/ / __|
* / \| |_ __/> <| |_
* /_/\_\\__\___/_/\_\\__|
- *
+ *
* Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -28,17 +28,19 @@ import org.eclipse.xtext.testlanguages.ContentAssistTestLanguage;
import org.eclipse.xtext.testlanguages.ReferenceGrammarTestLanguage;
import org.eclipse.xtext.testlanguages.TreeTestLanguage;
+import com.google.inject.Injector;
+
/**
* Generates all required testgrammars with xtend services for this test
* project.
- *
+ *
* This code was copied from class
* <code>org.eclipse.xtext.ui.common.GenerateAllTestGrammarsWithUiConfig</code>
* within project 'org.eclipse.xtext.ui.common.tests'. <p/>
- *
+ *
* The duplication of this class was required because we need a language setup
* with xtend services. services.
- *
+ *
* @author Michael Clay - Initial contribution and API
* @author Jan Koehnlein
*/
@@ -65,12 +67,12 @@ public class GenerateAllTestGrammarsWithXtendServices {
String uiPath = (args.length > 0) ? args[0] : UI_PATH;
String runtimePath = ((args.length > 0) ? args[0] + "/" : "") + RUNTIME_PATH;
- XtextStandaloneSetup.doSetup();
+ Injector injector = new XtextStandaloneSetup().createInjectorAndDoEMFRegistration();
GeneratorFacade.cleanFolder(uiPath + "/src-gen");
for (Class<?> clazz : testClasses) {
String filename = GenerateAllTestGrammars.getGrammarFileNameAsURI(clazz);
logger.info("loading " + filename);
- ResourceSetImpl rs = new XtextResourceSet();
+ ResourceSetImpl rs = injector.getInstance(XtextResourceSet.class);
URI uri = URI.createURI(filename);
Resource resource = rs.createResource(uri);
resource.load(null);