Search in sources :

Example 11 with TTCN3_Sequence_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.

the class ChangeCreator method calculateEditLocations.

private WorkspaceJob calculateEditLocations(final NavigableSet<ILocateableNode> nodes, final IFile file, final MultiTextEdit rootEdit) throws CoreException {
    final WorkspaceJob job = new WorkspaceJob("InsertFieldRefactoring: calculate edit locations") {

        @Override
        public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
            for (ILocateableNode node : nodes) {
                int vmLen = settings.getType().length() + settings.getId().getTtcnName().length();
                if (node instanceof Def_Type) {
                    Def_Type df = (Def_Type) node;
                    Type type = df.getType(CompilationTimeStamp.getBaseTimestamp());
                    if (type instanceof TTCN3_Sequence_Type || type instanceof TTCN3_Set_Type) {
                        vmLen = insertField((TTCN3_Set_Seq_Choice_BaseType) type, node, rootEdit, vmLen);
                    }
                } else if (node instanceof Sequence_Value) {
                    Sequence_Value sv = (Sequence_Value) node;
                    vmLen += 6;
                    final Location nodeLocation = node.getLocation();
                    if (settings.getPosition() < sv.getNofComponents()) {
                        final Location valueLocation = sv.getSeqValueByIndex(settings.getPosition()).getLocation();
                        Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), valueLocation.getOffset(), valueLocation.getEndOffset() + vmLen);
                        rootEdit.addChild(new InsertEdit(l.getOffset(), settings.getId().getTtcnName() + " := " + settings.getValue() + ", "));
                    } else {
                        int max = sv.getNofComponents();
                        final Location valueLocation = sv.getSeqValueByIndex(max - 1).getLocation();
                        Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), valueLocation.getEndOffset(), valueLocation.getEndOffset() + vmLen);
                        rootEdit.addChild(new InsertEdit(l.getOffset(), ", " + settings.getId().getTtcnName() + " := " + settings.getValue()));
                    }
                } else if (node instanceof TTCN3Template) {
                    TTCN3Template template = (TTCN3Template) node;
                    vmLen += 6;
                    if (template instanceof Named_Template_List) {
                        Named_Template_List ntl = (Named_Template_List) template;
                        final Location nodeLocation = node.getLocation();
                        if (settings.getPosition() < ntl.getNofTemplates()) {
                            final Location templateLocation = ntl.getTemplateByIndex(settings.getPosition()).getLocation();
                            Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getOffset(), templateLocation.getEndOffset() + vmLen);
                            rootEdit.addChild(new InsertEdit(l.getOffset(), settings.getId().getTtcnName() + " := " + settings.getValue() + ", "));
                        } else {
                            int max = ntl.getNofTemplates();
                            final Location templateLocation = ntl.getTemplateByIndex(max - 1).getLocation();
                            Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getEndOffset(), templateLocation.getEndOffset() + vmLen);
                            rootEdit.addChild(new InsertEdit(l.getOffset(), ", " + settings.getId().getTtcnName() + " := " + settings.getValue()));
                        }
                    } else if (template instanceof Template_List) {
                        Template_List tl = (Template_List) template;
                        final Location nodeLocation = node.getLocation();
                        if (settings.getPosition() < tl.getNofTemplates()) {
                            final Location templateLocation = tl.getTemplateByIndex(settings.getPosition()).getLocation();
                            Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getOffset(), templateLocation.getEndOffset() + vmLen);
                            rootEdit.addChild(new InsertEdit(l.getOffset(), settings.getValue() + ","));
                        } else {
                            int max = tl.getNofTemplates();
                            final Location templateLocation = tl.getTemplateByIndex(max - 1).getLocation();
                            Location l = new Location(nodeLocation.getFile(), nodeLocation.getLine(), templateLocation.getEndOffset(), templateLocation.getEndOffset() + vmLen);
                            rootEdit.addChild(new InsertEdit(l.getOffset(), "," + settings.getValue()));
                        }
                    }
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.schedule();
    return job;
}
Also used : Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) InsertEdit(org.eclipse.text.edits.InsertEdit) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) TTCN3_Set_Seq_Choice_BaseType(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) Type(org.eclipse.titan.designer.AST.Type) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Template_List) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List) ILocateableNode(org.eclipse.titan.designer.AST.ILocateableNode) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) Named_Template_List(org.eclipse.titan.designer.AST.TTCN3.templates.Named_Template_List) TTCN3_Set_Seq_Choice_BaseType(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType) Location(org.eclipse.titan.designer.AST.Location)

Example 12 with TTCN3_Sequence_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.

the class InsertFieldWizardInputPage method checkPosition.

public void checkPosition() {
    try {
        settings.setPosition(Integer.parseInt(positionField.getText().trim()));
        final IType type = selection.getType(CompilationTimeStamp.getBaseTimestamp());
        if (type instanceof TTCN3_Sequence_Type || type instanceof TTCN3_Set_Type) {
            final TTCN3_Set_Seq_Choice_BaseType ss = (TTCN3_Set_Seq_Choice_BaseType) type;
            final int noc = ss.getNofComponents();
            if (settings.getPosition() < 0) {
                positionErrorMessage = NEGATIVEPOSITION;
                posDone = false;
            } else if (settings.getPosition() > noc) {
                positionErrorMessage = String.format(INVALIDUPPERBOUNDPOSITION, noc);
                posDone = false;
            } else {
                positionErrorMessage = "";
                posDone = true;
            }
        }
    } catch (NumberFormatException ex) {
        positionErrorMessage = NOTNUMBERPOSITION;
        posDone = false;
    }
    setErrorMessage(positionErrorMessage + typeErrorMessage + nameErrorMessage + valueErrorMessage);
    setPageComplete(posDone && typeDone && nameDone && valueDone);
}
Also used : TTCN3_Set_Seq_Choice_BaseType(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 13 with TTCN3_Sequence_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.

the class T3Doc method getCommentStringBasedOnReference.

public static String getCommentStringBasedOnReference(final DeclarationCollector declarationCollector, final List<DeclarationCollectionHelper> collected, final IEditorPart targetEditor, final IRegion hoverRegion, final IReferenceParser referenceParser, final ITextViewer textViewer) {
    if (!T3Doc.isT3DocEnable()) {
        return null;
    }
    Reference ref = declarationCollector.getReference();
    if (ref == null) {
        return null;
    }
    if ((ref.getMyScope() instanceof NamedBridgeScope || ref.getMyScope() instanceof FormalParameterList) && !collected.isEmpty()) {
        DeclarationCollectionHelper declaration = collected.get(0);
        if (declaration.node instanceof TTCN3_Sequence_Type || declaration.node instanceof FormalParameter) {
            final IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
            ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
            final Module tempModule = projectSourceParser.containedModule(file);
            Assignment ass = tempModule.getEnclosingAssignment(hoverRegion.getOffset());
            if (ass != null) {
                Reference reference = referenceParser.findReferenceForOpening(file, hoverRegion.getOffset(), textViewer.getDocument());
                String str = reference.getDisplayName();
                List<String> al = T3Doc.getCommentStrings(ass.getCommentLocation(), str);
                if (!al.isEmpty()) {
                    final StringBuilder sb = new StringBuilder();
                    for (String string : al) {
                        sb.append(string);
                    }
                    return sb.toString();
                }
            }
        }
    }
    return null;
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) IFile(org.eclipse.core.resources.IFile) Reference(org.eclipse.titan.designer.AST.Reference) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser) DeclarationCollectionHelper(org.eclipse.titan.designer.editors.actions.DeclarationCollectionHelper) Assignment(org.eclipse.titan.designer.AST.Assignment) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)

Example 14 with TTCN3_Sequence_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.

the class TTCN3_Choice_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<FieldInfo> fieldInfos = new ArrayList<FieldInfo>();
    boolean hasOptional = false;
    for (final CompField compField : compFieldMap.fields) {
        final IType cfType = compField.getType();
        final FieldInfo fi = new FieldInfo(cfType.getGenNameValue(aData, source, getMyScope()), cfType.getGenNameTemplate(aData, source, getMyScope()), compField.getIdentifier().getName(), compField.getIdentifier().getDisplayName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
        hasOptional |= compField.isOptional();
        fieldInfos.add(fi);
    }
    for (final CompField compField : compFieldMap.fields) {
        final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
        compField.getType().generateCode(aData, tempSource);
    }
    final boolean hasRaw = getGenerateCoderFunctions(MessageEncoding_type.RAW);
    RawASTStruct raw = null;
    if (hasRaw) {
        RawAST dummy_raw;
        if (rawAttribute == null) {
            dummy_raw = new RawAST(getDefaultRawFieldLength());
        } else {
            dummy_raw = rawAttribute;
        }
        raw = new RawASTStruct(dummy_raw);
        // building taglist
        final int taglistSize = dummy_raw.taglist == null ? 0 : dummy_raw.taglist.size();
        for (int c = 0; c < taglistSize; c++) {
            final rawAST_single_tag singleTag = dummy_raw.taglist.get(c);
            final rawAST_coding_taglist codingSingleTag = raw.taglist.list.get(c);
            if (singleTag.keyList != null) {
                codingSingleTag.fields = new ArrayList<RawASTStruct.rawAST_coding_field_list>(singleTag.keyList.size());
            }
            codingSingleTag.fieldname = singleTag.fieldName.getName();
            codingSingleTag.varName = FieldSubReference.getJavaGetterName(codingSingleTag.fieldname);
            final Identifier idf = singleTag.fieldName;
            codingSingleTag.fieldnum = getComponentIndexByName(idf);
            final int keyListSize = singleTag.keyList == null ? 0 : singleTag.keyList.size();
            for (int a = 0; a < keyListSize; a++) {
                final rawAST_tag_field_value key = singleTag.keyList.get(a);
                final RawASTStruct.rawAST_coding_field_list codingKey = new RawASTStruct.rawAST_coding_field_list();
                codingSingleTag.fields.add(codingKey);
                codingKey.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(key.keyField.names.size());
                // codingKey.value = key.value;
                final ExpressionStruct expression = new ExpressionStruct();
                key.v_value.generateCodeExpression(aData, expression, true);
                codingKey.expression = expression;
                codingKey.isOmitValue = key.v_value.getValuetype() == Value_type.OMIT_VALUE;
                codingKey.start_pos = 0;
                final CompField cf = getComponentByIndex(codingSingleTag.fieldnum);
                IType t = cf.getType().getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
                final RawASTStruct.rawAST_coding_fields tempField = new rawAST_coding_fields();
                tempField.nthfield = codingSingleTag.fieldnum;
                tempField.nthfieldname = singleTag.fieldName.getName();
                tempField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                tempField.type = t.getGenNameValue(aData, source, myScope);
                tempField.typedesc = t.getGenNameTypeDescriptor(aData, source, myScope);
                codingKey.fields.add(tempField);
                for (int b = 0; b < key.keyField.names.size(); b++) {
                    final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
                    codingKey.fields.add(newField);
                    final Identifier idf2 = key.keyField.names.get(b);
                    int comp_index = 0;
                    CompField cf2;
                    switch(t.getTypetype()) {
                        case TYPE_TTCN3_CHOICE:
                            comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
                            cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
                            newField.nthfield = comp_index;
                            newField.nthfieldname = idf2.getName();
                            newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                            break;
                        case TYPE_TTCN3_SEQUENCE:
                        case TYPE_TTCN3_SET:
                            comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
                            cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
                            newField.nthfield = comp_index;
                            newField.nthfieldname = idf2.getName();
                            if (cf2.isOptional()) {
                                newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                            } else {
                                newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                            }
                            break;
                        default:
                            // internal error
                            return;
                    }
                    final IType field_type = cf2.getType();
                    newField.type = field_type.getGenNameValue(aData, source, myScope);
                    newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
                    if (field_type.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE && ((TTCN3_Sequence_Type) field_type).rawAttribute != null && (((TTCN3_Sequence_Type) field_type).rawAttribute.pointerto == null || ((TTCN3_Sequence_Type) field_type).rawAttribute.lengthto != null)) {
                        codingKey.start_pos = -1;
                    }
                    if (t.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE) {
                        IType t2;
                        for (int i = 0; i < comp_index && codingKey.start_pos >= 0; i++) {
                            t2 = ((TTCN3_Sequence_Type) t).getComponentByIndex(i).getType();
                            if (t2.getRawLength() >= 0) {
                                if (((Type) t2).rawAttribute != null) {
                                    codingKey.start_pos += ((Type) t2).rawAttribute.padding;
                                }
                                codingKey.start_pos += ((Type) t2).getRawLength();
                            } else {
                                codingKey.start_pos = -1;
                            }
                        }
                    }
                    t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
                }
            }
        }
    }
    UnionGenerator.generateValueClass(aData, source, genName, displayName, fieldInfos, hasOptional, hasRaw, raw);
    UnionGenerator.generateTemplateClass(aData, source, genName, displayName, fieldInfos, hasOptional);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : RawAST(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST) RawASTStruct.rawAST_coding_taglist(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_taglist) ArrayList(java.util.ArrayList) RawASTStruct.rawAST_coding_fields(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_fields) IType(org.eclipse.titan.designer.AST.IType) Type(org.eclipse.titan.designer.AST.Type) SubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) Identifier(org.eclipse.titan.designer.AST.Identifier) RawASTStruct(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct) RawASTStruct.rawAST_coding_fields(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_fields) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct) RawAST.rawAST_tag_field_value(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_tag_field_value) FieldInfo(org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo) RawAST.rawAST_single_tag(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_single_tag)

Example 15 with TTCN3_Sequence_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.

the class TTCN3_Set_Seq_Choice_BaseType method convertRAWCodingAttributes.

// FIXME comment
protected RawASTStruct convertRAWCodingAttributes(final JavaGenData aData, final StringBuilder source, final boolean hasRaw, final List<FieldInfo> namesList) {
    RawASTStruct raw = null;
    if (hasRaw) {
        RawAST dummy_raw;
        if (rawAttribute == null) {
            dummy_raw = new RawAST(getDefaultRawFieldLength());
        } else {
            dummy_raw = rawAttribute;
        }
        raw = new RawASTStruct(dummy_raw);
        // building taglist
        final int taglistSize = dummy_raw.taglist == null ? 0 : dummy_raw.taglist.size();
        for (int c = 0; c < taglistSize; c++) {
            final rawAST_single_tag singleTag = dummy_raw.taglist.get(c);
            final rawAST_coding_taglist codingSingleTag = raw.taglist.list.get(c);
            if (singleTag.keyList != null) {
                codingSingleTag.fields = new ArrayList<RawASTStruct.rawAST_coding_field_list>(singleTag.keyList.size());
            }
            codingSingleTag.fieldname = singleTag.fieldName.getName();
            codingSingleTag.varName = FieldSubReference.getJavaGetterName(codingSingleTag.fieldname);
            final Identifier idf = singleTag.fieldName;
            codingSingleTag.fieldnum = getComponentIndexByName(idf);
            final int keyListSize = singleTag.keyList == null ? 0 : singleTag.keyList.size();
            for (int a = 0; a < keyListSize; a++) {
                final rawAST_tag_field_value key = singleTag.keyList.get(a);
                final RawASTStruct.rawAST_coding_field_list codingKey = new RawASTStruct.rawAST_coding_field_list();
                codingSingleTag.fields.add(codingKey);
                codingKey.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(key.keyField.names.size());
                // codingKey.value = key.value;
                final ExpressionStruct expression = new ExpressionStruct();
                key.v_value.generateCodeExpression(aData, expression, true);
                codingKey.expression = expression;
                codingKey.isOmitValue = key.v_value.getValuetype() == Value_type.OMIT_VALUE;
                codingKey.start_pos = 0;
                final CompField cf = getComponentByIndex(codingSingleTag.fieldnum);
                IType t = cf.getType().getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
                final RawASTStruct.rawAST_coding_fields tempField = new rawAST_coding_fields();
                tempField.nthfield = codingSingleTag.fieldnum;
                tempField.nthfieldname = singleTag.fieldName.getName();
                tempField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                tempField.type = t.getGenNameValue(aData, source, myScope);
                tempField.typedesc = t.getGenNameTypeDescriptor(aData, source, myScope);
                if (cf.isOptional()) {
                    tempField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                } else {
                    tempField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                }
                codingKey.fields.add(tempField);
                for (int b = 0; b < key.keyField.names.size(); b++) {
                    final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
                    codingKey.fields.add(newField);
                    final Identifier idf2 = key.keyField.names.get(b);
                    int comp_index = 0;
                    CompField cf2;
                    switch(t.getTypetype()) {
                        case TYPE_TTCN3_CHOICE:
                            comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
                            cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
                            newField.nthfield = comp_index;
                            newField.nthfieldname = idf2.getName();
                            newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                            break;
                        case TYPE_TTCN3_SEQUENCE:
                        case TYPE_TTCN3_SET:
                            comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
                            cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
                            newField.nthfield = comp_index;
                            newField.nthfieldname = idf2.getName();
                            if (cf2.isOptional()) {
                                newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                            } else {
                                newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                            }
                            break;
                        default:
                            // internal error
                            return null;
                    }
                    final IType field_type = cf2.getType();
                    newField.type = field_type.getGenNameValue(aData, source, myScope);
                    newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
                    if (field_type.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE && ((TTCN3_Sequence_Type) field_type).rawAttribute != null && (((TTCN3_Sequence_Type) field_type).rawAttribute.pointerto == null || ((TTCN3_Sequence_Type) field_type).rawAttribute.lengthto != null)) {
                        codingKey.start_pos = -1;
                    }
                    if (t.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE) {
                        IType t2;
                        for (int i = 0; i < comp_index && codingKey.start_pos >= 0; i++) {
                            t2 = ((TTCN3_Sequence_Type) t).getComponentByIndex(i).getType();
                            if (t2.getRawLength() >= 0) {
                                if (((Type) t2).rawAttribute != null) {
                                    codingKey.start_pos += ((Type) t2).rawAttribute.padding;
                                }
                                codingKey.start_pos += ((Type) t2).getRawLength();
                            } else {
                                codingKey.start_pos = -1;
                            }
                        }
                    }
                    t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
                }
            }
        }
        // building presence list
        final int presenceListSize = dummy_raw.presence == null || dummy_raw.presence.keyList == null ? 0 : dummy_raw.presence.keyList.size();
        for (int a = 0; a < presenceListSize; a++) {
            final rawAST_tag_field_value fieldValue = dummy_raw.presence.keyList.get(a);
            final rawAST_coding_field_list presences = new rawAST_coding_field_list();
            raw.presence.fields.add(presences);
            final ExpressionStruct expression = new ExpressionStruct();
            fieldValue.v_value.generateCodeExpression(aData, expression, true);
            presences.expression = expression;
            presences.isOmitValue = fieldValue.v_value.getValuetype() == Value_type.OMIT_VALUE;
            final int keySize = fieldValue.keyField == null || fieldValue.keyField.names == null ? 0 : fieldValue.keyField.names.size();
            presences.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(keySize);
            IType t = this;
            for (int b = 0; b < keySize; b++) {
                final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
                presences.fields.add(newField);
                final Identifier idf2 = fieldValue.keyField.names.get(b);
                int comp_index = 0;
                CompField cf2;
                switch(t.getTypetype()) {
                    case TYPE_TTCN3_CHOICE:
                        comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
                        cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
                        newField.nthfield = comp_index;
                        newField.nthfieldname = idf2.getName();
                        newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                        break;
                    case TYPE_TTCN3_SEQUENCE:
                    case TYPE_TTCN3_SET:
                        comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
                        cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
                        newField.nthfield = comp_index;
                        newField.nthfieldname = idf2.getName();
                        if (cf2.isOptional()) {
                            newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                        } else {
                            newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                        }
                        break;
                    default:
                        // internal error
                        return null;
                }
                final IType field_type = cf2.getType();
                newField.type = field_type.getGenNameValue(aData, source, myScope);
                newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
                t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            }
        }
        final int extBiGroupSize = dummy_raw.ext_bit_groups == null ? 0 : dummy_raw.ext_bit_groups.size();
        for (int c = 0; c < extBiGroupSize; c++) {
            final rawAST_ext_bit_group tempGroup = dummy_raw.ext_bit_groups.get(c);
            final Identifier idf = tempGroup.from;
            final Identifier idf2 = tempGroup.to;
            final rawAST_coding_ext_group codingGroup = new rawAST_coding_ext_group();
            raw.ext_bit_groups.add(codingGroup);
            codingGroup.ext_bit = tempGroup.ext_bit;
            codingGroup.from = getComponentIndexByName(idf);
            codingGroup.to = getComponentIndexByName(idf2);
        }
        for (int i = 0; i < getNofComponents(); i++) {
            final FieldInfo element_i = namesList.get(i);
            final CompField cf = getComponentByIndex(i);
            final IType t_field = cf.getType();
            final IType t_field_last = t_field.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            final RawAST rawpar = t_field.getRawAttribute();
            if (rawpar != null) {
                element_i.raw = new RawASTStruct(rawpar);
                final int lengthtoNum = rawpar.lengthto == null ? 0 : rawpar.lengthto.size();
                for (int j = 0; j < lengthtoNum; j++) {
                    final Identifier idf = rawpar.lengthto.get(j);
                    element_i.raw.lengthto.add(getComponentIndexByName(idf));
                }
                if (lengthtoNum > 0 && rawpar.lengthindex != null) {
                    final Identifier idf = rawpar.lengthindex.names.get(0);
                    int comp_index = 0;
                    CompField cf2;
                    switch(t_field_last.getTypetype()) {
                        case TYPE_TTCN3_CHOICE:
                            comp_index = ((TTCN3_Choice_Type) t_field_last).getComponentIndexByName(idf);
                            cf2 = ((TTCN3_Choice_Type) t_field_last).getComponentByIndex(comp_index);
                            element_i.raw.lengthindex.nthfield = comp_index;
                            element_i.raw.lengthindex.nthfieldname = idf.getName();
                            break;
                        case TYPE_TTCN3_SEQUENCE:
                        case TYPE_TTCN3_SET:
                            comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentIndexByName(idf);
                            cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentByIndex(comp_index);
                            element_i.raw.lengthindex.nthfield = comp_index;
                            element_i.raw.lengthindex.nthfieldname = idf.getName();
                            break;
                        default:
                            // internal error
                            return null;
                    }
                    final Type t_field2 = cf2.getType();
                    if (t_field2.getTypetype() == Type_type.TYPE_TTCN3_CHOICE) {
                        element_i.raw.lengthindex.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                    } else if (cf2.isOptional()) {
                        element_i.raw.lengthindex.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                    } else {
                        element_i.raw.lengthindex.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                    }
                    element_i.raw.lengthindex.type = t_field2.getGenNameValue(aData, source, myScope);
                    element_i.raw.lengthindex.typedesc = t_field2.getGenNameTypeDescriptor(aData, source, myScope);
                }
                if (lengthtoNum > 0 && rawpar.lengthindex == null) {
                    switch(t_field_last.getTypetype()) {
                        case TYPE_TTCN3_CHOICE:
                        case TYPE_TTCN3_SEQUENCE:
                        case TYPE_TTCN3_SET:
                            final int componentsNumber = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getNofComponents();
                            element_i.raw.union_member_num = componentsNumber;
                            element_i.raw.member_name = new ArrayList<String>(componentsNumber + 1);
                            element_i.raw.member_name.add(t_field_last.getGenNameValue(aData, source, myScope));
                            for (int m = 1; m < componentsNumber + 1; m++) {
                                final CompField compf = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentByIndex(m - 1);
                                element_i.raw.member_name.add(compf.getIdentifier().getName());
                            }
                            break;
                        default:
                            break;
                    }
                }
                if (rawpar.pointerto != null) {
                    final Identifier idf = rawpar.pointerto;
                    element_i.raw.pointerto = getComponentIndexByName(idf);
                    if (rawpar.ptrbase != null) {
                        final Identifier idf2 = rawpar.ptrbase;
                        element_i.raw.pointerbase = getComponentIndexByName(idf2);
                    } else {
                        element_i.raw.pointerbase = i;
                    }
                }
                // building presence list
                final int parPresenceListSize = rawpar.presence == null || rawpar.presence.keyList == null ? 0 : rawpar.presence.keyList.size();
                for (int a = 0; a < parPresenceListSize; a++) {
                    final rawAST_coding_field_list presences = new rawAST_coding_field_list();
                    element_i.raw.presence.fields.add(presences);
                    final rawAST_tag_field_value fieldValue = rawpar.presence.keyList.get(a);
                    final ExpressionStruct expression = new ExpressionStruct();
                    fieldValue.v_value.generateCodeExpression(aData, expression, true);
                    presences.expression = expression;
                    presences.isOmitValue = fieldValue.v_value.getValuetype() == Value_type.OMIT_VALUE;
                    presences.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(fieldValue.keyField.names.size());
                    IType t = this;
                    for (int b = 0; b < fieldValue.keyField.names.size(); b++) {
                        final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
                        presences.fields.add(newField);
                        final Identifier idf2 = fieldValue.keyField.names.get(b);
                        int comp_index = 0;
                        CompField cf2;
                        switch(t.getTypetype()) {
                            case TYPE_TTCN3_CHOICE:
                                comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
                                cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
                                newField.nthfield = comp_index;
                                newField.nthfieldname = idf2.getName();
                                newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                                break;
                            case TYPE_TTCN3_SEQUENCE:
                            case TYPE_TTCN3_SET:
                                comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
                                cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
                                newField.nthfield = comp_index;
                                newField.nthfieldname = idf2.getName();
                                if (cf2.isOptional()) {
                                    newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                                } else {
                                    newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                                }
                                break;
                            default:
                                // internal error
                                return null;
                        }
                        final IType field_type = cf2.getType();
                        newField.type = field_type.getGenNameValue(aData, source, myScope);
                        newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
                        t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
                    }
                }
                // building crosstaglist
                final int crossTaglistSize = rawpar.crosstaglist == null ? 0 : rawpar.crosstaglist.size();
                for (int c = 0; c < crossTaglistSize; c++) {
                    final rawAST_single_tag singleTag = rawpar.crosstaglist.get(c);
                    final rawAST_coding_taglist codingSingleTag = element_i.raw.crosstaglist.list.get(c);
                    if (singleTag.keyList != null) {
                        codingSingleTag.fields = new ArrayList<RawASTStruct.rawAST_coding_field_list>(singleTag.keyList.size());
                    }
                    codingSingleTag.fieldname = singleTag.fieldName.getName();
                    codingSingleTag.varName = FieldSubReference.getJavaGetterName(codingSingleTag.fieldname);
                    final Identifier idf = singleTag.fieldName;
                    switch(t_field_last.getTypetype()) {
                        case TYPE_TTCN3_CHOICE:
                        case TYPE_TTCN3_SEQUENCE:
                        case TYPE_TTCN3_SET:
                            codingSingleTag.fieldnum = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentIndexByName(idf);
                            break;
                        case TYPE_ASN1_CHOICE:
                            codingSingleTag.fieldnum = ((ASN1_Set_Seq_Choice_BaseType) t_field_last).getComponentIndexByName(idf);
                            break;
                        default:
                            codingSingleTag.fieldnum = -1;
                            break;
                    }
                    final int keyListSize = singleTag.keyList == null ? 0 : singleTag.keyList.size();
                    for (int a = 0; a < keyListSize; a++) {
                        final rawAST_tag_field_value key = singleTag.keyList.get(a);
                        final RawASTStruct.rawAST_coding_field_list codingKey = new RawASTStruct.rawAST_coding_field_list();
                        codingSingleTag.fields.add(codingKey);
                        codingKey.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(key.keyField.names.size());
                        final ExpressionStruct expression = new ExpressionStruct();
                        key.v_value.generateCodeExpression(aData, expression, true);
                        codingKey.expression = expression;
                        codingKey.isOmitValue = key.v_value.getValuetype() == Value_type.OMIT_VALUE;
                        IType t = this;
                        for (int b = 0; b < key.keyField.names.size(); b++) {
                            final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
                            codingKey.fields.add(newField);
                            final Identifier idf2 = key.keyField.names.get(b);
                            int comp_index = 0;
                            CompField cf2;
                            switch(t.getTypetype()) {
                                case TYPE_TTCN3_CHOICE:
                                    comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
                                    cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
                                    newField.nthfield = comp_index;
                                    newField.nthfieldname = idf2.getName();
                                    newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
                                    break;
                                case TYPE_TTCN3_SEQUENCE:
                                case TYPE_TTCN3_SET:
                                    comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
                                    cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
                                    newField.nthfield = comp_index;
                                    newField.nthfieldname = idf2.getName();
                                    if (cf2.isOptional()) {
                                        newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
                                    } else {
                                        newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
                                    }
                                    break;
                                default:
                                    // internal error
                                    return null;
                            }
                            final IType field_type = cf2.getType();
                            newField.type = field_type.getGenNameValue(aData, source, myScope);
                            newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
                            t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
                        }
                    }
                }
                element_i.raw.length = t_field.getRawLength();
                element_i.hasRaw = true;
            } else {
                element_i.hasRaw = false;
            }
        }
    }
    return raw;
}
Also used : RawAST(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST) RawASTStruct.rawAST_coding_taglist(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_taglist) RawAST.rawAST_ext_bit_group(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_ext_bit_group) RawASTStruct.rawAST_coding_ext_group(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_ext_group) RawASTStruct.rawAST_coding_fields(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_fields) IType(org.eclipse.titan.designer.AST.IType) RawASTStruct.rawAST_coding_field_list(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_field_list) ASN1_Set_Seq_Choice_BaseType(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Seq_Choice_BaseType) Type(org.eclipse.titan.designer.AST.Type) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) RawASTStruct.rawAST_coding_field_list(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_field_list) Identifier(org.eclipse.titan.designer.AST.Identifier) RawASTStruct(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct) RawASTStruct.rawAST_coding_fields(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_fields) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct) RawAST.rawAST_tag_field_value(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_tag_field_value) RawAST.rawAST_single_tag(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_single_tag) FieldInfo(org.eclipse.titan.designer.AST.TTCN3.types.RecordSetCodeGenerator.FieldInfo)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)14 Identifier (org.eclipse.titan.designer.AST.Identifier)11 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)8 TTCN3_Sequence_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type)8 IValue (org.eclipse.titan.designer.AST.IValue)7 TTCN3_Set_Type (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type)5 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)4 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)4 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)4 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)4 ISubReference (org.eclipse.titan.designer.AST.ISubReference)4 Type (org.eclipse.titan.designer.AST.Type)4 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)3 TTCN3_Set_Seq_Choice_BaseType (org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType)3 ArrayList (java.util.ArrayList)2 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)2 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)2 Reference (org.eclipse.titan.designer.AST.Reference)2 RawAST (org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST)2 RawAST.rawAST_single_tag (org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_single_tag)2