use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class AltGuards method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
boolean enveloped = false;
int nofDamaged = 0;
int leftBoundary = location.getOffset();
int rightBoundary = location.getEndOffset();
final int damageOffset = reparser.getDamageStart();
for (int i = 0, size = altGuards.size(); i < size && !enveloped; i++) {
final AltGuard altGuard = altGuards.get(i);
final Location temporalLocation = altGuard.getLocation();
if (reparser.envelopsDamage(temporalLocation)) {
enveloped = true;
leftBoundary = temporalLocation.getOffset();
rightBoundary = temporalLocation.getEndOffset();
} else if (reparser.isDamaged(temporalLocation)) {
nofDamaged++;
} else {
if (temporalLocation.getEndOffset() < damageOffset && temporalLocation.getEndOffset() > leftBoundary) {
leftBoundary = temporalLocation.getEndOffset();
}
if (temporalLocation.getOffset() >= damageOffset && temporalLocation.getOffset() < rightBoundary) {
rightBoundary = temporalLocation.getOffset();
}
}
}
if (nofDamaged != 0) {
throw new ReParseException();
}
for (Iterator<AltGuard> iterator = altGuards.iterator(); iterator.hasNext(); ) {
final AltGuard altGuard = iterator.next();
final Location temporalLocation = altGuard.getLocation();
if (reparser.isAffectedAppended(temporalLocation)) {
altGuard.updateSyntax(reparser, enveloped && reparser.envelopsDamage(temporalLocation));
reparser.updateLocation(altGuard.getLocation());
}
}
return;
}
for (int i = 0, size = altGuards.size(); i < size; i++) {
final AltGuard guard = altGuards.get(i);
guard.updateSyntax(reparser, false);
reparser.updateLocation(guard.getLocation());
}
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class AssignmentList_Parameter_Redirect method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final Signature_Type signature, final boolean isOut) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
final SignatureFormalParameterList parameterList = signature.getParameterList();
if (parameterList.getNofParameters() == 0) {
getLocation().reportSemanticError(MessageFormat.format(SIGNATUREWITHOUTPARAMETERS, signature.getTypename()));
checkErroneous(timestamp);
return;
}
boolean errorFlag = false;
final HashMap<String, Parameter_Assignment> parameterMap = new HashMap<String, Parameter_Assignment>();
for (int i = 0, size = assignments.getNofParameterAssignments(); i < size; i++) {
final Parameter_Assignment assignment = assignments.getParameterAssignmentByIndex(i);
final String name = assignment.getIdentifier().getName();
if (parameterMap.containsKey(name)) {
assignment.getLocation().reportSemanticError(MessageFormat.format("Duplicate redirect for parameter `{0}''", assignment.getIdentifier().getDisplayName()));
final Location otherLocation = parameterMap.get(name).getLocation();
otherLocation.reportSemanticWarning(MessageFormat.format("A variable entry for parameter `{0}'' is already given here", assignment.getIdentifier().getDisplayName()));
errorFlag = true;
} else {
parameterMap.put(name, assignment);
}
if (parameterList.hasParameterWithName(name)) {
final SignatureFormalParameter parameterTemplate = parameterList.getParameterByName(name);
if (isOut) {
if (SignatureFormalParameter.ParamaterDirection.PARAM_IN == parameterTemplate.getDirection()) {
final String message = MessageFormat.format("Parameter `{0}'' of signature `{1}'' has `in'' direction", assignment.getIdentifier().getDisplayName(), signature.getTypename());
assignment.getLocation().reportSemanticError(message);
errorFlag = true;
}
} else {
if (SignatureFormalParameter.ParamaterDirection.PARAM_OUT == parameterTemplate.getDirection()) {
final String message = MessageFormat.format("Parameter `{0}'' of signature `{1}'' has `out'' direction", assignment.getIdentifier().getDisplayName(), signature.getTypename());
assignment.getLocation().reportSemanticError(message);
errorFlag = true;
}
}
checkVariableReference(timestamp, assignment.getReference(), parameterTemplate.getType());
} else {
assignment.getLocation().reportSemanticError(MessageFormat.format("Signature `{0}'' does not have parameter named `{1}''", signature.getTypename(), assignment.getIdentifier().getDisplayName()));
errorFlag = true;
checkVariableReference(timestamp, assignment.getReference(), null);
}
}
if (!errorFlag) {
// converting the AssignmentList to VariableList
final Variable_Entries variableEntries = new Variable_Entries();
final int upperLimit = isOut ? parameterList.getNofOutParameters() : parameterList.getNofInParameters();
for (int i = 0; i < upperLimit; i++) {
final SignatureFormalParameter parameter = isOut ? parameterList.getOutParameterByIndex(i) : parameterList.getInParameterByIndex(i);
final String name = parameter.getIdentifier().getName();
if (parameterMap.containsKey(name)) {
variableEntries.add(new Variable_Entry(parameterMap.get(name).getReference()));
} else {
variableEntries.add(new Variable_Entry());
}
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class Def_Const 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 (value != null) {
if (enveloped) {
value.updateSyntax(reparser, false);
reparser.updateLocation(value.getLocation());
} else if (reparser.envelopsDamage(value.getLocation())) {
reparser.extendDamagedRegion(value.getLocation().getOffset(), value.getLocation().getEndOffset());
final int result = reparse(reparser);
if (result == 0) {
enveloped = true;
value.setFullNameParent(this);
value.setMyScope(getMyScope());
} else {
throw new ReParseException();
}
}
}
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 (value != null) {
value.updateSyntax(reparser, false);
reparser.updateLocation(value.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 ParserMarkerSupport method createOnTheFlySyntacticMarker.
public static void createOnTheFlySyntacticMarker(final IFile file, final SyntacticErrorStorage errorStorage, final int severity, final Location relativeLocation) {
if (!file.isAccessible()) {
return;
}
int lineNumber = errorStorage.lineNumber;
int charStart = errorStorage.charStart;
int charEnd = errorStorage.charEnd;
String message = errorStorage.message;
Location location = new Location(file, relativeLocation.getLine() + lineNumber - 1, relativeLocation.getOffset() + charStart, relativeLocation.getOffset() + charEnd);
location.reportSingularExternalProblem(message, severity, GeneralConstants.ONTHEFLY_SYNTACTIC_MARKER);
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class ParserMarkerSupport method createOnTheFlyMixedMarker.
public static void createOnTheFlyMixedMarker(final IFile file, final SyntacticErrorStorage errorStorage, final int severity, final Location relativeLocation) {
if (!file.isAccessible()) {
return;
}
int lineNumber = errorStorage.lineNumber;
int charStart = errorStorage.charStart;
int charEnd = errorStorage.charEnd;
String message = errorStorage.message;
Location location = new Location(file, relativeLocation.getLine() + lineNumber - 1, relativeLocation.getOffset() + charStart, relativeLocation.getOffset() + charEnd);
location.reportSingularExternalProblem(message, severity, GeneralConstants.ONTHEFLY_MIXED_MARKER);
}
Aggregations