Javafx: Handle wildcard event type in the quick fix that creates event handler method. Add test for that. (IDEA-151694)

This commit is contained in:
Pavel Dolgov
2016-03-21 21:21:22 +03:00
parent d7c2749d49
commit b0326abca2
5 changed files with 21 additions and 1 deletions
@@ -64,6 +64,10 @@ public class JavaFxEventHandlerInspectionTest extends AbstractJavaFXTestCase {
doQuickfixTest("Create method 'void onSort(SortEvent)'");
}
public void testQuickfixSuper() throws Exception {
doQuickfixTest("Create method 'void click(MouseEvent)'");
}
private void doHighlightingTest() throws Exception {
myFixture.configureByFiles(getTestName(true) + ".fxml", getTestName(false) + ".java");
myFixture.checkHighlighting();
@@ -112,7 +112,10 @@ public class JavaFxEventHandlerReference extends PsiReferenceBase<XmlAttributeVa
final PsiType handlerType =
tagClassSubstitutor != null ? tagClassSubstitutor.substitute(eventHandlerPropertyType) : eventHandlerPropertyType;
if (handlerType instanceof PsiClassType) {
final PsiType eventType = JavaFxPsiUtil.substituteEventType((PsiClassType)handlerType, element.getProject());
PsiType eventType = JavaFxPsiUtil.substituteEventType((PsiClassType)handlerType, element.getProject());
if (eventType instanceof PsiWildcardType && ((PsiWildcardType)eventType).isSuper()) {
eventType = ((PsiWildcardType)eventType).getBound();
}
if (eventType != null) {
if (eventType instanceof PsiClassType && JavaFxPsiUtil.isNotFullyResolvedGeneric((PsiClassType)eventType)) {
canonicalText = ((PsiClassType)eventType).rawType().getCanonicalText();
@@ -0,0 +1 @@
public class QuickfixSuper{}
@@ -0,0 +1,7 @@
import javafx.scene.input.MouseEvent;
public class QuickfixSuper{
public void click(MouseEvent mouseEvent) {
}
}
@@ -0,0 +1,5 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.GridPane?>
<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="QuickfixSuper">
<Label onMouseClicked="#cl<caret>ick"/>
</GridPane>