text:
'use strict';
var path = require('path');
var fs = require('fs');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-generator').assert;

describe('license', function() {
  before(function(done) {
    helpers.run(path.join(__dirname, '../generators/license'))
      .on('end', done);
  });

  it('should generate the LICENSE', function() {
    assert.file('LICENSE');
    assert.fileContent('LICENSE', 'Copyright');
  });
});

redpajama_set_name: RedPajamaGithub


text:
These samples demonstrate usage of the google-cloud-compute library to interact
with the Google Compute Engine API.

## Running the quickstart script

### Before you begin

1. If you haven't already, set up a Python Development Environment by following the [python setup guide](https://cloud.google.com/python/setup) and
[create a project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project).

1. Use `gcloud auth application-default login` to allow the script to authenticate using
your credentials to the Google Cloud APIs.

### Install requirements

Create a new virtual environment and install the required libraries.
```bash
virtualenv --python python3 name-of-your-virtualenv
source name-of-your-virtualenv/bin/activate
pip install -r ../requirements.txt
```

### Run the demo

Run the quickstart script, it will create and destroy a `n1-standard-1`
type machine in the `europe-central2-b` zone.
```bash
python quickstart.py
```


text:
/**
 *
 */
package io.pratik.elasticsearch.services;

import java.util.List;

import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.stereotype.Service;

import io.pratik.elasticsearch.models.Product;
import io.pratik.elasticsearch.repositories.ProductRepository;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Pratik Das
 *
 */
@Service
@Slf4j
public class SearchService {

	private  ProductRepository productRepository;

	private  ElasticsearchOperations elasticsearchOperations;

	@Autowired
	public SearchService(ProductRepository productRepository, ElasticsearchOperations elasticsearchOperations) {
		super();
		this.productRepository = productRepository;
		this.elasticsearchOperations = elasticsearchOperations;
	}

	public List<Product> fetchProductNames(final String name){

		return productRepository.findByManufacturerAndCategory(name, "");
	}

	public List<Product> fetchProductNamesContaining(final String name){

		return productRepository.findByNameContaining(name);
	}

}


text:
require 'remockable/active_model/helpers'

require 'remockable/active_model/allow_values_for'
require 'remockable/active_model/validate_acceptance_of'
require 'remockable/active_model/validate_confirmation_of'
require 'remockable/active_model/validate_exclusion_of'
require 'remockable/active_model/validate_format_of'
require 'remockable/active_model/validate_inclusion_of'
require 'remockable/active_model/validate_length_of'
require 'remockable/active_model/validate_numericality_of'
require 'remockable/active_model/validate_presence_of'


text:
package mekanism.common.tile;

import mekanism.common.content.tank.DynamicFluidTank;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.PipeUtils;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;

public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFluidHandler
{
	public DynamicFluidTank fluidTank;

	public TileEntityDynamicValve()
	{
		super("Dynamic Valve");
		fluidTank = new DynamicFluidTank(this);
	}

	@Override
	public FluidTankInfo[] getTankInfo(ForgeDirection from)
	{
		return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY;
	}

	@Override
	public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
	{
		return fluidTank.fill(resource, doFill);
	}

	@Override
	public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
	{
		if(structure != null && structure.fluidStored != null)
		{
			if(resource.getFluid() == structure.fluidStored.getFluid())
			{
				return fluidTank.drain(resource.amount, doDrain);
			}
		}

		return null;
	}

	@Override
	public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
	{
		if(structure != null)
		{
			return fluidTank.drain(maxDrain, doDrain);
		}

		return null;
	}

	@Override
	public boolean canFill(ForgeDirection from, Fluid fluid)
	{
		return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure));
	}

	@Override
	public boolean canDrain(ForgeDirection from, Fluid fluid)
	{
		return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure));
	}

	@Override
	public String getInventoryName()
	{
		return MekanismUtils.localize("gui.dynamicTank");
	}
}


text:
import { h, render, Component } from 'preact';

// Module constants (change according to your flavor file)
var footerStickyClassName = 'sticky';

// Footer component.
export function Footer(attributes){
	var outProps = Object.assign({},attributes);
	if (typeof outProps.sticky === 'undefined') outProps.sticky = false;
	if (outProps.sticky)
		if (typeof outProps.className === 'undefined') outProps.className = footerStickyClassName;
		else outProps.className += ' ' + footerStickyClassName;
	delete outProps.sticky;
	return h(
		'footer',outProps, outProps.children
	);
}


text:
import * as React from 'react';
import * as ReactDom from 'react-dom';
import {
  IPropertyPaneField,
  PropertyPaneFieldType,
  IPropertyPaneCustomFieldProps
} from '@microsoft/sp-webpart-base';
import PropertyFieldSliderRangeHost, { IPropertyFieldSliderRangeHostProps } from './PropertyFieldSliderRangeHost';
import { SPComponentLoader } from '@microsoft/sp-loader';
import { Async } from 'office-ui-fabric-react/lib/Utilities';

/**
 * @interface
 * Public properties of the PropertyFieldSliderRange custom field
 *
 */
export interface IPropertyFieldSliderRangeProps {
  /**
   * @var
   * Property field label displayed on top
   */
  label: string;
  /**
   * @var
   * Initial value
   */
  initialValue?: string;
  /**
   * @var
   * Disables the slider if set to true. Default is false.
   */
  disabled?: boolean;
  /**
   * @var
   * The minimum value of the slider. Default is 0.
   */
  min?: number;
  /**
   * @var
   * The maximum value of the slider. Default is 100.
   */
  max?: number;
  /**
   * @var
   * Default 1 - Determines the size or amount of each interval or step the
   * slider takes between the min and max. The full specified value range of the
   * slider (max - min) should be evenly divisible by the step.
   */
  step?: number;
  /**
   * @var
   * Determines whether the slider handles move horizontally (min on left,
   * max on right) or vertically (min on bottom, max on top).
   * Possible values: "horizontal", "vertical".
   */
  orientation?: string;
  /**
   * @var
   * Display the value on left & right of the slider or not
   */
  showValue?: boolean;
  /**
   * @function
   * Defines a onPropertyChange function to raise when the selected Color changed.
   * Normally this function must be always defined with the 'this.onPropertyChange'
   * method of the web part object.
   */
  onPropertyChange(propertyPath: string, oldValue: any, newValue: any): void;
  /**
   * @function
   * This API is called to render the web part.
   * Normally this function must be always defined with the 'this.render.bind(this)'
   * method of the web part object.
   */
  render(): void;
  /**
   * This property is used to indicate the web part's PropertyPane interaction mode: Reactive or NonReactive.
   * The default behaviour is Reactive.
   */
  disableReactivePropertyChanges?: boolean;
  /**
   * @var
   * Parent Web Part properties
   */
  properties: any;
  /**
   * @var
   * An UNIQUE key indicates the identity of this control
   */
  key?: string;
  /**
   * The method is used to get the validation error message and determine whether the input value is valid or not.
   *
   *   When it returns string:
   *   - If valid, it returns empty string.
   *   - If invalid, it returns the error message string and the text field will
   *     show a red border and show an error message below the text field.
   *
   *   When it returns Promise<string>:
   *   - The resolved value is display as error message.
   *   - The rejected, the value is thrown away.
   *
   */
   onGetErrorMessage?: (value: string) => string | Promise<string>;
   /**
    * Custom Field will start to validate after users stop typing for `deferredValidationTime` milliseconds.
    * Default value is 200.
    */
   deferredValidationTime?: number;
}

/**
 * @interface
 * Private properties of the PropertyFieldSliderRange custom field.
 * We separate public & private properties to include onRender & onDispose method waited
 * by the PropertyFieldCustom, witout asking to the developer to add it when he's using
 * the PropertyFieldSliderRange.
 *
 */
export interface IPropertyFieldSliderRangePropsInternal extends IPropertyPaneCustomFieldProps {
  label: string;
  initialValue?: string;
  targetProperty: string;
  showValue?: boolean;
  guid: string;
  disabled?: boolean;
  min?: number;
  max?: number;
  step?: number;
  orientation?: string;
  onRender(elem: HTMLElement): void;
  onDispose(elem: HTMLElement): void;
  onPropertyChange(propertyPath: string, oldValue: any, newValue: any): void;
  render(): void;
  disableReactivePropertyChanges?: boolean;
  properties: any;
  onGetErrorMessage?: (value: string) => string | Promise<string>;
  deferredValidationTime?: number;
}

/**
 * @interface
 * Represents a PropertyFieldSliderRange object
 *
 */
class PropertyFieldSliderRangeBuilder implements IPropertyPaneField<IPropertyFieldSliderRangePropsInternal> {

  //Properties defined by IPropertyPaneField
  public type: PropertyPaneFieldType = PropertyPaneFieldType.Custom;
  public targetProperty: string;
  public properties: IPropertyFieldSliderRangePropsInternal;

  //Custom properties
  private label: string;
  private initialValue: string;
  private guid: string;
  private disabled: boolean;
  private min: number;
  private max: number;
  private step: number;
  private orientation: string;
  private showValue: boolean;

  private onPropertyChange: (propertyPath: string, oldValue: any, newValue: any) => void;
  private customProperties: any;
  private key: string;
  private onGetErrorMessage: (value: string) => string | Promise<string>;
  private deferredValidationTime: number = 200;
  private renderWebPart: () => void;
  private disableReactivePropertyChanges: boolean = false;

  private latestValidateValue: string;
  private async: Async;
  private delayedValidate: (value: string) => void;

  /**
   * @function
   * Ctor
   */
  public constructor(_targetProperty: string, _properties: IPropertyFieldSliderRangePropsInternal) {
    this.render = this.render.bind(this);
    this.targetProperty = _properties.targetProperty;
    this.properties = _properties;
    this.label = _properties.label;
    this.initialValue = _properties.initialValue;
    this.disabled = _properties.disabled;
    this.min = _properties.min;
    this.max = _properties.max;
    this.step = _properties.step;
    this.showValue = _properties.showValue;
    this.orientation = _properties.orientation;
    this.guid = _properties.guid;
    this.properties.onDispose = this.dispose;
    this.properties.onRender = this.render;
    this.onPropertyChange = _properties.onPropertyChange;
    this.customProperties = _properties.properties;
    this.key = _properties.key;
    this.onGetErrorMessage = _properties.onGetErrorMessage;
    if (_properties.deferredValidationTime !== undefined)
      this.deferredValidationTime = _properties.deferredValidationTime;
    this.renderWebPart = _properties.render;
    if (_properties.disableReactivePropertyChanges !== undefined && _properties.disableReactivePropertyChanges != null)
      this.disableReactivePropertyChanges = _properties.disableReactivePropertyChanges;

    this.async = new Async(this);
    this.validate = this.validate.bind(this);
    this.notifyAfterValidate = this.notifyAfterValidate.bind(this);
    this.delayedValidate = this.async.debounce(this.validate, this.deferredValidationTime);

    SPComponentLoader.loadCss('//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css');
  }

  /**
   * @function
   * Renders the ColorPicker field content
   */
  private render(elem: HTMLElement): void {

    //Construct the JSX properties
    const element: React.ReactElement<IPropertyFieldSliderRangeHostProps> = React.createElement(PropertyFieldSliderRangeHost, {
      label: this.label,
      initialValue: this.initialValue,
      targetProperty: this.targetProperty,
      disabled: this.disabled,
      min: this.min,
      max: this.max,
      step: this.step,
      orientation: this.orientation,
      showValue: this.showValue,
      onDispose: this.dispose,
      onRender: this.render,
      onPropertyChange: this.onPropertyChange,
      guid: this.guid,
      properties: this.customProperties,
      key: this.key,
      onGetErrorMessage: this.onGetErrorMessage,
      deferredValidationTime: this.deferredValidationTime,
      render: this.renderWebPart,
      disableReactivePropertyChanges: this.disableReactivePropertyChanges
    });
    //Calls the REACT content generator
    ReactDom.render(element, elem);

    var jQueryCdn = '//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js';
    var jQueryUICdn = '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js';

    SPComponentLoader.loadScript(jQueryCdn, { globalExportsName: '$' }).then(($: any): void => {
      SPComponentLoader.loadScript(jQueryUICdn, { globalExportsName: '$' }).then((jqueryui: any): void => {
          ($ as any)('#' + this.guid + '-slider').slider({
            range: true,
            min: this.min != null ? this.min : 0,
            max: this.max != null ? this.max : 100,
            step: this.step != null ? this.step : 1,
            disabled: this.disabled != null ? this.disabled : false,
            orientation: this.orientation != null ? this.orientation : 'horizontal',
            values: (this.initialValue != null && this.initialValue != '' && this.initialValue.split(",").length == 2) ? [ Number(this.initialValue.split(",")[0]), Number(this.initialValue.split(",")[1]) ] : [this.min, this.max],
            slide: function( event, ui ) {
              var value: string = ui.values[ 0 ] + "," + ui.values[ 1];
              this.delayedValidate(value);
              /*if (this.onPropertyChange && value != null) {
                this.customProperties[this.targetProperty] = value;
                this.onPropertyChange(this.targetProperty, this.initialValue, value);
              }*/
              ($ as any)('#' + this.guid + '-min').html(ui.values[0]);
              ($ as any)('#' + this.guid + '-max').html(ui.values[1]);
            }.bind(this)
          });
      });
    });
  }

  /**
   * @function
   * Validates the new custom field value
   */
  private validate(value: string): void {
    if (this.onGetErrorMessage === null || this.onGetErrorMessage === undefined) {
      this.notifyAfterValidate(this.initialValue, value);
      return;
    }

    if (this.latestValidateValue === value)
      return;
    this.latestValidateValue = value;

    var result: string | PromiseLike<string> = this.onGetErrorMessage(value || '');
    if (result !== undefined) {
      if (typeof result === 'string') {
        if (result === undefined || result === '')
          this.notifyAfterValidate(this.initialValue, value);
        ((document.getElementById(this.guid + '-errorMssg1')) as any).innerHTML = result;
        ((document.getElementById(this.guid + '-errorMssg2')) as any).innerHTML = result;
      }
      else {
        result.then((errorMessage: string) => {
          if (errorMessage === undefined || errorMessage === '')
            this.notifyAfterValidate(this.initialValue, value);
          ((document.getElementById(this.guid + '-errorMssg1')) as any).innerHTML = errorMessage;
          ((document.getElementById(this.guid + '-errorMssg2')) as any).innerHTML = errorMessage;
        });
      }
    }
    else {
      this.notifyAfterValidate(this.initialValue, value);
    }
  }

  /**
   * @function
   * Notifies the parent Web Part of a property value change
   */
  private notifyAfterValidate(oldValue: string, newValue: string) {
    if (this.onPropertyChange && newValue != null) {
      this.customProperties[this.targetProperty] = newValue;
      this.onPropertyChange(this.targetProperty, this.properties.initialValue, newValue);
      if (!this.disableReactivePropertyChanges && this.renderWebPart != null)
        this.renderWebPart();
    }
  }

  /**
   * @function
   * Disposes the current object
   */
  private dispose(elem: HTMLElement): void {
    if (this.async !== undefined)
      this.async.dispose();
  }

}

function s4(): string {
    return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}

function getGuid(): string {
    return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
      s4() + '-' + s4() + s4() + s4();
}

/**
 * @function
 * Helper method to create the customer field on the PropertyPane.
 * @param targetProperty - Target property the custom field is associated to.
 * @param properties - Strongly typed custom field properties.
 */
export function PropertyFieldSliderRange(targetProperty: string, properties: IPropertyFieldSliderRangeProps): IPropertyPaneField<IPropertyFieldSliderRangePropsInternal> {

    //Create an internal properties object from the given properties
    var newProperties: IPropertyFieldSliderRangePropsInternal = {
      label: properties.label,
      targetProperty: targetProperty,
      initialValue: properties.initialValue,
      disabled: properties.disabled,
      min: properties.min,
      max: properties.max,
      step: properties.step,
      showValue: properties.showValue,
      orientation: properties.orientation,
      guid: getGuid(),
      onPropertyChange: properties.onPropertyChange,
      properties: properties.properties,
      onDispose: null,
      onRender: null,
      key: properties.key,
      onGetErrorMessage: properties.onGetErrorMessage,
      deferredValidationTime: properties.deferredValidationTime,
      render: properties.render,
      disableReactivePropertyChanges: properties.disableReactivePropertyChanges
    };
    //Calls the PropertyFieldSliderRange builder object
    //This object will simulate a PropertyFieldCustom to manage his rendering process
    return new PropertyFieldSliderRangeBuilder(targetProperty, newProperties);
}


text:
package hudson.tasks;

import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.Action;
import hudson.model.Project;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.Launcher;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;

/**
 * Provides compatibility with {@link BuildStep} before 1.150 so that old plugin
 * binaries can continue to function with new Hudson.
 *
 * @author Kohsuke Kawaguchi
 * @since 1.150
 * @deprecated since 1.150
 */
public abstract class BuildStepCompatibilityLayer implements BuildStep {
//
// new definitions >= 1.150
//

    public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
        if (build instanceof Build) {
            return prebuild((Build) build, listener);
        } else {
            return true;
        }
    }

    public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
        if (build instanceof Build) {
            return perform((Build) build, launcher, listener);
        } else {
            return true;
        }
    }

    public Action getProjectAction(AbstractProject<?, ?> project) {
        if (project instanceof Project) {
            return getProjectAction((Project) project);
        } else {
            return null;
        }
    }

    public Collection<? extends Action> getProjectActions(AbstractProject<?, ?> project) {
        // delegate to getJobAction (singular) for backward compatible behavior
        Action a = getProjectAction(project);
        if (a == null) {
            return Collections.emptyList();
        }
        return Collections.singletonList(a);
    }

//
// old definitions < 1.150
//
    /**
     * @deprecated Use {@link #prebuild(AbstractBuild, BuildListener)} instead.
     */
    public boolean prebuild(Build<?, ?> build, BuildListener listener) {
        return true;
    }

    /**
     * @deprecated Use {@link #perform(AbstractBuild, Launcher, BuildListener)}
     * instead.
     */
    public boolean perform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
        throw new UnsupportedOperationException();
    }

    /**
     * @deprecated Use {@link #getProjectAction(AbstractProject)} instead.
     */
    public Action getProjectAction(Project<?, ?> project) {
        return null;
    }
}


text:
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../../helpers/start-app';
import Person from '../../../models/person';
import Group from '../../../models/group';
import Post from '../../../models/post';
import Comment from '../../../models/comment';
import DjangoTastypieSerializer from 'ember-data-tastypie-adapter/serializers/dta';
import DjangoTastypieAdapter from 'ember-data-tastypie-adapter/adapters/dta';

var application;
var store;
var adapter;
var passedUrl, passedVerb, passedHash;
var run = Ember.run;

module('Acceptance: AdaptersDjangoTastypieAdapter', {
  beforeEach: function() {
    application = startApp({'namespace': 'api/v1'});

    store = application.__container__.lookup('service:store');
    adapter = application.__container__.lookup('adapter:application');

    passedUrl = passedVerb = passedHash = null;
  },
  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

function ajaxResponse(value) {
  adapter.reopen({
    ajax: function(url, verb, hash) {
      passedUrl = url;
      passedVerb = verb;
      passedHash = hash;

      return run(Ember.RSVP, 'resolve', value);
    }
  });
}

var expectUrl = function(assert, url, desc) {
  assert.equal(passedUrl, url, "the URL is: " + url);
};

var expectType = function(assert, type) {
  assert.equal(passedVerb, type, "the HTTP method is: " + type);
};

var expectData = function(assert, hash) {
  assert.deepEqual(passedHash.data, hash, "the hash was passed along");
};

var expectState = function(assert, model, state, value) {
  if (value === undefined) { value = true; }

  var flag = "is" + state.charAt(0).toUpperCase() + state.substr(1);
  assert.equal(model.get(flag), value, "the person is " + (value === false ? "not " : "") + state);
};

test("can create a record", function(assert) {
  run(function() {
    var record = store.createRecord('person');
    record.set('name', 'bar');

    assert.equal(record.get('name'), 'bar', "property was set on the record");
  });
});

test("find - basic payload", function (assert) {
  var id = $.mockjax({
    url: '/api/v1/person/1/',
    status: 200,
    responseText: {id: 1, name: "Rails is omakase", resource_uri: '/api/v1/person/1/'}
  });
  stop();
  run(store, 'find', 'person', 1).then(function (person) {
    assert.equal($.mockjax.mockedAjaxCalls().length, 1);
    assert.equal(person.get('id'), "1");
    assert.equal(person.get('name'), "Rails is omakase");

    $.mockjax.clear(id);
    start();
  });
});

test("creating a person makes a POST to /api/v1/person, with the data hash", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'POST',
    status: 200,
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.equal(data['name'], "Tom Dale");
      this.responseText = {id: 1, name: "Tom Dale", resource_uri: '/api/v1/person/1/'};
    }
  });

  stop();
  run(function() {
    var person = store.createRecord('person', {name: 'Tom Dale'});

    person.save().then(function(person) {
      assert.equal(person.get('id'), "1", "the post has the updated ID");
      assert.equal(person.get('isDirty'), false, "the post isn't dirty anymore");

      $.mockjax.clear(id);
      start();
    });
  });
});

test("updating a person makes a PUT to /people/:id with the data hash", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/1/',
    type: 'PUT',
    status: 200,
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.equal(data['name'], "Brohuda Brokatz");
      this.responseText = {id: 1, name: "Brohuda Brokatz", resource_uri: '/api/v1/person/1/'};
    }
  });

  adapter.set('bulkCommit', false);

  stop();
  run(store, 'push', 'person', { id: 1, name: "Yehuda Katz" });

  run(store, 'find', 'person', 1).then(function(person) {
    person.set('name', "Brohuda Brokatz");
    return person.save();
  }).then(function(person) {
    assert.equal(person.get('id'), "1");
    assert.equal(person.get('isDirty'), false, "the person isn't dirty anymore");
    assert.equal(person.get('name'), "Brohuda Brokatz");

    $.mockjax.clear(id);
    start();
  });

});

test("updates are not required to return data", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/1/',
    type: 'PUT',
    status: 200,
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.equal(data['name'], "Brohuda Brokatz");
      this.responseText = null;
    }
  });

  adapter.set('bulkCommit', false);

  stop();
  run(store, 'push', 'person', { id: 1, name: "Yehuda Katz" });

  var _person;

  run(store, 'find', 'person', 1).then(function(person) {
    expectState(assert, person, 'new', false);
    expectState(assert, person, 'loaded');
    expectState(assert, person, 'dirty', false);

    _person = person;

    person.set('name', "Brohuda Brokatz");
    expectState(assert, person, 'dirty');

    return person.save();
  }).then(function(person) {
    expectState(assert, person, 'saving', false);

    assert.equal(_person, store.getById('person', 1), "the same person is retrieved by the same ID");
    assert.equal(person.get('name'), "Brohuda Brokatz", "the data is preserved");

    $.mockjax.clear(id);
    start();
  });

});

test("deleting a person makes a DELETE to /api/v1/person/:id/", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/1/',
    type: 'DELETE',
    status: 200,
    responseText: null
  });

  adapter.set('bulkCommit', false);

  stop();
  run(store, 'push', 'person', { id: 1, name: "Tom Dale" });

  run(store, 'find', 'person', 1).then(function(person) {
    person.deleteRecord();
    return person.save();
  }).then(function(person) {
    assert.equal(person.get('isDirty'), false, "the post isn't dirty anymore");
    assert.equal(person.get('isDeleted'), true, "the post is now deleted");

    $.mockjax.clear(id);
    start();
  });
});

test("finding all people makes a GET to /api/v1/person/", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    responseText: {"objects": [{ id: 1, name: "Yehuda Katz", resource_uri: '/api/v1/person/1/' }]}
  });

  stop();
  run(store, 'find', 'person').then(function(people) {
    var person = people.objectAt(0);

    expectState(assert, person, 'loaded');
    expectState(assert, person, 'dirty', false);

    assert.equal(person, store.getById('person', 1), "the record is now in the store, and can be looked up by ID without another Ajax request");
    assert.equal($.mockjax.mockedAjaxCalls().length, 1);

    $.mockjax.clear(id);
    start();
  });
});

test("since gets set if needed for pagination", function(assert) {

  var callCount = 0;
  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    response: function(settings) {
      if (callCount === 0) {
        this.responseText = {
          objects: [{id: 1, name: "Roy", resource_uri: '/api/v1/person/1/'}, {
            id: 2,
            name: "Moss",
            resource_uri: '/api/v1/person/2/'
          }],
          meta: {limit: 2, next: "nextUrl&offset=2", offset: 0, previous: null, total_count: 25}
        };
        callCount++;
      } else {
        this.responseText = {
          objects: [{id: 3, name: "Roy", resource_uri: '/api/v1/person/3/'}, {
            id: 4,
            name: "Moss",
            resource_uri: '/api/v1/person/4/'
          }],
          meta: {limit: 2, next: "nextUrl&offset=4", offset: 2, previous: "previousUrl&offset=0", total_count: 25}
        };
        assert.equal(settings.data.offset, 2, "Offset is 2");
      }
    }
  });

  stop();
  run(function() {
    store.find('person').then(function(people) {
      assert.equal(people.get('meta.offset', 0, "Offset is set"));
      assert.equal(people.get('meta.next', "nextUrl&offset=2", "Next is set"));
      assert.equal(people.get('meta.totalCount', 25, "Total count is correct"));

      return store.find('person');
    }).then(function(morePeople) {
      assert.equal(store.metadataFor('person').offset, 2, "Offset is correct");

      $.mockjax.clear(id);
      start();
    });
  });

});

test("finding a person by ID makes a GET to /api/v1/person/:id/", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/1/',
    type: 'GET',
    responseText: {id: 1, name: "Yehuda Katz", resource_uri: '/api/v1/person/1/'}
  });

  stop();
  run(store, 'find', 'person', 1).then(function(person) {
    expectState(assert, person, 'loaded', true);
    expectState(assert, person, 'dirty', false);

    assert.equal(person, store.getById('person', 1), "the record is now in the store, and can be looked up by ID without another Ajax request");
    assert.equal($.mockjax.mockedAjaxCalls().length, 1);

    $.mockjax.clear(id);
    start();
  });
});

test("findByIds generates a tastypie style url", function(assert) {

  var id = $.mockjax({
    url: '/api/v1/person/set/*/',
    type: 'GET',
    response: function(settings) {
      assert.equal(settings.url, "/api/v1/person/set/1;2;3/");
      this.responseText = { objects: [
        { id: 1, name: "Rein Heinrichs", resource_uri: '/api/v1/person/1/'},
        { id: 2, name: "Tom Dale", resource_uri: '/api/v1/person/2/' },
        { id: 3, name: "Yehuda Katz", resource_uri: '/api/v1/person/3/' }
      ]};
    }
  });

  stop();

  run(function() {
    application.registry.register('adapter:person', DjangoTastypieAdapter.extend({
      coalesceFindRequests: true
    }));
  });

  run(store, 'findByIds', 'person', [1, 2, 3]).then(function(people) {
    var rein = store.getById('person', 1),
        tom = store.getById('person', 2),
        yehuda = store.getById('person', 3);

    assert.deepEqual(rein.getProperties('id', 'name'), { id: "1", name: "Rein Heinrichs" });
    assert.deepEqual(tom.getProperties('id', 'name'), { id: "2", name: "Tom Dale" });
    assert.deepEqual(yehuda.getProperties('id', 'name'), { id: "3", name: "Yehuda Katz" });

    application.registry.unregister('adapter:person');
    $.mockjax.clear(id);
    start();
  });
});

test("finding many people by a list of IDs", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/set/*/',
    type: 'GET',
    response: function(settings) {
      assert.equal(settings.url, "/api/v1/person/set/1;2;3/");
      this.responseText = { objects: [
        { id: 1, name: "Rein Heinrichs", resource_uri: '/api/v1/person/1/'},
        { id: 2, name: "Tom Dale", resource_uri: '/api/v1/person/2/' },
        { id: 3, name: "Yehuda Katz", resource_uri: '/api/v1/person/3/' }
      ]};
    }
  });

  stop();
  Group.reopen({ people: DS.hasMany('person', { async: true }) });

  run(function() {
    application.registry.register('adapter:person', DjangoTastypieAdapter.extend({
      coalesceFindRequests: true
    }));
  });

  run(store, 'push', 'group', { id: 1, name: "Group 1", people: [1, 2, 3]});

  run(store, 'find', 'group', 1).then(function(group) {
    assert.ok(true, "passed");

    return group.get('people');
  }).then(function(people) {

    var rein = store.getById('person', 1),
        tom = store.getById('person', 2),
        yehuda = store.getById('person', 3);

    assert.deepEqual(rein.getProperties('id', 'name'), { id: "1", name: "Rein Heinrichs" });
    assert.deepEqual(tom.getProperties('id', 'name'), { id: "2", name: "Tom Dale" });
    assert.deepEqual(yehuda.getProperties('id', 'name'), { id: "3", name: "Yehuda Katz" });

    assert.deepEqual(people.toArray(), [ rein, tom, yehuda ], "The correct records are in the array");

    application.registry.unregister('adapter:person');
    $.mockjax.clear(id);
    start();
  });
});

test("finding people by a query", function(assert) {
  var people, rein, tom, yehuda;

  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    status: 200,
    response: function(settings) {
      assert.equal(settings.data.page, 1);

      this.responseText = {
        objects: [
          { id: 1, name: "Rein Heinrichs", resource_uri: '/api/v1/person/1/' },
          { id: 2, name: "Tom Dale", resource_uri: '/api/v1/person/2/' },
          { id: 3, name: "Yehuda Katz", resource_uri: '/api/v1/person/3/' }
        ]
      };
    }
  });

  stop();
  run(store, 'find', 'person', {page: 1}).then(function(people) {
    assert.equal(people.get('length'), 3, "the people are now loaded");

    rein = people.objectAt(0);
    assert.equal(rein.get('name'), "Rein Heinrichs");
    assert.equal(rein.get('id'), 1);

    tom = people.objectAt(1);
    assert.equal(tom.get('name'), "Tom Dale");
    assert.equal(tom.get('id'), 2);

    yehuda = people.objectAt(2);
    assert.equal(yehuda.get('name'), "Yehuda Katz");
    assert.equal(yehuda.get('id'), 3);

    people.forEach(function(person) {
      assert.equal(person.get('isLoaded'), true, "the person is being loaded");
    });

    $.mockjax.clear(id);
    start();
  });
});

test("creating an item with a belongsTo relationship urlifies the Resource URI (default key)", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/task/',
    type: 'POST',
    status: 200,
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.deepEqual(data, { name: "Get a bike!", owner: "/api/v1/person/1/" }, "posted data is correct");
      this.responseText = null;
    }
  });

  stop();
  run(store, 'push', 'person', {id: 1, name: "Maurice Moss"});

  run(store, 'find', 'person', 1).then(function(person) {
    expectState(assert, person, 'new', false);
    expectState(assert, person, 'loaded');
    expectState(assert, person, 'dirty', false);

    var task = store.createRecord('task', {name: "Get a bike!"});
    expectState(assert, task, 'new', true);
    expectState(assert, task, 'dirty', true);
    task.set('owner', person);

    return task.save();
  }).then(function(task) {
    assert.ok(true);

    $.mockjax.clear(id);
    start();
  });

});

test("metadata is accessible", function (assert) {
  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    status: 200,
    responseText: {
      meta: { offset: 2, limit: 0 },
      objects: [
        {id: 1, name: "Maurice Moss"},
        {id: 2, name: "Roy"}
      ]
    }
});

  stop();
  run(function() {
    store.find('person').then(function (people) {
      assert.equal(store.metadataFor('person').offset,
          2,
          "Metadata can be accessed with metadataFor");

      $.mockjax.clear(id);
      start();
    });
  });
});

test("adding hasMany relationships parses the Resource URI (default key)", function(assert) {

  var id = $.mockjax({
    url: '/api/v1/group/1/',
    type: 'PUT',
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.deepEqual(data,  {name: "Team", people: ['/api/v1/person/1/', '/api/v1/person/2/']});
      this.responseText = null;
    }
  });

  Person.reopen({
    name: DS.attr('string'),
    group: DS.belongsTo('group', { async: true })
  });

  Group.reopen({
    people: DS.hasMany('person', { async: true })
  });

  stop();
  run(function () {
    store.push('person', {id: 1, name: "Maurice Moss"});
    store.push('person', {id: 2, name: "Roy"});
    store.push('group', {id: 1, name: "Team"});
  });

  run(function () {
    Ember.RSVP.hash({
      moss: store.find('person', 1),
      roy: store.find('person', 2),
      group: store.find('group', 1)
    }).then(function (objects) {
      var group = objects.group,
          people;

      return group.get('people').then(function (people) {
        people.pushObject(objects.moss);
        people.pushObject(objects.roy);

        return group.save();
      });
    }).
    then(function (data) {

      return store.find('person', 2);
    }).then(function (person) {
        assert.equal(person.get('name'), 'Roy');
        assert.equal(person.get('group').get('name'), 'Team');

        $.mockjax.clear(id);
        start();
    });
  });
});

test("async hasMany always returns a promise", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/comment/*',
    type: 'GET',
    status: 200,
    response: function(settings) {

      this.responseText = {
        objects: [
          { id: 1, text: "Rein Heinrichs", resource_uri: '/api/v1/comment/1/' },
          { id: 2, text: "Tom Dale", resource_uri: '/api/v1/comment/2/' }
        ]
      };

      $.mockjax.clear(id);
    }
  });

  Post.reopen({
    comments: DS.hasMany('comment', { async: true })
  });

  stop();
  run(function() {
    application.registry.register('adapter:comment', DjangoTastypieAdapter.extend({
      coalesceFindRequests: true
    }));
  });

  run(function() {
    store.push('post', { id: 1, text: "Some text", comments: ['1', '2']});

    store.find('post', 1).then(function(post) {
      assert.ok(post.get('comments') instanceof DS.PromiseArray, "comments is a promise");

      start();
    });
  });

});

test("sync hasMany find with full=True", function(assert) {

  Post.reopen({
    comments: DS.hasMany('comment', { async: false })
  });

  Comment.reopen({
    post: DS.belongsTo('post')
  });

  var id = $.mockjax({
    url: '/api/v1/post/1/',
    type: 'GET',
    responseText: {
      id: 1,
      text: "Some Text",
      comments: [
        {id: 1, text: 'Comment 1', post: '/api/v1/post/1/', resource_uri: '/api/v1/comment/1/'},
        {id: 2, text: 'Comment 2', post: '/api/v1/post/1/', resource_uri: '/api/v1/comment/2/'}
      ],
      resource_uri: '/api/v1/post/1/'
    }
  });

  stop();
  run(function() {
    store.find('post', 1).then(function(post) {
      assert.ok(post.get('comments') instanceof DS.ManyArray, "comments is not a promise");
      assert.ok(post.get('comments').isLoaded, "Comments are loaded");
      assert.equal(post.get('text'), "Some Text", "the post has the correct data");

      $.mockjax.clear(id);
      start();
    });
  });
});

test("sync hasMany save should not need to resolve relationship", function(assert) {
  var count = 0;
  var post;
  var id = $.mockjax({
    url: '/api/v1/post/1/',
    type: 'PUT',
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.deepEqual(data, {text: "New Text", comments: [
        { id: "1", body: null, children: [], root: false, text: 'Comment 1', post: '/api/v1/post/1/' },
        { id: "2", body: null, children: [], root: false, text: 'Comment 2', post: '/api/v1/post/1/' }
      ]});
      this.responseText = null;
    }
  });

  Post.reopen({
    comments: DS.hasMany('comment', { async: false })
  });

  Comment.reopen({
    post: DS.belongsTo('post', { async: false })
  });

  stop();
  run(function() {
    post = store.push('post', { id: 1, text: "Some text", comments: [1, 2]});
    store.push('comment', {id: 1, text: "Comment 1", post: post});
    store.push('comment', {id: 2, text: "Comment 2", post: post});

    application.registry.register('adapter:comment', DjangoTastypieAdapter.extend({
      findMany: function() {
        assert.ok(false, "Should not get here.");
      }
    }));
  });

  run(function() {
    store.find('post', 1).then(function(post) {
      post.set('text', 'New Text');

      assert.equal(post.get('isDirty'), true, "the post dirty");

      return post.save();
    }).then(function(post) {
      assert.equal(post.get('isDirty'), false, "the post is not dirty anymore");
      assert.equal(post.get('text'), "New Text", "the post was updated");

      application.registry.unregister('adapter:comment');
      $.mockjax.clear(id);
      start();
    });
  });

});

test("async hasMany save should resolve promise before post", function(assert) {
  var count = 0;
  var id = $.mockjax({
    url: '/api/v1/post/1/',
    type: 'PUT',
    response: function(settings) {
      var data = JSON.parse(settings.data);
      assert.deepEqual(data, {text: "New Text", comments: ['/api/v1/comment/1/', '/api/v1/comment/2/'] });
      this.responseText = null;
    }
  });

  Post.reopen({
    comments: DS.hasMany('comment', { async: true })
  });

  Comment.reopen({
    post: DS.belongsTo('post', { async: true })
  });

  stop();
  run(function() {
    store.push('post', { id: 1, text: "Some text", comments: [1, 2]});
    application.registry.register('adapter:comment', DjangoTastypieAdapter.extend({
      coalesceFindRequests: true,
      findMany: function() {
        assert.ok(count++ === 0, "findHasMany called once");

        return Ember.RSVP.resolve({ objects: [
          {id: 1, text: "Comment 1", post: '/api/v1/post/1/', resource_uri: '/api/v1/comment/1/'},
          {id: 2, text: "Comment 2", post: '/api/v1/post/1/', resource_uri: '/api/v1/comment/2/'}
        ]});
      }
    }));
  });

  run(function() {
    store.find('post', 1).then(function(post) {
      post.set('text', 'New Text');

      assert.equal(post.get('isDirty'), true, "the post dirty");

      return post.save();
    }).then(function(post) {

      assert.equal(post.get('isDirty'), false, "the post is not dirty anymore");
      assert.equal(post.get('text'), "New Text", "the post was updated");

      application.registry.unregister('adapter:comment');
      $.mockjax.clear(id);
      start();
    });
  });
});

test("findQuery - payload 'meta' is accessible on the record array", function(assert) {
  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    responseText: {
      meta: { offset: 5 },
      objects: [{id: 1, name: "Roy"}]
    }
  });

  stop();
  run(function() {
    store.findQuery('person', { page: 2 }).then(function(people) {
      assert.equal(
          people.get('meta.offset'),
          5,
          "Reponse metadata can be accessed with recordArray.meta"
      );

      $.mockjax.clear(id);
      start();
    });
  });
});

test("findQuery - each record array can have it's own meta object", function(assert) {
  var count = 0;
  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    response: function(settings) {
      if (count === 0) {
        this.responseText = {
          meta: {offset: 5},
          objects: [{id: 1, name: "Roy"}]
        };
        count++;
      } else {
        this.responseText = {
          meta: { offset: 1 },
          objects: [{id: 1, name: "Maurice Moss"}]
        };
      }
    }
  });

  stop();
  run(function() {
    store.findQuery('person', { page: 2 }).then(function(people) {
      assert.equal(
          people.get('meta.offset'),
          5,
          "Reponse metadata can be accessed with recordArray.meta"
      );

      store.findQuery('person', { page: 1}).then(function(newPeople){
        assert.equal(newPeople.get('meta.offset'), 1, 'new array has correct metadata');
        assert.equal(people.get('meta.offset'), 5, 'metadata on the old array hasnt been clobbered');

        $.mockjax.clear(id);
        start();
      });
    });
  });
});

test("the adapter can use custom keys", function(assert) {

  var id = $.mockjax({
    url: '/api/v1/person/',
    type: 'GET',
    responseText: { objects: [{ id: 1, name_custom: "Rails is omakase", resource_uri: '/api/v1/person/1/' }, { id: 2, name_custom: "The Parley Letter", resource_uri: '/api/v1/person/2/' }] }
  });

  stop();
  run(function() {
    application.registry.register('serializer:person', DjangoTastypieSerializer.extend({
      attrs: { name: 'name_custom' }
    }));
  });

  run(function() {
    store.findAll('person').then(function (people) {
      var person1 = store.getById('person', 1),
        person2 = store.getById('person', 2);

      assert.deepEqual(person1.getProperties('id', 'name'), {id: "1", name: "Rails is omakase"}, "Person 1 is loaded");
      assert.deepEqual(person2.getProperties('id', 'name'), {id: "2", name: "The Parley Letter"}, "Person 2 is loaded");

      assert.equal(people.get('length'), 2, "The posts are in the array");
      assert.equal(people.get('isLoaded'), true, "The RecordArray is loaded");
      assert.deepEqual(people.toArray(), [person1, person2], "The correct records are in the array");

      application.registry.unregister('serializer:person');
      $.mockjax.clear(id);
      start();
    });
  });
});


text:
package com.vnet.demo.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

import org.springframework.stereotype.Service;

/**
 * Jersey Info Rest API.
 *
 *
show project and framework version info

 *
 */
@Service("cxfRestService")
@Path("/info")
public class CXFService {

    /**
     * Test Rest API.
     *
     * @return -- String
     */
	@Path("/")
	@GET
    public Response getMsg() {
        return Response.ok("Hello World !! - cxf 3").build();
    }

}


text:
<?php
use yii\bootstrap\Html;
?>
<?php $this->beginBlock('moduleName')?>
<?= Html::a("Inventory")?>
<?php $this->endBlock() ?>

<?php $this->beginBlock('sidebar') ?>
<?= $this->render('sidebar')?>
<?php $this->endBlock() ?>

<?php $this->beginContent('@app/views/layouts/main.php'); ?>
<?= $content?>
<?php $this->endContent();


text:
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.Text;
using Roslyn.Test.EditorUtilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
{
    [UseExportProvider]
    public class ITextSnapshotExtensionsTests
    {
        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_EmptyLineReturnsEmptyString()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition(string.Empty, 0);
            Assert.Equal(string.Empty, leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_WhitespaceLineReturnsWhitespace1()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("    ", 0);
            Assert.Equal("    ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_WhitespaceLineReturnsWhitespace2()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition(" \t ", 0);
            Assert.Equal(" \t ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_WhitespaceLineReturnsWhitespace3()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("\t\t", 0);
            Assert.Equal("\t\t", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextLine()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo", 0);
            Assert.Equal(string.Empty, leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextLineStartingWithWhitespace1()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("    Goo", 0);
            Assert.Equal("    ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextLineStartingWithWhitespace2()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition(" \t Goo", 0);
            Assert.Equal(" \t ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextLineStartingWithWhitespace3()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("\t\tGoo", 0);
            Assert.Equal("\t\t", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_EmptySecondLineReturnsEmptyString()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n", 5);
            Assert.Equal(string.Empty, leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_WhitespaceSecondLineReturnsWhitespace1()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n    ", 5);
            Assert.Equal("    ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_WhitespaceSecondLineReturnsWhitespace2()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n \t ", 5);
            Assert.Equal(" \t ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_WhitespaceSecondLineReturnsWhitespace3()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n\t\t", 5);
            Assert.Equal("\t\t", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextSecondLine()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\nGoo", 5);
            Assert.Equal(string.Empty, leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextSecondLineStartingWithWhitespace1()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n    Goo", 5);
            Assert.Equal("    ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextSecondLineStartingWithWhitespace2()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n \t Goo", 5);
            Assert.Equal(" \t ", leadingWhitespace);
        }

        [Fact]
        public void GetLeadingWhitespaceOfLineAtPosition_TextSecondLineStartingWithWhitespace3()
        {
            var leadingWhitespace = GetLeadingWhitespaceOfLineAtPosition("Goo\r\n\t\tGoo", 5);
            Assert.Equal("\t\t", leadingWhitespace);
        }

        [Fact]
        public void GetSpanTest()
        {
            // each line of sample code contains 4 characters followed by a newline
            var snapshot = GetSampleCodeSnapshot();
            var span = snapshot.GetSpan(0, 2, 1, 1);

            // column 0, index 2 = (0 * 5) + 2 = 2
            Assert.Equal(span.Start, 2);

            // column 1, index 1 = (1 * 5) + 1 = 6
            Assert.Equal(span.End, 6);
        }

        [Fact]
        public void TryGetPositionTest()
        {
            // each line of sample code contains 4 characters followed by a newline
            var snapshot = GetSampleCodeSnapshot();
            var point = new SnapshotPoint();

            // valid line, valid column
            Assert.True(snapshot.TryGetPosition(3, 2, out point));
            Assert.Equal(17, point.Position);

            // valid line, invalid column
            Assert.False(snapshot.TryGetPosition(1, 8, out point));
            Assert.False(snapshot.TryGetPosition(3, -2, out point));

            // invalid line, valid column
            Assert.False(snapshot.TryGetPosition(18, 1, out point));
            Assert.False(snapshot.TryGetPosition(-1, 1, out point));
        }

        [Fact]
        public void TryGetPointValueTest()
        {
            var snapshot = GetSampleCodeSnapshot();
            Assert.Equal(new SnapshotPoint(snapshot, 15), snapshot.TryGetPoint(3, 0).Value);
        }

        [Fact]
        public void TryGetPointNullTest()
        {
            var snapshot = GetSampleCodeSnapshot();
            Assert.Null(snapshot.TryGetPoint(3000, 0));
        }

        [Fact]
        public void GetLineAndColumnTest()
        {
            var snapshot = GetSampleCodeSnapshot();
            snapshot.GetLineAndColumn(16, out var line, out var col);
            Assert.Equal(3, line);
            Assert.Equal(1, col);
        }

        private string GetLeadingWhitespaceOfLineAtPosition(string code, int position)
        {
            var snapshot = EditorFactory.CreateBuffer(TestExportProvider.ExportProviderWithCSharpAndVisualBasic, code).CurrentSnapshot;
            return snapshot.GetLeadingWhitespaceOfLineAtPosition(position);
        }

        private ITextSnapshot GetSampleCodeSnapshot()
        {
            // to make verification simpler, each line of code is 4 characters and will be joined to other lines
            // with a single newline character making the formula to calculate the offset from a given line and
            // column thus:
            //   position = row * 5 + column
            var lines = new string[]
            {
                "goo1",
                "bar1",
                "goo2",
                "bar2",
                "goo3",
                "bar3",
            };
            var code = string.Join("\n", lines);
            var snapshot = EditorFactory.CreateBuffer(TestExportProvider.ExportProviderWithCSharpAndVisualBasic, code).CurrentSnapshot;
            return snapshot;
        }
    }
}


text:
<!doctype html>

  <meta charset="utf-8">

  <title>The fabulous Cat-clicker</title>
  <meta name="description" content="Click through a list of cats">
  <meta name="author" content="Jon Welzel">

  <link rel="stylesheet" href="css/vendor/bootstrap.min.css">
  <link rel="stylesheet" href="css/main.css">

    <marquee scrollamount="20" id="titulo-bem-legal">welcome to cat-clicker</marquee>

Clicks:


text:
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chrome.browser.download.settings;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import org.chromium.chrome.browser.download.DownloadDialogBridge;
import org.chromium.chrome.browser.download.DownloadLaterPromptStatus;
import org.chromium.chrome.browser.download.DownloadPromptStatus;
import org.chromium.chrome.browser.download.R;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate;
import org.chromium.components.browser_ui.settings.SettingsUtils;
import org.chromium.components.prefs.PrefService;
import org.chromium.components.user_prefs.UserPrefs;

// Vivaldi
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import org.chromium.build.BuildConfig;
import org.chromium.ui.base.DeviceFormFactor;
import org.vivaldi.browser.preferences.VivaldiPreferences;

/**
 * Fragment containing Download settings.
 */
public class DownloadSettings
        extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener {
    static final String PREF_LOCATION_CHANGE = "location_change";
    static final String PREF_DOWNLOAD_LATER_PROMPT_ENABLED = "download_later_prompt_enabled";
    static final String PREF_LOCATION_PROMPT_ENABLED = "location_prompt_enabled";

    private PrefService mPrefService;
    private DownloadLocationPreference mLocationChangePref;
    private ChromeSwitchPreference mDownloadLaterPromptEnabledPref;
    private ChromeSwitchPreference mLocationPromptEnabledPref;
    private ManagedPreferenceDelegate mLocationPromptEnabledPrefDelegate;

    //Vivaldi
    private static final String PREF_EXTERNAL_DOWNLOAD_MANAGER = "external_download_manager";
    private Preference mExternalDownloadManagerPref;

    @Override
    public void onCreatePreferences(@Nullable Bundle savedInstanceState, String s) {
        getActivity().setTitle(R.string.menu_downloads);
        SettingsUtils.addPreferencesFromResource(this, R.xml.download_preferences);
        mPrefService = UserPrefs.get(Profile.getLastUsedRegularProfile());

        mDownloadLaterPromptEnabledPref =
                (ChromeSwitchPreference) findPreference(PREF_DOWNLOAD_LATER_PROMPT_ENABLED);
        mDownloadLaterPromptEnabledPref.setOnPreferenceChangeListener(this);

        boolean locationManaged = DownloadDialogBridge.isLocationDialogManaged();
        if (locationManaged || !ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_LATER)) {
            getPreferenceScreen().removePreference(
                    findPreference(PREF_DOWNLOAD_LATER_PROMPT_ENABLED));
        }

        mLocationPromptEnabledPref =
                (ChromeSwitchPreference) findPreference(PREF_LOCATION_PROMPT_ENABLED);
        mLocationPromptEnabledPref.setOnPreferenceChangeListener(this);
        mLocationPromptEnabledPrefDelegate = new ChromeManagedPreferenceDelegate() {
            @Override
            public boolean isPreferenceControlledByPolicy(Preference preference) {
                return DownloadDialogBridge.isLocationDialogManaged();
            }
        };
        mLocationPromptEnabledPref.setManagedPreferenceDelegate(mLocationPromptEnabledPrefDelegate);
        mLocationChangePref = (DownloadLocationPreference) findPreference(PREF_LOCATION_CHANGE);

        // Vivaldi
        mExternalDownloadManagerPref = findPreference(PREF_EXTERNAL_DOWNLOAD_MANAGER);
    }

    @Override
    public void onDisplayPreferenceDialog(Preference preference) {
        if (preference instanceof DownloadLocationPreference) {
            DownloadLocationPreferenceDialog dialogFragment =
                    DownloadLocationPreferenceDialog.newInstance(
                            (DownloadLocationPreference) preference);
            dialogFragment.setTargetFragment(this, 0);
            dialogFragment.show(getFragmentManager(), DownloadLocationPreferenceDialog.TAG);
        } else {
            super.onDisplayPreferenceDialog(preference);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        updateDownloadSettings();
    }

    private void updateDownloadSettings() {
        mLocationChangePref.updateSummary();

        if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_LATER)) {
            @DownloadLaterPromptStatus
            int downloadLaterPromptStatus =
                    mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS);
            mDownloadLaterPromptEnabledPref.setChecked(
                    !(downloadLaterPromptStatus == DownloadLaterPromptStatus.DONT_SHOW));
        }

        if (DownloadDialogBridge.isLocationDialogManaged()) {
            // Location prompt can be controlled by the enterprise policy.
            mLocationPromptEnabledPref.setChecked(
                    DownloadDialogBridge.getPromptForDownloadPolicy());
        } else {
            // Location prompt is marked enabled if the prompt status is not DONT_SHOW.
            boolean isLocationPromptEnabled = DownloadDialogBridge.getPromptForDownloadAndroid()
                    != DownloadPromptStatus.DONT_SHOW;
            mLocationPromptEnabledPref.setChecked(isLocationPromptEnabled);
            mLocationPromptEnabledPref.setEnabled(true);
        }

        // Vivaldi - update external download Manager summary
        if (mExternalDownloadManagerPref != null) {
            mExternalDownloadManagerPref.setSummary(
                    VivaldiPreferences.getSharedPreferencesManager().readString(
                            VivaldiPreferences.EXTERNAL_DOWNLOAD_MANAGER_APPLICATION, "Off"));
        }
    }

    // Preference.OnPreferenceChangeListener implementation.
    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (PREF_DOWNLOAD_LATER_PROMPT_ENABLED.equals(preference.getKey())) {
            if (!ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_LATER)) return false;
            @DownloadLaterPromptStatus
            int downloadLaterPromptStatus =
                    mPrefService.getInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS);
            if (!(boolean) newValue) {
                mPrefService.setInteger(
                        Pref.DOWNLOAD_LATER_PROMPT_STATUS, DownloadLaterPromptStatus.DONT_SHOW);
                return true;
            }

            // Only update if the download later dialog has been shown before.
            if (downloadLaterPromptStatus != DownloadLaterPromptStatus.SHOW_INITIAL) {
                mPrefService.setInteger(Pref.DOWNLOAD_LATER_PROMPT_STATUS,
                        DownloadLaterPromptStatus.SHOW_PREFERENCE);
            }
        } else if (PREF_LOCATION_PROMPT_ENABLED.equals(preference.getKey())) {
            if ((boolean) newValue) {
                // Only update if the download location dialog has been shown before.
                if (DownloadDialogBridge.getPromptForDownloadAndroid()
                        != DownloadPromptStatus.SHOW_INITIAL) {
                    DownloadDialogBridge.setPromptForDownloadAndroid(
                            DownloadPromptStatus.SHOW_PREFERENCE);
                }
            } else {
                DownloadDialogBridge.setPromptForDownloadAndroid(DownloadPromptStatus.DONT_SHOW);
            }
        }
        return true;
    }

    @VisibleForTesting
    ManagedPreferenceDelegate getLocationPromptEnabledPrefDelegateForTesting() {
        return mLocationPromptEnabledPrefDelegate;
    }

    /** Vivaldi **/
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        if (BuildConfig.IS_VIVALDI) {
            boolean isTablet = DeviceFormFactor
                    .isNonMultiDisplayContextOnTablet(view.getContext());
            if (isTablet) {
                getView().setBackgroundColor(getResources()
                        .getColor(R.color.tablet_panel_bg_color));
                Toolbar toolbar = new Toolbar(getContext());
                if (getView() != null) {
                    ((ViewGroup) getView()).addView(toolbar, 0);
                    toolbar.getLayoutParams().height =
                    Math.round(56 * getResources().getDisplayMetrics().density);
                    toolbar.setBackgroundColor(
                            getResources().getColor(R.color.tablet_panel_bg_color));
                    toolbar.setSubtitle(getResources().getString(R.string.downloads));
                    toolbar.setNavigationIcon(R.drawable.vivaldi_nav_button_back);
                    ((LinearLayout.LayoutParams) toolbar.getLayoutParams()).gravity = Gravity.TOP;
                    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            getParentFragmentManager().popBackStack();
                        }
                    });
                }

            }
        }
        super.onViewCreated(view, savedInstanceState);
    }
}


text:
package net.adamjak.math.expressionevaluator;

import net.adamjak.math.expressionevaluator.results.ResultSimple;
import net.adamjak.math.expressionevaluator.results.ResultMultiple;
import net.adamjak.math.expressionevaluator.tokens.Token;
import net.adamjak.math.expressionevaluator.tokens.TokenType;
import net.adamjak.math.expressionevaluator.exceptions.EvaluateException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.adamjak.math.expressionevaluator.functions.Function;
import net.adamjak.math.expressionevaluator.exceptions.ParseException;
import net.adamjak.math.expressionevaluator.functions.StringToNumber;
import net.adamjak.math.expressionevaluator.parser.InputParser;
import net.adamjak.math.expressionevaluator.results.Result;
import net.adamjak.math.expressionevaluator.tokens.ArgumentSeparatorEvaluator;
import net.adamjak.math.expressionevaluator.tokens.BinaryOperatorEvaluator;
import net.adamjak.math.expressionevaluator.tokens.TokenEvaluateResult;
import net.adamjak.math.expressionevaluator.tokens.UnaryOperatorEvaluator;
import net.adamjak.math.expressionevaluator.variables.VariableValue;
import net.adamjak.math.expressionevaluator.variables.VariableValueSet;
import net.adamjak.utils.Utils;
import net.adamjak.utils.validators.ObjectNotNull;

/**
 *
 * @author Marian Adamjak
 */
public class BaseExpression extends Expression {

    private final List<ExpressionSequence> exprSeq;
    private final StringToNumber stringToNumber = new StringToNumber();

    public static BaseExpression create(String input) throws ParseException {
        BaseExpression be = new BaseExpression(input);
        be.parseInput();
        return be;
    }

    private BaseExpression(String input) {
        super(input);
        exprSeq = new ArrayList<>();
    }

    private void parseInput() throws ParseException {
        InputParser inputParser = InputParser.createParser(getInput().trim());
        if (inputParser.getParseStatus() == InputParser.ParseStatus.ERROR) {
            throw new ParseException("Incorrect char in input", inputParser.getLastParsePosition() + 1);
        }
        int bracketCount = 0;
        for (Token token : inputParser.getParsedToken()) {
            if (token.getType() == TokenType.FUNCTION_NAME) {
                if (Expression.getFunctionMap().containsKey(token.getContent()) == false) {
                    throw new ParseException("Unknown function name", token.startPoisition() + 1);
                }
            }
            if (token.getType() == TokenType.BRACKET_LEFT) {
                bracketCount = bracketCount + 1;
                token.setPriority(bracketCount);
            }
            if (token.getType() == TokenType.BRACKET_RIGHT) {
                token.setPriority(bracketCount);
                bracketCount = bracketCount - 1;
                if (bracketCount < 0) {
                    throw new ParseException("Unexpected right bracket", token.startPoisition() + 1);
                }
            }
        }
        Token lastToken = Utils.lastElement(inputParser.getParsedToken());
        if (lastToken.getType().canBeLast() == false) {
            throw new ParseException("Unexpected last token", lastToken.startPoisition() + 1);
        }

        exprSeq.addAll(inputParser.getParsedToken());
        convertNumberTokens();
        convertTextTokens();
    }

    public List<ExpressionSequence> getExprSeq() {
        return exprSeq;
    }

    @Override
    public List<ExpressionSequence> evaluate(VariableValueSet variableSet) throws EvaluateException {
        if (this.exprSeq.isEmpty()) {
            return Collections.EMPTY_LIST;
        }
        if (this.exprSeq.size() == 1) {
            List<ExpressionSequence> output = new ArrayList<>(1);
            output.add(this.exprSeq.get(0));
            return output;
        }
        if (containsVariable() && (variableSet == null || variableSet.getVariableNames().isEmpty())) {
            throw new EvaluateException("Expression contains variable(s), but no variableSet has given");
        }
        return evaluateExprSeq(variableSet);
    }

    @Override
    public List<String> getVariableNames() {
        List<String> variableNames = new ArrayList<>();
        for (ExpressionSequence eseq : this.exprSeq) {
            if (eseq instanceof Token) {
                Token token = (Token) eseq;
                if (token.getType() == TokenType.VARIABLE_NAME) {
                    variableNames.add(token.getContent());
                }
            }
        }
        return variableNames;
    }

    private boolean containsVariable() {
        for (ExpressionSequence eseq : this.exprSeq) {
            if (eseq instanceof Token) {
                Token token = (Token) eseq;
                if (token.getType() == TokenType.VARIABLE_NAME) {
                    return true;
                }
            }
        }
        return false;
    }

    private void convertNumberTokens() throws ParseException {
        for (int i = 0; i < exprSeq.size(); i++) {
            if (exprSeq.get(i) instanceof Token && ((Token) exprSeq.get(i)).getType() == TokenType.NUMBER) {
                try {
                    List<ResultSimple> results = stringToNumber.getResults((Token) exprSeq.get(i));
                    exprSeq.set(i, results.get(0));
                } catch (EvaluateException ex) {
                    throw new ParseException("Can not parse number. Error:" + ex.getMessage(), exprSeq.get(i).startPoisition());
                }
            }
        }
    }

    private void convertTextTokens() throws ParseException {
        for (int i = 0; i < exprSeq.size(); i++) {
            if (exprSeq.get(i) instanceof Token && ((Token) exprSeq.get(i)).getType() == TokenType.TEXT) {
                ResultSimple result = new ResultSimple(((Token) exprSeq.get(i)).getContent(), exprSeq.get(i).startPoisition(), exprSeq.get(i).length());
                exprSeq.set(i, result);
            }
        }
    }

    private List<ExpressionSequence> evaluateExprSeq(VariableValueSet variableSet) throws EvaluateException {
        replaceVariables(variableSet);
        evaluateExprSubSeq(new IntegerPair(0, this.exprSeq.size() - 1));
        return this.exprSeq;
    }

    private void evaluateExprSubSeq(IntegerPair evaluateRange) throws EvaluateException {
        Utils.validateInput(evaluateRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = evaluateRange.getInt01();
        int endSeq = evaluateRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);

        //remove spaces
        int sizeBefore = this.exprSeq.size();
        List<Integer> spacePositions = findAllPositionsSpace(new IntegerPair(startSeq, endSeq));
        for (int i = spacePositions.size() - 1; i >= 0; i--) {
            int positionToRemove = spacePositions.get(i);
            this.exprSeq.remove(positionToRemove);
        }
        if (sizeBefore > this.exprSeq.size()) {
            endSeq = endSeq - (sizeBefore - this.exprSeq.size());
        }

        //evaluating inside of brackets
        int bracketPriority = getMaxBracketPriority(new IntegerPair(startSeq, endSeq));
        while (bracketPriority > 0) {
            IntegerPair bracketPosition = findFirstStartEndPositionForBracketPriority(new IntegerPair(startSeq, endSeq), bracketPriority);
            if (bracketPosition == null) {
                break;
            }
            if ((bracketPosition.int02 - bracketPosition.int01) <= 0) {
                throw new EvaluateException("Can not interpret bracket at position: " + bracketPosition.int01);
            }
            if ((bracketPosition.int02 - bracketPosition.int01) == 1) {
                this.exprSeq.set(bracketPosition.int01, new ResultSimple(bracketPosition.int01, 2));
                this.exprSeq.remove(bracketPosition.int02);
                endSeq = endSeq - 1;
            } else if ((bracketPosition.int02 - bracketPosition.int01) == 2) {
                if (this.exprSeq.get(bracketPosition.int01 + 1) instanceof ResultSimple || this.exprSeq.get(bracketPosition.int01 + 1) instanceof ResultMultiple) {
                    this.exprSeq.remove(bracketPosition.int02);
                    this.exprSeq.remove(bracketPosition.int01);
                    endSeq = endSeq - 2;
                }
            } else {
                int lenBefore = this.exprSeq.size();
                evaluateExprSubSeq(new IntegerPair(bracketPosition.int01 + 1, bracketPosition.int02 - 1));
                endSeq = endSeq - (lenBefore - this.exprSeq.size());
            }
            bracketPriority = getMaxBracketPriority(new IntegerPair(startSeq, endSeq));
        }

        // evaluation functions
        int functionPosition = findFirstStartEndPositionFunction(new IntegerPair(startSeq, endSeq));
        while (functionPosition >= 0) {
            Token token = (Token) this.exprSeq.get(functionPosition);
            Function function = Expression.getFunctionByName(token.getContent());
            if (function == null) {
                throw new EvaluateException("Can not find function: " + token.getContent(),token.startPoisition());
            }
            List<ResultSimple> funcResult;
            int argumentLenght = 0;
            if (this.exprSeq.get(functionPosition + 1) instanceof ResultSimple) {
                ResultSimple rs = (ResultSimple) this.exprSeq.get(functionPosition + 1);
                argumentLenght = rs.length();
                funcResult = function.getResults(rs);
            } else if (this.exprSeq.get(functionPosition + 1) instanceof ResultMultiple) {
                ResultMultiple rm = (ResultMultiple) this.exprSeq.get(functionPosition + 1);
                argumentLenght = rm.length();
                funcResult = function.getResults(rm.getResults());
            } else {
                throw new EvaluateException("There is no suitable argument for function", token.startPoisition());
            }
            ExpressionSequence funcResSeq;
            if (funcResult.isEmpty()) {
                funcResSeq = new ResultSimple(functionPosition, argumentLenght);
            } else if (funcResult.size() == 1) {
                funcResSeq = funcResult.get(0);
            } else {
                funcResSeq = ResultMultiple.createFromResultSimple(funcResult);
            }
            this.exprSeq.set(functionPosition, funcResSeq);
            this.exprSeq.remove(functionPosition + 1);
            endSeq = endSeq - 1;
            functionPosition = findFirstStartEndPositionFunction(new IntegerPair(startSeq, endSeq));
        }

       // evaluate aritmetic operators + cumulate simple result around argument separator into multiple results
        List<Integer> argSeparatorPositions = findAllPositionsArgumentSeparator(new IntegerPair(startSeq, endSeq));
        while (argSeparatorPositions.isEmpty() == false) {
            if (argSeparatorPositions.size() == 1) {
                if (argSeparatorPositions.get(0) - startSeq == 1) {
                    if (endSeq - argSeparatorPositions.get(0) == 1) {
                        TokenEvaluateResult ter = ArgumentSeparatorEvaluator.getInstance().evaluate(exprSeq, argSeparatorPositions.get(0));
                        switch (ter.getEvaluateResultType()) {
                            case EVALUATE_FULL:
                                this.exprSeq.set(ter.getReplaceStartPosition(), ter.getEvaluateResult());
                                for (int removePosition = ter.getReplaceEndPosition(); removePosition > ter.getReplaceStartPosition(); removePosition--) {
                                    this.exprSeq.remove(removePosition);
                                }
                                endSeq = endSeq - (ter.getReplaceEndPosition() - ter.getReplaceStartPosition());
                                break;
                            case EVALUATE_PARTIALY:
                                throw new EvaluateException("Stop evaluation - Argument separator has been evaluated partialy.", tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                            case NO_EVALUATE:
                                throw new EvaluateException("Stop evaluation - Argument separator has not been evaluated." , tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                            default:
                                throw new UnsupportedOperationException("Unknown TokenResultType " + ter.getEvaluateResultType().name());

                        }
                    } else {
                        sizeBefore = this.exprSeq.size();
                        evaluateExprSubSeq(new IntegerPair(argSeparatorPositions.get(0) + 1, endSeq));
                        if (sizeBefore > this.exprSeq.size()) {
                            endSeq = endSeq - (sizeBefore - this.exprSeq.size());
                        } else {
                            throw new EvaluateException("Evaluating before argument separator fail.", tokenPositionToInputPosition(argSeparatorPositions.get(0)));
                        }
                    }
                } else {
                    sizeBefore = this.exprSeq.size();
                    evaluateExprSubSeq(new IntegerPair(startSeq, argSeparatorPositions.get(0) - 1));
                    if (sizeBefore > this.exprSeq.size()) {
                        endSeq = endSeq - (sizeBefore - this.exprSeq.size());
                    } else {
                        throw new EvaluateException("Evaluating before argument separator fail.", tokenPositionToInputPosition(argSeparatorPositions.get(0)));
                    }
                }
            } else if (argSeparatorPositions.get(0) - startSeq == 1) {
                if (argSeparatorPositions.get(1) - argSeparatorPositions.get(0) == 2) {
                    TokenEvaluateResult ter = ArgumentSeparatorEvaluator.getInstance().evaluate(exprSeq, argSeparatorPositions.get(0));
                    switch (ter.getEvaluateResultType()) {
                        case EVALUATE_FULL:
                            this.exprSeq.set(ter.getReplaceStartPosition(), ter.getEvaluateResult());
                            for (int removePosition = ter.getReplaceEndPosition(); removePosition > ter.getReplaceStartPosition(); removePosition--) {
                                this.exprSeq.remove(removePosition);
                            }
                            endSeq = endSeq - (ter.getReplaceEndPosition() - ter.getReplaceStartPosition());
                            break;
                        case EVALUATE_PARTIALY:
                            throw new EvaluateException("Stop evaluation - Argument separator has been evaluated partialy." , tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                        case NO_EVALUATE:
                            throw new EvaluateException("Stop evaluation - Argument separator has not been evaluated.", tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                        default:
                            throw new UnsupportedOperationException("Unknown TokenResultType " + ter.getEvaluateResultType().name());
                    }
                } else {
                    sizeBefore = this.exprSeq.size();
                    evaluateExprSubSeq(new IntegerPair(argSeparatorPositions.get(0) + 1, argSeparatorPositions.get(1) - 1));
                    if (sizeBefore > this.exprSeq.size()) {
                        endSeq = endSeq - (sizeBefore - this.exprSeq.size());
                    } else {
                        throw new EvaluateException("Evaluating before argument separator fail." + tokenPositionToInputPosition(argSeparatorPositions.get(0)));
                    }
                }
            } else {
                sizeBefore = this.exprSeq.size();
                evaluateExprSubSeq(new IntegerPair(startSeq, argSeparatorPositions.get(0) - 1));
                if (sizeBefore > this.exprSeq.size()) {
                    endSeq = endSeq - (sizeBefore - this.exprSeq.size());
                } else {
                    throw new EvaluateException("Evaluating before argument separator fail near position " + argSeparatorPositions.get(0));
                }
            }
            argSeparatorPositions = findAllPositionsArgumentSeparator(new IntegerPair(startSeq, endSeq));
        }
        evaluateArithmeticOperations(new IntegerPair(startSeq, endSeq));

    }

    private void evaluateArithmeticOperations(IntegerPair evaluateRange) throws EvaluateException {
        Utils.validateInput(evaluateRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = evaluateRange.getInt01();
        int endSeq = evaluateRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        if (startSeq == endSeq) {
            if (this.exprSeq.get(startSeq) instanceof Result) {
                return;
            } else {
                throw new EvaluateException("Evaluate AritmeticOperators - One token evaluating - result is excepted", this.exprSeq.get(startSeq).startPoisition());
            }
        }

        int unOpPosition = findFirstUnaryOperator(new IntegerPair(startSeq, endSeq));
        while (unOpPosition > -1) {
            TokenEvaluateResult ter = UnaryOperatorEvaluator.getInstance().evaluate(exprSeq, unOpPosition);
            switch (ter.getEvaluateResultType()) {
                case EVALUATE_FULL:
                    this.exprSeq.set(ter.getReplaceStartPosition(), ter.getEvaluateResult());
                    for (int removePosition = ter.getReplaceEndPosition(); removePosition > ter.getReplaceStartPosition(); removePosition--) {
                        this.exprSeq.remove(removePosition);
                    }
                    endSeq = endSeq - (ter.getReplaceEndPosition() - ter.getReplaceStartPosition());
                    break;
                case EVALUATE_PARTIALY:
                    throw new EvaluateException("Stop evaluation - Unary operator has been evaluated partialy.", tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                case NO_EVALUATE:
                    throw new EvaluateException("Stop evaluation - Unary operator has not been evaluated.", tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                default:
                    throw new UnsupportedOperationException("Unknown TokenResultType " + ter.getEvaluateResultType().name());

            }
            unOpPosition = findFirstUnaryOperator(new IntegerPair(startSeq, endSeq));
        }
        if (startSeq == endSeq) {
            if (this.exprSeq.get(startSeq) instanceof Result) {
                return;
            } else {
                throw new EvaluateException("Evaluate AritmeticOperators - No result after unary operators evaluation", this.exprSeq.get(startSeq).startPoisition());
            }
        }
        int maxOpPriority = getMaxBinaryOpPriority(new IntegerPair(startSeq, endSeq));
        if (maxOpPriority == -1) {
            throw new EvaluateException("Evaluate BinaryOperators - no operator there", this.exprSeq.get(startSeq).startPoisition());
        }
        while (maxOpPriority > 0) {
            int opPosition = findFirstBinaryOperatorByPriority(new IntegerPair(startSeq, endSeq), maxOpPriority);
            if (opPosition > 0) {
                TokenEvaluateResult ter = BinaryOperatorEvaluator.getInstance().evaluate(exprSeq, opPosition);
                switch (ter.getEvaluateResultType()) {
                    case EVALUATE_FULL:
                        this.exprSeq.set(ter.getReplaceStartPosition(), ter.getEvaluateResult());
                        for (int removePosition = ter.getReplaceEndPosition(); removePosition > ter.getReplaceStartPosition(); removePosition--) {
                            this.exprSeq.remove(removePosition);
                        }
                        endSeq = endSeq - (ter.getReplaceEndPosition() - ter.getReplaceStartPosition());
                        break;
                    case EVALUATE_PARTIALY:
                        throw new EvaluateException("Stop evaluation - Binary operator has been evaluated partialy. Postion near: " + tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                    case NO_EVALUATE:
                        throw new EvaluateException("Stop evaluation - Binary operator has not been evaluated. Postion near: " + tokenPositionToInputPosition(ter.getReplaceStartPosition()));
                    default:
                        throw new UnsupportedOperationException("Unknown TokenResultType " + ter.getEvaluateResultType().name());

                }
            }
            maxOpPriority = getMaxBinaryOpPriority(new IntegerPair(startSeq, endSeq));
        }
        if (startSeq == endSeq) {
            if (this.exprSeq.get(startSeq) instanceof Result) {
                return;
            } else {
                throw new EvaluateException("Evaluate BinaryOperators - Output is no result type",this.exprSeq.get(startSeq).startPoisition());
            }
        } else {
            throw new EvaluateException("Evaluate BinaryOperators - more then one token is result",this.exprSeq.get(startSeq).startPoisition());
        }
    }

    private int findFirstUnaryOperator(IntegerPair searchRange) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.UNARY_OPERATOR) {
                    return pos;
                }
            }
        }
        return -1;
    }

    private int findFirstBinaryOperatorByPriority(IntegerPair searchRange, int priority) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.BINARY_OPERATOR) {
                    if (token.getPriority() == priority) {
                        return pos;
                    }
                }
            }
        }
        return -1;
    }

    private List<Integer> findAllPositionsSpace(IntegerPair searchRange) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        List<Integer> output = new ArrayList<>();
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.SPACE) {
                    output.add(pos);
                }
            }
        }
        return output;
    }

    private List<Integer> findAllPositionsArgumentSeparator(IntegerPair searchRange) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        List<Integer> output = new ArrayList<>();
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.ARGUMENT_SEPARATOR) {
                    output.add(pos);
                }
            }
        }
        return output;
    }

    private int findFirstStartEndPositionFunction(IntegerPair searchRange) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.FUNCTION_NAME) {
                    return pos;
                }
            }
        }
        return -1;
    }

    private int getMaxBinaryOpPriority(IntegerPair searchRange) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        int maxPriority = -1;
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.BINARY_OPERATOR) {
                    if (token.getPriority() > maxPriority) {
                        maxPriority = token.getPriority();
                    }
                }
            }
        }
        return maxPriority;
    }

    private int getMaxBracketPriority(IntegerPair searchRange) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        int maxPriority = -1;
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.BRACKET_LEFT) {
                    if (token.getPriority() > maxPriority) {
                        maxPriority = token.getPriority();
                    }
                }
            }
        }
        return maxPriority;
    }

    private IntegerPair findFirstStartEndPositionForBracketPriority(IntegerPair searchRange, int priority) {
        Utils.validateInput(searchRange, ObjectNotNull.getInstance(), NullPointerException.class, "IntPair can not be null");
        int startSeq = searchRange.getInt01();
        int endSeq = searchRange.getInt02();
        checkSubSeqIndex(startSeq, endSeq);
        boolean leftBracketFound = false;
        for (int pos = startSeq; pos < endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.BRACKET_LEFT && token.getPriority() == priority) {
                    startSeq = pos;
                    leftBracketFound = true;
                    break;
                }
            }
        }
        if (leftBracketFound == false) {
            return null;
        }
        boolean rightBracketFound = false;
        for (int pos = startSeq + 1; pos <= endSeq; pos++) {
            if (this.exprSeq.get(pos) instanceof Token) {
                Token token = (Token) this.exprSeq.get(pos);
                if (token.getType() == TokenType.BRACKET_RIGHT && token.getPriority() == priority) {
                    endSeq = pos;
                    rightBracketFound = true;
                    break;
                }
            }
        }
        if (rightBracketFound == false) {
            return null;
        }
        return new IntegerPair(startSeq, endSeq);
    }

    private void replaceVariables(VariableValueSet variableSet) {
        for (int i = 0; i < exprSeq.size(); i++) {
            if (exprSeq.get(i) instanceof Token && ((Token) exprSeq.get(i)).getType() == TokenType.VARIABLE_NAME) {
                Token token = (Token) exprSeq.get(i);
                VariableValue varVal = variableSet.getVariableValueByName(token.getContent());
                //TODO: check variable type against neigbor tokens
                if (varVal != null) {
                    exprSeq.set(i, varVal.getResult(exprSeq.get(i).startPoisition(), exprSeq.get(i).length()));
                }
            }
        }
    }

    private void checkSubSeqIndex(int startSeq, int endSeq) {
        if (startSeq < 0 || startSeq >= this.exprSeq.size()) {
            throw new IndexOutOfBoundsException("StartSeq is out of index range");
        }
        if (endSeq < 0 || endSeq >= this.exprSeq.size()) {
            throw new IndexOutOfBoundsException("EndSeq is out of index range");
        }
        if (startSeq > endSeq) {
            throw new IllegalArgumentException("StartSeq is great then EndSeq");
        }
    }

    private int tokenPositionToInputPosition(int tokenPosition){
        if(tokenPosition < 0 || tokenPosition > this.exprSeq.size() -1){
            return -1;
        }
        return this.exprSeq.get(tokenPosition).startPoisition();
    }

    private class IntegerPair {

        private final int int01;
        private final int int02;

        public IntegerPair(int int01, int int02) {
            this.int01 = int01;
            this.int02 = int02;
        }

        public int getInt01() {
            return int01;
        }

        public int getInt02() {
            return int02;
        }

    }
}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.security.keyvault.jca.implementation.signature;

/**
 * key vault SHA384
 */
public final class KeyVaultKeyLessEcSha384Signature extends KeyVaultKeyLessECSignature {

    @Override
    public String getAlgorithmName() {
        return "SHA384withECDSA";
    }

    /**
     * support SHA-384
     */
    public KeyVaultKeyLessEcSha384Signature() {
        super("SHA-384", "ES384");
    }
}


text:
extern LoggingType peloton_logging_mode;

extern size_t peloton_data_file_size;

extern int64_t peloton_wait_timeout;

namespace peloton {
namespace benchmark {

namespace ycsb {
configuration state;
}
namespace tpcc {
configuration state;
}

namespace logger {

// Configuration
configuration state;

// Main Entry Point
void RunBenchmark() {

  // First, set the global peloton logging mode and pmem file size
  peloton_logging_mode = state.logging_type;
  peloton_data_file_size = state.data_file_size;
  peloton_wait_timeout = state.wait_timeout;

  //===--------------------------------------------------------------------===//
  // WAL
  //===--------------------------------------------------------------------===//
  if (IsBasedOnWriteAheadLogging(peloton_logging_mode)) {
    // Prepare a simple log file
    PrepareLogFile();

    // Reset data
    ResetSystem();

    // Do recovery
    DoRecovery();

  }
  //===--------------------------------------------------------------------===//
  // WBL
  //===--------------------------------------------------------------------===//
  else if (IsBasedOnWriteBehindLogging(peloton_logging_mode)) {
    // Test a simple log process
    PrepareLogFile();

    // Do recovery
    DoRecovery();
  }

}

}  // namespace logger
}  // namespace benchmark
}  // namespace peloton

int main(int argc, char **argv) {
  peloton::benchmark::logger::ParseArguments(argc, argv,
                                             peloton::benchmark::logger::state);

  peloton::benchmark::logger::RunBenchmark();

  return 0;
}


text:
var mainbottom = 200;

// on scroll,
// $(window).on('scroll',function(){

//     // we round here to reduce a little workload
//     var stop = Math.round($(window).scrollTop());

//     if (stop > mainbottom) {
//         $('html').addClass('scrolled');
//     } else {
//         $('html').removeClass('scrolled');
//     }

// });

//smooth page scroll
$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});