import java.util.ArrayList;
-import net.sourceforge.phpdt.internal.compiler.CompilationResult;
-
import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
-import net.sourceforge.phpdt.internal.compiler.parser.UnitParser;
import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
+import net.sourceforge.phpdt.internal.core.util.CommentRecorderParser;
import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.AnonymousLocalTypeDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.Argument;
* Any (parsing) problem encountered is also provided.
*/
-public class SourceElementParser extends UnitParser {
+public class SourceElementParser extends CommentRecorderParser {//extends UnitParser {
ISourceElementRequestor requestor;
int fieldCount;
int lastFieldEndPosition;
ISourceType sourceType;
boolean reportReferenceInfo;
- char[][] typeNames;
+ char[][] typeNames;
char[][] superTypeNames;
int nestedTypeIndex;
static final char[] JAVA_LANG_OBJECT = "java.lang.Object".toCharArray(); //$NON-NLS-1$
requestor.exitMethod(methodDeclaration.declarationSourceEnd);
}
}
-///*
-//* Update the bodyStart of the corresponding parse node
-//*/
-//public void notifySourceElementRequestor(FieldDeclaration fieldDeclaration) {
-//
-// // range check
-// boolean isInRange =
-// scanner.initialPosition <= fieldDeclaration.declarationSourceStart
-// && scanner.eofPosition >= fieldDeclaration.declarationSourceEnd;
-//
-// if (fieldDeclaration.isField()) {
-// int fieldEndPosition = fieldDeclaration.declarationSourceEnd;
+/*
+* Update the bodyStart of the corresponding parse node
+*/
+public void notifySourceElementRequestor(FieldDeclaration fieldDeclaration) {
+
+ // range check
+ boolean isInRange =
+ scanner.initialPosition <= fieldDeclaration.declarationSourceStart
+ && scanner.eofPosition >= fieldDeclaration.declarationSourceEnd;
+
+ if (fieldDeclaration.isField()) {
+ int fieldEndPosition = fieldDeclaration.declarationSourceEnd;
// if (fieldDeclaration instanceof SourceFieldDeclaration) {
// fieldEndPosition = ((SourceFieldDeclaration) fieldDeclaration).fieldEndPosition;
// if (fieldEndPosition == 0) {
// fieldEndPosition = fieldDeclaration.declarationSourceEnd;
// }
// }
-// if (isInRange) {
-// int modifiers = fieldDeclaration.modifiers;
-// boolean deprecated = (modifiers & AccDeprecated) != 0; // remember deprecation so as to not lose it below
-// requestor.enterField(
-// fieldDeclaration.declarationSourceStart,
-// deprecated ? (modifiers & AccJustFlag) | AccDeprecated : modifiers & AccJustFlag,
-// returnTypeName(fieldDeclaration.type),
-// fieldDeclaration.name,
-// fieldDeclaration.sourceStart,
-// fieldDeclaration.sourceEnd);
-// }
+ if (isInRange) {
+ int modifiers = fieldDeclaration.modifiers;
+ boolean deprecated = (modifiers & AccDeprecated) != 0; // remember deprecation so as to not lose it below
+ requestor.enterField(
+ fieldDeclaration.declarationSourceStart,
+ deprecated ? (modifiers & AccJustFlag) | AccDeprecated : modifiers & AccJustFlag,
+ returnTypeName(fieldDeclaration.type),
+ fieldDeclaration.name,
+ fieldDeclaration.sourceStart,
+ fieldDeclaration.sourceEnd);
+ }
// this.visitIfNeeded(fieldDeclaration);
-// if (isInRange){
+ if (isInRange){
// requestor.exitField(
// // filter out initializations that are not a constant (simple check)
// (fieldDeclaration.initialization == null
// fieldDeclaration.initialization.sourceStart,
// fieldEndPosition,
// fieldDeclaration.declarationSourceEnd);
-// }
-//
-// } else {
+ requestor.exitField(
+ // filter out initializations that are not a constant (simple check)
+ -1,
+ fieldEndPosition,
+ fieldDeclaration.declarationSourceEnd);
+ }
+
+ } else {
// if (isInRange){
// requestor.enterInitializer(
// fieldDeclaration.declarationSourceStart,
// if (isInRange){
// requestor.exitInitializer(fieldDeclaration.declarationSourceEnd);
// }
-// }
-//}
+ }
+}
//public void notifySourceElementRequestor(
// ImportReference importReference,
// boolean isPackage) {
switch (nextDeclarationType) {
case 0 :
fieldIndex++;
-// notifySourceElementRequestor(nextFieldDeclaration);
+ notifySourceElementRequestor(nextFieldDeclaration);
break;
case 1 :
methodIndex++;
// if (compilationUnit == null) return;
// super.reportSyntaxError(act, currentKind,stateStackTop);
//}
-
+protected CompilationUnitDeclaration endParse(int act) {
+// if (sourceType != null) {
+// if (sourceType.isInterface()) {
+// consumeInterfaceDeclaration();
+// } else {
+// consumeClassDeclaration();
+// }
+// }
+ if (compilationUnit != null) {
+ CompilationUnitDeclaration result = super.endParse(act);
+ return result;
+ } else {
+ return null;
+ }
+}
}