<commit_before>/**
 * Copyright (c) 2009, 2014 <NAME>, MulgaSoft
 *
 * 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
 *
 */
package com.mulgasoft.emacsplus;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

import org.eclipse.core.commands.AbstractParameterValueConverter;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.ParameterType;
import org.eclipse.core.commands.ParameterValueConversionException;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.CommandException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.bindings.Binding;
import org.eclipse.jface.bindings.BindingManager;
import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TypedPosition;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.WorkbenchPage;
import org.eclipse.ui.internal.keys.BindingService;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.part.MultiEditor;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;

import com.mulgasoft.emacsplus.execute.KbdMacroSupport;
import com.mulgasoft.emacsplus.preferences.EmacsPlusPreferenceConstants;

// Getting an arbitrary widget:
//	Control focus= page.getWorkbenchWindow().getShell().getDisplay().getFocusControl();

/**
 * Assorted utility methods
 * 
 * @author <NAME> - initial API and implementation
 */
@SuppressWarnings("restriction")	// for cast to internal class org.eclipse.ui.internal.WorkbenchPage 
public class EmacsPlusUtils {
	
	private static final String N_GEN = "\\c";	//$NON-NLS-1$
	private static final String N_NEW = "\\n";	//$NON-NLS-1$
	private static final String N_RET = "\\r";	//$NON-NLS-1$
	private static final String N_TAB = "\\t";	//$NON-NLS-1$
	private static final String N_BS = "\\b";	//$NON-NLS-1$
	private static final String N_FF = "\\f";	//$NON-NLS-1$
	
	// The assumption is that the position categories will be part of this document category
	private static final String DOC_CAT = "__content_types_category";   									  //$NON-NLS-1$
	// In Java at least, these point to foldable regions in the doc (as well as, oddly enough, spelling errors [& others?])
	public static final String DOC_FNS = "__dflt_position_category";   									  //$NON-NLS-1$
	// java specific comment
	//	public static String JAVA_DOC = org.eclipse.jdt.ui.text.IJavaPartitions.JAVA_DOC;
	// use javadoc string directly to avoid having a dependency of jdt.ui
	public static final String JAVA_DOC = "javadoc";														  //$NON-NLS-1$
	public static final String[] JAVADOC_POS= {JAVA_DOC};
	// The assumption is that generic comment position categories will include 'comment' in their name 
	public static final String[] COMMENT_POS= {"comment",JAVA_DOC}; 										  //$NON-NLS-1$ 
	// The assumption is that string position categories will include 'string' in their name 
	public static final String[] STRING_POS= {"string"};													  //$NON-NLS-1$
	// collect them all for efficiency
	public static final String[] ALL_POS= {"comment",JAVA_DOC,"string"};									  //$NON-NLS-1$ //$NON-NLS-2$
	
	// used for sanity checks on commands (invocation, etc.)
	public static final String MULGASOFT = "com.mulgasoft"; 												  //$NON-NLS-1$
	
	// Emacs+ plugin bundles symbolic names
	public static final String EMP_STR = "com.mulgasoft.emacsplus"; 										  //$NON-NLS-1$<commit_msg>Update comment<commit_after>/**
 * Copyright (c) 2009, 2014 <NAME>, MulgaSoft
 *
 * 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
 *
 */
package com.mulgasoft.emacsplus;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

import org.eclipse.core.commands.AbstractParameterValueConverter;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
import org.eclipse.core.commands.ParameterType;
import org.eclipse.core.commands.ParameterValueConversionException;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.CommandException;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.bindings.Binding;
import org.eclipse.jface.bindings.BindingManager;
import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TypedPosition;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.WorkbenchPage;
import org.eclipse.ui.internal.keys.BindingService;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.part.MultiEditor;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;

import com.mulgasoft.emacsplus.execute.KbdMacroSupport;
import com.mulgasoft.emacsplus.preferences.EmacsPlusPreferenceConstants;

// Getting an arbitrary widget:
//	Control focus= page.getWorkbenchWindow().getShell().getDisplay().getFocusControl();

/**
 * Assorted utility methods
 * 
 * @author <NAME> - initial API and implementation
 */
@SuppressWarnings("restriction")	// for cast to internal class org.eclipse.ui.internal.WorkbenchPage 
public class EmacsPlusUtils {
	
	private static final String N_GEN = "\\c";	//$NON-NLS-1$
	private static final String N_NEW = "\\n";	//$NON-NLS-1$
	private static final String N_RET = "\\r";	//$NON-NLS-1$
	private static final String N_TAB = "\\t";	//$NON-NLS-1$
	private static final String N_BS = "\\b";	//$NON-NLS-1$
	private static final String N_FF = "\\f";	//$NON-NLS-1$
	
	// The assumption is that the position categories will be part of this document category
	private static final String DOC_CAT = "__content_types_category";   									  //$NON-NLS-1$
	// In Java at least, these point to collapsible regions in the doc as well as other things 
	public static final String DOC_FNS = "__dflt_position_category";   									      //$NON-NLS-1$
	// java specific comment
	//	public static String JAVA_DOC = org.eclipse.jdt.ui.text.IJavaPartitions.JAVA_DOC;
	// use javadoc string directly to avoid having a dependency of jdt.ui
	public static final String JAVA_DOC = "javadoc";														  //$NON-NLS-1$
	public static final String[] JAVADOC_POS= {JAVA_DOC};
	// The assumption is that generic comment position categories will include 'comment' in their name 
	public static final String[] COMMENT_POS= {"comment",JAVA_DOC}; 										  //$NON-NLS-1$ 
	// The assumption is that string position categories will include 'string' in their name 
	public static final String[] STRING_POS= {"string"};													  //$NON-NLS-1$
	// collect them all for efficiency
	public static final String[] ALL_POS= {"comment",JAVA_DOC,"string"};									  //$NON-NLS-1$ //$NON-NLS-2$
	
	// used for sanity checks on commands (invocation, etc.)
	public static final String MULGASOFT = "com.mulgasoft"; 												  //$NON-NLS-1$
	
	// Emacs+ plugin bundles symbolic names
	public static final String EMP_STR = "com.mulgasoft.emacsplus"; 										  //$NON-NLS-1$
{'fraction_non_alphanumeric': 0.11146012767250987, 'fraction_numerical': 0.005674333772418685, 'mean_word_length': 4.492487479131887, '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': '1366914', 'n_tokens_mistral': 3244, 'n_tokens_neox': 3004, 'n_words': 745}