use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class MemberMatrix method toString.
@Override
public String toString() {
if (!allMembers().hasNext()) {
return "MemberMatrix not initialized yet.";
}
TMember first = allMembers().next();
StringBuilder strb = new StringBuilder("MemberMatrix: ");
if (first.isStatic()) {
strb.append("static ");
}
strb.append(first.getName());
strb.append("\n");
final int tab = 15;
StringBuilder row = new StringBuilder();
tab(row, 10);
for (int source = 0; source < SOURCE_COUNT_WITHOUT_CONSUMED; source++) {
row.append(COLS[source]);
if (source < 2) {
tab(row, 10 + (1 + source) * tab);
}
}
strb.append(row);
for (MemberType type : MemberType.values()) {
row.setLength(0);
row.append(type.getName()).append(": ");
tab(row, 10);
for (int source = 0; source < SOURCE_COUNT_WITHOUT_CONSUMED; source++) {
row.append(members(source, type).stream().map(m -> m.getContainingType().getName()).collect(Collectors.joining(",")));
if (source < 2) {
tab(row, 10 + (1 + source) * tab);
}
}
strb.append("\n").append(row);
}
strb.append("\n");
if (!consumed.isEmpty()) {
strb.append("consumed: ");
strb.append(consumed.stream().map(m -> m != null ? m.getMemberType() + " " + m.getContainingType().getName() + "." + m.getName() : "null").collect(Collectors.joining(",")));
}
return strb.toString();
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class KeyUtils method getSpecKeyWithoutProjectFolder.
/**
* @return a unique key for the given element. The source folder is not part of the key. Instead, only the module
* name is used.
*/
public static String getSpecKeyWithoutProjectFolder(RepoRelativePathHolder rrph, IdentifiableElement element) {
if (element instanceof TMember) {
ContainerType<?> containingType = ((TMember) element).getContainingType();
String specKeyOfType = getSpecKeyWithoutProjectFolder(rrph, containingType);
String specKey = specKeyOfType + "." + element.getName();
return specKey;
}
TModule module = element.getContainingModule();
if (module == null) {
return "GLOBAL.";
} else {
RepoRelativePath rrp = rrph.get(element);
String elementName = nameFromElement(rrph, element);
String key = getSpecKeyWithoutProjectFolder(rrp, elementName);
return key;
}
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class N4JSDReader method processClassifier.
private void processClassifier(Multimap<String, SpecInfo> specInfoByName, Type testType, TClassifier ctype) {
RepoRelativePath rrp = RepoRelativePath.compute(testType.eResource(), n4jsCore);
Doclet testTypeDoclet = n4jsDocHelper.getDoclet(ctype.getAstElement());
Collection<FullMemberReference> testeeRefsFromType = getFullMemberRefsFromType(testTypeDoclet);
Collection<FullMemberReference> testeeTypeRefsFromType = getFullTypeRefsFromType(testTypeDoclet);
MemberList<TMember> allMembers = containerTypesHelper.fromContext(testType).allMembers(ctype, false, false);
for (TMember testMember : allMembers) {
boolean isOwnedMember = testMember.getContainingType() == ctype;
if (testMember instanceof TMethod && AnnotationDefinition.TEST_METHOD.hasAnnotation(testMember)) {
EObject astElement = testMember.getAstElement();
if (!astElement.eIsProxy()) {
Doclet testMethodDoclet = n4jsDocHelper.getDoclet(astElement);
LineTag tag = findLinkToElementTag(testMethodDoclet, isOwnedMember);
if (tag != null) {
processTag(specInfoByName, rrp, testeeRefsFromType, testeeTypeRefsFromType, testMember, isOwnedMember, astElement, testMethodDoclet, tag);
}
} else {
System.err.println("cannot result AST when scanning for doclets: " + astElement);
}
}
}
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class N4JSDReader method getRefMember.
// TODO fqn of getter vs setter, fqn of static vs instance
private TMember getRefMember(ContainerType<?> ct, FullMemberReference ref) {
TMember member = null;
String memberName = ref.getMemberName();
boolean _static = ref.isStaticMember();
MemberCollector memberCollector = containerTypesHelper.fromContext(ct);
member = memberCollector.findMember(ct, memberName, false, _static);
if (member == null) {
member = memberCollector.findMember(ct, memberName, false, !_static);
if (member == null) {
member = memberCollector.findMember(ct, memberName, true, _static);
if (member == null) {
member = memberCollector.findMember(ct, memberName, true, !_static);
}
}
}
return member;
}
use of org.eclipse.n4js.ts.types.TMember in project n4js by eclipse.
the class SourceEntryFactory method getDelimiter.
private static String getDelimiter(IdentifiableElement ie) {
String delimiter = "";
if (ie instanceof TMember) {
TMember tm = (TMember) ie;
delimiter = tm.isStatic() ? "@" : "#";
if (tm.isGetter())
delimiter += "<";
if (tm.isSetter())
delimiter += ">";
}
return delimiter;
}
Aggregations