RutaStream stream, InferenceCrowd crowd) {
Type contextType = type.getType(element.getParent());
stream.moveToFirst();
List<AnnotationFS> visibleContexts = new ArrayList<AnnotationFS>();
while (stream.isValid()) {
RutaBasic each = (RutaBasic) stream.get();
if (each.beginsWith(contextType)) {
visibleContexts.addAll(each.getBeginAnchors(contextType));
}
stream.moveToNext();
}
List<AnnotationFS> overlappingContexts = new ArrayList<AnnotationFS>();
for (AnnotationFS eachContext : visibleContexts) {
if (eachContext.getBegin() <= annotation.getBegin()
&& eachContext.getEnd() >= annotation.getEnd()) {
overlappingContexts.add(eachContext);
}
}
boolean result = false;
for (AnnotationFS eachContext : overlappingContexts) {
int index = 0;
int counter = 0;
List<RutaBasic> basicsInWindow = stream.getBasicsInWindow(eachContext);
for (RutaBasic eachBasic : basicsInWindow) {
Set<AnnotationFS> beginAnchors = eachBasic.getBeginAnchors(annotation.getType());
if (beginAnchors != null) {
for (AnnotationFS each : beginAnchors) {
counter++;
if (each.getBegin() == annotation.getBegin()
&& each.getEnd() == annotation.getEnd()
&& (each.getType().equals(annotation.getType()) || stream.getCas()
.getTypeSystem().subsumes(annotation.getType(), each.getType()))) {
index = counter;
}
}
}
}