Class PropMarker

java.lang.Object
com.iizigo.prop.PropMarker
All Implemented Interfaces:
Runnable

public class PropMarker extends Object implements Runnable
The property marker is a class that holds error/warning/information about a property that is stored in a file.
Author:
Christopher Mindus
  • Field Details

    • MARKER_ID_PROPERTY

      public static final String MARKER_ID_PROPERTY
      The Property problem marker ID.
      See Also:
    • MARKER_ATTRIBUTE_PROPERTY_REFERENCE

      public static final String MARKER_ATTRIBUTE_PROPERTY_REFERENCE
      Attribute in Property problem marker for Property Reference.
      See Also:
    • MARKER_ATTRIBUTE_CHILD_NAME

      public static final String MARKER_ATTRIBUTE_CHILD_NAME
      Attribute in Property problem marker for Property Reference to a child name.
      See Also:
    • MARKER_ATTRIBUTE_PROPERTY_INDEX

      public static final String MARKER_ATTRIBUTE_PROPERTY_INDEX
      Attribute in Property problem marker for Property Reference with an indexed multi-property, assigns an Integer value (equal or greater than zero), otherwise not set.
      See Also:
    • markerID

      public final String markerID
      The Eclipse-registered marker ID.
    • severity

      public final int severity
      Marker severity: IMarker.SEVERITY_ERROR=2, IMarker.SEVERITY_WARNING=1 or IMarker.SEVERITY_INFO=0.
    • message

      public final String message
      The message.
    • location

      public final String location
      The location.
    • reference

      public final String reference
      Property reference of the error, null when not a property error.
    • index

      public final int index
      Index for property reference error, -1 when not set.
    • start

      public final int start
      The character start position of the marker, -1 when not position based.
    • length

      public final int length
      The character length of the marker, -1 when not position based.
    • quickFixIDs

      public final String[] quickFixIDs
      Array of registered quick-fixes for the problem (all must be registered in QuickFixer), never null.
    • childError

      public final String childError
      The name of child property in error.
  • Constructor Details

    • PropMarker

      public PropMarker(String markerID, boolean isError, String message, String location, String... quickFixIDs)
      Creates a new property marker for a property, typically used for general errors.
      Parameters:
      markerID - The Eclipse-registered marker ID.
      isError - Flag for error, false = warning.
      message - The message.
      location - The location.
      quickFixIDs - List of registered quick-fixes for the problem (all must be registered in QuickFixer)-
    • PropMarker

      public PropMarker(String markerID, boolean isError, String message, int start, int length, String... quickFixIDs)
      Creates a new property marker for a property, specialized to text file position, e.g for Java source file.
      Parameters:
      markerID - The Eclipse-registered marker ID.
      isError - Flag for error, false = warning.
      message - The message.
      start - The (character) start location in the file.
      length - The length of the marker.
      quickFixIDs - List of registered quick-fixes for the problem (all must be registered in QuickFixer)-
    • PropMarker

      public PropMarker(PropErrorItemOrigin errorItemOrigin)
      Creates a new property marker for a property error item.
      Parameters:
      errorItemOrigin - The error item including origin.
  • Method Details

    • getProperty

      public static GProp<?> getProperty(IMarker marker)
      Gets the property from the reference in the marker.
    • registerMarker

      public static void registerMarker(String markerID, boolean isPersistent)
      Registers a marker for a plug-in.
    • deleteMarkers

      public static void deleteMarkers(IResource resource, String markerID) throws CoreException
      Removes all markers of the IIZI Module type and any file errors associated with an attached property.
      Parameters:
      resource - The resource.
      markerID - The marker ID to remove or null for all.
      Throws:
      CoreException - If a marker cannot be deleted.
    • deleteAllMarkers

      public static void deleteAllMarkers(IResource resource)
      Removes all markers for a resource directly or in a job if it fails.
      Parameters:
      resource - The resource.
    • deleteAllMarkers

      public static void deleteAllMarkers(IResource resource, String type, boolean includeSubtypes, int depth, Runnable completed)
      Removes all markers for a resource directly or in a job if it fails.
      Parameters:
      resource - The resource.
      type - The type of marker to consider, or null to indicate all types.
      includeSubtypes - Whether or not to consider sub-types of the given type.
      depth - How far to recurse (see IResource.DEPTH_*).
      completed - A runnable that is called when it completes, also when there was no marker to delete, null for none.
    • createMarker

      public boolean createMarker(IResource resource)
      Creates the marker.

      This marker's monitor is held only while its own fields are read or written, and never while the workspace is asked to create, change or delete a marker (CC-FIX-DESIGNER-MARKER-DEADLOCK). IResource.createMarker, IMarker.setAttributes and IMarker.delete wait for the workspace lock, and the thread that holds that lock runs the resource change listeners before it gives the lock back: a listener that disposes of a marker (DesignerProp.removeMarkers, from ModuleModel's visit of the changed files) then waited for the monitor of the thread that waited for its lock, and iiziGo stopped (the SWT thread creating a marker while a job saved the Module settings: the gate of r22226). What the monitor gave is kept by created(IMarker): a marker whose creation ends after dispose(IResource) is deleted again. A property marker is created once, and never after its dispose.

      Returns:
      false if the marker cannot be created due to resource inaccessibility, true otherwise.
    • createMarkerLater

      public boolean createMarkerLater(IResource resource)
      Creates the marker as createMarker(IResource) does, but in the marker job and never on the calling thread.

      For a caller that must not wait for the workspace (CC-FIX-DESIGNER-LOAD-MARKERS): IResource.createMarker takes the workspace lock. A project that is opened is loaded inside the notification of its opening, so the thread that opened it holds that lock while it waits for the threads that load the project's files (ModuleModel.loadProject); a load thread that created a marker itself would wait for that lock forever, and iiziGo with it. The job creates the marker once the workspace is free; a marker disposed of before that is not created.

      Parameters:
      resource - The resource.
      Returns:
      false if the marker cannot be created due to resource inaccessibility, true otherwise.
    • run

      public void run()
      Performs the adding of the marker in a job.
      Specified by:
      run in interface Runnable
    • dispose

      public void dispose(IResource resource)
      Disposes of a marker.

      The Eclipse marker is deleted after this marker's monitor, never under it (createMarker(IResource) says why).

      Parameters:
      resource - The resource, or null for no marker removal on the resource.
    • toString

      public String toString()
      The string representation.
      Overrides:
      toString in class Object