Search in sources :

Example 31 with Definition

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definition in project titan.EclipsePlug-ins by eclipse.

the class Visibility method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof FormalParameter) {
        return;
    } else if (node instanceof Definition) {
        final Definition s = (Definition) node;
        final Identifier identifier = s.getIdentifier();
        check(identifier, s.getDescription(), problems);
    } else if (node instanceof Group) {
        final Group s = (Group) node;
        final Identifier identifier = s.getIdentifier();
        check(identifier, "group", problems);
    } else {
        return;
    }
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) Group(org.eclipse.titan.designer.AST.TTCN3.definitions.Group) Identifier(org.eclipse.titan.designer.AST.Identifier) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)

Example 32 with Definition

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definition in project titan.EclipsePlug-ins by eclipse.

the class TypenameInDef method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    if (!(node instanceof Def_Const) && !(node instanceof Def_ExternalConst) && !(node instanceof Def_Extfunction) && !(node instanceof Def_Function) && !(node instanceof Def_ModulePar) && !(node instanceof Def_Template) && !(node instanceof Def_Var_Template) && !(node instanceof Def_Var)) {
        return;
    }
    final Definition s = (Definition) node;
    check(s.getIdentifier(), s.getType(timestamp), s.getDescription(), problems);
}
Also used : Def_ExternalConst(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_ExternalConst) Def_Extfunction(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Extfunction) Def_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template) Def_Var(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var) Def_ModulePar(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_ModulePar) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) Def_Const(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const) Def_Var_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Example 33 with Definition

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definition in project titan.EclipsePlug-ins by eclipse.

the class UncommentedDefinition method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof Definition) {
        final Definition s = (Definition) node;
        if (s.getCommentLocation() == null) {
            final String msg = MessageFormat.format("The {0} {1} should have a comment", s.getAssignmentName(), s.getIdentifier().getDisplayName());
            problems.report(s.getIdentifier().getLocation(), msg);
        }
    }
}
Also used : Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)

Example 34 with Definition

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definition in project titan.EclipsePlug-ins by eclipse.

the class NonprivatePrivate method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (!(node instanceof Definition)) {
        return;
    }
    final Definition d = (Definition) node;
    if (d.isUsed() && d.referingHere.size() == 1 && !VisibilityModifier.Private.equals(d.getVisibilityModifier()) && !d.isLocal()) {
        final String moduleName = d.getMyScope().getModuleScope().getName();
        if (d.referingHere.get(0).equals(moduleName)) {
            final String msg = MessageFormat.format(SHOULD_BE_PRIVATE, d.getIdentifier().getDisplayName());
            problems.report(d.getIdentifier().getLocation(), msg);
        }
    }
}
Also used : Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)

Example 35 with Definition

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Definition 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)

Aggregations

Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)52 Assignment (org.eclipse.titan.designer.AST.Assignment)16 IValue (org.eclipse.titan.designer.AST.IValue)12 Location (org.eclipse.titan.designer.AST.Location)11 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)10 IType (org.eclipse.titan.designer.AST.IType)10 Identifier (org.eclipse.titan.designer.AST.Identifier)10 Module (org.eclipse.titan.designer.AST.Module)10 ArrayList (java.util.ArrayList)9 Reference (org.eclipse.titan.designer.AST.Reference)9 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)8 ISubReference (org.eclipse.titan.designer.AST.ISubReference)6 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)6 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)6 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)6 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)5 RunsOnScope (org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)5 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)5 IFile (org.eclipse.core.resources.IFile)4 Restriction_type (org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type)4