mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Javafx: In FXML completion for event handler show methods from controller's superclasses (IDEA-154115)
This commit is contained in:
+5
@@ -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");
|
||||
|
||||
+3
-1
@@ -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>
|
||||
Reference in New Issue
Block a user