Search in sources :

Example 1 with XMLLineTokenizer

use of org.eclipse.wst.xml.core.internal.parser.XMLLineTokenizer in project webtools.sourceediting by eclipse.

the class StreamingMarkupValidator method validateFile.

/**
 * Validates the given file. It will stream the contents of the file without creating a model for the file; it will only
 * use existing
 * @param file the file to validate
 * @param reporter the reporter
 */
private void validateFile(IFile file, IReporter reporter) {
    Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, file.getFullPath().toString().substring(1));
    reporter.displaySubtask(StreamingMarkupValidator.this, message);
    XMLLineTokenizer tokenizer = null;
    try {
        tagStack = new Stack();
        model = StructuredModelManager.getModelManager().getExistingModelForRead(file);
        try {
            if (model == null) {
                tokenizer = new XMLLineTokenizer(new BufferedReader(new InputStreamReader(file.getContents(true), getCharset(file))));
            } else {
                tokenizer = new XMLLineTokenizer(new BufferedReader(new DocumentReader(model.getStructuredDocument())));
            }
            checkTokens(tokenizer, reporter);
        } finally {
            if (model != null) {
                model.releaseFromRead();
                model = null;
            }
        }
    } catch (UnsupportedEncodingException e) {
    } catch (CoreException e) {
    } catch (IOException e) {
    }
}
Also used : IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) LocalizedMessage(org.eclipse.wst.validation.internal.operations.LocalizedMessage) Message(org.eclipse.wst.validation.internal.core.Message) InputStreamReader(java.io.InputStreamReader) CoreException(org.eclipse.core.runtime.CoreException) BufferedReader(java.io.BufferedReader) UnsupportedEncodingException(java.io.UnsupportedEncodingException) XMLLineTokenizer(org.eclipse.wst.xml.core.internal.parser.XMLLineTokenizer) DocumentReader(org.eclipse.wst.sse.core.internal.document.DocumentReader) IOException(java.io.IOException) LocalizedMessage(org.eclipse.wst.validation.internal.operations.LocalizedMessage) Stack(java.util.Stack)

Aggregations

BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Stack (java.util.Stack)1 CoreException (org.eclipse.core.runtime.CoreException)1 DocumentReader (org.eclipse.wst.sse.core.internal.document.DocumentReader)1 Message (org.eclipse.wst.validation.internal.core.Message)1 LocalizedMessage (org.eclipse.wst.validation.internal.operations.LocalizedMessage)1 IMessage (org.eclipse.wst.validation.internal.provisional.core.IMessage)1 XMLLineTokenizer (org.eclipse.wst.xml.core.internal.parser.XMLLineTokenizer)1