use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class DeferredTypeParameterHintCollectorTest method createOwner.
@Override
protected StandardTypeReferenceOwner createOwner() {
CommonTypeComputationServices _services = this.getServices();
ResourceSet _contextResourceSet = this.getContextResourceSet();
return new StandardTypeReferenceOwner(_services, _contextResourceSet) {
@Override
public void acceptHint(final Object handle, final LightweightBoundTypeArgument boundTypeArgument) {
DeferredTypeParameterHintCollectorTest.this.hints.put(handle, boundTypeArgument);
}
@Override
public List<LightweightBoundTypeArgument> getAllHints(final Object handle) {
return DeferredTypeParameterHintCollectorTest.this.hints.get(handle);
}
@Override
public boolean isResolved(final Object handle) {
return false;
}
};
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class ValidationBug450834Test method test_01.
@Test
public void test_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("public static val c1 = 5");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile c = this.parser.parse(_builder);
final ResourceSet resourceSet = c.eResource().getResourceSet();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class D {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("public static val d1 = 5");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def void m() {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("if (C.c1 == D.d1) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final XtendFile d = this.parser.parse(_builder_1, resourceSet);
this.helper.assertWarning(d, XbasePackage.Literals.XBINARY_OPERATION, IssueCodes.CONSTANT_BOOLEAN_CONDITION, "Constant condition is always true");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class JavaIoFileSystemTest method setUp.
@Before
public void setUp() {
try {
final File tempDir = this.temporaryFolder.newFolder();
JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
File _file = new File(tempDir, "foo");
FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
it_2.addSourceFolder("src");
};
return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
};
it.setProjectConfigProvider(_function_1);
IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
it.setEncodingProvider(_runtime);
XtextResourceSet _xtextResourceSet = new XtextResourceSet();
it.setContext(_xtextResourceSet);
};
JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
this.fs = _doubleArrow;
this.createProject("foo");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class XtendResourceSetBasedResourceDescriptionsTest method testBidirectionalRef.
@Test
public void testBidirectionalRef() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo class ClassA extends bar.ClassB {}");
Pair<String, String> _mappedTo = Pair.<String, String>of("foo/ClassA.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package bar class ClassB { public foo.ClassA myField }");
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("bar/ClassB.xtend", _builder_1.toString());
final ResourceSet resourceSet = this.compiler.resourceSet(_mappedTo, _mappedTo_1);
final List<? extends Resource> resources = resourceSet.getResources();
ArrayList<Resource> _arrayList = new ArrayList<Resource>(resources);
for (final Resource res : _arrayList) {
{
final List<Issue> issues = this.validator.validate(res, CheckMode.ALL, CancelIndicator.NullImpl);
Assert.assertTrue(issues.toString(), issues.isEmpty());
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.ResourceSet in project xtext-xtend by eclipse.
the class TestCaseCompiler method compile.
public void compile(String qualifiedName) throws IOException {
ResourceSet set = injector.getInstance(ResourceSet.class);
final String from = "src/" + qualifiedName.replace('.', '/') + ".xtend";
final String to = "src-gen/" + qualifiedName.replace('.', '/') + ".java";
Resource res = set.getResource(org.eclipse.emf.common.util.URI.createFileURI(from), true);
EcoreUtil.resolveAll(res);
if (!res.getErrors().isEmpty())
throw new RuntimeException(res.getErrors().toString());
final File file = new File(to);
createFolders(file);
FileWriter writer = new FileWriter(file);
IXtendJvmAssociations associations = injector.getInstance(IXtendJvmAssociations.class);
JvmModelGenerator generator = injector.getInstance(JvmModelGenerator.class);
XtendFile xtendFile = (XtendFile) res.getContents().get(0);
JvmGenericType inferredType = associations.getInferredType((XtendClass) xtendFile.getXtendTypes().get(0));
GeneratorConfig config = injector.getInstance(IGeneratorConfigProvider.class).get(inferredType);
CharSequence javaCode = generator.generateType(inferredType, config);
writer.append(javaCode);
writer.close();
System.out.println("compiled " + from + " to " + to);
}
Aggregations