<commit_before>/*******************************************************************************
 * Copyright (c) 2016 ModelSolv, Inc. and others.
 * 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:
 *    ModelSolv, Inc. - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.reprezen.swagedit.common.editor;

import org.dadacoalition.yedit.editor.YEditSourceViewerConfiguration;
import org.dadacoalition.yedit.editor.scanner.YAMLScanner;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region;
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.hyperlink.URLHyperlinkDetector;
import org.eclipse.jface.text.information.IInformationPresenter;
import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension;
import org.eclipse.jface.text.information.IInformationProviderExtension2;
import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.templates.ContextTypeRegistry;
import org.eclipse.jface.text.templates.persistence.TemplateStore;
import org.eclipse.swt.widgets.Shell;

import com.reprezen.swagedit.core.assist.JsonContentAssistProcessor;

public class JsonSourceViewerConfiguration extends YEditSourceViewerConfiguration {

    private JsonEditor editor;
    private YAMLScanner scanner;
    private InformationPresenter informationPresenter;
	private final IPreferenceStore store;

    public JsonSourceViewerConfiguration(IPreferenceStore store) {
        super();
		this.store = store;
    }

    @Override
    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
        ContentAssistant ca = new ContentAssistant();
        JsonContentAssistProcessor processor = createContentAssistProcessor(ca);

        ca.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
        ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));

        ca.enableAutoInsert(false);
        ca.enablePrefixCompletion(false);
        ca.enableAutoActivation(true);
        ca.setAutoActivationDelay(100);
        ca.enableColoredLabels(true);
        ca.setShowEmptyList(true);
        ca.setRepeatedInvocationMode(true);
        ca.addCompletionListener(processor);
        ca.setStatusLineVisible(true);

        return ca;
    }
    
    protected JsonContentAssistProcessor createContentAssistProcessor(ContentAssistant ca) {
    	return new JsonContentAssistProcessor(ca){

			@Override
			protected TemplateStore getTemplateStore() {
				return null;
			}

			@Override
			protected ContextTypeRegistry getContextTypeRegistry() {
				return null;
			}

			@Override
			protected String getContextTypeId(String path) {
				return null;
			}};
    }

    @Override
    protected YAMLScanner getScanner() {
        if (scanner == null) {
            scanner = new JsonScanner(colorManager, store);
        }
        return scanner;
    }

    @Override
    public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
        return new String[] { IDocument.DEFAULT_CONTENT_TYPE };
    }

    @Override
    public IReconciler getReconciler(ISourceViewer sourceViewer) {
        JsonReconcilingStrategy strategy = new JsonReconcilingStrategy();
        strategy.setEditor(editor);
        MonoReconciler reconciler = new MonoReconciler(strategy, false);
        return reconciler;
    }

    @Override
    public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
        return new IHyperlinkDetector[] { new URLHyperlinkDetector()/* FIXME ,new JsonReferenceHyperlinkDetector(),
                new PathParamHyperlinkDetector(), new DefinitionHyperlinkDetector() */};
    }

    @Override
    public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
        // TODO Auto-generated method stub
        return super.getInformationPresenter(sourceViewer);
    }

    public void setEditor(JsonEditor editor) {
        this.editor = editor;
    }

    public JsonEditor getEditor() {
        return editor;
    }<commit_msg>Remove obsolete comment<commit_after>/*******************************************************************************
 * Copyright (c) 2016 ModelSolv, Inc. and others.
 * 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:
 *    ModelSolv, Inc. - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.reprezen.swagedit.common.editor;

import org.dadacoalition.yedit.editor.YEditSourceViewerConfiguration;
import org.dadacoalition.yedit.editor.scanner.YAMLScanner;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region;
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.hyperlink.URLHyperlinkDetector;
import org.eclipse.jface.text.information.IInformationPresenter;
import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension;
import org.eclipse.jface.text.information.IInformationProviderExtension2;
import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.templates.ContextTypeRegistry;
import org.eclipse.jface.text.templates.persistence.TemplateStore;
import org.eclipse.swt.widgets.Shell;

import com.reprezen.swagedit.core.assist.JsonContentAssistProcessor;

public class JsonSourceViewerConfiguration extends YEditSourceViewerConfiguration {

    private JsonEditor editor;
    private YAMLScanner scanner;
    private InformationPresenter informationPresenter;
	private final IPreferenceStore store;

    public JsonSourceViewerConfiguration(IPreferenceStore store) {
        super();
		this.store = store;
    }

    @Override
    public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
        ContentAssistant ca = new ContentAssistant();
        JsonContentAssistProcessor processor = createContentAssistProcessor(ca);

        ca.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
        ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));

        ca.enableAutoInsert(false);
        ca.enablePrefixCompletion(false);
        ca.enableAutoActivation(true);
        ca.setAutoActivationDelay(100);
        ca.enableColoredLabels(true);
        ca.setShowEmptyList(true);
        ca.setRepeatedInvocationMode(true);
        ca.addCompletionListener(processor);
        ca.setStatusLineVisible(true);

        return ca;
    }
    
    protected JsonContentAssistProcessor createContentAssistProcessor(ContentAssistant ca) {
    	return new JsonContentAssistProcessor(ca){

			@Override
			protected TemplateStore getTemplateStore() {
				return null;
			}

			@Override
			protected ContextTypeRegistry getContextTypeRegistry() {
				return null;
			}

			@Override
			protected String getContextTypeId(String path) {
				return null;
			}};
    }

    @Override
    protected YAMLScanner getScanner() {
        if (scanner == null) {
            scanner = new JsonScanner(colorManager, store);
        }
        return scanner;
    }

    @Override
    public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
        return new String[] { IDocument.DEFAULT_CONTENT_TYPE };
    }

    @Override
    public IReconciler getReconciler(ISourceViewer sourceViewer) {
        JsonReconcilingStrategy strategy = new JsonReconcilingStrategy();
        strategy.setEditor(editor);
        MonoReconciler reconciler = new MonoReconciler(strategy, false);
        return reconciler;
    }

    @Override
    public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
        return new IHyperlinkDetector[] { new URLHyperlinkDetector()};
    }

    @Override
    public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
        return super.getInformationPresenter(sourceViewer);
    }

    public void setEditor(JsonEditor editor) {
        this.editor = editor;
    }

    public JsonEditor getEditor() {
        return editor;
    }
{'fraction_non_alphanumeric': 0.10967677374161913, 'fraction_numerical': 0.0024016811768237767, 'mean_word_length': 4.488193300384404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4632998', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2726, 'n_words': 507}