2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.intellij
.lang
.xpath
.xslt
;
18 import com
.intellij
.codeHighlighting
.TextEditorHighlightingPass
;
19 import com
.intellij
.codeInsight
.daemon
.impl
.DaemonProgressIndicator
;
20 import com
.intellij
.codeInsight
.daemon
.impl
.TextEditorHighlightingPassRegistrarEx
;
21 import com
.intellij
.openapi
.application
.ApplicationManager
;
22 import com
.intellij
.openapi
.progress
.ProgressIndicator
;
23 import com
.intellij
.openapi
.project
.Project
;
24 import com
.intellij
.openapi
.util
.Computable
;
25 import com
.intellij
.psi
.PsiDocumentManager
;
26 import com
.intellij
.util
.ArrayUtil
;
27 import org
.intellij
.lang
.xpath
.TestBase
;
28 import org
.intellij
.lang
.xpath
.xslt
.impl
.XsltStuffProvider
;
30 import java
.util
.List
;
33 * Created by IntelliJ IDEA.
37 public class XsltHighlightingTest
extends TestBase
{
39 protected void setUp() throws Exception
{
41 myFixture
.enableInspections(new XsltStuffProvider(null).getInspectionClasses());
44 public void xtestBackwardIncludedVariable() throws Throwable
{
48 public void testUnknownTemplate() throws Throwable
{
52 public void testUnknownMode() throws Throwable
{
56 public void testCurrentModeXslt2() throws Throwable
{
60 public void testUndeclaredParam() throws Throwable
{
64 public void testMissingParam() throws Throwable
{
68 public void testUnusedVariable() throws Throwable
{
72 public void testShadowedVariable() throws Throwable
{
76 public void testValidPatterns() throws Throwable
{
80 public void testInvalidPattern1() throws Throwable
{
84 public void testInvalidPattern2() throws Throwable
{
88 public void testInvalidPattern3() throws Throwable
{
92 public void testInvalidPattern4() throws Throwable
{
96 public void testInvalidPattern5() throws Throwable
{
100 public void xtestPerformance() throws Throwable
{
101 myFixture
.configureByFile(getTestFileName() + ".xsl");
102 final long l
= runHighlighting();
103 assertTrue("Highlighting took " + l
+ "ms", l
< 6000);
106 private long runHighlighting() {
107 final Project project
= myFixture
.getProject();
108 PsiDocumentManager
.getInstance(project
).commitAllDocuments();
110 return ApplicationManager
.getApplication().runReadAction(new Computable
<Long
>() {
111 public Long
compute() {
112 final long l
= System
.currentTimeMillis();
113 List
<TextEditorHighlightingPass
> passes
=
114 TextEditorHighlightingPassRegistrarEx
.getInstanceEx(myFixture
.getProject()).instantiatePasses(myFixture
.getFile(), myFixture
.getEditor(), ArrayUtil
.EMPTY_INT_ARRAY
);
115 ProgressIndicator progress
= new DaemonProgressIndicator();
116 for (TextEditorHighlightingPass pass
: passes
) {
117 pass
.collectInformation(progress
);
119 return System
.currentTimeMillis() - l
;
124 private void doXsltHighlighting(String
... moreFiles
) throws Throwable
{
125 final String name
= getTestFileName();
126 myFixture
.testHighlighting(true, false, false, ArrayUtil
.append(moreFiles
, name
+ ".xsl"));
129 protected String
getSubPath() {
130 return "xslt/highlighting";