sdedic commented on code in PR #7737: URL: https://github.com/apache/netbeans/pull/7737#discussion_r1759800028
########## ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/errors/TaskCache.java: ########## @@ -277,18 +306,26 @@ private List<Task> loadErrors(File input, FileObject file) throws IOException { continue; } - int lineNumber = Integer.parseInt(parts[1]); + ErrorsCache.Range range; + Matcher matcher = PATTERN.matcher(parts[1]); + if (matcher.matches()) { + ErrorsCache.Position start = new ErrorsCache.Position(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); + ErrorsCache.Position end = matcher.group(3) != null && matcher.group(4) != null ? new ErrorsCache.Position(Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4))) : null; + range = new ErrorsCache.Range(start, end); + } else { + int lineNumber = Integer.parseInt(parts[1]); + range = new ErrorsCache.Range(new ErrorsCache.Position(lineNumber, 1), null); + } + String message = parts[2]; message = message.replaceAll("\\\\d", ":"); //NOI18N Review Comment: Maybe can use `.replace()` without regexp escapes (should be also faster) ? ########## ide/parsing.indexing/src/org/netbeans/modules/parsing/spi/indexing/ErrorsCache.java: ########## @@ -82,6 +94,52 @@ public static interface Convertor<T> { public String getMessage(T t); } + public static final class Position { Review Comment: javadocs, please, maybe also apichanges entry. ########## ide/parsing.indexing/apichanges.xml: ########## @@ -87,6 +87,20 @@ is the proper place. <!-- ACTUAL CHANGES BEGIN HERE: --> <changes> + <change id="ErrorsCache.getErrors"> + <api name="IndexingAPI"/> + <summary>Added method to ErrorsCache to return all errors or warnings for the given file</summary> + <version major="9" minor="37"/> Review Comment: I can't find spec version bump in `project.properties` ########## ide/csl.api/src/org/netbeans/modules/csl/core/TLIndexerFactory.java: ########## @@ -178,6 +178,29 @@ public int getLineNumber(SimpleError error) { return lineNumber; } @Override + public ErrorsCache.Range getRange(SimpleError error) { + int originalOffset = error.getStartPosition(); //snapshot offset + int lineNumber = 1; + int colNumber = 1; + if (originalOffset >= 0) { + int idx = Collections.binarySearch(lineStartOffsets, originalOffset); + if (idx < 0) { + // idx == (-(insertion point) - 1) -> (insertion point) == -idx - 1 + int ln = -idx - 1; + assert ln >= 1 && ln <= lineStartOffsets.size() : + "idx=" + idx + ", lineNumber=" + ln + ", lineStartOffsets.size()=" + lineStartOffsets.size(); //NOI18N + if (ln >= 1 && ln <= lineStartOffsets.size()) { + lineNumber = ln; + } + } else { + lineNumber = idx + 1; Review Comment: I think `idx >= 0` iff the exact `originalOffset` value is among `lineStartOffsets`, so this branch would execute just for `originalOffset` at line start => colNumber == 1 ? -- 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-unsubscr...@netbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists