Class ConsoleErrorLocation
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.ConsoleErrorLocation
-
public final class ConsoleErrorLocation extends java.lang.Object
Represents information about an error that has been printed as part of a stack trace in the script output window. Contains both an identifier that may be used to locate the original source file, and an optional line number at which the error was located. Instances of this class are not usually created directly, but are instead obtained from the script console.
-
-
Constructor Summary
Constructors Constructor Description ConsoleErrorLocation(java.lang.String identifier, int lineNumber)
Creates a new instance that describes an error with the specified source identifier and line number.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getEvalLineNumber()
Returns the line number (starting from 1) of the error, within an evaluated string or 0 if the line number is unknown or was not within aneval
function.java.lang.String
getIdentifier()
Returns the full file identifier for the error.int
getLineNumber()
Returns the line number (starting from 1) of the error, or 0 if the line number is unknown.java.lang.String
getShortIdentifier()
Returns a shortened version of the identifier.void
open()
Attempts to open the error location in an editor.
-
-
-
Constructor Detail
-
ConsoleErrorLocation
public ConsoleErrorLocation(java.lang.String identifier, int lineNumber)
Creates a new instance that describes an error with the specified source identifier and line number.- Parameters:
identifier
- the identifier that describes the location of the errorlineNumber
- the line number, starting from 1, or 0 if the line number is unknown
-
-
Method Detail
-
getIdentifier
public java.lang.String getIdentifier()
Returns the full file identifier for the error. For a script run in the Quickscript window, this is "Quickscript". For a script run from a plug-in, this may be a "res:" URL or a "file:" URL. For a script run in the context of an open project, this will be a "project:" URL.- Returns:
- a string that identifies the file where the error took place
-
getShortIdentifier
public java.lang.String getShortIdentifier()
Returns a shortened version of the identifier. If the identifier represents a URL or local file, then this returns the last name on the path (the file name). Otherwise, the full identifier is returned.- Returns:
- the file name portion of the path, or the full identifier
-
getLineNumber
public int getLineNumber()
Returns the line number (starting from 1) of the error, or 0 if the line number is unknown.- Returns:
- the line number of the error
-
getEvalLineNumber
public int getEvalLineNumber()
Returns the line number (starting from 1) of the error, within an evaluated string or 0 if the line number is unknown or was not within aneval
function. When an error occurs during the evaluation of a string, this returns the line number within that string whilegetLineNumber()
returns the line number of theeval()
call.- Returns:
- the line number of the error within the evaluated code
-
open
public void open()
Attempts to open the error location in an editor. If the location represents a script file, the script is opened in a source editor (if it can be located) and the caret moved to the relevant line. If the error occurred in the Quickscript window, that is made visible (if necessary) and the caret moved to the relevant line. If the identifier refers to a plug-in resource, then the file may be opened in read-only mode unless exactly one equivalent file can be located in an appropriate location in the open project. If the identifier refers to a Java class, then it may be opened in a source editor window if a relevant source file can be located. If the file cannot be located or it cannot be opened for some other reason, then error feedback (typically a beep) will be provided and no editor will be opened.
-
-