<commit_before>package org.intellij.lang.xpath.xslt;

import org.intellij.lang.xpath.TestBase;
import org.intellij.lang.xpath.xslt.impl.XsltStuffProvider;

import com.intellij.codeHighlighting.TextEditorHighlightingPass;
import com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPassRegistrarEx;
import com.intellij.mock.MockProgressIndicator;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.ArrayUtil;

import java.util.List;

/*
* Created by IntelliJ IDEA.
* User: sweinreuter
* Date: 12.06.2008
*/
public class XsltHighlightingTest extends TestBase {
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        myFixture.enableInspections(new XsltStuffProvider(null).getInspectionClasses());
    }

    public void xtestBackwardIncludedVariable() throws Throwable {
        doXsltHighlighting();
    }

    public void testUnknownTemplate() throws Throwable {
        doXsltHighlighting();
    }

    public void testUnknownMode() throws Throwable {
        doXsltHighlighting();
    }

    public void testUndeclaredParam() throws Throwable {
        doXsltHighlighting();
    }

    public void testMissingParam() throws Throwable {
        doXsltHighlighting();
    }

    public void testUnusedVariable() throws Throwable {
        doXsltHighlighting();
    }

    public void testShadowedVariable() throws Throwable {
        doXsltHighlighting();
    }

    public void testValidPatterns() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern1() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern2() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern3() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern4() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern5() throws Throwable {
        doXsltHighlighting();
    }

    public void xtestPerformance() throws Throwable {
        myFixture.configureByFile(getTestFileName() + ".xsl");
        final long l = runHighlighting();
        assertTrue("Highlighting took " + l + "ms", l < 6000);
    }

    private long runHighlighting() {
        final Project project = myFixture.getProject();
        PsiDocumentManager.getInstance(project).commitAllDocuments();

        return ApplicationManager.getApplication().runReadAction(new Computable<Long>() {
                    public Long compute() {
                        final long l = System.currentTimeMillis();
                        List<TextEditorHighlightingPass> passes =
                                TextEditorHighlightingPassRegistrarEx.getInstanceEx(myFixture.getProject()).instantiatePasses(myFixture.getFile(), myFixture.getEditor(), ArrayUtil.EMPTY_INT_ARRAY);
                        MockProgressIndicator progress = new MockProgressIndicator();
                        for (TextEditorHighlightingPass pass : passes) {
                            pass.collectInformation(progress);
                        }
                        return System.currentTimeMillis() - l;
                    }
                });
    }

    private void doXsltHighlighting(String... moreFiles) throws Throwable {
        final String name = getTestFileName();
        myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xsl"));<commit_msg>Fixed bug when visible pass finishes after updateAll pass and wipes its results (Pre-Tested Commit)<commit_after>package org.intellij.lang.xpath.xslt;

import com.intellij.codeHighlighting.TextEditorHighlightingPass;
import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
import com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPassRegistrarEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.ArrayUtil;
import org.intellij.lang.xpath.TestBase;
import org.intellij.lang.xpath.xslt.impl.XsltStuffProvider;

import java.util.List;

/*
* Created by IntelliJ IDEA.
* User: sweinreuter
* Date: 12.06.2008
*/
public class XsltHighlightingTest extends TestBase {
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        myFixture.enableInspections(new XsltStuffProvider(null).getInspectionClasses());
    }

    public void xtestBackwardIncludedVariable() throws Throwable {
        doXsltHighlighting();
    }

    public void testUnknownTemplate() throws Throwable {
        doXsltHighlighting();
    }

    public void testUnknownMode() throws Throwable {
        doXsltHighlighting();
    }

    public void testUndeclaredParam() throws Throwable {
        doXsltHighlighting();
    }

    public void testMissingParam() throws Throwable {
        doXsltHighlighting();
    }

    public void testUnusedVariable() throws Throwable {
        doXsltHighlighting();
    }

    public void testShadowedVariable() throws Throwable {
        doXsltHighlighting();
    }

    public void testValidPatterns() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern1() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern2() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern3() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern4() throws Throwable {
        doXsltHighlighting();
    }

    public void testInValidPattern5() throws Throwable {
        doXsltHighlighting();
    }

    public void xtestPerformance() throws Throwable {
        myFixture.configureByFile(getTestFileName() + ".xsl");
        final long l = runHighlighting();
        assertTrue("Highlighting took " + l + "ms", l < 6000);
    }

    private long runHighlighting() {
        final Project project = myFixture.getProject();
        PsiDocumentManager.getInstance(project).commitAllDocuments();

        return ApplicationManager.getApplication().runReadAction(new Computable<Long>() {
                    public Long compute() {
                        final long l = System.currentTimeMillis();
                        List<TextEditorHighlightingPass> passes =
                                TextEditorHighlightingPassRegistrarEx.getInstanceEx(myFixture.getProject()).instantiatePasses(myFixture.getFile(), myFixture.getEditor(), ArrayUtil.EMPTY_INT_ARRAY);
                        ProgressIndicator progress = new DaemonProgressIndicator();
                        for (TextEditorHighlightingPass pass : passes) {
                            pass.collectInformation(progress);
                        }
                        return System.currentTimeMillis() - l;
                    }
                });
    }

    private void doXsltHighlighting(String... moreFiles) throws Throwable {
        final String name = getTestFileName();
        myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xsl"));
{'fraction_non_alphanumeric': 0.08699209162803381, 'fraction_numerical': 0.004635942187073902, 'mean_word_length': 2.9078316462440066, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3232414', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1970, 'n_words': 399}