sdedic commented on code in PR #4091:
URL: https://github.com/apache/netbeans/pull/4091#discussion_r907507231
##########
groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/api/GroovyIndex.java:
##########
@@ -340,14 +332,56 @@ public Set<IndexedMethod> getMethods(final String name,
final String clz, QueryS
// XXX THIS DOES NOT WORK WHEN THERE ARE IDENTICAL
SIGNATURES!!!
assert map != null;
- methods.add(createMethod(signature, map));
+ IndexedMethod method = createMethod(signature, map);
+ if (method != null) {
+ methods.add(method);
+ }
}
}
}
return methods;
}
-
+
+ // protected for test reasons.
+ protected static boolean matchCamelCase(String prefix, String where,
boolean insensitive) {
+ if (where == null || where.length() == 0 || prefix == null ||
prefix.length() == 0) {
+ return false;
+ }
+ if (!prefix.equals(cachedPrefix) || cachedInsensitive != insensitive) {
+ cachedCamelCasePattern = null;
+ }
+ if (cachedCamelCasePattern == null) {
+ StringBuilder sb = new StringBuilder();
+ int lastIndex = 0;
+ int index;
+ do {
+ index = findNextUpper(prefix, lastIndex + 1);
+ String token = prefix.substring(lastIndex, index == -1 ?
prefix.length() : index);
+ if (insensitive) {
Review Comment:
What about `matchCamelCase("CaCa", "CAMELCase")` -- IMHO the first token
("Ca") will be searched as `Ca|ca`, which will not match "`CA`MELCase" ... ?
It's probably better to just compile the pattern with `Pattern.CASE_INSENSITIVE`
This works OK in Java BUT Java indexer uses pair of fields, one for raw
values and the other for case-insensitive (lowercase) ones. This would require
yet additional changes ... for (IMHO) a niche case. Let's leave it for now, but
I wonder what other queries could be affected.
##########
groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/api/GroovyIndex.java:
##########
@@ -340,14 +332,56 @@ public Set<IndexedMethod> getMethods(final String name,
final String clz, QueryS
// XXX THIS DOES NOT WORK WHEN THERE ARE IDENTICAL
SIGNATURES!!!
assert map != null;
- methods.add(createMethod(signature, map));
+ IndexedMethod method = createMethod(signature, map);
+ if (method != null) {
+ methods.add(method);
+ }
}
}
}
return methods;
}
-
+
+ // protected for test reasons.
+ protected static boolean matchCamelCase(String prefix, String where,
boolean insensitive) {
+ if (where == null || where.length() == 0 || prefix == null ||
prefix.length() == 0) {
+ return false;
+ }
+ if (!prefix.equals(cachedPrefix) || cachedInsensitive != insensitive) {
Review Comment:
Note the `cachePrefix`, `cachedInsensitive` and `cachedCamelCasePattern` are
shared between all instances of `GroovyIndex` across threads (2 threads can
call `GroovyIndex.getFields()` simultaneously). Without synchronizing, Java may
flush just part of the triplet on write making it temporarily inconsistent for
other concurrent accesses.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists