Search in sources :

Example 1 with NamedBridgeScope

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

the class Def_Template method setMyScope.

@Override
public /**
 * {@inheritDoc}
 */
void setMyScope(final Scope scope) {
    if (bridgeScope != null && bridgeScope.getParentScope() == scope) {
        return;
    }
    bridgeScope = new NamedBridgeScope();
    bridgeScope.setParentScope(scope);
    scope.addSubScope(getLocation(), bridgeScope);
    bridgeScope.setScopeMacroName(identifier.getDisplayName());
    super.setMyScope(bridgeScope);
    if (type != null) {
        type.setMyScope(bridgeScope);
    }
    if (formalParList != null) {
        formalParList.setMyScope(bridgeScope);
        bridgeScope.addSubScope(formalParList.getLocation(), formalParList);
        if (body != null) {
            body.setMyScope(formalParList);
        }
    } else if (body != null) {
        body.setMyScope(bridgeScope);
    }
    if (derivedReference != null) {
        derivedReference.setMyScope(bridgeScope);
    }
}
Also used : NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope)

Example 2 with NamedBridgeScope

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

the class RenameRefactoring method checkFinalConditions.

@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException {
    RefactoringStatus result = new RefactoringStatus();
    final boolean reportDebugInformation = Platform.getPreferencesService().getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
    // search
    idsMap = rf.findAllReferences(module, file.getProject(), pm, reportDebugInformation);
    // add the referred identifier to the map of found identifiers
    Identifier refdIdentifier = rf.getReferredIdentifier();
    Module refdModule = rf.assignment.getMyScope().getModuleScope();
    if (idsMap.containsKey(refdModule)) {
        idsMap.get(refdModule).add(new Hit(refdIdentifier));
    } else {
        ArrayList<Hit> identifierList = new ArrayList<Hit>();
        identifierList.add(new Hit(refdIdentifier));
        idsMap.put(refdModule, identifierList);
    }
    // scopes
    if (rf.fieldId == null) {
        // check that in all affected scopes there is no
        // definition with the new name
        Identifier.Identifier_type idType = Identifier_type.ID_TTCN;
        if (rf.scope.getModuleScope() instanceof ASN1Module) {
            idType = Identifier_type.ID_ASN;
        }
        Identifier newId = new Identifier(idType, newIdentifierName);
        // check for assignment with given id in all sub-scopes
        // of the assignment's scope
        // TODO: this does not detect runs on <-> component
        // member conflicts because the RunsOnScope is not a
        // sub-scope of the ComponentTypeBody scope,
        // also it does not go into other modules
        Scope rootScope = rf.assignment.getMyScope();
        if (rootScope instanceof NamedBridgeScope && rootScope.getParentScope() != null) {
            rootScope = rootScope.getParentScope();
        }
        SubScopeVisitor subScopeVisitor = new SubScopeVisitor(rootScope);
        module.accept(subScopeVisitor);
        List<Scope> subScopes = subScopeVisitor.getSubScopes();
        subScopes.add(rootScope);
        for (Scope ss : subScopes) {
            if (ss.hasAssignmentWithId(CompilationTimeStamp.getBaseTimestamp(), newId)) {
                List<ISubReference> subReferences = new ArrayList<ISubReference>();
                subReferences.add(new FieldSubReference(newId));
                Reference reference = new Reference(null, subReferences);
                Assignment assignment = ss.getAssBySRef(CompilationTimeStamp.getBaseTimestamp(), reference);
                if (assignment != null && assignment.getLocation() != null) {
                    result.addError(MessageFormat.format(DEFINITIONALREADYEXISTS2, newId.getDisplayName(), module.getName(), assignment.getLocation().getLine()));
                } else {
                    result.addError(MessageFormat.format(DEFINITIONALREADYEXISTS, newId.getDisplayName()));
                }
                // to avoid spam and multiple messages for the same conflict
                return result;
            }
        }
    } else {
        boolean alreadyExists = false;
        // name
        if (rf.type instanceof TTCN3_Set_Seq_Choice_BaseType) {
            alreadyExists = ((TTCN3_Set_Seq_Choice_BaseType) rf.type).hasComponentWithName(newIdentifierName);
        } else if (rf.type instanceof TTCN3_Enumerated_Type) {
            alreadyExists = ((TTCN3_Enumerated_Type) rf.type).hasEnumItemWithName(new Identifier(Identifier_type.ID_TTCN, newIdentifierName));
        } else if (rf.type instanceof ASN1_Choice_Type) {
            alreadyExists = ((ASN1_Choice_Type) rf.type).hasComponentWithName(new Identifier(Identifier_type.ID_ASN, newIdentifierName));
        } else if (rf.type instanceof ASN1_Enumerated_Type) {
            alreadyExists = ((ASN1_Enumerated_Type) rf.type).hasEnumItemWithName(new Identifier(Identifier_type.ID_ASN, newIdentifierName));
        } else if (rf.type instanceof ASN1_Sequence_Type) {
            alreadyExists = ((ASN1_Sequence_Type) rf.type).hasComponentWithName(new Identifier(Identifier_type.ID_ASN, newIdentifierName));
        } else if (rf.type instanceof ASN1_Set_Type) {
            alreadyExists = ((ASN1_Set_Type) rf.type).hasComponentWithName(new Identifier(Identifier_type.ID_ASN, newIdentifierName));
        }
        if (alreadyExists) {
            result.addError(MessageFormat.format(FIELDALREADYEXISTS, newIdentifierName, rf.type.getTypename()));
        }
    }
    return result;
}
Also used : Identifier_type(org.eclipse.titan.designer.AST.Identifier.Identifier_type) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) SubScopeVisitor(org.eclipse.titan.designer.AST.SubScopeVisitor) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) Reference(org.eclipse.titan.designer.AST.Reference) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) ArrayList(java.util.ArrayList) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ASN1_Set_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type) ASN1_Enumerated_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Enumerated_Type) Assignment(org.eclipse.titan.designer.AST.Assignment) ASN1_Choice_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Hit(org.eclipse.titan.designer.AST.ReferenceFinder.Hit) ASN1Module(org.eclipse.titan.designer.AST.ASN1.definitions.ASN1Module) Identifier(org.eclipse.titan.designer.AST.Identifier) Scope(org.eclipse.titan.designer.AST.Scope) NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope) NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope) ASN1_Sequence_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type) TTCN3_Set_Seq_Choice_BaseType(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType) Module(org.eclipse.titan.designer.AST.Module) ASN1Module(org.eclipse.titan.designer.AST.ASN1.definitions.ASN1Module)

Example 3 with NamedBridgeScope

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

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

the class Def_Function method setMyScope.

@Override
public /**
 * {@inheritDoc}
 */
void setMyScope(final Scope scope) {
    if (bridgeScope != null && bridgeScope.getParentScope() == scope) {
        return;
    }
    bridgeScope = new NamedBridgeScope();
    bridgeScope.setParentScope(scope);
    scope.addSubScope(getLocation(), bridgeScope);
    bridgeScope.setScopeMacroName(identifier.getDisplayName());
    super.setMyScope(bridgeScope);
    if (runsOnRef != null) {
        runsOnRef.setMyScope(bridgeScope);
    }
    formalParList.setMyScope(bridgeScope);
    if (returnType != null) {
        returnType.setMyScope(bridgeScope);
    }
    if (block != null) {
        block.setMyScope(formalParList);
    }
    if (block != null) {
        bridgeScope.addSubScope(block.getLocation(), block);
    }
    bridgeScope.addSubScope(formalParList.getLocation(), formalParList);
}
Also used : NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope)

Example 5 with NamedBridgeScope

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

the class Def_Testcase method setMyScope.

@Override
public /**
 * {@inheritDoc}
 */
void setMyScope(final Scope scope) {
    if (bridgeScope != null && bridgeScope.getParentScope() == scope) {
        return;
    }
    bridgeScope = new NamedBridgeScope();
    bridgeScope.setParentScope(scope);
    scope.addSubScope(getLocation(), bridgeScope);
    bridgeScope.setScopeMacroName(identifier.getDisplayName());
    super.setMyScope(bridgeScope);
    if (runsOnReference != null) {
        runsOnReference.setMyScope(bridgeScope);
    }
    if (systemReference != null) {
        systemReference.setMyScope(bridgeScope);
    }
    formalParList.setMyScope(bridgeScope);
    if (block != null) {
        block.setMyScope(formalParList);
        bridgeScope.addSubScope(block.getLocation(), block);
    }
    bridgeScope.addSubScope(formalParList.getLocation(), formalParList);
}
Also used : NamedBridgeScope(org.eclipse.titan.designer.AST.NamedBridgeScope)

Aggregations

NamedBridgeScope (org.eclipse.titan.designer.AST.NamedBridgeScope)7 Assignment (org.eclipse.titan.designer.AST.Assignment)2 Module (org.eclipse.titan.designer.AST.Module)2 Reference (org.eclipse.titan.designer.AST.Reference)2 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1 ASN1Module (org.eclipse.titan.designer.AST.ASN1.definitions.ASN1Module)1 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)1 ASN1_Enumerated_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Enumerated_Type)1 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)1 ASN1_Set_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Type)1 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Identifier_type (org.eclipse.titan.designer.AST.Identifier.Identifier_type)1 Hit (org.eclipse.titan.designer.AST.ReferenceFinder.Hit)1 Scope (org.eclipse.titan.designer.AST.Scope)1 SubScopeVisitor (org.eclipse.titan.designer.AST.SubScopeVisitor)1 FormalParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)1