public IStatus validateInJob()

in eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/internal/validation/IgnoreMissingGrammarXmlValidator.java [98:148]


    public IStatus validateInJob(IValidationContext context, IReporter reporter) throws ValidationException {
        NestedValidatorContext nestedcontext = new NestedValidatorContext();
        setupValidation(nestedcontext);
        String[] fileURIs = context.getURIs();
        if (fileURIs != null && fileURIs.length > 0) {
            int numFiles = fileURIs.length;
            for (int i = 0; i < numFiles && !reporter.isCancelled(); i++) {
                String fileName = fileURIs[i];
                if (fileName != null) {
                    Object[] parms = { fileName };

                    IFile file = (IFile) context.loadModel(GET_FILE, parms);
                    if (file != null && shouldValidate(file)) {
                        nestedcontext.setProject(file.getProject());
                        // The helper may not have a file stored in it but may have an InputStream if being
                        // called from a source other than the validation framework such as an editor.
                        if (context.loadModel(GET_INPUTSTREAM) instanceof InputStream) {
                            doValidate(file, (InputStream) context.loadModel(GET_INPUTSTREAM), null, reporter, nestedcontext); // do we need
                                                                                                                             // the
                                                                                                                             // fileName?
                                                                                                                             // what is int
                                                                                                                             // ruleGroup?
                        } else {
                            doValidate(file, null, null, reporter, nestedcontext);
                        }
                    }
                }
            }
        }
        // TODO: Is this needed? Shouldn't the framework pass the complete list?
        // Should I know that I'm validating a project as opposed to files?
        else {
            Object[] parms = { getValidatorID() };
            Collection files = (Collection) context.loadModel(GET_PROJECT_FILES, parms);
            // files can be null if they're outside of the workspace
            if (files != null) {
                Iterator iter = files.iterator();
                while (iter.hasNext() && !reporter.isCancelled()) {
                    IFile file = (IFile) iter.next();
                    if (shouldValidate(file)) {
                        doValidate(file, null, null, reporter, nestedcontext);
                    }
                }
            }
        }

        teardownValidation(nestedcontext);
        if (reporter.isCancelled())
            return Status.CANCEL_STATUS;
        return Status.OK_STATUS;
    }