<commit_before>/*******************************************************************************
 * Copyright (c) 2008 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: 
 *    <NAME> - initial API and implementation
 *******************************************************************************/
package ccw.editors.clojure;

import static ccw.preferences.PreferenceConstants.isReplExplicitLoggingMode;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;

import ccw.repl.Actions;
import ccw.repl.REPLView;

public class EvaluateTopLevelSExpressionAction extends Action {

	public final static String ID = "EvaluateTopLevelSExpressionAction"; //$NON-NLS-1$

	private final ClojureEditor editor;

	public EvaluateTopLevelSExpressionAction(ClojureEditor editor) {
		super(ClojureEditorMessages.EvaluateTopLevelSExpressionAction_label);
		Assert.isNotNull(editor);
		this.editor= editor;
		setEnabled(true);
	}

	public void run() {
		String selectedText = editor.getSelectedText();
		
		if (selectedText==null || selectedText.trim().equals("")) {
			selectedText = editor.getCurrentOrNextTopLevelSExpression();
		}

		REPLView repl = REPLView.activeREPL.get();
		if (repl != null && !repl.isDisposed()) {
			String textToEvaluate = selectedText;
			String editorNamespace = editor.findDeclaringNamespace();
			String replNamespace = repl.getCurrentNamespace();
			if (editorNamespace != null && !editorNamespace.equals(replNamespace)) {
				textToEvaluate = "(clojure.core/in-ns '" + editorNamespace + ")\n" + textToEvaluate + "\n(clojure.core/in-ns '" + replNamespace + ")";
			}
			
			EvaluateTextUtil.evaluateText(repl, textToEvaluate, isReplExplicitLoggingMode());
			Actions.ShowActiveREPL.execute(isReplExplicitLoggingMode());
		}
	}
}
<commit_msg>Fix Issue 366: 	Sending expression in non-Quiet REPL mode triggering REPL focus<commit_after>/*******************************************************************************
 * Copyright (c) 2008 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: 
 *    <NAME> - initial API and implementation
 *******************************************************************************/
package ccw.editors.clojure;

import static ccw.preferences.PreferenceConstants.isReplExplicitLoggingMode;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;

import ccw.repl.Actions;
import ccw.repl.REPLView;

public class EvaluateTopLevelSExpressionAction extends Action {

	public final static String ID = "EvaluateTopLevelSExpressionAction"; //$NON-NLS-1$

	private final ClojureEditor editor;

	public EvaluateTopLevelSExpressionAction(ClojureEditor editor) {
		super(ClojureEditorMessages.EvaluateTopLevelSExpressionAction_label);
		Assert.isNotNull(editor);
		this.editor= editor;
		setEnabled(true);
	}

	public void run() {
		String selectedText = editor.getSelectedText();
		
		if (selectedText==null || selectedText.trim().equals("")) {
			selectedText = editor.getCurrentOrNextTopLevelSExpression();
		}

		REPLView repl = REPLView.activeREPL.get();
		if (repl != null && !repl.isDisposed()) {
			String textToEvaluate = selectedText;
			String editorNamespace = editor.findDeclaringNamespace();
			String replNamespace = repl.getCurrentNamespace();
			if (editorNamespace != null && !editorNamespace.equals(replNamespace)) {
				textToEvaluate = "(clojure.core/in-ns '" + editorNamespace + ")\n" + textToEvaluate + "\n(clojure.core/in-ns '" + replNamespace + ")";
			}
			
			EvaluateTextUtil.evaluateText(repl, textToEvaluate, isReplExplicitLoggingMode());
			Actions.ShowActiveREPL.execute(false);
		}
	}
}

{'fraction_non_alphanumeric': 0.17890586495810745, 'fraction_numerical': 0.005174963035978314, 'mean_word_length': 5.484025559105431, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6442533', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1117, 'n_words': 251}