Search in sources :

Example 61 with TMember

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();
}
Also used : MemberType(org.eclipse.n4js.ts.types.MemberType) TMember(org.eclipse.n4js.ts.types.TMember)

Example 62 with TMember

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;
    }
}
Also used : TMember(org.eclipse.n4js.ts.types.TMember) TModule(org.eclipse.n4js.ts.types.TModule)

Example 63 with TMember

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);
            }
        }
    }
}
Also used : TMethod(org.eclipse.n4js.ts.types.TMethod) LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) EObject(org.eclipse.emf.ecore.EObject) TMember(org.eclipse.n4js.ts.types.TMember) FullMemberReference(org.eclipse.n4js.jsdoc.dom.FullMemberReference)

Example 64 with TMember

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;
}
Also used : TMember(org.eclipse.n4js.ts.types.TMember) MemberCollector(org.eclipse.n4js.utils.ContainerTypesHelper.MemberCollector)

Example 65 with TMember

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;
}
Also used : TMember(org.eclipse.n4js.ts.types.TMember)

Aggregations

TMember (org.eclipse.n4js.ts.types.TMember)65 EObject (org.eclipse.emf.ecore.EObject)19 TClassifier (org.eclipse.n4js.ts.types.TClassifier)13 Type (org.eclipse.n4js.ts.types.Type)13 ContainerType (org.eclipse.n4js.ts.types.ContainerType)11 ArrayList (java.util.ArrayList)10 TClass (org.eclipse.n4js.ts.types.TClass)10 TField (org.eclipse.n4js.ts.types.TField)10 TMethod (org.eclipse.n4js.ts.types.TMethod)9 TModule (org.eclipse.n4js.ts.types.TModule)9 MemberList (org.eclipse.n4js.ts.types.util.MemberList)9 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)9 HashSet (java.util.HashSet)8 HashMap (java.util.HashMap)7 NameStaticPair (org.eclipse.n4js.ts.types.util.NameStaticPair)7 MemberCollector (org.eclipse.n4js.utils.ContainerTypesHelper.MemberCollector)7 Optional (java.util.Optional)6 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)6 EcoreUtil2 (org.eclipse.xtext.EcoreUtil2)6 Inject (com.google.inject.Inject)5