<commit_before>/*
 * @author: fabioz
 * Created: January 2004
 * License: Common Public License v1.0
 */
 
package org.python.pydev.editor.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.python.pydev.editor.PyEdit;

/**
 * @author <NAME>
 * 
 * Superclass of all our actions. Contains utility functions.
 * 
 * Subclasses should implement run(IAction action) method.
 */
public abstract class PyAction implements IEditorActionDelegate {

	// Always points to the current editor
	protected IEditorPart targetEditor;

	public void setEditor(IEditorPart targetEditor) {
		this.targetEditor = targetEditor;
	}
	
	/**
	 * This is an IEditorActionDelegate override
	 */
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
		setEditor(targetEditor);
	}

	/**
	 * Activate action  (if we are getting text)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
		if (selection instanceof TextSelection) {
			action.setEnabled(true);
			return;
		}
		action.setEnabled( targetEditor instanceof ITextEditor);
	}

	/**
	 * This method returns the delimiter for the document
	 * @param doc
	 * @param startLineIndex
	 * @return  delimiter for the document (\n|\r\|r\n)
	 * @throws BadLocationException
	 */
	protected static String getDelimiter(IDocument doc, int startLineIndex)
		throws BadLocationException {
		String endLineDelim = doc.getLineDelimiter(startLineIndex);
		if (endLineDelim == null) {<commit_msg>changed getDelimiter to public.<commit_after>/*
 * @author: fabioz
 * Created: January 2004
 * License: Common Public License v1.0
 */
 
package org.python.pydev.editor.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
import org.python.pydev.editor.PyEdit;

/**
 * @author <NAME>
 * 
 * Superclass of all our actions. Contains utility functions.
 * 
 * Subclasses should implement run(IAction action) method.
 */
public abstract class PyAction implements IEditorActionDelegate {

	// Always points to the current editor
	protected IEditorPart targetEditor;

	public void setEditor(IEditorPart targetEditor) {
		this.targetEditor = targetEditor;
	}
	
	/**
	 * This is an IEditorActionDelegate override
	 */
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
		setEditor(targetEditor);
	}

	/**
	 * Activate action  (if we are getting text)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
		if (selection instanceof TextSelection) {
			action.setEnabled(true);
			return;
		}
		action.setEnabled( targetEditor instanceof ITextEditor);
	}

	/**
	 * This method returns the delimiter for the document
	 * @param doc
	 * @param startLineIndex
	 * @return  delimiter for the document (\n|\r\|r\n)
	 * @throws BadLocationException
	 */
	public static String getDelimiter(IDocument doc, int startLineIndex)
		throws BadLocationException {
		String endLineDelim = doc.getLineDelimiter(startLineIndex);
		if (endLineDelim == null) {
{'fraction_non_alphanumeric': 0.09607577807848444, 'fraction_numerical': 0.003247631935047361, 'mean_word_length': 4.608497723823976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7660365', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1082, 'n_words': 287}