Search in sources :

Example 41 with ISubReference

use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Enumerated_Type method getFieldType.

@Override
public final /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
            return null;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference)

Example 42 with ISubReference

use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Enumerated_Type method addDeclaration.

@Override
public final /**
 * {@inheritDoc}
 */
void addDeclaration(final DeclarationCollector declarationCollector, final int i) {
    final List<ISubReference> subreferences = declarationCollector.getReference().getSubreferences();
    if (subreferences.size() <= i) {
        return;
    }
    final ISubReference subreference = subreferences.get(i);
    if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
        if (subreferences.size() <= i + 1) {
            final String referenceName = subreference.getId().getName();
            if (enumerations.enumItems1 != null) {
                final List<EnumItem> enumItems = enumerations.enumItems1.getItems();
                for (EnumItem item : enumItems) {
                    final Identifier itemID = item.getId();
                    if (itemID.getName().startsWith(referenceName)) {
                        declarationCollector.addDeclaration(itemID.getDisplayName(), itemID.getLocation(), this);
                    }
                }
            }
            if (enumerations.enumItems2 != null) {
                final List<EnumItem> enumItems = enumerations.enumItems2.getItems();
                for (EnumItem item : enumItems) {
                    final Identifier itemID = item.getId();
                    if (itemID.getName().startsWith(referenceName)) {
                        declarationCollector.addDeclaration(itemID.getDisplayName(), itemID.getLocation(), this);
                    }
                }
            }
        }
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) EnumItem(org.eclipse.titan.designer.AST.TTCN3.types.EnumItem)

Example 43 with ISubReference

use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.

the class ASN1Module method addDeclaration.

@Override
public /**
 * {@inheritDoc}
 */
void addDeclaration(final DeclarationCollector declarationCollector) {
    final Identifier moduleId = declarationCollector.getReference().getModuleIdentifier();
    if (null == moduleId) {
        final List<ISubReference> subrefs = declarationCollector.getReference().getSubreferences();
        if (1 == subrefs.size() && null != identifier && identifier.getName().equals(subrefs.get(0).getId().getName())) {
            declarationCollector.addDeclaration(name, identifier.getLocation(), this);
        }
        imports.addDeclaration(declarationCollector);
    } else if (null != identifier && moduleId.getName().equals(identifier.getName())) {
        for (int i = 0; i < assignments.getNofAssignments(); i++) {
            assignments.getAssignmentByIndex(i).addDeclaration(declarationCollector, 0);
        }
    } else {
        if (imports.hasImportedModuleWithId(moduleId)) {
            final ImportModule importation = imports.getImportedModuleById(moduleId);
            if (null != importation) {
                importation.addDeclaration(declarationCollector, identifier);
            }
        }
    }
    super.addDeclaration(declarationCollector);
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier)

Example 44 with ISubReference

use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.

the class Exports method check.

/**
 * Checks this export list.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 */
public void check(final CompilationTimeStamp timestamp) {
    if (null != lastCompilationTimeStamp && !lastCompilationTimeStamp.isLess(timestamp)) {
        return;
    }
    if (exportAll) {
        lastCompilationTimeStamp = timestamp;
        return;
    }
    symbols.checkUniqueness(timestamp);
    for (int i = 0; i < symbols.size(); i++) {
        final List<ISubReference> list = new ArrayList<ISubReference>();
        list.add(new FieldSubReference(symbols.getNthElement(i)));
        final Defined_Reference reference = new Defined_Reference(null, list);
        /* check whether exists or not */
        module.getAssBySRef(timestamp, reference);
    }
    lastCompilationTimeStamp = timestamp;
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Defined_Reference(org.eclipse.titan.designer.AST.ASN1.Defined_Reference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ArrayList(java.util.ArrayList)

Example 45 with ISubReference

use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.

the class ObjectClass_Definition method addDeclaration.

@Override
public /**
 * {@inheritDoc}
 */
void addDeclaration(final DeclarationCollector declarationCollector, final int i) {
    final List<ISubReference> subreferences = declarationCollector.getReference().getSubreferences();
    if (subreferences.size() <= i) {
        return;
    }
    final ISubReference subreference = subreferences.get(i);
    if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
        if (subreferences.size() > i + 1) {
            // the reference might go on
            final Identifier identifier = subreference.getId();
            final FieldSpecification fieldSpecification = fieldSpecifications.getFieldSpecificationByIdentifier(identifier);
            if (null == fieldSpecification) {
                return;
            }
            fieldSpecification.addDeclaration(declarationCollector, i + 1);
        } else {
            // final part of the reference
            final String name = subreference.getId().getName();
            final List<FieldSpecification> fieldSpecs = fieldSpecifications.getFieldSpecificationsWithPrefix(name);
            for (final FieldSpecification field : fieldSpecs) {
                declarationCollector.addDeclaration(field.getIdentifier().getDisplayName(), field.getLocation(), this);
            }
        }
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier)

Aggregations

ISubReference (org.eclipse.titan.designer.AST.ISubReference)205 IType (org.eclipse.titan.designer.AST.IType)80 IValue (org.eclipse.titan.designer.AST.IValue)63 Identifier (org.eclipse.titan.designer.AST.Identifier)53 Value (org.eclipse.titan.designer.AST.Value)47 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)46 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)40 Assignment (org.eclipse.titan.designer.AST.Assignment)28 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)25 Reference (org.eclipse.titan.designer.AST.Reference)18 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)15 ArrayList (java.util.ArrayList)14 Template (org.eclipse.jface.text.templates.Template)11 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)11 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)11 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)10 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)8 Module (org.eclipse.titan.designer.AST.Module)8 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)7 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)6