Expressions like:
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / phpdt / core / tests / lucene / PHPWriter.java
diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/PHPWriter.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/PHPWriter.java
deleted file mode 100644 (file)
index 042d989..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-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<computedUnit.imports.length; i++) {
-                                       // add the php include
-                                       imp = computedUnit.imports[i];
-                                       String incl = new String(imp.includeSource);
-                                       doc.add(Field.Keyword("i", incl));
-                                       doc.add(Field.UnIndexed(incl, "include meta-info"));
-                               }
-                       }
-                       if (computedUnit.types != null) {
-                               Object obj;
-                               MethodDeclaration m;
-                               TypeDeclaration c;
-                               for (int i=0; i<computedUnit.types.size(); i++) {
-                                       obj = computedUnit.types.get(i);
-                                       if (obj instanceof MethodDeclaration) {
-                                               m = (MethodDeclaration) obj;
-                                               // add the php function name
-                                               String function = new String(m.selector);
-                                               doc.add(Field.Keyword("f", function));
-                                               doc.add(Field.UnIndexed(function, "function meta-info"));
-                                       } else if (obj instanceof TypeDeclaration) {
-                                               c = (TypeDeclaration) obj;
-                                               // add the class-name
-                                               String clazz = new String(c.name);
-//                                             new Field("c", clazz, true, false, true, false);
-                                               doc.add(Field.Keyword("c", clazz));
-                                               doc.add(Field.UnIndexed(clazz, "class meta-info"));
-                                               if (c.fields!=null) {
-                                                       for (int j = 0; j < c.fields.length; j++) {
-                                                               String attribute = new String(c.fields[j].name);
-                                                               doc.add(Field.Keyword("a", attribute));
-                                                               doc.add(Field.UnIndexed(attribute, "field meta-data"));
-                                                       }
-                                               }
-                                               if (c.methods!=null) {
-                                                       for (int j = 0; j < c.methods.length; j++) {
-                                                               String function = new String(c.methods[j].selector);
-                                                               doc.add(Field.Keyword("m", function));
-                                                               doc.add(Field.UnIndexed(function, "method meta-data"));
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       fWriter.addDocument(doc);
-                       return true;
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
-               return false;
-       }
-
-       public void close() {
-
-               try {
-                       fWriter.optimize();
-                       fWriter.close();
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
-
-       }
-
-}