Class JavaProblem

All Implemented Interfaces:
IProblem
Direct Known Subclasses:
AnnotationProblem, TypeProblem

public abstract class JavaProblem extends CategorizedProblem
Abstract class for errors produced in the Annotation and Type/Method parsers.
Author:
Mikael Andersson, Christopher Mindus
  • Field Details

    • CAT_SYNTAX

      public static final int CAT_SYNTAX
      Category for problems related to syntax of IIZI annotations.
      See Also:
    • CAT_REF

      public static final int CAT_REF
      Category for problems related to reference problems in IIZI annotations.
      See Also:
    • CAT_TYPE

      public static final int CAT_TYPE
      Category for problems related to class type referenced by IIZI annotations.
      See Also:
    • CAT_FIELD_VARIABLE

      public static final int CAT_FIELD_VARIABLE
      Category for problems related to field or variables referenced by IIZI annotations.
      See Also:
    • CAT_OPTIONAL_FIELD_VARIABLE

      public static final int CAT_OPTIONAL_FIELD_VARIABLE
      Optional annotated cast to field or variables referenced by IIZI annotations.
      See Also:
    • EMPTY_KEYS

      public static final String[] EMPTY_KEYS
    • EMPTY_VALUES

      public static final Object[] EMPTY_VALUES
    • UNASSIGNED

      public static final int UNASSIGNED
      See Also:
    • category

      protected final int category
    • problem

      protected final int problem
  • Constructor Details

    • JavaProblem

      public JavaProblem(int category, int problem, String message, int start, int end, int line)
      Constructor without quick fixes.
      Parameters:
      category - The problem category
      problem - The problem ID
      message - The message associated with the problem
      start - The problem location start
      end - The problem location end
      line - The (text file) line number
    • JavaProblem

      public JavaProblem(int category, int problem, String message, int start, int end, int line, String... fixIds)
      Constructor with quick fix IDs.
      Parameters:
      category - The problem category
      problem - The problem ID
      message - The message associated with the problem
      start - The problem location start
      end - The problem location end
      line - The (text file) line number
      fixIds - The quick fix IDs associated with the problem
    • JavaProblem

      public JavaProblem(int category, int problem, String message, int start, int end, int line, IQuickFix... fixes)
      Constructor with IQuickFix.
      Parameters:
      category - The problem category
      problem - The problem ID
      message - The message associated with the problem
      start - The problem location start
      end - The problem location end
      line - The (text file) line number
      fixes - The quick fixes associated with the problem
  • Method Details

    • equals

      public boolean equals(Object o)
      Checks for equality.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Gets the hash code of this instance.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • getCategoryID

      public int getCategoryID()
      Returns the integer identifying the category of this problem. Categories, like problem IDs are defined in the context of some marker type. Custom implementations of CategorizedProblem may choose arbitrary values for problem/category IDs, as long as they are associated with a different marker type. Standard Java problem markers (i.e. marker type is "org.eclipse.jdt.core.problem") carry an attribute "categoryId" persisting the originating problem category ID as defined by this method).
      Specified by:
      getCategoryID in class CategorizedProblem
      Returns:
      id - an integer identifying the category of this problem
    • getMarkerType

      public abstract String getMarkerType()
      Returns the marker type associated to this problem, if it gets persisted into a marker by the JavaBuilder Standard Java problems are associated to marker type "org.eclipse.jdt.core.problem"). Note: problem markers are expected to extend "org.eclipse.core.resources.problemmarker" marker type.
      Specified by:
      getMarkerType in class CategorizedProblem
      Returns:
      The type of the marker which would be associated to the problem.
    • addFixId

      public void addFixId(String... fixIds)
      Add an array of quick fix IDs. Create the ArrayList if necessary.
      Parameters:
      fixIds - Array of IDs.
    • addFixId

      public void addFixId(IQuickFix... fixes)
      Add an array of quick fixes. Create the ArrayList if necessary.
      Parameters:
      fixes - Array of IQuickFix
    • getExtraMarkerAttributeNames

      public String[] getExtraMarkerAttributeNames()
      Returns the names of the extra marker attributes associated to this problem when persisted into a marker by the JavaBuilder. Extra attributes are only optional, and are allowing client customization of generated markers. By default, no EXTRA attributes is persisted, and a categorized problem only persists the following attributes:The names must be eligible for marker creation, as defined by IMarker#setAttributes(String[], Object[]), and there must be as many names as values according to getExtraMarkerAttributeValues(). Note that extra marker attributes will be inserted after default ones (as described in CategorizedProblem.getMarkerType(), and thus could be used to override defaults.
      Overrides:
      getExtraMarkerAttributeNames in class CategorizedProblem
      Returns:
      the names of the corresponding marker attributes
    • getExtraMarkerAttributeValues

      public Object[] getExtraMarkerAttributeValues()
      Returns the respective values for the extra marker attributes associated to this problem when persisted into a marker by the JavaBuilder. Each value must correspond to a matching attribute name, as defined by getExtraMarkerAttributeNames().

      The values must be eligible for marker creation, as defined by IMarker#setAttributes(String[], Object[]).

      Overrides:
      getExtraMarkerAttributeValues in class CategorizedProblem
      Returns:
      the values of the corresponding extra marker attributes
    • getArguments

      public String[] getArguments()
      Answer back the original arguments recorded into the problem.
      Returns:
      the original arguments recorded into the problem
    • getID

      public int getID()
      Returns the problem id
      Returns:
      the problem id
    • getMessage

      public String getMessage()
      Answer a localized, human-readable message string which describes the problem.
      Returns:
      a localized, human-readable message string which describes the problem
    • setOriginatingFileName

      public void setOriginatingFileName(char[] name)
      Set the name of the file where the problem was found.
      Parameters:
      name - The file name
    • setOriginatingFileName

      public void setOriginatingFileName(String name)
      Set the name of the file where the problem was found.
      Parameters:
      name - The file name
    • getOriginatingFileName

      public char[] getOriginatingFileName()
      Answer the file name in which the problem was found.
      Returns:
      the file name in which the problem was found
    • setSourceEnd

      public void setSourceEnd(int sourceEnd)
      Set the end position of the problem (inclusive), or -1 if unknown. Used for shifting problem positions.
      Parameters:
      sourceEnd - the given end position
    • setSourceLineNumber

      public void setSourceLineNumber(int lineNumber)
      Set the line number in source where the problem begins.
      Parameters:
      lineNumber - the given line number
    • setSourceStart

      public void setSourceStart(int sourceStart)
      Set the start position of the problem (inclusive), or -1 if unknown. Used for shifting problem positions.
      Parameters:
      sourceStart - the given start position
    • getSourceEnd

      public int getSourceEnd()
      Answer the end position of the problem (inclusive), or -1 if unknown.
      Returns:
      the end position of the problem (inclusive), or -1 if unknown
    • getSourceLineNumber

      public int getSourceLineNumber()
      Answer the line number in source where the problem begins.
      Returns:
      the line number in source where the problem begins
    • getSourceStart

      public int getSourceStart()
      Answer the start position of the problem (inclusive), or -1 if unknown.
      Returns:
      the start position of the problem (inclusive), or -1 if unknown