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);
}
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations