<commit_before>/**
 * Copyright (c) 2005-2013 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */
package org.python.pydev.editor;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Drawable;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TypedListener;
import org.python.pydev.ast.item_pointer.ItemPointer;
import org.python.pydev.core.docutils.PyStringUtils;
import org.python.pydev.editor.actions.PyOpenAction;
import org.python.pydev.shared_core.string.FastStringBuffer;
import org.python.pydev.shared_ui.tooltips.presenter.AbstractInformationPresenter;

/**
 * Based on HTMLTextPresenter
 *
 * @author Fabio
 */
public class PyInformationPresenter extends AbstractInformationPresenter {

    public static class PyStyleRange extends StyleRange {
        public PyStyleRange() {
        }

        public PyStyleRange(int start, int length, Color foreground, Color background) {
            super(start, length, foreground, background);
        }

        public PyStyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
            super(start, length, foreground, background, fontStyle);
        }

        public String tagReplaced;
    }

    private int fCounter;
    private boolean fEnforceUpperLineLimit;
    private ControlListener resizeCallback;

    public PyInformationPresenter(boolean enforceUpperLineLimit) {
        super();
        fEnforceUpperLineLimit = enforceUpperLineLimit;
    }

    public PyInformationPresenter() {
        this(true);
    }

    private TypedListener resizeListener = new TypedListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
            if (resizeCallback != null) {
                resizeCallback.controlMoved(e);
            }
        }
<commit_msg>Fix hover links when different pydev_link pointers are used<commit_after>/**
 * Copyright (c) 2005-2013 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */
package org.python.pydev.editor;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Drawable;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TypedListener;
import org.python.pydev.ast.item_pointer.ItemPointer;
import org.python.pydev.core.docutils.PyStringUtils;
import org.python.pydev.editor.actions.PyOpenAction;
import org.python.pydev.shared_core.string.FastStringBuffer;
import org.python.pydev.shared_ui.tooltips.presenter.AbstractInformationPresenter;

/**
 * Based on HTMLTextPresenter
 *
 * @author Fabio
 */
public class PyInformationPresenter extends AbstractInformationPresenter {

    public static class PyStyleRange extends StyleRange {
        public PyStyleRange() {
        }

        public PyStyleRange(int start, int length, Color foreground, Color background) {
            super(start, length, foreground, background);
        }

        public PyStyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
            super(start, length, foreground, background, fontStyle);
        }

        public String tagReplaced;

        @Override
        public boolean similarTo(StyleRange style) {
            if (!super.similarTo(style)) {
                return false;
            }
            if (style instanceof PyStyleRange) {
                String otherTagReplaced = ((PyStyleRange) style).tagReplaced;
                if (tagReplaced == null) {
                    return otherTagReplaced == null;
                }
                return tagReplaced.equals(otherTagReplaced);
            }
            return true;
        }
    }

    private int fCounter;
    private boolean fEnforceUpperLineLimit;
    private ControlListener resizeCallback;

    public PyInformationPresenter(boolean enforceUpperLineLimit) {
        super();
        fEnforceUpperLineLimit = enforceUpperLineLimit;
    }

    public PyInformationPresenter() {
        this(true);
    }

    private TypedListener resizeListener = new TypedListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
            if (resizeCallback != null) {
                resizeCallback.controlMoved(e);
            }
        }

{'fraction_non_alphanumeric': 0.08836833602584815, 'fraction_numerical': 0.002584814216478191, 'mean_word_length': 3.4765003615328993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7593191', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1694, 'n_words': 411}