当前位置: 首页>>代码示例>>Java>>正文


Java XtextResourceSet.setClasspathURIContext方法代码示例

本文整理汇总了Java中org.eclipse.xtext.resource.XtextResourceSet.setClasspathURIContext方法的典型用法代码示例。如果您正苦于以下问题:Java XtextResourceSet.setClasspathURIContext方法的具体用法?Java XtextResourceSet.setClasspathURIContext怎么用?Java XtextResourceSet.setClasspathURIContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.resource.XtextResourceSet的用法示例。


在下文中一共展示了XtextResourceSet.setClasspathURIContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createResourceSet

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
/**
 * Creates the common resource set to use during compilation. Installs a light weight index.
 *
 * @return the resource set
 */
private ResourceSet createResourceSet() {
	// TODO try to reuse code from IN4JSCore.createResourceSet

	XtextResourceSet resourceSet = xtextResourceSetProvider.get();
	resourceSet.setClasspathURIContext(classLoader);

	// Install containerState as adapter.
	resourceSet.eAdapters().add(new DelegatingIAllContainerAdapter(rsbAcs));

	// Install a lightweight index.
	OrderedResourceDescriptionsData index = new OrderedResourceDescriptionsData(Collections.emptyList());
	ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index);

	return resourceSet;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:N4HeadlessCompiler.java

示例2: resourceSet

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
/**
 * creates a fresh resource set with the given resources
 * 
 * @param resources - pairs of file names and their contents 
 * @return a ResourceSet, containing the given resources.
 * @throws IOException if the resource loading fails 
 */
public ResourceSet resourceSet(Pair<String,? extends CharSequence> ...resources ) throws IOException {
	XtextResourceSet result = resourceSetProvider.get();
	result.setClasspathURIContext(classpathUriContext);
	FileProjectConfig projectConfig = new FileProjectConfig(new File(workspaceRoot,PROJECT_NAME), PROJECT_NAME);
	projectConfig.addSourceFolder("src");
	ProjectConfigAdapter.install(result, projectConfig);
	for (Pair<String, ? extends CharSequence> entry : resources) {
		URI uri = copyToWorkspace(getSourceFolderPath()+"/"+entry.getKey(), entry.getValue());
		Resource resource = result.createResource(uri);
		if (resource == null)
			throw new IllegalStateException("Couldn't create resource for URI "+uri+". Resource.Factory not registered?");
		resource.load(newHashMap());
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:CompilationTestHelper.java

示例3: testXtextFormatting

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Test public void testXtextFormatting() throws IOException {
	String path = getClass().getPackage().getName().replace('.', '/');
	URI u = URI.createURI("classpath:/" + path + "/XtextFormatterMessy.xtext");
	XtextResourceSet resourceSet = new XtextResourceSet();
	resourceSet.setClasspathURIContext(getClass());
	Resource r = resourceSet.getResource(u, true);
	// System.out.println(r.getWarnings());
	// System.out.println(r.getErrors());
	ByteArrayOutputStream formatted = new ByteArrayOutputStream();
	r.save(formatted, SaveOptions.newBuilder().format().getOptions().toOptionsMap());
	// System.out.println(EmfFormatter.listToStr(r.getContents()));
	// System.out.println(formatted.toString());

	URI expectedURI = URI.createURI("classpath:/" + path + "/XtextFormatterExpected.xtext");
	XtextResource expectedResource = (XtextResource) resourceSet.getResource(expectedURI, true);
	String expected = expectedResource.getParseResult().getRootNode().getText();
	assertEquals(expected.replaceAll(System.lineSeparator(), "\n"), 
	    formatted.toString().replaceAll(System.lineSeparator(), "\n"));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:XtextFormatterTest.java

示例4: setUp

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
	EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
	resourceSet = new XtextResourceSet();
	resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
	resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
	resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
	resourceSet.setClasspathURIContext(getClasspathURIContext());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:AbstractPortableURIsTest.java

示例5: testBug_266807

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Test
public void testBug_266807() throws Exception {
  final XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
  rs.setClasspathURIContext(this.getClass());
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("classpath:/");
  String _replace = this.getClass().getPackage().getName().replace(Character.valueOf('.').charValue(), Character.valueOf('/').charValue());
  _builder.append(_replace);
  _builder.append("/Test.xtext");
  Resource _createResource = rs.createResource(
    URI.createURI(_builder.toString()), 
    ContentHandler.UNSPECIFIED_CONTENT_TYPE);
  final XtextResource resource = ((XtextResource) _createResource);
  resource.load(null);
  EList<Resource.Diagnostic> _errors = resource.getErrors();
  for (final Resource.Diagnostic d : _errors) {
    Assert.fail(d.getMessage());
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:Xtext2EcoreTransformerTest.java

示例6: testLoadingBuiltInTypes

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@SuppressWarnings("javadoc")
@Test
public void testLoadingBuiltInTypes() {
	XtextResourceSet resourceSet = (XtextResourceSet) resourceSetProvider.get(null);
	resourceSet.setClasspathURIContext(N4JSResource.class.getClassLoader());
	BuiltInTypeScope scope = BuiltInTypeScope.get(resourceSet);
	IEObjectDescription anyType = scope.getSingleElement(QualifiedName.create("any"));
	Assert.assertNotNull(anyType);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:BuiltInTypeScopePluginTest.java

示例7: doGetResource

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
protected XtextResource doGetResource(InputStream in, URI uri) throws Exception {
	XtextResourceSet rs = get(XtextResourceSet.class);
	rs.setClasspathURIContext(getClasspathURIContext());
	XtextResource resource = (XtextResource) getResourceFactory().createResource(uri);
	rs.getResources().add(resource);
	resource.load(in, null);
	if (resource instanceof LazyLinkingResource) {
		((LazyLinkingResource) resource).resolveLazyCrossReferences(CancelIndicator.NullImpl);
	} else {
		EcoreUtil.resolveAll(resource);
	}
	return resource;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:AbstractXtextTests.java

示例8: setUp

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
	EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
	resourceSet = new XtextResourceSet();
	resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
	resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
	resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
	resourceSet.setClasspathURIContext(getClasspathURIContext());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:AbstractPortableURIsTest.java

示例9: _testRedundantImportLarge

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
public void _testRedundantImportLarge() {
	XtextResourceSet resourceSet = get(XtextResourceSet.class);
	resourceSet.setClasspathURIContext(getClass().getClassLoader());
	URI uri = URI.createURI("classpath:/org/eclipse/xtext/linking/04.importuritestlanguage");
	Resource res = resourceSet.getResource(uri, true);
	assertNotNull("res", res);
	EcoreUtil.resolveAll(res);
	assertFalse(res.getErrors().toString(), res.getErrors().isEmpty());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:Bug266082Test.java

示例10: setUp

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
	super.setUp();
	XtextResourceSet set = new XtextResourceSet();
	set.setClasspathURIContext(getClass());
	Resource resource = set.getResource(URI.createURI("classpath:/org/eclipse/xtext/generator/grammarAccess/ametamodel.ecore"), true);
	metamodel = (EPackage) resource.getContents().get(0);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:FragmentFakingEcoreResourceTest.java

示例11: doGetResource

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Override
public XtextResource doGetResource(final InputStream in, final URI uri) throws Exception {
  XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
  rs.setClasspathURIContext(this.getClass());
  Resource _createResource = this.getResourceFactory().createResource(uri);
  final XtextResource resource = ((XtextResource) _createResource);
  rs.getResources().add(resource);
  XtextLinker linker = new XtextLinker() {
    @Override
    protected Xtext2EcoreTransformer createTransformer(final Grammar grammar, final IDiagnosticConsumer consumer) {
      Xtext2EcoreTransformer result = super.createTransformer(grammar, consumer);
      ErrorAcceptor _errorAcceptor = result.getErrorAcceptor();
      Xtext2EcoreTransformerTest.MyErrorAcceptor _myErrorAcceptor = new Xtext2EcoreTransformerTest.MyErrorAcceptor(_errorAcceptor, Xtext2EcoreTransformerTest.this.errorAcceptorMock);
      result.setErrorAcceptor(_myErrorAcceptor);
      return result;
    }
  };
  ILinker _linker = resource.getLinker();
  linker.setScopeProvider(((XtextLinker) _linker).getScopeProvider());
  ILinker _linker_1 = resource.getLinker();
  linker.setLinkingService(((Linker) _linker_1).getLinkingService());
  ILinker _linker_2 = resource.getLinker();
  linker.setLinkingHelper(((Linker) _linker_2).getLinkingHelper());
  XtextLinker.PackageRemover _packageRemover = new XtextLinker.PackageRemover();
  linker.setPackageRemover(_packageRemover);
  LinkingDiagnosticMessageProvider _linkingDiagnosticMessageProvider = new LinkingDiagnosticMessageProvider();
  linker.setDiagnosticMessageProvider(_linkingDiagnosticMessageProvider);
  OnChangeEvictingCache _onChangeEvictingCache = new OnChangeEvictingCache();
  linker.setCache(_onChangeEvictingCache);
  resource.setLinker(linker);
  resource.load(in, null);
  return resource;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:34,代码来源:Xtext2EcoreTransformerTest.java

示例12: doGetResource

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
protected XtextResource doGetResource(InputStream in, URI uri) throws Exception {
	XtextResourceSet rs = get(XtextResourceSet.class);
	rs.setClasspathURIContext(getClass());
	XtextResource resource = (XtextResource) getResourceFactory().createResource(uri);
	rs.getResources().add(resource);
	resource.load(in, null);
	if (resource instanceof LazyLinkingResource) {
		((LazyLinkingResource) resource).resolveLazyCrossReferences(CancelIndicator.NullImpl);
	} else {
		EcoreUtil.resolveAll(resource);
	}
	return resource;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:AbstractXtextTests.java

示例13: doGetResource

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Override
public XtextResource doGetResource(final InputStream in, final URI uri) throws Exception {
  XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
  rs.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
  rs.setClasspathURIContext(this.getClass());
  Resource _createResource = this.getResourceFactory().createResource(uri);
  final XtextResource resource = ((XtextResource) _createResource);
  rs.getResources().add(resource);
  XtextLinker linker = new XtextLinker() {
    @Override
    protected Xtext2EcoreTransformer createTransformer(final Grammar grammar, final IDiagnosticConsumer consumer) {
      Xtext2EcoreTransformer result = super.createTransformer(grammar, consumer);
      ErrorAcceptor _errorAcceptor = result.getErrorAcceptor();
      Xtext2EcoreTransformerTest.MyErrorAcceptor _myErrorAcceptor = new Xtext2EcoreTransformerTest.MyErrorAcceptor(_errorAcceptor, Xtext2EcoreTransformerTest.this.errorAcceptorMock);
      result.setErrorAcceptor(_myErrorAcceptor);
      return result;
    }
  };
  ILinker _linker = resource.getLinker();
  linker.setScopeProvider(((XtextLinker) _linker).getScopeProvider());
  ILinker _linker_1 = resource.getLinker();
  linker.setLinkingService(((Linker) _linker_1).getLinkingService());
  ILinker _linker_2 = resource.getLinker();
  linker.setLinkingHelper(((Linker) _linker_2).getLinkingHelper());
  XtextLinker.PackageRemover _packageRemover = new XtextLinker.PackageRemover();
  linker.setPackageRemover(_packageRemover);
  LinkingDiagnosticMessageProvider _linkingDiagnosticMessageProvider = new LinkingDiagnosticMessageProvider();
  linker.setDiagnosticMessageProvider(_linkingDiagnosticMessageProvider);
  OnChangeEvictingCache _onChangeEvictingCache = new OnChangeEvictingCache();
  linker.setCache(_onChangeEvictingCache);
  resource.setLinker(linker);
  resource.load(in, null);
  return resource;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:41,代码来源:Xtext2EcoreTransformerTest.java

示例14: setClasspathURIContext

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
public void setClasspathURIContext(Object class1) {
	final XtextResourceSet resourceSet = new XtextResourceSet();
	resourceSet.setClasspathURIContext(class1);
	setResourceSetProvider(new Provider<ResourceSet>() {
		
		@Override
		public ResourceSet get() {
			return resourceSet;
		}
	});
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:UriBasedReader.java

示例15: doGetResource

import org.eclipse.xtext.resource.XtextResourceSet; //导入方法依赖的package包/类
@Override
protected XtextResource doGetResource(InputStream in, URI uri) throws Exception {
	XtextResourceSet rs = get(XtextResourceSet.class);
	rs.setClasspathURIContext(getClass());
	XtextResource resource = (XtextResource) factory.createResource(uri);
	rs.getResources().add(resource);
	resource.load(in, null);
	EcoreUtil.resolveAll(resource);
	return resource;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:Bug287988WithEagerLinkingTest.java


注:本文中的org.eclipse.xtext.resource.XtextResourceSet.setClasspathURIContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。