use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class For_Loop_Definitions method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastCompilationTimeStamp != null && !lastCompilationTimeStamp.isLess(timestamp)) {
return;
}
lastCompilationTimeStamp = timestamp;
lastUniquenessCheckTimeStamp = timestamp;
if (definitionMap == null) {
definitionMap = new HashMap<String, Definition>(definitions.size());
}
definitionMap.clear();
String definitionName;
Definition definition;
Identifier identifier;
for (int i = 0, size = definitions.size(); i < size; i++) {
definition = definitions.get(i);
identifier = definition.getIdentifier();
definitionName = identifier.getName();
if (definitionMap.containsKey(definitionName)) {
final Location otherLocation = definitionMap.get(definitionName).getIdentifier().getLocation();
otherLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
definitionMap.put(definitionName, definition);
if (parentScope != null && definition.getLocation() != null) {
if (parentScope.hasAssignmentWithId(timestamp, identifier)) {
definition.getLocation().reportSemanticError(MessageFormat.format(StatementBlock.HIDINGSCOPEELEMENT, identifier.getDisplayName()));
final List<ISubReference> subReferences = new ArrayList<ISubReference>();
subReferences.add(new FieldSubReference(identifier));
final Reference reference = new Reference(null, subReferences);
final Assignment assignment = parentScope.getAssBySRef(timestamp, reference);
if (assignment != null && assignment.getLocation() != null) {
assignment.getLocation().reportSingularSemanticError(MessageFormat.format(StatementBlock.HIDDENSCOPEELEMENT, identifier.getDisplayName()));
}
} else if (parentScope.isValidModuleId(identifier)) {
definition.getLocation().reportSemanticWarning(MessageFormat.format(StatementBlock.HIDINGMODULEIDENTIFIER, identifier.getDisplayName()));
}
}
}
definition.check(timestamp);
}
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class FriendModule method updateSyntax.
/**
* Handles the incremental parsing of this friend module declaration.
*
* @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) {
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.parse();
identifier = r.getIdentifier();
// damage handled
if (result == 0) {
enveloped = true;
} else {
throw new ReParseException(result);
}
}
if (withAttributesPath != null) {
if (enveloped) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
} else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
reparser.extendDamagedRegion(withAttributesPath.getLocation());
result = reparse(reparser);
}
}
if (result != 0) {
throw new ReParseException();
}
return;
}
reparser.updateLocation(identifier.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 AssignmentList_Parameter_Redirect method checkErroneous.
@Override
public /**
* {@inheritDoc}
*/
void checkErroneous(final CompilationTimeStamp timestamp) {
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()));
} else {
parameterMap.put(name, assignment);
}
checkVariableReference(timestamp, assignment.getReference(), null);
}
}
use of org.eclipse.titan.designer.AST.Location in project titan.EclipsePlug-ins by eclipse.
the class ImportModule method updateSyntax.
/**
* Handles the incremental parsing of this module importation.
*
* @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) {
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.parse();
identifier = r.getIdentifier();
// damage handled
if (result == 0) {
enveloped = true;
} else {
throw new ReParseException(result);
}
}
if (withAttributesPath != null) {
if (enveloped) {
withAttributesPath.updateSyntax(reparser, false);
reparser.updateLocation(withAttributesPath.getLocation());
} else if (reparser.envelopsDamage(withAttributesPath.getLocation())) {
reparser.extendDamagedRegion(withAttributesPath.getLocation());
final int result = reparse(reparser);
if (result != 0) {
throw new ReParseException();
}
enveloped = true;
}
}
if (!enveloped) {
throw new ReParseException(1);
}
return;
}
reparser.updateLocation(identifier.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 TTCN3Module method getAssBySRef.
@Override
public /**
* {@inheritDoc}
*/
Assignment getAssBySRef(final CompilationTimeStamp timestamp, final Reference reference, final IReferenceChain refChain) {
// if a moduleId is present, that import (or the actual module)
// must be searched
final Identifier moduleId = reference.getModuleIdentifier();
final Location referenceLocation = reference.getLocation();
final Identifier id = reference.getId();
if (id == null) {
return null;
}
Assignment temporalAssignment = null;
if (moduleId == null) {
// no module name is given in the reference
if ("anytype".equals(id.getTtcnName())) {
return anytypeDefinition;
}
Assignment tempResult = null;
for (final ImportModule impMod : importedModules) {
if (impMod.getReferredModule() != null) {
final ModuleImportationChain referenceChain = new ModuleImportationChain(ModuleImportationChain.CIRCULARREFERENCE, false);
tempResult = impMod.importAssignment(timestamp, referenceChain, identifier, reference, new ArrayList<ModuleImportation>());
if (tempResult != null && !tempResult.getMyScope().getModuleScope().isVisible(timestamp, this.getIdentifier(), tempResult)) {
tempResult = null;
}
if (tempResult != null) {
if (temporalAssignment == null) {
temporalAssignment = tempResult;
} else if (temporalAssignment != tempResult) {
reference.getLocation().reportSemanticError("It is not possible to resolve this reference unambigously, as it can be resolved to `" + temporalAssignment.getFullName() + "' and to `" + tempResult.getFullName() + "'");
return null;
}
}
}
}
if (temporalAssignment != null) {
return temporalAssignment;
}
referenceLocation.reportSemanticError(MessageFormat.format(MISSINGREFERENCE, id.getDisplayName(), identifier.getDisplayName()));
missingReferences.add(reference);
} else if (moduleId.getName().equals(name)) {
// the reference points to the own module
if ("anytype".equals(id.getTtcnName())) {
return anytypeDefinition;
}
temporalAssignment = definitions.getLocalAssignmentByID(timestamp, id);
if (temporalAssignment == null) {
referenceLocation.reportSemanticError(MessageFormat.format(MISSINGREFERENCE, id.getDisplayName(), identifier.getDisplayName()));
}
} else {
// the reference points to another module
for (final ImportModule impMod : importedModules) {
if (moduleId.getName().equals(impMod.getName())) {
if (impMod.getReferredModule() == null) {
return temporalAssignment;
}
final ModuleImportationChain referenceChain = new ModuleImportationChain(ModuleImportationChain.CIRCULARREFERENCE, false);
temporalAssignment = impMod.importAssignment(timestamp, referenceChain, identifier, reference, new ArrayList<ModuleImportation>());
if (!impMod.getReferredModule().isVisible(timestamp, this.getIdentifier(), temporalAssignment)) {
temporalAssignment = null;
}
if (temporalAssignment == null) {
referenceLocation.reportSemanticError(MessageFormat.format(MISSINGREFERENCE, id.getDisplayName(), impMod.getIdentifier().getDisplayName()));
}
return temporalAssignment;
}
}
referenceLocation.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTMISSINGIMPORTEDMODULE, GeneralConstants.WARNING, null), MessageFormat.format(ImportModule.MISSINGMODULE, moduleId.getDisplayName()));
missingReferences.add(reference);
}
return temporalAssignment;
}
Aggregations