private ValProperty getValProperty(IResource resource, ValType valType, int configNumber) { ValProperty vp = null; try { if (valType == ValType.Build) vp = (ValProperty) resource.getSessionProperty(StatusBuild); else if (valType == ValType.Manual) vp = (ValProperty) resource.getSessionProperty(StatusManual); } catch (CoreException e) { // don't care about this one } if (vp == null) return null; if (vp.getConfigNumber() != _configNumber.get()) return null; return vp; }
/** * Accept a visitor for all the validators that are enabled for the given project, resource, and * validation mode. * * @param valType the type of validation request */ public void accept( IValidatorVisitor visitor, IProject project, IResource resource, ValType valType, ValOperation operation, IProgressMonitor monitor) { if (isDisabled(project)) return; Map<String, IValidatorGroupListener[]> groupListeners = new HashMap<String, IValidatorGroupListener[]>(); ValProperty vp = getValProperty(resource, valType, _configNumber.get()); if (vp != null) { BitSet bs = vp.getConfigSet(); for (Validator val : getValidators(project)) { if (!monitor.isCanceled()) { if (!bs.get(_idManager.getIndex(val.getId()))) continue; if (operation.isSuspended(val, project)) continue; Validator.V2 v2 = val.asV2Validator(); if (v2 != null) { notifyGroupListenersStarting( resource, operation.getState(), monitor, groupListeners, v2); } try { visitor.visit(val, project, valType, operation, monitor); } catch (Exception e) { ValidationPlugin.getPlugin().handleException(e); } } } notifyGroupFinishing(resource, operation.getState(), monitor, groupListeners); return; } vp = new ValProperty(); vp.setConfigNumber(_configNumber.get()); ContentTypeWrapper ctw = new ContentTypeWrapper(); for (Validator val : getValidators(project)) { if (!monitor.isCanceled()) { if (!ValidatorProjectManager.get().shouldValidate(val, project, valType)) continue; if (Friend.shouldValidate(val, resource, valType, ctw)) { vp.getConfigSet().set(_idManager.getIndex(val.getId())); // we do the suspend check after figuring out if it needs to be validated, because we save // this information for the session. if (operation.isSuspended(val, project)) continue; Validator.V2 v2 = val.asV2Validator(); if (v2 != null) { notifyGroupListenersStarting( resource, operation.getState(), monitor, groupListeners, v2); } try { visitor.visit(val, project, valType, operation, monitor); } catch (Exception e) { ValidationPlugin.getPlugin().handleException(e); } } } } notifyGroupFinishing(resource, operation.getState(), monitor, groupListeners); putValProperty(vp, resource, valType); }