use of org.eclipse.titan.designer.AST.Assignments in project titan.EclipsePlug-ins by eclipse.
the class ImportModule method addDeclaration.
/**
* Adds the imported module or definitions contained in it, to the list
* declaration proposals.
*
* @param declarationCollector
* the declaration collector.
* @param targetModuleId
* the identifier of the module where the declaration
* should be inserted into.
*/
@Override
public /**
* {@inheritDoc}
*/
void addDeclaration(final DeclarationCollector declarationCollector, final Identifier targetModuleId) {
final Module savedReferredModule = referredModule;
if (savedReferredModule != null) {
final Assignments assignments = savedReferredModule.getAssignments();
for (int i = 0; i < assignments.getNofAssignments(); i++) {
final Assignment temporalAssignment = assignments.getAssignmentByIndex(i);
if (savedReferredModule.isVisible(CompilationTimeStamp.getBaseTimestamp(), targetModuleId, temporalAssignment)) {
temporalAssignment.addDeclaration(declarationCollector, 0);
}
}
final Identifier moduleId = declarationCollector.getReference().getModuleIdentifier();
final List<ISubReference> subrefs = declarationCollector.getReference().getSubreferences();
if (moduleId == null && subrefs.size() == 1 && identifier.getName().equals(subrefs.get(0).getId().getName())) {
declarationCollector.addDeclaration(savedReferredModule.getIdentifier().getDisplayName(), savedReferredModule.getIdentifier().getLocation(), (Scope) null);
}
}
}
use of org.eclipse.titan.designer.AST.Assignments in project titan.EclipsePlug-ins by eclipse.
the class ASN1Assignments method checkUniqueness.
/**
* Checks the uniqueness of the definitions, and also builds a hashmap
* of them to speed up further searches.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
*/
public void checkUniqueness(final CompilationTimeStamp timestamp) {
if (null != lastUniqueNessCheckTimeStamp && !lastUniqueNessCheckTimeStamp.isLess(timestamp)) {
return;
}
if (null == assignmentMap) {
assignmentMap = new HashMap<String, ASN1Assignment>(assignments.size());
}
lastUniqueNessCheckTimeStamp = timestamp;
dynamic_assignments.clear();
assignmentMap.clear();
final Assignments specialAssignments = SpecialASN1Module.getSpecialModule().getAssignments();
for (ASN1Assignment assignment : assignments) {
final Identifier identifier = assignment.getIdentifier();
final String assignmentName = identifier.getName();
if (specialAssignments.hasAssignmentWithId(timestamp, identifier)) {
final Location selfLocation = assignment.getIdentifier().getLocation();
selfLocation.reportSemanticError(MessageFormat.format(RESERVEDIDENTIFIER, identifier.getDisplayName()));
} else if (assignmentMap.containsKey(assignmentName)) {
final Location otherLocation = assignmentMap.get(assignmentName).getIdentifier().getLocation();
otherLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
final Location selfLocation = assignment.getIdentifier().getLocation();
selfLocation.reportSemanticError(MessageFormat.format(DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
assignmentMap.put(assignmentName, assignment);
}
}
}
use of org.eclipse.titan.designer.AST.Assignments in project titan.EclipsePlug-ins by eclipse.
the class ASN1Assignments method addDynamicAssignment.
/**
* Adds a dynamic assignment to the list of assignments.
* <p>
* Only assignments which were created dynamically during the semantic
* check shall be added with this function. The scope of the newly added
* assignment is set to this scope scope here.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param assignment
* the assignment to be added
*/
public void addDynamicAssignment(final CompilationTimeStamp timestamp, final ASN1Assignment assignment) {
if (null == assignment || null == assignment.getIdentifier()) {
return;
}
if (null == lastUniqueNessCheckTimeStamp) {
checkUniqueness(timestamp);
}
dynamic_assignments.add(assignment);
assignment.setMyScope(this);
final Identifier identifier = assignment.getIdentifier();
final String assignmentName = identifier.getName();
final Assignments specialAssignments = SpecialASN1Module.getSpecialModule().getAssignments();
if (specialAssignments.hasAssignmentWithId(timestamp, identifier)) {
final Location tempLocation = assignment.getIdentifier().getLocation();
tempLocation.reportSemanticError(MessageFormat.format(RESERVEDIDENTIFIER, identifier.getDisplayName()));
} else if (assignmentMap.containsKey(assignmentName)) {
final Location otherLocation = assignmentMap.get(assignmentName).getIdentifier().getLocation();
otherLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
final Location selfLocation = assignment.getIdentifier().getLocation();
selfLocation.reportSemanticError(MessageFormat.format(DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
assignmentMap.put(assignmentName, assignment);
}
}
use of org.eclipse.titan.designer.AST.Assignments in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method getAssignmentsFrom.
public List<AssignmentHandler> getAssignmentsFrom(final Module module) {
final List<AssignmentHandler> assignmentHandlers = new ArrayList<AssignmentHandler>();
final Assignments assignments = module.getAssignments();
for (int d = 0; d < assignments.getNofAssignments(); ++d) {
final Assignment assignment = assignments.getAssignmentByIndex(d);
final AssignmentHandler assignmentHandler = AssignmentHandlerFactory.getDefinitionHandler(assignment);
if (assignment instanceof Undefined_Assignment) {
final ASN1Assignment realAssignment = ((Undefined_Assignment) assignment).getRealAssignment(CompilationTimeStamp.getBaseTimestamp());
if (realAssignment != null) {
realAssignment.accept(assignmentHandler);
} else {
// TODO: re-fine this branch
assignment.accept(assignmentHandler);
}
} else {
assignment.accept(assignmentHandler);
}
assignmentHandlers.add(assignmentHandler);
}
return assignmentHandlers;
}
use of org.eclipse.titan.designer.AST.Assignments in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method processStartModules.
public void processStartModules(final List<Module> startModules, final Map<Module, List<AssignmentHandler>> moduleAndBrokenAssignments) {
for (Module startModule : startModules) {
if (isTooSlow()) {
return;
}
if (startModule instanceof TTCN3Module && startModule.getLastCompilationTimeStamp() != null && !startModule.isCheckRoot()) {
// definition name has not changed but module semantically has not been checked:
final Assignments startAssignments = startModule.getAssignments();
final List<AssignmentHandler> brokens = new ArrayList<AssignmentHandler>();
final List<AssignmentHandler> notBrokens = new ArrayList<AssignmentHandler>();
for (Assignment assignment : startAssignments) {
MarkerHandler.markAllSemanticMarkersForRemoval(assignment);
}
for (int d = 0; d < startAssignments.getNofAssignments(); ++d) {
final Assignment startAssignment = startAssignments.getAssignmentByIndex(d);
final AssignmentHandler assignmentHandler = AssignmentHandlerFactory.getDefinitionHandler(startAssignment);
startAssignment.check(timestamp);
startAssignment.accept(assignmentHandler);
if (startAssignment.isCheckRoot()) {
assignmentHandler.setIsInfected(true);
startAssignment.notCheckRoot();
assignmentHandler.addReason("Definition's infected, because of incremental parsing.");
brokens.add(assignmentHandler);
} else if (assignmentHandler.getIsInfected()) {
assignmentHandler.addReason("Definition contains an infected reference.");
brokens.add(assignmentHandler);
} else {
notBrokens.add(assignmentHandler);
}
}
if (!brokens.isEmpty()) {
checkLocalAssignments(brokens, notBrokens);
if (moduleAndBrokenAssignments.containsKey(startModule)) {
moduleAndBrokenAssignments.get(startModule).addAll(brokens);
} else {
moduleAndBrokenAssignments.put(startModule, brokens);
}
}
} else {
if (startModule.getLastCompilationTimeStamp() == null) {
// The markers have been marked for removal only for ASN1 modules
startModule.check(timestamp);
}
// puts additional markers!
final List<AssignmentHandler> startAssignments = getAssignmentsFrom(startModule);
for (AssignmentHandler assignmentHandler : startAssignments) {
assignmentHandler.initStartParts();
assignmentHandler.assignment.notCheckRoot();
assignmentHandler.addReason("Parent module's CompilationTimeStamp is null.");
}
if (moduleAndBrokenAssignments.containsKey(startModule)) {
moduleAndBrokenAssignments.get(startModule).addAll(startAssignments);
} else {
moduleAndBrokenAssignments.put(startModule, startAssignments);
}
}
startModule.notCheckRoot();
}
}
Aggregations