<commit_before>/*
 * Copyright 2013 Palantir Technologies, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.palantir.typescript.search;

import static com.google.common.base.Preconditions.checkNotNull;

import java.text.MessageFormat;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.model.WorkbenchLabelProvider;

import com.google.common.base.CharMatcher;
import com.palantir.typescript.Resources;
import com.palantir.typescript.services.language.Reference;

/**
 * The label provider for a search result.
 *
 * @author dcicerone
 */
final class SearchResultLabelProvider extends LabelProvider implements IStyledLabelProvider {

    private static final String HIGHLIGHT_BG_COLOR_NAME = "org.eclipse.search.ui.match.highlight";
    private static final Styler HIGHLIGHT_STYLE = StyledString.createColorRegistryStyler(null, HIGHLIGHT_BG_COLOR_NAME);
    private static final CharMatcher NON_WHITESPACE_MATCHER = CharMatcher.WHITESPACE.negate();

    private final boolean isTree;
    private final WorkbenchLabelProvider labelProvider;
    private final SearchResultPage page;

    public SearchResultLabelProvider(SearchResultPage page, boolean isTree) {
        checkNotNull(page);

        this.isTree = isTree;
        this.labelProvider = new WorkbenchLabelProvider();
        this.page = page;
    }

    @Override
    public void addListener(ILabelProviderListener listener) {
        super.addListener(listener);

        this.labelProvider.addListener(listener);
    }

    @Override
    public void removeListener(ILabelProviderListener listener) {
        super.removeListener(listener);

        this.labelProvider.removeListener(listener);
    }

    @Override
    public void dispose() {
        super.dispose();

        this.labelProvider.dispose();
    }

    @Override
    public Image getImage(Object element) {
        if (element instanceof IResource) {
            return this.labelProvider.getImage(element);
        }<commit_msg>Show icon decorations in the search results<commit_after>/*
 * Copyright 2013 Palantir Technologies, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.palantir.typescript.search;

import static com.google.common.base.Preconditions.checkNotNull;

import java.text.MessageFormat;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.model.WorkbenchLabelProvider;

import com.google.common.base.CharMatcher;
import com.palantir.typescript.Resources;
import com.palantir.typescript.services.language.Reference;

/**
 * The label provider for a search result.
 *
 * @author dcicerone
 */
final class SearchResultLabelProvider extends LabelProvider implements IStyledLabelProvider {

    private static final String HIGHLIGHT_BG_COLOR_NAME = "org.eclipse.search.ui.match.highlight";
    private static final Styler HIGHLIGHT_STYLE = StyledString.createColorRegistryStyler(null, HIGHLIGHT_BG_COLOR_NAME);
    private static final CharMatcher NON_WHITESPACE_MATCHER = CharMatcher.WHITESPACE.negate();

    private final boolean isTree;
    private final ILabelProvider labelProvider;
    private final SearchResultPage page;

    public SearchResultLabelProvider(SearchResultPage page, boolean isTree) {
        checkNotNull(page);

        this.isTree = isTree;
        this.labelProvider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();
        this.page = page;
    }

    @Override
    public void addListener(ILabelProviderListener listener) {
        super.addListener(listener);

        this.labelProvider.addListener(listener);
    }

    @Override
    public void removeListener(ILabelProviderListener listener) {
        super.removeListener(listener);

        this.labelProvider.removeListener(listener);
    }

    @Override
    public void dispose() {
        super.dispose();

        this.labelProvider.dispose();
    }

    @Override
    public Image getImage(Object element) {
        if (element instanceof IResource) {
            return this.labelProvider.getImage(element);
        }
{'fraction_non_alphanumeric': 0.07950861627708582, 'fraction_numerical': 0.002729909571745436, 'mean_word_length': 4.1286089238845145, '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': '3233020', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1564, 'n_words': 419}