text:
require "test_helper"

class SessionWithoutUserModelTest < Test::Unit::TestCase
  def setup
    Object.send(:remove_const, :User) if defined?(User)
  end

  def test_is_invalid_when_user_model_is_nil
    session = ActiveModel::Session.new(user: nil, password: "secret")
    assert session.invalid?
  end

  def test_is_invalid_when_user_does_not_authenticate
    user = Object.new
    def user.authenticate(password)
      password == "secret"
    end
    session = ActiveModel::Session.new(user: user, password: "wrongsecret")
    assert session.invalid?
  end

  def test_is_valid_when_user_authenticates
    user = Object.new
    def user.authenticate(password)
      password == "secret"
    end
    session = ActiveModel::Session.new(user: user, password: "secret")
    assert session.valid?
  end
end


text:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ItemAnimation : MonoBehaviour {
  public float duration = 0.5f;
  public float moveSpeed = .05f;
  public string infoText = "";

  private float elapsed = 0;

  // Use this for initialization
  void Start () {

    Text display = this.GetComponentInChildren<Text> ();

    display.text = infoText;
    display.color = new Color(255, 100, 0, 255);
    display.CrossFadeAlpha (0, this.duration, false);
  }

  // Update is called once per frame
  void Update () {
    this.elapsed += Time.deltaTime;

    this.transform.Translate (0, (float) (Mathf.Sqrt (this.elapsed - Time.deltaTime) * this.moveSpeed), 0);

    if (this.elapsed > this.duration) {
      Destroy (this.gameObject);
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
require_relative "../../abstract_unit"
require "active_support/core_ext/module/anonymous"

class AnonymousTest < ActiveSupport::TestCase
  test "an anonymous class or module are anonymous" do
    assert_predicate Module.new, :anonymous?
    assert_predicate Class.new, :anonymous?
  end

  test "a named class or module are not anonymous" do
    assert_not_predicate Kernel, :anonymous?
    assert_not_predicate Object, :anonymous?
  end
end


text:
<?php

namespace Saklient\Cloud\Errors;

require_once __DIR__ . "/../../../Saklient/Errors/HttpBadRequestException.php";
use \Saklient\Errors\HttpBadRequestException;
require_once __DIR__ . "/../../../Saklient/Util.php";
use \Saklient\Util;

/** 不適切な要求です。必要なパラメータが指定されていません。 */
class MissingParamException extends HttpBadRequestException {

	/**
	 * @access public
	 * @param int $status
	 * @param string $code=null
	 * @param string $message=""
	 */
	public function __construct($status, $code=null, $message="")
	{
		parent::__construct($status, $code, $message == null || $message == "" ? "不適切な要求です。必要なパラメータが指定されていません。" : $message);
	}

}


text:
package angulate2.router

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

@js.native
@JSImport("@angular/router","UrlTree")
class UrlTree(val root: UrlSegmentGroup, val queryParams: js.Dictionary[String], val fragment: String) extends js.Object {

}

@js.native
@JSImport("@angular/router","UrlSegmentGroup")
class UrlSegmentGroup(val segments: js.Array[UrlSegment], children: js.Dictionary[UrlSegmentGroup]) extends js.Object {

}

@js.native
@JSImport("@angular/router","UrlSegment")
class UrlSegment(val path: String, val parameters: js.Dictionary[String]) extends js.Object


text:
from django.conf import settings
from allauth.account.adapter import DefaultAccountAdapter
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
# from src.apps.Profile.models import Agent
import logging

class AccountAdapter(DefaultAccountAdapter):
    def is_open_for_signup(self, request):
        return getattr(settings, 'ACCOUNT_ALLOW_REGISTRATION', True)

    # def save_user(self, request, user, form, commit=False):
    #     logging.error("made it to the custom Save_user")
    #     data = form.cleaned_data
    #     user.email = data.get('email')
    #     user.first_name = data.get('first_name')
    #     user.last_name = data.get('last_name')
    #     if 'password1' in data:
    #         user.set_password(data['password1'])
    #     else:
    #         user.set_unusable_password()
    #     if commit:
    #         user.save()
    #     return user

    # def save_client_user(self, request,  invite, data,  commit=False):
    #     user = self.new_user(self, request)

    #     user.first_name = invite.first_name
    #     user.last_name = invite.last_name
    #     user.email = invite.email
    #     user.set_password(data['password'])
    #     self.populate_username(self, request, user)

    #     if commit:
    #         user.save()
    #     return user

class SocialAccountAdapter(DefaultSocialAccountAdapter):
    def is_open_for_signup(self, request, sociallogin):
        return getattr(settings, 'ACCOUNT_ALLOW_REGISTRATION', True)


text:
package org.apache.calcite.rel.metadata;

import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.plan.volcano.RelSubset;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Aggregate;
import org.apache.calcite.rel.core.Exchange;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.Join;
import org.apache.calcite.rel.core.Project;
import org.apache.calcite.rel.core.SemiJoin;
import org.apache.calcite.rel.core.Sort;
import org.apache.calcite.rel.core.Union;
import org.apache.calcite.rel.core.Values;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.util.Bug;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.NumberUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * RelMdDistinctRowCount supplies a default implementation of
 * {@link RelMetadataQuery#getDistinctRowCount} for the standard logical
 * algebra.
 */
public class RelMdDistinctRowCount
    implements MetadataHandler<BuiltInMetadata.DistinctRowCount> {
  public static final RelMetadataProvider SOURCE =
      ReflectiveRelMetadataProvider.reflectiveSource(
          BuiltInMethod.DISTINCT_ROW_COUNT.method, new RelMdDistinctRowCount());

  //~ Constructors -----------------------------------------------------------

  protected RelMdDistinctRowCount() {}

  //~ Methods ----------------------------------------------------------------

  public MetadataDef<BuiltInMetadata.DistinctRowCount> getDef() {
    return BuiltInMetadata.DistinctRowCount.DEF;
  }

  /** Catch-all implementation for
   * {@link BuiltInMetadata.DistinctRowCount#getDistinctRowCount(ImmutableBitSet, RexNode)},
   * invoked using reflection.
   *
   * @see org.apache.calcite.rel.metadata.RelMetadataQuery#getDistinctRowCount(RelNode, ImmutableBitSet, RexNode)
   */
  public Double getDistinctRowCount(RelNode rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    // REVIEW zfong 4/19/06 - Broadbase code does not take into
    // consideration selectivity of predicates passed in.  Also, they
    // assume the rows are unique even if the table is not
    boolean uniq = RelMdUtil.areColumnsDefinitelyUnique(mq, rel, groupKey);
    if (uniq) {
      return NumberUtil.multiply(mq.getRowCount(rel),
          mq.getSelectivity(rel, predicate));
    }
    return null;
  }

  public Double getDistinctRowCount(Union rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    double rowCount = 0.0;
    int[] adjustments = new int[rel.getRowType().getFieldCount()];
    RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
    for (RelNode input : rel.getInputs()) {
      // convert the predicate to reference the types of the union child
      RexNode modifiedPred;
      if (predicate == null) {
        modifiedPred = null;
      } else {
        modifiedPred =
            predicate.accept(
                new RelOptUtil.RexInputConverter(
                    rexBuilder,
                    null,
                    input.getRowType().getFieldList(),
                    adjustments));
      }
      Double partialRowCount =
          mq.getDistinctRowCount(input, groupKey, modifiedPred);
      if (partialRowCount == null) {
        return null;
      }
      rowCount += partialRowCount;
    }
    return rowCount;
  }

  public Double getDistinctRowCount(Sort rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    return mq.getDistinctRowCount(rel.getInput(), groupKey, predicate);
  }

  public Double getDistinctRowCount(Exchange rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    return mq.getDistinctRowCount(rel.getInput(), groupKey, predicate);
  }

  public Double getDistinctRowCount(Filter rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    if (predicate == null || predicate.isAlwaysTrue()) {
      if (groupKey.isEmpty()) {
        return 1D;
      }
    }
    // REVIEW zfong 4/18/06 - In the Broadbase code, duplicates are not
    // removed from the two filter lists.  However, the code below is
    // doing so.
    RexNode unionPreds =
        RelMdUtil.unionPreds(
            rel.getCluster().getRexBuilder(),
            predicate,
            rel.getCondition());

    return mq.getDistinctRowCount(rel.getInput(), groupKey, unionPreds);
  }

  public Double getDistinctRowCount(Join rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    if (predicate == null || predicate.isAlwaysTrue()) {
      if (groupKey.isEmpty()) {
        return 1D;
      }
    }
    return RelMdUtil.getJoinDistinctRowCount(mq, rel, rel.getJoinType(),
        groupKey, predicate, false);
  }

  public Double getDistinctRowCount(SemiJoin rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    if (predicate == null || predicate.isAlwaysTrue()) {
      if (groupKey.isEmpty()) {
        return 1D;
      }
    }
    // create a RexNode representing the selectivity of the
    // semijoin filter and pass it to getDistinctRowCount
    RexNode newPred = RelMdUtil.makeSemiJoinSelectivityRexNode(mq, rel);
    if (predicate != null) {
      RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
      newPred =
          rexBuilder.makeCall(
              SqlStdOperatorTable.AND,
              newPred,
              predicate);
    }

    return mq.getDistinctRowCount(rel.getLeft(), groupKey, newPred);
  }

  public Double getDistinctRowCount(Aggregate rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    if (predicate == null || predicate.isAlwaysTrue()) {
      if (groupKey.isEmpty()) {
        return 1D;
      }
    }
    // determine which predicates can be applied on the child of the
    // aggregate
    final List<RexNode> notPushable = new ArrayList<>();
    final List<RexNode> pushable = new ArrayList<>();
    RelOptUtil.splitFilters(
        rel.getGroupSet(),
        predicate,
        pushable,
        notPushable);
    final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
    RexNode childPreds =
        RexUtil.composeConjunction(rexBuilder, pushable, true);

    // set the bits as they correspond to the child input
    ImmutableBitSet.Builder childKey = ImmutableBitSet.builder();
    RelMdUtil.setAggChildKeys(groupKey, rel, childKey);

    Double distinctRowCount =
        mq.getDistinctRowCount(rel.getInput(), childKey.build(), childPreds);
    if (distinctRowCount == null) {
      return null;
    } else if (notPushable.isEmpty()) {
      return distinctRowCount;
    } else {
      RexNode preds =
          RexUtil.composeConjunction(rexBuilder, notPushable, true);
      return distinctRowCount * RelMdUtil.guessSelectivity(preds);
    }
  }

  public Double getDistinctRowCount(Values rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    if (predicate == null || predicate.isAlwaysTrue()) {
      if (groupKey.isEmpty()) {
        return 1D;
      }
    }
    double selectivity = RelMdUtil.guessSelectivity(predicate);

    // assume half the rows are duplicates
    double nRows = rel.estimateRowCount(mq) / 2;
    return RelMdUtil.numDistinctVals(nRows, nRows * selectivity);
  }

  public Double getDistinctRowCount(Project rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    if (predicate == null || predicate.isAlwaysTrue()) {
      if (groupKey.isEmpty()) {
        return 1D;
      }
    }
    ImmutableBitSet.Builder baseCols = ImmutableBitSet.builder();
    ImmutableBitSet.Builder projCols = ImmutableBitSet.builder();
    List<RexNode> projExprs = rel.getProjects();
    RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);

    final List<RexNode> notPushable = new ArrayList<>();
    final List<RexNode> pushable = new ArrayList<>();
    RelOptUtil.splitFilters(
        ImmutableBitSet.range(rel.getRowType().getFieldCount()),
        predicate,
        pushable,
        notPushable);
    final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();

    // get the distinct row count of the child input, passing in the
    // columns and filters that only reference the child; convert the
    // filter to reference the children projection expressions
    RexNode childPred =
        RexUtil.composeConjunction(rexBuilder, pushable, true);
    RexNode modifiedPred;
    if (childPred == null) {
      modifiedPred = null;
    } else {
      modifiedPred = RelOptUtil.pushPastProject(childPred, rel);
    }
    Double distinctRowCount =
        mq.getDistinctRowCount(rel.getInput(), baseCols.build(),
            modifiedPred);

    if (distinctRowCount == null) {
      return null;
    } else if (!notPushable.isEmpty()) {
      RexNode preds =
          RexUtil.composeConjunction(rexBuilder, notPushable, true);
      distinctRowCount *= RelMdUtil.guessSelectivity(preds);
    }

    // No further computation required if the projection expressions
    // are all column references
    if (projCols.cardinality() == 0) {
      return distinctRowCount;
    }

    // multiply by the cardinality of the non-child projection expressions
    for (int bit : projCols.build()) {
      Double subRowCount =
          RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit));
      if (subRowCount == null) {
        return null;
      }
      distinctRowCount *= subRowCount;
    }

    return RelMdUtil.numDistinctVals(distinctRowCount, mq.getRowCount(rel));
  }

  public Double getDistinctRowCount(RelSubset rel, RelMetadataQuery mq,
      ImmutableBitSet groupKey, RexNode predicate) {
    final RelNode best = rel.getBest();
    if (best != null) {
      return mq.getDistinctRowCount(best, groupKey, predicate);
    }
    if (!Bug.CALCITE_1048_FIXED) {
      return getDistinctRowCount((RelNode) rel, mq, groupKey, predicate);
    }
    Double d = null;
    for (RelNode r2 : rel.getRels()) {
      try {
        Double d2 = mq.getDistinctRowCount(r2, groupKey, predicate);
        d = NumberUtil.min(d, d2);
      } catch (CyclicMetadataException e) {
        // Ignore this relational expression; there will be non-cyclic ones
        // in this set.
      }
    }
    return d;
  }
}

// End RelMdDistinctRowCount.java


text:
<?php
namespace app\fetch;

use app\models\Fetch;
use yii\web\NotFoundHttpException;
use app\fetch\FetchIbells;
use app\fetch\FetchMedbells;
use app\fetch\FetchTaxcom;

abstract class FetchBase
{
    public $itemList = array();
    public $uniqueId;
    protected $url;
    protected $path;

    abstract public function fetchElements();
    abstract public function getType();
    abstract public function saveToDb();

    public static function getTypeByName($typeName)
    {
        $fetchName = 'app\fetch\Fetch' . ucfirst($typeName);

        /** @var FetchBase $fetch */
        $fetch = new $fetchName();

        return $fetch->getType();
    }

    public static function init($type, $uniqueId = null)
    {
        $fetchName = null;

        switch ($type) {
            case Fetch::TYPE_TAXCOM:
                $fetchName = 'app\fetch\FetchTaxcom';
                break;
            case Fetch::TYPE_IBELLS:
                $fetchName = 'app\fetch\FetchIbells';
                break;
            case Fetch::TYPE_MEDBELLS:
                $fetchName = 'app\fetch\FetchMedbells';
                break;
        }

        if ($fetchName == null) {
            return null;
        }

        /** @var FetchBase $fetch */
        $fetch = new $fetchName();
        $fetch->uniqueId = $uniqueId;

        return $fetch;
    }

    public function saveToFile($file)
    {
        file_put_contents($file, serialize($this->itemList));
    }

    public function setProgress($cur, $total)
    {
        if (is_null($this->uniqueId)) {
            return;
        }
        if ($cur == $total) {
            unlink($this->uniqueId);
            return;
        }

        $percent = round(($cur++ / $total) * 100);
        file_put_contents($this->uniqueId, $percent.'%');
    }

    public static function loadFromFile($file, $type)
    {
        if (file_exists($file)) {
            $fetch = self::init($type);
            $fetch->itemList = unserialize(file_get_contents($file));
            return $fetch;
        }
        else {
            throw new NotFoundHttpException('Файл не найден.');
        }
    }

    public static function getUniqueId($prefix)
    {
        return uniqid($prefix, true);
    }

    protected static function getInnerHtml($node)
    {
        $innerHTML= '';
        $children = $node->childNodes;
        foreach ($children as $child) {
            $innerHTML .= $child->ownerDocument->saveXML($child);
        }

        return $innerHTML;
    }

    /** @var \DOMNodeList $nodeList */
    public static function  getOnlyNodes($nodeList)
    {
        $ret = array();
        /** @var \DOMElement $node */
        foreach ($nodeList as $node) {
            if ($node->nodeType == 1) {
                $ret[] = $node;
            }
        }

        return $ret;
    }
}


text:
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Reflection;

namespace Banshee.Controls
{
    /// <summary>
    /// This class represents a PropertyDescriptor for subproperties
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class SubPropertyDescriptor<T> : PropertyDescriptor
    {
        #region Fields

        private PropertyInfo propertyInfo;

        #endregion

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name"></param>
        public SubPropertyDescriptor(string name)
            : base(name, null)
        {
            Type t = typeof(T);
            this.propertyInfo = null;

            string[] subPropertyNames = name.Split('.');
            if (subPropertyNames.Length == 1)
            {
                // a regular property
                this.propertyInfo = t.GetProperty(name);
            }
            else
            {
                // navigate through the subproperties
                for (int i = 0; i < subPropertyNames.Length; ++i)
                {
                    this.propertyInfo = t.GetProperty(subPropertyNames[i]);
                    t = this.propertyInfo.PropertyType;
                }
            }
        }

        #endregion

        #region Overriden Methods

        /// <summary>
        /// <see cref="PropertyDescriptor.ComponentType"/>
        /// </summary>
        public override Type ComponentType
        {
            get { return typeof(T); }
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.PropertyType"/>
        /// </summary>
        public override Type PropertyType
        {
            get { return this.propertyInfo.PropertyType; }
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.IsReadOnly"/>
        /// </summary>
        public override bool IsReadOnly
        {
            get { return false; }
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.GetValue"/>
        /// </summary>
        public override object GetValue(object component)
        {
            object value = component;
            foreach (string property in this.Name.Split('.'))
            {
                value = value.GetType().GetProperty(property).GetValue(value, null);
            }

            return value;
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.SetValue"/>
        /// </summary>
        public override void SetValue(object component, object value)
        {
            Type t = typeof(T);
            PropertyInfo subPropertyInfo = null;

            string[] subPropertyNames = this.Name.Split('.');
            if (subPropertyNames.Length == 1)
            {
                // a regular property
                subPropertyInfo = t.GetProperty(this.Name);
            }
            else
            {
                // navigate through the subproperties
                for (int i = 0; i < subPropertyNames.Length; ++i)
                {
                    subPropertyInfo = t.GetProperty(subPropertyNames[i]);
                    t = subPropertyInfo.PropertyType;

                    if (i < subPropertyNames.Length - 1)
                    {
                        component = subPropertyInfo.GetValue(component, null);
                    }
                }
            }

            subPropertyInfo.SetValue(component, value, null);
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.CanResetValue"/>
        /// </summary>
        public override bool CanResetValue(object component)
        {
            return false;
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.ResetValue"/>
        /// </summary>
        public override void ResetValue(object component)
        {
        }

        /// <summary>
        /// <see cref="PropertyDescriptor.ShouldSerializeValue"/>
        /// </summary>
        public override bool ShouldSerializeValue(object component)
        {
            return false;
        }

        #endregion
    }
}


text:
<?php

// Included here for completeness, but this is a very dangerous operation.
// It is the caller's responsibility to confirm the requestor's intent and
// authorisation to do this.

function user_remove($uid) {
	if(! $uid)
		return;
	$a = get_app();
	logger('Removing user: ' . $uid);
	q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
	q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
	if($uid == local_user()) {
		unset($_SESSION['authenticated']);
		unset($_SESSION['uid']);
		goaway($a->get_baseurl());
	}
}

function contact_remove($id) {
	q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
		intval($id)
	);
	q("DELETE FROM `item` WHERE `contact-id` = %d ",
		intval($id)
	);
	q("DELETE FROM `photo` WHERE `contact-id` = %d ",
		intval($id)
	);
	q("DELETE FROM `mail` WHERE `contact-id` = %d ",
		intval($id)
	);
	q("DELETE FROM `event` WHERE `cid` = %d ",
		intval($id)
	);
	q("DELETE FROM `queue` WHERE `cid` = %d ",
		intval($id)
	);

}

// Contact has refused to recognise us as a friend. We will start a countdown.
// If they still don't recognise us in 32 days, the relationship is over,
// and we won't waste any more time trying to communicate with them.
// This provides for the possibility that their database is temporarily messed
// up or some other transient event and that there's a possibility we could recover from it.

if(! function_exists('mark_for_death')) {
function mark_for_death($contact) {
	if($contact['term-date'] == '0000-00-00 00:00:00') {
		q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
				dbesc(datetime_convert()),
				intval($contact['id'])
		);
	}
	else {
		$expiry = $contact['term-date'] . ' + 32 days ';
		if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {

			// relationship is really truly dead.

			contact_remove($contact['id']);

		}
	}

}}

if(! function_exists('unmark_for_death')) {
function unmark_for_death($contact) {
	// It's a miracle. Our dead contact has inexplicably come back to life.
	q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
		dbesc('0000-00-00 00:00:00'),
		intval($contact['id'])
	);
}}

if(! function_exists('contact_photo_menu')){
function contact_photo_menu($contact) {

	$a = get_app();

	$contact_url="";
	$pm_url="";
	$status_link="";
	$photos_link="";
	$posts_link="";

	$sparkle = false;
	if($contact['network'] === NETWORK_DFRN) {
		$sparkle = true;
		$profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
	}
	else
		$profile_link = $contact['url'];

	if($profile_link === 'mailbox')
		$profile_link = '';

	if($sparkle) {
		$status_link = $profile_link . "?url=status";
		$photos_link = $profile_link . "?url=photos";
		$profile_link = $profile_link . "?url=profile";
		$pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
	}

	$contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
	$posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];

	$menu = Array(
		t("View status") => $status_link,
		t("View profile") => $profile_link,
		t("View photos") => $photos_link,
		t("View recent") => $posts_link,
		t("Edit contact") => $contact_url,
		t("Send PM") => $pm_url,
	);

	$args = array('contact' => $contact, 'menu' => $menu);

	call_hooks('contact_photo_menu', $args);

	$o = "";
	foreach($menu as $k=>$v){
		if ($v!="") {
			if(($k !== t("View recent")) && ($k !== t("Send PM")))
				$o .= "
$k
\n";
			else
				$o .= "
$k
\n";
		}
	}
	return $o;
}}


text:
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { IgxCalendarModule } from '../calendar/public_api';
import { IgxCalendarContainerModule } from '../date-common/calendar-container/calendar-container.component';
import { IgxPickersCommonModule } from '../date-common/picker-icons.common';
import { IgxDateTimeEditorModule } from '../directives/date-time-editor/public_api';
import { IgxMaskModule } from '../directives/mask/mask.directive';
import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive';
import { IgxIconModule } from '../icon/public_api';
import { IgxInputGroupModule } from '../input-group/public_api';
import { IgxDatePickerComponent } from './date-picker.component';

/** @hidden */
@NgModule({
    declarations: [
        IgxDatePickerComponent
    ],
    exports: [
        IgxDatePickerComponent,
        IgxPickersCommonModule
    ],
    imports: [
        FormsModule,
        CommonModule,
        IgxIconModule,
        IgxMaskModule,
        IgxCalendarModule,
        IgxInputGroupModule,
        IgxPickersCommonModule,
        IgxTextSelectionModule,
        IgxDateTimeEditorModule,
        IgxCalendarContainerModule,
    ]
})
export class IgxDatePickerModule { }


text:
package com.intellij.java.psi.formatter.java;

import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;

/**
 * @author Denis Zhdanov
 * @since 1/18/11 3:11 PM
 */
public class JavadocFormatterTest extends AbstractJavaFormatterTest {

  public void testRightMargin() {
    getSettings().WRAP_LONG_LINES = true;
    getSettings().RIGHT_MARGIN = 35;
    doTextTest(
      "/** Here is one-line java-doc comment */" +
      "class Foo {\n" +
      "}",
      "/**\n" +
      " * Here is one-line java-doc \n" +
      " * comment\n" +
      " */\n" +
      "class Foo {\n" +
      "}");

  }

  public void test_NoFormatting_IfStartsWithLotsOfAsterisks() {
    doTextTest(
      "/****\n" +
      " * description\n" +
      " *\n" +
      " *\n" +
      " * xxxx\n" +
      " */\n" +
      "      class X {}",
      "/****\n" +
      " * description\n" +
      " *\n" +
      " *\n" +
      " * xxxx\n" +
      " */\n" +
      "class X {\n" +
      "}"
    );
  }

  public void testDoNotWrapLink() {
    getSettings().WRAP_LONG_LINES = true;
    getSettings().RIGHT_MARGIN = 70;
    doTextTest(
      "/**\n" +
      " * Some of the usl contained {@link sdfsdf.test.ttttttt.ssss.stttt.tttttttcom}\n" +
      " */\n" +
      "            public class X {\n" +
      "}",
      "/**\n" +
      " * Some of the usl contained \n" +
      " * {@link sdfsdf.test.ttttttt.ssss.stttt.tttttttcom}\n" +
      " */\n" +
      "public class X {\n" +
      "}"
    );
  }

  public void testDoNot() {
    getSettings().WRAP_LONG_LINES = true;
    getSettings().RIGHT_MARGIN = 70;

    doTextTest(
      "/**\n" +
      " * Some of the usl contained \n" +
      " */\n" +
      "            public class X {\n" +
      "}",
      "/**\n" +
      " * Some of the usl contained \n" +
      " * \n" +
      " */\n" +
      "public class X {\n" +
      "}"
    );
  }

  public void testPackageJavadoc() {
    doTextTest(
      "/**\n" +
      " *              super auper\n" +
      " */\n" +
      " package com;\n",
      "/**\n" +
      " * super auper\n" +
      " */\n" +
      "package com;\n"
    );
  }

  public void test_do_wrap_on_asterisks() {
    doTextTest(
        "/***********\n" +
        " *\n" +
        " *********************/\n" +
        "\n" +
        "\n" +
        "   public class Test {\n" +
        "}\n",
        "/***********\n" +
        " *\n" +
        " *********************/\n" +
        "\n" +
        "\n" +
        "public class Test {\n" +
        "}\n"
    );
  }

  public void test_wrap_after_asterisks() {
    doTextTest(
        "/** hollla la\n" +
        " * I am javadoc comment\n" +
        " * heey ***********/\n" +
        "   class T {   }\n",
        "/**\n" +
        " * hollla la\n" +
        " * I am javadoc comment\n" +
        " * heey\n" +
        " ***********/\n" +
        "class T {\n" +
        "}\n"
    );
  }

  public void test_strange_comment() {
    doTextTest(
        "/**F*****/\n" +
        "public class T {\n" +
        "}",
        "/**\n" +
        " * F\n" +
        " *****/\n" +
        "public class T {\n" +
        "}"
    );
  }

  public void test_incomplete_javadoc() {
    doTextTest(
        "/**\n",
        "/**\n"
    );
  }

  public void testEA49739() {
    getSettings().WRAP_LONG_LINES = true;
    getSettings().RIGHT_MARGIN = 35;
    getSettings().WRAP_COMMENTS = true;
    doTextTest("class A {\n" +
               "    /**\n" +
               "     * @return a is one line javadoc\n" +
               "     */\n" +
               "    public int get(int a) {\n" +
               "        return 1;\n" +
               "    }\n" +
               "  }",
               "class A {\n" +
               "    /**\n" +
               "     * @return a is one line \n" +
               "     * javadoc\n" +
               "     */\n" +
               "    public int get(int a) {\n" +
               "        return 1;\n" +
               "    }\n" +
               "}");
  }

  public void testOneLineCommentWrappedByRightMarginIntoMultiLine() {
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
    getSettings().RIGHT_MARGIN = 35;
    doTextTest(
      "/** Here is one-line java-doc comment */" +
      "class Foo {\n" +
      "}",
      "/**\n" +
      " * Here is one-line java-doc\n" +
      " * comment\n" +
      " */\n" +
      "class Foo {\n" +
      "}");
  }

  public void testLineFeedsArePreservedDuringWrap() {
    // Inspired by IDEA-61895
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getJavaSettings().JD_PRESERVE_LINE_FEEDS = true;
    getSettings().RIGHT_MARGIN = 48;

    doTextTest(
      "/**\n" +
      " * This is a long comment that spans more than one\n" +
      " * line\n" +
      " */\n" +
      "class Test {\n" +
      "}",
      "/**\n" +
      " * This is a long comment that spans more than\n" +
      " * one\n" +
      " * line\n" +
      " */\n" +
      "class Test {\n" +
      "}"
    );
  }

  public void testSCR11296() {
    final CommonCodeStyleSettings settings = getSettings();
    settings.RIGHT_MARGIN = 50;
    settings.getRootSettings().WRAP_COMMENTS = true;
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_P_AT_EMPTY_LINES = false;
    getJavaSettings().JD_KEEP_EMPTY_LINES = false;
    doTest();
  }

  public void testSCR2632() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getSettings().RIGHT_MARGIN = 20;
    doTextTest("/**\n" +
               " *
\n" +
               " * Another paragraph of the description placed after blank line.\n" +
               " */\n" +
               "class A{}",
               "/**\n" +
               " *
\n" +
               " * Another paragraph\n" +
               " * of the description\n" +
               " * placed after\n" +
               " * blank line.\n" +
               " */\n" +
               "class A {\n" +
               "}");
  }

  public void test_PreserveExistingSelfClosingTags_AndGenerateOnlyPTag() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    LanguageLevel before = LanguageLevelProjectExtension.getInstance(getProject()).getLanguageLevel();
    LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
    try {
      doTextTest(
        "/**\n" +
        " * My test comment\n" +
        " *
\n" +
        " * \n" +
        " * With empty line\n" +
        " */\n" +
        "class T {\n" +
        "}",
        "/**\n" +
        " * My test comment\n" +
        " *
\n" +
        " *
\n" +
        " * With empty line\n" +
        " */\n" +
        "class T {\n" +
        "}"
      );
    }
    finally {
      LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(before);
    }
  }

  public void testParagraphTagGeneration() {
    // Inspired by IDEA-61811
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_P_AT_EMPTY_LINES = true;
    LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
    doTextTest(
      "/**\n" +
      " * line 1\n" +
      " *\n" +
      " * line 2\n" +
      " *
\n" +
      " *   line 3\n" +
      " *\n" +
      " *   line 4\n" +
      " *
\n" +
      " */\n" +
      "class Test {\n" +
      "}",
      "/**\n" +
      " * line 1\n" +
      " *
\n" +
      " * line 2\n" +
      " *
\n" +
      " *   line 3\n" +
      " *\n" +
      " *   line 4\n" +
      " *
\n" +
      " */\n" +
      "class Test {\n" +
      "}"
    );
  }

  public void testParameterDescriptionNotOnNewLine() {
    // IDEA-107383
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_ALIGN_PARAM_COMMENTS = true;

    doClassTest(
      "/**\n" +
      " @param protocolId protocol id\n" +
      " @param connectedUserIdHandlerFromServer user id\n" +
      " @return\n" +

      " */\n" +
      "public void register(int protocolId, int connectedUserIdHandlerFromServer) {\n" +
      "}",

      "/**\n" +
      " * @param protocolId                       protocol id\n" +
      " * @param connectedUserIdHandlerFromServer user id\n" +
      " * @return\n" +
      " */\n" +
      "public void register(int protocolId, int connectedUserIdHandlerFromServer) {\n" +
      "}");
  }

  public void testWrappedParameterDescription() {
    // Inspired by IDEA-13072
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getJavaSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE = true;
    doClassTest(
      "/**\n" +
      " * test description\n" +
      " * @param first first description\n" +
      " * @param second\n" +
      " * @param third third\n" +
      " *              description\n" +
      " * @param forth\n" +
      " *          forth description\n" +
      " */\n" +
      "void test(int first, int second, int third, int forth) {\n" +
      "}",
      "/**\n" +
      " * test description\n" +
      " *\n" +
      " * @param first\n" +
      " *         first description\n" +
      " * @param second\n" +
      " * @param third\n" +
      " *         third description\n" +
      " * @param forth\n" +
      " *         forth description\n" +
      " */\n" +
      "void test(int first, int second, int third, int forth) {\n" +
      "}"
    );
  }

  public void testExceptionAlignmentCorrect() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_ALIGN_EXCEPTION_COMMENTS = true;

    String before =
      "public class Controller {\n" +
      "\n" +
      "    /**\n" +
      "     * @throws NoSearchServersConfiguredException If no search engine servers are configured.\n" +
      "     * @throws SearchServerUnavailableException If the search engine server is not accessible.\n" +
      "     * @throws InvalidSearchServerResponseException If the search engine server response was invalid.\n" +
      "     * @throws NotificationEncodingException If the request could not be encoded to UTF-8.\n" +
      "     * @throws NotificationUnavailableException If the notification server is not available or sent back an invalid response code.\n" +
      "     */\n" +
      "    public int superDangerousMethod() {\n" +
      "        return 68;\n" +
      "    }\n" +
      "}";

    String after =
      "public class Controller {\n" +
      "\n" +
      "    /**\n" +
      "     * @throws NoSearchServersConfiguredException   If no search engine servers are configured.\n" +
      "     * @throws SearchServerUnavailableException     If the search engine server is not accessible.\n" +
      "     * @throws InvalidSearchServerResponseException If the search engine server response was invalid.\n" +
      "     * @throws NotificationEncodingException        If the request could not be encoded to UTF-8.\n" +
      "     * @throws NotificationUnavailableException     If the notification server is not available or sent back an invalid response code.\n" +
      "     */\n" +
      "    public int superDangerousMethod() {\n" +
      "        return 68;\n" +
      "    }\n" +
      "}";

    doTextTest(before, after);
  }

  public void testDoNotWrapMultiLineCommentIntoOneLine() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
    String test = "/**\n" +
                  " * foo\n" +
                  " */\n" +
                  "public Object next() {\n" +
                  "    return new Object();\n" +
                  "}";
    doClassTest(test, test);
  }

  public void testLeaveOneLineComment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
    String test = "/** foo */\n" +
                  "public Object next() {\n" +
                  "    return new Object();\n" +
                  "}";
    doClassTest(test, test);
  }

  public void testWrapOneLineComment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = false;
    String test = "/** foo */\n" +
                  "public Object next() {\n" +
                  "    return new Object();\n" +
                  "}";
    String after = "/**\n" +
                   " * foo\n" +
                   " */\n" +
                   "public Object next() {\n" +
                   "    return new Object();\n" +
                   "}";
    doClassTest(test, after);
  }

  public void testWrapStrangeComment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = false;
    String test = "/** foo" +
                  " */\n" +
                  "public Object next() {\n" +
                  "    return new Object();\n" +
                  "}";
    String after = "/**\n" +
                   " * foo\n" +
                   " */\n" +
                   "public Object next() {\n" +
                   "    return new Object();\n" +
                   "}";
    doClassTest(test, after);
  }

  public void testWrapStrangeCommentIfNotWrapOneLines() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
    String test = "/** foo\n" +
                  " */" +
                  "public Object next() {\n" +
                  "    return new Object();\n" +
                  "}";
    String after = "/**\n" +
                   " * foo\n" +
                   " */\n" +
                   "public Object next() {\n" +
                   "    return new Object();\n" +
                   "}";
    doClassTest(test, after);
  }

  public void testReturnTagAlignment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().RIGHT_MARGIN = 80;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;

    String before = "    /**\n" +
                    "     * @return this is a return value documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters, which should be greater than any sane right margin.\n" +
                    "     */\n" +
                    "    public int method(int parameter) {\n" +
                    "        return 0;\n" +
                    "    }\n";

    String after = "/**\n" +
                   " * @return this is a return value documentation with a very long description\n" +
                   " * that is longer than the right margin. It is more than 200 characters\n" +
                   " * long, not including the comment indent and the asterisk characters, which\n" +
                   " * should be greater than any sane right margin.\n" +
                   " */\n" +
                   "public int method(int parameter) {\n" +
                   "    return 0;\n" +
                   "}\n";

    doClassTest(before, after);
  }

  public void testReturnTagAlignmentWithPreTagOnFirstLine() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().RIGHT_MARGIN = 80;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;

    String before = "    /**\n" +
                    "     * @return
this is a return value documentation with a very long description\n" +
                    "     * that is longer than the right margin.
\n" +
                    "     */\n" +
                    "    public int method(int parameter) {\n" +
                    "        return 0;\n" +
                    "    }";

    String after = "/**\n" +
                   " * @return
this is a return value documentation with a very long\n" +
                   " * description\n" +
                   " * that is longer than the right margin.
\n" +
                   " */\n" +
                   "public int method(int parameter) {\n" +
                   "    return 0;\n" +
                   "}";

    doClassTest(before, after);
  }

  public void testDoNotMergeCommentLines() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getJavaSettings().JD_PRESERVE_LINE_FEEDS = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;

    doClassTest(
      "/**\n" +
      " * Some comment\n" +
      " * 2016\n" +
      " * Date: Mar 03, 2016\n" +
      " *\n" +
      " */\n" +
      "     public class TestCase {\n" +
      "}",

      "/**\n" +
      " * Some comment\n" +
      " * 2016\n" +
      " * Date: Mar 03, 2016\n" +
      " */\n" +
      "public class TestCase {\n" +
      "}"
    );
  }

  public void testSeeTagAlignment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().RIGHT_MARGIN = 80;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;

    String before = "    /**\n" +
                    "     * @see this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
                    "     */\n" +
                    "    public int method(int parameter) {\n" +
                    "        return 0;\n" +
                    "    }";

    String after = "/**\n" +
                   " * @see this is an additional documentation with a very long description\n" +
                   " * that is longer than the right margin. It is more than 200 characters\n" +
                   " * long, not including the comment indent and the asterisk characters which\n" +
                   " * should be greater than any sane right margin\n" +
                   " */\n" +
                   "public int method(int parameter) {\n" +
                   "    return 0;\n" +
                   "}";

    doClassTest(before, after);
  }

  public void testDummySinceTagAlignment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().RIGHT_MARGIN = 80;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;

    String before = "    /**\n" +
                    "     * @since this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
                    "     */\n" +
                    "    public int method(int parameter) {\n" +
                    "        return 0;\n" +
                    "    }";

    String after = "/**\n" +
                   " * @since this is an additional documentation with a very long description\n" +
                   " * that is longer than the right margin. It is more than 200 characters\n" +
                   " * long, not including the comment indent and the asterisk characters which\n" +
                   " * should be greater than any sane right margin\n" +
                   " */\n" +
                   "public int method(int parameter) {\n" +
                   "    return 0;\n" +
                   "}";

    doClassTest(before, after);
  }

  public void testDummyDeprecatedTagAlignment() {
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getSettings().RIGHT_MARGIN = 80;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getSettings().getRootSettings().WRAP_COMMENTS = true;
    getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;

    String before = "    /**\n" +
                    "     * @deprecated this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
                    "     */\n" +
                    "    public int method(int parameter) {\n" +
                    "        return 0;\n" +
                    "    }";

    String after = "/**\n" +
                   " * @deprecated this is an additional documentation with a very long\n" +
                   " * description that is longer than the right margin. It is more than 200\n" +
                   " * characters long, not including the comment indent and the asterisk\n" +
                   " * characters which should be greater than any sane right margin\n" +
                   " */\n" +
                   "public int method(int parameter) {\n" +
                   "    return 0;\n" +
                   "}";

    doClassTest(before, after);
  }

  public void testJavadocFormattingIndependentOfMethodIndentation() {
    getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 50);
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getCurrentCodeStyleSettings().WRAP_COMMENTS = true;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getJavaSettings().JD_P_AT_EMPTY_LINES = false;
    getJavaSettings().JD_KEEP_EMPTY_LINES = false;
    getJavaSettings().JD_ADD_BLANK_AFTER_DESCRIPTION = false;
    String before1 = "class A {\n" +
                     "    /**\n" +
                     "     * Some really great independent test approach purpose live fish\n" +
                     "     * banana split string be accurate when writing tests and code\n" +
                     "     * read write buffer.\n" +
                     "     *\n" +
                     "     * Some text after empty line\n" +
                     "     *\n" +
                     "     */\n" +
                     "void foo() {\n" +
                     "\n" +
                     "}\n" +
                     "}";

    String before2 = "class A {\n" +
                     "    /**\n" +
                     "     * Some really great independent test approach purpose live fish\n" +
                     "     * banana split string be accurate when writing tests and code\n" +
                     "     * read write buffer.\n" +
                     "     *\n" +
                     "     * Some text after empty line\n" +
                     "     *\n" +
                     "     */\n" +
                     "    void foo() {\n" +
                     "\n" +
                     "    }\n" +
                     "}";

    formatEveryoneAndCheckIfResultEqual(before1, before2);
  }

  public void testJavadocAlignmentForInnerClasses() {
    getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 40);
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    getCurrentCodeStyleSettings().WRAP_COMMENTS = true;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;

    String code = "public class Outer {\n" +
                  "    class Inner {\n" +
                  "        /**\n" +
                  "         * Password from wild forest big house\n" +
                  "         */\n" +
                  "        public int getMagic() {\n" +
                  "            return 312;\n" +
                  "        }\n" +
                  "\n" +
                  "class InnerInner {\n" +
                  "/**\n" +
                  " * Special magic needs special rules\n" +
                  " */\n" +
                  "public int innerMagic() {\n" +
                  "    return 1;\n" +
                  "}\n" +
                  "}\n" +
                  "    }\n" +
                  "}";

    String result = "public class Outer {\n" +
                    "    class Inner {\n" +
                    "        /**\n" +
                    "         * Password from wild forest big\n" +
                    "         * house\n" +
                    "         */\n" +
                    "        public int getMagic() {\n" +
                    "            return 312;\n" +
                    "        }\n" +
                    "\n" +
                    "        class InnerInner {\n" +
                    "            /**\n" +
                    "             * Special magic needs\n" +
                    "             * special rules\n" +
                    "             */\n" +
                    "            public int innerMagic() {\n" +
                    "                return 1;\n" +
                    "            }\n" +
                    "        }\n" +
                    "    }\n" +
                    "}";
    doTextTest(code, result);
  }

  public void testAlignmentWithNoTopClassMembersIndentation() {
    getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 40);
    getCurrentCodeStyleSettings().WRAP_COMMENTS = true;
    getJavaSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
    getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE).DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = true;

    String before = "public class Outer {\n" +
                    "class Inner {\n" +
                    "/**\n" +
                    " * Password from wild forest big\n" +
                    " * house\n" +
                    " */\n" +
                    "public int getMagic() {\n" +
                    "    return 312;\n" +
                    "}\n" +
                    "\n" +
                    "class InnerInner {\n" +
                    "/**\n" +
                    " * Special magic needs special rules\n" +
                    " */\n" +
                    "public int innerMagic() {\n" +
                    "    return 1;\n" +
                    "}\n" +
                    "\n" +
                    "class InnerInnerInner {\n" +
                    "int iii;\n" +
                    "class TripleInner {\n" +
                    "int ti;\n" +
                    "}\n" +
                    "}\n" +
                    "}\n" +
                    "}\n" +
                    "    public static void main(String[] args) {\n" +
                    "        System.out.println(\"AAA!\");\n" +
                    "    }\n" +
                    "}";

   String after = "public class Outer {\n" +
                  "class Inner {\n" +
                  "    /**\n" +
                  "     * Password from wild forest big\n" +
                  "     * house\n" +
                  "     */\n" +
                  "    public int getMagic() {\n" +
                  "        return 312;\n" +
                  "    }\n" +
                  "\n" +
                  "    class InnerInner {\n" +
                  "        /**\n" +
                  "         * Special magic needs special\n" +
                  "         * rules\n" +
                  "         */\n" +
                  "        public int innerMagic() {\n" +
                  "            return 1;\n" +
                  "        }\n" +
                  "\n" +
                  "        class InnerInnerInner {\n" +
                  "            int iii;\n" +
                  "\n" +
                  "            class TripleInner {\n" +
                  "                int ti;\n" +
                  "            }\n" +
                  "        }\n" +
                  "    }\n" +
                  "}\n" +
                  "\n" +
                  "public static void main(String[] args) {\n" +
                  "    System.out.println(\"AAA!\");\n" +
                  "}\n" +
                  "}";

    doTextTest(before, after);
  }

  public void testDoNotWrapLongLineCommentWithSpaceInStart() {
    getSettings().KEEP_FIRST_COLUMN_COMMENT = true;
    getSettings().WRAP_LONG_LINES = true;
    getSettings().RIGHT_MARGIN = 200;
    String before = "public class JiraIssue {\n" +
                    "\n" +
                    "    public static void main(String[] args) {\n" +
                    "// AAAMIIGgIBADANBgkqhkiG9w0BAQEFAASCBugwgsdfssdflkldkflskdfsdkfjskdlfjdskjfksdjfksdjfkjsdkfjsdkfjgbkAgEAAoIBgQCZfKds4XjFWIU8D4OqCYJ0TkAkKPVV96v2l6PuMBNbON3ndHCVvwoJOJnopfbtFro9eCTCUC9MlAUZBAVdCbPVi3ioqaEN\n" +
                    "    }\n" +
                    "}";
    doTextTest(before, before);
  }

  public void testNotGenerateSelfClosingPTagIfLanguageLevelJava8() {
    getJavaSettings().JD_P_AT_EMPTY_LINES = true;
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    String before = "/**\n" +
                    " * Super method\n" +
                    " *\n" +
                    " * Super multiple times\n" +
                    " */\n" +
                    "public void voo() {\n" +
                    "}\n";
    String after = "/**\n" +
                    " * Super method\n" +
                    " *
\n" +
                    " * Super multiple times\n" +
                    " */\n" +
                    "public void voo() {\n" +
                    "}\n";
    doClassTest(before, after);
  }

  public void testPTagIfLanguageLevelNotJava8() {
    getJavaSettings().JD_P_AT_EMPTY_LINES = true;
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;
    LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
    String before = "/**\n" +
                    " * Super method\n" +
                    " *\n" +
                    " * Super multiple times\n" +
                    " */\n" +
                    "public void voo() {\n" +
                    "}\n";
    String after = "/**\n" +
                   " * Super method\n" +
                   " *
\n" +
                   " * Super multiple times\n" +
                   " */\n" +
                   "public void voo() {\n" +
                   "}\n";
    doClassTest(before, after);
  }

  public void test_DoNotTouch_SingleLineComments() {
    getJavaSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;

    doClassTest(
      "/****** AAAAAAA *******/\n" +
      "  \n" +
      "  public void t() {\n" +
      "         }",
      "/****** AAAAAAA *******/\n" +
      "\n" +
      "public void t() {\n" +
      "}"
    );
  }

  public void test_Keep_P_Tags() {
    getJavaSettings().JD_P_AT_EMPTY_LINES = true;
    getJavaSettings().ENABLE_JAVADOC_FORMATTING = true;

    doClassTest(
      "/**\n" +
      " *
new\n" +
      " * code
\n" +
      " *
\n" +
      " * Whatever.\n" +
      " *
\n" +
      " * Whatever.\n" +
      "    */\n" +
      "public static void main(String[] args) {\n" +
      "     }",
      "/**\n" +
      " *
new\n" +
      " * code
\n" +
      " *
\n" +
      " * Whatever.\n" +
      " *
\n" +
      " * Whatever.\n" +
      " */\n" +
      "public static void main(String[] args) {\n" +
      "}"
    );
  }

  public void test_Touch_Nothing_Inside_Pre_Tag() {
    doClassTest(
      "/**\n" +
      " *   Holla\n" +
      " *
\n" +
      " * @Override\n" +
      " *              Test me\n" +
      " *
\n" +
      " */\n" +
      "public void test() {\n" +
      "}",
      "/**\n" +
      " * Holla\n" +
      " *
\n" +
      " * @Override\n" +
      " *              Test me\n" +
      " *
\n" +
      " */\n" +
      "public void test() {\n" +
      "}"
    );
  }

  public void test_ContinuationDescriptionFormatting() {
    getCurrentCodeStyleSettings().setRightMargin(JavaLanguage.INSTANCE, 40);

    getCurrentCodeStyleSettings().getIndentOptions(JavaFileType.INSTANCE).CONTINUATION_INDENT_SIZE = 2;

    getJavaSettings().JD_INDENT_ON_CONTINUATION = true;
    getJavaSettings().JD_ALIGN_PARAM_COMMENTS = false;
    getJavaSettings().JD_ALIGN_EXCEPTION_COMMENTS = false;
    getCurrentCodeStyleSettings().WRAP_COMMENTS = true;

    doClassTest(
      "/**\n" +
      " * Just some random text\n" +
      " * @param aParameter randomness in life does not mean it's easy to generate random text\n" +
      " * @param bParameter another random parameter with qualified epoch\n" +
      " * @author rumor oculus rivierra underground sound\n" +
      " * @myrandomtag just write what you want and cranberries with bicycle\n" +
      " * @return super string with everything involved, be aware\n" +
      " */\n" +
      "String test(int aParameter, int bParameter) {\n" +
      "  return \"\";\n" +
      "}  \n",

      "/**\n" +
      " * Just some random text\n" +
      " *\n" +
      " * @param aParameter randomness in\n" +
      " *   life does not mean it's easy to\n" +
      " *   generate random text\n" +
      " * @param bParameter another\n" +
      " *   random parameter with qualified\n" +
      " *   epoch\n" +
      " * @return super string with\n" +
      " *   everything involved, be aware\n" +
      " * @author rumor oculus rivierra\n" +
      " *   underground sound\n" +
      " * @myrandomtag just write what\n" +
      " *   you want and cranberries with\n" +
      " *   bicycle\n" +
      " */\n" +
      "String test(int aParameter, int bParameter) {\n" +
      "    return \"\";\n" +
      "}\n"
    );
  }

  public void test_JdWithTabs() {
    doClassTest(
      "\t/**\n" +
      "\t \t *\n" +
      "\t \t *\n" +
      "\t \t */\n" +
      "\tvoid check() {\n" +
      "\t}",
      "/**\n" +
      " *\n" +
      " *\n" +
      " */\n" +
      "void check() {\n" +
      "}"
    );
  }

  public void testMultipleSince() {
    doTextTest("/**\n" +
               " * @since 1.7\n" +
               " * @since 2.0\n" +
               " */\n" +
               "public class C {\n" +
               "}",
               "/**\n" +
               " * @since 1.7\n" +
               " * @since 2.0\n" +
               " */\n" +
               "public class C {\n" +
               "}");
  }
}


text:
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;

namespace AvaloniaEdit.Document
{
    /// <summary>
    /// A document representing a source code file for refactoring.
    /// Line and column counting starts at 1.
    /// Offset counting starts at 0.
    /// </summary>
    public interface IDocument : ITextSource, IServiceProvider
    {
        /// <summary>
        /// Gets/Sets the text of the whole document..
        /// </summary>
        new string Text { get; set; } // hides ITextSource.Text to add the setter

        /// <summary>
        /// This event is called directly before a change is applied to the document.
        /// </summary>
        /// <remarks>
        /// It is invalid to modify the document within this event handler.
        /// Aborting the change (by throwing an exception) is likely to cause corruption of data structures
        /// that listen to the Changing and Changed events.
        /// </remarks>
        event EventHandler<TextChangeEventArgs> TextChanging;

        /// <summary>
        /// This event is called directly after a change is applied to the document.
        /// </summary>
        /// <remarks>
        /// It is invalid to modify the document within this event handler.
        /// Aborting the event handler (by throwing an exception) is likely to cause corruption of data structures
        /// that listen to the Changing and Changed events.
        /// </remarks>
        event EventHandler<TextChangeEventArgs> TextChanged;

        /// <summary>
        /// This event is called after a group of changes is completed.
        /// </summary>
        /// <seealso cref="EndUndoableAction"/>
        event EventHandler ChangeCompleted;

        /// <summary>
        /// Gets the number of lines in the document.
        /// </summary>
        int LineCount { get; }

        /// <summary>
        /// Gets the document line with the specified number.
        /// </summary>
        /// <param name="lineNumber">The number of the line to retrieve. The first line has number 1.</param>
        IDocumentLine GetLineByNumber(int lineNumber);

        /// <summary>
        /// Gets the document line that contains the specified offset.
        /// </summary>
        IDocumentLine GetLineByOffset(int offset);

        /// <summary>
        /// Gets the offset from a text location.
        /// </summary>
        /// <seealso cref="GetLocation"/>
        int GetOffset(int line, int column);

        /// <summary>
        /// Gets the offset from a text location.
        /// </summary>
        /// <seealso cref="GetLocation"/>
        int GetOffset(TextLocation location);

        /// <summary>
        /// Gets the location from an offset.
        /// </summary>
        /// <seealso cref="GetOffset(TextLocation)"/>
        TextLocation GetLocation(int offset);

        /// <summary>
        /// Inserts text.
        /// </summary>
        /// <param name="offset">The offset at which the text is inserted.</param>
        /// <param name="text">The new text.</param>
        /// <remarks>
        /// Anchors positioned exactly at the insertion offset will move according to their movement type.
        /// For AnchorMovementType.Default, they will move behind the inserted text.
        /// The caret will also move behind the inserted text.
        /// </remarks>
        void Insert(int offset, string text);

        /// <summary>
        /// Inserts text.
        /// </summary>
        /// <param name="offset">The offset at which the text is inserted.</param>
        /// <param name="text">The new text.</param>
        /// <remarks>
        /// Anchors positioned exactly at the insertion offset will move according to their movement type.
        /// For AnchorMovementType.Default, they will move behind the inserted text.
        /// The caret will also move behind the inserted text.
        /// </remarks>
        void Insert(int offset, ITextSource text);

        /// <summary>
        /// Inserts text.
        /// </summary>
        /// <param name="offset">The offset at which the text is inserted.</param>
        /// <param name="text">The new text.</param>
        /// <param name="defaultAnchorMovementType">
        /// Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
        /// For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
        /// The caret will also move according to the <paramref name="defaultAnchorMovementType"/> parameter.
        /// </param>
        void Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType);

        /// <summary>
        /// Inserts text.
        /// </summary>
        /// <param name="offset">The offset at which the text is inserted.</param>
        /// <param name="text">The new text.</param>
        /// <param name="defaultAnchorMovementType">
        /// Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
        /// For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
        /// The caret will also move according to the <paramref name="defaultAnchorMovementType"/> parameter.
        /// </param>
        void Insert(int offset, ITextSource text, AnchorMovementType defaultAnchorMovementType);

        /// <summary>
        /// Removes text.
        /// </summary>
        /// <param name="offset">Starting offset of the text to be removed.</param>
        /// <param name="length">Length of the text to be removed.</param>
        void Remove(int offset, int length);

        /// <summary>
        /// Replaces text.
        /// </summary>
        /// <param name="offset">The starting offset of the text to be replaced.</param>
        /// <param name="length">The length of the text to be replaced.</param>
        /// <param name="newText">The new text.</param>
        void Replace(int offset, int length, string newText);

        /// <summary>
        /// Replaces text.
        /// </summary>
        /// <param name="offset">The starting offset of the text to be replaced.</param>
        /// <param name="length">The length of the text to be replaced.</param>
        /// <param name="newText">The new text.</param>
        void Replace(int offset, int length, ITextSource newText);

        /// <summary>
        /// Make the document combine the following actions into a single
        /// action for undo purposes.
        /// </summary>
        void StartUndoableAction();

        /// <summary>
        /// Ends the undoable action started with <see cref="StartUndoableAction"/>.
        /// </summary>
        void EndUndoableAction();

        /// <summary>
        /// Creates an undo group. Dispose the returned value to close the undo group.
        /// </summary>
        /// <returns>An object that closes the undo group when Dispose() is called.</returns>
        IDisposable OpenUndoGroup();

        /// <summary>
        /// Creates a new <see cref="ITextAnchor"/> at the specified offset.
        /// </summary>
        /// <inheritdoc cref="ITextAnchor" select="remarks|example"/>
        ITextAnchor CreateAnchor(int offset);

        /// <summary>
        /// Gets the name of the file the document is stored in.
        /// Could also be a non-existent dummy file name or null if no name has been set.
        /// </summary>
        string FileName { get; }

        /// <summary>
        /// Fired when the file name of the document changes.
        /// </summary>
        event EventHandler FileNameChanged;
    }

    /// <summary>
    /// A line inside a <see cref="IDocument"/>.
    /// </summary>
    public interface IDocumentLine : ISegment
    {
        /// <summary>
        /// Gets the length of this line, including the line delimiter.
        /// </summary>
        int TotalLength { get; }

        /// <summary>
        /// Gets the length of the line terminator.
        /// Returns 1 or 2; or 0 at the end of the document.
        /// </summary>
        int DelimiterLength { get; }

        /// <summary>
        /// Gets the number of this line.
        /// The first line has the number 1.
        /// </summary>
        int LineNumber { get; }

        /// <summary>
        /// Gets the previous line. Returns null if this is the first line in the document.
        /// </summary>
        IDocumentLine PreviousLine { get; }

        /// <summary>
        /// Gets the next line. Returns null if this is the last line in the document.
        /// </summary>
        IDocumentLine NextLine { get; }

        /// <summary>
        /// Gets whether the line was deleted.
        /// </summary>
        bool IsDeleted { get; }
    }

    /// <summary>
    /// Describes a change of the document text.
    /// This class is thread-safe.
    /// </summary>
    public class TextChangeEventArgs : EventArgs
    {
        /// <summary>
        /// The offset at which the change occurs.
        /// </summary>
        public int Offset { get; }

        /// <summary>
        /// The text that was removed.
        /// </summary>
        public ITextSource RemovedText { get; }

        /// <summary>
        /// The number of characters removed.
        /// </summary>
        public int RemovalLength => RemovedText.TextLength;

        /// <summary>
        /// The text that was inserted.
        /// </summary>
        public ITextSource InsertedText { get; }

        /// <summary>
        /// The number of characters inserted.
        /// </summary>
        public int InsertionLength => InsertedText.TextLength;

        /// <summary>
        /// Creates a new TextChangeEventArgs object.
        /// </summary>
        public TextChangeEventArgs(int offset, string removedText, string insertedText)
        {
            if (offset < 0)
                throw new ArgumentOutOfRangeException(nameof(offset), offset, "offset must not be negative");
            Offset = offset;
            RemovedText = removedText != null ? new StringTextSource(removedText) : StringTextSource.Empty;
            InsertedText = insertedText != null ? new StringTextSource(insertedText) : StringTextSource.Empty;
        }

        /// <summary>
        /// Creates a new TextChangeEventArgs object.
        /// </summary>
        public TextChangeEventArgs(int offset, ITextSource removedText, ITextSource insertedText)
        {
            if (offset < 0)
                throw new ArgumentOutOfRangeException(nameof(offset), offset, "offset must not be negative");
            Offset = offset;
            RemovedText = removedText ?? StringTextSource.Empty;
            InsertedText = insertedText ?? StringTextSource.Empty;
        }

        /// <summary>
        /// Gets the new offset where the specified offset moves after this document change.
        /// </summary>
        public virtual int GetNewOffset(int offset, AnchorMovementType movementType = AnchorMovementType.Default)
        {
            if (offset >= Offset && offset <= Offset + RemovalLength)
            {
                if (movementType == AnchorMovementType.BeforeInsertion)
                    return Offset;
                return Offset + InsertionLength;
            }
            if (offset > Offset)
            {
                return offset + InsertionLength - RemovalLength;
            }
            return offset;
        }

        /// <summary>
        /// Creates TextChangeEventArgs for the reverse change.
        /// </summary>
        public virtual TextChangeEventArgs Invert()
        {
            return new TextChangeEventArgs(Offset, InsertedText, RemovedText);
        }
    }
}