use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class MemberCube method addMembers.
private void addMembers(int source, List<TMember> members) {
for (TMember member : members) {
NameStaticPair nsp = NameStaticPair.of(member);
MemberMatrix memberMatrix = memberMatrixesByName.get(nsp);
if (memberMatrix == null) {
memberMatrix = new MemberMatrix();
memberMatrixesByName.put(nsp, memberMatrix);
}
memberMatrix.add(source, member);
}
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class JSDoc2ADocSpecProcessor method addMembers.
/**
* This method iterates through all members of a N4JS type and creates corresponding {@link SpecFile}s from them.
* During this process, member tests are linked if available.
*/
private void addMembers(SpecInfo specInfo, TN4Classifier classifier, Map<String, SpecSection> specsByKey, TreeMap<String, SpecFile> specChangeSet) {
MemberCollector memberCollector = containerTypesHelper.fromContext(classifier);
MemberList<TMember> memberList = memberCollector.allMembers(classifier, false, false, false);
Stream<TMember> nonPrivMembs = memberList.stream().filter(isNonPrivate());
// add spec region for new members
for (TMember member : (Iterable<TMember>) nonPrivMembs::iterator) {
SpecSection specSection = new SpecIdentifiableElementSection(specInfo, member, rootDir, repoPathHolder);
if (!specsByKey.containsKey(specSection.getSpecKey())) {
specSection.setTestInfosForMember(specInfo.getTestsForMember(member));
insertIntoSpecModuleFile(specChangeSet, specsByKey, (SpecIdentifiableElementSection) specSection);
}
}
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class SourceEntryFactory method getElementName.
private static String getElementName(IdentifiableElement ie) {
String elName = ie.getName();
if (ie instanceof TMember) {
TMember tm = (TMember) ie;
@SuppressWarnings("rawtypes") ContainerType ct = tm.getContainingType();
elName = ct.getName();
}
return elName;
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class ConcreteMembersOrderedForTranspiler method create.
/**
* Returns a tuple of collections used by transpiler to generate interface or class members.
*/
public static ConcreteMembersOrderedForTranspiler create(ContainerTypesHelper containerTypesHelper, TClassifier type, Script context) {
MemberCollector collector = containerTypesHelper.fromContext(context);
List<TMember> concreteInheritedMembers = (type instanceof TClass) ? collector.inheritedMembers((TClass) type) : emptyList();
List<TMember> ownedAndMixedInConcreteMembers = collector.computeOwnedAndMixedInConcreteMembers(type);
List<AccessorTuple> concreteAccessorTuples = getConcreteFieldAccessors(ownedAndMixedInConcreteMembers, concreteInheritedMembers);
MemberList<TField> fieldsOverridingAccessors = getFieldsOverridingAccessor(ownedAndMixedInConcreteMembers, concreteInheritedMembers);
// compute the list of mixed in fields, which do not override any Accessor (handled separately)
MemberList<TField> fieldsPurelyMixedInNotOverridingAccessor = new MemberList<>();
fieldsPurelyMixedInNotOverridingAccessor.addAll(ownedAndMixedInConcreteMembers.stream().filter(it -> it instanceof TField && // must stem from different type
it.getContainingType() != type).map(it -> (TField) it).filter(// remove the ones overriding get/set
it -> !fieldsOverridingAccessors.contains(it)).collect(Collectors.toList()));
return new ConcreteMembersOrderedForTranspiler(concreteInheritedMembers, ownedAndMixedInConcreteMembers, concreteAccessorTuples, fieldsOverridingAccessors, fieldsPurelyMixedInNotOverridingAccessor);
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class ConcreteMembersOrderedForTranspiler method getConcreteFieldAccessors.
/**
* Helper method, returns all concrete field accessors as tuples of the given classifier, which may even contain
* fields if they override concrete getters or setter. Since getter/setters can only be defined as pairs, in case of
* single owned getter with inherited setter, a delegate is created for the setter (and vice versa).
*/
private static List<AccessorTuple> getConcreteFieldAccessors(List<TMember> ownedAndMixedInConcreteMember, List<TMember> concreteInheritedMembers) {
Set<TField> ownedAndMixedInFields = new HashSet<>();
Set<TGetter> ownedAndMixedInGetters = new HashSet<>();
Map<NameStaticPair, TSetter> ownedAndMixedInSetters = new HashMap<>();
for (TMember m : ownedAndMixedInConcreteMember) {
if (m instanceof TField) {
ownedAndMixedInFields.add((TField) m);
} else if (m instanceof TGetter) {
ownedAndMixedInGetters.add((TGetter) m);
} else if (m instanceof TSetter) {
ownedAndMixedInSetters.put(NameStaticPair.of(m), (TSetter) m);
}
}
Map<NameStaticPair, TGetter> inheritedGetters = new HashMap<>();
Map<NameStaticPair, TSetter> inheritedSetters = new HashMap<>();
for (TMember m : concreteInheritedMembers) {
if (m instanceof TGetter) {
if (!ownedAndMixedInGetters.contains(m)) {
inheritedGetters.put(NameStaticPair.of(m), (TGetter) m);
}
} else if (m instanceof TSetter) {
NameStaticPair nsp = NameStaticPair.of(m);
if (ownedAndMixedInSetters.get(nsp) != m) {
inheritedSetters.put(nsp, (TSetter) m);
}
}
}
List<AccessorTuple> ownedOrMixedInAccessorTouples = mapToAccessorTuples(ownedAndMixedInGetters, ownedAndMixedInSetters, ownedAndMixedInFields, inheritedGetters, inheritedSetters);
return ownedOrMixedInAccessorTouples;
}
Aggregations