Javafx: In FXML completion for event handler show methods from controller's superclasses (IDEA-154115)

This commit is contained in:
Pavel Dolgov
2016-04-05 16:30:33 +03:00
parent 06fa856169
commit e52eb35339
5 changed files with 29 additions and 1 deletions
@@ -217,6 +217,11 @@ public class JavaFxCompletionTest extends LightFixtureCompletionTestCase {
doTest("ColumnConstraints");
}
public void testEventHandlerMethod() throws Exception {
configureAndComplete("EventHandlerMethod.java", "EventHandlerMethodSuper.java");
assertSameElements(myFixture.getLookupElementStrings(), "onMyKeyTyped", "onSuperKeyTyped");
}
public void testRawCollectionItem() throws Exception {
configureAndComplete();
assertDoesntContain(myFixture.getLookupElementStrings(), "T", "Object", "java.lang.Object");
@@ -57,7 +57,7 @@ public class JavaFxEventHandlerReference extends PsiReferenceBase<XmlAttributeVa
public Object[] getVariants() {
if (myController == null) return EMPTY_ARRAY;
final List<PsiMethod> availableHandlers = new ArrayList<PsiMethod>();
for (PsiMethod psiMethod : myController.getMethods()) {
for (PsiMethod psiMethod : myController.getAllMethods()) {
if (isHandlerMethodSignature(psiMethod) && JavaFxPsiUtil.isVisibleInFxml(psiMethod)) {
availableHandlers.add(psiMethod);
}
@@ -66,6 +66,8 @@ public class JavaFxEventHandlerReference extends PsiReferenceBase<XmlAttributeVa
}
public static boolean isHandlerMethodSignature(PsiMethod psiMethod) {
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass != null && CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) return false;
if (!psiMethod.hasModifierProperty(PsiModifier.STATIC)) {
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
if (parameters.length == 1) {
@@ -0,0 +1,8 @@
import javafx.fxml.FXML;
import javafx.scene.input.KeyEvent;
public class EventHandlerMethod extends EventHandlerMethodSuper {
@FXML
private void onMyKeyTyped(KeyEvent event) {
}
}
@@ -0,0 +1,8 @@
import javafx.fxml.FXML;
import javafx.scene.input.KeyEvent;
public class EventHandlerMethodSuper {
@FXML
private void onSuperKeyTyped(KeyEvent event) {
}
}
@@ -0,0 +1,5 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/null" fx:controller="EventHandlerMethod">
<TextField onKeyTyped="#<caret>"/>
</VBox>