Search in sources :

Example 11 with Module

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

the class Def_Altstep method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    isUsed = false;
    runsOnType = null;
    lastTimeChecked = timestamp;
    T3Doc.check(this.getCommentLocation(), KIND);
    if (runsOnRef != null) {
        runsOnType = runsOnRef.chkComponentypeReference(timestamp);
        if (runsOnType != null) {
            final Scope formalParlistPreviosScope = formalParList.getParentScope();
            if (formalParlistPreviosScope instanceof RunsOnScope && ((RunsOnScope) formalParlistPreviosScope).getParentScope() == myScope) {
                ((RunsOnScope) formalParlistPreviosScope).setComponentType(runsOnType);
            } else {
                final Scope tempScope = new RunsOnScope(runsOnType, myScope);
                formalParList.setMyScope(tempScope);
            }
        }
    }
    if (formalParList.hasNotusedDefaultValue()) {
        formalParList.getLocation().reportSemanticError(DASHALLOWEDONLYFORTEMPLATES);
    }
    boolean canSkip = false;
    if (myScope != null) {
        final Module module = myScope.getModuleScope();
        if (module != null) {
            if (module.getSkippedFromSemanticChecking()) {
                canSkip = true;
            }
        }
    }
    if (!canSkip) {
        formalParList.reset();
    }
    formalParList.check(timestamp, getAssignmentType());
    if (canSkip) {
        return;
    }
    NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_ALTSTEP, identifier, this);
    NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
    if (block != null) {
        block.check(timestamp);
        block.setCodeSection(CodeSectionType.CS_INLINE);
    }
    if (altGuards != null) {
        altGuards.setIsAltstep();
        altGuards.setMyAltguards(altGuards);
        altGuards.setMyLaicStmt(altGuards, null);
        altGuards.check(timestamp);
        altGuards.setCodeSection(CodeSectionType.CS_INLINE);
    }
    if (withAttributesPath != null) {
        withAttributesPath.checkGlobalAttributes(timestamp, false);
        withAttributesPath.checkAttributes(timestamp);
    }
    if (block != null) {
        block.postCheck();
    }
    if (altGuards != null) {
        altGuards.postCheck();
    }
}
Also used : NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope) Scope(org.eclipse.titan.designer.AST.Scope) Module(org.eclipse.titan.designer.AST.Module)

Example 12 with Module

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

the class Done_Statement method generateCodeExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
    aData.addCommonLibraryImport("TTCN_Runtime");
    aData.addBuiltinTypeImport("TitanComponent");
    if (componentreference != null) {
        if (doneMatch != null) {
            // value returning done
            // figure out what type the done() function belongs to
            IType t = doneMatch.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
            if (t == null) {
                ErrorReporter.INTERNAL_ERROR("Encountered a done with unknown governor `" + getFullName() + "''");
                return;
            }
            while (t instanceof Referenced_Type && !t.hasDoneAttribute()) {
                final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                t = ((IReferencingType) t).getTypeRefd(CompilationTimeStamp.getBaseTimestamp(), refChain);
                refChain.release();
            }
            if (!t.hasDoneAttribute()) {
                ErrorReporter.INTERNAL_ERROR("Encountered a done return type without done attribute `" + getFullName() + "''");
                return;
            }
            // determine whether the done() function is in the same module
            final Module t_module = t.getMyScope().getModuleScope();
            if (t_module != myStatementBlock.getModuleScope()) {
                expression.expression.append(MessageFormat.format("{0}.", t_module.getIdentifier().getName()));
            }
            expression.expression.append("done(");
            componentreference.generateCodeExpression(aData, expression, true);
            expression.expression.append(", ");
            // FIXME handle decoded match
            doneMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
        // expression.expression.append(", ");
        // FIXME handle value redirection
        } else {
            // simple done
            componentreference.generateCodeExpressionMandatory(aData, expression, true);
            expression.expression.append(".done(");
        }
        // FIXME handle index redirection
        expression.expression.append(')');
    } else if (isAny) {
        // any component.done
        expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ANY_COMPREF)");
    } else {
        // all component.done
        expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ALL_COMPREF)");
    }
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Module(org.eclipse.titan.designer.AST.Module) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 13 with Module

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

the class CTs_EE_CTs method check.

public void check(final CompilationTimeStamp timestamp) {
    if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (null != myScope && null != lastTimeChecked) {
        final Module module = myScope.getModuleScope();
        if (null != module) {
            if (module.getSkippedFromSemanticChecking()) {
                lastTimeChecked = timestamp;
                return;
            }
        }
    }
    if (null == myType) {
        return;
    } else if (null == components) {
        components = new ArrayList<CompField>();
        componentsMap = new HashMap<String, CompField>();
    }
    lastTimeChecked = timestamp;
    components.clear();
    componentsMap.clear();
    String typeName;
    String componentName;
    switch(myType.getTypetype()) {
        case TYPE_ASN1_SEQUENCE:
            typeName = "SEQUENCE";
            componentName = "Component";
            break;
        case TYPE_ASN1_SET:
            typeName = "SET";
            componentName = "Component";
            break;
        case TYPE_ASN1_CHOICE:
            typeName = "CHOICE";
            componentName = "Alternative";
            break;
        default:
            // some INTERNAL ERROR
            typeName = "<unknown>";
            componentName = "component";
            break;
    }
    for (int i = 0; i < componentTypeList1.getNofComps(); i++) {
        checkComponentField(componentTypeList1.getCompByIndex(i), typeName, componentName);
    }
    if (null != extensionAndException) {
        for (int i = 0; i < extensionAndException.getNofComps(); i++) {
            checkComponentField(extensionAndException.getCompByIndex(i), typeName, componentName);
        }
        final ExceptionSpecification es = extensionAndException.getExceptionSpecification();
        if (es != null) {
            es.getType().check(timestamp);
        }
    }
    for (int i = 0; i < componentTypeList2.getNofComps(); i++) {
        checkComponentField(componentTypeList2.getCompByIndex(i), typeName, componentName);
    }
    components.trimToSize();
    IType type;
    for (final CompField componentField : components) {
        type = componentField.getType();
        type.setGenName(myType.getGenNameOwn(), componentField.getIdentifier().getName());
        type.setParentType(myType);
        componentField.check(timestamp);
    }
}
Also used : HashMap(java.util.HashMap) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) ArrayList(java.util.ArrayList) Module(org.eclipse.titan.designer.AST.Module) IType(org.eclipse.titan.designer.AST.IType)

Example 14 with Module

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

the class ImportModule method addProposal.

/**
 * Adds the imported module or definitions contained in it, to the list
 * completion proposals.
 *
 * @param propCollector
 *                the proposal collector.
 * @param targetModuleId
 *                the identifier of the module where the definition will
 *                be inserted. It is used to check if it is visible
 *                there or not.
 */
@Override
public /**
 * {@inheritDoc}
 */
void addProposal(final ProposalCollector propCollector, final Identifier targetModuleId) {
    final List<ISubReference> subrefs = propCollector.getReference().getSubreferences();
    if (propCollector.getReference().getModuleIdentifier() == null && subrefs.size() == 1) {
        propCollector.addProposal(identifier, ImageCache.getImage(getOutlineIcon()), KIND);
    }
    final Module savedReferredModule = referredModule;
    if (savedReferredModule != null) {
        final Assignments assignments = savedReferredModule.getAssignments();
        for (int i = 0, size = assignments.getNofAssignments(); i < size; i++) {
            final Assignment temporalAssignment = assignments.getAssignmentByIndex(i);
            if (savedReferredModule.isVisible(CompilationTimeStamp.getBaseTimestamp(), targetModuleId, temporalAssignment)) {
                temporalAssignment.addProposal(propCollector, 0);
            }
        }
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Assignments(org.eclipse.titan.designer.AST.Assignments) Module(org.eclipse.titan.designer.AST.Module)

Example 15 with Module

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

the class Imports method checkImports.

/**
 * Checks the import hierarchies of this importation (and the ones in
 * the imported module recursively).
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param referenceChain
 *                a chain of references used to find circularly imported
 *                modules.
 * @param moduleStack
 *                the stack of modules visited so far, from the starting
 *                point.
 */
public void checkImports(final CompilationTimeStamp timestamp, final ModuleImportationChain referenceChain, final List<Module> moduleStack) {
    if (null != lastImportCheckTimeStamp && !lastImportCheckTimeStamp.isLess(timestamp)) {
        return;
    }
    lastImportCheckTimeStamp = timestamp;
    if (null == project) {
        return;
    }
    importedModules_map.clear();
    singularImportedSymbols_map.clear();
    pluralImportedSymbols.clear();
    final ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
    if (null == parser) {
        return;
    }
    for (ImportModule importModule : importedModules_v) {
        final Identifier identifier = importModule.getIdentifier();
        if (null == identifier || null == identifier.getLocation()) {
            continue;
        }
        final Module referredModule = parser.getModuleByName(identifier.getName());
        if (null == referredModule) {
            identifier.getLocation().reportSemanticError(MessageFormat.format(ImportModule.MISSINGMODULE, identifier.getDisplayName()));
            continue;
        } else if (!(referredModule instanceof ASN1Module)) {
            identifier.getLocation().reportSemanticError(TTCN3IMPORT);
            continue;
        } else if (referredModule == module) {
            identifier.getLocation().reportSemanticError(SELFIMPORT);
            continue;
        }
        String name = identifier.getName();
        if (importedModules_map.containsKey(name)) {
            final Location importedLocation = importedModules_map.get(name).getIdentifier().getLocation();
            importedLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEIMPORTFIRST, identifier.getDisplayName()));
            identifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEIMPORTREPEATED, identifier.getDisplayName()));
        } else {
            importedModules_map.put(name, importModule);
        }
        final Symbols symbols = importModule.getSymbols();
        if (null == symbols) {
            continue;
        }
        for (int i = 0; i < symbols.size(); i++) {
            name = symbols.getNthElement(i).getName();
            if (singularImportedSymbols_map.containsKey(name)) {
                if (!referredModule.equals(singularImportedSymbols_map.get(name))) {
                    singularImportedSymbols_map.remove(name);
                    pluralImportedSymbols.add(name);
                }
            } else if (!pluralImportedSymbols.contains(name)) {
                singularImportedSymbols_map.put(name, referredModule);
            }
        }
        importModule.setUnhandledChange(false);
        LoadBalancingUtilities.astNodeChecked();
    }
    for (ImportModule importModule : importedModules_v) {
        // check the imports recursively
        referenceChain.markState();
        importModule.checkImports(timestamp, referenceChain, moduleStack);
        referenceChain.previousState();
    }
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) Module(org.eclipse.titan.designer.AST.Module) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) Location(org.eclipse.titan.designer.AST.Location)

Aggregations

Module (org.eclipse.titan.designer.AST.Module)130 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)51 ArrayList (java.util.ArrayList)37 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)36 IFile (org.eclipse.core.resources.IFile)32 Assignment (org.eclipse.titan.designer.AST.Assignment)22 Identifier (org.eclipse.titan.designer.AST.Identifier)21 Location (org.eclipse.titan.designer.AST.Location)16 Reference (org.eclipse.titan.designer.AST.Reference)16 ImportModule (org.eclipse.titan.designer.AST.TTCN3.definitions.ImportModule)16 HashMap (java.util.HashMap)14 List (java.util.List)13 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)11 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)11 IProject (org.eclipse.core.resources.IProject)10 IResource (org.eclipse.core.resources.IResource)10 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)10 Assignments (org.eclipse.titan.designer.AST.Assignments)9 Scope (org.eclipse.titan.designer.AST.Scope)9 TextSelection (org.eclipse.jface.text.TextSelection)8