Search in sources :

Example 6 with Scope

use of org.eclipse.titan.designer.AST.Scope 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 7 with Scope

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

the class TableConstraint method getOpenTypeAlternativeName.

// Original titan.core version: t_type->get_otaltname(is_strange);
private Identifier getOpenTypeAlternativeName(final CompilationTimeStamp timestamp, final Type type, final AtomicBoolean isStrange) {
    StringBuffer sb = new StringBuffer();
    // TODO:  if (is_tagged() || is_constrained() || hasRawAttrs()) {
    if (!type.getIsErroneous(timestamp) && type.isConstrained()) {
        sb.append(type.getGenNameOwn());
        isStrange.set(true);
    } else if (!type.getIsErroneous(timestamp) && type instanceof Referenced_Type) {
        Reference t_ref = ((Referenced_Type) type).getReference();
        if (t_ref != null) {
            final Identifier id = t_ref.getId();
            final String dn = id.getDisplayName();
            int i = dn.indexOf('.');
            if (i >= 0 && i < dn.length()) {
                // id is not regular because t_ref is a parameterized reference
                sb.append(id.getName());
                isStrange.set(true);
            } else {
                Assignment as = t_ref.getRefdAssignment(timestamp, true);
                if (as == null) {
                    return null;
                }
                Scope assScope = as.getMyScope();
                if (assScope.getParentScope() == assScope.getModuleScope()) {
                    sb.append(id.getName());
                    isStrange.set(false);
                } else {
                    // t_ref is a dummy reference in a parameterized assignment
                    // (i.e. it points to a parameter assignment of an instantiation)
                    // perform the same examination recursively on the referenced type
                    // (which is the actual parameter)
                    IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                    IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
                    chain.release();
                    return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
                }
            }
        } else {
            // the type comes from an information object [class]
            // examine the referenced type recursively
            IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
            IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
            chain.release();
            return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
        }
    } else {
        Identifier tmpId1 = new Identifier(Identifier_type.ID_NAME, type.getFullName());
        String s = tmpId1.getDisplayName();
        // module name will be cut off:
        if (s.startsWith("@") && s.indexOf('.') > 0) {
            s = s.substring(s.indexOf('.') + 1);
        }
        Identifier tmpId2 = new Identifier(Identifier_type.ID_ASN, s);
        sb.append(tmpId2.getTtcnName());
    }
    // conversion to lower case initial:
    sb.replace(0, 1, sb.substring(0, 1).toLowerCase());
    // trick:
    Identifier tmpId = new Identifier(Identifier_type.ID_NAME, sb.toString());
    return new Identifier(Identifier_type.ID_ASN, tmpId.getAsnName());
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IReferencingType(org.eclipse.titan.designer.AST.IReferencingType) TTCN3_Set_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Type) ASN1_Sequence_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type) TTCN3_Choice_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type) Open_Type(org.eclipse.titan.designer.AST.ASN1.types.Open_Type) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) FieldSetting_Type(org.eclipse.titan.designer.AST.ASN1.Object.FieldSetting_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) ObjectClassField_Type(org.eclipse.titan.designer.AST.ASN1.types.ObjectClassField_Type) TTCN3_Sequence_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type) 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) Identifier(org.eclipse.titan.designer.AST.Identifier) Scope(org.eclipse.titan.designer.AST.Scope) Reference(org.eclipse.titan.designer.AST.Reference) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 8 with Scope

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

the class Object_FieldSpecification method setMyObjectClass.

@Override
public /**
 * {@inheritDoc}
 */
void setMyObjectClass(final ObjectClass_Definition objectClass) {
    super.setMyObjectClass(objectClass);
    final Scope scope = myObjectClass.getMyScope();
    objectClass.setMyScope(scope);
    if (null != defaultObject) {
        defaultObject.setMyScope(scope);
    }
}
Also used : Scope(org.eclipse.titan.designer.AST.Scope)

Example 9 with Scope

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

the class ContentAssistProcessor method computeCompletionProposals.

@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
    IDocument doc = viewer.getDocument();
    IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
    ASN1ReferenceParser refParser = new ASN1ReferenceParser();
    Reference ref = refParser.findReferenceForCompletion(file, offset, doc);
    IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
        TITANDebugConsole.println("parsed the reference: " + ref);
    }
    if (ref == null || ref.getSubreferences().isEmpty()) {
        return new ICompletionProposal[] {};
    }
    Scope scope = null;
    ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
    Module tempModule = projectSourceParser.containedModule(file);
    if (tempModule != null) {
        scope = tempModule.getSmallestEnclosingScope(refParser.getReplacementOffset());
        ref.setMyScope(scope);
        ref.detectModid();
    }
    TemplateContextType contextType = new TemplateContextType(ASN1CodeSkeletons.CONTEXT_IDENTIFIER, ASN1CodeSkeletons.CONTEXT_NAME);
    ProposalCollector propCollector = new ProposalCollector(Identifier_type.ID_ASN, ASN1CodeSkeletons.CONTEXT_IDENTIFIER, contextType, doc, ref, refParser.getReplacementOffset());
    if (scope != null) {
        scope.addProposal(propCollector);
        propCollector.sortTillMarked();
        propCollector.markPosition();
    }
    if (ref.getSubreferences().size() != 1) {
        return propCollector.getCompletitions();
    }
    if (scope == null) {
        propCollector.addProposal(CodeScanner.TAGS, null, KEYWORD);
    } else {
        ASN1CodeSkeletons.addSkeletonProposals(doc, refParser.getReplacementOffset(), propCollector);
    }
    propCollector.sortTillMarked();
    propCollector.markPosition();
    propCollector.addProposal(CodeScanner.VERBS, null, KEYWORD);
    propCollector.addProposal(CodeScanner.COMPARE_TYPES, null, KEYWORD);
    propCollector.addProposal(CodeScanner.STATUS_TYPE, null, KEYWORD);
    propCollector.addProposal(CodeScanner.KEYWORDS, null, KEYWORD);
    propCollector.addProposal(CodeScanner.STORAGE, null, KEYWORD);
    propCollector.addProposal(CodeScanner.MODIFIER, null, KEYWORD);
    propCollector.addProposal(CodeScanner.ACCESS_TYPE, null, KEYWORD);
    propCollector.sortTillMarked();
    String sortingpolicy = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CONTENTASSISTANT_PROPOSAL_SORTING);
    if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
        propCollector.sortAll();
    }
    return propCollector.getCompletitions();
}
Also used : ProposalCollector(org.eclipse.titan.designer.editors.ProposalCollector) IFile(org.eclipse.core.resources.IFile) Scope(org.eclipse.titan.designer.AST.Scope) Reference(org.eclipse.titan.designer.AST.Reference) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) Module(org.eclipse.titan.designer.AST.Module) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType) IDocument(org.eclipse.jface.text.IDocument) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 10 with Scope

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

the class Altstep_Type method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    runsOnType = null;
    lastTimeChecked = timestamp;
    isErroneous = false;
    parseAttributes(timestamp);
    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);
            }
        }
    }
    formalParList.reset();
    formalParList.check(timestamp, Assignment_type.A_ALTSTEP);
    formalParList.checkNoLazyParams();
    checkSubtypeRestrictions(timestamp);
    if (myScope != null) {
        checkEncode(timestamp);
        checkVariants(timestamp);
    }
}
Also used : Scope(org.eclipse.titan.designer.AST.Scope) RunsOnScope(org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope) RunsOnScope(org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)

Aggregations

Scope (org.eclipse.titan.designer.AST.Scope)24 IType (org.eclipse.titan.designer.AST.IType)13 Module (org.eclipse.titan.designer.AST.Module)9 Assignment (org.eclipse.titan.designer.AST.Assignment)6 Identifier (org.eclipse.titan.designer.AST.Identifier)6 Reference (org.eclipse.titan.designer.AST.Reference)6 RunsOnScope (org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)5 IValue (org.eclipse.titan.designer.AST.IValue)4 NamedBridgeScope (org.eclipse.titan.designer.AST.NamedBridgeScope)4 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)3 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)3 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)2 IDocument (org.eclipse.jface.text.IDocument)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)2 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)2 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)2 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)2 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)2