Search in sources :

Example 81 with Type

use of org.eclipse.n4js.ts.types.Type in project n4js by eclipse.

the class N4JSDReader method getRealTopLevelTypes.

/**
 * The method {@link TModule#getTopLevelTypes()} returns also functions that are nested in functions. These are
 * filtered out in this method.
 *
 * @return real top level types
 */
private Collection<Type> getRealTopLevelTypes(Script script) {
    Collection<Type> realTLT = new LinkedList<>();
    for (Type tlt : script.getModule().getTopLevelTypes()) {
        if (tlt instanceof SyntaxRelatedTElement) {
            SyntaxRelatedTElement srte = (SyntaxRelatedTElement) tlt;
            EObject astElem = srte.getAstElement();
            astElem = astElem != null ? astElem.eContainer() : null;
            FunctionOrFieldAccessor fofa = EcoreUtil2.getContainerOfType(astElem, FunctionOrFieldAccessor.class);
            if (fofa != null) {
                continue;
            }
        }
        realTLT.add(tlt);
    }
    return realTLT;
}
Also used : ContainerType(org.eclipse.n4js.ts.types.ContainerType) Type(org.eclipse.n4js.ts.types.Type) FunctionOrFieldAccessor(org.eclipse.n4js.n4JS.FunctionOrFieldAccessor) SyntaxRelatedTElement(org.eclipse.n4js.ts.types.SyntaxRelatedTElement) EObject(org.eclipse.emf.ecore.EObject) LinkedList(java.util.LinkedList)

Example 82 with Type

use of org.eclipse.n4js.ts.types.Type in project n4js by eclipse.

the class SpecModuleFile method ensureNewContent.

private String ensureNewContent() {
    if (newContent != null)
        return newContent;
    StringBuilder strb = new StringBuilder();
    int startline = 1;
    startline = generateModuleHeader(strb, startline);
    startline = generateVariableSection(strb, startline);
    startline = generateFunctionSection(strb, startline);
    for (Iterator<Type> it = types.iterator(); it.hasNext(); ) {
        Type type = it.next();
        startline = generateTypeSection(strb, startline, type);
    }
    newContent = strb.toString();
    return newContent;
}
Also used : Type(org.eclipse.n4js.ts.types.Type)

Example 83 with Type

use of org.eclipse.n4js.ts.types.Type in project n4js by eclipse.

the class SpecModuleFile method add.

/**
 * Adds another region change entry to this file.
 */
@Override
public void add(SpecSection specElem) {
    if (!(specElem instanceof SpecIdentifiableElementSection))
        return;
    SpecIdentifiableElementSection specIE = (SpecIdentifiableElementSection) specElem;
    EObject container = specIE.idElement.eContainer();
    if (container instanceof Type) {
        addTypeElement((Type) container, specIE);
        return;
    }
    if (specIE.idElement instanceof TFunction) {
        functions.add(specIE);
        allSections.add(specIE);
        return;
    }
    if (specIE.idElement instanceof TVariable) {
        variables.add(specIE);
        allSections.add(specIE);
        return;
    }
    if (specIE.idElement instanceof Type) {
        addTypeElement((Type) specIE.idElement, specIE);
        return;
    }
    throw new RuntimeException("Missing Implementation");
}
Also used : Type(org.eclipse.n4js.ts.types.Type) TFunction(org.eclipse.n4js.ts.types.TFunction) TVariable(org.eclipse.n4js.ts.types.TVariable) EObject(org.eclipse.emf.ecore.EObject)

Example 84 with Type

use of org.eclipse.n4js.ts.types.Type 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

Type (org.eclipse.n4js.ts.types.Type)84 ContainerType (org.eclipse.n4js.ts.types.ContainerType)32 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)28 TStructuralType (org.eclipse.n4js.ts.types.TStructuralType)26 EObject (org.eclipse.emf.ecore.EObject)21 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)21 PrimitiveType (org.eclipse.n4js.ts.types.PrimitiveType)19 AnyType (org.eclipse.n4js.ts.types.AnyType)18 UndefinedType (org.eclipse.n4js.ts.types.UndefinedType)18 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)17 NullType (org.eclipse.n4js.ts.types.NullType)17 VoidType (org.eclipse.n4js.ts.types.VoidType)17 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)16 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)16 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)16 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)16 ModuleNamespaceVirtualType (org.eclipse.n4js.ts.types.ModuleNamespaceVirtualType)16 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)16 Result (org.eclipse.xsemantics.runtime.Result)16 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)15