inference: propagate variable renames through the call hierarchy; calculate tooltips in tests (IDEA-151948)

This commit is contained in:
Anna Kozlova
2016-02-22 20:05:58 +01:00
parent 792d40fc9f
commit 930df16f98
14 changed files with 73 additions and 18 deletions
@@ -16,11 +16,17 @@
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/graphInference";
@@ -399,6 +405,34 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testVariableNamesOfNestedCalls() throws Exception {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
String filePath = BASE_PATH + "/" + getTestName(false) + ".java";
configureByFile(filePath);
Collection<HighlightInfo> infos = doHighlighting();
List<String> tooltips = new ArrayList<>();
for (HighlightInfo info : infos) {
if (info.getSeverity() == HighlightSeverity.ERROR) {
tooltips.add(info.getToolTip());
}
}
assertTrue(tooltips.contains("<html><body><table border=0><tr><td>" +
"<b>identity(&nbsp;)&nbsp;</b></td><td colspan=1>in <b>Function</b>&nbsp;cannot be applied</td></tr><tr><td>to</td><td><b>()</b>&nbsp;" +
"</td></tr></table><br/>" +
"reason: no instance(s) of type variable(s) K, U exist so that Map&lt;K, U&gt; conforms to Function&lt;U, V&gt;" +
"</body></html>"));
assertTrue(tooltips.contains(
"<html><body><table border=0><tr><td>" +
"<b>identity(&nbsp;)&nbsp;</b></td><td colspan=1>in <b>Function</b>&nbsp;cannot be applied</td></tr><tr><td>to</td><td><b>()</b>&nbsp;" +
"</td></tr></table><br/>" +
"reason: no instance(s) of type variable(s) K, U exist so that Map&lt;K, U&gt; conforms to Function&lt;U, V&gt;" +
"</body></html>"));
}
private void doTest() throws Exception {
doTest(false);
}