IDEA-260227 add test for ctrl+mouse documentation on a lambda parameter

GitOrigin-RevId: 65b32ec19f159956adc298eba0d02aa05d4c2c0d
This commit is contained in:
Daniil Ovchinnikov
2021-01-26 19:31:34 +01:00
committed by intellij-monorepo-bot
parent 15c38734d4
commit 98f2cd578a
4 changed files with 52 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
<html><head><style>
body, div, td, p {font-family:'Lucida Grande'; font-size:13pt; color:#000000;}
a {font-family:'Lucida Grande'; font-size:13pt; color:#589df6;}
code {font-size:13pt;}
ul {list-style:disc; margin-left:15px;}
</style></head><body><a href="psi_element://java.lang.String">String</a> item</body></html>

View File

@@ -0,0 +1,14 @@
interface FunctionalInterface<T> {
void apply(T t);
}
interface MethodOwner<T> {
void method(FunctionalInterface<T> fi);
}
class JavaClass {
void usage(MethodOwner<String> mo) {
mo.method(<caret>item -> System.out.println(item));
}
}

View File

@@ -0,0 +1,25 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.javadoc
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction
import com.intellij.java.codeInsight.javadoc.JavaDocInfoGeneratorTest.assertEqualsFileText
import com.intellij.testFramework.RunsInEdt
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase4
import org.junit.Test
@RunsInEdt
class JavaCtrlMouseTest : LightJavaCodeInsightFixtureTestCase4(
testDataPath = "${JavaTestUtil.getJavaTestDataPath()}/codeInsight/ctrlMouse/"
) {
private fun doTest() {
val testName = testName
fixture.configureByFile("$testName.java")
val actual = GotoDeclarationAction().getCtrlMouseInfo(fixture.editor, fixture.file, fixture.caretOffset)?.docInfo?.text!!
assertEqualsFileText("$testDataPath$testName.html", actual)
}
@Test
fun `lambda parameter`(): Unit = doTest()
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.javadoc;
import com.intellij.JavaTestUtil;
@@ -349,8 +349,12 @@ public class JavaDocInfoGeneratorTest extends JavaCodeInsightTestCase {
}
private void assertFileTextEquals(String docInfo, String expectedFile) {
String actualText = replaceEnvironmentDependentContent(docInfo);
File htmlPath = new File(getTestDataPath() + TEST_DATA_FOLDER + expectedFile);
assertEqualsFileText(getTestDataPath() + TEST_DATA_FOLDER + expectedFile, docInfo);
}
static void assertEqualsFileText(@NotNull String expectedFile, @NotNull String actual) {
String actualText = replaceEnvironmentDependentContent(actual);
File htmlPath = new File(expectedFile);
String expectedText = loadFile(htmlPath);
if (!StringUtil.equals(expectedText, actualText)) {
String message = "Text mismatch in file: " + htmlPath.getName();