Search in sources :

Example 6 with FullMemberReference

use of org.eclipse.n4js.jsdoc.dom.FullMemberReference in project n4js by eclipse.

the class N4JSDReader method processTag.

private void processTag(Multimap<String, SpecInfo> specInfoByName, RepoRelativePath rrp, Collection<FullMemberReference> testeeRefsFromType, Collection<FullMemberReference> testeeTypeRefsFromType, TMember testMember, boolean isOwnedMember, EObject astElement, Doclet testMethodDoclet, LineTag tag) {
    String title = tag.getTitle().getTitle();
    if ("testee".equals(title)) {
        FullMemberReference ref = getFullMemberRef(tag);
        if (ref != null) {
            addTestInfoForCodeElement(rrp, testMethodDoclet, ref, testMember, specInfoByName);
        }
    } else if ("testeeFromType".equals(title)) {
        RepoRelativePath rrpTestMethod = isOwnedMember ? rrp : RepoRelativePath.compute(astElement.eResource(), n4jsCore);
        for (FullMemberReference ref : testeeRefsFromType) {
            addTestInfoForCodeElement(rrpTestMethod, testMethodDoclet, ref, testMember, specInfoByName);
        }
    } else if ("testeeMember".equals(title)) {
        String testeeMember = N4JSDocletParser.TAG_TESTEEMEMBER.getValue(tag, "");
        RepoRelativePath rrpTestMethod = isOwnedMember ? rrp : RepoRelativePath.compute(astElement.eResource(), n4jsCore);
        for (FullMemberReference testeeTypeRef : testeeTypeRefsFromType) {
            FullMemberReference combinedTesteeRef = EcoreUtil.copy(testeeTypeRef);
            combinedTesteeRef.setMemberName(testeeMember);
            combinedTesteeRef.setRange(tag.getBegin(), tag.getEnd());
            addTestInfoForCodeElement(rrpTestMethod, testMethodDoclet, combinedTesteeRef, testMember, specInfoByName);
        }
    } else if ("reqid".equals(title)) {
        String reqid = N4JSDocletParser.TAG_REQID.getValue(tag, "");
        if (Strings.isNullOrEmpty(reqid)) {
            throw new IllegalStateException("Found reqid tag without requirement ID.");
        }
        RepoRelativePath rrpTestMethod = isOwnedMember ? rrp : RepoRelativePath.compute(astElement.eResource(), n4jsCore);
        addTestInfoForRequirement(rrpTestMethod, testMethodDoclet, reqid, testMember, specInfoByName);
    } else {
        // should not happen
        System.err.println("unhandled referencing tag: " + title);
    }
}
Also used : FullMemberReference(org.eclipse.n4js.jsdoc.dom.FullMemberReference)

Example 7 with FullMemberReference

use of org.eclipse.n4js.jsdoc.dom.FullMemberReference 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 8 with FullMemberReference

use of org.eclipse.n4js.jsdoc.dom.FullMemberReference in project n4js by eclipse.

the class LineTagWithFullElementReference method parse.

@Override
public Tag parse(TagTitle title, JSDocCharScanner scanner, DescriptionParser descriptionParser) {
    FullMemberReference ref = parseReference(scanner, scanner.length());
    Tag tag = createLineTag(title);
    addValue(tag, REF, ref);
    return tag;
}
Also used : Tag(org.eclipse.n4js.jsdoc.dom.Tag) FullMemberReference(org.eclipse.n4js.jsdoc.dom.FullMemberReference)

Example 9 with FullMemberReference

use of org.eclipse.n4js.jsdoc.dom.FullMemberReference in project n4js by eclipse.

the class LineTagWithFullElementReference method createReferenceFromType.

@SuppressWarnings("javadoc")
public static FullMemberReference createReferenceFromType(TMember member) {
    FullMemberReference ref = DomFactory.eINSTANCE.createFullMemberReference();
    Type type = member.getContainingType();
    ref.setRange(-1, -1);
    ref.setModuleName(type.getContainingModule().getModuleSpecifier());
    ref.setTypeName(type.getName());
    ref.setStaticMember(member.isStatic());
    ref.setMemberName(member.getName());
    return ref;
}
Also used : Type(org.eclipse.n4js.ts.types.Type) FullMemberReference(org.eclipse.n4js.jsdoc.dom.FullMemberReference)

Aggregations

FullMemberReference (org.eclipse.n4js.jsdoc.dom.FullMemberReference)9 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)4 JSDocCompletionHint (org.eclipse.n4js.jsdoc.JSDocCompletionHint)3 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)3 DocletParser (org.eclipse.n4js.jsdoc.DocletParser)2 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)2 Tag (org.eclipse.n4js.jsdoc.dom.Tag)2 TMember (org.eclipse.n4js.ts.types.TMember)2 Type (org.eclipse.n4js.ts.types.Type)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 ITextViewer (org.eclipse.jface.text.ITextViewer)1 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 ITagDefinition (org.eclipse.n4js.jsdoc.ITagDefinition)1 JSDocCharScanner (org.eclipse.n4js.jsdoc.JSDocCharScanner)1 ScannerState (org.eclipse.n4js.jsdoc.JSDocCharScanner.ScannerState)1