Search in sources :

Example 1 with INamedNode

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

the class NamedValue method getDeclaration.

@Override
public /**
 * {@inheritDoc}
 */
Declaration getDeclaration() {
    INamedNode inamedNode = getNameParent();
    while (!(inamedNode instanceof IValue)) {
        if (inamedNode == null) {
            // FIXME: this is just a temp solution! find the reason!
            return null;
        }
        inamedNode = inamedNode.getNameParent();
    }
    final IValue iValue = (IValue) inamedNode;
    IType type = iValue.getMyGovernor();
    if (type == null) {
        return null;
    }
    type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (type instanceof ITypeWithComponents) {
        final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getName());
        return Declaration.createInstance(type.getDefiningAssignment(), id);
    }
    return null;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Identifier(org.eclipse.titan.designer.AST.Identifier) ITypeWithComponents(org.eclipse.titan.designer.AST.ITypeWithComponents) INamedNode(org.eclipse.titan.designer.AST.INamedNode) IType(org.eclipse.titan.designer.AST.IType)

Example 2 with INamedNode

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

the class CompFieldMap method checkUniqueness.

/**
 * Checks the uniqueness of the definitions, and also builds a hashmap of
 * them to speed up further searches.
 *
 * @param timestamp the timestamp of the actual semantic check cycle, or -1
 *            in silent check mode.
 */
protected void checkUniqueness(final CompilationTimeStamp timestamp) {
    if (lastUniquenessCheck != null && !lastUniquenessCheck.isLess(timestamp)) {
        return;
    }
    if (doubleComponents != null) {
        doubleComponents.clear();
    }
    componentFieldMap = new HashMap<String, CompField>(fields.size());
    if (fields.size() == 0) {
        // too early check
        return;
    }
    lastUniquenessCheck = timestamp;
    for (int i = 0, size = fields.size(); i < size; i++) {
        final CompField field = fields.get(i);
        final Identifier fieldIdentifier = field.getIdentifier();
        if (fieldIdentifier == null) {
            continue;
        }
        final String fieldName = fieldIdentifier.getName();
        if (componentFieldMap.containsKey(fieldName)) {
            if (doubleComponents == null) {
                doubleComponents = new ArrayList<CompField>();
            }
            doubleComponents.add(field);
        } else {
            componentFieldMap.put(fieldName, field);
        }
    }
    // FIXME: Perhaps this class should be copied under asn1 to handle this ASN1 problem
    if (doubleComponents != null) {
        final INamedNode p = getNameParent();
        if (p instanceof Open_Type) {
            return;
        }
        for (int i = 0, size = doubleComponents.size(); i < size; i++) {
            final CompField field = doubleComponents.get(i);
            // remove duplication from fields - not used anymore
            // fields.remove(field);
            // report duplication:
            final Identifier fieldIdentifier = field.getIdentifier();
            final String fieldName = fieldIdentifier.getName();
            componentFieldMap.get(fieldName).getIdentifier().getLocation().reportSingularSemanticError(MessageFormat.format(DUPLICATEFIELDNAMEFIRST, fieldIdentifier.getDisplayName()));
            fieldIdentifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEFIELDNAMEREPEATED, fieldIdentifier.getDisplayName()));
        }
    }
}
Also used : Open_Type(org.eclipse.titan.designer.AST.ASN1.types.Open_Type) Identifier(org.eclipse.titan.designer.AST.Identifier) INamedNode(org.eclipse.titan.designer.AST.INamedNode)

Example 3 with INamedNode

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

the class Shorthand method check.

protected void check(final Statement s, final Problems problems) {
    if (s == null) {
        return;
    }
    // shorthand statements are ignored inside alt statements
    INamedNode curr = s;
    while (curr != null) {
        if (curr instanceof Alt_Statement || curr instanceof Call_Statement) {
            return;
        }
        curr = curr.getNameParent();
    }
    final StatementBlock sb = s.getMyStatementBlock();
    if (sb == null) {
        return;
    }
    final Definition d = sb.getMyDefinition();
    if (d == null) {
        return;
    }
    // shorthand statements are marked in functions, test cases and altsteps that have a 'runs on' clause
    if (d instanceof Def_Function && ((Def_Function) d).getRunsOnType(timestamp) != null) {
        problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
        return;
    }
    if (d instanceof Def_Altstep || d instanceof Def_Testcase) {
        problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
    }
}
Also used : Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) INamedNode(org.eclipse.titan.designer.AST.INamedNode) Call_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Call_Statement) Alt_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) Def_Altstep(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Example 4 with INamedNode

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

the class CompField method getDeclaration.

@Override
public /**
 * {@inheritDoc}
 */
Declaration getDeclaration() {
    INamedNode inamedNode = getNameParent();
    while (!(inamedNode instanceof Definition)) {
        if (inamedNode == null) {
            // FIXME: this is just a temp solution! find the reason!
            return null;
        }
        inamedNode = inamedNode.getNameParent();
    }
    final Definition namedTemplList = (Definition) inamedNode;
    IType tempType = namedTemplList.getType(CompilationTimeStamp.getBaseTimestamp());
    if (tempType == null) {
        return null;
    }
    tempType = tempType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (tempType instanceof ITypeWithComponents) {
        final Identifier resultId = ((ITypeWithComponents) tempType).getComponentIdentifierByName(getIdentifier());
        return Declaration.createInstance(tempType.getDefiningAssignment(), resultId);
    }
    return null;
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) ITypeWithComponents(org.eclipse.titan.designer.AST.ITypeWithComponents) INamedNode(org.eclipse.titan.designer.AST.INamedNode) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) IType(org.eclipse.titan.designer.AST.IType)

Example 5 with INamedNode

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

the class NamedTemplate method getDeclaration.

@Override
public /**
 * {@inheritDoc}
 */
Declaration getDeclaration() {
    INamedNode inamedNode = getNameParent();
    while (!(inamedNode instanceof Named_Template_List)) {
        if (inamedNode == null) {
            // FIXME: this is just a temp solution! find the reason!
            return null;
        }
        inamedNode = inamedNode.getNameParent();
    }
    final Named_Template_List namedTemplList = (Named_Template_List) inamedNode;
    IType type = namedTemplList.getMyGovernor();
    if (type == null) {
        return null;
    }
    type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    if (type instanceof ITypeWithComponents) {
        final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getName());
        return Declaration.createInstance(type.getDefiningAssignment(), id);
    }
    return null;
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) ITypeWithComponents(org.eclipse.titan.designer.AST.ITypeWithComponents) INamedNode(org.eclipse.titan.designer.AST.INamedNode) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

INamedNode (org.eclipse.titan.designer.AST.INamedNode)5 Identifier (org.eclipse.titan.designer.AST.Identifier)4 IType (org.eclipse.titan.designer.AST.IType)3 ITypeWithComponents (org.eclipse.titan.designer.AST.ITypeWithComponents)3 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)2 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)1 IValue (org.eclipse.titan.designer.AST.IValue)1 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)1 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)1 Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)1 Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)1 Call_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Call_Statement)1 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)1