Returns the closest enclosing type of the specified element.
496706
@Requires("element != null")
  public static TypeModel getTypeOf(ElementModel element) {
    return findEnclosingElement(element, TypeModel.class,
        ElementKind.CLASS, ElementKind.ENUM, ElementKind.INTERFACE);
  }
1172757
def _calculate_type_bound_at_step(match_step):
    """"""
    current_type_bounds = []

    if isinstance(match_step.root_block, QueryRoot):
        # The QueryRoot start class is a type bound.
        current_type_bounds.extend(match_step.root_block.start_class)

    if match_step.coerce_type_block is not None:
        # The CoerceType target class is also a type bound.
        current_type_bounds.extend(match_step.coerce_type_block.target_class)

    if current_type_bounds:
        # A type bound exists. Assert that there is exactly one bound, defined in precisely one way.
        return get_only_element_from_collection(current_type_bounds)
    else:
        # No type bound exists at this MATCH step.
        return None
662935
public static TypeMirror upperBound(Elements elements, TypeMirror type) {
    if (type.getKind() == TypeKind.WILDCARD) {
      WildcardType wildcard = (WildcardType) type;
      type = wildcard.getExtendsBound();
      if (type == null) {
        type = elements.getTypeElement(Object.class.getName()).asType();
      }
    }
    return type;
  }
4301
private TypeMirror getTypeFromDOMElement(Element element) {
    return DOMElementsUtil
        .getTypeForElementTag(element.getStartTag().getName())
        .map(Class::getCanonicalName)
        .map(elements::getTypeElement)
        .map(TypeElement::asType)
        .orElse(null);
  }
913852
function getRect(elem) {
  if (elem && !elem.nodeType) {
    elem = elem[0];
  }

  if (!elem || 1 !== elem.nodeType) {
    return false;
  }

  var bounds = elem.getBoundingClientRect();

  return {
    height: bounds.bottom - bounds.top,
    width: bounds.right - bounds.left,
    top: bounds.top,
    left: bounds.left
  };
}
435457
function findClosestLink( ele )    {
        while ( ele ) {
            // Look for the closest element with a nodeName of "a".
            // Note that we are checking if we have a valid nodeName
            // before attempting to access it. This is because the
            // node we get called with could have originated from within
            // an embedded SVG document where some symbol instance elements
            // don't have nodeName defined on them, or strings are of type
            // SVGAnimatedString.
            if ( ( typeof ele.nodeName === "string" ) && ele.nodeName.toLowerCase() === "a" ) {
                break;
            }
            ele = ele.parentNode;
        }
        return ele;
    }
830784
private static TypeElement getEnclosingType(Element element) {
    return element.accept(new SimpleElementVisitor6<TypeElement, Void>() {
      @Override protected TypeElement defaultAction(Element e, Void p) {
        return e.getEnclosingElement().accept(this, p);
      }

      @Override public TypeElement visitType(TypeElement e, Void p) {
        return e;
      }

      @Override public TypeElement visitPackage(PackageElement e, Void p) {
        throw new IllegalArgumentException();
      }
    }, null);
  }
954419
function closest(el, fn) {
                    return el && (fn(el) ? el : closest(el.parentNode, fn));
                }
1238447
function getClosestTodoElement(element) {

		var matchesSelector = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector;

		while (element) {
			if (matchesSelector.bind(element)('li')) {
				return element;
			} else {
				element = element.parentNode;
			}
		}
		return false;

	}
494660
function( range, start )
					{
						// Creates a collapsed range at the requested boundary.
						range = range.duplicate();
						range.collapse( start );

						// Gets the element that encloses the range entirely.
						var parent = range.parentElement(),
							doc = parent.ownerDocument;

						// Empty parent element, e.g. <i>^</i>
						if ( !parent.hasChildNodes() )
							return  { container : parent, offset : 0 };

						var siblings = parent.children,
							child,
							sibling,
							testRange = range.duplicate(),
							startIndex = 0,
							endIndex = siblings.length - 1,
							index = -1,
							position,
							distance;

						// Binary search over all element childs to test the range to see whether
						// range is right on the boundary of one element.
						while ( startIndex <= endIndex )
						{
							index = Math.floor( ( startIndex + endIndex ) / 2 );
							child = siblings[ index ];
							testRange.moveToElementText( child );
							position = testRange.compareEndPoints( 'StartToStart', range );

							if ( position > 0 )
								endIndex = index - 1;
							else if ( position < 0 )
								startIndex = index + 1;
							else
							{
								// IE9 report wrong measurement with compareEndPoints when range anchors between two BRs.
								// e.g. <p>text<br />^<br /></p> (#7433)
								if ( CKEDITOR.env.ie9Compat && child.tagName == 'BR' )
								{
									var bmId = 'cke_range_marker';
									range.execCommand( 'CreateBookmark', false, bmId );
									child = doc.getElementsByName( bmId )[ 0 ];
									var offset = getNodeIndex( child );
									parent.removeChild( child );
									return { container : parent, offset : offset };
								}
								else
									return { container : parent, offset : getNodeIndex( child ) };
							}
						}

						// All childs are text nodes,
						// or to the right hand of test range are all text nodes. (#6992)
						if ( index == -1 || index == siblings.length - 1 && position < 0 )
						{
							// Adapt test range to embrace the entire parent contents.
							testRange.moveToElementText( parent );
							testRange.setEndPoint( 'StartToStart', range );

							// IE report line break as CRLF with range.text but
							// only LF with textnode.nodeValue, normalize them to avoid
							// breaking character counting logic below. (#3949)
							distance = testRange.text.replace( /(\r\n|\r)/g, '\n' ).length;

							siblings = parent.childNodes;

							// Actual range anchor right beside test range at the boundary of text node.
							if ( !distance )
							{
								child = siblings[ siblings.length - 1 ];

								if ( child.nodeType == CKEDITOR.NODE_ELEMENT )
									return { container : parent, offset : siblings.length };
								else
									return { container : child, offset : child.nodeValue.length };
							}

							// Start the measuring until distance overflows, meanwhile count the text nodes.
							var i = siblings.length;
							while ( distance > 0 )
								distance -= siblings[ --i ].nodeValue.length;

							return  { container : siblings[ i ], offset : -distance };
						}
						// Test range was one offset beyond OR behind the anchored text node.
						else
						{
							// Adapt one side of test range to the actual range
							// for measuring the offset between them.
							testRange.collapse( position > 0 ? true : false );
							testRange.setEndPoint( position > 0 ? 'StartToStart' : 'EndToStart', range );

							// IE report line break as CRLF with range.text but
							// only LF with textnode.nodeValue, normalize them to avoid
							// breaking character counting logic below. (#3949)
							distance = testRange.text.replace( /(\r\n|\r)/g, '\n' ).length;

							// Actual range anchor right beside test range at the inner boundary of text node.
							if ( !distance )
								return { container : parent, offset : getNodeIndex( child ) + ( position > 0 ? 0 : 1 ) };

							// Start the measuring until distance overflows, meanwhile count the text nodes.
							while ( distance > 0 )
							{
								try
								{
									sibling = child[ position > 0 ? 'previousSibling' : 'nextSibling' ];
									distance -= sibling.nodeValue.length;
									child = sibling;
								}
								// Measurement in IE could be somtimes wrong because of <select> element. (#4611)
								catch( e )
								{
									return { container : parent, offset : getNodeIndex( child ) };
								}
							}

							return { container : child, offset : position > 0 ? -distance : child.nodeValue.length + distance };
						}
					}
336347
void visitEnclosingElement(ImageElement element,
      ImageElement key, int value)
     throws IOException {
    visitEnclosingElement(element, key, Integer.toString(value));
  }
1109754
function closestScrollableElement(element) {
  if (!element) {
    return getDocumentScrollingElement();
  }

  const position = getComputedStyle(element).getPropertyValue('position');
  const excludeStaticParents = position === 'absolute';

  const scrollableElement = closest(element, (parent) => {
    if (excludeStaticParents && isStaticallyPositioned(parent)) {
      return false;
    }
    return hasOverflow(parent);
  });

  if (position === 'fixed' || !scrollableElement) {
    return getDocumentScrollingElement();
  } else {
    return scrollableElement;
  }
}
278656
function() {
					var range = self.getRanges()[ 0 ].clone(),
						enclosed, selected;

					// Check first any enclosed element, e.g. <ul>[<li><a href="#">item</a></li>]</ul>
					for ( var i = 2; i && !( ( enclosed = range.getEnclosedNode() ) && ( enclosed.type == CKEDITOR.NODE_ELEMENT ) && styleObjectElements[ enclosed.getName() ] && ( selected = enclosed ) ); i-- ) {
						// Then check any deep wrapped element, e.g. [<b><i><img /></i></b>]
						range.shrink( CKEDITOR.SHRINK_ELEMENT );
					}

					return selected && selected.$;
				}
205505
function getNearestTypeElement(element) {
		var $element = $(element),
			found = $element.is('[data-type]');

		while (!found && $element.length && !$element.is(MODULE_SELECTOR)) {
			$element = $element.parent();
			found = $element.is('[data-type]');
		}

		return found ? $element[0] : null;
	}
1190946
public Annotation getEnclosingSpan() {
    if (DictTerm_Type.featOkTst && ((DictTerm_Type)jcasType).casFeat_enclosingSpan == null)
      jcasType.jcas.throwFeatMissing("enclosingSpan", "org.apache.uima.conceptMapper.DictTerm");
    return (Annotation)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((DictTerm_Type)jcasType).casFeatCode_enclosingSpan)));}
170165
def closest_length(refs, pred):
    '''
    
    '''
    smallest_diff = float('inf')
    closest_length = float('inf')
    for ref in refs:
        diff = abs(len(ref) - len(pred))
        if diff < smallest_diff or (diff == smallest_diff and len(ref) < closest_length):
            smallest_diff = diff
            closest_length = len(ref)
    return closest_length
282833
private static double findPrototype(DistanceQuery<?> dq, DBIDs cx, DBIDs cy, DBIDVar prototype, double minMaxDist) {
    for(DBIDIter i = cx.iter(); i.valid(); i.advance()) {
      // Maximum distance of i to all elements in cy
      double maxDist = findMax(dq, i, cy, 0., minMaxDist);
      if(maxDist >= minMaxDist) {
        // We already have an at least equally good candidate.
        continue;
      }
      // Maximum distance of i to all elements in cx
      maxDist = findMax(dq, i, cx, maxDist, minMaxDist);

      // New best solution?
      if(maxDist < minMaxDist) {
        minMaxDist = maxDist;
        prototype.set(i);
      }
    }
    return minMaxDist;
  }