import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
-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.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
public class LuceneTest extends AbstractCompilerTest {
public LuceneTest(String name) {
PHPSearcher indexSearcher = new PHPSearcher(indexPath);
+ indexSearcher.getIncludeInfo("hello_world");
indexSearcher.getClassInfo("Overlib");
indexSearcher.getAttributeInfo("$ol_closetext");
indexSearcher.getMethodInfo("set");
+
}
/**
return hits;
}
+ public Hits getIncludeInfo(String ident) {
+ Hits hits = null;
+ try {
+// Query query = QueryParser.parse(ident, "f", new StandardAnalyzer());
+ Query query = new TermQuery(new Term("i", ident));
+ hits = fSearcher.search(query);
+ int hitCount = hits.length();
+ Document doc;
+ for (int i = 0; (i < hitCount && i < 10); i++) {
+ doc = hits.doc(i);
+ for (int j = 0; j < doc.getValues("i").length; j++) {
+ System.out.println(doc.getValues("i")[j]);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return hits;
+ }
+
public Hits getFunctionInfo(String ident) {
Hits hits = null;
try {
import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
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;
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 = computedUnit.types.size(); --i >= 0;) {
+ for (int i=0; i<computedUnit.types.size(); i++) {
obj = computedUnit.types.get(i);
if (obj instanceof MethodDeclaration) {
m = (MethodDeclaration) obj;