@Override public ValidationResult validate(IResource resource,int kind,ValidationState state,IProgressMonitor monitor){
  ValidationResult result=new ValidationResult();
  IIDETypeScriptProject tsProject=(IIDETypeScriptProject)state.get(TYPESCRIPT_VALIDATOR_CONTEXT);
  if (tsProject != null && TypeScriptResourceUtil.canConsumeTsserver(resource) && tsProject.isInScope(resource)) {
    IReporter reporter=result.getReporter(monitor);
    IIDETypeScriptFile tsFile=null;
    boolean wasOpened=false;
    try {
      tsFile=tsProject.getOpenedFile(resource);
      if (tsFile != null) {
        wasOpened=true;
      }
 else {
        try {
          tsFile=tsProject.openFile(resource,null);
        }
 catch (        TypeScriptException e) {
          Trace.trace(Trace.SEVERE,"Error while opening file for validation",e);
        }
      }
      if (tsFile != null) {
        TypeScriptValidationHelper.validate(tsFile,reporter,this);
      }
    }
  finally {
      if (!wasOpened && tsFile != null) {
        try {
          tsFile.close();
        }
 catch (        TypeScriptException e) {
          Trace.trace(Trace.SEVERE,"Error while closing file for validation",e);
        }
      }
    }
  }
  return result;
}

@ Override public ValidationResult validate ( IResource resource , int kind , ValidationState state , IProgressMonitor monitor ) { ValidationResult result = new ValidationResult ( ) ; IIDETypeScriptProject tsProject = ( IIDETypeScriptProject ) state . get ( TYPESCRIPT_VALIDATOR_CONTEXT ) ; if ( tsProject != null && TypeScriptResourceUtil . canConsumeTsserver ( resource ) && tsProject . isInScope ( resource ) ) { IReporter reporter = result . getReporter ( monitor ) ; IIDETypeScriptFile tsFile = null ; boolean wasOpened = false ; try { tsFile = tsProject . getOpenedFile ( resource ) ; if ( tsFile != null ) { wasOpened = true ; } else { try { tsFile = tsProject . openFile ( resource , null ) ; } catch ( TypeScriptException e ) { Trace . trace ( Trace . SEVERE , "Error while opening file for validation" , e ) ; } } if ( tsFile != null ) { TypeScriptValidationHelper . validate ( tsFile , reporter , this ) ; } } finally { if ( ! wasOpened && tsFile != null ) { try { tsFile . close ( ) ; } catch ( TypeScriptException e ) { Trace . trace ( Trace . SEVERE , "Error while closing file for validation" , e ) ; } } } } return result ; }
perform the validation using version 2 of the validation framework .
