package net.sourceforge.phpdt.core.tests.lucene; import java.io.IOException; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference; import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.eclipse.core.resources.IFile; public class PHPWriter { private IndexWriter fWriter = null; public PHPWriter(String indexPath, boolean create) throws IOException { // Make a lucene writer and create new Lucene index with arg3 = true fWriter = new IndexWriter(indexPath, new StandardAnalyzer(), create); } public boolean addDocument(CompilationUnitDeclaration computedUnit, IFile file) { Document doc = new Document(); try { if (file != null) { doc.add(Field.Keyword("filename", file.getName())); doc.add(Field.Keyword("path", file.getProjectRelativePath().toString())); } if (computedUnit.imports != null) { ImportReference imp; for (int i=0; i