<commit_before>package com.redhat.ceylon.eclipse.code.html;

import static com.redhat.ceylon.eclipse.code.html.HTMLPrinter.convertToHTMLContent;
import static com.redhat.ceylon.eclipse.code.html.HTMLPrinter.toHex;
import static com.redhat.ceylon.eclipse.util.Highlights.CHARS;
import static com.redhat.ceylon.eclipse.util.Highlights.COMMENTS;
import static com.redhat.ceylon.eclipse.util.Highlights.IDENTIFIERS;
import static com.redhat.ceylon.eclipse.util.Highlights.KEYWORDS;
import static com.redhat.ceylon.eclipse.util.Highlights.NUMBERS;
import static com.redhat.ceylon.eclipse.util.Highlights.PACKAGES;
import static com.redhat.ceylon.eclipse.util.Highlights.STRINGS;
import static com.redhat.ceylon.eclipse.util.Highlights.TYPES;
import static com.redhat.ceylon.eclipse.util.Highlights.getCurrentThemeColor;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

import org.antlr.runtime.Token;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.swt.graphics.FontData;
import org.osgi.framework.Bundle;

import com.redhat.ceylon.compiler.java.tools.NewlineFixingStringStream;
import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.model.Module;
import com.redhat.ceylon.compiler.typechecker.model.Package;
import com.redhat.ceylon.compiler.typechecker.model.Referenceable;
import com.redhat.ceylon.compiler.typechecker.model.Scope;
import com.redhat.ceylon.compiler.typechecker.parser.CeylonLexer;
import com.redhat.ceylon.eclipse.code.editor.CeylonEditor;
import com.redhat.ceylon.eclipse.ui.CeylonPlugin;
import com.redhat.ceylon.eclipse.util.Escaping;

public class HTML {

    /**
     * The style sheet (css).
     */
    private static String fgStyleSheet;

    public static URL fileUrl(String icon) {
        try {
            Bundle bundle = CeylonPlugin.getInstance().getBundle();
            return FileLocator.toFileURL(FileLocator.find(bundle, 
                    new Path("icons/").append(icon), null));
        } 
        catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * Returns the Javadoc hover style sheet with the current Javadoc font from the preferences.
     * @return the updated style sheet
     * @since 3.4
     */
    public static String getStyleSheet() {
        if (fgStyleSheet == null) {
            fgStyleSheet = loadStyleSheet();
        }
        String css = fgStyleSheet + "body { padding: 15px; } hr { padding: 2px; border:0; filter: alpha(opacity=0); }";
        FontData textFontData= CeylonEditor.getHoverFont().getFontData()[0];
        FontData monospaceFontData = CeylonEditor.getEditorFont().getFontData()[0];
        css = HTMLPrinter.convertTopLevelFont(css, textFontData);
        return css + " tt, pre, code { font-family: '" + monospaceFontData.getName()  + "', monospace }";
    }

    /**<commit_msg>no more <hr/>s to suppress<commit_after>package com.redhat.ceylon.eclipse.code.html;

import static com.redhat.ceylon.eclipse.code.html.HTMLPrinter.convertToHTMLContent;
import static com.redhat.ceylon.eclipse.code.html.HTMLPrinter.toHex;
import static com.redhat.ceylon.eclipse.util.Highlights.CHARS;
import static com.redhat.ceylon.eclipse.util.Highlights.COMMENTS;
import static com.redhat.ceylon.eclipse.util.Highlights.IDENTIFIERS;
import static com.redhat.ceylon.eclipse.util.Highlights.KEYWORDS;
import static com.redhat.ceylon.eclipse.util.Highlights.NUMBERS;
import static com.redhat.ceylon.eclipse.util.Highlights.PACKAGES;
import static com.redhat.ceylon.eclipse.util.Highlights.STRINGS;
import static com.redhat.ceylon.eclipse.util.Highlights.TYPES;
import static com.redhat.ceylon.eclipse.util.Highlights.getCurrentThemeColor;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

import org.antlr.runtime.Token;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.swt.graphics.FontData;
import org.osgi.framework.Bundle;

import com.redhat.ceylon.compiler.java.tools.NewlineFixingStringStream;
import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.model.Module;
import com.redhat.ceylon.compiler.typechecker.model.Package;
import com.redhat.ceylon.compiler.typechecker.model.Referenceable;
import com.redhat.ceylon.compiler.typechecker.model.Scope;
import com.redhat.ceylon.compiler.typechecker.parser.CeylonLexer;
import com.redhat.ceylon.eclipse.code.editor.CeylonEditor;
import com.redhat.ceylon.eclipse.ui.CeylonPlugin;
import com.redhat.ceylon.eclipse.util.Escaping;

public class HTML {

    /**
     * The style sheet (css).
     */
    private static String fgStyleSheet;

    public static URL fileUrl(String icon) {
        try {
            Bundle bundle = CeylonPlugin.getInstance().getBundle();
            return FileLocator.toFileURL(FileLocator.find(bundle, 
                    new Path("icons/").append(icon), null));
        } 
        catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * Returns the Javadoc hover style sheet with the current Javadoc font from the preferences.
     * @return the updated style sheet
     * @since 3.4
     */
    public static String getStyleSheet() {
        if (fgStyleSheet == null) {
            fgStyleSheet = loadStyleSheet();
        }
        String css = fgStyleSheet + "body { padding: 15px; }";
        FontData textFontData= CeylonEditor.getHoverFont().getFontData()[0];
        FontData monospaceFontData = CeylonEditor.getEditorFont().getFontData()[0];
        css = HTMLPrinter.convertTopLevelFont(css, textFontData);
        return css + " tt, pre, code { font-family: '" + monospaceFontData.getName()  + "', monospace }";
    }

    /**
{'fraction_non_alphanumeric': 0.11234487263226649, 'fraction_numerical': 0.002449379490529066, 'mean_word_length': 3.830441640378549, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '3144996', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1877, 'n_words': 332}