You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by db...@apache.org on 2022/05/03 07:20:28 UTC

[netbeans] branch master updated: Micronaut Data finder completion should work for record entities. (#4053)

This is an automated email from the ASF dual-hosted git repository.

dbalek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new f46c99ccb7 Micronaut Data finder completion should work for record entities. (#4053)
f46c99ccb7 is described below

commit f46c99ccb7cbf9fb0844ca7b2cb340c63d0e56b5
Author: Dusan Balek <du...@oracle.com>
AuthorDate: Tue May 3 09:20:24 2022 +0200

    Micronaut Data finder completion should work for record entities. (#4053)
---
 .../completion/MicronautDataCompletionTask.java        | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java
index fc9ac7cd41..2584357d6c 100644
--- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java
+++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionTask.java
@@ -41,6 +41,7 @@ import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.Modifier;
+import javax.lang.model.element.RecordComponentElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeKind;
@@ -248,8 +249,21 @@ public class MicronautDataCompletionTask {
             Map<String, String> prop2Types = new HashMap<>();
             for (ExecutableElement method : ElementFilter.methodsIn(entity.getEnclosedElements())) {
                 String methodName = method.getSimpleName().toString();
-                if (methodName.startsWith(GET) && method.getParameters().isEmpty()) {
-                    prop2Types.put(methodName.substring(GET.length()), tu.getTypeName(method.getReturnType()).toString());
+                if (methodName.startsWith(GET) && methodName.length() > 3 && method.getParameters().isEmpty()) {
+                    TypeMirror type = method.getReturnType();
+                    if (type.getKind() != TypeKind.ERROR) {
+                        methodName = methodName.substring(GET.length());
+                        methodName = methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1);
+                        prop2Types.put(methodName, tu.getTypeName(type).toString());
+                    }
+                }
+            }
+            for (RecordComponentElement recordComponent : ElementFilter.recordComponentsIn(entity.getEnclosedElements())) {
+                TypeMirror type = recordComponent.asType();
+                if (type.getKind() != TypeKind.ERROR) {
+                    String name = recordComponent.getSimpleName().toString();
+                    name = name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1);
+                    prop2Types.put(name, tu.getTypeName(type).toString());
                 }
             }
             addFindByCompletions(entity, prop2Types, prefix, full, consumer);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists