use of org.eclipse.wst.json.core.internal.parser.JSONLineTokenizer in project webtools.sourceediting by eclipse.
the class JSONSyntaxValidatorHelperTest method validate.
public IReporter validate(String json) {
IReporter reporter = new MockReporter();
JSONLineTokenizer tokenizer = new JSONLineTokenizer(new StringReader(json));
JSONSyntaxValidatorHelper.validate(tokenizer, reporter, null, PROVIDER);
return reporter;
}
use of org.eclipse.wst.json.core.internal.parser.JSONLineTokenizer in project webtools.sourceediting by eclipse.
the class JSONSyntaxValidator 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(JSONSyntaxValidator.this, message);
JSONLineTokenizer tokenizer = null;
try {
IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(file);
try {
if (model == null) {
tokenizer = new JSONLineTokenizer(new BufferedReader(new InputStreamReader(file.getContents(true), getCharset(file))));
} else {
tokenizer = new JSONLineTokenizer(new BufferedReader(new DocumentReader(model.getStructuredDocument())));
}
JSONSyntaxValidatorHelper.validate(tokenizer, reporter, this, this);
} finally {
if (model != null) {
model.releaseFromRead();
model = null;
}
}
} catch (UnsupportedEncodingException e) {
} catch (CoreException e) {
} catch (IOException e) {
}
}
Aggregations