use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration 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.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ConstantExpressionsInterpreterTest method testConstants_WithStaticImport.
@Test
public void testConstants_WithStaticImport() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import static test.Constants1.* ");
_builder.newLine();
_builder.append("class C { ");
_builder.newLine();
_builder.append("\t");
_builder.append("val someString = STRING_CONSTANT");
_builder.newLine();
_builder.append("\t");
_builder.append("val someInt = INT_CONSTANT");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.file(_builder.toString());
final XtendField stringField = IterableExtensions.<XtendField>head(Iterables.<XtendField>filter(IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()).getMembers(), XtendField.class));
final XtendField intField = ((XtendField[]) Conversions.unwrapArray(Iterables.<XtendField>filter(IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()).getMembers(), XtendField.class), XtendField.class))[1];
Assert.assertEquals(Constants1.STRING_CONSTANT, this.interpreter.evaluate(stringField.getInitialValue(), null));
Assert.assertEquals(Integer.valueOf(Constants1.INT_CONSTANT), this.interpreter.evaluate(intField.getInitialValue(), null));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ProblemSupportTests method testErrorOnDerivedElement.
@Test
public void testErrorOnDerivedElement() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class MyClass {");
_builder.newLine();
_builder.append("\t");
_builder.append("String foo = \'foo\'");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
final MutableClassDeclaration derived = it.getTypeLookup().findClass("MyClass");
it.getProblemSupport().addError(derived, "error on derived element");
Assert.assertEquals("error on derived element", IterableExtensions.<Resource.Diagnostic>head(it.getXtendFile().eResource().getErrors()).getMessage());
Resource.Diagnostic _head = IterableExtensions.<Resource.Diagnostic>head(it.getXtendFile().eResource().getErrors());
Assert.assertEquals(IterableExtensions.<XtendTypeDeclaration>head(it.getXtendFile().getXtendTypes()), ((EObjectDiagnosticImpl) _head).getProblematicObject());
};
this.asCompilationUnit(this.validFile(_builder), _function);
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class UnloadingTest method testProperUnloading.
@Test
public void testProperUnloading() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class B {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void foo() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new A(this)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String fileB = _builder.toString();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class A {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("new (B b) {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
final List<XtendFile> parsedFiles = IterableExtensions.<XtendFile>toList(this.files(true, _builder_1.toString(), fileB));
Resource _eResource = parsedFiles.get(1).eResource();
final DerivedStateAwareResource resource = ((DerivedStateAwareResource) _eResource);
final Resource resourceA = IterableExtensions.<XtendFile>head(parsedFiles).eResource();
resource.reparse(fileB);
EObject _head = IterableExtensions.<EObject>head(resourceA.getContents());
final XtendFile file = ((XtendFile) _head);
XtendTypeDeclaration _head_1 = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head_2 = IterableExtensions.<XtendMember>head(((XtendClass) _head_1).getMembers());
Assert.assertNotNull(IterableExtensions.<XtendParameter>head(((XtendConstructor) _head_2).getParameters()).getParameterType().getType().eResource());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendCompiler method needSyntheticSelfVariable.
@Override
protected boolean needSyntheticSelfVariable(XClosure closure, LightweightTypeReference typeRef) {
JvmType jvmType = typeRef.getType();
TreeIterator<EObject> closureIterator = closure.eAllContents();
while (closureIterator.hasNext()) {
EObject obj1 = closureIterator.next();
if (obj1 instanceof XClosure) {
closureIterator.prune();
} else if (obj1 instanceof XtendTypeDeclaration) {
TreeIterator<EObject> typeIterator = obj1.eAllContents();
while (typeIterator.hasNext()) {
EObject obj2 = typeIterator.next();
if (obj2 instanceof XClosure) {
typeIterator.prune();
} else if (obj2 instanceof XFeatureCall && isReferenceToSelf((XFeatureCall) obj2, jvmType)) {
return true;
}
}
closureIterator.prune();
}
}
return false;
}
Aggregations