Search in sources :

Example 1 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JsValidator method validate.

public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE || !shouldValidate((IFile) resource))
        return null;
    ValidationResult result = new ValidationResult();
    IReporter reporter = result.getReporter(monitor);
    IFile file = (IFile) resource;
    validateFile(file, reporter);
    result.setDependsOn(createDependencies(file));
    return result;
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) IFile(org.eclipse.core.resources.IFile) ValidationResult(org.eclipse.wst.validation.ValidationResult)

Example 2 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSONSyntaxValidatorHelperTest method missingEndObjectAndBadObjectKey.

@Test
@Ignore
public void missingEndObjectAndBadObjectKey() throws Exception {
    IReporter reporter = validate("{aa");
    List messages = reporter.getMessages();
    Assert.assertEquals(2, messages.size());
    LocalizedMessage msg = (LocalizedMessage) messages.get(0);
    assertMessage(msg, "Expected object key but found undefined", 1, 1);
    msg = (LocalizedMessage) messages.get(1);
    assertMessage(msg, "Missing end object", 1, 1);
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) List(java.util.List) LocalizedMessage(org.eclipse.wst.validation.internal.operations.LocalizedMessage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSONSyntaxValidatorHelperTest method badObjectKey.

@Test
@Ignore
public void badObjectKey() throws Exception {
    IReporter reporter = validate("{aa}");
    List messages = reporter.getMessages();
    Assert.assertEquals(1, messages.size());
    LocalizedMessage msg = (LocalizedMessage) messages.get(0);
    assertMessage(msg, "Expected object key but found undefined", 1, 1);
// msg = (LocalizedMessage) messages.get(1);
// assertMessage(msg, "Unexpected token", 1, 1);
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) List(java.util.List) LocalizedMessage(org.eclipse.wst.validation.internal.operations.LocalizedMessage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSONSyntaxValidatorHelperTest method noErrorsWithArray.

@Test
public void noErrorsWithArray() throws Exception {
    IReporter reporter = validate("[]");
    List messages = reporter.getMessages();
    Assert.assertEquals(0, messages.size());
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) List(java.util.List) Test(org.junit.Test)

Example 5 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSONSyntaxValidatorHelperTest method unexpectedColonInArray.

@Test
public void unexpectedColonInArray() throws Exception {
    IReporter reporter = validate("[\"a\":]");
    List messages = reporter.getMessages();
    Assert.assertEquals(1, messages.size());
    LocalizedMessage msg = (LocalizedMessage) messages.get(0);
    assertMessage(msg, "Unexpected token", 1, 1);
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) List(java.util.List) LocalizedMessage(org.eclipse.wst.validation.internal.operations.LocalizedMessage) Test(org.junit.Test)

Aggregations

IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)43 IFile (org.eclipse.core.resources.IFile)17 Path (org.eclipse.core.runtime.Path)15 List (java.util.List)11 JSPJavaValidator (org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)10 ValidationResult (org.eclipse.wst.validation.ValidationResult)9 Test (org.junit.Test)8 IProject (org.eclipse.core.resources.IProject)7 IPath (org.eclipse.core.runtime.IPath)7 JSPValidator (org.eclipse.jst.jsp.core.internal.validation.JSPValidator)7 LocalizedMessage (org.eclipse.wst.validation.internal.operations.LocalizedMessage)6 CoreException (org.eclipse.core.runtime.CoreException)5 ReporterForTest (org.eclipse.jst.jsp.core.tests.validation.ReporterForTest)5 ValidationContextForTest (org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest)5 IOException (java.io.IOException)4 JSPActionValidator (org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)4 JSPDirectiveValidator (org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator)4 IMessage (org.eclipse.wst.validation.internal.provisional.core.IMessage)4 Iterator (java.util.Iterator)3 JSPContentValidator (org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)3