use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class LinkingTest method doTestNestedTypeResolution.
protected void doTestNestedTypeResolution(String input, boolean success) throws Exception {
XtendFile file = file(input);
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XtendParameter firstParameter = m.getParameters().get(0);
JvmType parameterType = firstParameter.getParameterType().getType();
if (success)
assertEquals("org.eclipse.emf.ecore.EDataType$Internal$ConversionDelegate$Factory$Registry", parameterType.getIdentifier());
else
assertTrue(parameterType.eIsProxy());
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendQuickfixProvider method getExceptions.
/**
* @param all but the last element in the issue data is considered to be a URI to an exception type.
*/
protected List<JvmType> getExceptions(String[] issueData, XtextResource resource) {
List<JvmType> exceptions = Lists.newArrayList();
for (int i = 0; i < issueData.length - 1; i++) {
URI exceptionURI = URI.createURI(issueData[i]);
EObject exception = resource.getResourceSet().getEObject(exceptionURI, true);
if (exception instanceof JvmType) {
exceptions.add((JvmType) exception);
}
}
return exceptions;
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testEnumReference.
@Test
public void testEnumReference() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def baz(Foo f){}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("enum Foo { BAR, BAZ }");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers());
final JvmType en = IterableExtensions.<XtendParameter>head(((XtendFunction) _head).getParameters()).getParameterType().getType();
Assert.assertEquals("Foo", this.signatureProvider.getSignature(en));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testAnnotationReference.
@Test
public void testAnnotationReference() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("@Foo");
_builder.newLine();
_builder.append("class Bar {}");
_builder.newLine();
_builder.append("annotation Foo { }");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
final JvmType in = IterableExtensions.<XAnnotation>head(((XtendClass) _head).getAnnotations()).getAnnotationType();
Assert.assertEquals("Foo", this.signatureProvider.getSignature(in));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class ResourceStorageTest method testUpstreamResourcesAreLoadedFromStorage.
@Test
public void testUpstreamResourcesAreLoadedFromStorage() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package mypack");
_builder.newLine();
_builder.newLine();
_builder.append("class MyClass {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.helper.createFile("mypack/MyClass.xtend", _builder.toString());
final IProject downStreamProject = WorkbenchTestHelper.createPluginProject("downstream", this.helper.getProject().getName());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package downstream");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("class SomeClass {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def void foo(mypack.MyClass myClass) {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final IFile downstreamFile = this.helper.createFileImpl("/downstream/src/downstream/SomeClass.xtend", _builder_1.toString());
IResourcesSetupUtil.waitForBuild();
final URI downstreamUri = this.uriMapper.getUri(downstreamFile);
final ResourceSet resourceSet = this.resourceSetProvider.get(downStreamProject);
SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(downstreamUri)));
Resource _resource = resourceSet.getResource(downstreamUri, true);
final StorageAwareResource downstreamResource = ((StorageAwareResource) _resource);
EObject _get = downstreamResource.getContents().get(1);
final JvmGenericType type = ((JvmGenericType) _get);
final JvmType parameterType = IterableExtensions.<JvmFormalParameter>head(IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(type.getMembers(), JvmOperation.class)).getParameters()).getParameterType().getType();
Assert.assertNotNull(parameterType);
Resource _eResource = parameterType.eResource();
Assert.assertTrue(((StorageAwareResource) _eResource).isLoadedFromStorage());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations