diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiFileHighlightingTest.java b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiFileHighlightingTest.java index 12d93d10b5b..82c01dcad5c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiFileHighlightingTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiFileHighlightingTest.java @@ -16,18 +16,6 @@ package org.jetbrains.kotlin.idea.stubs; -import com.intellij.codeInsight.completion.CompletionTestCase; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; -import com.intellij.codeInsight.daemon.impl.HighlightInfo; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.DumbService; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.impl.cache.CacheManager; -import com.intellij.psi.impl.source.tree.TreeElement; -import com.intellij.psi.impl.source.tree.TreeUtil; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.UsageSearchContext; -import com.intellij.testFramework.ExpectedHighlightingData; import kotlin.Unit; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; @@ -35,9 +23,8 @@ import org.jetbrains.kotlin.idea.test.AstAccessControl; import org.jetbrains.kotlin.idea.test.PluginTestCaseBase; import java.io.File; -import java.util.Collection; -public abstract class AbstractMultiFileHighlightingTest extends CompletionTestCase { +public abstract class AbstractMultiFileHighlightingTest extends AbstractMultiHighlightingTest { public void doTest(@NotNull String filePath) throws Exception { configureByFile(new File(filePath).getName(), ""); @@ -58,33 +45,4 @@ public abstract class AbstractMultiFileHighlightingTest extends CompletionTestCa protected String getTestDataPath() { return PluginTestCaseBase.getTestDataPathBase() + "/multiFileHighlighting/"; } - - //NOTE: partially copied from DaemonAnalyzerTestCase#checkHighlighting - @Override - @NotNull - protected Collection checkHighlighting(@NotNull ExpectedHighlightingData data) { - data.init(); - PsiDocumentManager.getInstance(myProject).commitAllDocuments(); - - //to load text - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - TreeUtil.clearCaches((TreeElement) myFile.getNode()); - } - }); - - //to initialize caches - if (!DumbService.isDumb(getProject())) { - CacheManager.SERVICE.getInstance(myProject) - .getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true); - } - - Collection infos = doHighlighting(); - - String text = myEditor.getDocument().getText(); - data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(getFile()), getProject()), text); - data.checkResult(infos, text); - return infos; - } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiHighlightingTest.kt new file mode 100644 index 00000000000..d323011d897 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiHighlightingTest.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * 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 org.jetbrains.kotlin.idea.stubs + +import com.intellij.codeInsight.completion.CompletionTestCase +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl +import com.intellij.codeInsight.daemon.impl.HighlightInfo +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.project.DumbService +import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.impl.cache.CacheManager +import com.intellij.psi.impl.source.tree.TreeElement +import com.intellij.psi.impl.source.tree.TreeUtil +import com.intellij.psi.search.GlobalSearchScope +import com.intellij.psi.search.UsageSearchContext +import com.intellij.testFramework.ExpectedHighlightingData + +abstract class AbstractMultiHighlightingTest : CompletionTestCase() { + + protected open val shouldCheckLineMarkers = false + + protected open val shouldCheckResult = true + + override fun checkHighlighting(data: ExpectedHighlightingData): Collection { + data.init() + PsiDocumentManager.getInstance(myProject).commitAllDocuments() + + //to load text + ApplicationManager.getApplication().runWriteAction { TreeUtil.clearCaches(myFile.node as TreeElement) } + + //to initialize caches + if (!DumbService.isDumb(project)) { + CacheManager.SERVICE.getInstance(myProject) + .getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(myProject), true) + } + + val infos = doHighlighting() + + val text = myEditor.document.text + if (shouldCheckLineMarkers) { + data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(getDocument(file), project), text) + } + if (shouldCheckResult) { + data.checkResult(infos, text) + } + return infos + } + +} \ No newline at end of file