/** * Validators can use project level settings (Project natures and facets) to determine if they are * applicable to the project or not. * * @param project The project that the configuration is based on. * @param useProject Specifies how to use the project preferences. This can be used to force the * project properties to be used. There is a case where the user has toggled the Enable * project specific settings checkbox in the dialog, but has not yet committed the changes. * This allows that setting to be passed through. * @return The validators that are configured to run on this project based on the project level * settings. These are the "live" validators, they are not copies. * @throws ProjectUnavailableError */ public Validator[] getValidatorsConfiguredForProject( IProject project, UseProjectPreferences useProject) throws ProjectUnavailableError { Map<String, Validator> v2Vals = getV2Validators(project, useProject); TreeSet<Validator> sorted = new TreeSet<Validator>(); sorted.addAll(v2Vals.values()); if (useProject == UseProjectPreferences.MustNotUse) { sorted.addAll(ExtensionValidators.instance().getV1Validators(project)); } else { try { ValidationConfiguration vc = ConfigurationManager.getManager().getProjectConfiguration(project); ValidatorMetaData[] vmds = vc.getValidators(); for (ValidatorMetaData vmd : vmds) { Validator v = Validator.create(vmd, vc, project); sorted.add(v); } } catch (InvocationTargetException e) { ValidationPlugin.getPlugin().handleException(e); } } List<Validator> list = new LinkedList<Validator>(); for (Validator v : sorted) { if (v.shouldValidateProject(project, false, false)) list.add(v); } Validator[] vals = new Validator[list.size()]; list.toArray(vals); return vals; }
/** * Answer all the validators for the given project. * * <p>Individual projects may override the global validation preference settings. If the project * has it's own settings, then those validators are returned via this method. * * <p>The following approach is used. For version 1 validators, the validator is only returned if * it is defined to operate on this project type. This is the way that the previous version of the * framework did it. For version 2 validators, they are all returned. * * @param project This may be null, in which case the global preferences are returned. * @return The validators in name sorted order. */ private Validator[] getValidatorsNotCached(IProject project) throws ProjectUnavailableError { Map<String, Validator> v2Vals = getV2Validators(project, UseProjectPreferences.Normal); TreeSet<Validator> sorted = new TreeSet<Validator>(); sorted.addAll(v2Vals.values()); try { ValidationConfiguration vc = ConfigurationManager.getManager().getConfiguration(project); if (project == null) { // If the project is null we need to use this approach, since you can not use new // ManualValidatorsOperation(null) ValidatorMetaData[] vmds = vc.getValidators(); for (ValidatorMetaData vmd : vmds) { Validator v = Validator.create(vmd, vc, project); sorted.add(v); } } else { ManualValidatorsOperation mvo = new ManualValidatorsOperation(project); Set<ValidatorMetaData> vmds = mvo.getEnabledValidators(); for (ValidatorMetaData vmd : vmds) { Validator v = Validator.create(vmd, vc, project); sorted.add(v); } } } catch (InvocationTargetException e) { ValidationPlugin.getPlugin().handleException(e); } Validator[] vals = new Validator[sorted.size()]; sorted.toArray(vals); return vals; }