本文整理汇总了Java中org.eclipse.xtext.resource.IResourceFactory类的典型用法代码示例。如果您正苦于以下问题:Java IResourceFactory类的具体用法?Java IResourceFactory怎么用?Java IResourceFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResourceFactory类属于org.eclipse.xtext.resource包,在下文中一共展示了IResourceFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Resource load(final ResourceSet resourceSet, final URI uri, final InputStream input) throws IOException {
final Injector injector = IXtInjectorProvider.INSTANCE.getInjector(context.get(XpectJavaModel.class), uri);
final Resource resource = injector.getInstance(IResourceFactory.class).createResource(uri);
final Resource existingResousce = from(resourceSet.getResources())
.firstMatch(r -> r.getURI().equals(resource.getURI())).orNull();
if (null != existingResousce) {
// remove the existing one
resourceSet.getResources().remove(existingResousce);
}
resourceSet.getResources().add(resource);
try {
resource.load(input, null);
} finally {
if (input != null)
input.close();
}
return resource;
}
示例2: transformContent
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
protected String transformContent(IResourceFactory resourceFactory) {
BufferedReader reader = new BufferedReader(new StringReader(content));
try {
try {
StringWriter writer = new StringWriter(content.length());
PrintWriter printer = new PrintWriter(writer);
String line = reader.readLine();
while (line != null) {
line = transfromLine(line, resourceFactory);
printer.println(line);
line = reader.readLine();
}
printer.close();
return writer.toString();
} finally {
reader.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例3: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.baernreuther.de/dsls/Pkmntcgo")) {
EPackage.Registry.INSTANCE.put("http://www.baernreuther.de/dsls/Pkmntcgo", PkmntcgoPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ptcgo", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("ptcgo", serviceProvider);
}
示例4: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4ts", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4ts", serviceProvider);
}
示例5: createThisResource
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
/**
* Creates {@link N4JSResource} in new {@link ResourceSet}. Created resource has uri of processed xt file and its
* context. During creation resource factory is obtained dynamically to preserve bindings created by XPECT (see
* {@link org.eclipse.xpect.xtext.lib.tests.ValidationTestModuleSetup#configure})
*
*/
@Creates(ThisResource.class)
public XtextResource createThisResource() throws IOException, CoreException {
Entry<IFile, IProject> file2project = findTestResources();
IFile xpectFile = file2project.getKey();
IProject userProject = file2project.getValue();
ResourceSet resourceSet = resourceSetProvider.get(userProject);
URI xpectFilePlatformURI = URI.createPlatformResourceURI(xpectFile.getFullPath().toString(),
ENCODE_PLATFORM_RESOURCE_URIS);
Injector injector = IXtInjectorProvider.INSTANCE.getInjector(ctx.get(XpectJavaModel.class),
xpectFilePlatformURI);
Resource resource = injector.getInstance(IResourceFactory.class).createResource(xpectFilePlatformURI);
resourceSet.getResources().add(resource);
InputStream input = xpectFile.getContents();
try {
resource.load(input, null);
} finally {
if (input != null)
input.close();
}
return (XtextResource) resource;
}
示例6: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/n4js/regex/RegularExpression")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/n4js/regex/RegularExpression", RegularExpressionPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("regex", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("regex", serviceProvider);
}
示例7: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4js", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4js", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsx", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsx", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("js", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("js", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("jsx", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("jsx", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsd", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsd", serviceProvider);
}
示例8: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4mf", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4mf", serviceProvider);
}
示例9: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.xtext.org/example/mydsl/MyDsl")) {
EPackage.Registry.INSTANCE.put("http://www.xtext.org/example/mydsl/MyDsl", MyDslPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("mensa", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("mensa", serviceProvider);
}
示例10: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.hribol.com/bromium/dsl/Bromium")) {
EPackage.Registry.INSTANCE.put("http://www.hribol.com/bromium/dsl/Bromium", BromiumPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("brm", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("brm", serviceProvider);
}
示例11: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.gw4e/dsl/DSLPolicies")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.gw4e/dsl/DSLPolicies", DSLPoliciesPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("policies", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("policies", serviceProvider);
}
示例12: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.wamas.com/ide/launching/LcDsl")) {
EPackage.Registry.INSTANCE.put("http://www.wamas.com/ide/launching/LcDsl", LcDslPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("lc", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("lc", serviceProvider);
}
示例13: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/gemoc/Dsl")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/gemoc/Dsl", DslPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("dsl", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("dsl", serviceProvider);
}
示例14: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.xtext.org/dsl/restaurante/Restaurante")) {
EPackage.Registry.INSTANCE.put("http://www.xtext.org/dsl/restaurante/Restaurante", RestaurantePackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("rest", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("rest", serviceProvider);
}
示例15: register
import org.eclipse.xtext.resource.IResourceFactory; //导入依赖的package包/类
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("occi", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("occi", serviceProvider);
}