use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class FormalParameterList method checkNoLazyParams.
/**
* check that @lazy paramterization not used in cases currently
* unsupported
*/
public final void checkNoLazyParams() {
for (int i = 0, size = parameters.size(); i < size; i++) {
if (parameters.get(i).getIsLazy()) {
final Location tempLocation = parameters.get(i).getLocation();
tempLocation.reportSemanticError(MessageFormat.format("Formal parameter `{0}'' cannot be @lazy, not supported in this case.", parameters.get(i).getAssignmentName()));
}
}
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class Group method updateSyntax.
/**
* Handles the incremental parsing of this list of definitions.
*
* @param reparser
* the parser doing the incremental parsing.
* @param allImportedModules
* the list of module importations found in the same
* module.
* @param allDefinitions
* the list of definitions found in the same module.
* @param allFriends
* the list of friend module declarations found in the
* same module.
* @return in case of processing error the minimum amount of semantic
* levels that must be destroyed to handle the syntactic
* changes, otherwise 0.
*/
public void updateSyntax(final TTCN3ReparseUpdater reparser, final List<ImportModule> allImportedModules, final List<Definition> allDefinitions, final List<FriendModule> allFriends) throws ReParseException {
int result = 0;
Location tempLocation = identifier.getLocation();
if (reparser.isDamaged(tempLocation)) {
if (reparser.envelopsDamage(tempLocation) || reparser.isExtending(tempLocation)) {
reparser.extendDamagedRegion(tempLocation);
result = reparseIdentifier(reparser);
if (result != 0) {
throw new ReParseException(result);
}
} else {
throw new ReParseException();
}
} else {
reparser.updateLocation(tempLocation);
}
if (reparser.isDamaged(innerLocation) && !reparser.envelopsDamage(innerLocation)) {
throw new ReParseException();
}
boolean enveloped = false;
int nofDamaged = 0;
int leftBoundary = innerLocation.getOffset();
int rightBoundary = innerLocation.getEndOffset();
final int damageOffset = reparser.getDamageStart();
IAppendableSyntax lastAppendableBeforeChange = null;
IAppendableSyntax lastPrependableBeforeChange = null;
for (int i = 0, size = groups.size(); i < size && !enveloped; i++) {
final Group temp = groups.get(i);
tempLocation = temp.getLocation();
if (reparser.envelopsDamage(tempLocation)) {
enveloped = true;
leftBoundary = tempLocation.getOffset();
rightBoundary = tempLocation.getEndOffset();
} else if (reparser.isDamaged(tempLocation)) {
nofDamaged++;
} else {
if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
leftBoundary = tempLocation.getEndOffset();
lastAppendableBeforeChange = temp;
}
if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = temp;
}
}
}
for (int i = 0, size = importedModules.size(); i < size && !enveloped; i++) {
final ImportModule temp = importedModules.get(i);
tempLocation = temp.getLocation();
if (reparser.envelopsDamage(tempLocation)) {
enveloped = true;
leftBoundary = tempLocation.getOffset();
rightBoundary = tempLocation.getEndOffset();
} else if (reparser.isDamaged(tempLocation)) {
nofDamaged++;
} else {
if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
leftBoundary = tempLocation.getEndOffset();
lastAppendableBeforeChange = temp;
}
if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = temp;
}
}
}
for (int i = 0, size = friendModules.size(); i < size && !enveloped; i++) {
final FriendModule temp = friendModules.get(i);
tempLocation = temp.getLocation();
if (reparser.envelopsDamage(tempLocation)) {
enveloped = true;
leftBoundary = tempLocation.getOffset();
rightBoundary = tempLocation.getEndOffset();
} else if (reparser.isDamaged(tempLocation)) {
nofDamaged++;
} else {
if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
leftBoundary = tempLocation.getEndOffset();
lastAppendableBeforeChange = temp;
}
if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = temp;
}
}
}
for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext() && !enveloped; ) {
final Definition temp = iterator.next();
tempLocation = temp.getLocation();
if (reparser.envelopsDamage(tempLocation)) {
enveloped = true;
leftBoundary = tempLocation.getOffset();
rightBoundary = tempLocation.getEndOffset();
} else if (reparser.isDamaged(tempLocation)) {
nofDamaged++;
if (reparser.getDamageStart() == tempLocation.getEndOffset()) {
lastAppendableBeforeChange = temp;
} else if (reparser.getDamageEnd() == tempLocation.getOffset()) {
lastPrependableBeforeChange = temp;
}
// reparser.extendDamagedRegion(temp_location);
} else {
if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
leftBoundary = tempLocation.getEndOffset();
lastAppendableBeforeChange = temp;
}
if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = temp;
}
}
final Location tempCommentLocation = temp.getCommentLocation();
if (tempCommentLocation != null && reparser.isDamaged(tempCommentLocation)) {
rightBoundary = tempCommentLocation.getOffset();
lastPrependableBeforeChange = temp;
}
}
// was not enveloped
if (!enveloped && reparser.envelopsDamage(location)) {
reparser.extendDamagedRegion(leftBoundary, rightBoundary);
}
// 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) {
// remove damaged stuff
removeStuffInRange(reparser, allImportedModules, allDefinitions, friendModules);
}
// update what is left
for (int i = 0; i < groups.size(); i++) {
final Group temp = groups.get(i);
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
temp.updateSyntax(reparser, allImportedModules, allDefinitions, friendModules);
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
groups.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
e.decreaseDepth();
throw e;
}
}
}
}
for (int i = 0; i < importedModules.size(); i++) {
final ImportModule temp = importedModules.get(i);
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
importedModules.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
e.decreaseDepth();
throw e;
}
}
}
}
for (int i = 0; i < friendModules.size(); i++) {
final FriendModule temp = friendModules.get(i);
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
temp.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
friendModules.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
e.decreaseDepth();
throw e;
}
}
}
}
for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
final Definition temp = iterator.next();
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
try {
final boolean isDamaged = enveloped && reparser.envelopsDamage(tempLocation);
temp.updateSyntax(reparser, isDamaged);
if (reparser.getNameChanged()) {
lastUniquenessCheckTimeStamp = null;
reparser.setNameChanged(false);
}
if (isDamaged) {
temp.checkRoot();
}
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
definitions.remove(temp);
reparser.extendDamagedRegion(tempLocation);
result = 1;
} else {
e.decreaseDepth();
throw e;
}
}
}
}
if (result == 1) {
removeStuffInRange(reparser, allImportedModules, allDefinitions, friendModules);
}
for (int i = 0, size = groups.size(); i < size; i++) {
final Group temp = groups.get(i);
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
reparser.updateLocation(tempLocation);
}
}
for (int i = 0, size = importedModules.size(); i < size; i++) {
final ImportModule temp = importedModules.get(i);
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
reparser.updateLocation(tempLocation);
}
}
for (int i = 0, size = friendModules.size(); i < size; i++) {
final FriendModule temp = friendModules.get(i);
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
reparser.updateLocation(tempLocation);
}
}
for (final Iterator<Definition> iterator = definitions.iterator(); iterator.hasNext(); ) {
final Definition temp = iterator.next();
tempLocation = temp.getLocation();
if (reparser.isAffected(tempLocation)) {
reparser.updateLocation(tempLocation);
}
}
if (withAttributesPath != null && reparser.isAffected(withAttributesPath.getLocation())) {
if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
reparser.extendDamagedRegion(withAttributesPath.getLocation());
result = reparseOptionalWithStatement(reparser);
if (result != 0) {
throw new ReParseException(result);
}
return;
}
withAttributesPath.updateSyntax(reparser, reparser.envelopsDamage(withAttributesPath.getLocation()));
reparser.updateLocation(withAttributesPath.getLocation());
}
if (!enveloped && reparser.envelopsDamage(innerLocation)) {
reparser.extendDamagedRegion(leftBoundary, rightBoundary);
result = reparseModuleDefinitionsList(reparser);
}
reparser.updateLocation(innerLocation);
if (result > 1) {
throw new ReParseException(result - 1);
}
return;
}
use of org.eclipse.titan.designer.AST.Location 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());
}
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class Def_Testcase method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
lastTimeChecked = null;
boolean enveloped = false;
int result = 1;
final Location temporalIdentifier = identifier.getLocation();
if (reparser.envelopsDamage(temporalIdentifier) || reparser.isExtending(temporalIdentifier)) {
reparser.extendDamagedRegion(temporalIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
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 (runsOnReference != null) {
if (enveloped) {
runsOnReference.updateSyntax(reparser, false);
reparser.updateLocation(runsOnReference.getLocation());
} else if (reparser.envelopsDamage(runsOnReference.getLocation())) {
try {
runsOnReference.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(runsOnReference.getLocation());
} catch (ReParseException e) {
removeBridge();
throw e;
}
}
}
if (systemReference != null) {
if (enveloped) {
systemReference.updateSyntax(reparser, false);
reparser.updateLocation(systemReference.getLocation());
} else if (reparser.envelopsDamage(systemReference.getLocation())) {
try {
systemReference.updateSyntax(reparser, true);
enveloped = true;
reparser.updateLocation(systemReference.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 (runsOnReference != null) {
runsOnReference.updateSyntax(reparser, false);
reparser.updateLocation(runsOnReference.getLocation());
}
if (systemReference != null) {
systemReference.updateSyntax(reparser, false);
reparser.updateLocation(systemReference.getLocation());
}
if (block != null) {
block.updateSyntax(reparser, false);
reparser.updateLocation(block.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_Timer method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
lastTimeChecked = null;
int result = 1;
final Location tempIdentifier = identifier.getLocation();
if (reparser.envelopsDamage(tempIdentifier) || reparser.isExtending(tempIdentifier)) {
reparser.extendDamagedRegion(tempIdentifier);
final IIdentifierReparser r = new IdentifierReparser(reparser);
result = r.parseAndSetNameChanged();
identifier = r.getIdentifier();
if (result != 0) {
throw new ReParseException(result);
}
if (dimensions != null) {
dimensions.updateSyntax(reparser, false);
}
if (defaultDuration != null) {
defaultDuration.updateSyntax(reparser, false);
reparser.updateLocation(defaultDuration.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
return;
}
throw new ReParseException();
}
reparser.updateLocation(identifier.getLocation());
if (dimensions != null) {
dimensions.updateSyntax(reparser, false);
}
if (defaultDuration != null) {
defaultDuration.updateSyntax(reparser, false);
reparser.updateLocation(defaultDuration.getLocation());
}
if (withAttributesPath != null) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
}
}
Aggregations