Search in sources :

Example 76 with Identifier

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

the class MissingFriend method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof FriendModule) {
        final FriendModule s = (FriendModule) node;
        final Identifier identifier = s.getIdentifier();
        final ProjectSourceParser parser = GlobalParser.getProjectSourceParser(s.getProject());
        if (parser != null && identifier != null) {
            final Module referredModule = parser.getModuleByName(identifier.getName());
            if (referredModule == null) {
                final String msg = MessageFormat.format(MISSING_MODULE, identifier.getDisplayName());
                problems.report(identifier.getLocation(), msg);
            }
        }
    }
}
Also used : FriendModule(org.eclipse.titan.designer.AST.TTCN3.definitions.FriendModule) Identifier(org.eclipse.titan.designer.AST.Identifier) Module(org.eclipse.titan.designer.AST.Module) FriendModule(org.eclipse.titan.designer.AST.TTCN3.definitions.FriendModule) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 77 with Identifier

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

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

the class OutlineLabelProvider method getText.

@Override
public String getText(final Object element) {
    Identifier identifier = null;
    if (element instanceof IOutlineElement) {
        IOutlineElement e = (IOutlineElement) element;
        String outlineText = e.getOutlineText();
        if (outlineText.length() != 0) {
            return outlineText;
        }
        identifier = e.getIdentifier();
    }
    if (identifier == null) {
        return "unknown";
    }
    return identifier.getDisplayName();
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) IOutlineElement(org.eclipse.titan.designer.AST.IOutlineElement)

Example 79 with Identifier

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

the class OutlinePage method selectionChanged.

@Override
public void selectionChanged(final SelectionChangedEvent event) {
    super.selectionChanged(event);
    ISelection selection = event.getSelection();
    if (selection.isEmpty()) {
        return;
    }
    Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
    Identifier identifier = null;
    if (selectedElement instanceof IOutlineElement) {
        identifier = ((IOutlineElement) selectedElement).getIdentifier();
    }
    if (identifier == null || identifier.getLocation() == null) {
        return;
    }
    Location location = identifier.getLocation();
    editor.selectAndReveal(location.getOffset(), location.getEndOffset() - location.getOffset());
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOutlineElement(org.eclipse.titan.designer.AST.IOutlineElement) Location(org.eclipse.titan.designer.AST.Location)

Example 80 with Identifier

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

the class OutlineLabelProvider method getText.

@Override
public String getText(final Object element) {
    Identifier identifier = null;
    if (element instanceof IOutlineElement) {
        IOutlineElement e = (IOutlineElement) element;
        String outlineText = e.getOutlineText();
        if (outlineText.length() != 0) {
            return outlineText;
        }
        identifier = e.getIdentifier();
    } else if (element instanceof List<?>) {
        return "imports";
    }
    if (identifier == null) {
        return "unknown";
    }
    return identifier.getDisplayName();
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) IOutlineElement(org.eclipse.titan.designer.AST.IOutlineElement)

Aggregations

Identifier (org.eclipse.titan.designer.AST.Identifier)176 IType (org.eclipse.titan.designer.AST.IType)75 ISubReference (org.eclipse.titan.designer.AST.ISubReference)57 IValue (org.eclipse.titan.designer.AST.IValue)39 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)38 Type (org.eclipse.titan.designer.AST.Type)35 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 Assignment (org.eclipse.titan.designer.AST.Assignment)25 ArrayList (java.util.ArrayList)24 Location (org.eclipse.titan.designer.AST.Location)24 Reference (org.eclipse.titan.designer.AST.Reference)22 Module (org.eclipse.titan.designer.AST.Module)21 HashMap (java.util.HashMap)16 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)15 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)12 Value (org.eclipse.titan.designer.AST.Value)12 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)10 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)10 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10