use of org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser in project titan.EclipsePlug-ins by eclipse.
the class TTCN3Module method updateSyntax.
/**
* Handles the incremental parsing of this definition.
*
* @param reparser
* the parser doing the incremental parsing.
* @param sourceParser
* the general utility handling the parse of TTCN-3 and
* ASN.1 files, to efficiently handle module renaming.
*/
public void updateSyntax(final TTCN3ReparseUpdater reparser, final ProjectSourceParser sourceParser) throws ReParseException {
if (reparser.getShift() < 0) {
throw new ReParseException();
}
// edited outside the module
if (reparser.getDamageEnd() < location.getOffset()) {
// before the module
reparser.updateLocation(identifier.getLocation());
if (definitions != null) {
definitions.updateSyntax(reparser, importedModules, friendModules, controlpart);
}
if (controlpart != null) {
controlpart.updateSyntax(reparser);
reparser.updateLocation(controlpart.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
return;
} else if (reparser.getDamageStart() > location.getEndOffset()) {
// after the module
if (withAttributesPath == null || withAttributesPath.getAttributes() == null) {
// new attribute might have appeared
reparser.extendDamagedRegionTillFileEnd();
final int result = reparseAfterModule(reparser);
if (result != 0) {
throw new ReParseException();
}
}
return;
}
// edited the module identifier
final Location temporalIdentifier = identifier.getLocation();
if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
reparser.extendDamagedRegion(temporalIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
final int result = r.parse();
identifier = r.getIdentifier();
// damage handled
if (result != 0) {
throw new ReParseException(result);
}
if (definitions != null) {
definitions.updateSyntax(reparser, importedModules, friendModules, controlpart);
}
if (controlpart != null) {
controlpart.updateSyntax(reparser);
reparser.updateLocation(controlpart.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
return;
} else if (reparser.isDamaged(temporalIdentifier)) {
throw new ReParseException();
}
// the module has structurally changed
boolean enveloped = false;
if ((definitions != null && reparser.envelopsDamage(definitions.getLocation())) || (controlpart != null && reparser.envelopsDamage(controlpart.getLocation()))) {
if (definitions != null && reparser.isAffected(definitions.getLocation())) {
try {
definitions.updateSyntax(reparser, importedModules, friendModules, controlpart);
} catch (ReParseException e) {
throw e;
}
reparser.updateLocation(definitions.getLocation());
}
if (controlpart != null && reparser.isAffected(controlpart.getLocation())) {
try {
controlpart.updateSyntax(reparser);
} catch (ReParseException e) {
throw e;
}
reparser.updateLocation(controlpart.getLocation());
}
enveloped = true;
}
if (withAttributesPath != null && reparser.isAffected(withAttributesPath.getLocation())) {
// The modification happened inside the attribute list
if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
reparser.extendDamagedRegion(withAttributesPath.getLocation());
final int result = reparseInsideAttributelist(reparser);
if (result != 0) {
throw new ReParseException();
}
return;
} else if (enveloped) {
// The modification happened inside the module
withAttributesPath.updateSyntax(reparser, reparser.envelopsDamage(withAttributesPath.getLocation()));
reparser.updateLocation(withAttributesPath.getLocation());
} else {
// out
throw new ReParseException();
}
}
if (!enveloped) {
throw new ReParseException();
}
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser in project titan.EclipsePlug-ins by eclipse.
the class Def_Altstep method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
lastTimeChecked = null;
boolean enveloped = false;
final Location temporalIdentifier = identifier.getLocation();
if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
reparser.extendDamagedRegion(temporalIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
final int result = r.parseAndSetNameChanged();
identifier = r.getIdentifier();
// damage handled
if (result == 0 && identifier != null) {
enveloped = true;
} else {
removeBridge();
throw new ReParseException(result);
}
}
if (formalParList != null) {
if (enveloped) {
formalParList.updateSyntax(reparser, false);
reparser.updateLocation(formalParList.getLocation());
} else if (reparser.envelopsDamage(formalParList.getLocation())) {
try {
formalParList.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(formalParList.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (runsOnRef != null) {
if (enveloped) {
runsOnRef.updateSyntax(reparser, false);
reparser.updateLocation(runsOnRef.getLocation());
} else if (reparser.envelopsDamage(runsOnRef.getLocation())) {
try {
runsOnRef.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(runsOnRef.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (altGuards != null) {
if (enveloped) {
altGuards.updateSyntax(reparser, false);
reparser.updateLocation(altGuards.getLocation());
} else if (reparser.envelopsDamage(altGuards.getLocation())) {
try {
altGuards.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(altGuards.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (block != null) {
if (enveloped) {
block.updateSyntax(reparser, false);
reparser.updateLocation(block.getLocation());
} else if (reparser.envelopsDamage(block.getLocation())) {
try {
block.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(block.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (withAttributesPath != null) {
if (enveloped) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
} else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
try {
withAttributesPath.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(withAttributesPath.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (!enveloped) {
removeBridge();
throw new ReParseException();
}
return;
}
reparser.updateLocation(identifier.getLocation());
if (formalParList != null) {
formalParList.updateSyntax(reparser, false);
reparser.updateLocation(formalParList.getLocation());
}
if (runsOnRef != null) {
runsOnRef.updateSyntax(reparser, false);
reparser.updateLocation(runsOnRef.getLocation());
}
if (block != null) {
block.updateSyntax(reparser, false);
reparser.updateLocation(block.getLocation());
}
if (altGuards != null) {
altGuards.updateSyntax(reparser, false);
reparser.updateLocation(altGuards.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser in project titan.EclipsePlug-ins by eclipse.
the class Def_ExternalConst method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
lastTimeChecked = null;
boolean enveloped = false;
final Location temporalIdentifier = identifier.getLocation();
if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
reparser.extendDamagedRegion(temporalIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
final int result = r.parseAndSetNameChanged();
identifier = r.getIdentifier();
// damage handled
if (result == 0 && identifier != null) {
enveloped = true;
} else {
throw new ReParseException(result);
}
}
if (type != null) {
if (enveloped) {
type.updateSyntax(reparser, false);
reparser.updateLocation(type.getLocation());
} else if (reparser.envelopsDamage(type.getLocation())) {
type.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(type.getLocation());
}
}
if (withAttributesPath != null) {
if (enveloped) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
} else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
withAttributesPath.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(withAttributesPath.getLocation());
}
}
if (!enveloped) {
throw new ReParseException();
}
return;
}
reparser.updateLocation(identifier.getLocation());
if (type != null) {
type.updateSyntax(reparser, false);
reparser.updateLocation(type.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser in project titan.EclipsePlug-ins by eclipse.
the class CompField method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
boolean enveloped = false;
if (name != null) {
final Location tempIdentifier = name.getLocation();
if (reparser.envelopsDamage(tempIdentifier) || reparser.isExtending(tempIdentifier)) {
reparser.extendDamagedRegion(tempIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
final int result = r.parse();
name = r.getIdentifier();
// damage handled
if (result == 0) {
enveloped = true;
} else {
throw new ReParseException(result);
}
}
}
if (type != null) {
if (enveloped) {
type.updateSyntax(reparser, false);
reparser.updateLocation(type.getLocation());
} else if (reparser.envelopsDamage(type.getLocation())) {
type.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(type.getLocation());
}
}
if (defaultValue != null) {
if (enveloped) {
defaultValue.updateSyntax(reparser, false);
reparser.updateLocation(defaultValue.getLocation());
} else if (reparser.envelopsDamage(defaultValue.getLocation())) {
defaultValue.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(defaultValue.getLocation());
}
}
if (enveloped) {
return;
}
throw new ReParseException();
}
reparser.updateLocation(name.getLocation());
if (type != null) {
type.updateSyntax(reparser, false);
reparser.updateLocation(type.getLocation());
}
if (defaultValue != null) {
defaultValue.updateSyntax(reparser, false);
reparser.updateLocation(defaultValue.getLocation());
}
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.IIdentifierReparser in project titan.EclipsePlug-ins by eclipse.
the class Def_Template method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
lastTimeChecked = null;
boolean enveloped = false;
final Location temporalIdentifier = identifier.getLocation();
if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
reparser.extendDamagedRegion(temporalIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
final int result = r.parseAndSetNameChanged();
identifier = r.getIdentifier();
// damage handled
if (result == 0 && identifier != null) {
enveloped = true;
} else {
removeBridge();
throw new ReParseException(result);
}
}
if (type != null) {
if (enveloped) {
type.updateSyntax(reparser, false);
reparser.updateLocation(type.getLocation());
} else if (reparser.envelopsDamage(type.getLocation())) {
try {
type.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(type.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (formalParList != null) {
if (enveloped) {
formalParList.updateSyntax(reparser, false);
reparser.updateLocation(formalParList.getLocation());
} else if (reparser.envelopsDamage(formalParList.getLocation())) {
try {
formalParList.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(formalParList.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (derivedReference != null) {
if (enveloped) {
derivedReference.updateSyntax(reparser, false);
reparser.updateLocation(derivedReference.getLocation());
} else if (reparser.envelopsDamage(derivedReference.getLocation())) {
try {
derivedReference.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(derivedReference.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (body != null) {
if (enveloped) {
body.updateSyntax(reparser, false);
reparser.updateLocation(body.getLocation());
} else if (reparser.envelopsDamage(body.getLocation())) {
try {
body.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(body.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (withAttributesPath != null) {
if (enveloped) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
} else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
try {
withAttributesPath.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(withAttributesPath.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (!enveloped) {
removeBridge();
throw new ReParseException();
}
return;
}
reparser.updateLocation(identifier.getLocation());
if (type != null) {
type.updateSyntax(reparser, false);
reparser.updateLocation(type.getLocation());
}
if (formalParList != null) {
formalParList.updateSyntax(reparser, false);
reparser.updateLocation(formalParList.getLocation());
}
if (derivedReference != null) {
derivedReference.updateSyntax(reparser, false);
reparser.updateLocation(derivedReference.getLocation());
}
if (body != null) {
body.updateSyntax(reparser, false);
reparser.updateLocation(body.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
}
Aggregations