private boolean init(IValidationContext helper, IReporter reporter, boolean test) {
   if (!test && disabled) {
     return false;
   }
   if (context == null) {
     synchronized (reporters) {
       reporters.add(document);
     }
     String[] uris = helper.getURIs();
     if (uris.length == 0) {
       return false;
     }
     IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
     file = root.getFile(new Path(uris[0]));
     if (!file.isAccessible()) {
       return false;
     }
     context = new EditorValidationContext(file.getProject(), document);
     if (context.getValidators().isEmpty()) {
       return false;
     }
     rootProjects = new HashMap<IValidator, IProject>();
     for (IValidator validator : context.getValidators()) {
       Map<IProject, IValidatingProjectSet> projectTree =
           context.getValidatingProjectTree(validator).getBrunches();
       if (!projectTree.isEmpty()) {
         IProject rootProject = projectTree.keySet().iterator().next();
         rootProjects.put(validator, rootProject);
       }
     }
   }
   return true;
 }
 private void validate(
     Set<? extends IAsYouTypeValidator> validators,
     Collection<IRegion> dirtyRegions,
     IValidationContext helper,
     IReporter reporter) {
   count++;
   for (IAsYouTypeValidator validator : validators) {
     try {
       IProject rootProject = rootProjects.get(validator);
       IValidatingProjectSet projectBrunch =
           context.getValidatingProjectTree(validator).getBrunches().get(rootProject);
       if (projectBrunch != null) {
         validator.validate(
             this,
             rootProject,
             dirtyRegions,
             helper,
             reporter,
             context,
             projectBrunch.getRootContext(),
             file);
       }
     } catch (Exception e) {
       // We need to catch exceptions and wrap them in KBValidationException to let JUnit tests
       // catch validation exceptions reported to eclipse log.
       CommonPlugin.getDefault().logError(new JBTValidationException(e.getMessage(), e));
     }
   }
 }
 protected void validateJavaElement(
     Collection<IRegion> dirtyRegions,
     IValidationContext helper,
     IReporter reporter,
     boolean test) {
   if (shouldValidate(helper, reporter, test)) {
     validate(context.getJavaElementValidators(), dirtyRegions, helper, reporter);
   }
 }