X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 47d1390..08ba9c4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -48,9 +48,9 @@ import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities; import net.sourceforge.phpdt.internal.compiler.util.Util; -import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil; +import net.sourceforge.phpdt.internal.core.util.PHPFileUtil; import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; -import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil; +//import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -93,10 +93,10 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, this.initializeScanner(); } - public void setFileToParse(IFile fileToParse) { - this.token = TokenNameEOF; - this.initializeScanner(); - } +// public void setFileToParse(IFile fileToParse) { +// this.token = TokenNameEOF; +// this.initializeScanner(); +// } /** * ClassDeclaration Constructor. @@ -106,26 +106,26 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, * Description of Parameter * @see */ - public Parser(IFile fileToParse) { - // if (keywordMap == null) { - // keywordMap = new HashMap(); - // for (int i = 0; i < PHP_KEYWORS.length; i++) { - // keywordMap.put(PHP_KEYWORS[i], new Integer(PHP_KEYWORD_TOKEN[i])); - // } - // } - // this.currentPHPString = 0; - // PHPParserSuperclass.fileToParse = fileToParse; - // this.phpList = null; - this.includesList = null; - // this.str = ""; - this.token = TokenNameEOF; - // this.chIndx = 0; - // this.rowCount = 1; - // this.columnCount = 0; - // this.phpEnd = false; - // getNextToken(); - this.initializeScanner(); - } +// public Parser(IFile fileToParse) { +// // if (keywordMap == null) { +// // keywordMap = new HashMap(); +// // for (int i = 0; i < PHP_KEYWORS.length; i++) { +// // keywordMap.put(PHP_KEYWORS[i], new Integer(PHP_KEYWORD_TOKEN[i])); +// // } +// // } +// // this.currentPHPString = 0; +// // PHPParserSuperclass.fileToParse = fileToParse; +// // this.phpList = null; +// this.includesList = null; +// // this.str = ""; +// this.token = TokenNameEOF; +// // this.chIndx = 0; +// // this.rowCount = 1; +// // this.columnCount = 0; +// // this.phpEnd = false; +// // getNextToken(); +// this.initializeScanner(); +// } public void initializeScanner() { this.scanner = new Scanner( @@ -1397,7 +1397,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, // fully_qualified_class_name do { if (token == TokenNameIdentifier) { - char[] ident = scanner.getCurrentIdentifierSource(); + //char[] ident = scanner.getCurrentIdentifierSource(); // TODO make this code working better: // SingleTypeReference ref = // ParserUtil.getTypeReference(scanner, @@ -1882,10 +1882,10 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, } } - private void optional_class_type() { - // /* empty */ - // | T_STRING - } +// private void optional_class_type() { +// // /* empty */ +// // | T_STRING +// } // private void parameterDeclaration() { // //variable @@ -2013,7 +2013,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, throwSyntaxError("'endif' expected."); } getNextToken(); - if (token != TokenNameSEMICOLON) { + if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) { reportSyntaxError("';' expected after if-statement."); iState.sourceEnd = scanner.getCurrentTokenStartPosition(); } else { @@ -2255,7 +2255,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, throwSyntaxError("'endswitch' expected."); } getNextToken(); - if (token != TokenNameSEMICOLON) { + if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) { throwSyntaxError("';' expected after switch-statement."); } getNextToken(); @@ -2283,7 +2283,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, throwSyntaxError("'endfor' expected."); } getNextToken(); - if (token != TokenNameSEMICOLON) { + if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) { throwSyntaxError("';' expected after for-statement."); } getNextToken(); @@ -2301,7 +2301,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, throwSyntaxError("'endwhile' expected."); } getNextToken(); - if (token != TokenNameSEMICOLON) { + if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) { throwSyntaxError("';' expected after while-statement."); } getNextToken(); @@ -2318,7 +2318,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, throwSyntaxError("'endforeach' expected."); } getNextToken(); - if (token != TokenNameSEMICOLON) { + if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) { throwSyntaxError("';' expected after foreach-statement."); } getNextToken(); @@ -4170,7 +4170,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (path == null) { // SyntaxError: "File: << >> doesn't exist in project." String[] args = { expression.toStringExpression(), - project.getLocation().toString() }; + project.getFullPath().toString() }; problemReporter.phpIncludeNotExistWarning(args, literal.sourceStart, literal.sourceEnd, referenceContext, @@ -4259,17 +4259,17 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, return false; } - private void scalar() { - // scalar: - // T_STRING - // | T_STRING_VARNAME - // | class_constant - // | common_scalar - // | '"' encaps_list '"' - // | '\'' encaps_list '\'' - // | T_START_HEREDOC encaps_list T_END_HEREDOC - throwSyntaxError("Not yet implemented (scalar)."); - } +// private void scalar() { +// // scalar: +// // T_STRING +// // | T_STRING_VARNAME +// // | class_constant +// // | common_scalar +// // | '"' encaps_list '"' +// // | '\'' encaps_list '\'' +// // | T_START_HEREDOC encaps_list T_END_HEREDOC +// throwSyntaxError("Not yet implemented (scalar)."); +// } private void static_scalar() { // static_scalar: /* compile-time evaluated scalars */ @@ -4945,17 +4945,17 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, // return anomaliesDetected; // } // } - protected void pushOnAstLengthStack(int pos) { - try { - astLengthStack[++astLengthPtr] = pos; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = astLengthStack.length; - int[] oldPos = astLengthStack; - astLengthStack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldPos, 0, astLengthStack, 0, oldStackLength); - astLengthStack[astLengthPtr] = pos; - } - } +// protected void pushOnAstLengthStack(int pos) { +// try { +// astLengthStack[++astLengthPtr] = pos; +// } catch (IndexOutOfBoundsException e) { +// int oldStackLength = astLengthStack.length; +// int[] oldPos = astLengthStack; +// astLengthStack = new int[oldStackLength + StackIncrement]; +// System.arraycopy(oldPos, 0, astLengthStack, 0, oldStackLength); +// astLengthStack[astLengthPtr] = pos; +// } +// } protected void pushOnAstStack(ASTNode node) { /* @@ -4991,23 +4991,26 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, protected void consumePackageDeclarationName(IFile file) { // create a package name similar to java package names - String projectPath = ProjectPrefUtil.getDocumentRoot(file.getProject()) - .toString(); - String filePath = file.getRawLocation().toString(); - String ext = file.getRawLocation().getFileExtension(); - int fileExtensionLength = ext == null ? 0 : ext.length() + 1; - ImportReference impt; - char[][] tokens; - if (filePath.startsWith(projectPath)) { + // incastrix + //String projectPath = ProjectPrefUtil.getDocumentRoot(file.getProject()) + // .toString(); + //String filePath = file.getFullPath().toString(); + + String ext = file.getFileExtension(); + int fileExtensionLength = ext == null ? 0 : ext.length() + 1; + ImportReference impt; + char[][] tokens; + + /*if (filePath.startsWith(projectPath)) { tokens = CharOperation.splitOn('/', filePath.toCharArray(), projectPath.length() + 1, filePath.length() - fileExtensionLength); - } else { + } else {*/ String name = file.getName(); tokens = new char[1][]; tokens[0] = name.substring(0, name.length() - fileExtensionLength) .toCharArray(); - } + //} this.compilationUnit.currentPackage = impt = new ImportReference( tokens, new char[0], 0, 0, true);