Class CategorizedProblem

java.lang.Object
org.aspectj.org.eclipse.jdt.core.compiler.CategorizedProblem
All Implemented Interfaces:
IProblem
Direct Known Subclasses:
DefaultProblem

public abstract class CategorizedProblem extends Object implements IProblem
Richer description of a Java problem, as detected by the compiler or some of the underlying technology reusing the compiler. With the introduction of org.aspectj.org.eclipse.jdt.core.compiler.CompilationParticipant, the simpler problem interface IProblem did not carry enough information to better separate and categorize Java problems. In order to minimize impact on existing API, Java problems are still passed around as IProblem, though actual implementations should explicitly extend CategorizedProblem. Participants can produce their own problem definitions, and given these are categorized problems, they can be better handled by clients (such as user interface).

A categorized problem provides access to:

  • its location (originating source file name, source position, line number)
  • its message description
  • predicates to check its severity (error, warning, or info)
  • its ID : a number identifying the very nature of this problem. All possible IDs for standard Java problems are listed as constants on IProblem.
  • its marker type : a string identifying the problem creator. It corresponds to the marker type chosen if this problem was to be persisted. Standard Java problems are associated to marker type "org.eclipse.jdt.core.problem").
  • its category ID : a number identifying the category this problem belongs to. All possible IDs for standard Java problem categories are listed in this class.

Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular their ID (attribute "id") is set to one of the IDs defined on this interface.

Note: Standard Java problems produced by Java default tooling will be subclasses of this class. Technically, most API methods dealing with problems are referring to IProblem for backward compatibility reason. It is intended that CategorizedProblem will be subclassed for custom problem implementation when participating in compilation operations, so as to allow participant to contribute their own marker types, and thus defining their own domain specific problem/category IDs.

Note: standard Java problems produced by Java default tooling will set the marker IMarker#SOURCE_ID attribute to JavaBuilder#SOURCE_ID; compiler participants may specify the IMarker#SOURCE_ID attribute of their markers by adding it to the extra marker attributes of the problems they generate; markers resulting from compiler participants' problems that do not have the IMarker#SOURCE_ID extra attribute set do not have the JavaBuilder#SOURCE_ID attribute set either.

Since:
3.2