use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class TTCN3Module method checkFriendModuleUniqueness.
/**
* Checks that each friend module of this module is provided only once.
*/
private void checkFriendModuleUniqueness() {
if (!friendModules.isEmpty()) {
final Map<String, FriendModule> map = new HashMap<String, FriendModule>(friendModules.size());
for (final FriendModule friendModule : friendModules) {
final Identifier identifier = friendModule.getIdentifier();
final String name = identifier.getName();
if (map.containsKey(name)) {
final Location otherLocation = map.get(name).getIdentifier().getLocation();
otherLocation.reportSingularSemanticError(MessageFormat.format("Duplicate friend module `{0}'' was first declared here", identifier.getDisplayName()));
final Location friendLocation = friendModule.getIdentifier().getLocation();
friendLocation.reportSingularSemanticError(MessageFormat.format("Duplicate friend module `{0}'' was declared here again", identifier.getDisplayName()));
} else {
map.put(name, friendModule);
}
}
}
}
use of org.eclipse.titan.designer.AST.Location 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.AST.Location 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.AST.Location 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.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class Qualifier method getQualifierWithoutFirstSubRef.
/**
* Creates a qualifier which is almost a copy of the actual one, but
* does not have it's first subreference.
*
* @return the created qualifier
*/
public Qualifier getQualifierWithoutFirstSubRef() {
final Qualifier temp = new Qualifier();
temp.setLocation(new Location(getLocation()));
for (int i = 1; i < subReferences.size(); i++) {
temp.addSubReference(subReferences.get(i));
}
return temp;
}
Aggregations