use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendAnnotationReferenceImpl method getAnnotationTypeDeclaration.
@Override
public AnnotationTypeDeclaration getAnnotationTypeDeclaration() {
AnnotationTypeDeclaration _switchResult = null;
JvmType _annotationType = this.getAnnotationType();
final JvmType type = _annotationType;
boolean _matched = false;
if (type instanceof JvmAnnotationType) {
_matched = true;
TypeDeclaration _typeDeclaration = this.getCompilationUnit().toTypeDeclaration(((JvmDeclaredType) type));
_switchResult = ((AnnotationTypeDeclaration) _typeDeclaration);
}
if (!_matched) {
_switchResult = null;
}
return _switchResult;
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class AbstractXtendOutlineTreeBuilder method buildMembers.
protected void buildMembers(final JvmDeclaredType inferredType, final JvmDeclaredType baseType, @Extension final IXtendOutlineContext context) {
EList<JvmMember> _members = inferredType.getMembers();
for (final JvmMember member : _members) {
boolean _isProcessed = context.isProcessed(member);
boolean _not = (!_isProcessed);
if (_not) {
if ((member instanceof JvmDeclaredType)) {
boolean _isShowInherited = context.isShowInherited();
if (_isShowInherited) {
final IXtendOutlineContext typeContext = context.newContext();
final EObject sourceElement = this._iXtendJvmAssociations.getPrimarySourceElement(member);
if ((sourceElement instanceof XtendTypeDeclaration)) {
this.buildType(sourceElement, typeContext);
} else {
this.buildJvmType(((JvmDeclaredType) member), typeContext);
}
} else {
this.buildJvmType(((JvmDeclaredType) member), context);
}
} else {
if ((member instanceof JvmFeature)) {
boolean _skipFeature = this.skipFeature(((JvmFeature) member));
boolean _not_1 = (!_skipFeature);
if (_not_1) {
final IXtendOutlineContext featureContext = this.buildFeature(baseType, ((JvmFeature) member), member, context);
final Consumer<JvmGenericType> _function = (JvmGenericType it) -> {
this.buildJvmType(it, featureContext.newContext());
};
((JvmFeature) member).getLocalClasses().forEach(_function);
}
}
}
context.markAsProcessed(member);
}
}
boolean _isShowInherited_1 = context.isShowInherited();
if (_isShowInherited_1) {
this.buildInheritedMembers(inferredType, context);
}
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class JavaLinkingTest method testNavigateToXtendClassArray.
@Test
public void testNavigateToXtendClassArray() throws Exception {
IFile xtendFile = testHelper.createFile("test/XtendClass", "package test\nclass XtendClass {}");
IFile javaFile = testHelper.createFileImpl(WorkbenchTestHelper.TESTPROJECT_NAME + "/src/test/JavaClass.java", "package test;\npublic class JavaClass extends java.util.ArrayList<XtendClass[]> {}");
waitForBuild();
assertNumberOfMarkers(xtendFile, 0);
assertNumberOfMarkers(javaFile, 0);
ResourceSet resourceSet = resourceSetProvider.get(testHelper.getProject());
IJvmTypeProvider jvmTypeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
JvmType javaType = jvmTypeProvider.findTypeByName("test.JavaClass");
assertNotNull(javaType);
assertTrue(javaType instanceof JvmDeclaredType);
JvmDeclaredType declaredJavaType = (JvmDeclaredType) javaType;
JvmParameterizedTypeReference arrayList = (JvmParameterizedTypeReference) declaredJavaType.getSuperTypes().get(0);
JvmTypeReference arrayReference = arrayList.getArguments().get(0);
assertTrue(arrayReference instanceof JvmGenericArrayTypeReference);
JvmType arrayType = arrayReference.getType();
assertTrue(arrayType instanceof JvmArrayType);
JvmType xtendType = ((JvmArrayType) arrayType).getComponentType();
assertNotNull(xtendType);
assertEquals("test.XtendClass", xtendType.getQualifiedName());
Resource xtendResource = xtendType.eResource();
assertEquals("platform:/resource" + xtendFile.getFullPath(), xtendResource.getURI().toString());
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendCompiler method isVariableDeclarationRequired.
@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
boolean result = super.isVariableDeclarationRequired(expr, b, recursive);
if (result && expr instanceof XConstructorCall) {
EObject container = expr.eContainer();
if (container instanceof AnonymousClass) {
AnonymousClass anonymousClass = (AnonymousClass) container;
result = isVariableDeclarationRequired(anonymousClass, b, recursive);
if (result) {
JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor();
JvmDeclaredType type = constructor.getDeclaringType();
if (((JvmGenericType) type).isAnonymous()) {
return false;
}
}
}
}
return result;
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-xtend by eclipse.
the class XtendCompiler method _toJavaStatement.
@Override
protected void _toJavaStatement(final XConstructorCall expr, ITreeAppendable b, final boolean isReferenced) {
for (XExpression arg : expr.getArguments()) {
prepareExpression(arg, b);
}
if (!isReferenced) {
b.newLine();
constructorCallToJavaExpression(expr, b);
if (expr.eContainer() instanceof AnonymousClass) {
JvmConstructor constructor = expr.getConstructor();
JvmDeclaredType declaringType = constructor.getDeclaringType();
compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, b);
}
b.append(";");
} else if (isVariableDeclarationRequired(expr, b, true)) {
Later later = new Later() {
@Override
public void exec(ITreeAppendable appendable) {
constructorCallToJavaExpression(expr, appendable);
if (expr.eContainer() instanceof AnonymousClass) {
JvmConstructor constructor = expr.getConstructor();
JvmDeclaredType declaringType = constructor.getDeclaringType();
compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, appendable);
}
}
};
declareFreshLocalVariable(expr, b, later);
}
}
Aggregations