Search in sources :

Example 1 with Location

use of nu.validator.source.Location in project validator by validator.

the class MessageEmitterAdapter method messageWithExact.

private void messageWithExact(MessageType type, Exception message, String systemId, int oneBasedLine, int oneBasedColumn, int[] start) throws SAXException {
    if (start != null && !sourceCode.getIsCss()) {
        oneBasedColumn = oneBasedColumn + start[2];
    }
    systemId = batchMode ? systemId : null;
    startMessage(type, scrub(shortenDataUri(systemId)), oneBasedLine, oneBasedColumn, oneBasedLine, oneBasedColumn, true);
    messageText(message);
    Location location = sourceCode.newLocatorLocation(oneBasedLine, oneBasedColumn);
    if (sourceCode.isWithinKnownSource(location)) {
        SourceHandler sourceHandler = emitter.startSource();
        if (sourceHandler != null) {
            sourceCode.exactError(location, sourceHandler);
        }
        emitter.endSource();
    } else {
        sourceCode.rememberExactError(location);
    }
    elaboration(message);
    endMessage();
}
Also used : SourceHandler(nu.validator.source.SourceHandler) Location(nu.validator.source.Location)

Example 2 with Location

use of nu.validator.source.Location in project validator by validator.

the class MessageEmitterAdapter method messageWithRange.

private void messageWithRange(MessageType type, Exception message, String systemId, int oneBasedLine, int oneBasedColumn, int[] start) throws SAXException {
    if (start != null && !sourceCode.getIsCss()) {
        oneBasedColumn = oneBasedColumn + start[2];
    }
    systemId = batchMode ? systemId : null;
    Location rangeLast = sourceCode.newLocatorLocation(oneBasedLine, oneBasedColumn);
    if (!sourceCode.isWithinKnownSource(rangeLast)) {
        messageWithoutExtract(type, message, null, oneBasedLine, oneBasedColumn);
        return;
    }
    Location rangeStart = sourceCode.rangeStartForRangeLast(rangeLast);
    if (start != null) {
        if (sourceCode.getIsCss()) {
            rangeStart = sourceCode.newLocatorLocation(start[0], start[1]);
        } else {
            rangeStart = sourceCode.newLocatorLocation(start[0], start[1] + start[2]);
        }
    }
    startMessage(type, scrub(shortenDataUri(systemId)), rangeStart.getLine() + 1, rangeStart.getColumn() + 1, oneBasedLine, oneBasedColumn, false);
    messageText(message);
    SourceHandler sourceHandler = emitter.startSource();
    if (sourceHandler != null) {
        if (start != null) {
            sourceCode.addLocatorLocation(rangeStart.getLine() + 1, rangeStart.getColumn());
        }
        sourceCode.rangeEndError(rangeStart, rangeLast, sourceHandler);
    }
    emitter.endSource();
    elaboration(message);
    endMessage();
}
Also used : SourceHandler(nu.validator.source.SourceHandler) Location(nu.validator.source.Location)

Example 3 with Location

use of nu.validator.source.Location in project validator by validator.

the class MessageEmitterAdapter method emitImageList.

private void emitImageList(ImageReviewHandler imageReviewHandler, List<Image> list, char[] heading, DocumentFragment instruction, boolean hasAlt) throws SAXException {
    if (!list.isEmpty()) {
        imageReviewHandler.startImageGroup(heading, instruction, hasAlt);
        for (Image image : list) {
            String systemId = image.getSystemId();
            int oneBasedLine = image.getLineNumber();
            int oneBasedColumn = image.getColumnNumber();
            Location rangeLast = sourceCode.newLocatorLocation(oneBasedLine, oneBasedColumn);
            if (sourceCode.isWithinKnownSource(rangeLast)) {
                Location rangeStart = sourceCode.rangeStartForRangeLast(rangeLast);
                imageReviewHandler.image(image, hasAlt, systemId, rangeStart.getLine() + 1, rangeStart.getColumn() + 1, oneBasedLine, oneBasedColumn);
            } else {
                imageReviewHandler.image(image, hasAlt, systemId, -1, -1, -1, -1);
            }
        }
        imageReviewHandler.endImageGroup();
    }
}
Also used : Image(nu.validator.servlet.imagereview.Image) Location(nu.validator.source.Location)

Aggregations

Location (nu.validator.source.Location)3 SourceHandler (nu.validator.source.SourceHandler)2 Image (nu.validator.servlet.imagereview.Image)1