Handle scalar/repeater/pointer/anchor
776713
def handle_s_r_p_a(tokens, options)
      anchor_span = get_anchor(tokens[3..tokens.size - 1], options)
      handle_srp(tokens, anchor_span, options)
    end
269936
function queueHostBindingForCheck(dirIndex) {
    // Must subtract the header offset because hostBindings functions are generated with
    // instructions that expect element indices that are NOT adjusted (e.g. elementProperty).
    ngDevMode &&
        assertEqual(firstTemplatePass, true, 'Should only be called in first template pass.');
    (tView.hostBindings || (tView.hostBindings = [])).push(dirIndex, viewData.length - 1 - HEADER_OFFSET);
}
834263
def handle_rdn_rmn_od(tokens, options)
      month = tokens[1].get_tag(RepeaterMonthName)
      day = tokens[2].get_tag(OrdinalDay).type
      time_tokens = tokens.last(tokens.size - 3)
      year = self.now.year

      return if month_overflow?(year, month.index, day)

      begin
        if time_tokens.empty?
          start_time = Chronic.time_class.local(year, month.index, day)
          end_time = time_with_rollover(year, month.index, day + 1)
          Span.new(start_time, end_time)
        else
          day_start = Chronic.time_class.local(year, month.index, day)
          day_or_time(day_start, time_tokens, options)
        end
      rescue ArgumentError
        nil
      end
    end
746576
private String computeUri(String target, String query, String anchor) {

        StringBuffer uri = new StringBuffer(64);
        uri.append(target);
        if (query != null) {
            uri.append('?');
            uri.append(query);
        }
        if (anchor != null) {
            uri.append('#');
            uri.append(anchor);
        }
        return uri.toString();

    }
898400
function(scalar)
	{
		scalar = this.trim(scalar);
		
		var raw = null;
		var cast = null;

		if (	( 'null' == scalar.toLowerCase() ) ||
				( '' == scalar ) ||
				( '~' == scalar ) )
			return null;
		if ( (scalar+'').indexOf('!str ') == 0 )
			return (''+scalar).substring(5);
		if ( (scalar+'').indexOf('! ') == 0 )
			return parseInt(this.parseScalar((scalar+'').substr(2)));
		if ( /^\d+$/.test(scalar) )
		{
			raw = scalar;
			cast = parseInt(scalar);
			return '0' == scalar.charAt(0) ? this.octdec(scalar) : (( ''+raw == ''+cast ) ? cast : raw);
		}
		if ( 'true' == (scalar+'').toLowerCase() )
			return true;
		if ( 'false' == (scalar+'').toLowerCase() )
			return false;
		if ( this.isNumeric(scalar) )
			return '0x' == (scalar+'').substr(0, 2) ? this.hexdec(scalar) : parseFloat(scalar);
		if ( scalar.toLowerCase() == '.inf' )
			return Infinity;
		if ( scalar.toLowerCase() == '.nan' )
			return NaN;
		if ( scalar.toLowerCase() == '-.inf' )
			return -Infinity;
		if ( /^(-|\+)?[0-9,]+(\.[0-9]+)?$/.test(scalar) )
			return parseFloat(scalar.split(',').join(''));
		if ( this.getTimestampRegex().test(scalar) )
			return new Date(this.strtotime(scalar));
		//else
			return ''+scalar;
	}
170182
private static function resolveByDotNotation($dots, $scalar = false)
    {
        # Explode the $def string to array by "."
        $exploded = explode('.', $dots);
        # Initial pointer to array is the private array variable
        $arrPointer = static::$store;

        # Each subsequent dot-value
        foreach ($exploded as $explode) {
            # The value if set, so goto new array pointer
            if ( isset($arrPointer[$explode]) ) {
                $arrPointer = $arrPointer[$explode];
                # Not found the value by dot-notation at given loop run so return null
            } else {
                return null;
            }

            # Finished iterating the array and the value array pointer is pointing to is not another array (except you want a non scalar value)...
            if ( end($exploded) == $explode && ($scalar === false || !is_array($arrPointer)) ) {
                return $arrPointer;
            }
        }
    }
1211644
private void handleRenderRedirect(final PrintWriter writer) {
		UIContext uic = UIContextHolder.getCurrent();
		// Redirect user to error page
		LOG.warn("User will be redirected to " + redirectUrl);

		// Setup response with redirect
		getResponse().setContentType(WebUtilities.CONTENT_TYPE_XML);
		writer.write(XMLUtil.getXMLDeclarationWithThemeXslt(uic));

		writer.print("<ui:ajaxresponse ");
		writer.print(XMLUtil.UI_NAMESPACE);
		writer.print(">");
		writer.print("<ui:ajaxtarget id=\"" + triggerId + "\" action=\"replace\">");

		// Redirect URL
		writer.print("<ui:redirect url=\"" + redirectUrl + "\" />");

		writer.print("</ui:ajaxtarget>");
		writer.print("</ui:ajaxresponse>");
	}
206185
def _length_scalar_handler(scalar_factory, ion_type, length, ctx):
    """"""
    _, self = yield
    if length == 0:
        data = b''
    else:
        yield ctx.read_data_transition(length, self)
        data = ctx.queue.read(length)

    scalar = scalar_factory(data)
    event_cls = IonEvent
    if callable(scalar):
        # TODO Wrap the exception to get context position.
        event_cls = IonThunkEvent
    yield ctx.event_transition(event_cls, IonEventType.SCALAR, ion_type, scalar)
420428
function (basePath, anchors) {
    var fullPath = normalizePath(this.path, basePath) || '/';

    anchors = anchors || [];
    function getAnchor (title) {
      var anchor = String(title).toLowerCase()
        .replace(/[\s\-]+/g, ' ')
        .replace(/[^a-z0-9 ]/g, '')
        .trim()
        .replace(/ /g, '-');
      if (anchors.indexOf(anchor) > -1) {
        var i = 2;
        while (anchors.indexOf(anchor + '-' + i) > -1) {
          i++;
        }
        anchor += '-' + i;
      }
      anchors.push(anchor);
      return anchor;
    }

    var html = '';
    if (this.title) {
      html +=
        '<h1 id="' + getAnchor(this.title) + '">' + this.title + '</h1>\n';
    }
    if (this.description) {
      html += '<p>' + this.description.replace(/\n/g, '<br>') + '</p>\n';
    }

    // Export own request handlers.
    for (var method in this.handlers) {
      var handler = this.handlers[method];
      var title = handler.title || '(no title)';
      html += '<h2 id="' + getAnchor(title) + '">' + title + '</h2>\n';
      html += '<pre>' + method.toUpperCase() + ' ' + fullPath + '</pre>\n';
      if (handler.description) {
        html += '<p>' + handler.description.replace(/\n/g, '<br>') + '</p>\n';
      }

      if (handler.examples && handler.examples.length > 0) {
        var example = handler.examples[0];

        var request = example.request || {};
        if (request.urlParameters || request.headers || request.body) {
          html += '<h3>Input</h3>\n<pre>';
          var exampleURL = method.toUpperCase() + ' ' + fullPath;
          if (request.urlParameters) {
            exampleURL = replaceUrlParameters(exampleURL,
              request.urlParameters);
          }
          html += exampleURL + '\n';
          var requestHeaders = request.headers || {};
          for (var header in requestHeaders) {
            html += header + ': ' + requestHeaders[header] + '\n';
          }
          if (request.body) {
            html += '\n' + jsonStringifyIfObject(request.body).trim() + '\n';
          }
          html += '</pre>\n';
        }

        var response = example.response || {};
        var hasResponseStatus = isExplicitExample(response.status);
        var hasResponseBody = isExplicitExample(response.body);
        if (hasResponseStatus || response.headers || hasResponseBody) {
          html += '<h3>Response</h3>\n<pre>';
          if (hasResponseStatus) {
            var message = http.STATUS_CODES[response.status];
            html += 'Status: ' + response.status + ' ' + message + '\n';
          }
          var responseHeaders = response.headers || {};
          for (var header in responseHeaders) {
            var headerValue = responseHeaders[header];
            if (isExplicitExample(headerValue)) {
              html += header + ': ' + headerValue + '\n';
            }
          }
          if (hasResponseBody) {
            if (hasResponseStatus || Object.keys(responseHeaders).length > 0) {
              html += '\n';
            }
            html += jsonStringifyIfObject(response.body).trim() + '\n';
          }
          html += '</pre>\n';
        }
        // TODO Document all unique possible status codes?
        // TODO Document all request parameters?
      }
    }

    // Export children's request handlers recursively.
    for (var path in this.children) {
      var child = this.children[path];
      html += child.toHTML(fullPath, anchors);
    }

    return html;
  }
83571
def next(pointer)
      super

      if !@current_week_start
        case pointer
        when :future
          sunday_repeater = RepeaterDayName.new(:sunday)
          sunday_repeater.start = @now
          next_sunday_span = sunday_repeater.next(:future)
          @current_week_start = next_sunday_span.begin
        when :past
          sunday_repeater = RepeaterDayName.new(:sunday)
          sunday_repeater.start = (@now + RepeaterDay::DAY_SECONDS)
          sunday_repeater.next(:past)
          last_sunday_span = sunday_repeater.next(:past)
          @current_week_start = last_sunday_span.begin
        end
      else
        direction = pointer == :future ? 1 : -1
        @current_week_start += direction * WEEK_SECONDS
      end

      Span.new(@current_week_start, @current_week_start + WEEK_SECONDS)
    end
299403
function parsePointer (pointer) {
  if (pointer === '') {
    return []
  }
  if (pointer.charAt(0) !== '/') {
    throw new error.PointerError('Invalid JSON pointer: ' + pointer)
  }
  return pointer.substring(1).split(/\//).map(unescape)
}
1130714
private Expression handleThisSuffix(Java7Parser.PrimaryContext primaryContext, AdapterParameters adapterParameters) {
        /*
            thisSuffix
            locals [int operationType]
                :   (LBRACKET expression RBRACKET)+                     {$operationType = 1;}
                |   arguments                                           {$operationType = 2;}
                |   DOT nonWildcardTypeArguments Identifier arguments   {$operationType = 3;}
                |   innerCreator                                        {$operationType = 4;}
                ;


        //this.m.m.m[].class;        // 0 :   (LBRACKET RBRACKET)+ DOT CLASS                      // ClassOrInterfaceType ClassOrInterfaceType ClassOrInterfaceType ReferenceType ClassExpr
        this.m.m.m[1];             // 1 |   (LBRACKET expression RBRACKET)+                     // NameExpr FieldAccessExpr FieldAccessExpr ArrayAccessExpr
        this.m.m.m("");            // 2 |   arguments                                           // NameExpr FieldAccessExpr MethodCallExpr
        //this.m.m.m.class;          // 3 |   DOT CLASS                                           // ClassOrInterfaceType ClassOrInterfaceType ClassOrInterfaceType ReferenceType ClassExpr
        this.m.m.<T>m("");         // 4 |   DOT nonWildcardTypeArguments Identifier arguments   // NameExpr FieldAccessExpr MethodCallExpr
        this.m.m.m.this;           // 5 |   DOT THIS                                            // NameExpr FieldAccessExpr FieldAccessExpr ThisExpr
        //m.m.super("");      // 6 |   DOT SUPER arguments

        */

        ThisExpr thisExpr = new ThisExpr();
        Expression leftExpression = thisExpr;

        for (int i = 0; i < primaryContext.Identifier().size(); i++) {
            FieldAccessExpr fieldAccessExpr = new FieldAccessExpr();
            fieldAccessExpr.setField(primaryContext.Identifier(i).getText());
            fieldAccessExpr.setScope(leftExpression);
            leftExpression = fieldAccessExpr;
        }

        // if thisSuffix is null/not specified
        if (primaryContext.thisSuffix() == null) {
            return leftExpression;
        }

        ClassOrInterfaceType rootType = new ClassOrInterfaceType();

        if (primaryContext.Identifier() != null && primaryContext.Identifier().size() > 0) {
            rootType.setName(primaryContext.Identifier(0).getText());
        }

        switch (primaryContext.thisSuffix().operationType) {
            case 1:
                for (int i = 0; i < primaryContext.thisSuffix().LBRACKET().size(); i++) {
                    ArrayAccessExpr arrayAccessExpr = new ArrayAccessExpr();
                    arrayAccessExpr.setName(leftExpression);
                    arrayAccessExpr.setIndex(Adapters.getExpressionContextAdapter().adapt(primaryContext.thisSuffix().expression(i), adapterParameters));
                    leftExpression = arrayAccessExpr;
                }

                return leftExpression;
            case 2:
                MethodCallExpr methodCallExpr = new MethodCallExpr();

                if (leftExpression instanceof FieldAccessExpr) {
                    methodCallExpr.setName(((FieldAccessExpr)leftExpression).getField());

                    // Set the leftExpression back one since we're changing the top one to a method call
                    leftExpression = ((FieldAccessExpr) leftExpression).getScope();
                    methodCallExpr.setScope(leftExpression);
                }

                if (methodCallExpr.getName() == null) {
                    throw new RuntimeException("Syntax Error: possibly calling 'this' as a method with arguments.  Something like 'this(\"\")'");
                }

                methodCallExpr.setArgs(Adapters.getArgumentsContextAdapter().adapt(primaryContext.thisSuffix().arguments(), adapterParameters));
                leftExpression = methodCallExpr;

                return leftExpression;
            case 3:
                List<Type> typeList = Adapters.getTypeListContextAdapter().adapt(primaryContext.thisSuffix().nonWildcardTypeArguments().typeList(), adapterParameters);

                MethodCallExpr typeArgMethodCallExpr = new MethodCallExpr();
                typeArgMethodCallExpr.setName(primaryContext.thisSuffix().Identifier().getText());
                typeArgMethodCallExpr.setTypeArgs(typeList);
                typeArgMethodCallExpr.setScope(leftExpression);
                typeArgMethodCallExpr.setArgs(Adapters.getArgumentsContextAdapter().adapt(primaryContext.thisSuffix().arguments(), adapterParameters));
                leftExpression = typeArgMethodCallExpr;

                return leftExpression;
            case 4:
                ObjectCreationExpr objectCreationExpr = Adapters.getInnerCreatorContextAdapter().adapt(primaryContext.thisSuffix().innerCreator(), adapterParameters);
                objectCreationExpr.setScope(leftExpression);
                return objectCreationExpr;
        }

        return null;
    }
231770
function handle(name, element, {parent = null, spaces = 4, marker = '+',
                                initialMarker = '+',
                                initialIndent = true,
                                attributesElement = element}) {
  let str = initialMarker;

  // Start with the item name if it has one.
  if (name) {
    str += ` ${name}`;
  }

  // Next, comes the optional example value
  if (typeof element.content !== 'object') {
    if (parent && parent.element !== 'array') {
      str += ':';
    }
    str += ` ${element.content}`;
  }

  // Then the type and attribute information (e.g. required)
  const attributes = getTypeAttributes(element, attributesElement.attributes,
                                       parent);
  if (attributes.length) {
    str += ` (${attributes.join(', ')})`;
  }

  str += handleDescription(attributesElement.description,
                           element, parent, spaces, marker);

  // Return the entire block indented to the correct number of spaces.
  if (initialIndent) {
    str = indent(str, spaces);
  }

  return str + '\n';
}
527649
function resolveAttributeValue(value, part) {
  if (isDirective(value)) {
    value = resolveDirectiveValue(value, part);
  }

  if (value === nothingString) {
    return value;
  }

  if (isTemplateResult(value)) {
    value = value.read();
  }

  if (isPrimitive(value)) {
    const string = typeof value !== 'string' ? String(value) : value;
    // Escape if not prefixed with unsafePrefixString, otherwise strip prefix
    return Buffer.from(
      string.indexOf(unsafePrefixString) === 0 ? string.slice(33) : escapeHTML(string)
    );
  } else if (Buffer.isBuffer(value)) {
    return value;
  } else if (isPromise(value)) {
    return value.then((value) => resolveAttributeValue(value, part));
  } else if (isSyncIterator(value)) {
    if (!Array.isArray(value)) {
      value = Array.from(value);
    }
    return Buffer.concat(
      value.reduce((values, value) => {
        value = resolveAttributeValue(value, part);
        // Flatten
        if (Array.isArray(value)) {
          return values.concat(value);
        }
        values.push(value);
        return values;
      }, [])
    );
  } else {
    throw Error('unknown AttributPart value', value);
  }
}
1005824
function BINDING_anchor($scope, key, element, getControl, bindings) {
        bindings.push($scope.$watch(key, function (newValue, oldValue) {
            newValue = typeof newValue === "string" ? select(newValue, element) : newValue;
            oldValue = typeof oldValue === "string" ? select(oldValue, element) : oldValue;
            if (oldValue && oldValue._anchorClick) {
                oldValue.removeEventListener("click", oldValue._anchorClick);
                oldValue._anchorClick = null;
            }
            if (newValue && !newValue._anchorClick) {
                newValue._anchorClick = function () { getControl().show(); };
                newValue.addEventListener("click", newValue._anchorClick);
            }
            return newValue;
        }));
        var anchor = $scope[key];
        return typeof anchor === "string" ? select(anchor, element) : anchor;
    }
803458
function ( index, direction, router ) {
			var current = F.current;

			if (!current) {
				return;
			}

			index = getScalar(index);

			F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
			F.router    = router || 'jumpto';

			if (current.loop) {
				if (index < 0) {
					index = current.group.length + (index % current.group.length);
				}

				index = index % current.group.length;
			}

			if (current.group[ index ] !== undefined) {
				F.cancel();

				F._start(index);
			}
		}
49616
@Override protected void handleEvents(final String EVENT_TYPE) {
        super.handleEvents(EVENT_TYPE);
        if ("RECALC".equals(EVENT_TYPE)) {
            range     = gauge.getRange();
            angleStep = ANGLE_RANGE / range;
            minValue  = gauge.getMinValue();
            sections  = gauge.getSections();
            resize();
            redraw();
            setBar(gauge.getCurrentValue());
        } else if ("VISIBILITY".equals(EVENT_TYPE)) {
            Helper.enableNode(valueText, gauge.isValueVisible());
            Helper.enableNode(titleText, !gauge.getTitle().isEmpty());
            Helper.enableNode(unitText, !gauge.getUnit().isEmpty());
            boolean tickLabelsVisible = gauge.getTickLabelsVisible();
            Helper.enableNode(minText, tickLabelsVisible);
            Helper.enableNode(maxText, tickLabelsVisible);
            boolean thresholdVisible = gauge.isThresholdVisible();
            Helper.enableNode(threshold, thresholdVisible);
            Helper.enableNode(thresholdText, thresholdVisible);
            resize();
            redraw();
        }
    }