/** {@inheritDoc} */
  public Set<IResource> getAffectedResources(IResource resource, int kind, int deltaKind)
      throws CoreException {
    Set<IResource> resources = new HashSet<IResource>();

    if (kind != IncrementalProjectBuilder.FULL_BUILD
        && resource instanceof IFile
        && resource.getName().endsWith(JdtUtils.JAVA_FILE_EXTENSION)) {

      // Make sure that only a structural change to a java source file triggers a rebuild
      TypeStructureState structureState = context.get(TypeStructureState.class);
      BeansTypeHierachyState hierachyState = context.get(BeansTypeHierachyState.class);

      if (structureState == null
          || structureState.hasStructuralChanges(
              resource,
              ITypeStructureCache.FLAG_ANNOTATION | ITypeStructureCache.FLAG_ANNOTATION_VALUE)) {
        for (IBean bean : hierachyState.getBeansByContainingTypes(resource)) {
          IBeansConfig beansConfig = BeansModelUtils.getConfig(bean);
          resources.add(beansConfig.getElementResource());
          if (affectedBeans.containsKey(beansConfig)) {
            affectedBeans.get(beansConfig).add(bean);
          } else {
            Set<IBean> beans = new LinkedHashSet<IBean>();
            beans.add(bean);
            affectedBeans.put(beansConfig, beans);
          }
        }
      }
    } else if (BeansCoreUtils.isBeansConfig(resource, true)) {
      IBeansConfig beansConfig = (IBeansConfig) BeansModelUtils.getResourceModelElement(resource);
      if (beansConfig instanceof IImportedBeansConfig) {
        beansConfig = BeansModelUtils.getParentOfClass(beansConfig, IBeansConfig.class);
      }
      for (IBeansImport beansImport : beansConfig.getImports()) {
        for (IImportedBeansConfig importedBeansConfig : beansImport.getImportedBeansConfigs()) {
          resources.add(importedBeansConfig.getElementResource());
          addBeans(importedBeansConfig);
        }
      }
      resources.add(beansConfig.getElementResource());
      addBeans(beansConfig);
    }
    return resources;
  }
 /**
  * Register an instance of {@link BeansTypeHierachyState} with the given <code>state</code>
  * instance.
  */
 @Override
 public void start(
     int kind,
     IResourceDelta delta,
     List<ProjectBuilderDefinition> builderDefinitions,
     List<ValidatorDefinition> validatorDefinitions,
     IProjectContributorState state,
     IProject project) {
   state.hold(new BeansTypeHierachyState());
 }