From c85e2f2f99ea62795e1573e7b5b088315d62c17e Mon Sep 17 00:00:00 2001 From: axelcl Date: Mon, 30 Jan 2006 21:17:44 +0000 Subject: [PATCH] Report "multiple" inheritence as error --- .../phpdt/internal/compiler/parser/Parser.java | 43 +++++++++++++++++-- 1 files changed, 38 insertions(+), 5 deletions(-) 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 d82979c..05333a1 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 @@ -11,6 +11,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import net.sourceforge.phpdt.core.ICompilationUnit; +import net.sourceforge.phpdt.core.IJavaElement; +import net.sourceforge.phpdt.core.IType; +import net.sourceforge.phpdt.core.JavaCore; +import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; import net.sourceforge.phpdt.core.compiler.InvalidInputException; @@ -1275,7 +1280,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI // | T_EXTENDS interface_list if (token == TokenNameextends) { getNextToken(); - interface_list(); + class_list(typeDecl); } } @@ -1284,11 +1289,37 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI // | T_IMPLEMENTS interface_list if (token == TokenNameimplements) { getNextToken(); - interface_list(); + interface_list(typeDecl); } } - private void interface_list() { + private void class_list(TypeDeclaration typeDecl) { + // class_list: + // fully_qualified_class_name + do { + if (token == TokenNameIdentifier) { + char[] ident = scanner.getCurrentIdentifierSource(); + // TODO make this code working better: + // SingleTypeReference ref = ParserUtil.getTypeReference(scanner, + // includesList, ident); + // if (ref != null) { + // typeDecl.superclass = ref; + // } + getNextToken(); + } else { + throwSyntaxError("Classname expected after keyword 'extends'."); + } + if (token == TokenNameCOMMA) { + reportSyntaxError("No multiple inheritence allowed. Expected token 'implements' or '{'."); + getNextToken(); + continue; + } else { + break; + } + } while (true); + } + + private void interface_list(TypeDeclaration typeDecl) { // interface_list: // fully_qualified_class_name // | interface_list ',' fully_qualified_class_name @@ -1296,7 +1327,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI if (token == TokenNameIdentifier) { getNextToken(); } else { - throwSyntaxError("Interface name expected after keyword 'implements'."); + throwSyntaxError("Interfacename expected after keyword 'implements'."); } if (token != TokenNameCOMMA) { return; @@ -3888,8 +3919,10 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI String ext = file.getRawLocation().getFileExtension(); int fileExtensionLength = ext == null ? 0 : ext.length() + 1; + IFile f = PHPFileUtil.createFile(path, project); + impt.tokens = CharOperation.splitOn('/', filePath.toCharArray(), 0, filePath.length() - fileExtensionLength); - impt.setFile(PHPFileUtil.createFile(path, project)); + impt.setFile(f); } catch (Exception e) { // the file is outside of the workspace } -- 1.7.1