forked from eclipse-xpect/Xpect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXtResourceServiceProviderProvider.java
More file actions
44 lines (37 loc) · 1.72 KB
/
Copy pathXtResourceServiceProviderProvider.java
File metadata and controls
44 lines (37 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
* Copyright (c) 2012-2017 TypeFox GmbH and itemis AG.
* 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:
* Moritz Eysholdt - Initial contribution and API
*******************************************************************************/
package org.eclipse.xpect.services;
import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.resource.IResourceServiceProvider;
import org.eclipse.xpect.XpectConstants;
import org.eclipse.xpect.registry.ILanguageInfo;
import org.eclipse.xpect.runner.XpectRunner;
import org.eclipse.xpect.runner.XpectTestGlobalState;
import org.eclipse.xpect.util.IXtInjectorProvider;
import com.google.inject.Injector;
/**
* @author Simon Kaufmann - Initial contribution and API
*/
public class XtResourceServiceProviderProvider implements IResourceServiceProvider.Provider {
public static final XtResourceServiceProviderProvider INSTANCE = new XtResourceServiceProviderProvider();
private XtResourceServiceProviderProvider() {
}
public IResourceServiceProvider get(URI uri, String contentType) {
if (XpectTestGlobalState.INSTANCE.model() != null) {
Injector injector = IXtInjectorProvider.INSTANCE.getInjector(XpectTestGlobalState.INSTANCE.model(), uri);
if (injector != null)
return injector.getInstance(IResourceServiceProvider.class);
}
Injector injector = ILanguageInfo.Registry.INSTANCE.getLanguageByFileExtension(XpectConstants.XT_FILE_EXT).getInjector();
return injector.getInstance(IResourceServiceProvider.class);
}
}