org.eclipse.xtext.resource.XtextResourceSet Java Examples
The following examples show how to use
org.eclipse.xtext.resource.XtextResourceSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XIncrementalBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Run the build. * <p> * Cancellation behavior: does not throw exception but returns with a partial result. */ public XBuildResult build(XBuildRequest request, IResourceClusteringPolicy clusteringPolicy) { ResourceDescriptionsData resDescrsCopy = request.getState().getResourceDescriptions().copy(); XSource2GeneratedMapping fileMappingsCopy = request.getState().getFileMappings().copy(); XIndexState oldState = new XIndexState(resDescrsCopy, fileMappingsCopy); XtextResourceSet resourceSet = request.getResourceSet(); XBuildContext context = new XBuildContext(languagesRegistry::getResourceServiceProvider, resourceSet, oldState, clusteringPolicy, request.getCancelIndicator()); XStatefulIncrementalBuilder builder = provider.get(); builder.setContext(context); builder.setRequest(request); return builder.launch(); }
Example #2
Source File: FormatterFacade.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public String format(final String xtendCode) { try { final XtextResourceSet resourceSet = new XtextResourceSet(); Resource _createResource = this.resourceFactory.createResource(URI.createURI("synthetic://to-be-formatted.xtend")); final XtextResource resource = ((XtextResource) _createResource); EList<Resource> _resources = resourceSet.getResources(); _resources.add(resource); StringInputStream _stringInputStream = new StringInputStream(xtendCode); resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap()); final ITextRegionAccess regionAccess = this.regionAccessBuilder.get().forNodeModel(resource).create(); FormatterRequest _formatterRequest = new FormatterRequest(); final Procedure1<FormatterRequest> _function = (FormatterRequest it) -> { it.setAllowIdentityEdits(false); it.setTextRegionAccess(regionAccess); it.setPreferences(TypedPreferenceValues.castOrWrap(this.cfgProvider.getPreferenceValues(resource))); }; FormatterRequest request = ObjectExtensions.<FormatterRequest>operator_doubleArrow(_formatterRequest, _function); List<ITextReplacement> replacements = this.formatter.format(request); return regionAccess.getRewriter().renderToString(replacements); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #3
Source File: XStatefulIncrementalBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void removeGeneratedFiles(URI source, XSource2GeneratedMapping source2GeneratedMapping) { Map<URI, String> outputConfigMap = source2GeneratedMapping.deleteSourceAndGetOutputConfigs(source); IResourceServiceProvider serviceProvider = context.getResourceServiceProvider(source); IContextualOutputConfigurationProvider2 outputConfigurationProvider = serviceProvider .get(IContextualOutputConfigurationProvider2.class); XtextResourceSet resourceSet = request.getResourceSet(); Set<OutputConfiguration> outputConfigs = outputConfigurationProvider.getOutputConfigurations(resourceSet); Map<String, OutputConfiguration> outputConfigsMap = Maps.uniqueIndex(outputConfigs, OutputConfiguration::getName); URIConverter uriConverter = resourceSet.getURIConverter(); for (URI generated : outputConfigMap.keySet()) { OutputConfiguration config = outputConfigsMap.get(outputConfigMap.get(generated)); if (config != null && config.isCleanUpDerivedResources()) { try { uriConverter.delete(generated, CollectionLiterals.emptyMap()); request.setResultDeleteFile(generated); } catch (IOException e) { Exceptions.sneakyThrow(e); } } } }
Example #4
Source File: SerializationUtil.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public static String getCompleteContent(XtextResource xr) throws IOException, UnsupportedEncodingException { XtextResourceSet resourceSet = (XtextResourceSet) xr.getResourceSet(); URIConverter uriConverter = resourceSet.getURIConverter(); URI uri = xr.getURI(); String encoding = xr.getEncoding(); InputStream inputStream = null; try { inputStream = uriConverter.createInputStream(uri); return getCompleteContent(encoding, inputStream); } finally { tryClose(inputStream, null); } }
Example #5
Source File: ContentAssistContextTestHelper.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private XtextResource parse(final String doc) { try { String _primaryFileExtension = this.fileExtension.getPrimaryFileExtension(); String _plus = ("dummy." + _primaryFileExtension); final URI uri = URI.createURI(_plus); Resource _createResource = this.resFactory.createResource(uri); final XtextResource res = ((XtextResource) _createResource); EList<Resource> _resources = new XtextResourceSet().getResources(); _resources.add(res); if ((this.entryPoint != null)) { res.setEntryPoint(this.entryPoint); } StringInputStream _stringInputStream = new StringInputStream(doc); res.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap()); this.validator.assertNoErrors(res); return res; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #6
Source File: ClasspathTypeProviderFactory.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public ClassLoader getClassLoader(ResourceSet resourceSet) { if (resourceSet instanceof XtextResourceSet) { XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet; Object ctx = xtextResourceSet.getClasspathURIContext(); if (ctx != null) { if (ctx instanceof Class<?>) { return ((Class<?>)ctx).getClassLoader(); } if (!(ctx instanceof ClassLoader)) { return ctx.getClass().getClassLoader(); } return (ClassLoader) ctx; } } return classLoader; }
Example #7
Source File: FormatterFacadeTest.java From sarl with Apache License 2.0 | 6 votes |
private void assertResourceContentFormat(String source, String expected) throws IOException { final ResourceSet resourceSet = new XtextResourceSet(); final URI createURI = URI.createURI("synthetic://to-be-formatted.sarl"); //$NON-NLS-1$ final XtextResource resource = (XtextResource) this.resourceFactory.createResource(createURI); resourceSet.getResources().add(resource); try (StringInputStream stringInputStream = new StringInputStream(source)) { resource.load(stringInputStream, Collections.emptyMap()); } this.facade.format(resource); final String actual; try (ByteArrayOutputStream stringOutputStream = new ByteArrayOutputStream()) { resource.save(stringOutputStream, Collections.emptyMap()); stringOutputStream.flush(); actual = stringOutputStream.toString(); } assertEquals(expected, actual); }
Example #8
Source File: DirtyStateResourceDescriptionTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public XtextResource parse(final String fileName, final CharSequence model) { try { XtextResource _xblockexpression = null; { final XtextResourceSet rs = this.resourceSetProvider.get(); Resource _createResource = rs.createResource(URI.createURI((fileName + ".xtend"))); final XtextResource r = ((XtextResource) _createResource); String _string = model.toString(); StringInputStream _stringInputStream = new StringInputStream(_string); r.load(_stringInputStream, Collections.<Object, Object>unmodifiableMap(CollectionLiterals.<Object, Object>newHashMap())); _xblockexpression = r; } return _xblockexpression; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #9
Source File: XtextFormatterTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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")); }
Example #10
Source File: ResourceAccess.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void registerResourceSet(ResourceSet resourceSet) { if (resourceSet instanceof XtextResourceSet) { Object context = ((XtextResourceSet) resourceSet).getClasspathURIContext(); if (context instanceof IJavaProject) { IProject project = ((IJavaProject) context).getProject(); resourceSets.put(project, resourceSet); } } this.fallBackResourceSet = resourceSet; }
Example #11
Source File: DefaultResourceDescription2Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testNotYetLinked() throws Exception { XtextResourceSet rs = get(XtextResourceSet.class); Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage")); res1.load(new StringInputStream("type Foo"), null); XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage")); res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Bar extends Foo"), null); Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames(); assertTrue(names.iterator().hasNext()); }
Example #12
Source File: GrammarParser.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public Grammar parse(String rules) throws IOException { ResourceSet resourceSet = new XtextResourceSet(); Resource grammarResource = resourceSet.createResource(URI.createURI("Test.xtext")); grammarResource.load(new StringInputStream( "grammar Test with org.eclipse.xtext.common.Terminals \n" + "generate test \"Test\"\n" + rules), null); EList<EObject> contents = grammarResource.getContents(); assertEquals(1, contents.size()); EObject root = contents.get(0); assertTrue(root instanceof Grammar); return (Grammar) root; }
Example #13
Source File: SerializationBug269362Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(SerializationBug269362TestLanguageStandaloneSetup.class); resourceSet = get(XtextResourceSet.class); resource = get(XtextResource.class); resourceSet.getResources().add(resource); model = SerializationBug269362TestLanguageFactory.eINSTANCE .createModel(); resource.getContents().add(model); }
Example #14
Source File: XtextSerializerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testFQNInSuper_01() { GrammarProvider grammarProvider = new GrammarProvider("org.eclipse.xtext.grammarinheritance.InheritanceTestLanguage", new Provider<XtextResourceSet>() { @Override public XtextResourceSet get() { return XtextSerializerTest.this.get(XtextResourceSet.class); } }); grammarProvider.setClassLoader(getClass().getClassLoader()); TerminalsGrammarAccess gaTerminals = new TerminalsGrammarAccess(grammarProvider); BaseInheritanceTestLanguageGrammarAccess gaBaseInheritanceTestLanguage = new BaseInheritanceTestLanguageGrammarAccess(grammarProvider, gaTerminals); InheritanceTestLanguageGrammarAccess grammarAccess = new InheritanceTestLanguageGrammarAccess(grammarProvider, gaBaseInheritanceTestLanguage, gaTerminals); String string = get(ISerializer.class).serialize(grammarAccess.getFQNRule().getAlternatives()); Assert.assertEquals("ID (\".\" ID)*", string); }
Example #15
Source File: XtextScopingTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); with(XtextStandaloneSetup.class); XtextResourceSet resourceSet = get(XtextResourceSet.class); resourceSet.setClasspathURIContext(getClass().getClassLoader()); Resource resource = resourceSet.getResource( URI.createURI("classpath:/org/eclipse/xtext/grammarinheritance/ConcreteTestLanguage.xtext"), true); grammar = (Grammar) resource.getContents().get(0); }
Example #16
Source File: DefaultResourceDescription2Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testValidLocalLink() throws Exception { XtextResourceSet rs = get(XtextResourceSet.class); Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage")); res1.load(new StringInputStream("type Foo"), null); XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage")); res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Foo type Bar extends Foo"), null); EcoreUtil.resolveAll(res2); Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames(); assertFalse(names.iterator().hasNext()); }
Example #17
Source File: SubPackageAwareGrammarAccessFragmentTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@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); fragment = new GrammarAccessFragment(); }
Example #18
Source File: SemanticSequencerExtensions.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ResourceSet cloneResourceSet(final ResourceSet rs) { final XtextResourceSet result = new XtextResourceSet(); result.setPackageRegistry(rs.getPackageRegistry()); result.setResourceFactoryRegistry(rs.getResourceFactoryRegistry()); result.setURIConverter(rs.getURIConverter()); if ((rs instanceof XtextResourceSet)) { result.setClasspathURIContext(((XtextResourceSet)rs).getClasspathURIContext()); result.setClasspathUriResolver(((XtextResourceSet)rs).getClasspathUriResolver()); } return result; }
Example #19
Source File: ReusedTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); if (ReusedTypeProviderTest.typeProvider == null) { String pathToSources = "/org/eclipse/xtext/common/types/testSetups"; List<String> files = ReusedTypeProviderTest.readResource(pathToSources + "/files.list"); ResourceDescriptionsData part = new ResourceDescriptionsData(Collections.emptySet()); XtextResourceSet resourceSet = resourceSetProvider.get(); ProjectDescription projectDesc = new ProjectDescription(); projectDesc.setName("my-test-project"); projectDesc.attachToEmfObject(resourceSet); ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(Collections.emptyMap(), resourceSet); index.setContainer(projectDesc.getName(), part); resourceSet.setClasspathURIContext(ReusedTypeProviderTest.class.getClassLoader()); typeProviderFactory.createTypeProvider(resourceSet); BuildRequest buildRequest = new BuildRequest(); for (String file : files) { if (file != null) { String fullPath = pathToSources + "/" + file; URL url = ReusedTypeProviderTest.class.getResource(fullPath); buildRequest.getDirtyFiles().add(URI.createURI(url.toExternalForm())); } } buildRequest.setResourceSet(resourceSet); buildRequest.setState(new IndexState(part, new Source2GeneratedMapping())); builder.build(buildRequest, (URI it) -> { return resourceServiceProviderRegistry.getResourceServiceProvider(it); }); ReusedTypeProviderTest.typeProvider = typeProviderFactory.findTypeProvider(resourceSet); } }
Example #20
Source File: AbstractXtendTestCase.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected XtendFile fileWithErrors(String string) throws Exception { XtextResourceSet set = getResourceSet(); String fileName = getFileName(string); Resource resource = set.createResource(URI.createURI(fileName + ".xtend")); resource.load(new StringInputStream(string), null); assertTrue(resource.getErrors().toString(), resource.getErrors().size() > 0); XtendFile file = (XtendFile) resource.getContents().get(0); return file; }
Example #21
Source File: ScriptEngineImpl.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private XtextResourceSet getResourceSet() { if (resourceSet == null) { resourceSet = ScriptStandaloneSetup.getInjector().getInstance(XtextResourceSet.class); resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.FALSE); } return resourceSet; }
Example #22
Source File: AbstractXtextTests.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
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; }
Example #23
Source File: XtendBatchCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * Performs the actual installation of the JvmTypeProvider. */ private void internalInstallJvmTypeProvider(ResourceSet resourceSet, File tmpClassDirectory, boolean skipIndexLookup) { Iterable<String> classPathEntries = concat(asList(tmpClassDirectory.toString()), getClassPathEntries(), getSourcePathDirectories()); classPathEntries = filter(classPathEntries, new Predicate<String>() { @Override public boolean apply(String input) { return !Strings.isEmpty(input.trim()); } }); Iterable<File> classpath = transform(classPathEntries, TO_FILE); if (log.isDebugEnabled()) { log.debug("classpath used for Xtend compilation : " + classpath); } ClassLoader parentClassLoader; if (useCurrentClassLoaderAsParent) { parentClassLoader = currentClassLoader; } else { if (isEmpty(bootClassPath)) { parentClassLoader = ClassLoader.getSystemClassLoader().getParent(); } else { Iterable<File> bootClassPathEntries = transform(getBootClassPathEntries(), TO_FILE); parentClassLoader = new AlternateJdkLoader(bootClassPathEntries); } } jvmTypesClassLoader = createClassLoader(classpath, parentClassLoader); new ClasspathTypeProvider(jvmTypesClassLoader, resourceSet, skipIndexLookup ? null : indexedJvmTypeAccess, null); ((XtextResourceSet) resourceSet).setClasspathURIContext(jvmTypesClassLoader); // for annotation processing we need to have the compiler's classpath as a parent. annotationProcessingClassLoader = createClassLoader(classpath, currentClassLoader); resourceSet.eAdapters().add(new ProcessorInstanceForJvmTypeProvider.ProcessorClassloaderAdapter(annotationProcessingClassLoader)); }
Example #24
Source File: BundleAwareTypeProvider.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@inheritDoc} */ @Override protected BinaryClassFinder createBinaryClassFinder(final ClassLoader classLoader) { if (getResourceSet() instanceof XtextResourceSet) { Object context = ((XtextResourceSet) getResourceSet()).getClasspathURIContext(); if (context instanceof Bundle) { Bundle bundle = (Bundle) context; return new BundleClassFinder(classLoader, bundle); } } return super.createBinaryClassFinder(classLoader); }
Example #25
Source File: AbstractXtextResourceSetTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testResourcesAreInMapWithNormalizedURI_03() { final XtextResourceSet rs = this.createEmptyResourceSet(); Assert.assertEquals(0, rs.getURIResourceMap().size()); final XtextResource resource = new XtextResource(); EList<Resource> _resources = rs.getResources(); _resources.add(resource); Assert.assertEquals(1, rs.getURIResourceMap().size()); Assert.assertEquals(resource, rs.getURIResourceMap().get(null)); Assert.assertEquals(0, rs.getNormalizationMap().size()); resource.setURI(URI.createURI("/a/../foo")); Assert.assertEquals(2, rs.getURIResourceMap().size()); Assert.assertFalse(rs.getURIResourceMap().containsKey(null)); Assert.assertEquals(resource, rs.getURIResourceMap().get(resource.getURI())); Assert.assertEquals(resource, rs.getURIResourceMap().get(rs.getURIConverter().normalize(resource.getURI()))); Assert.assertEquals(1, rs.getNormalizationMap().size()); Assert.assertEquals(rs.getURIConverter().normalize(resource.getURI()), rs.getNormalizationMap().get(resource.getURI())); resource.setURI(URI.createURI("/a/../bar")); Assert.assertEquals(2, rs.getURIResourceMap().size()); Assert.assertFalse(rs.getURIResourceMap().containsKey(null)); Assert.assertEquals(resource, rs.getURIResourceMap().get(resource.getURI())); Assert.assertEquals(resource, rs.getURIResourceMap().get(rs.getURIConverter().normalize(resource.getURI()))); Assert.assertEquals(1, rs.getNormalizationMap().size()); Assert.assertEquals(rs.getURIConverter().normalize(resource.getURI()), rs.getNormalizationMap().get(resource.getURI())); resource.setURI(null); Assert.assertEquals(1, rs.getURIResourceMap().size()); Assert.assertEquals(resource, rs.getURIResourceMap().get(null)); Assert.assertEquals(0, rs.getNormalizationMap().size()); rs.getResources().remove(resource); Assert.assertTrue(resource.eAdapters().isEmpty()); Assert.assertEquals(0, rs.getURIResourceMap().size()); Assert.assertEquals(0, rs.getNormalizationMap().size()); }
Example #26
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private boolean isRuntime(ReferencedMetamodel metamodelReference) { ResourceSet resourceSet = metamodelReference.eResource().getResourceSet(); if (resourceSet instanceof XtextResourceSet) { Object context = ((XtextResourceSet) resourceSet).getClasspathURIContext(); boolean result = context == null || context instanceof Class || context instanceof ClassLoader; return result; } return false; }
Example #27
Source File: AbstractContentAssistTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public XtextResource getResourceFor(InputStream stream) { try { XtextResourceSet set = resourceSetProvider.get(); initializeTypeProvider(set); Resource result = set.createResource(URI.createURI("Test." + fileExtensionProvider.getPrimaryFileExtension())); result.load(stream, null); return (XtextResource) result; } catch (IOException e) { throw Exceptions.sneakyThrow(e); } }
Example #28
Source File: OpenFileContext.java From n4js with Eclipse Public License 1.0 | 5 votes |
protected XtextResourceSet createResourceSet() { XtextResourceSet result = resourceSetProvider.get(); ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(result, index); externalContentSupport.configureResourceSet(result, new OpenFileContentProvider()); IAllContainersState allContainersState = new OpenFileAllContainersState(this); result.eAdapters().add(new DelegatingIAllContainerAdapter(allContainersState)); return result; }
Example #29
Source File: NewlineAwareXcoreStandaloneSetup.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public XtextResourceSet getInitializedResourceSet() { XtextResourceSet resourceSet = new XtextResourceSet() { @Override public Resource createResource(URI uri) { Resource result = getResource(uri, false); if (result == null) return super.createResource(uri); return result; } }; injector.injectMembers(resourceSet); resourceSet.eAdapters().add(new AllContainerAdapter(resourceSet)); return resourceSet; }
Example #30
Source File: DefaultResourceDescription2Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathURIIsNormalized() { XtextResourceSet xtextResourceSet = new XtextResourceSet(); xtextResourceSet.setClasspathURIContext(this); URI classpathURI = URI.createURI("classpath:/org/eclipse/xtext/XtextGrammarTestLanguage.ecore"); Resource resource = xtextResourceSet.getResource(classpathURI, true); IResourceDescription ecoreResourceDescription = createResourceDescription(resource); assertNotSame(classpathURI, ecoreResourceDescription.getURI()); assertEquals(xtextResourceSet.getURIConverter().normalize(classpathURI), ecoreResourceDescription.getURI()); }