Search in sources :

Example 51 with Location

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

the class Parameterised_Reference method newInstance.

public Parameterised_Reference newInstance() {
    Parameterised_Reference temp = null;
    temp = new Parameterised_Reference(assignmentReference.newInstance(), mBlock);
    temp.setLocation(new Location(location));
    return temp;
}
Also used : Location(org.eclipse.titan.designer.AST.Location)

Example 52 with Location

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

the class Object_Definition method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (null == fieldSettingMap) {
        fieldSettingMap = new HashMap<String, FieldSetting>(fieldSettings.size());
    }
    fieldSettingMap.clear();
    if (null != myGovernor) {
        myGovernor.check(timestamp);
    }
    parseBlock(timestamp);
    String name;
    for (int i = 0; i < fieldSettings.size(); i++) {
        final FieldSetting fieldSetting = fieldSettings.get(i);
        name = fieldSetting.getName().getName();
        if (fieldSettingMap.containsKey(name)) {
            final Location location = fieldSettingMap.get(name).getLocation();
            location.reportSingularSemanticError(MessageFormat.format(DUPLICATEDFIELDSETTINGFIRST, fieldSetting.getName().getDisplayName()));
            fieldSetting.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEDFIELDSETTINGREPEATED, fieldSetting.getName().getDisplayName()));
        } else {
            fieldSettingMap.put(name, fieldSetting);
        }
    }
    fieldSettings.trimToSize();
    if (null != myGovernor) {
        myGovernor.checkThisObject(timestamp, this);
    }
}
Also used : Location(org.eclipse.titan.designer.AST.Location)

Example 53 with Location

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

the class ASN1Assignments method checkUniqueness.

/**
 * Checks the uniqueness of the definitions, and also builds a hashmap
 * of them to speed up further searches.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 */
public void checkUniqueness(final CompilationTimeStamp timestamp) {
    if (null != lastUniqueNessCheckTimeStamp && !lastUniqueNessCheckTimeStamp.isLess(timestamp)) {
        return;
    }
    if (null == assignmentMap) {
        assignmentMap = new HashMap<String, ASN1Assignment>(assignments.size());
    }
    lastUniqueNessCheckTimeStamp = timestamp;
    dynamic_assignments.clear();
    assignmentMap.clear();
    final Assignments specialAssignments = SpecialASN1Module.getSpecialModule().getAssignments();
    for (ASN1Assignment assignment : assignments) {
        final Identifier identifier = assignment.getIdentifier();
        final String assignmentName = identifier.getName();
        if (specialAssignments.hasAssignmentWithId(timestamp, identifier)) {
            final Location selfLocation = assignment.getIdentifier().getLocation();
            selfLocation.reportSemanticError(MessageFormat.format(RESERVEDIDENTIFIER, identifier.getDisplayName()));
        } else if (assignmentMap.containsKey(assignmentName)) {
            final Location otherLocation = assignmentMap.get(assignmentName).getIdentifier().getLocation();
            otherLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
            final Location selfLocation = assignment.getIdentifier().getLocation();
            selfLocation.reportSemanticError(MessageFormat.format(DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
        } else {
            assignmentMap.put(assignmentName, assignment);
        }
    }
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) Assignments(org.eclipse.titan.designer.AST.Assignments) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) Location(org.eclipse.titan.designer.AST.Location)

Example 54 with Location

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

the class ASN1Assignments method addDynamicAssignment.

/**
 * Adds a dynamic assignment to the list of assignments.
 * <p>
 * Only assignments which were created dynamically during the semantic
 * check shall be added with this function. The scope of the newly added
 * assignment is set to this scope scope here.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param assignment
 *                the assignment to be added
 */
public void addDynamicAssignment(final CompilationTimeStamp timestamp, final ASN1Assignment assignment) {
    if (null == assignment || null == assignment.getIdentifier()) {
        return;
    }
    if (null == lastUniqueNessCheckTimeStamp) {
        checkUniqueness(timestamp);
    }
    dynamic_assignments.add(assignment);
    assignment.setMyScope(this);
    final Identifier identifier = assignment.getIdentifier();
    final String assignmentName = identifier.getName();
    final Assignments specialAssignments = SpecialASN1Module.getSpecialModule().getAssignments();
    if (specialAssignments.hasAssignmentWithId(timestamp, identifier)) {
        final Location tempLocation = assignment.getIdentifier().getLocation();
        tempLocation.reportSemanticError(MessageFormat.format(RESERVEDIDENTIFIER, identifier.getDisplayName()));
    } else if (assignmentMap.containsKey(assignmentName)) {
        final Location otherLocation = assignmentMap.get(assignmentName).getIdentifier().getLocation();
        otherLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
        final Location selfLocation = assignment.getIdentifier().getLocation();
        selfLocation.reportSemanticError(MessageFormat.format(DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
    } else {
        assignmentMap.put(assignmentName, assignment);
    }
}
Also used : Identifier(org.eclipse.titan.designer.AST.Identifier) Assignments(org.eclipse.titan.designer.AST.Assignments) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) Location(org.eclipse.titan.designer.AST.Location)

Example 55 with Location

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

the class For_Statement method setMyScope.

@Override
public /**
 * {@inheritDoc}
 */
void setMyScope(final Scope scope) {
    super.setMyScope(scope);
    if (definitions == null) {
        if (initialAssignment != null) {
            initialAssignment.setMyScope(scope);
        }
        if (finalExpression != null) {
            finalExpression.setMyScope(scope);
        }
        if (stepAssignment != null) {
            stepAssignment.setMyScope(scope);
        }
        if (statementblock != null) {
            statementblock.setMyScope(scope);
            scope.addSubScope(statementblock.getLocation(), statementblock);
        }
    } else {
        definitions.setParentScope(scope);
        final Location startLoc = definitions.getLocation();
        Location endLoc = null;
        if (finalExpression != null) {
            finalExpression.setMyScope(definitions);
            endLoc = finalExpression.getLocation();
        }
        if (stepAssignment != null) {
            stepAssignment.setMyScope(definitions);
            endLoc = stepAssignment.getLocation();
        }
        scope.addSubScope((endLoc == null) ? startLoc : Location.interval(startLoc, endLoc), definitions);
        if (statementblock != null) {
            statementblock.setMyScope(definitions);
            scope.addSubScope(statementblock.getLocation(), statementblock);
        }
    }
}
Also used : Location(org.eclipse.titan.designer.AST.Location)

Aggregations

Location (org.eclipse.titan.designer.AST.Location)109 Identifier (org.eclipse.titan.designer.AST.Identifier)24 ReParseException (org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)24 NULL_Location (org.eclipse.titan.designer.AST.NULL_Location)21 IIdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser)18 IdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser)18 Module (org.eclipse.titan.designer.AST.Module)16 ArrayList (java.util.ArrayList)15 IFile (org.eclipse.core.resources.IFile)13 HashMap (java.util.HashMap)11 Reference (org.eclipse.titan.designer.AST.Reference)10 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)10 Assignment (org.eclipse.titan.designer.AST.Assignment)9 IDocument (org.eclipse.jface.text.IDocument)8 InsertEdit (org.eclipse.text.edits.InsertEdit)8 ILocateableNode (org.eclipse.titan.designer.AST.ILocateableNode)8 CoreException (org.eclipse.core.runtime.CoreException)7 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)7 TITANMarker (org.eclipse.titan.common.parsers.TITANMarker)7 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)7