use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.
the class TTCN3Template method updateSyntax.
/**
* Handles the incremental parsing of this template.
*
* @param reparser
* the parser doing the incremental parsing.
* @param isDamaged
* true if the location contains the damaged area, false
* if only its' location needs to be updated.
*/
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
throw new ReParseException();
}
if (lengthRestriction != null) {
lengthRestriction.updateSyntax(reparser, false);
reparser.updateLocation(lengthRestriction.getLocation());
}
if (baseTemplate instanceof IIncrementallyUpdateable) {
((IIncrementallyUpdateable) baseTemplate).updateSyntax(reparser, false);
reparser.updateLocation(baseTemplate.getLocation());
} else if (baseTemplate != null) {
throw new ReParseException();
}
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException 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.ReParseException in project titan.EclipsePlug-ins by eclipse.
the class CompFieldMap method updateSyntax.
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
lastCompilationTimeStamp = null;
if (doubleComponents != null) {
fields.addAll(doubleComponents);
doubleComponents = null;
lastUniquenessCheck = 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 = fields.size(); i < size && !enveloped; i++) {
final CompField field = fields.get(i);
final Location tempLocation = field.getLocation();
// move offset to commentLocation
if (field.getCommentLocation() != null) {
tempLocation.setOffset(field.getCommentLocation().getOffset());
}
if (reparser.envelopsDamage(tempLocation)) {
enveloped = true;
leftBoundary = tempLocation.getOffset();
rightBoundary = tempLocation.getEndOffset();
} else if (reparser.isDamaged(tempLocation)) {
nofDamaged++;
if (reparser.getDamageStart() == tempLocation.getEndOffset()) {
lastAppendableBeforeChange = field;
} else if (reparser.getDamageEnd() == tempLocation.getOffset()) {
lastPrependableBeforeChange = field;
}
} else {
if (tempLocation.getEndOffset() < damageOffset && tempLocation.getEndOffset() > leftBoundary) {
leftBoundary = tempLocation.getEndOffset();
lastAppendableBeforeChange = field;
}
if (tempLocation.getOffset() >= damageOffset && tempLocation.getOffset() < rightBoundary) {
rightBoundary = tempLocation.getOffset();
lastPrependableBeforeChange = field;
}
}
}
// extend the reparser to the calculated values if the damage was not enveloped
if (!enveloped) {
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) {
removeStuffInRange(reparser);
}
for (int i = 0; i < fields.size(); i++) {
final CompField field = fields.get(i);
final Location tempLocation = field.getLocation();
if (reparser.isAffectedAppended(tempLocation)) {
try {
field.updateSyntax(reparser, enveloped && reparser.envelopsDamage(tempLocation));
reparser.updateLocation(field.getLocation());
} catch (ReParseException e) {
if (e.getDepth() == 1) {
enveloped = false;
fields.remove(i);
i--;
reparser.extendDamagedRegion(tempLocation);
} else {
e.decreaseDepth();
throw e;
}
}
}
}
if (!enveloped) {
reparser.extendDamagedRegion(leftBoundary, rightBoundary);
int result = reparse(reparser);
if (result == 0) {
return;
}
throw new ReParseException(Math.max(--result, 0));
}
return;
}
for (int i = 0, size = fields.size(); i < size; i++) {
final CompField field = fields.get(i);
field.updateSyntax(reparser, false);
reparser.updateLocation(field.getLocation());
}
if (doubleComponents != null) {
for (int i = 0, size = doubleComponents.size(); i < size; i++) {
final CompField field = doubleComponents.get(i);
field.updateSyntax(reparser, false);
reparser.updateLocation(field.getLocation());
}
}
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.
the class ProjectSourceSyntacticAnalyzer method updateSyntax.
/**
* The entry point of incremental parsing.
* <p>
* Handles the data storages, calls the module level incremental parser
* on the file, and if everything fails does a full parsing to correct
* possibly invalid states.
*
* @param file
* the edited file
* @param reparser
* the parser doing the incremental parsing.
*/
public void updateSyntax(final IFile file, final TTCN3ReparseUpdater reparser) {
if (uptodateFiles.containsKey(file)) {
Module module = sourceParser.getSemanticAnalyzer().getModulebyFile(file);
sourceParser.getSemanticAnalyzer().reportSemanticOutdating(file);
if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
try {
reparser.setUnsupportedConstructs(unsupportedConstructMap);
try {
((TTCN3Module) module).updateSyntax(reparser, sourceParser);
reparser.updateLocation(((TTCN3Module) module).getLocation());
} catch (ReParseException e) {
syntacticallyOutdated = true;
uptodateFiles.remove(file);
sourceParser.getSemanticAnalyzer().reportSemanticOutdating(file);
String oldModuleName = fileMap.get(file);
if (oldModuleName != null) {
sourceParser.getSemanticAnalyzer().removeModule(oldModuleName);
fileMap.remove(file);
}
unsupportedConstructMap.remove(file);
reparser.maxDamage();
ITtcn3FileReparser r = new Ttcn3FileReparser(reparser, file, sourceParser, fileMap, uptodateFiles, highlySyntaxErroneousFiles);
syntacticallyOutdated = r.parse();
}
MarkerHandler.removeAllOnTheFlySyntacticMarkedMarkers(file);
// update the position of the markers located after the damaged region
MarkerHandler.updateMarkers(file, reparser.getFirstLine(), reparser.getLineShift(), reparser.getDamageEnd(), reparser.getShift());
} catch (Exception e) {
// This catch is extremely important, as
// it is supposed to protect the project
// parser, from whatever might go wrong
// inside the analysis.
ErrorReporter.logExceptionStackTrace(e);
}
} else {
reportOutdating(file);
}
} else if (highlySyntaxErroneousFiles.contains(file)) {
reportOutdating(file);
} else {
MarkerHandler.markAllMarkersForRemoval(file);
TemporalParseData temp = fileBasedTTCN3Analysis(file);
postFileBasedGeneralAnalysis(temp);
}
reparser.reportSyntaxErrors();
}
use of org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException in project titan.EclipsePlug-ins by eclipse.
the class Values method updateSyntax.
/**
* Handles the incremental parsing of this value list.
*
* @param reparser the parser doing the incremental parsing.
* @param isDamaged true if the location contains the damaged area, false if only its' location needs to be updated.
*/
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
throw new ReParseException();
}
if (isIndexed) {
for (int i = 0, size = indexedValues.size(); i < size; i++) {
final IndexedValue indexedValue = indexedValues.get(i);
indexedValue.updateSyntax(reparser, false);
reparser.updateLocation(indexedValue.getLocation());
}
} else {
for (int i = 0, size = values.size(); i < size; i++) {
final IValue value = values.get(i);
if (value instanceof IIncrementallyUpdateable) {
((IIncrementallyUpdateable) value).updateSyntax(reparser, false);
reparser.updateLocation(value.getLocation());
} else {
throw new ReParseException();
}
}
}
}
Aggregations