use of org.eclipse.xtext.common.types.JvmMember in project xtext-xtend by eclipse.
the class RegisterGlobalsContextImpl method setNameAndAccept.
private void setNameAndAccept(final JvmDeclaredType newType, final String qualifiedName) {
ConditionUtils.checkQualifiedName(qualifiedName, "qualifiedName");
JvmDeclaredType _findType = this.findType(qualifiedName);
boolean _tripleEquals = (_findType == null);
StringConcatenation _builder = new StringConcatenation();
_builder.append("The type \'");
_builder.append(qualifiedName);
_builder.append("\' has already been registered.");
Preconditions.checkArgument(_tripleEquals, _builder);
this.compilationUnit.checkCanceled();
final Pair<String, String> namespaceAndName = this.getNameParts(qualifiedName);
final String headerText = this.compilationUnit.getFileHeaderProvider().getFileHeader(this.compilationUnit.getXtendFile().eResource());
this.compilationUnit.getJvmTypesBuilder().setFileHeader(newType, headerText);
String _key = namespaceAndName.getKey();
boolean _tripleNotEquals = (_key != null);
if (_tripleNotEquals) {
final JvmDeclaredType parentType = this.findType(namespaceAndName.getKey());
if ((parentType != null)) {
EList<JvmMember> _members = parentType.getMembers();
_members.add(newType);
newType.setStatic(true);
} else {
newType.setPackageName(namespaceAndName.getKey());
this.acceptor.<JvmDeclaredType>accept(newType);
}
} else {
this.acceptor.<JvmDeclaredType>accept(newType);
}
newType.setSimpleName(namespaceAndName.getValue());
}
use of org.eclipse.xtext.common.types.JvmMember in project xtext-xtend by eclipse.
the class CompilationUnitImpl method translate.
protected Object translate(final Object object) {
if ((object instanceof XAnnotation[])) {
final AnnotationReference[] result = new AnnotationReference[((Object[]) object).length];
int _length = ((Object[]) object).length;
ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _length, true);
for (final Integer i : _doubleDotLessThan) {
result[(i).intValue()] = this.translateAnnotation(((XAnnotation[]) object)[(i).intValue()]);
}
return result;
}
if ((object instanceof XAnnotation)) {
return this.translateAnnotation(((XAnnotation) object));
}
if ((object instanceof JvmTypeReference[])) {
final TypeReference[] result_1 = new TypeReference[((Object[]) object).length];
int _length_1 = ((Object[]) object).length;
ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, _length_1, true);
for (final Integer i_1 : _doubleDotLessThan_1) {
Object _translate = this.translate(((Object[]) object)[(i_1).intValue()]);
result_1[(i_1).intValue()] = ((TypeReference) _translate);
}
return result_1;
}
if ((object instanceof JvmTypeReference)) {
return this.toTypeReference(((JvmTypeReference) object));
}
if ((object instanceof JvmEnumerationLiteral[])) {
final EnumerationValueDeclaration[] result_2 = new EnumerationValueDeclaration[((Object[]) object).length];
int _length_2 = ((Object[]) object).length;
ExclusiveRange _doubleDotLessThan_2 = new ExclusiveRange(0, _length_2, true);
for (final Integer i_2 : _doubleDotLessThan_2) {
Object _translate_1 = this.translate(((Object[]) object)[(i_2).intValue()]);
result_2[(i_2).intValue()] = ((EnumerationValueDeclaration) _translate_1);
}
return result_2;
}
if ((object instanceof JvmEnumerationLiteral)) {
return this.toMemberDeclaration(((JvmMember) object));
}
return object;
}
use of org.eclipse.xtext.common.types.JvmMember in project xtext-xtend by eclipse.
the class TypeParameterDeclarationImpl method getTypeParameterDeclarator.
@Override
public TypeParameterDeclarator getTypeParameterDeclarator() {
EObject _eContainer = this.getDelegate().eContainer();
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(((JvmMember) _eContainer));
return ((TypeParameterDeclarator) _memberDeclaration);
}
use of org.eclipse.xtext.common.types.JvmMember in project xtext-xtend by eclipse.
the class CachingResourceValidatorImpl method addWarningsForOrphanedJvmElements.
private void addWarningsForOrphanedJvmElements(final Resource resource, final CancelIndicator monitor, final IAcceptor<Issue> acceptor) {
final IssueSeverities issueSeverities = this.issueSeveritiesProvider.getIssueSeverities(resource);
final Severity severity = issueSeverities.getSeverity(IssueCodes.ORPHAN_ELMENT);
boolean _equals = Objects.equal(severity, Severity.IGNORE);
if (_equals) {
return;
}
Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(IterableExtensions.<EObject>tail(resource.getContents()), JvmDeclaredType.class);
for (final JvmDeclaredType jvmType : _filter) {
final Function1<JvmMember, Boolean> _function = (JvmMember it) -> {
boolean _isSynthetic = this._jvmTypeExtensions.isSynthetic(it);
return Boolean.valueOf((!_isSynthetic));
};
Iterable<JvmMember> _iterable = IteratorExtensions.<JvmMember>toIterable(IteratorExtensions.<JvmMember>filter(Iterators.<JvmMember>filter(jvmType.eAllContents(), JvmMember.class), _function));
for (final JvmMember jvmMember : _iterable) {
{
this.operationCanceledManager.checkCanceled(monitor);
final EObject sourceElement = this._iJvmModelAssociations.getPrimarySourceElement(jvmMember);
if ((sourceElement == null)) {
this.addWarningForOrphanedJvmElement(resource, jvmMember, severity, acceptor);
}
}
}
}
}
use of org.eclipse.xtext.common.types.JvmMember in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testXtendField_00.
@Test
public void testXtendField_00() throws Exception {
XtendFile xtendFile = file("class Foo { @Inject String string }");
JvmGenericType type = getInferredType(xtendFile);
Iterable<JvmField> iterable = type.getDeclaredFields();
JvmField next = iterable.iterator().next();
assertEquals("string", next.getSimpleName());
assertEquals(JvmVisibility.PRIVATE, next.getVisibility());
assertEquals("java.lang.String", next.getType().getIdentifier());
for (JvmMember member : type.getMembers()) {
if (member instanceof JvmExecutable) {
assertEquals(JvmVisibility.PUBLIC, member.getVisibility());
} else {
assertEquals(JvmVisibility.PRIVATE, member.getVisibility());
}
}
}
Aggregations