From: khartlage Date: Fri, 18 Jun 2004 09:54:23 +0000 (+0000) Subject: added class const identifiers to outline X-Git-Url: http://git.phpeclipse.com?hp=6a83993ec7dab2a34ee30c72a136e4b266e2b660 added class const identifiers to outline --- 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 e99fb28..1f76111 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 @@ -19,6 +19,7 @@ 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.phpeclipse.builder.IdentifierIndexManager; import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; @@ -69,12 +70,15 @@ public class Parser //extends PHPParserSuperclass //private boolean phpMode; protected int modifiers; protected int modifiersSourceStart; + protected IdentifierIndexManager indexManager; + protected Parser(ProblemReporter problemReporter) { this.problemReporter = problemReporter; this.options = problemReporter.options; this.currentPHPString = 0; // PHPParserSuperclass.fileToParse = fileToParse; this.phpList = null; + this.indexManager = null; this.str = ""; this.token = TokenNameEOF; // this.chIndx = 0; @@ -88,6 +92,7 @@ public class Parser //extends PHPParserSuperclass this.currentPHPString = 0; // PHPParserSuperclass.fileToParse = fileToParse; this.phpList = null; + this.indexManager = null; this.str = ""; this.token = TokenNameEOF; this.phpEnd = false; @@ -219,9 +224,13 @@ public class Parser //extends PHPParserSuperclass scanner.setPHPMode(false); } protected void initialize(boolean phpMode) { + initialize(phpMode, null); + } + protected void initialize(boolean phpMode, IdentifierIndexManager indexManager) { compilationUnit = null; referenceContext = null; includesList = new ArrayList(); + this.indexManager = indexManager; this.str = ""; this.token = TokenNameEOF; // this.chIndx = 0; @@ -851,6 +860,7 @@ public class Parser //extends PHPParserSuperclass } else if (token == TokenNamefunction) { MethodDeclaration methodDecl = new MethodDeclaration(this.compilationUnit.compilationResult); methodDecl.declarationSourceStart = scanner.getCurrentTokenStartPosition(); + methodDecl.modifiers = AccDefault; getNextToken(); functionDefinition(methodDecl); return; @@ -1249,7 +1259,8 @@ public class Parser //extends PHPParserSuperclass getNextToken(); class_variable_declaration(declarationSourceStart, list); } else if (token == TokenNameconst) { - class_constant_declaration(); + checkAndSetModifiers(AccFinal|AccPublic); + class_constant_declaration(declarationSourceStart, list); if (token != TokenNameSEMICOLON) { throwSyntaxError("';' expected after class const declaration."); } @@ -1272,21 +1283,8 @@ public class Parser //extends PHPParserSuperclass class_variable_declaration(declarationSourceStart, list); } } - // if (token == TokenNamefunction) { - // MethodDeclaration methodDecl = new MethodDeclaration( - // this.compilationUnit.compilationResult); - // methodDecl.declarationSourceStart = scanner - // .getCurrentTokenStartPosition(); - // getNextToken(); - // functionDefinition(methodDecl); - // } else if (token == TokenNamevar) { - // getNextToken(); - // classProperty(); - // } else { - // throwSyntaxError("'function' or 'var' expected."); - // } } - private void class_constant_declaration() { + private void class_constant_declaration(int declarationSourceStart, ArrayList list) { // class_constant_declaration ',' T_STRING '=' static_scalar // | T_CONST T_STRING '=' static_scalar if (token != TokenNameconst) { @@ -1298,6 +1296,14 @@ public class Parser //extends PHPParserSuperclass if (token != TokenNameIdentifier) { throwSyntaxError("Identifier expected in class const declaration."); } + FieldDeclaration fieldDeclaration = new FieldDeclaration(scanner.getCurrentIdentifierSource(), scanner + .getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition()); + fieldDeclaration.modifiers = this.modifiers; + fieldDeclaration.declarationSourceStart = declarationSourceStart; + fieldDeclaration.declarationSourceEnd = scanner.getCurrentTokenEndPosition(); + fieldDeclaration.modifiersSourceStart = declarationSourceStart; + // fieldDeclaration.type + list.add(fieldDeclaration); getNextToken(); if (token != TokenNameEQUAL) { throwSyntaxError("'=' expected in class const declaration.");