Search in sources :

Example 1 with Undefined_Assignment

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

the class ReferenceFinder method detectAssignmentDataByOffset.

public boolean detectAssignmentDataByOffset(final Module module, final int offset, final IEditorPart targetEditor, final boolean reportErrors, final boolean reportDebugInformation) {
    // detect the scope we are in
    scope = module.getSmallestEnclosingScope(offset);
    if (scope == null) {
        if (reportErrors) {
            targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NORECOGNISABLESCOPE);
        }
        return false;
    }
    final IdentifierFinderVisitor visitor = new IdentifierFinderVisitor(offset);
    module.accept(visitor);
    final Declaration declaration = visitor.getReferencedDeclaration();
    if (declaration == null) {
        return false;
    }
    assignment = declaration.getAssignment();
    if (assignment == null) {
        if (reportErrors) {
            targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NORECOGNISABLEASSIGNMENT);
        }
        return false;
    }
    scope = detectSmallestScope(assignment);
    // assignments which are created during SA
    if (assignment instanceof Undefined_Assignment) {
        assignment = ((Undefined_Assignment) assignment).getRealAssignment(CompilationTimeStamp.getBaseTimestamp());
        if (assignment == null) {
            if (reportErrors) {
                targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NORECOGNISABLEASSIGNMENT);
            }
            return false;
        }
    }
    // in a field
    if (assignment.getAssignmentType() == Assignment_type.A_TYPE) {
        type = assignment.getType(CompilationTimeStamp.getBaseTimestamp());
        if (type == null) {
            if (reportErrors) {
                targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOASSIGNMENTTYPE);
            }
            return false;
        }
        type.getEnclosingField(offset, this);
        type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    }
    if (reportDebugInformation) {
        final MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream();
        TITANDebugConsole.println("found scope: name=" + scope.getScopeName() + "  type=" + scope.getClass().getName(), stream);
        TITANDebugConsole.println("found assignment: name=" + assignment.getIdentifier().getDisplayName() + "  type=" + assignment.getClass().getName(), stream);
        if (type != null) {
            TITANDebugConsole.println("found type: name=" + type.getTypename() + "  type=" + type.getClass().getName(), stream);
        }
        if (fieldId != null) {
            TITANDebugConsole.println("found field: name=" + fieldId.getDisplayName(), stream);
        }
    }
    return true;
}
Also used : Undefined_Assignment(org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment) IdentifierFinderVisitor(org.eclipse.titan.designer.declarationsearch.IdentifierFinderVisitor) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) Declaration(org.eclipse.titan.designer.declarationsearch.Declaration)

Example 2 with Undefined_Assignment

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

the class Referenced_Type method getTypeRefd.

@Override
public /**
 * {@inheritDoc}
 */
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (refChain.add(this) && reference != null && !getIsErroneous(timestamp)) {
        if (refd != null) {
            return refd;
        }
        Assignment ass = reference.getRefdAssignment(timestamp, true, refChain);
        if (ass != null && Assignment_type.A_UNDEF.semanticallyEquals(ass.getAssignmentType())) {
            ass = ((Undefined_Assignment) ass).getRealAssignment(timestamp);
        }
        if (ass == null || ass.getIsErroneous()) {
            // The referenced assignment was not found, or is erroneous
            isErroneous = true;
            lastTimeChecked = timestamp;
            return this;
        }
        switch(ass.getAssignmentType()) {
            case A_TYPE:
                {
                    IType tempType = ass.getType(timestamp);
                    if (tempType != null) {
                        if (!tempType.getIsErroneous(timestamp)) {
                            tempType.check(timestamp);
                            tempType = tempType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, refChain, false);
                            if (tempType == null) {
                                setIsErroneous(true);
                                return this;
                            }
                            refd = tempType;
                            return refd;
                        }
                    }
                    break;
                }
            case A_VS:
                {
                    final IType tempType = ass.getType(timestamp);
                    if (tempType == null) {
                        isErroneous = true;
                        lastTimeChecked = timestamp;
                        return this;
                    }
                    refd = tempType;
                    return refd;
                }
            case A_OC:
            case A_OBJECT:
            case A_OS:
                final ISetting setting = reference.getRefdSetting(timestamp);
                if (setting == null || setting.getIsErroneous(timestamp)) {
                    isErroneous = true;
                    lastTimeChecked = timestamp;
                    return this;
                }
                if (!Setting_type.S_T.equals(setting.getSettingtype())) {
                    reference.getLocation().reportSemanticError(MessageFormat.format(TYPEREFERENCEEXPECTED, reference.getDisplayName()));
                    isErroneous = true;
                    lastTimeChecked = timestamp;
                    return this;
                }
                refd = (Type) setting;
                if (refd.getOwnertype() == TypeOwner_type.OT_UNKNOWN) {
                    refd.setOwnertype(TypeOwner_type.OT_REF, this);
                }
                return refd;
            default:
                reference.getLocation().reportSemanticError(MessageFormat.format(TYPEREFERENCEEXPECTED, reference.getDisplayName()));
                break;
        }
    }
    isErroneous = true;
    lastTimeChecked = timestamp;
    return this;
}
Also used : Type_Assignment(org.eclipse.titan.designer.AST.ASN1.Type_Assignment) Undefined_Assignment(org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ISetting(org.eclipse.titan.designer.AST.ISetting) IType(org.eclipse.titan.designer.AST.IType)

Example 3 with Undefined_Assignment

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

the class BrokenPartsViaReferences method getAssignmentsFrom.

public List<AssignmentHandler> getAssignmentsFrom(final Module module) {
    final List<AssignmentHandler> assignmentHandlers = new ArrayList<AssignmentHandler>();
    final Assignments assignments = module.getAssignments();
    for (int d = 0; d < assignments.getNofAssignments(); ++d) {
        final Assignment assignment = assignments.getAssignmentByIndex(d);
        final AssignmentHandler assignmentHandler = AssignmentHandlerFactory.getDefinitionHandler(assignment);
        if (assignment instanceof Undefined_Assignment) {
            final ASN1Assignment realAssignment = ((Undefined_Assignment) assignment).getRealAssignment(CompilationTimeStamp.getBaseTimestamp());
            if (realAssignment != null) {
                realAssignment.accept(assignmentHandler);
            } else {
                // TODO: re-fine this branch
                assignment.accept(assignmentHandler);
            }
        } else {
            assignment.accept(assignmentHandler);
        }
        assignmentHandlers.add(assignmentHandler);
    }
    return assignmentHandlers;
}
Also used : Undefined_Assignment(org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) Undefined_Assignment(org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment) ArrayList(java.util.ArrayList) Assignments(org.eclipse.titan.designer.AST.Assignments) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)

Aggregations

Undefined_Assignment (org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment)3 Assignment (org.eclipse.titan.designer.AST.Assignment)2 ArrayList (java.util.ArrayList)1 ASN1Assignment (org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)1 Type_Assignment (org.eclipse.titan.designer.AST.ASN1.Type_Assignment)1 Assignments (org.eclipse.titan.designer.AST.Assignments)1 ISetting (org.eclipse.titan.designer.AST.ISetting)1 IType (org.eclipse.titan.designer.AST.IType)1 Declaration (org.eclipse.titan.designer.declarationsearch.Declaration)1 IdentifierFinderVisitor (org.eclipse.titan.designer.declarationsearch.IdentifierFinderVisitor)1 MessageConsoleStream (org.eclipse.ui.console.MessageConsoleStream)1