use of org.eclipse.titan.designer.AST.TTCN3.definitions.For_Loop_Definitions in project titan.EclipsePlug-ins by eclipse.
the class ReferenceFinder method detectSmallestScope.
/**
* Detect the smallest scope where the references should be searched
*
* @param assignment
* The assignment
* @return The detected scope
*/
private Scope detectSmallestScope(final Assignment assignment) {
Scope localScope = assignment.getMyScope();
final Module module = localScope.getModuleScope();
if (localScope instanceof StatementBlock) {
final StatementBlock statementBlock = (StatementBlock) localScope;
if (statementBlock.getMyDefinition() instanceof Def_Altstep) {
localScope = localScope.getParentScope();
}
if (statementBlock.hasEnclosingLoopOrAltguard()) {
localScope = localScope.getParentScope();
}
}
if (localScope instanceof NamedBridgeScope) {
localScope = localScope.getParentScope();
}
// control,function,testcase,altstep then it is global
if (localScope instanceof Assignments && localScope.getParentScope() == module) {
localScope = module;
} else // treat it as global definition
if (localScope instanceof ComponentTypeBody) {
// FIXME this still does not make them global, that is something completely different.
localScope = module;
} else // search for actual named parameters everywhere
if (localScope instanceof FormalParameterList || localScope instanceof RunsOnScope) {
localScope = module;
} else // For_Statement that must be searched
if (localScope instanceof For_Loop_Definitions) {
localScope = localScope.getParentScope();
}
return localScope;
}
Aggregations