<commit_before>package org.lamport.tla.toolbox.editor.basic;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.lamport.tla.toolbox.editor.basic.tla.TLAAnnotationHover;
import org.lamport.tla.toolbox.editor.basic.tla.TLACompletionProcessor;

/**
 * Configuration of the source viewer for TLA+ editor 
 * @author <NAME>
 * @version $Id$
 */
public class TLASourceViewerConfiguration extends TextSourceViewerConfiguration
{
    /**
     * Constructor
     */
    public TLASourceViewerConfiguration() 
    {
        super();
    }

    /**
     * Constructs configuration based on a preference store  
     * @param preferenceStore
     */
    public TLASourceViewerConfiguration(IPreferenceStore preferenceStore)
    {
        super(preferenceStore);
    }

    /**
     * Reconciler setup
     */
    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
    {
        TLAColorProvider provider = TLAEditorActivator.getDefault().getTLAColorProvider();
        PresentationReconciler reconciler = new PresentationReconciler();
        reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

        DefaultDamagerRepairer dr = new DefaultDamagerRepairer(TLAEditorActivator.getDefault().getTLACodeScanner());
        reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
        reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

        dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider
                .getColor(TLAColorProvider.MULTI_LINE_COMMENT))));
        reconciler.setDamager(dr, TLAPartitionScanner.TLA_MULTILINE_COMMENT);
        reconciler.setRepairer(dr, TLAPartitionScanner.TLA_MULTILINE_COMMENT);

        
        return reconciler;
    }

    /**
     * Partitioning
     */
    public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer)
    {
        return TLAPartitionScanner.TLA_PARTITIONING;
    }

    /**
     * Configured content types
     */
    public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
    {
        return new String[] { IDocument.DEFAULT_CONTENT_TYPE, TLAPartitionScanner.TLA_MULTILINE_COMMENT};
    }
    
    
    /**
     * Content assistant
     */
    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

        ContentAssistant assistant= new ContentAssistant();
        assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
        assistant.setContentAssistProcessor(new TLACompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
        assistant.enableAutoActivation(true);
        assistant.setAutoActivationDelay(500);
        assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
        assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
        assistant.setContextInformationPopupBackground(TLAEditorActivator.getDefault().getTLAColorProvider().getColor(TLAColorProvider.CONTENT_ASSIST_BACKGROUNG));
        return assistant;
    }
    
    /**
     * Ruler annotation
     */
    public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer)
    {
        return new TLAAnnotationHover();
    }
    
    
    public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer)
    {
        // TODO Auto-generated method stub
        return super.getHyperlinkDetectors(sourceViewer);
    }
    
    /**
     * Single token scanner, returns attributed token
     */
    public static class SingleTokenScanner extends BufferedRuleBasedScanner
    {
        public SingleTokenScanner(TextAttribute attribute)
        {
            setDefaultReturnToken(new Token(attribute));
        }
    }





}<commit_msg>source folding added<commit_after>package org.lamport.tla.toolbox.editor.basic;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.lamport.tla.toolbox.editor.basic.tla.TLAAnnotationHover;
import org.lamport.tla.toolbox.editor.basic.tla.TLACompletionProcessor;

/**
 * Configuration of the source viewer for TLA+ editor 
 * @author <NAME>
 * @version $Id$
 */
public class TLASourceViewerConfiguration extends TextSourceViewerConfiguration
{

    private final TLAEditor editor;

    /**
     * Constructs configuration based on a preference store  
     * @param preferenceStore
     */
    public TLASourceViewerConfiguration(IPreferenceStore preferenceStore, TLAEditor editor)
    {
        super(preferenceStore);
        this.editor = editor;
    }

    /**
     * Reconciler setup
     */
    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
    {
        TLAColorProvider provider = TLAEditorActivator.getDefault().getTLAColorProvider();
        PresentationReconciler reconciler = new PresentationReconciler();
        reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

        DefaultDamagerRepairer dr = new DefaultDamagerRepairer(TLAEditorActivator.getDefault().getTLACodeScanner());
        reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
        reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

        dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider
                .getColor(TLAColorProvider.MULTI_LINE_COMMENT))));
        reconciler.setDamager(dr, TLAPartitionScanner.TLA_MULTILINE_COMMENT);
        reconciler.setRepairer(dr, TLAPartitionScanner.TLA_MULTILINE_COMMENT);

        return reconciler;
    }

    /**
     * Partitioning
     */
    public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer)
    {
        return TLAPartitionScanner.TLA_PARTITIONING;
    }

    /**
     * Configured content types
     */
    public String[] getConfiguredContentTypes(ISourceViewer sourceViewer)
    {
        return new String[] { IDocument.DEFAULT_CONTENT_TYPE, TLAPartitionScanner.TLA_MULTILINE_COMMENT };
    }

    /**
     * Content assistant
     */
    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
    {

        ContentAssistant assistant = new ContentAssistant();
        assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
        assistant.setContentAssistProcessor(new TLACompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
        assistant.enableAutoActivation(true);
        assistant.setAutoActivationDelay(500);
        assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
        assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
        assistant.setContextInformationPopupBackground(TLAEditorActivator.getDefault().getTLAColorProvider().getColor(
                TLAColorProvider.CONTENT_ASSIST_BACKGROUNG));
        return assistant;
    }

    /**
     * Ruler annotation
     */
    public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer)
    {
        return new TLAAnnotationHover();
    }

    /**
     * 
     */
    public IReconciler getReconciler(ISourceViewer sourceViewer)
    {
        TLAReconcilingStrategy strategy = new TLAReconcilingStrategy();
        strategy.setEditor(editor);
        MonoReconciler reconciler = new MonoReconciler(strategy, false);
        return reconciler;
    }

    /**
     * Single token scanner, returns attributed token
     */
    public static class SingleTokenScanner extends BufferedRuleBasedScanner
    {
        public SingleTokenScanner(TextAttribute attribute)
        {
            setDefaultReturnToken(new Token(attribute));
        }
    }

    public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType)
    {
        return new String[] { "\\*", "" };
    }

}
{'fraction_non_alphanumeric': 0.08147188950037769, 'fraction_numerical': 0.0006474587245063128, 'mean_word_length': 3.916710875331565, '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': '1470367', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2704, 'n_words': 380}