use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendCompilerErrorHandlingTest method assertCompilesTo.
public void assertCompilesTo(final CharSequence input, final CharSequence expected, final boolean shouldBeSyntacticallyValid) {
try {
final XtendFile file = this.file(input.toString(), false, shouldBeSyntacticallyValid);
final Resource resource = file.eResource();
try {
this.issueProviderFactory.attachData(resource);
final JvmDeclaredType inferredType = IterableExtensions.<JvmDeclaredType>head(Iterables.<JvmDeclaredType>filter(resource.getContents(), JvmDeclaredType.class));
CharSequence javaCode = this.generator.generateType(inferredType, this.generatorConfigProvider.get(inferredType));
javaCode = this.postProcessor.postProcess(null, javaCode);
Assert.assertEquals(expected.toString(), javaCode.toString());
} finally {
this.issueProviderFactory.detachData(resource);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendValidationTest method testSyntheticallyUsedField.
@Test
public void testSyntheticallyUsedField() throws Exception {
XtendClass clazz = clazz("class X { String foo }");
JvmDeclaredType jvmType = (JvmDeclaredType) clazz.eResource().getContents().get(1);
EObject eObject = jvmType.getMembers().get(1);
readAndWriteTracking.markReadAccess(eObject);
helper.assertNoIssues(clazz.eContainer());
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendValidationTest method testSyntheticallyUsedFunction.
@Test
public void testSyntheticallyUsedFunction() throws Exception {
XtendClass clazz = clazz("class X { def private String foo() {} def bar(){}}");
JvmDeclaredType jvmType = (JvmDeclaredType) clazz.eResource().getContents().get(1);
EObject eObject = jvmType.getMembers().get(1);
readAndWriteTracking.markReadAccess(eObject);
helper.assertNoIssues(clazz.eContainer());
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class AbstractXtendCompilerTest method doAssertCompilesTo.
protected XtendFile doAssertCompilesTo(final CharSequence input, final CharSequence expected, final GeneratorConfig config, final boolean serializeAllTypes) {
try {
final XtendFile file = this.file(input.toString(), true);
final ArrayList<CharSequence> results = CollectionLiterals.<CharSequence>newArrayList();
Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(file.eResource().getContents(), JvmDeclaredType.class);
for (final JvmDeclaredType inferredType : _filter) {
{
Assert.assertFalse(DisableCodeGenerationAdapter.isDisabled(inferredType));
CharSequence javaCode = this.generator.generateType(inferredType, config);
javaCode = this.postProcessor.postProcess(null, javaCode);
results.add(javaCode);
if (this.useJavaCompiler) {
final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
it.getCompiledClass();
};
this.compilationTestHelper.compile(input, _function);
}
}
}
if (serializeAllTypes) {
Assert.assertEquals(expected.toString(), IterableExtensions.join(results, "\n"));
} else {
Assert.assertEquals(expected.toString(), IterableExtensions.<CharSequence>head(results).toString());
}
return file;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class AbstractMultiModeOutlineTreeProvider method createQualifier.
private String createQualifier(JvmMember jvmMember) {
String qualifier = null;
if (jvmMember instanceof JvmFeature) {
JvmDeclaredType declaringType = jvmMember.getDeclaringType();
qualifier = getPackageFreeNameForType(declaringType);
} else if (jvmMember instanceof JvmDeclaredType) {
if (jvmMember.eContainer() instanceof JvmDeclaredType) {
qualifier = getPackageFreeNameForType((JvmDeclaredType) jvmMember.eContainer());
} else {
JvmDeclaredType jvmDeclaredType = (JvmDeclaredType) jvmMember;
if (StringUtils.isEmpty(jvmDeclaredType.getPackageName())) {
qualifier = "(default package)";
} else {
qualifier = jvmDeclaredType.getPackageName();
}
}
}
return qualifier;
}
Aggregations