/*
 * Thibaut Colar Sep 2, 2009
 */
package net.colar.netbeans.fan.indexer;

import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import org.netbeans.modules.parsing.api.Snapshot;
import org.netbeans.modules.parsing.spi.indexing.Context;
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexer;
import org.netbeans.modules.parsing.spi.indexing.EmbeddingIndexerFactory;
import org.netbeans.modules.parsing.spi.indexing.Indexable;
import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport;

/**
 * Indexer Factory impl.
 * @author thibautc
 */
public class FanIndexerFactory extends EmbeddingIndexerFactory
{

	static{System.err.println("Fantom - Init indexer Factory");}

	public static final String NAME = "FanIndexer";
	public static final int VERSION = 1;

	@Override
	public EmbeddingIndexer createIndexer(Indexable indexable, Snapshot snapshot)
	{
		if (snapshot.getSource().getFileObject() != null)
		{
			return new FanIndexer();
		}
		return null;
	}

	@Override
	public void filesDeleted(Collection<? extends Indexable> deleted, Context context)
	{
		try
		{
			IndexingSupport is = IndexingSupport.getInstance(context);
			Iterator<? extends Indexable> it = deleted.iterator();
			while (it.hasNext())
			{
				is.removeDocuments(it.next());
			}
		} catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	@Override
	public void filesDirty(Collection<? extends Indexable> dirty, Context context)
	{
		try
		{
			IndexingSupport is = IndexingSupport.getInstance(context);
			Iterator<? extends Indexable> it = dirty.iterator();
			while (it.hasNext())
			{
				is.markDirtyDocuments(it.next());
			}
		} catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	@Override
	public String getIndexerName()
	{
		return NAME;
	}

	@Override
	public int getIndexVersion()
	{
		return VERSION;
	}



}



@@ -1045,26 +1045,24 @@
 Deleted(
-Collection
+Iterable
 %3C? exten
@@ -1400,26 +1400,24 @@
 esDirty(
-Collection
+Iterable
 %3C? exten
@@ -1430,21 +1430,24 @@
 exable%3E 
-dirty
+iterable
 , Contex
@@ -1574,13 +1574,16 @@
 t = 
-dirty
+iterable
 .ite
@@ -1856,14 +1856,12 @@
 ON;%0A
+
 %09%7D%0A%0A
-%0A%0A
 %7D%0A%0A%0A

Fix for indexfactory cahnage in 6.8