Search in sources :

Example 21 with ReParseException

use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.

the class StatementBlock method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (!isDamaged) {
        // handle the simple case quickly
        for (int i = 0, size = statements.size(); i < size; i++) {
            final Statement statement = statements.get(i);
            statement.updateSyntax(reparser, false);
            reparser.updateLocation(statement.getLocation());
        }
        return;
    }
    returnStatus = null;
    lastTimeChecked = null;
    boolean enveloped = false;
    int nofDamaged = 0;
    int leftBoundary = location.getOffset();
    int rightBoundary = location.getEndOffset();
    final int damageOffset = reparser.getDamageStart();
    IAppendableSyntax lastAppendableBeforeChange = null;
    IAppendableSyntax lastPrependableBeforeChange = null;
    for (int i = 0, size = statements.size(); i < size && !enveloped; i++) {
        final Statement statement = statements.get(i);
        final Location temporalLocation = statement.getLocation();
        Location cumulativeLocation;
        if (statement instanceof Definition_Statement) {
            cumulativeLocation = ((Definition_Statement) statement).getDefinition().getCumulativeDefinitionLocation();
        } else {
            cumulativeLocation = temporalLocation;
        }
        if (temporalLocation.equals(cumulativeLocation) && reparser.envelopsDamage(cumulativeLocation)) {
            enveloped = true;
            leftBoundary = cumulativeLocation.getOffset();
            rightBoundary = cumulativeLocation.getEndOffset();
        } else if (reparser.isDamaged(cumulativeLocation)) {
            nofDamaged++;
            if (reparser.getDamageStart() == cumulativeLocation.getEndOffset()) {
                lastAppendableBeforeChange = statement;
            } else if (reparser.getDamageEnd() == cumulativeLocation.getOffset()) {
                lastPrependableBeforeChange = statement;
            }
        } else {
            if (cumulativeLocation.getEndOffset() < damageOffset && cumulativeLocation.getEndOffset() > leftBoundary) {
                leftBoundary = cumulativeLocation.getEndOffset();
                lastAppendableBeforeChange = statement;
            }
            if (cumulativeLocation.getOffset() >= damageOffset && cumulativeLocation.getOffset() < rightBoundary) {
                rightBoundary = cumulativeLocation.getOffset();
                lastPrependableBeforeChange = statement;
            }
        }
    }
    // was not enveloped
    if (!enveloped) {
        reparser.extendDamagedRegion(leftBoundary, rightBoundary);
    }
    // extension might be correct
    if (lastAppendableBeforeChange != null) {
        final boolean isBeingExtended = reparser.startsWithFollow(lastAppendableBeforeChange.getPossibleExtensionStarterTokens());
        if (isBeingExtended) {
            leftBoundary = lastAppendableBeforeChange.getLocation().getOffset();
            nofDamaged++;
            enveloped = false;
            reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        }
    }
    if (lastPrependableBeforeChange != null) {
        final List<Integer> temp = lastPrependableBeforeChange.getPossiblePrefixTokens();
        if (temp != null && reparser.endsWithToken(temp)) {
            rightBoundary = lastPrependableBeforeChange.getLocation().getEndOffset();
            nofDamaged++;
            enveloped = false;
            reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        }
    }
    if (nofDamaged != 0) {
        removeStuffInRange(reparser);
    }
    for (final Iterator<Statement> iterator = statements.iterator(); iterator.hasNext(); ) {
        final Statement statement = iterator.next();
        final Location temporalLocation = statement.getLocation();
        Location cumulativeLocation;
        if (statement instanceof Definition_Statement) {
            cumulativeLocation = ((Definition_Statement) statement).getDefinition().getCumulativeDefinitionLocation();
        } else {
            cumulativeLocation = temporalLocation;
        }
        if (reparser.isAffectedAppended(cumulativeLocation)) {
            try {
                statement.updateSyntax(reparser, enveloped && reparser.envelopsDamage(cumulativeLocation));
                reparser.updateLocation(statement.getLocation());
            } catch (ReParseException e) {
                if (e.getDepth() == 1) {
                    enveloped = false;
                    iterator.remove();
                    reparser.extendDamagedRegion(cumulativeLocation);
                } else {
                    e.decreaseDepth();
                    throw e;
                }
            }
        }
    }
    if (!enveloped) {
        reparser.extendDamagedRegion(leftBoundary, rightBoundary);
        final int result = reparse(reparser);
        if (result > 1) {
            throw new ReParseException(result - 1);
        }
    }
}
Also used : IAppendableSyntax(org.eclipse.titan.designer.AST.TTCN3.IAppendableSyntax) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) Location(org.eclipse.titan.designer.AST.Location)

Example 22 with ReParseException

use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.

the class Stop_Component_Statement method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        throw new ReParseException();
    }
    if (componentReference instanceof IIncrementallyUpdateable) {
        ((IIncrementallyUpdateable) componentReference).updateSyntax(reparser, false);
        reparser.updateLocation(componentReference.getLocation());
    } else if (componentReference != null) {
        throw new ReParseException();
    }
}
Also used : IIncrementallyUpdateable(org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)

Example 23 with ReParseException

use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.

the class Reply_Statement method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        throw new ReParseException();
    }
    if (portReference != null) {
        portReference.updateSyntax(reparser, false);
        reparser.updateLocation(portReference.getLocation());
    }
    if (parameter != null) {
        parameter.updateSyntax(reparser, false);
        reparser.updateLocation(parameter.getLocation());
    }
    if (replyValue != null) {
        replyValue.updateSyntax(reparser, false);
        reparser.updateLocation(replyValue.getLocation());
    }
    if (toClause instanceof IIncrementallyUpdateable) {
        ((IIncrementallyUpdateable) toClause).updateSyntax(reparser, false);
        reparser.updateLocation(toClause.getLocation());
    } else if (toClause != null) {
        throw new ReParseException();
    }
}
Also used : IIncrementallyUpdateable(org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)

Example 24 with ReParseException

use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.

the class Send_Statement method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        throw new ReParseException();
    }
    if (portReference != null) {
        portReference.updateSyntax(reparser, false);
        reparser.updateLocation(portReference.getLocation());
    }
    if (parameter != null) {
        parameter.updateSyntax(reparser, false);
        reparser.updateLocation(parameter.getLocation());
    }
    if (toClause instanceof IIncrementallyUpdateable) {
        ((IIncrementallyUpdateable) toClause).updateSyntax(reparser, false);
        reparser.updateLocation(toClause.getLocation());
    } else if (toClause != null) {
        throw new ReParseException();
    }
}
Also used : IIncrementallyUpdateable(org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)

Example 25 with ReParseException

use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.

the class Unknown_Start_Statement method updateSyntax.

@Override
public /**
 * {@inheritDoc}
 */
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
    if (isDamaged) {
        throw new ReParseException();
    }
    if (reference != null) {
        reference.updateSyntax(reparser, false);
        reparser.updateLocation(reference.getLocation());
    }
    if (value instanceof IIncrementallyUpdateable) {
        ((IIncrementallyUpdateable) value).updateSyntax(reparser, false);
        reparser.updateLocation(value.getLocation());
    } else if (value != null) {
        throw new ReParseException();
    }
}
Also used : IIncrementallyUpdateable(org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)

Aggregations

ReParseException (org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)52 Location (org.eclipse.titan.designer.AST.Location)24 IIncrementallyUpdateable (org.eclipse.titan.designer.AST.TTCN3.IIncrementallyUpdateable)21 IIdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser)18 IdentifierReparser (org.eclipse.titan.designer.parsers.ttcn3parser.IdentifierReparser)18 NULL_Location (org.eclipse.titan.designer.AST.NULL_Location)6 IAppendableSyntax (org.eclipse.titan.designer.AST.TTCN3.IAppendableSyntax)5 IType (org.eclipse.titan.designer.AST.IType)2 FileNotFoundException (java.io.FileNotFoundException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IValue (org.eclipse.titan.designer.AST.IValue)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Module (org.eclipse.titan.designer.AST.Module)1 Reference (org.eclipse.titan.designer.AST.Reference)1 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)1 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)1 ObjectIdentifierComponent (org.eclipse.titan.designer.AST.TTCN3.values.ObjectIdentifierComponent)1 Type (org.eclipse.titan.designer.AST.Type)1 ITtcn3FileReparser (org.eclipse.titan.designer.parsers.ttcn3parser.ITtcn3FileReparser)1 Ttcn3FileReparser (org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3FileReparser)1