import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Locale;
+import java.util.Map;
import junit.framework.Test;
import junit.framework.TestCase;
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.UnitParser;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblem;
import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
new UnitParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- //new CompilerOptions(getCompilerOptions()),
+ new CompilerOptions(getCompilerOptions()),
new DefaultProblemFactory(Locale.getDefault())));
ICompilationUnit sourceUnit = new CompilationUnit(source, "", null);
new UnitParser(
new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- //new CompilerOptions(getCompilerOptions()),
+ new CompilerOptions(getCompilerOptions()),
new DefaultProblemFactory(Locale.getDefault())));
ICompilationUnit sourceUnit = new CompilationUnit(source, "", null);
super(name);
}
-// protected Map getCompilerOptions() {
-// Map options = new CompilerOptions().getMap();
+ protected Map getCompilerOptions() {
+ Map options = new CompilerOptions().getMap();
// if (COMPLIANCE_1_3.equals(this.complianceLevel)) {
// options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3);
// options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
// options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
// options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
// }
-// return options;
-// }
+ return options;
+ }
public String getName() {
String name = super.getName();
/**
* Testcase for the PHPPartitionScanner
* @author Stefan Langer
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class PHPPartitionScannerTest extends TestCase
{
token = fScanner.nextToken();
junit.framework.Assert.assertEquals(
"PHPComment Partition 1 not recognized!",
- IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.PHP_PHPDOC_COMMENT,
(String) token.getData());
junit.framework.Assert.assertEquals(
"Length of PHPComment Partition 1 not correct!",
token = fScanner.nextToken();
junit.framework.Assert.assertEquals(
"PHP Multilinecomment 2 not recognized!",
- IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.PHP_PHPDOC_COMMENT,
(String) token.getData());
junit.framework.Assert.assertEquals(
"Length of PHP Multilinecomment 2 not correct!",
token = fScanner.nextToken();
junit.framework.Assert.assertEquals(
"PHP Multiline not recognized!",
- IPHPPartitions.PHP_MULTILINE_COMMENT,
+ IPHPPartitions.PHP_PHPDOC_COMMENT,
(String) token.getData());
junit.framework.Assert.assertEquals(
"Length of PHP Multinline not correct!",
* Test the PHP Parser with different PHP snippets
*/
public void testPHPParser() {
- checkPHP("switch ($aItem[ELM_NAME]) {\r\n" +
+ checkPHP("$test=\"{4IP}/{$include}\";");
+ checkPHP("$this->mRegex = \"/{$this->mBaseRegex}/{$case}\";");
+ checkPHP("$schema_create .= \" DEFAULT \'$row[Default]\'\";");
+ checkPHP("$stringVar=\"ein normaler $varText\";");
+ checkPHP("$stringVar=\'ein normaler $varText\';");
+ checkPHP("switch ($aItem[ELM_NAME]) {\r\n" +
" case \'channel\':\r\n" +
" $this->readChannel($aItem);\r\n" +
" break;\r\n" +
checkPHP("try {echo $Stream->readAll(); } catch (Exception $e) {\r\n" +
" // Swallow exception\r\n" +
" }");
- checkPHP("$this->mRegex = \"/{$this->mBaseRegex}/{$case}\";");
- checkPHP("$schema_create .= \" DEFAULT \'$row[Default]\'\";");
+
checkHTML("<?php\n"+
" function overLib($path = \"\") {\n" +
"\n" +
break;
default :
if (token != TokenNameINLINE_HTML) {
- throwSyntaxError("Error in expression (found token '"
- + scanner.toStringAction(token) + "').");
+ if (token > TokenNameKEYWORD) {
+ getNextToken();
+ break;
+ } else {
+ throwSyntaxError("Error in expression (found token '"
+ + scanner.toStringAction(token) + "').");
+ }
}
return;
}
break;
case TokenNameCURLY_OPEN :
getNextToken();
- if (token == TokenNameIdentifier) {
+ if (token == TokenNameIdentifier||token>TokenNameKEYWORD) {
getNextToken();
if (token == TokenNameLBRACKET) {
getNextToken();