Errors and warning markers are used to indicate if there are problems in the source files. These are used by the Eclipse compiler to indicate Java compile errors, but they are also used for non-Java errors. For example, text editors also show warnings when words are misspelled. A warning can be shown if the .minimark
file is empty and the title is missing.
There isn't a simple way of accessing the file's size in Eclipse, so one heuristic is that if the generated HTML file is less than about 100 bytes then there probably wasn't much to start with anyway.
MinimarkVisitor
class and go to the processResource
method.ByteArrayOutputStream baos = new ByteArrayOutputStream(); MinimarkTranslator.convert(new InputStreamReader(in), new OutputStreamWriter(baos)); ByteArrayInputStream contents = new ByteArrayInputStream( baos.toByteArray()); if (baos.size() < 100) { System.out.println("Minimark file is empty"); }
IMarker
object, created on the source resource, and with additional properties to set the type and location of the error:// System.out.println("Minimark file is empty"); IMarker marker = resource.createMarker(IMarker.PROBLEM); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); marker.setAttribute(IMarker.MESSAGE, "Minimark file is empty"); marker.setAttribute(IMarker.LINE_NUMBER, 1); marker.setAttribute(IMarker.CHAR_START, 0); marker.setAttribute(IMarker.CHAR_END, 0);
.minimark
file. When it is saved, an error will be reported in the Problems view. If it's not shown, it can be opened with Window | Show View | Other | General | Problems:A heuristic that detected when the input file was likely to be empty was used to generate a marker in the build view. When creating an empty file, the builder runs and the problem is generated in the problems view.
The marker also allows additional fields to be set if the location of the problem is known. These are optional fields but can be used to give a user more information as to the source of the problem. In the cases of a misspelled word, the CHAR_START
and CHAR_END
constants can be used to pinpoint the exact word on a line; in the cases of more general errors, the LINE_NUMBER
constant can be used to indicate the approximate location in the file.
Each time the file is changed; additional markers are created in the problems view. Even if content is added, the existing errors aren't removed. That will be fixed in the next section.
18.118.255.234