You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/06/09 15:14:01 UTC

[GitHub] [netbeans] ppisl commented on a diff in pull request #4091: Implementation of GoTo Symbol for Groovy

ppisl commented on code in PR #4091:
URL: https://github.com/apache/netbeans/pull/4091#discussion_r893634432


##########
groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/language/GroovyTypeSearcher.java:
##########
@@ -59,10 +62,38 @@ public class GroovyTypeSearcher implements IndexSearcher {
 
     @Override
     public Set<? extends Descriptor> getSymbols(Project project, String textForQuery, Kind kind, Helper helper) {
-        // TODO - search for methods too!!
+        GroovyIndex index = GroovyIndex.get(QuerySupport.findRoots(project, Collections.singleton(ClassPath.SOURCE), Collections.<String>emptySet(), Collections.<String>emptySet()));
 
-        // For now, just at a minimum do the types
-        return getTypes(project, textForQuery, kind, helper);
+        kind = adjustKind(kind, textForQuery);
+        
+        if (kind == QuerySupport.Kind.CASE_INSENSITIVE_PREFIX /*|| kind == QuerySupport.Kind.CASE_INSENSITIVE_REGEXP*/) {
+            textForQuery = textForQuery.toLowerCase(Locale.ENGLISH);
+        }
+        
+        Set<GroovyTypeDescriptor> result = new HashSet<GroovyTypeDescriptor>();
+        
+        
+        if (textForQuery.length() > 0) {
+            Set<IndexedClass> classes = null;
+            classes = index.getClasses(textForQuery, kind);
+            for (IndexedClass cls : classes) {
+                result.add(new GroovyTypeDescriptor(cls, helper));
+            }
+            
+            Set<IndexedField> fields = index.getFields(textForQuery, null, kind);
+            for (IndexedField field : fields) {
+                result.add(new GroovyTypeDescriptor(field, helper));
+            }
+            
+            Set<IndexedMethod> methods = index.getMethods(textForQuery, null, kind);
+            for (IndexedMethod method : methods) {
+                if (method.getOffsetRange(null)  != OffsetRange.NONE) {

Review Comment:
   I have to admit that can look strange. The condition is here for my testing purposes and can be deleted. Unfortunately currently we don't store into the index whether the element is synthetic. Synthetic elements have offset [0,0] so it can be a sign how to recognize them. The question is, should we offer them in the Goto Symbol?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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

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