text:
package com.azure.resourcemanager.commerce.implementation;

import com.azure.resourcemanager.commerce.fluent.models.UsageAggregationInner;
import com.azure.resourcemanager.commerce.models.InfoField;
import com.azure.resourcemanager.commerce.models.UsageAggregation;
import java.time.OffsetDateTime;
import java.util.UUID;

public final class UsageAggregationImpl implements UsageAggregation {
    private UsageAggregationInner innerObject;

    private final com.azure.resourcemanager.commerce.UsageManager serviceManager;

    UsageAggregationImpl(
        UsageAggregationInner innerObject, com.azure.resourcemanager.commerce.UsageManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
    }

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public UUID subscriptionId() {
        return this.innerModel().subscriptionId();
    }

    public String meterId() {
        return this.innerModel().meterId();
    }

    public OffsetDateTime usageStartTime() {
        return this.innerModel().usageStartTime();
    }

    public OffsetDateTime usageEndTime() {
        return this.innerModel().usageEndTime();
    }

    public Float quantity() {
        return this.innerModel().quantity();
    }

    public String unit() {
        return this.innerModel().unit();
    }

    public String meterName() {
        return this.innerModel().meterName();
    }

    public String meterCategory() {
        return this.innerModel().meterCategory();
    }

    public String meterSubCategory() {
        return this.innerModel().meterSubCategory();
    }

    public String meterRegion() {
        return this.innerModel().meterRegion();
    }

    public InfoField infoFields() {
        return this.innerModel().infoFields();
    }

    public String instanceData() {
        return this.innerModel().instanceData();
    }

    public UsageAggregationInner innerModel() {
        return this.innerObject;
    }

    private com.azure.resourcemanager.commerce.UsageManager manager() {
        return this.serviceManager;
    }
}


text:
// commented as using Interop.* requires for MSOffice installed

//using EmailRegistry.Infrastructure.BusinessLogic.Exporting.Data;
//using EmailRegistry.Infrastructure.Extensions.Lifecycle;
//using System;
//using System.Threading.Tasks;
//using Excel = Microsoft.Office.Interop.Excel;

//namespace EmailRegistry.Infrastructure.BusinessLogic.Exporting.ExportingObjects
//{
//    public class ExcelInteropExportingObject : IExportingObject // TODO
//    {
//        private MarshaledObject<Excel.Application> _application;
//        private MarshaledObject<Excel.Workbook> _workbook;
//        private MarshaledObject<Excel.Worksheet> _worksheet;

//        public async Task Export(ExportSet set, bool saveSheet)
//        {
//            this.InitializeObjects();

//            try
//            {
//                await this.ExportDataAsync(set, saveSheet);
//            }
//            finally
//            {
//                this.DisposeObjects();
//            }
//        }

//        private void InitializeObjects()
//        {
//            this._application = new MarshaledObject<Excel.Application>(new Excel.Application());
//            this._workbook = new MarshaledObject<Excel.Workbook>(this._application.Object.Workbooks.Add());
//            this._worksheet = new MarshaledObject<Excel.Worksheet>(this._workbook.Object.Worksheets.Add());
//        }

//        private async Task ExportDataAsync(ExportSet set, bool saveSheet)
//        {
//            await this.CreateSheetAsync(set);

//            if (saveSheet)
//            {
//                await this.SaveSheetAsync();
//            }

//            await this.PrintSheetAsync();
//        }

//        private Task CreateSheetAsync(ExportSet set)
//        {
//            return Task.Run(() =>
//            {
//                var row = 2;
//                var column = 1;

//                this._worksheet.Object.Cells.WrapText = true;

//                foreach (var item in set.Metadata.Descriptors)
//                {
//                    var cell = this.GetCells(row, column);

//                    cell.Value2 = item.Head;
//                    cell.ColumnWidth = item.Width;

//                    column++;
//                }

//                var headerRange = this._worksheet.Object.Range[this.GetCells(1, 1), this.GetCells(1, column - 1)];
//                headerRange.Merge();
//                headerRange.Value2 = set.Metadata.Header;

//                var metaRange = this._worksheet.Object.Range[this.GetCells(1, 1), this.GetCells(row, column - 1)];
//                SetHeaderStyle(metaRange);

//                row++;

//                foreach (var exportable in set.Exportables)
//                {
//                    column = 1;
//                    foreach (var rowContainer in exportable.GetRowContainers())
//                    {
//                        var cell = this.GetCells(row, column);

//                        cell.Value2 = rowContainer.Value.GetString();
//                        cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;

//                        if (rowContainer.Value.WrapValue)
//                        {
//                            cell.WrapText = true;
//                        }

//                        column++;
//                    }

//                    this._worksheet.Object.Range[this.GetCells(row, 1), this.GetCells(row, column - 1)].EntireRow.AutoFit();

//                    row++;
//                }

//                SetCommonStyle(this._worksheet.Object.Range[this.GetCells(1, 1), this.GetCells(row - 1, column - 1)]);
//                SetBordersStyle(this._worksheet.Object.Range[this.GetCells(2, 1), this.GetCells(row - 1, column - 1)]);
//                this.SetPageMargins();
//            });
//        }

//        private void SetPageMargins()
//        {
//            var pageSetup = this._worksheet.Object.PageSetup;

//            pageSetup.TopMargin = pageSetup.BottomMargin = 0.6D * 72D;
//            pageSetup.LeftMargin = pageSetup.RightMargin = 0.4D * 72D;
//            pageSetup.HeaderMargin = pageSetup.FooterMargin = 0D;
//        }

//        private static void SetBordersStyle(Excel.Range range)
//        {
//            range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle =
//                range.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle =
//                    range.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle =
//                        range.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle =
//                            range.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle =
//                                range.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;

//            range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].Weight =
//                range.Borders[Excel.XlBordersIndex.xlInsideVertical].Weight =
//                    range.Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight =
//                        range.Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight =
//                            range.Borders[Excel.XlBordersIndex.xlEdgeRight].Weight =
//                                range.Borders[Excel.XlBordersIndex.xlEdgeTop].Weight = 2D;
//        }

//        private static void SetCommonStyle(Excel.Range cell)
//        {
//            cell.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
//            cell.Font.Name = "Times New Roman";
//            cell.Font.Size = 13;
//        }

//        private static void SetHeaderStyle(Excel.Range range)
//        {
//            range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
//            range.Font.Bold = true;
//            range.RowHeight = 40;
//        }

//        private Excel.Range GetCells(int row, int column)
//        {
//            return (Excel.Range) this._worksheet.Object.Cells[row, column];
//        }

//        private Task SaveSheetAsync()
//        {
//            return Task.Run(() =>
//            {
//                var name = AppDomain.CurrentDomain.BaseDirectory + Guid.NewGuid().ToString("N") + ".xls";
//                this._worksheet.Object.SaveAs(
//                    name,
//                    Excel.XlFileFormat.xlExcel8,
//                    ReadOnlyRecommended: false,
//                    CreateBackup: false,
//                    AddToMru: Excel.XlSaveAsAccessMode.xlShared);
//            });
//        }

//        private Task PrintSheetAsync()
//        {
//            return Task.Run(() => this._worksheet.Object.PrintOut());
//        }

//        private void DisposeObjects()
//        {
//            this._workbook.Object.Close(false);
//            this._application.Object.Quit();

//            this._worksheet.Dispose();
//            this._workbook.Dispose();
//            this._application.Dispose();
//        }
//    }
//}

redpajama_set_name: RedPajamaGithub


text:
(function() {
  var PNG, PNGImage, zlib;

  zlib = require('zlib');

  PNG = require('png-js');

  PNGImage = (function() {
    function PNGImage(data) {
      this.image = new PNG(data.data);
      this.width = this.image.width;
      this.height = this.image.height;
      this.imgData = this.image.imgData;
    }

    PNGImage.prototype.object = function(document, fn) {
      var mask, obj, palette, rgb, sMask, val, x, _i, _len,
        _this = this;
      if (!this.alphaChannel) {
        if (this.image.transparency.indexed) {
          this.loadIndexedAlphaChannel(function() {
            return _this.object(document, fn);
          });
          return;
        } else if (this.image.hasAlphaChannel) {
          this.splitAlphaChannel(function() {
            return _this.object(document, fn);
          });
          return;
        }
      }
      obj = document.ref({
        Type: 'XObject',
        Subtype: 'Image',
        BitsPerComponent: this.image.bits,
        Width: this.width,
        Height: this.height,
        Length: this.imgData.length,
        Filter: 'FlateDecode'
      });
      if (!this.image.hasAlphaChannel) {
        obj.data['DecodeParms'] = document.ref({
          Predictor: 15,
          Colors: this.image.colors,
          BitsPerComponent: this.image.bits,
          Columns: this.width
        });
      }
      if (this.image.palette.length === 0) {
        obj.data['ColorSpace'] = this.image.colorSpace;
      } else {
        palette = document.ref({
          Length: this.image.palette.length
        });
        palette.add(new Buffer(this.image.palette));
        obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', (this.image.palette.length / 3) - 1, palette];
      }
      if (this.image.transparency.grayscale) {
        val = this.image.transparency.greyscale;
        obj.data['Mask'] = [val, val];
      } else if (this.image.transparency.rgb) {
        rgb = this.image.transparency.rgb;
        mask = [];
        for (_i = 0, _len = rgb.length; _i < _len; _i++) {
          x = rgb[_i];
          mask.push(x, x);
        }
        obj.data['Mask'] = mask;
      }
      if (this.alphaChannel) {
        sMask = document.ref({
          Type: 'XObject',
          Subtype: 'Image',
          Height: this.height,
          Width: this.width,
          BitsPerComponent: 8,
          Length: this.alphaChannel.length,
          Filter: 'FlateDecode',
          ColorSpace: 'DeviceGray',
          Decode: [0, 1]
        });
        sMask.add(this.alphaChannel);
        obj.data['SMask'] = sMask;
      }
      obj.add(this.imgData);
      return fn(obj);
    };

    PNGImage.prototype.splitAlphaChannel = function(fn) {
      var _this = this;
      return this.image.decodePixels(function(pixels) {
        var a, alphaChannel, colorByteSize, done, i, imgData, len, p, pixelCount;
        colorByteSize = _this.image.colors * _this.image.bits / 8;
        pixelCount = _this.width * _this.height;
        imgData = new Buffer(pixelCount * colorByteSize);
        alphaChannel = new Buffer(pixelCount);
        i = p = a = 0;
        len = pixels.length;
        while (i < len) {
          imgData[p++] = pixels[i++];
          imgData[p++] = pixels[i++];
          imgData[p++] = pixels[i++];
          alphaChannel[a++] = pixels[i++];
        }
        done = 0;
        zlib.deflate(imgData, function(err, imgData) {
          _this.imgData = imgData;
          if (err) {
            throw err;
          }
          if (++done === 2) {
            return fn();
          }
        });
        return zlib.deflate(alphaChannel, function(err, alphaChannel) {
          _this.alphaChannel = alphaChannel;
          if (err) {
            throw err;
          }
          if (++done === 2) {
            return fn();
          }
        });
      });
    };

    PNGImage.prototype.loadIndexedAlphaChannel = function(fn) {
      var transparency,
        _this = this;
      transparency = this.image.transparency.indexed;
      return this.image.decodePixels(function(pixels) {
        var alphaChannel, i, j, _i, _ref;
        alphaChannel = new Buffer(_this.width * _this.height);
        i = 0;
        for (j = _i = 0, _ref = pixels.length; _i < _ref; j = _i += 1) {
          alphaChannel[i++] = transparency[pixels[j]];
        }
        return zlib.deflate(alphaChannel, function(err, alphaChannel) {
          _this.alphaChannel = alphaChannel;
          if (err) {
            throw err;
          }
          return fn();
        });
      });
    };

    return PNGImage;

  })();

  module.exports = PNGImage;

}).call(this);


text:
package alluxio.job.plan.load;

import alluxio.AlluxioURI;
import alluxio.Constants;
import alluxio.client.block.BlockWorkerInfo;
import alluxio.client.file.URIStatus;
import alluxio.collections.Pair;
import alluxio.exception.status.FailedPreconditionException;
import alluxio.job.RunTaskContext;
import alluxio.job.SelectExecutorsContext;
import alluxio.job.plan.AbstractVoidPlanDefinition;
import alluxio.job.plan.load.LoadDefinition.LoadTask;
import alluxio.job.util.JobUtils;
import alluxio.job.util.SerializableVoid;
import alluxio.util.CommonUtils;
import alluxio.wire.BlockLocation;
import alluxio.wire.FileBlockInfo;
import alluxio.wire.TieredIdentity.LocalityTier;
import alluxio.wire.WorkerInfo;
import alluxio.wire.WorkerNetAddress;

import com.google.common.base.MoreObjects;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * A simple loading job that loads the blocks of a file in a distributed and round-robin fashion.
 */
@NotThreadSafe
public final class LoadDefinition
    extends AbstractVoidPlanDefinition<LoadConfig, ArrayList<LoadTask>> {
  private static final Logger LOG = LoggerFactory.getLogger(LoadDefinition.class);
  private static final int MAX_BUFFER_SIZE = 500 * Constants.MB;
  private static final int JOBS_PER_WORKER = 10;

  /**
   * Constructs a new {@link LoadDefinition}.
   */
  public LoadDefinition() {
  }

  @Override
  public Set<Pair<WorkerInfo, ArrayList<LoadTask>>> selectExecutors(LoadConfig config,
      List<WorkerInfo> jobWorkerInfoList, SelectExecutorsContext context)
      throws Exception {
    Map<String, WorkerInfo> jobWorkersByAddress = jobWorkerInfoList.stream()
        .collect(Collectors.toMap(info -> info.getAddress().getHost(), info -> info));
    // Filter out workers which have no local job worker available.
    List<String> missingJobWorkerHosts = new ArrayList<>();
    List<BlockWorkerInfo> workers = new ArrayList<>();
    for (BlockWorkerInfo worker : context.getFsContext().getCachedWorkers()) {
      if (jobWorkersByAddress.containsKey(worker.getNetAddress().getHost())) {
        String workerHost = worker.getNetAddress().getHost().toUpperCase();
        if (!isEmptySet(config.getExcludedWorkerSet())
            && config.getExcludedWorkerSet().contains(workerHost)) {
          continue;
        }
        // If specified the locality id, the candidate worker must match one at least
        boolean match = false;
        if (worker.getNetAddress().getTieredIdentity().getTiers() != null) {
          if (!(isEmptySet(config.getLocalityIds())
              && isEmptySet(config.getExcludedLocalityIds()))) {
            boolean exclude = false;
            for (LocalityTier tier : worker.getNetAddress().getTieredIdentity().getTiers()) {
              if (!isEmptySet(config.getExcludedLocalityIds())
                  && config.getExcludedLocalityIds().contains(tier.getValue().toUpperCase())) {
                exclude = true;
                break;
              }
              if (!isEmptySet(config.getLocalityIds())
                  && config.getLocalityIds().contains(tier.getValue().toUpperCase())) {
                match = true;
                break;
              }
            }
            if (exclude) {
              continue;
            }
          }
        }
        // Add current worker as candidate worker
        // if it matches the given locality id or contained in the given worker set
        // Or user specified neither worker-set nor locality id
        if ((isEmptySet(config.getWorkerSet()) && isEmptySet(config.getLocalityIds()))
            || match
            || (!isEmptySet(config.getWorkerSet())
                && config.getWorkerSet().contains(workerHost))) {
          workers.add(worker);
        }
      } else {
        LOG.warn("Worker on host {} has no local job worker", worker.getNetAddress().getHost());
        missingJobWorkerHosts.add(worker.getNetAddress().getHost());
      }
    }
    // Mapping from worker to block ids which that worker is supposed to load.
    Multimap<WorkerInfo, LoadTask> assignments = LinkedListMultimap.create();
    AlluxioURI uri = new AlluxioURI(config.getFilePath());
    for (FileBlockInfo blockInfo : context.getFileSystem().getStatus(uri).getFileBlockInfos()) {
      List<BlockWorkerInfo> workersWithoutBlock = getWorkersWithoutBlock(workers, blockInfo);
      int neededReplicas = config.getReplication() - blockInfo.getBlockInfo().getLocations().size();
      if (workersWithoutBlock.size() < neededReplicas) {
        String missingJobWorkersMessage = "";
        if (!missingJobWorkerHosts.isEmpty()) {
          missingJobWorkersMessage = ". The following workers could not be used because they have "
              + "no local job workers: " + missingJobWorkerHosts;
        }
        throw new FailedPreconditionException(String.format(
            "Failed to find enough block workers to replicate to. Needed %s but only found %s. "
            + "Available workers without the block: %s" + missingJobWorkersMessage,
            neededReplicas, workersWithoutBlock.size(), workersWithoutBlock));
      }
      Collections.shuffle(workersWithoutBlock);
      for (int i = 0; i < neededReplicas; i++) {
        String address = workersWithoutBlock.get(i).getNetAddress().getHost();
        WorkerInfo jobWorker = jobWorkersByAddress.get(address);
        assignments.put(jobWorker, new LoadTask(blockInfo.getBlockInfo().getBlockId(),
            workersWithoutBlock.get(i).getNetAddress()));
      }
    }

    Set<Pair<WorkerInfo, ArrayList<LoadTask>>> result = Sets.newHashSet();
    for (Map.Entry<WorkerInfo, Collection<LoadTask>> assignment : assignments.asMap().entrySet()) {
      Collection<LoadTask> loadTasks = assignment.getValue();
      List<List<LoadTask>> partitionedTasks =
          CommonUtils.partition(Lists.newArrayList(loadTasks), JOBS_PER_WORKER);

      for (List<LoadTask> tasks : partitionedTasks) {
        if (!tasks.isEmpty()) {
          result.add(new Pair<>(assignment.getKey(), Lists.newArrayList(tasks)));
        }
      }
    }

    return result;
  }

  /**
   * @param blockWorkers a list of block workers
   * @param blockInfo information about a block
   * @return the block worker hosts which are not storing the specified block
   */
  private List<BlockWorkerInfo> getWorkersWithoutBlock(List<BlockWorkerInfo> blockWorkers,
      FileBlockInfo blockInfo) {
    List<WorkerNetAddress> blockLocations = blockInfo.getBlockInfo().getLocations().stream()
        .map(BlockLocation::getWorkerAddress)
        .collect(Collectors.toList());

    return blockWorkers.stream()
        .filter(worker -> !blockLocations.contains(worker.getNetAddress()))
        .collect(Collectors.toList());
  }

  @Override
  public SerializableVoid runTask(LoadConfig config, ArrayList<LoadTask> tasks,
      RunTaskContext context) throws Exception {

    // TODO(jiri): Replace with internal client that uses file ID once the internal client is
    // factored out of the core server module. The reason to prefer using file ID for this job is
    // to avoid the the race between "replicate" and "rename", so that even a file to replicate is
    // renamed, the job is still working on the correct file.
    URIStatus status = context.getFileSystem().getStatus(new AlluxioURI(config.getFilePath()));

    for (LoadTask task : tasks) {
      JobUtils.loadBlock(status, context.getFsContext(), task.getBlockId(),
          task.getWorkerNetAddress(), config.isDirectCache());
      LOG.info("Loaded file " + config.getFilePath() + " block " + task.getBlockId());
    }
    return null;
  }

  private boolean isEmptySet(Set s) {
    return s == null || s.isEmpty();
  }

  /**
   * A task representing loading a block into the memory of a worker.
   */
  public static class LoadTask implements Serializable {
    private static final long serialVersionUID = 2028545900913354425L;
    final long mBlockId;
    final WorkerNetAddress mWorkerNetAddress;

    /**
     * @param blockId the id of the block to load
     * @param workerNetAddress worker net address
     */
    public LoadTask(long blockId, WorkerNetAddress workerNetAddress) {
      mBlockId = blockId;
      mWorkerNetAddress = workerNetAddress;
    }

    /**
     * @return the block id
     */
    public long getBlockId() {
      return mBlockId;
    }

    /**
     * @return worker net address
     */
    public WorkerNetAddress getWorkerNetAddress() {
      return mWorkerNetAddress;
    }

    @Override
    public String toString() {
      return MoreObjects.toStringHelper(this)
          .add("blockId", mBlockId)
          .add("workerNetAddress", mWorkerNetAddress)
          .toString();
    }
  }

  @Override
  public Class<LoadConfig> getJobConfigClass() {
    return LoadConfig.class;
  }
}


text:
package org.apache.bval.jsr.xml;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javax.validation.BootstrapConfiguration;
import javax.validation.ValidationException;
import javax.validation.executable.ExecutableType;

import org.apache.bval.jsr.BootstrapConfigurationImpl;
import org.apache.bval.jsr.ConfigurationImpl;
import org.apache.bval.jsr.metadata.XmlBuilder;
import org.apache.bval.util.Exceptions;
import org.apache.bval.util.Validate;
import org.apache.bval.util.reflection.Reflection;
import org.apache.commons.weaver.privilizer.Privileged;
import org.apache.commons.weaver.privilizer.Privilizing;
import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
import org.xml.sax.InputSource;

/**
 * Description: uses jaxb to parse validation.xml<br/>
 */
@Privilizing(@CallTo(Reflection.class))
public class ValidationParser {

    private static final String DEFAULT_VALIDATION_XML_FILE = "META-INF/validation.xml";
    private static final Logger log = Logger.getLogger(ValidationParser.class.getName());

    private static final SchemaManager SCHEMA_MANAGER = new SchemaManager.Builder()
        .add(XmlBuilder.Version.v10.getId(), "http://jboss.org/xml/ns/javax/validation/configuration",
            "META-INF/validation-configuration-1.0.xsd")
        .add(XmlBuilder.Version.v11.getId(), "http://jboss.org/xml/ns/javax/validation/configuration",
            "META-INF/validation-configuration-1.1.xsd")
        .add(XmlBuilder.Version.v30.getId(), "https://jakarta.ee/xml/ns/validation/configuration",
                "META-INF/validation-configuration-3.0.xsd")
        .add(XmlBuilder.Version.v20.getId(), "http://xmlns.jcp.org/xml/ns/validation/configuration",
            "META-INF/validation-configuration-2.0.xsd")
        .build();

    private static String getValidationXmlFile(String file) {
        return file == null ? DEFAULT_VALIDATION_XML_FILE : file;
    }

    private static Map<String, String> toMap(final List<PropertyType> property) {
        return property == null || property.isEmpty() ? Collections.emptyMap()
            : property.stream().collect(Collectors.toMap(PropertyType::getName, PropertyType::getValue));
    }

    private final ClassLoader loader;

    public ValidationParser(ClassLoader loader) {
        this.loader = Validate.notNull(loader, null);
    }

    public BootstrapConfiguration processValidationConfig(final String file,
        final ConfigurationImpl targetConfig) {
        final ValidationConfigType xmlConfig = parseXmlConfig(file);
        if (xmlConfig == null) {
            return null;
        }
        final boolean executableValidationEnabled;
        final Set<ExecutableType> defaultValidatedExecutableTypes;

        if (xmlConfig.getExecutableValidation() == null) {
            defaultValidatedExecutableTypes = EnumSet.of(ExecutableType.IMPLICIT);
            executableValidationEnabled = true;
        } else {
            final Optional<ExecutableValidationType> executableValidation =
                Optional.of(xmlConfig).map(ValidationConfigType::getExecutableValidation);
            executableValidationEnabled = executableValidation.map(ExecutableValidationType::getEnabled)
                .filter(Predicate.isEqual(Boolean.TRUE)).isPresent();

            defaultValidatedExecutableTypes = executableValidation.filter(x -> executableValidationEnabled)
                .map(ExecutableValidationType::getDefaultValidatedExecutableTypes)
                .map(DefaultValidatedExecutableTypesType::getExecutableType).map(EnumSet::copyOf)
                .orElse(EnumSet.noneOf(ExecutableType.class));
        }
        return new BootstrapConfigurationImpl(xmlConfig.getDefaultProvider(), xmlConfig.getConstraintValidatorFactory(),
            xmlConfig.getMessageInterpolator(), xmlConfig.getTraversableResolver(),
            xmlConfig.getParameterNameProvider(), new HashSet<>(xmlConfig.getConstraintMapping()),
            executableValidationEnabled, defaultValidatedExecutableTypes, toMap(xmlConfig.getProperty()),
            xmlConfig.getClockProvider(), new HashSet<>(xmlConfig.getValueExtractor()));
    }

    public InputStream open(String mappingFileName) {
        if (mappingFileName.charAt(0) == '/') {
            // Classloader needs a path without a starting /
            mappingFileName = mappingFileName.substring(1);
        }
        try {
            final InputStream in = getInputStream(mappingFileName);
            Exceptions.raiseIf(in == null, ValidationException::new,
                    "Unable to open input stream for mapping file %s", mappingFileName);
            return(in);
        } catch (IOException e) {
            throw Exceptions.create(ValidationException::new, e, "Unable to open input stream for mapping file %s",
                mappingFileName);
        }
    }

    InputStream getInputStream(final String path) throws IOException {
        final List<URL> urls = Collections.list(loader.getResources(path));
        Exceptions.raiseIf(urls.stream().distinct().count() > 1, ValidationException::new,
            "More than one %s is found in the classpath", path);
        return urls.isEmpty() ? null : urls.get(0).openStream();
    }

    @Privileged
    private ValidationConfigType parseXmlConfig(final String validationXmlFile) {
        try (InputStream inputStream = getInputStream(getValidationXmlFile(validationXmlFile))) {
            if (inputStream == null) {
                log.log(Level.FINEST,
                    String.format("No %s found. Using annotation based configuration only.", validationXmlFile));
                return null;
            }
            log.log(Level.FINEST, String.format("%s found.", validationXmlFile));

            return SCHEMA_MANAGER.unmarshal(new InputSource(inputStream), ValidationConfigType.class);
        } catch (Exception e) {
            throw Exceptions.create(ValidationException::new, e, "Unable to parse %s", validationXmlFile);
        }
    }
}


text:
ngapp.controller('manageExtensionsModalController', function($scope, extensionService, modalService) {
    $scope.tabs = extensionService.getTabs();
    modalService.initTabsModal($scope);
});


text:
'use strict';

const chalk = require('chalk');
const os = require('os');
const fsExtra = require('fs-extra');
const Spinner = require('cli-spinner').Spinner;

const spinner = new Spinner('%s');

/**
 * Check operation system name
 * @return {Boolean} Is OS Windows or not
 */
function isWindows() {
    return (/^win/i).test(os.platform());
}

if (isWindows()) {
    spinner.setSpinnerString('|/-\\');
} else {
    spinner.setSpinnerString('⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏');
}

/**
 * Helper function for spinner, just stop and start spinner
 */
spinner.restart = function restart() {
    this.stop(true);
    this.start();
};

module.exports = {

    /**
     * Check that TARS inited in current directory.
     * @return {Object}
     */
    isTarsInited() {
        const cwd = process.cwd();

        try {
            require(`${cwd}/tars-config`);
        } catch (error) {
            if (error.code !== 'MODULE_NOT_FOUND') {
                this.tarsSay(chalk.red('There are some problems with your tars-config.js!\n'), true);
                console.error(error.stack);
                return {
                    inited: true,
                    error: true
                };
            }

            return {
                inited: false,
                error: false
            };
        }

        return {
            inited: true,
            error: false
        };
    },

    /**
     * Gets TARS-config from TARS in current directory.
     * @return {boolean | object} tars-config
     */
    getTarsConfig() {
        const cwd = process.cwd();
        const initedStatus = this.isTarsInited();

        if (initedStatus.inited && !initedStatus.error) {
            return require(`${cwd}/tars-config`);
        }

        if (!initedStatus.error) {
            this.tarsNotInitedActions();
        }
        return false;
    },

    getTarsProjectVersion() {
        const cwd = process.cwd();

        if (this.isTarsInited().inited) {
            return fsExtra.readJsonSync(`${cwd}/tars.json`).version;
        }

        this.tarsNotInitedActions();
        return false;
    },

    /**
     * Output messages from TARS
     * @param  {String}  message Message to output
     * @param  {Boolean} Stopspinner or restart it
     */
    tarsSay(message, stopSpinner) {

        // Restart spinner after every message from TARS
        if (stopSpinner) {
            this.spinner.stop(true);
        } else {
            this.spinner.restart();
        }

        if (os.platform() === 'darwin') {
            console.log(chalk.bold.cyan('🅃 🄰 🅁 🅂 : ') + chalk.bold.white(message));
        } else {
            console.log(chalk.bold.cyan('[ TARS ]: ') + chalk.bold.white(message));
        }
    },

    /**
     * Actions, then TARS is not inited
     * @return {[type]} [description]
     */
    tarsNotInitedActions() {
        console.log('\n');
        this.tarsSay(chalk.red('TARS is not inited.'));
        this.tarsSay(`Use ${chalk.bold.cyan('"tars init"')} to init TARS in current directory.\n`, true);
    },

    /**
     * Validate folder name
     * @param  {String}                     Value Recieved folder name
     * @return {Boolean || String}          True or error text (not consistent, because of inquirer va)
     */
    validateFolderName(value) {
        const pass = /[?<>:*|"\\]/.test(value);

        if (!pass) {
            return true;
        }

        return 'Symbols \'?<>:*|"\\\' are not allowed. Please, enter a valid folder name!';
    },

    /**
     * Extract only used flags from inquirer options
     * @param  {Object} Inquirer options
     * @return {Array}
     */
    getUsedFlags(inquirerOptions) {
        return Object.keys(inquirerOptions).reduce((result, currentValue) => {
            if (currentValue.indexOf('_') !== 0 && currentValue !== 'options' &&
                currentValue !== 'commands' && currentValue !== 'parent') {
                result.push(currentValue);
            }

            return result;
        }, []);
    },

    spinner,

    /**
     * Determines is current platform windows.
     * @return {boolean}
     */
    isWindows
};


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="BookmarkManager">
    <bookmark url="file://$PROJECT_DIR$/lib/esConnector.js" line="122" mnemonic="0" />
  </component>
  <component name="ChangeListManager">
    <list default="true" id="4f34650d-9150-4224-b6cf-0b63a94dccc0" name="Default" comment="+ Correct english texts
+ Fix code comments and params
+ Add some unit test">
      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" />
      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/loopback_connector_elastic_search_node_modules.xml" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
    </list>
    <ignored path="loopback-connector-elastic-search.iws" />
    <ignored path=".idea/workspace.xml" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="DaemonCodeAnalyzer">
    <disable_hints />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
  <component name="FavoritesManager">
    <favorites_list name="loopback-connector-elastic-search" />
  </component>
  <component name="FileEditorManager">
    <leaf>
      <file leaf-file-name="esConnector.js" pinned="false" current="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/lib/esConnector.js">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="0.0" vertical-offset="1603" max-vertical-offset="8802">
              <caret line="97" column="46" selection-start-line="0" selection-start-column="0" selection-end-line="483" selection-end-column="41" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="elastic.js" pinned="false" current="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/examples/node_modules/loopback-connector-elastic-search/lib/elastic.js">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="0.0" vertical-offset="1621" max-vertical-offset="8802">
              <caret line="106" column="42" selection-start-line="106" selection-start-column="42" selection-end-line="106" selection-end-column="42" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="package.json" pinned="false" current="true" current-in-tab="true">
        <entry file="file://$PROJECT_DIR$/package.json">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-0.43326038" vertical-offset="432" max-vertical-offset="900">
              <caret line="13" column="4" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
    </leaf>
  </component>
  <component name="FindManager">
    <FindUsagesManager>
      <setting name="OPEN_NEW_TAB" value="true" />
    </FindUsagesManager>
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="IdeDocumentHistory">
    <option name="changedFiles">
      <list>
        <option value="$PROJECT_DIR$/README.md" />
        <option value="$PROJECT_DIR$/lib/elastic.js" />
        <option value="$PROJECT_DIR$/examples/package.json" />
        <option value="$PROJECT_DIR$/test/datasource-test.json" />
        <option value="$PROJECT_DIR$/test/settings-test.js" />
        <option value="$PROJECT_DIR$/test/filter-test.js" />
        <option value="$PROJECT_DIR$/test/makeId-test.js" />
        <option value="$PROJECT_DIR$/lib/esConnector.js" />
        <option value="$PROJECT_DIR$/test/mock-data-test.json" />
        <option value="$PROJECT_DIR$/test/init.js" />
        <option value="$PROJECT_DIR$/test/resource/mock-data-test.json" />
        <option value="$PROJECT_DIR$/test/resource/model-test.json" />
        <option value="$PROJECT_DIR$/test/match-model-test.js" />
        <option value="$PROJECT_DIR$/Gruntfile.js" />
        <option value="$PROJECT_DIR$/HISTORY" />
        <option value="$PROJECT_DIR$/examples/node_modules/loopback-connector-elastic-search/lib/elastic.js" />
        <option value="$PROJECT_DIR$/package.json" />
      </list>
    </option>
  </component>
  <component name="NodeJsMochaPackageDirSetting">
    <data>$PROJECT_DIR$/node_modules/mocha</data>
  </component>
  <component name="ProjectFrameBounds">
    <option name="width" value="1600" />
    <option name="height" value="876" />
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="2" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectReloadState">
    <option name="STATE" value="0" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource ProjectPane="true" />
      <sortByType />
    </navigator>
    <panes>
      <pane id="ProjectPane">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="test" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="test" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="resource" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="lib" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="examples" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="examples" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="server" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="examples" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="node_modules" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="examples" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="node_modules" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="examples" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="node_modules" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="loopback-connector-elastic-search" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="lib" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
      <pane id="Scope" />
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="options.lastSelected" value="Errors" />
    <property name="options.splitter.main.proportions" value="0.3" />
    <property name="options.splitter.details.proportions" value="0.2" />
    <property name="options.searchVisible" value="true" />
    <property name="WebServerToolWindowFactoryState" value="false" />
    <property name="LayoutCode.rearrangeEntriesJavaScript" value="false" />
    <property name="LayoutCode.rearrangeEntriesJSON" value="false" />
    <property name="recentsLimit" value="5" />
    <property name="last_opened_file_path" value="$PROJECT_DIR$/test" />
    <property name="restartRequiresConfirmation" value="false" />
  </component>
  <component name="RecentsManager">
    <key name="MoveFile.RECENT_KEYS">
      <recent name="$PROJECT_DIR$/test/resource" />
    </key>
  </component>
  <component name="RunManager" selected="Node.js.example">
    <configuration default="true" type="DartUnitRunConfigurationType" factoryName="DartUnit">
      <option name="VMOptions" />
      <option name="arguments" />
      <option name="filePath" />
      <option name="scope" value="ALL" />
      <option name="testName" />
      <method />
    </configuration>
    <configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
      <option name="VMOptions" />
      <option name="arguments" />
      <option name="filePath" />
      <option name="name" value="Dart" />
      <option name="saveOutputToFile" value="false" />
      <option name="showConsoleOnStdErr" value="false" />
      <option name="showConsoleOnStdOut" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="CucumberJavaScriptRunConfigurationType" factoryName="Cucumber.js">
      <option name="cucumberJsArguments" />
      <option name="executablePath" />
      <option name="filePath" />
      <method />
    </configuration>
    <configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma" config-file="">
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="JSTestDriver:ConfigurationType" factoryName="JsTestDriver">
      <setting name="configLocationType" value="CONFIG_FILE" />
      <setting name="settingsFile" value="" />
      <setting name="serverType" value="INTERNAL" />
      <setting name="preferredDebugBrowser" value="Chromium" />
      <method />
    </configuration>
    <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
      <method />
    </configuration>
    <configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
      <node-options />
      <working-directory>/usr/local/lib/node_modules/mocha</working-directory>
      <pass-parent-env>true</pass-parent-env>
      <envs />
      <ui>BDD</ui>
      <extra-mocha-options />
      <test-directory />
      <recursive>false</recursive>
      <method />
    </configuration>
    <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" working-dir="">
      <method />
    </configuration>
    <configuration default="false" name="example" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="/usr/local/bin/node" path-to-js-file="examples/server/server.js" working-dir="$PROJECT_DIR$">
      <RunnerSettings RunnerId="NodeJS.debug" />
      <ConfigurationWrapper RunnerId="NodeJS.debug" />
      <method />
    </configuration>
    <configuration default="false" name="test" type="mocha-javascript-test-runner" factoryName="Mocha">
      <node-options />
      <working-directory>$PROJECT_DIR$</working-directory>
      <pass-parent-env>true</pass-parent-env>
      <envs />
      <ui>BDD</ui>
      <extra-mocha-options />
      <test-directory>$PROJECT_DIR$/test</test-directory>
      <recursive>false</recursive>
      <RunnerSettings RunnerId="MochaDebugRunner" />
      <ConfigurationWrapper RunnerId="MochaDebugRunner" />
      <method />
    </configuration>
    <list size="2">
      <item index="0" class="java.lang.String" itemvalue="Node.js.example" />
      <item index="1" class="java.lang.String" itemvalue="Mocha.test" />
    </list>
  </component>
  <component name="ShelveChangesManager" show_recycled="false" />
  <component name="SvnConfiguration">
    <configuration />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="4f34650d-9150-4224-b6cf-0b63a94dccc0" name="Default" comment="" />
      <created>1412099720640</created>
      <updated>1412099720640</updated>
    </task>
    <task id="LOCAL-00001" summary="General packages and readme changes">
      <created>1412099843508</created>
      <updated>1412099843508</updated>
    </task>
    <task id="LOCAL-00002" summary="General packages and readme changes">
      <created>1412100355588</created>
      <updated>1412100355588</updated>
    </task>
    <task id="LOCAL-00003" summary="+ Correct english texts
+ Fix code comments and params
+ Add some unit test">
      <created>1412189923558</created>
      <updated>1412189923558</updated>
    </task>
    <option name="localTasksCounter" value="4" />
    <servers />
  </component>
  <component name="TodoView" selected-index="0">
    <todo-panel id="selected-file">
      <are-packages-shown value="false" />
      <are-modules-shown value="false" />
      <flatten-packages value="false" />
      <is-autoscroll-to-source value="false" />
    </todo-panel>
    <todo-panel id="all">
      <are-packages-shown value="false" />
      <are-modules-shown value="false" />
      <flatten-packages value="false" />
      <is-autoscroll-to-source value="false" />
    </todo-panel>
    <todo-panel id="default-changelist">
      <are-packages-shown value="false" />
      <are-modules-shown value="false" />
      <flatten-packages value="false" />
      <is-autoscroll-to-source value="false" />
    </todo-panel>
  </component>
  <component name="ToolWindowManager">
    <frame x="0" y="0" width="1600" height="876" extended-state="6" />
    <editor active="true" />
    <layout>
      <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3298292" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3285151" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3298292" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24952501" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39947438" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3298292" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
    </layout>
  </component>
  <component name="Vcs.Log.UiProperties">
    <option name="RECENTLY_FILTERED_USER_GROUPS">
      <collection />
    </option>
    <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
      <collection />
    </option>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="VcsManagerConfiguration">
    <option name="myTodoPanelSettings">
      <TodoPanelSettings />
    </option>
    <MESSAGE value="General packages and readme changes" />
    <MESSAGE value="+ Correct english texts
+ Fix code comments and params
+ Add some unit test" />
    <option name="LAST_COMMIT_MESSAGE" value="+ Correct english texts
+ Fix code comments and params
+ Add some unit test" />
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager>
      <option name="time" value="24" />
    </breakpoint-manager>
  </component>
  <component name="editorHistoryManager">
    <entry file="file://$PROJECT_DIR$/TODO">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="734">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/examples/package.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.49131513" vertical-offset="0" max-vertical-offset="468">
          <caret line="11" column="34" selection-start-line="11" selection-start-column="34" selection-end-line="11" selection-end-column="34" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/index.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="126">
          <caret line="0" column="39" selection-start-line="0" selection-start-column="39" selection-end-line="0" selection-end-column="39" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/examples/server/datasources.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.66997516" vertical-offset="0" max-vertical-offset="403">
          <caret line="15" column="0" selection-start-line="15" selection-start-column="0" selection-end-line="15" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/resource/datasource-test.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.3126551" vertical-offset="0" max-vertical-offset="403">
          <caret line="7" column="26" selection-start-line="7" selection-start-column="26" selection-end-line="7" selection-end-column="26" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/makeId-test.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.2511628" vertical-offset="0" max-vertical-offset="430">
          <caret line="6" column="37" selection-start-line="6" selection-start-column="37" selection-end-line="6" selection-end-column="37" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
      <provider editor-type-id="MarkdownPreviewEditor">
        <state />
      </provider>
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="404">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/examples/common/models/entry.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.89330024" vertical-offset="54" max-vertical-offset="630">
          <caret line="23" column="6" selection-start-line="0" selection-start-column="0" selection-end-line="29" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/README.md">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.31188118" vertical-offset="0" max-vertical-offset="2196">
          <caret line="7" column="43" selection-start-line="7" selection-start-column="43" selection-end-line="7" selection-end-column="43" />
          <folding />
        </state>
      </provider>
      <provider editor-type-id="MarkdownPreviewEditor">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/examples/node_modules/loopback-boot/lib/executor.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.33255813" vertical-offset="2845" max-vertical-offset="3960">
          <caret line="166" column="4" selection-start-line="166" selection-start-column="4" selection-end-line="166" selection-end-column="4" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/settings-test.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.66976744" vertical-offset="108" max-vertical-offset="576">
          <caret line="22" column="8" selection-start-line="22" selection-start-column="8" selection-end-line="22" selection-end-column="41" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/filter-test.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.54418606" vertical-offset="0" max-vertical-offset="756">
          <caret line="13" column="12" selection-start-line="13" selection-start-column="12" selection-end-line="13" selection-end-column="62" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/resource/mock-data-test.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.3126551" vertical-offset="0" max-vertical-offset="403">
          <caret line="7" column="16" selection-start-line="7" selection-start-column="5" selection-end-line="7" selection-end-column="16" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/resource/model-test.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.75930524" vertical-offset="0" max-vertical-offset="576">
          <caret line="17" column="20" selection-start-line="17" selection-start-column="20" selection-end-line="17" selection-end-column="20" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/HISTORY">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.29752067" vertical-offset="0" max-vertical-offset="484">
          <caret line="8" column="10" selection-start-line="8" selection-start-column="10" selection-end-line="8" selection-end-column="10" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Gruntfile.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.6322314" vertical-offset="0" max-vertical-offset="484">
          <caret line="17" column="43" selection-start-line="17" selection-start-column="43" selection-end-line="17" selection-end-column="43" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/init.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.446281" vertical-offset="0" max-vertical-offset="484">
          <caret line="12" column="2" selection-start-line="12" selection-start-column="2" selection-end-line="12" selection-end-column="2" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/test/match-model-test.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.55785125" vertical-offset="0" max-vertical-offset="846">
          <caret line="15" column="37" selection-start-line="15" selection-start-column="37" selection-end-line="15" selection-end-column="37" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/lib/esConnector.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="1603" max-vertical-offset="8802">
          <caret line="97" column="46" selection-start-line="0" selection-start-column="0" selection-end-line="483" selection-end-column="41" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/examples/node_modules/loopback-connector-elastic-search/lib/elastic.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="1621" max-vertical-offset="8802">
          <caret line="106" column="42" selection-start-line="106" selection-start-column="42" selection-end-line="106" selection-end-column="42" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/package.json">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-0.43326038" vertical-offset="432" max-vertical-offset="900">
          <caret line="13" column="4" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" />
          <folding />
        </state>
      </provider>
    </entry>
  </component>
</project>


text:
using System;
using System.Runtime.InteropServices;

namespace Cheer.JsonVisualizer.CoreServices.Interop
{
    public static class Gdi32
    {
        [DllImport("gdi32.dll")]
        public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
    }
}


text:
import * as sinon from 'sinon';
import { Type } from '@es-git/core';
import { GitObject } from '@es-git/object-mixin';

import readCombinerMixin from './index';

test('load', async () => {
  const load = sinon.stub();
  const {promise, resolve} = defer();
  load.returns(promise);
  const objectRepo = new ReadCombinerRepo({load});
  const result1 = objectRepo.loadObject('object');
  const result2 = objectRepo.loadObject('object');
  const race = Promise.race([
    result1.then(x => false),
    result2.then(x => false),
    Promise.resolve(true)
  ]);
  resolve({type: Type.blob, body: new Uint8Array(0)});
  expect(await race).toBe(true);
});

test('loadObject of super called only once', async () => {
  const load = sinon.stub();
  const {promise, resolve} = defer();
  load.returns(promise);
  const objectRepo = new ReadCombinerRepo({load});
  const result1 = objectRepo.loadObject('object');
  const result2 = objectRepo.loadObject('object');
  const result3 = objectRepo.loadObject('object');
  const result4 = objectRepo.loadObject('object');
  resolve({type: Type.blob, body: new Uint8Array(0)});
  expect(load.calledOnce).toBe(true);
});

const ReadCombinerRepo = readCombinerMixin(class TestRepo {
  private readonly load : sinon.SinonStub;
  private readonly map : Map<string, GitObject>;
  constructor({load} : {load? : sinon.SinonStub} = {}){
    this.load = load || sinon.stub();
    this.map = new Map<string, GitObject>();
  }
  async saveObject(object : GitObject){
    const hash = new Date().toISOString();
    this.map.set(hash, object);
    return hash;
  }
  async loadObject(hash : string){
    return this.load(hash);
  }
});

function defer(){
  let resolve = (v? : any) => {};
  let reject = (e? : any) => {};
  return {
    promise: new Promise((res, rej) => {resolve = res, reject = res}),
    resolve,
    reject
  }
}


text:
package android.support.v4.view.accessibility;

import android.view.accessibility.AccessibilityManager;
import java.util.List;

// Referenced classes of package android.support.v4.view.accessibility:
//            j, k

class i
{

    i()
    {
    }

    public static Object a(k k)
    {
        return new j(k);
    }

    public static List a(AccessibilityManager accessibilitymanager)
    {
        return accessibilitymanager.getInstalledAccessibilityServiceList();
    }

    public static List a(AccessibilityManager accessibilitymanager, int k)
    {
        return accessibilitymanager.getEnabledAccessibilityServiceList(k);
    }

    public static boolean a(AccessibilityManager accessibilitymanager, Object obj)
    {
        return accessibilitymanager.addAccessibilityStateChangeListener((android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener)obj);
    }

    public static boolean b(AccessibilityManager accessibilitymanager)
    {
        return accessibilitymanager.isTouchExplorationEnabled();
    }

    public static boolean b(AccessibilityManager accessibilitymanager, Object obj)
    {
        return accessibilitymanager.removeAccessibilityStateChangeListener((android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener)obj);
    }
}


text:
package com.github.alexcojocaru.mojo.elasticsearch.v2;

import java.io.File;

import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;

import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;

/**
 * Base mojo to define maven parameters required by all ES mojos.
 *
 * @author Alex Cojocaru
 */
public abstract class AbstractElasticsearchBaseMojo
        extends AbstractMojo
        implements ElasticsearchBaseConfiguration
{
    /**
     * The number of Elasticsearch nodes to start within the cluster.
     */
    @Parameter(property="es.instanceCount", defaultValue = "1")
    protected int instanceCount;

    /**
     * The Elasticsearch base path.
     */
    @Parameter(defaultValue = "${project.build.directory}/elasticsearch", readonly = true)
    protected File baseDir;

    /**
     * Whether to skip the plugin execution or not.
     */
    @Parameter(property="es.skip", defaultValue = "false")
    protected boolean skip;

    /**
     * The plugin log level.
     */
    @Parameter(property="es.logLevel", defaultValue = "INFO")
    protected String logLevel;

    private Log log;

    @Override
    public int getInstanceCount()
    {
        return instanceCount;
    }

    public void setInstanceCount(int instanceCount)
    {
        this.instanceCount = instanceCount;
    }

    @Override
    public File getBaseDir()
    {
        return baseDir;
    }

    public void setBaseDir(File baseDir)
    {
        this.baseDir = baseDir;
    }

    @Override
    public boolean isSkip()
    {
        return skip;
    }

    public void setSkip(boolean skip)
    {
        this.skip = skip;
    }

    @Override
    public String getLogLevel()
    {
        return logLevel;
    }

    public void setLogLevel(String logLevel)
    {
        this.logLevel = logLevel;
    }

    private int getMavenLogLevel()
    {
        switch (logLevel)
        {
            case "DEBUG":
                return Logger.LEVEL_DEBUG;
            case "WARN":
                return Logger.LEVEL_WARN;
            case "ERROR":
                return Logger.LEVEL_ERROR;
            case "FATAL":
                return Logger.LEVEL_FATAL;
            case "DISABLED":
                return Logger.LEVEL_DISABLED;
            case "INFO":
            default:
                return Logger.LEVEL_INFO;
        }
    }

    @Override
    public Log getLog()
    {
        if (log == null)
        {
            log = new DefaultLog(new ConsoleLogger(getMavenLogLevel(), "console"));
        }
        return log;
    }

    @Override
    public ClusterConfiguration buildClusterConfiguration()
    {
        ClusterConfiguration.Builder clusterConfigBuilder = new ClusterConfiguration.Builder()
                .withArtifactResolver(buildArtifactResolver())
                .withLog(getLog());

        for (int i = 0; i < instanceCount; i++)
        {
            clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
                    .withId(i)
                    .withBaseDir(baseDir.getAbsolutePath() + i)
                    .build());
        }

        ClusterConfiguration clusterConfig = clusterConfigBuilder.build();

        return clusterConfig;
    }

    @Override
    public PluginArtifactResolver buildArtifactResolver()
    {
        ChainedArtifactResolver artifactResolver = new ChainedArtifactResolver();
        return artifactResolver;
    }

}


text:
class Finding < ActiveRecord::Base
  include Filterable

  validates :repo_id, presence: true
  validates :fingerprint, presence: true

  before_create :filter!

  after_save do
    CodeburnerUtil.update_repo_stats(self.repo.id)
    CodeburnerUtil.update_system_stats
  end

  attr_default  :status, 0

  has_and_belongs_to_many    :burns
  belongs_to    :repo
  belongs_to    :branch
  belongs_to    :filter

  scope :id,                  -> (finding_id)   { scope_multiselect('findings.id', finding_id) }
  scope :burn_id,             -> (burn_id)      { joins('INNER JOIN burns_findings ON findings.id = burns_findings.finding_id').where('burns_findings.burn_id = ?', burn_id) }
  scope :description,         -> (description)  { where description: description }
  scope :detail,              -> (detail)       { where detail: detail }
  scope :repo_id,             -> (repo_id)      { scope_multiselect('findings.repo_id', repo_id) }
  scope :branch_id,           -> (branch_id)    { scope_multiselect('findings.branch_id', branch_id) }
  scope :branch,              -> (branch_name)  { joins(:branch).where('branches.name = ?', branch_name) }
  scope :repo_name,           -> (repo_name)    { joins(:repo).where('lower(repos.full_name) = ? OR lower(repos.name) = ?', repo_name.downcase, repo_name.downcase) }
  scope :severity,            -> (severity)     { where severity: severity }
  scope :fingerprint,         -> (fingerprint)  { where fingerprint: fingerprint }
  scope :scanner,             -> (scanner)      { where scanner: scanner }
  scope :file,                -> (file)         { where file: file }
  scope :line,                -> (line)         { where line: line }
  scope :code,                -> (code)         { where code: code }
  scope :status,              -> (status)       { scope_multiselect('findings.status', status.to_s) }
  scope :filtered_by,         -> (filter_id)    { joins(:filter).where('filters.id = ?', filter_id)}
  scope :repo_portal,         -> (repo_portal)  { joins(:burn).where('burns.repo_portal = ?', repo_portal) }
  scope :only_current,        ->                { where current: true }

  def filter!
    hit = self.filtered_by?

    if hit.count > 0
      self.status = 3
      self.filter = hit.first
    end
  end

  def filtered_by?
    Filter.repo_id(self.repo_id) \
      .severity(self.severity) \
      .fingerprint(self.fingerprint) \
      .scanner(self.scanner) \
      .description(self.description) \
      .detail(self.detail) \
      .file(self.file) \
      .line(self.line.to_s) \
      .code(self.code)
  end

  def self.scope_current only_current
    if only_current
      where('findings.current = ?', true)
    end
  end

  def self.scope_repo_name name
    if name.nil?
      Finding.where("repos.full_name LIKE '%' OR repos.name LIKE '%'")
    else
      name_query = "#{name.downcase}"
      Finding.where("lower(repos.full_name) LIKE ? OR lower(repos.name) LIKE ?", name_query, name_query)
    end
  end

  def to_json
    self.attributes.merge({:branch => self.branch, :repo => self.repo, :filter => self.filter}).as_json
  end

  def self.status_code
    {
      :open => 0,
      :hidden => 1,
      :published => 2,
      :filtered => 3
    }
  end

end


text:
local doc = require('doc')

local version =
    doc.desc[[
    A collection utility functions for working with the lark project version.
    ]] ..
    doc.var[[filename  string
    -- Explicitly specify a default file path containing the version.  If no
    path is specified the default path "VERSION" is used.
    ]] ..
    {}

local version_file = nil
local version_string = nil

local default_filename = 'VERSION'

version.filename = nil

local function get_filename(filename)
    if filename then
        return filename
    end
    if version.filename then
        return version.filename
    end
    return default_filename
end

version.get =
    doc.desc[[
    Return the current project version by reading the version file.  The return
    value is cached so future calls to get() do not need to re-read the file.
    ]] ..
    doc.sig[[filename => version]] ..
    doc.param[[filename  string
    -- The file to read the version number from.  When not given the default
    filename configured for the module will be read.
    ]] ..
    doc.param[[version  string
    -- The first line of the version file (with any trailing newline removed)
    ]] ..
    function(filename)
        filename = get_filename(filename)
        if not version_string or filename ~= version_file then
            version_file = filename
            version_string = version.read(filename)
        end
        return version_string
    end

version.read =
    doc.desc[[
    Return the current project version by reading the version file.  The read()
    function will read the version file every time it is called, unlike the
    get() function.
    ]] ..
    doc.sig[[filename => version]] ..
    doc.param[[filename  string
    -- The file to read the version number from.  When not given the default
    filename configured for the module will be read.
    ]] ..
    doc.param[[version  string
    -- The first line of the version file (with any trailing newline removed)
    ]] ..
    function (filename)
        filename = get_filename(filename)

        local f, err = io.open(filename)
        if err then
            return nil, err
        end
        local v = f:read('*all')
        f:close()
        v = string.gsub(v, '#[^\n]\n', '')
        v = string.gsub(v, '%s', '')
        return v
    end

return version


text:
{% load form_helpers %}

    {{ field.label }}
    {% include "horizon/common/_form_field_decorator.html" %}

    {% if field|is_checkbox %}
      {% with is_horizontal=1 %}
      {% include 'horizon/common/fields/_themable_checkbox.html' %}
      {% endwith %}
    {% elif field|is_radio %}
      {% with is_horizontal=1 %}
      {% include 'horizon/common/fields/_themable_radiobutton.html' %}
      {% endwith %}
    {% else %}
      {{ field|add_bootstrap_class }}
    {% endif %}
    {% for error in field.errors %}
      {{ error }}
    {% endfor %}


text:
module Wizardly
  module Wizard
    class DSL

      def initialize(config)
        @config = config
      end

      # DSL methods
      def when_completed_redirect_to(redir); @config._when_completed_redirect_to(redir); end
      def when_canceled_redirect_to(redir); @config._when_canceled_redirect_to(redir); end
      def change_button(name)
        @config._change_button(name)
      end
      def create_button(name, opts)
        @config._create_button(name, opts)
      end
      def set_page(name);
        @config._set_page(name)
      end
      def mask_passwords(passwords)
        @config._mask_passwords(passwords)
      end
      alias_method :mask_password, :mask_passwords
    end
  end
end


text:
'use strict';

describe('Service: selectedDatasetInformation', function () {

  // load the service's module
  beforeEach(module('ocwUiApp'));

  // instantiate service
  var selectedDatasetInformation;
  beforeEach(inject(function (_selectedDatasetInformation_) {
    selectedDatasetInformation = _selectedDatasetInformation_;
  }));

  it('should initialize the selectedDatasetInformation service', function() {
    inject(function(selectedDatasetInformation) {
      expect(selectedDatasetInformation).not.toEqual(null);
    });
  });

  it('should provide the getDatasets function', function() {
    inject(function(selectedDatasetInformation) {
      expect(selectedDatasetInformation.getDatasets()).not.toEqual(null);
    });
  });

  it('should provide the getDatasetCount function', function() {
    inject(function(selectedDatasetInformation) {
      expect(selectedDatasetInformation.getDatasetCount()).toEqual(0);
    });
  });

  it('should provide the addDataset function', function() {
    inject(function(selectedDatasetInformation) {
      selectedDatasetInformation.addDataset({});
      expect(selectedDatasetInformation.getDatasetCount()).toEqual(1);
    });
  });

  it('should set the shouldDisplay attribute when adding a dataset', function() {
    inject(function(selectedDatasetInformation) {
      selectedDatasetInformation.addDataset({});
      expect(selectedDatasetInformation.getDatasets()[0].shouldDisplay).toBe(false);
    });
  });

  it('should set the regrid attribute when adding a dataset', function() {
    inject(function(selectedDatasetInformation) {
      selectedDatasetInformation.addDataset({});
      expect(selectedDatasetInformation.getDatasets()[0].regrid).toBe(false);
    });
  });

  it('should provide the removeDataset function', function() {
    inject(function(selectedDatasetInformation) {
      selectedDatasetInformation.addDataset(1);
      selectedDatasetInformation.addDataset(2);

      expect(selectedDatasetInformation.getDatasets()[0]).toEqual(1);
      selectedDatasetInformation.removeDataset(0);
      expect(selectedDatasetInformation.getDatasets()[0]).toEqual(2);
    });
  });

  it('should provide the clearDatasets function', function() {
    inject(function(selectedDatasetInformation) {
      selectedDatasetInformation.addDataset({});
      expect(selectedDatasetInformation.getDatasetCount()).toEqual(1);

      selectedDatasetInformation.clearDatasets();
      expect(selectedDatasetInformation.getDatasetCount()).toEqual(0);
    });
  });
});