API: problems
Source:
platform/problems.ts
Provides a wrapper for the platform's ProblemsFacade to manage system issues, including saving new problems, fetching existing ones, and updating their status.
Usage
import { Problems } from "sdk/platform";
import { response } from "sdk/http";
problems.save("/my-project/my-file", Problems.ACTIVE, "line: 4", "row: 10", "", "Some problem / at line 4", "Expected end of line ;", "ProblemsModule", "my-file.mjs", "my-file.mjs");
const myProblems = Problems.fetchAllProblems();
response.println(JSON.stringify(myProblems));
Problems.clearAllProblems();Classes
Problems
@class Problems
@description Static utility class for managing system problems via the ProblemsFacade.
Methods
save
save (location:string, type:string, line:string, column:string, cause:string, expected:string, category:string, module:string, source:string, program:string):voidSaves a new problem entry to the system's problem log.
@param {string} location The resource path or file location.
@param {string} type The severity or nature of the problem.
@param {string} line The line number.
@param {string} column The column number.
@param {string} cause The cause description.
@param {string} expected The expected state/value description.
@param {string} category The problem category.
@param {string} module The module/component name.
@param {string} source The original source content.
@param {string} program The program or file name.
findProblem
findProblem (id:number):ProblemFinds a specific problem by its unique ID.
Note: The underlying facade returns a JSON string which is parsed here.
@param {number} id The unique problem ID.
@returns {Problem} The found Problem object.
fetchAllProblems
fetchAllProblems ():Problem[]Fetches all recorded problems in the system.
Note: The underlying facade returns a JSON string which is parsed here.
@returns {Problem[]} An array of all Problem objects.
fetchProblemsBatch
fetchProblemsBatch (condition:string, limit:number):Problem[]Fetches a batch of problems based on a custom condition and limit.
@param {string} condition A SQL-like condition string (e.g., "CATEGORY='Syntax'").
@param {number} limit The maximum number of problems to retrieve.
@returns {Problem[]} An array of Problem objects matching the condition.
deleteProblem
deleteProblem (id:number):voidDeletes a problem record by its unique ID.
@param {number} id The unique problem ID to delete.
deleteAllByStatus
deleteAllByStatus (status:string):voidDeletes all problem records that currently have the specified status.
@param {string} status The status (e.g., Problems.SOLVED or Problems.IGNORED).
clearAllProblems
clearAllProblems ():voidClears (deletes) all problem records in the system, regardless of status.
updateStatus
updateStatus (id:number, status:string):voidUpdates the status of a single problem by its ID.
@param {number} id The unique problem ID.
@param {string} status The new status (e.g., Problems.SOLVED).
updateStatusMultiple
updateStatusMultiple (ids:number[], status:string):voidUpdates the status of multiple problems identified by an array of IDs.
@param {number[]} ids An array of unique problem IDs.
@param {string} status The new status to apply to all problems.