lahodaj commented on code in PR #8206:
URL: https://github.com/apache/netbeans/pull/8206#discussion_r1937142800


##########
ide/parsing.indexing/nbproject/project.properties:
##########
@@ -14,7 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-javac.source=1.8
+javac.release=17
 javac.compilerargs=-Xlint -Xlint:-serial
 spec.version.base=9.39.0

Review Comment:
   ```suggestion
   spec.version.base=9.40.0
   ```



##########
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="39"/>

Review Comment:
   ```suggestion
             <version major="9" minor="40"/>
   ```



##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/errors/TaskCache.java:
##########
@@ -200,6 +229,7 @@ public <T> void dumpErrors(final URL root, final Indexable 
i, final Iterable<? e
                 }
             });
         } catch (IOException ex) {
+            Exceptions.attachMessage(ex, "can't dump errors for: " + 
String.valueOf(i));
             Exceptions.printStackTrace(ex);
         }

Review Comment:
   If we re-throw here, the caller of `dumpErrors`/`ErrorsCache.setErrors` 
might fail. Not setting the errors is troublesome, but crashing the indexers is 
worse, as it can have effects not only on error reporting. I think keeping the 
exception report here is OK. Whether the enhanced info should be attached using 
`attachMessage` not sure - but duplicated text in the log also does not look 
too terrible. If needed, we could do something like this(?):
   ```
   Exceptions.printStackTrace(new IOException("can't dump errors for: " + 
String.valueOf(i), ex));
   ```



##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/spi/indexing/ErrorsCache.java:
##########
@@ -74,12 +75,46 @@ public static Collection<? extends URL> 
getAllFilesWithRecord(URL root) throws I
         return 
Collections.unmodifiableCollection(TaskCache.getDefault().getAllFilesWithRecord(root));
     }
 
-    /**Getter for properties of the given error description.
+    /**Return all errors or warnings for the given file
+     *
+     * @param file file for which the errors are being retrieved
+     * @param convertor constructor of {@code T} instances from error 
description properties
+     * @return errors or warnings
+     * @since 9.39
+     */
+    public static <T> List<T> getErrors(FileObject file, ReverseConvertor<T> 
convertor) throws IOException {
+        return 
Collections.unmodifiableList(TaskCache.getDefault().getErrors(file, convertor));
+    }
+
+    /**Position in a text expressed as 1-based line and character offset.
+     * @since 9.39
+     */
+    public record Position(int line, int column) {}
+
+    /**Range in a text expressed as (1-based) start and end positions.
+     * @since 9.39
+     */
+    public record Range(Position start, Position end) {}
+
+    /**Getter for properties of the given error description including the 
range.
      */
     public static interface Convertor<T> {
         public ErrorKind getKind(T t);
         public int       getLineNumber(T t);
         public String    getMessage(T t);
+        /**
+         * @since 9.39

Review Comment:
   ```suggestion
            * @since 9.40
   ```



##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/spi/indexing/ErrorsCache.java:
##########
@@ -74,12 +75,46 @@ public static Collection<? extends URL> 
getAllFilesWithRecord(URL root) throws I
         return 
Collections.unmodifiableCollection(TaskCache.getDefault().getAllFilesWithRecord(root));
     }
 
-    /**Getter for properties of the given error description.
+    /**Return all errors or warnings for the given file
+     *
+     * @param file file for which the errors are being retrieved
+     * @param convertor constructor of {@code T} instances from error 
description properties
+     * @return errors or warnings
+     * @since 9.39
+     */
+    public static <T> List<T> getErrors(FileObject file, ReverseConvertor<T> 
convertor) throws IOException {
+        return 
Collections.unmodifiableList(TaskCache.getDefault().getErrors(file, convertor));
+    }
+
+    /**Position in a text expressed as 1-based line and character offset.
+     * @since 9.39

Review Comment:
   ```suggestion
        * @since 9.40
   ```



##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/spi/indexing/ErrorsCache.java:
##########
@@ -74,12 +75,46 @@ public static Collection<? extends URL> 
getAllFilesWithRecord(URL root) throws I
         return 
Collections.unmodifiableCollection(TaskCache.getDefault().getAllFilesWithRecord(root));
     }
 
-    /**Getter for properties of the given error description.
+    /**Return all errors or warnings for the given file
+     *
+     * @param file file for which the errors are being retrieved
+     * @param convertor constructor of {@code T} instances from error 
description properties
+     * @return errors or warnings
+     * @since 9.39
+     */
+    public static <T> List<T> getErrors(FileObject file, ReverseConvertor<T> 
convertor) throws IOException {
+        return 
Collections.unmodifiableList(TaskCache.getDefault().getErrors(file, convertor));
+    }
+
+    /**Position in a text expressed as 1-based line and character offset.
+     * @since 9.39
+     */
+    public record Position(int line, int column) {}
+
+    /**Range in a text expressed as (1-based) start and end positions.
+     * @since 9.39
+     */
+    public record Range(Position start, Position end) {}
+
+    /**Getter for properties of the given error description including the 
range.
      */
     public static interface Convertor<T> {
         public ErrorKind getKind(T t);
         public int       getLineNumber(T t);
         public String    getMessage(T t);
+        /**
+         * @since 9.39
+         */
+        public default Range getRange(T t) {
+            return null;
+        }
+    }
+
+    /**Constructor of error description from the properties.
+     * @since 9.39

Review Comment:
   ```suggestion
        * @since 9.40
   ```



##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/spi/indexing/ErrorsCache.java:
##########
@@ -74,12 +75,46 @@ public static Collection<? extends URL> 
getAllFilesWithRecord(URL root) throws I
         return 
Collections.unmodifiableCollection(TaskCache.getDefault().getAllFilesWithRecord(root));
     }
 
-    /**Getter for properties of the given error description.
+    /**Return all errors or warnings for the given file
+     *
+     * @param file file for which the errors are being retrieved
+     * @param convertor constructor of {@code T} instances from error 
description properties
+     * @return errors or warnings
+     * @since 9.39

Review Comment:
   ```suggestion
        * @since 9.40
   ```



##########
ide/parsing.indexing/src/org/netbeans/modules/parsing/spi/indexing/ErrorsCache.java:
##########
@@ -74,12 +75,46 @@ public static Collection<? extends URL> 
getAllFilesWithRecord(URL root) throws I
         return 
Collections.unmodifiableCollection(TaskCache.getDefault().getAllFilesWithRecord(root));
     }
 
-    /**Getter for properties of the given error description.
+    /**Return all errors or warnings for the given file
+     *
+     * @param file file for which the errors are being retrieved
+     * @param convertor constructor of {@code T} instances from error 
description properties
+     * @return errors or warnings
+     * @since 9.39
+     */
+    public static <T> List<T> getErrors(FileObject file, ReverseConvertor<T> 
convertor) throws IOException {
+        return 
Collections.unmodifiableList(TaskCache.getDefault().getErrors(file, convertor));
+    }
+
+    /**Position in a text expressed as 1-based line and character offset.
+     * @since 9.39
+     */
+    public record Position(int line, int column) {}
+
+    /**Range in a text expressed as (1-based) start and end positions.
+     * @since 9.39

Review Comment:
   ```suggestion
        * @since 9.40
   ```



-- 
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

Reply via email to