Search in sources :

Example 46 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class SuperfluousTemplate method visit.

@Override
public int visit(final IVisitableNode node) {
    if (node instanceof TemplateInstance) {
        template = (TemplateInstance) node;
        final ITTCN3Template body = template.getTemplateBody();
        if (body instanceof Any_Value_Template || body instanceof AnyOrOmit_Template) {
            final Type type = template.getType();
            if (type == null) {
                // port.receive(?) or port.receive(*)
                receivesAny = true;
            } else if (receivableType != null && type.isIdentical(CompilationTimeStamp.getBaseTimestamp(), receivableType)) {
                // e.g. port.receive(integer:?)
                receivesAllOfType = true;
            }
        }
        // We don't want to investigate nested templates
        return V_SKIP;
    }
    return V_CONTINUE;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) CodeSmellType(org.eclipse.titanium.markers.types.CodeSmellType) Port_Type(org.eclipse.titan.designer.AST.TTCN3.types.Port_Type) Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) Any_Value_Template(org.eclipse.titan.designer.AST.TTCN3.templates.Any_Value_Template) AnyOrOmit_Template(org.eclipse.titan.designer.AST.TTCN3.templates.AnyOrOmit_Template) TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)

Example 47 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class UnnecessaryValueof method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof ValueofExpression) {
        final ValueofExpression exp = (ValueofExpression) node;
        final CompilationTimeStamp stamp = CompilationTimeStamp.getBaseTimestamp();
        if (exp.getIsErroneous(stamp) || exp.isUnfoldable(stamp, null)) {
            return;
        }
        final TemplateInstance inst = exp.getTemplateInstance();
        if (inst != null && inst.getDerivedReference() == null && inst.getTemplateBody().isValue(stamp)) {
            final String msg = MessageFormat.format(TEXT, inst.getTemplateBody().getValue().createStringRepresentation());
            problems.report(exp.getLocation(), msg);
        }
    }
}
Also used : CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) ValueofExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ValueofExpression) TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)

Example 48 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class PortTypeBody method addGetcallProposals.

/**
 * Adds the "getcall" related operations of port types, to the completion
 * list.
 *
 * @param propCollector the proposal collector
 * @param i index, not used
 */
public static void addGetcallProposals(final ProposalCollector propCollector, final int i) {
    propCollector.addProposal("getcall", "getcall", ImageCache.getImage("port.gif"), "");
    propCollector.addTemplateProposal("getcall", new Template("getcall from myPartner", "from clause", propCollector.getContextIdentifier(), "getcall from ${myPartner};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall -> sender myPartnerVar", "sender redirect", propCollector.getContextIdentifier(), "getcall -> sender ${myPartnerVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall( templateInstance )", "", propCollector.getContextIdentifier(), "getcall( ${templateInstance} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall( templateInstance ) from myPartner", "from clause", propCollector.getContextIdentifier(), "getcall( ${templateInstance} ) from ${myPartner};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall( templateInstance ) -> sender myPartnerVar", "sender redirect", propCollector.getContextIdentifier(), "getcall( ${templateInstance} ) -> sender ${myPartnerVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall( templateInstance ) -> param(parameters)", "parameters", propCollector.getContextIdentifier(), "getcall( ${templateInstance} ) -> param( ${parameters} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall( templateInstance ) from myPartner -> param(parameters)", "from clause and parameters", propCollector.getContextIdentifier(), "getcall( ${templateInstance} ) from ${myPartner} -> param( ${parameters} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("getcall", new Template("getcall( templateInstance ) -> param(parameters) sender mySenderVar", "parameters and sender clause", propCollector.getContextIdentifier(), "getcall( ${templateInstance} ) -> param( ${parameters} ) sender ${mySenderVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
Also used : Template(org.eclipse.jface.text.templates.Template) Def_Var_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)

Example 49 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class PortTypeBody method addReceiveProposals.

/**
 * Adds the "receive" related operations of port types, to the completion
 * list.
 *
 * @param propCollector the proposal collector
 * @param i index, not used
 */
private static void addReceiveProposals(final ProposalCollector propCollector, final int i) {
    propCollector.addProposal("receive", "receive", ImageCache.getImage("port.gif"), "");
    propCollector.addTemplateProposal("receive", new Template("receive -> value myVar", "value redirect", propCollector.getContextIdentifier(), "receive -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive -> sender myPeer", "sender redirect", propCollector.getContextIdentifier(), "receive -> sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive -> value myVar sender myPeer", "value and sender redirect", propCollector.getContextIdentifier(), "receive -> value ${myVar} sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive from myPeer", "from clause", propCollector.getContextIdentifier(), "receive from ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive from myPeer -> value myVar", "from clause with value redirect", propCollector.getContextIdentifier(), "receive from ${myPeer} -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive( templateInstance )", "", propCollector.getContextIdentifier(), "receive( ${template} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive( templateInstance ) -> value myVar", "value redirect", propCollector.getContextIdentifier(), "receive( ${templateInstance} ) -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive( templateInstance ) -> sender myPeer", "sender redirect", propCollector.getContextIdentifier(), "receive( ${templateInstance} ) -> sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive( templateInstance ) -> value myVar sender myPeer", "value and sender redirect", propCollector.getContextIdentifier(), "receive( ${templateInstance} ) -> value ${myVar} sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive( templateInstance ) from myPeer", "from clause", propCollector.getContextIdentifier(), "receive( ${templateInstance} ) from ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("receive", new Template("receive( templateInstance ) from myPeer -> value myVar", "from clause with value redirect", propCollector.getContextIdentifier(), "receive( ${templateInstance} ) from ${myPeer} -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
Also used : Template(org.eclipse.jface.text.templates.Template) Def_Var_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)

Example 50 with TemplateInstance

use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance in project titan.EclipsePlug-ins by eclipse.

the class PortTypeBody method addCatchProposals.

/**
 * Adds the "catch" related operations of port types, to the completion
 * list.
 *
 * @param propCollector the proposal collector
 * @param i index, not used
 */
public static void addCatchProposals(final ProposalCollector propCollector, final int i) {
    propCollector.addProposal("catch", "catch", ImageCache.getImage("port.gif"), "");
    propCollector.addTemplateProposal("catch", new Template("catch -> value myVar", "value redirect", propCollector.getContextIdentifier(), "catch -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch -> sender myPeer", "sender redirect", propCollector.getContextIdentifier(), "catch -> sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch -> value myVar sender myPeer", "value and sender redirect", propCollector.getContextIdentifier(), "catch -> value ${myVar} sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch from myPeer", "from clause", propCollector.getContextIdentifier(), "catch from ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch from myPeer -> value myVar", "from clause with value redirect", propCollector.getContextIdentifier(), "catch from ${myPeer} -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( signature, templateInstance )", "", propCollector.getContextIdentifier(), "catch( ${signature}, ${templateInstance} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( signature, templateInstance ) -> value myVar", "value redirect", propCollector.getContextIdentifier(), "catch( ${signature}, ${templateInstance} ) -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( signature, templateInstance ) -> sender myPeer", "sender redirect", propCollector.getContextIdentifier(), "catch( ${signature}, ${templateInstance} ) -> sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( signature, templateInstance ) -> value myVar sender myPeer", "value and sender redirect", propCollector.getContextIdentifier(), "catch( ${signature}, ${templateInstance} ) -> value ${myVar} sender ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( signature, templateInstance ) from myPeer", "from clause", propCollector.getContextIdentifier(), "catch( ${signature}, ${templateInstance} ) from ${myPeer};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( signature, templateInstance ) from myPeer -> value myVar", "from clause with value redirect", propCollector.getContextIdentifier(), "catch( ${signature}, ${templateInstance} ) from ${myPeer} -> value ${myVar};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
    propCollector.addTemplateProposal("catch", new Template("catch( timeout )", "", propCollector.getContextIdentifier(), "catch( timeout );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
Also used : Template(org.eclipse.jface.text.templates.Template) Def_Var_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)

Aggregations

ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)29 IType (org.eclipse.titan.designer.AST.IType)26 IValue (org.eclipse.titan.designer.AST.IValue)16 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)13 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)13 TemplateInstance (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)10 Reference (org.eclipse.titan.designer.AST.Reference)9 Assignment (org.eclipse.titan.designer.AST.Assignment)8 ISubReference (org.eclipse.titan.designer.AST.ISubReference)8 TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)7 Template (org.eclipse.jface.text.templates.Template)6 Def_Var_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)6 Referenced_Template (org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template)5 Port_Type (org.eclipse.titan.designer.AST.TTCN3.types.Port_Type)5 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)5 Type (org.eclipse.titan.designer.AST.Type)5 PortTypeBody (org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody)4 Signature_Type (org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type)4 TypeSet (org.eclipse.titan.designer.AST.TTCN3.types.TypeSet)4 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)3