<commit_before>/*
 * Copyright (C) 2009 the original author(s).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.sonatype.gshell.core;

import jline.console.Completer;
import jline.console.ConsoleReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.gshell.Branding;
import org.sonatype.gshell.History;
import org.sonatype.gshell.Shell;
import org.sonatype.gshell.ShellHolder;
import org.sonatype.gshell.VariableNames;
import org.sonatype.gshell.Variables;
import org.sonatype.gshell.command.IO;
import org.sonatype.gshell.console.Console;
import org.sonatype.gshell.console.ConsoleErrorHandler;
import org.sonatype.gshell.console.ConsolePrompt;
import org.sonatype.gshell.console.ConsoleTask;
import org.sonatype.gshell.event.EventAware;
import org.sonatype.gshell.event.EventManager;
import org.sonatype.gshell.execute.CommandExecutor;
import org.sonatype.gshell.io.Closer;
import org.sonatype.gshell.io.SystemInputOutputHijacker;
import org.sonatype.gshell.notification.ExitNotification;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * The default {@link org.sonatype.gshell.Shell} component.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @since 2.0
 */
public class ShellImpl
    implements Shell, VariableNames
{
    private final Logger log = LoggerFactory.getLogger(getClass());

    private final EventManager eventManager;

    private final Branding branding;

    private final CommandExecutor executor;

    private final IO io;

    private final Variables variables;

    private final ShellHistory history;

    private List<Completer> completers;

    private ConsolePrompt prompt;

    private ConsoleErrorHandler errorHandler;

    private boolean opened;

    public ShellImpl(final EventManager eventManager, final CommandExecutor executor, final Branding branding,
                     final IO io, final Variables variables) throws IOException
    {
        assert eventManager != null;
        assert executor != null;
        assert branding != null;
        // io and variables may be null

        this.eventManager = eventManager;
        this.executor = executor;
        this.branding = branding;
        this.io = io != null ? io : new IO();
        this.variables = variables != null ? variables : new VariablesImpl();
        if (variables instanceof EventAware) {
            ((EventAware) variables).setEventManager(eventManager);
        }
        this.history = new ShellHistory(new File(branding.getUserContextDir(), branding.getHistoryFileName()));

    }

    public Branding getBranding() {
        return branding;
    }

    public IO getIo() {
        return io;<commit_msg>Don't need to hold on to the event manager<commit_after>/*
 * Copyright (C) 2009 the original author(s).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.sonatype.gshell.core;

import jline.console.Completer;
import jline.console.ConsoleReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.gshell.Branding;
import org.sonatype.gshell.History;
import org.sonatype.gshell.Shell;
import org.sonatype.gshell.ShellHolder;
import org.sonatype.gshell.VariableNames;
import org.sonatype.gshell.Variables;
import org.sonatype.gshell.command.IO;
import org.sonatype.gshell.console.Console;
import org.sonatype.gshell.console.ConsoleErrorHandler;
import org.sonatype.gshell.console.ConsolePrompt;
import org.sonatype.gshell.console.ConsoleTask;
import org.sonatype.gshell.event.EventAware;
import org.sonatype.gshell.event.EventManager;
import org.sonatype.gshell.execute.CommandExecutor;
import org.sonatype.gshell.io.Closer;
import org.sonatype.gshell.io.SystemInputOutputHijacker;
import org.sonatype.gshell.notification.ExitNotification;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * The default {@link org.sonatype.gshell.Shell} component.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @since 2.0
 */
public class ShellImpl
    implements Shell, VariableNames
{
    private final Logger log = LoggerFactory.getLogger(getClass());

    private final Branding branding;

    private final CommandExecutor executor;

    private final IO io;

    private final Variables variables;

    private final ShellHistory history;

    private List<Completer> completers;

    private ConsolePrompt prompt;

    private ConsoleErrorHandler errorHandler;

    private boolean opened;

    public ShellImpl(final EventManager eventManager, final CommandExecutor executor, final Branding branding,
                     final IO io, final Variables variables) throws IOException
    {
        assert eventManager != null;
        assert executor != null;
        assert branding != null;
        // io and variables may be null

        this.executor = executor;
        this.branding = branding;
        this.io = io != null ? io : new IO();
        this.variables = variables != null ? variables : new VariablesImpl();
        if (variables instanceof EventAware) {
            ((EventAware) variables).setEventManager(eventManager);
        }
        this.history = new ShellHistory(new File(branding.getUserContextDir(), branding.getHistoryFileName()));

    }

    public Branding getBranding() {
        return branding;
    }

    public IO getIo() {
        return io;
{'fraction_non_alphanumeric': 0.09042942986955885, 'fraction_numerical': 0.003517514289901803, 'mean_word_length': 3.8673323823109844, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '257624', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1867, 'n_words': 557}