Tests for indexing a PHP AST with Lucene search engine;
authoraxelcl <axelcl>
Fri, 2 Sep 2005 19:23:53 +0000 (19:23 +0000)
committeraxelcl <axelcl>
Fri, 2 Sep 2005 19:23:53 +0000 (19:23 +0000)
Needs more ideas how to store the meta-information :-)

net.sourceforge.phpeclipse.tests/plugin.xml
net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/LuceneTest.java [new file with mode: 0644]
net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/PHPSearcher.java [new file with mode: 0644]
net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/PHPWriter.java [new file with mode: 0644]
net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/OverlibTestCase.java

index 246473a..c206c99 100644 (file)
@@ -21,8 +21,9 @@
       <import plugin="org.eclipse.core.runtime"/>
       <import plugin="org.eclipse.jface.text"/>
       <import plugin="org.eclipse.core.resources"/>
+      <import plugin="org.apache.lucene"/>
    </requires>
-
+<!-- <import plugin="org.apache.lucene"/> -->
    <extension
          point="org.eclipse.ui.popupMenus">
       <objectContribution
diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/LuceneTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/LuceneTest.java
new file mode 100644 (file)
index 0000000..2e8e653
--- /dev/null
@@ -0,0 +1,210 @@
+package net.sourceforge.phpdt.core.tests.lucene;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Locale;
+
+import net.sourceforge.phpdt.core.compiler.IProblem;
+import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest;
+import net.sourceforge.phpdt.core.tests.util.Util;
+import net.sourceforge.phpdt.internal.compiler.CompilationResult;
+import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies;
+import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit;
+import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
+import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpdt.internal.compiler.parser.UnitParser;
+import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblem;
+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) {
+               super(name);
+       }
+
+       private void checkPHP(String strEval) {
+               if (Scanner.DEBUG) {
+                       System.out.println("\n------------------------------------");
+                       System.out.println(strEval);
+               }
+
+               String expectedSyntaxErrorDiagnosis = "";
+
+               UnitParser parser = new UnitParser(new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+                               new CompilerOptions(getCompilerOptions()), new DefaultProblemFactory(Locale.getDefault())));
+
+               ICompilationUnit sourceUnit = new CompilationUnit(strEval.toCharArray(), "", null);
+               CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+
+               CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult, true);
+
+               StringBuffer buffer = new StringBuffer(100);
+               if (compilationResult.hasProblems() || compilationResult.hasTasks()) {
+                       IProblem[] problems = compilationResult.getAllProblems();
+                       int count = problems.length;
+                       int problemCount = 0;
+                       char[] unitSource = compilationResult.compilationUnit.getContents();
+                       for (int i = 0; i < count; i++) {
+                               if (problems[i] != null) {
+                                       if (problemCount == 0)
+                                               buffer.append("----------\n");
+                                       problemCount++;
+                                       buffer.append(problemCount + (problems[i].isError() ? ". ERROR" : ". WARNING"));
+                                       buffer.append(" in " + new String(problems[i].getOriginatingFileName()).replace('/', '\\'));
+                                       try {
+                                               buffer.append(((DefaultProblem) problems[i]).errorReportSource(unitSource));
+                                               buffer.append("\n");
+                                               buffer.append(problems[i].getMessage());
+                                               buffer.append("\n");
+                                       } catch (Exception e) {
+                                               StringWriter stringWriter = new StringWriter();
+                                               e.printStackTrace(new PrintWriter(stringWriter));
+                                               buffer.append(stringWriter.getBuffer());
+                                       }
+                                       buffer.append("----------\n");
+                               }
+                       }
+               }
+               String computedSyntaxErrorDiagnosis = buffer.toString();
+               if (!expectedSyntaxErrorDiagnosis.equals(computedSyntaxErrorDiagnosis)) {
+                       System.out.println(Util.displayString(computedSyntaxErrorDiagnosis));
+               }
+               assertEquals("Invalid syntax error diagnosis", expectedSyntaxErrorDiagnosis, computedSyntaxErrorDiagnosis);
+               String indexPath = "c:\\temp\\index_store";
+
+               PHPWriter writer = null;
+               try {
+                       writer = new PHPWriter(indexPath, true);
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       return;
+               }
+               writer.addDocument(computedUnit, null);
+               writer.close();
+
+               PHPSearcher indexSearcher = new PHPSearcher(indexPath);
+
+               indexSearcher.getClassInfo("Overlib");
+               indexSearcher.getAttributeInfo("$ol_closetext");
+               indexSearcher.getMethodInfo("set");
+       }
+
+       /**
+        * Test the PHP Parser with different PHP snippets
+        */
+       public void testPHPParser() {
+               checkPHP("\r\n" + "    /*\r\n" + "\r\n" + "     This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" + "\r\n"
+                               + "     written 1999, 2000, 2001 Patrick Hess <hess@dland.de>\r\n" + "\r\n" + " This software is distributed under GPL.\r\n"
+                               + " \r\n" + "   overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" + "\r\n"
+                               + "     This class is just a driver/container, so most of this wonderful\r\n" + " \r\n"
+                               + "     work is done by Eric Bosrup! Keep this in mind... \r\n" + " \r\n" + "    */\r\n" + "\r\n"
+                               + "include(\"hello_world\"); \r\n" + "function foo() {" + "} \r\n" + "\r\n" + " class Overlib {\r\n" + "\r\n"
+                               + "       public $ol_path          = \"modules/Forums\";\r\n" + "\r\n" + "        public $ol_sticky        = false;\r\n" + "\r\n"
+                               + "       public $ol_align              = 0;\r\n" + "\r\n" + "    public $ol_valign        = 0;\r\n" + "\r\n"
+                               + "       public $ol_fgcolor       = \"#fcfcfc\";\r\n" + "\r\n" + "       public $ol_bgcolor       = \"#0080C0\";\r\n" + "\r\n"
+                               + "       public $ol_capcolor      = \"#ffffff\";\r\n" + "\r\n" + "       public $ol_textcolor     = \"\";\r\n" + "\r\n"
+                               + "       public $ol_closecolor    = \"\";\r\n" + "\r\n" + "      public $ol_textfont      = \"\";\r\n" + "\r\n"
+                               + "       public $ol_captionfont   = \"\";\r\n" + "\r\n" + "      public $ol_closefont     = \"\";\r\n" + "\r\n"
+                               + "       public $ol_textsize      = 0;\r\n" + "\r\n" + "         public $ol_captionsize   = 0;\r\n" + "\r\n"
+                               + "       public $ol_closesize     = 0;\r\n" + "\r\n" + "         public $ol_height        = 0;\r\n" + "\r\n"
+                               + "       public $ol_width         = 0;\r\n" + "\r\n" + "         public $ol_border        = 3;\r\n" + "\r\n"
+                               + "       public $ol_offsetx       = 0;\r\n" + "\r\n" + "         public $ol_offsety       = 0;\r\n" + "\r\n"
+                               + "       public $ol_fgbackground  = \"\";\r\n" + "\r\n" + "      public $ol_bgbackground  = \"\";\r\n" + "\r\n"
+                               + "       public $ol_closetext     = \"Close\";\r\n" + "\r\n" + "         public $ol_close         = true;\r\n" + "\r\n"
+                               + "       public $ol_noclosetext   = false;\r\n" + "\r\n" + "     public $ol_autostatus    = false;\r\n" + "\r\n"
+                               + "       public $ol_autostatuscap = false;\r\n" + "\r\n" + "     public $ol_capicon       = \"images/forum/question.gif\";\r\n"
+                               + "\r\n" + "      public $ol_snapx         = 0;\r\n" + "\r\n" + "         public $ol_snapy         = 0;\r\n" + "\r\n"
+                               + "       public $ol_padxl         = 0;\r\n" + "\r\n" + "         public $ol_padxr         = 0;\r\n" + "\r\n"
+                               + "       public $ol_padyt         = 0;\r\n" + "\r\n" + "         public $ol_padyb         = 0;\r\n" + "\r\n"
+                               + "       public $ol_fixy          = 0;\r\n" + "\r\n" + "         public $ol_background    = \"\";\r\n" + "\r\n"
+                               + "       public $ol_fullhtml      = false;\r\n" + "\r\n" + "     public $ol_timeout    = -1;\r\n" + "\r\n"
+                               + "       public $ol_delay              = -1;\r\n" + "\r\n" + "   public $ol_vauto         = false;\r\n" + "\r\n"
+                               + "       public $ol_hauto         = false;\r\n" + "\r\n" + "\r\n" + "\r\n" + "   function overLib($path = \"\") {\r\n"
+                               + "\r\n" + "            if (strlen($path)) $this->ol_path = $path;\r\n" + "\r\n" + "?>\r\n" + "\r\n"
+                               + "<nolink rel=\'stylesheet\' href=<?php echo \"\'$this->ol_path/overlib.css\' \"; ?> \r\n" + "\r\n"
+                               + "      type=\'text/css\'>\r\n" + "\r\n"
+                               + "<div id=\'overDiv\' style=\'position:absolute; visibility:hide; z-index: 1000;\'>\r\n" + "\r\n" + "</div>\r\n" + "\r\n"
+                               + "<script language=\'javascript\' src=<?php echo \"\'$this->ol_path/overlib.js\'\"; ?>>\r\n" + "\r\n" + "</script>\r\n"
+                               + "\r\n" + "<?php\r\n" + "\r\n" + "       }  \r\n" + "  \r\n" + " \r\n" + "\r\n" + "      function set($var, $value) {\r\n"
+                               + "\r\n" + "            $v = \"ol_$var\";\r\n" + "\r\n" + "             $this->$v = $value;\r\n" + "\r\n" + "     }\r\n" + "\r\n" + "\r\n"
+                               + "\r\n" + "      function get($var) {\r\n" + "\r\n" + "                $v = \"ol_$var\";\r\n" + "\r\n" + "             return($this->$v);\r\n"
+                               + "\r\n" + "      }\r\n" + "\r\n" + "\r\n" + "\r\n" + "   function over($text, $title = \"\", $status = \"\")\r\n" + "\r\n"
+                               + "       {\r\n" + "\r\n" + "       $cmd = \"\'$text\'\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "       if(strlen($title)) \r\n"
+                               + "\r\n" + "            $cmd .= \", CAPTION, \'$title\'\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "      if(strlen($status)) \r\n" + "\r\n"
+                               + "             $cmd .= \", STATUS, \'$status\'\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "      if($this->ol_sticky)        \r\n" + "\r\n"
+                               + "             $cmd .= \", STICKY\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if($this->ol_align) {\r\n" + "\r\n"
+                               + "             switch($this->ol_align) {\r\n" + "\r\n" + "                 case 1: $cmd .= \", LEFT\"; break;\r\n" + "\r\n"
+                               + "                 case 2: $cmd .= \", CENTER\";       break;\r\n" + "\r\n" + "                    case 3: $cmd .= \", RIGHT\";        break;\r\n" + "\r\n"
+                               + "                 default:                    break;\r\n" + "\r\n" + "                }\r\n" + "\r\n" + "         }\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if($this->ol_valign) {\r\n" + "\r\n" + "            switch($this->ol_valign) {\r\n" + "\r\n"
+                               + "                 case 1: $cmd .= \", ABOVE\";        break;\r\n" + "\r\n" + "                    case 2: $cmd .= \", BELOW\";        break;\r\n" + "\r\n"
+                               + "                 default:                    break;\r\n" + "\r\n" + "                }\r\n" + "\r\n" + "         }\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if (strlen($this->ol_fgbackground)) {\r\n" + "\r\n"
+                               + "             $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" + "\r\n" + "            } else {\r\n" + "\r\n"
+                               + "             if (strlen($this->ol_fgcolor))\r\n" + "\r\n" + "                        $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" + "\r\n"
+                               + "         }\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if (strlen($this->ol_bgbackground)) {\r\n" + "\r\n"
+                               + "             $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" + "\r\n" + "            } else {\r\n" + "\r\n"
+                               + "             if (strlen($this->ol_bgcolor))\r\n" + "\r\n" + "                        $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" + "\r\n"
+                               + "         }\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if (strlen($this->ol_capcolor))\r\n" + "\r\n"
+                               + "             $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if (strlen($this->ol_textcolor))\r\n" + "\r\n" + "          $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if (strlen($this->ol_closecolor))\r\n" + "\r\n"
+                               + "             $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if (strlen($this->ol_textfont))\r\n" + "\r\n" + "           $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if (strlen($this->ol_captionfont))\r\n" + "\r\n"
+                               + "             $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if (strlen($this->ol_closefont))\r\n" + "\r\n" + "          $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if ($this->ol_textsize)\r\n" + "\r\n" + "           $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n"
+                               + "\r\n" + "\r\n" + "\r\n" + "      if ($this->ol_captionsize)\r\n" + "\r\n"
+                               + "             $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if ($this->ol_closesize)\r\n" + "\r\n" + "          $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" + "\r\n" + "\r\n"
+                               + "\r\n" + "        if ($this->ol_width)\r\n" + "\r\n" + "              $cmd .= \", WIDTH, $this->ol_width\";\r\n" + "\r\n" + "\r\n"
+                               + "\r\n" + "        if ($this->ol_height)\r\n" + "\r\n" + "             $cmd .= \", HEIGHT, $this->ol_height\";\r\n" + "\r\n" + "\r\n"
+                               + "\r\n" + "        if ($this->ol_border >= 0)\r\n" + "\r\n" + "                $cmd .= \", BORDER, $this->ol_border\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if ($this->ol_offsetx)\r\n" + "\r\n" + "            $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if ($this->ol_offsety)\r\n" + "\r\n" + "            $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if (strlen($this->ol_closetext))\r\n" + "\r\n"
+                               + "             $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "       if ($this->ol_noclose)\r\n"
+                               + "\r\n" + "            $cmd .= \", NOCLOSETEXT\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "      if ($this->ol_autostatus)\r\n" + "\r\n"
+                               + "             $cmd .= \", AUTOSTATUS\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "       if ($this->ol_autostatuscap)\r\n" + "\r\n"
+                               + "             $cmd .= \", AUTOSTATUSCAP\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "            if (strlen($this->ol_capicon))\r\n" + "\r\n"
+                               + "             $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if ($this->ol_snapx)\r\n"
+                               + "\r\n" + "            $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if ($this->ol_snapy)\r\n"
+                               + "\r\n" + "            $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if ($this->ol_fixy)\r\n"
+                               + "\r\n" + "            $cmd .= \", FIXY, $this->ol_fixy\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if ($this->ol_padxl || $this->ol_padxr)\r\n" + "\r\n"
+                               + "             $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if ($this->ol_padyt || $this->ol_padyb)\r\n" + "\r\n"
+                               + "             $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" + "\r\n" + "\r\n" + "\r\n"
+                               + "         if (strlen($this->ol_background))\r\n" + "\r\n" + "         $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n"
+                               + "\r\n" + "\r\n" + "\r\n" + "      if ($this->ol_fullhtml)\r\n" + "\r\n" + "           $cmd .= \", FULLHTML\";\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       if ($this->ol_timeout >= 0)\r\n" + "\r\n" + "               $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n"
+                               + "\r\n" + "\r\n" + "\r\n" + "      if ($this->ol_delay >= 0)\r\n" + "\r\n" + "         $cmd .= \", DELAY, $this->ol_delay\";\r\n"
+                               + "\r\n" + "\r\n" + "\r\n" + "      if ($this->ol_hauto) {\r\n" + "\r\n" + "            $cmd .= \", HAUTO\";\r\n" + "\r\n"
+                               + "             $this->ol_hauto = false;\r\n" + "\r\n" + "          }\r\n" + "\r\n" + "\r\n" + "\r\n" + "           if ($this->ol_vauto) {\r\n"
+                               + "\r\n" + "            $cmd .= \", VAUTO\";\r\n" + "\r\n" + "          $this->ol_hauto = false;\r\n" + "\r\n" + "          }\r\n" + "\r\n"
+                               + "\r\n" + "\r\n" + "       $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" + "\r\n"
+                               + "         $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" + "\r\n" + "\r\n" + "\r\n" + "            return ($output);\r\n" + "\r\n"
+                               + "       }\r\n" + "\r\n" + "\r\n" + "\r\n" + "   function pover ($text, $title = \"\", $status = \"\") \r\n" + "\r\n"
+                               + "       {\r\n" + "\r\n" + "       echo $this->over($text, $title, $status);\r\n" + "\r\n" + "   }\r\n" + "\r\n" + "   }\r\n"
+                               + "\r\n" + "?>\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "");
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/PHPSearcher.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpdt/core/tests/lucene/PHPSearcher.java
new file mode 100644 (file)
index 0000000..035c752
--- /dev/null
@@ -0,0 +1,105 @@
+package net.sourceforge.phpdt.core.tests.lucene;
+
+import java.io.IOException;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
+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.apache.lucene.search.TermQuery;
+
+public class PHPSearcher {
+       private IndexSearcher fSearcher;
+       private StandardAnalyzer analyzer;
+
+       public PHPSearcher(String indexPath) {
+               try {
+                       fSearcher = new IndexSearcher(indexPath);
+                       analyzer = new StandardAnalyzer();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public Hits getClassInfo(String ident) {
+               Hits hits = null;
+               try {
+      Query query = new TermQuery(new Term("c", 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("c").length; j++) {
+                                       System.out.println(doc.getValues("c")[j]);
+                               }
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return hits;
+       }
+
+       public Hits getFunctionInfo(String ident) {
+               Hits hits = null;
+               try {
+//                     Query query = QueryParser.parse(ident, "f", new StandardAnalyzer());
+                       Query query = new TermQuery(new Term("f", 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("f").length; j++) {
+                                       System.out.println(doc.getValues("f")[j]);
+                               }
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return hits;
+       }
+
+       public Hits getMethodInfo(String ident) {
+               Hits hits = null;
+               try {
+//                     Query query = QueryParser.parse(ident, "m", new StandardAnalyzer());
+                       Query query = new TermQuery(new Term("m", 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("m").length; j++) {
+                                       System.out.println(doc.getValues("m")[j]);
+                               }
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return hits;
+       }
+       public Hits getAttributeInfo(String ident) {
+               Hits hits = null;
+               try {
+//                     Query query = QueryParser.parse(ident, "m", new StandardAnalyzer());
+                       Query query = new TermQuery(new Term("a", 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("a").length; j++) {
+                                       System.out.println(doc.getValues("a")[j]);
+                               }
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return hits;
+       }
+}
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
new file mode 100644 (file)
index 0000000..bdd54d9
--- /dev/null
@@ -0,0 +1,86 @@
+package net.sourceforge.phpdt.core.tests.lucene;
+
+import java.io.IOException;
+
+import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
+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.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.types != null) {
+                               Object obj;
+                               MethodDeclaration m;
+                               TypeDeclaration c;
+                               for (int i = computedUnit.types.size(); --i >= 0;) {
+                                       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, "class 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();
+               }
+
+       }
+
+}
index 6f4cb49..b119ff8 100644 (file)
@@ -20,459 +20,461 @@ public class OverlibTestCase extends AbstractCompilerTest {
    */
   public void testPHPParser() {
     checkPHP(
-               "\r\n" + 
-               "    /*\r\n" + 
-               "\r\n" + 
-               "       This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" + 
-               "\r\n" + 
-               "       written 1999, 2000, 2001 Patrick Hess <hess@dland.de>\r\n" + 
-               "\r\n" + 
-               "       This software is distributed under GPL.\r\n" + 
-               " \r\n" + 
-               "       overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" + 
-               "\r\n" + 
-               "       This class is just a driver/container, so most of this wonderful\r\n" + 
-               " \r\n" + 
-               "       work is done by Eric Bosrup! Keep this in mind... \r\n" + 
-               "\r\n" + 
-               "    */\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "       class Overlib {\r\n" + 
-               "\r\n" + 
-               "         public $ol_path          = \"modules/Forums\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_sticky        = false;\r\n" + 
-               "\r\n" + 
-               "         public $ol_align              = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_valign        = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_fgcolor       = \"#fcfcfc\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_bgcolor       = \"#0080C0\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_capcolor      = \"#ffffff\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_textcolor     = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_closecolor    = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_textfont      = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_captionfont   = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_closefont     = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_textsize      = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_captionsize   = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_closesize     = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_height        = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_width         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_border        = 3;\r\n" + 
-               "\r\n" + 
-               "         public $ol_offsetx       = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_offsety       = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_fgbackground  = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_bgbackground  = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_closetext     = \"Close\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_close         = true;\r\n" + 
-               "\r\n" + 
-               "         public $ol_noclosetext   = false;\r\n" + 
-               "\r\n" + 
-               "         public $ol_autostatus    = false;\r\n" + 
-               "\r\n" + 
-               "         public $ol_autostatuscap = false;\r\n" + 
-               "\r\n" + 
-               "         public $ol_capicon       = \"images/forum/question.gif\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_snapx         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_snapy         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_padxl         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_padxr         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_padyt         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_padyb         = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_fixy          = 0;\r\n" + 
-               "\r\n" + 
-               "         public $ol_background    = \"\";\r\n" + 
-               "\r\n" + 
-               "         public $ol_fullhtml      = false;\r\n" + 
-               "\r\n" + 
-               "         public $ol_timeout    = -1;\r\n" + 
-               "\r\n" + 
-               "         public $ol_delay              = -1;\r\n" + 
-               "\r\n" + 
-               "         public $ol_vauto         = false;\r\n" + 
-               "\r\n" + 
-               "         public $ol_hauto         = false;\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "         function overLib($path = \"\") {\r\n" + 
-               "\r\n" + 
-               "               if (strlen($path)) $this->ol_path = $path;\r\n" + 
-               "\r\n" + 
-               "?>\r\n" + 
-               "\r\n" + 
-               "<nolink rel=\'stylesheet\' href=<?php echo \"\'$this->ol_path/overlib.css\' \"; ?> \r\n" + 
-               "\r\n" + 
-               "      type=\'text/css\'>\r\n" + 
-               "\r\n" + 
-               "<div id=\'overDiv\' style=\'position:absolute; visibility:hide; z-index: 1000;\'>\r\n" + 
-               "\r\n" + 
-               "</div>\r\n" + 
-               "\r\n" + 
-               "<script language=\'javascript\' src=<?php echo \"\'$this->ol_path/overlib.js\'\"; ?>>\r\n" + 
-               "\r\n" + 
-               "</script>\r\n" + 
-               "\r\n" + 
-               "<?php\r\n" + 
-               "\r\n" + 
-               "         }  \r\n" + 
-               "       \r\n" + 
-               " \r\n" + 
-               "\r\n" + 
-               "         function set($var, $value) {\r\n" + 
-               "\r\n" + 
-               "               $v = \"ol_$var\";\r\n" + 
-               "\r\n" + 
-               "               $this->$v = $value;\r\n" + 
-               "\r\n" + 
-               "         }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "         function get($var) {\r\n" + 
-               "\r\n" + 
-               "               $v = \"ol_$var\";\r\n" + 
-               "\r\n" + 
-               "               return($this->$v);\r\n" + 
-               "\r\n" + 
-               "         }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "         function over($text, $title = \"\", $status = \"\")\r\n" + 
-               "\r\n" + 
-               "         {\r\n" + 
-               "\r\n" + 
-               "           $cmd = \"\'$text\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if(strlen($title)) \r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CAPTION, \'$title\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if(strlen($status)) \r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", STATUS, \'$status\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if($this->ol_sticky)        \r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", STICKY\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if($this->ol_align) {\r\n" + 
-               "\r\n" + 
-               "               switch($this->ol_align) {\r\n" + 
-               "\r\n" + 
-               "                   case 1: $cmd .= \", LEFT\"; break;\r\n" + 
-               "\r\n" + 
-               "                   case 2: $cmd .= \", CENTER\";       break;\r\n" + 
-               "\r\n" + 
-               "                   case 3: $cmd .= \", RIGHT\";        break;\r\n" + 
-               "\r\n" + 
-               "                   default:                    break;\r\n" + 
-               "\r\n" + 
-               "               }\r\n" + 
-               "\r\n" + 
-               "           }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if($this->ol_valign) {\r\n" + 
-               "\r\n" + 
-               "               switch($this->ol_valign) {\r\n" + 
-               "\r\n" + 
-               "                   case 1: $cmd .= \", ABOVE\";        break;\r\n" + 
-               "\r\n" + 
-               "                   case 2: $cmd .= \", BELOW\";        break;\r\n" + 
-               "\r\n" + 
-               "                   default:                    break;\r\n" + 
-               "\r\n" + 
-               "               }\r\n" + 
-               "\r\n" + 
-               "           }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_fgbackground)) {\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" + 
-               "\r\n" + 
-               "           } else {\r\n" + 
-               "\r\n" + 
-               "               if (strlen($this->ol_fgcolor))\r\n" + 
-               "\r\n" + 
-               "                       $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" + 
-               "\r\n" + 
-               "           }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_bgbackground)) {\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" + 
-               "\r\n" + 
-               "           } else {\r\n" + 
-               "\r\n" + 
-               "               if (strlen($this->ol_bgcolor))\r\n" + 
-               "\r\n" + 
-               "                       $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" + 
-               "\r\n" + 
-               "           }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_capcolor))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_textcolor))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_closecolor))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_textfont))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_captionfont))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_closefont))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_textsize)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_captionsize)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_closesize)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_width)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", WIDTH, $this->ol_width\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_height)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", HEIGHT, $this->ol_height\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_border >= 0)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", BORDER, $this->ol_border\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_offsetx)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_offsety)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_closetext))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_noclose)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", NOCLOSETEXT\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_autostatus)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", AUTOSTATUS\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_autostatuscap)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", AUTOSTATUSCAP\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_capicon))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_snapx)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_snapy)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_fixy)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", FIXY, $this->ol_fixy\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_padxl || $this->ol_padxr)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_padyt || $this->ol_padyb)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if (strlen($this->ol_background))\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_fullhtml)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", FULLHTML\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_timeout >= 0)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_delay >= 0)\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", DELAY, $this->ol_delay\";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_hauto) {\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", HAUTO\";\r\n" + 
-               "\r\n" + 
-               "               $this->ol_hauto = false;\r\n" + 
-               "\r\n" + 
-               "           }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           if ($this->ol_vauto) {\r\n" + 
-               "\r\n" + 
-               "               $cmd .= \", VAUTO\";\r\n" + 
-               "\r\n" + 
-               "               $this->ol_hauto = false;\r\n" + 
-               "\r\n" + 
-               "           }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" + 
-               "\r\n" + 
-               "           $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "           return ($output);\r\n" + 
-               "\r\n" + 
-               "         }\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "         function pover ($text, $title = \"\", $status = \"\") \r\n" + 
-               "\r\n" + 
-               "         {\r\n" + 
-               "\r\n" + 
-               "           echo $this->over($text, $title, $status);\r\n" + 
-               "\r\n" + 
-               "         }\r\n" + 
-               "\r\n" + 
-               "       }\r\n" + 
-               "\r\n" + 
-               "?>\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
-               "\r\n" + 
+               "\r\n" +
+               "    /*\r\n" +
+               "\r\n" +
+               "       This is version 1.11 of class.overlib for php (http://www.php.net) \r\n" +
+               "\r\n" +
+               "       written 1999, 2000, 2001 Patrick Hess <hess@dland.de>\r\n" +
+               "\r\n" +
+               "       This software is distributed under GPL.\r\n" +
+               " \r\n" +
+               "       overLib is from Eric Bosrup (http://www.bosrup.com/web/overlib/)\r\n" +
+               "\r\n" +
+               "       This class is just a driver/container, so most of this wonderful\r\n" +
+               " \r\n" +
+               "       work is done by Eric Bosrup! Keep this in mind... \r\n" +
+               " \r\n" +
+               "    */\r\n" +
+               "\r\n" +
+               "include(\"hello_world\"); \r\n" +
+               "function foo() {" +
+               "} \r\n" +
+               "\r\n" +
+               "       class Overlib {\r\n" +
+               "\r\n" +
+               "         public $ol_path          = \"modules/Forums\";\r\n" +
+               "\r\n" +
+               "         public $ol_sticky        = false;\r\n" +
+               "\r\n" +
+               "         public $ol_align              = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_valign        = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_fgcolor       = \"#fcfcfc\";\r\n" +
+               "\r\n" +
+               "         public $ol_bgcolor       = \"#0080C0\";\r\n" +
+               "\r\n" +
+               "         public $ol_capcolor      = \"#ffffff\";\r\n" +
+               "\r\n" +
+               "         public $ol_textcolor     = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_closecolor    = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_textfont      = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_captionfont   = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_closefont     = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_textsize      = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_captionsize   = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_closesize     = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_height        = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_width         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_border        = 3;\r\n" +
+               "\r\n" +
+               "         public $ol_offsetx       = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_offsety       = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_fgbackground  = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_bgbackground  = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_closetext     = \"Close\";\r\n" +
+               "\r\n" +
+               "         public $ol_close         = true;\r\n" +
+               "\r\n" +
+               "         public $ol_noclosetext   = false;\r\n" +
+               "\r\n" +
+               "         public $ol_autostatus    = false;\r\n" +
+               "\r\n" +
+               "         public $ol_autostatuscap = false;\r\n" +
+               "\r\n" +
+               "         public $ol_capicon       = \"images/forum/question.gif\";\r\n" +
+               "\r\n" +
+               "         public $ol_snapx         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_snapy         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_padxl         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_padxr         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_padyt         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_padyb         = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_fixy          = 0;\r\n" +
+               "\r\n" +
+               "         public $ol_background    = \"\";\r\n" +
+               "\r\n" +
+               "         public $ol_fullhtml      = false;\r\n" +
+               "\r\n" +
+               "         public $ol_timeout    = -1;\r\n" +
+               "\r\n" +
+               "         public $ol_delay              = -1;\r\n" +
+               "\r\n" +
+               "         public $ol_vauto         = false;\r\n" +
+               "\r\n" +
+               "         public $ol_hauto         = false;\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "         function overLib($path = \"\") {\r\n" +
+               "\r\n" +
+               "               if (strlen($path)) $this->ol_path = $path;\r\n" +
+               "\r\n" +
+               "?>\r\n" +
+               "\r\n" +
+               "<nolink rel=\'stylesheet\' href=<?php echo \"\'$this->ol_path/overlib.css\' \"; ?> \r\n" +
+               "\r\n" +
+               "      type=\'text/css\'>\r\n" +
+               "\r\n" +
+               "<div id=\'overDiv\' style=\'position:absolute; visibility:hide; z-index: 1000;\'>\r\n" +
+               "\r\n" +
+               "</div>\r\n" +
+               "\r\n" +
+               "<script language=\'javascript\' src=<?php echo \"\'$this->ol_path/overlib.js\'\"; ?>>\r\n" +
+               "\r\n" +
+               "</script>\r\n" +
+               "\r\n" +
+               "<?php\r\n" +
+               "\r\n" +
+               "         }  \r\n" +
+               "       \r\n" +
+               " \r\n" +
+               "\r\n" +
+               "         function set($var, $value) {\r\n" +
+               "\r\n" +
+               "               $v = \"ol_$var\";\r\n" +
+               "\r\n" +
+               "               $this->$v = $value;\r\n" +
+               "\r\n" +
+               "         }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "         function get($var) {\r\n" +
+               "\r\n" +
+               "               $v = \"ol_$var\";\r\n" +
+               "\r\n" +
+               "               return($this->$v);\r\n" +
+               "\r\n" +
+               "         }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "         function over($text, $title = \"\", $status = \"\")\r\n" +
+               "\r\n" +
+               "         {\r\n" +
+               "\r\n" +
+               "           $cmd = \"\'$text\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if(strlen($title)) \r\n" +
+               "\r\n" +
+               "               $cmd .= \", CAPTION, \'$title\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if(strlen($status)) \r\n" +
+               "\r\n" +
+               "               $cmd .= \", STATUS, \'$status\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if($this->ol_sticky)        \r\n" +
+               "\r\n" +
+               "               $cmd .= \", STICKY\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if($this->ol_align) {\r\n" +
+               "\r\n" +
+               "               switch($this->ol_align) {\r\n" +
+               "\r\n" +
+               "                   case 1: $cmd .= \", LEFT\"; break;\r\n" +
+               "\r\n" +
+               "                   case 2: $cmd .= \", CENTER\";       break;\r\n" +
+               "\r\n" +
+               "                   case 3: $cmd .= \", RIGHT\";        break;\r\n" +
+               "\r\n" +
+               "                   default:                    break;\r\n" +
+               "\r\n" +
+               "               }\r\n" +
+               "\r\n" +
+               "           }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if($this->ol_valign) {\r\n" +
+               "\r\n" +
+               "               switch($this->ol_valign) {\r\n" +
+               "\r\n" +
+               "                   case 1: $cmd .= \", ABOVE\";        break;\r\n" +
+               "\r\n" +
+               "                   case 2: $cmd .= \", BELOW\";        break;\r\n" +
+               "\r\n" +
+               "                   default:                    break;\r\n" +
+               "\r\n" +
+               "               }\r\n" +
+               "\r\n" +
+               "           }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_fgbackground)) {\r\n" +
+               "\r\n" +
+               "               $cmd .= \", FGCOLOR, \'\', FGBACKGROUND, \'$this->ol_fgbackground\'\";\r\n" +
+               "\r\n" +
+               "           } else {\r\n" +
+               "\r\n" +
+               "               if (strlen($this->ol_fgcolor))\r\n" +
+               "\r\n" +
+               "                       $cmd .= \", FGCOLOR, \'$this->ol_fgcolor\'\";\r\n" +
+               "\r\n" +
+               "           }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_bgbackground)) {\r\n" +
+               "\r\n" +
+               "               $cmd .= \", BGCOLOR, \'\', BGBACKGROUND, \'$this->ol_bgbackground\'\";\r\n" +
+               "\r\n" +
+               "           } else {\r\n" +
+               "\r\n" +
+               "               if (strlen($this->ol_bgcolor))\r\n" +
+               "\r\n" +
+               "                       $cmd .= \", BGCOLOR, \'$this->ol_bgcolor\'\";\r\n" +
+               "\r\n" +
+               "           }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_capcolor))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CAPCOLOR, \'$this->ol_capcolor\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_textcolor))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", TEXTCOLOR, \'$this->ol_textcolor\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_closecolor))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CLOSECOLOR, \'$this->ol_closecolor\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_textfont))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", TEXTFONT, \'$this->ol_textfont\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_captionfont))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CAPTIONFONT, \'$this->ol_captionfont\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_closefont))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CLOSEFONT, \'$this->ol_closefont\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_textsize)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", TEXTSIZE, $this->ol_textsize\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_captionsize)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CAPTIONSIZE, $this->ol_captionsize\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_closesize)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CLOSESIZE, $this->ol_closesize\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_width)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", WIDTH, $this->ol_width\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_height)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", HEIGHT, $this->ol_height\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_border >= 0)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", BORDER, $this->ol_border\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_offsetx)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", OFFSETX, $this->ol_offsetx\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_offsety)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", OFFSETY, $this->ol_offsety\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_closetext))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CLOSETEXT, \'$this->ol_closetext\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_noclose)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", NOCLOSETEXT\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_autostatus)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", AUTOSTATUS\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_autostatuscap)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", AUTOSTATUSCAP\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_capicon))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", CAPICON, \'$this->ol_capicon\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_snapx)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", SNAPX, $this->ol_snapx\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_snapy)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", SNAPY, $this->ol_snapy\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_fixy)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", FIXY, $this->ol_fixy\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_padxl || $this->ol_padxr)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", PADX, $this->ol_padxl, $this->ol_padxr\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_padyt || $this->ol_padyb)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", PADY, $this->ol_padyt, $this->ol_padyb\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if (strlen($this->ol_background))\r\n" +
+               "\r\n" +
+               "               $cmd .= \", BACKGROUND, \'$this->ol_background\'\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_fullhtml)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", FULLHTML\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_timeout >= 0)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", TIMEOUT, $this->ol_timeout\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_delay >= 0)\r\n" +
+               "\r\n" +
+               "               $cmd .= \", DELAY, $this->ol_delay\";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_hauto) {\r\n" +
+               "\r\n" +
+               "               $cmd .= \", HAUTO\";\r\n" +
+               "\r\n" +
+               "               $this->ol_hauto = false;\r\n" +
+               "\r\n" +
+               "           }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           if ($this->ol_vauto) {\r\n" +
+               "\r\n" +
+               "               $cmd .= \", VAUTO\";\r\n" +
+               "\r\n" +
+               "               $this->ol_hauto = false;\r\n" +
+               "\r\n" +
+               "           }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           $output=\" onMouseOver=\\\"return overlib($cmd);\\\" \";\r\n" +
+               "\r\n" +
+               "           $output.=\" onMouseOut=\\\"nd();\\\" \";\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "           return ($output);\r\n" +
+               "\r\n" +
+               "         }\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "         function pover ($text, $title = \"\", $status = \"\") \r\n" +
+               "\r\n" +
+               "         {\r\n" +
+               "\r\n" +
+               "           echo $this->over($text, $title, $status);\r\n" +
+               "\r\n" +
+               "         }\r\n" +
+               "\r\n" +
+               "       }\r\n" +
+               "\r\n" +
+               "?>\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
+               "\r\n" +
                "");
   }
   private void checkPHP(String strEval) {