-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
149 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/scala/org/jetbrains/plugins/scala/base/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.jetbrains.plugins.scala | ||
|
||
import _root_.junit.framework.TestCase | ||
import org.jetbrains.plugins.scala.extensions.ObjectExt | ||
import org.jetbrains.plugins.scala.util.NotNothing | ||
import org.jetbrains.plugins.scala.util.runners.WithIndexingMode | ||
|
||
import java.lang.annotation.Annotation | ||
import scala.reflect.{ClassTag, classTag} | ||
import scala.util.Try | ||
|
||
package object base { | ||
final implicit class TestCaseExt(private val testCase: TestCase) extends AnyVal { | ||
// SCL-21849 | ||
def findIndexingModeAnnotation(): Option[WithIndexingMode] = findTestAnnotation[WithIndexingMode] | ||
|
||
/** | ||
* Tries to find the specified annotation on the current test method and then on the current class. | ||
* And then on the superclass if marked as [[java.lang.annotation.Inherited]]. | ||
*/ | ||
def findTestAnnotation[A <: Annotation : ClassTag : NotNothing]: Option[A] = | ||
testMethodAnnotation[A].orElse(classAnnotation[A]) | ||
|
||
private def testMethodAnnotation[A <: Annotation : ClassTag]: Option[A] = | ||
for { | ||
name <- testCase.getName.toOption | ||
// java.lang.NoSuchMethodException can happen in generated tests (e.g.: FileSetTests) | ||
method <- Try(testCase.getClass.getMethod(name)).toOption | ||
annotation <- method.getAnnotation(classTag[A].runtimeClass.asInstanceOf[Class[A]]).toOption | ||
} yield annotation | ||
|
||
private def classAnnotation[A <: Annotation : ClassTag]: Option[A] = | ||
testCase.getClass.getAnnotation(classTag[A].runtimeClass.asInstanceOf[Class[A]]).toOption | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/scala/org/jetbrains/plugins/scala/util/runners/WithIndexingMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.jetbrains.plugins.scala.util.runners; | ||
|
||
import com.intellij.testFramework.TestIndexingModeSupporter.IndexingMode; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* Enables one of the indexing modes for each test: smart mode or dumb mode with empty, partial or full index. | ||
* | ||
* @see IndexingMode | ||
* @see org.jetbrains.plugins.scala.base.ScalaLightCodeInsightFixtureTestCase | ||
* @see <a href="https://youtrack.jetbrains.com/issue/SCL-21849/Make-more-functionality-available-during-indexing">SCL-21849</a> | ||
* @see <a href="https://youtrack.jetbrains.com/articles/IJPL-A-270/Make-functionality-available-during-indexing">Make functionality available during indexing</a> | ||
*/ | ||
@Inherited | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface WithIndexingMode { | ||
IndexingMode mode(); | ||
|
||
String reason() default ""; | ||
} |