use of org.eclipse.xtext.common.types.JvmFeature in project xtext-xtend by eclipse.
the class SyntheticNameClashResolver method resolveNameClashes.
public void resolveNameClashes(JvmGenericType type) {
Multimap<String, JvmIdentifiableElement> classScope = HashMultimap.create();
List<JvmMember> renameableMembers = newArrayList();
int i = 1;
for (JvmMember member : type.getMembers()) {
String simpleName = member.getSimpleName();
if (simpleName != null) {
if (!isRenameable(member))
classScope.put(simpleName, member);
else
renameableMembers.add(member);
}
if (member instanceof JvmFeature) {
for (JvmGenericType localType : ((JvmFeature) member).getLocalClasses()) {
localType.setSimpleName(localType.getSimpleName() + '_' + (i++));
}
}
}
for (JvmMember renameable : renameableMembers) {
String simpleName = renameable.getSimpleName();
if (collides(renameable, simpleName, classScope)) {
int count = 0;
String currentName;
do {
if (count == Integer.MAX_VALUE)
throw new IllegalStateException("Cannot find a collision-free name for " + renameable.getIdentifier());
currentName = simpleName + "_" + ++count;
} while (collides(renameable, currentName, classScope));
renameable.setSimpleName(currentName);
classScope.put(currentName, renameable);
} else {
classScope.put(simpleName, renameable);
}
}
}
use of org.eclipse.xtext.common.types.JvmFeature in project xtext-xtend by eclipse.
the class EclipseXtendOutlineSourceContext method markCreateExtensionJvmFeaturesAsProcessed.
protected void markCreateExtensionJvmFeaturesAsProcessed(final JvmMember member) {
final EObject function = this._iXtendJvmAssociations.getPrimarySourceElement(member);
if ((function instanceof XtendFunction)) {
CreateExtensionInfo _createExtensionInfo = ((XtendFunction) function).getCreateExtensionInfo();
boolean _tripleNotEquals = (_createExtensionInfo != null);
if (_tripleNotEquals) {
final Function1<JvmFeature, Boolean> _function = (JvmFeature it) -> {
return Boolean.valueOf((!Objects.equal(it, member)));
};
final Function1<JvmFeature, Boolean> _function_1 = (JvmFeature it) -> {
return Boolean.valueOf((it.getSimpleName().startsWith(XtendJvmModelInferrer.CREATE_CHACHE_VARIABLE_PREFIX) || it.getSimpleName().startsWith(XtendJvmModelInferrer.CREATE_INITIALIZER_PREFIX)));
};
Iterable<JvmFeature> _filter = IterableExtensions.<JvmFeature>filter(IterableExtensions.<JvmFeature>filter(Iterables.<JvmFeature>filter(this._iXtendJvmAssociations.getJvmElements(function), JvmFeature.class), _function), _function_1);
for (final JvmFeature jvmFeature : _filter) {
super.markAsProcessed(jvmFeature);
}
}
}
}
Aggregations