import net.sourceforge.phpdt.core.IJavaModelMarker;
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.CompilationResult;
+import net.sourceforge.phpdt.internal.compiler.ast.ASTNode;
+import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.ConstructorDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.Initializer;
+import net.sourceforge.phpdt.internal.compiler.ast.MethodDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
-import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.Initializer;
-import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
// int astLength = astStack.length;
// if (noAstNodes.length < astLength){
- // noAstNodes = new AstNode[astLength];
+ // noAstNodes = new ASTNode[astLength];
// //System.out.println("Resized AST stacks : "+ astLength);
//
// }
goForCompilationUnit();
/* scanner initialization */
- scanner.setSource(sourceUnit.getContents());
+ scanner.setSource(sourceUnit, sourceUnit.getContents());
/* unit creation */
referenceContext =
referenceContext = cd;
compilationUnit = unit;
-
+
scanner.resetTo(cd.sourceEnd + 1, cd.declarationSourceEnd);
try {
parse();
referenceContext = type;
compilationUnit = unit;
-
+
scanner.setSource(initializationSource);
scanner.resetTo(0, initializationSource.length - 1);
try {
// field.initialization = expressionStack[expressionPtr];
//
// // mark field with local type if one was found during parsing
- // if ((type.bits & AstNode.HasLocalTypeMASK) != 0) {
- // field.bits |= AstNode.HasLocalTypeMASK;
+ // if ((type.bits & ASTNode.HasLocalTypeMASK) != 0) {
+ // field.bits |= ASTNode.HasLocalTypeMASK;
// }
}
// A P I
referenceContext = type;
compilationUnit = unit;
-
+
scanner.resetTo(ini.sourceStart, ini.sourceEnd); // just on the beginning {
try {
parse();
// ini.block = ((Initializer) astStack[astPtr]).block;
//
// // mark initializer with local type if one was found during parsing
- // if ((type.bits & AstNode.HasLocalTypeMASK) != 0) {
- // ini.bits |= AstNode.HasLocalTypeMASK;
+ // if ((type.bits & ASTNode.HasLocalTypeMASK) != 0) {
+ // ini.bits |= ASTNode.HasLocalTypeMASK;
// }
}
// A P I
goForCompilationUnit();
/* scanner initialization */
- scanner.setSource(sourceUnit.getContents());
+ scanner.setSource(sourceUnit, sourceUnit.getContents());
scanner.resetTo(start, end);
/* unit creation */
referenceContext =
compilationUnit = new CompilationUnitDeclaration(problemReporter, compilationResult, scanner.source.length);
+
/* run automaton */
parse();
} catch (SyntaxError syntaxError) {
}
return parsedUnit;
}
+
+ public void getMethodBodies(CompilationUnitDeclaration unit) {
+ //fill the methods bodies in order for the code to be generated
+
+ if (unit == null) return;
+
+ if (unit.ignoreMethodBodies) {
+ unit.ignoreFurtherInvestigation = true;
+ return;
+ // if initial diet parse did not work, no need to dig into method bodies.
+ }
+
+ if ((unit.bits & ASTNode.HasAllMethodBodies) != 0)
+ return; //work already done ...
+
+ //real parse of the method....
+ char[] contents = unit.compilationResult.compilationUnit.getContents();
+ this.scanner.setSource(contents);
+
+ // save existing values to restore them at the end of the parsing process
+ // see bug 47079 for more details
+ int[] oldLineEnds = this.scanner.lineEnds;
+ int oldLinePtr = this.scanner.linePtr;
+
+ final int[] lineSeparatorPositions = unit.compilationResult.lineSeparatorPositions;
+ this.scanner.lineEnds = lineSeparatorPositions;
+ this.scanner.linePtr = lineSeparatorPositions.length - 1;
+
+// if (this.javadocParser != null && this.javadocParser.checkDocComment) {
+// this.javadocParser.scanner.setSource(contents);
+// }
+ if (unit.types != null) {
+ for (int i = unit.types.size(); --i >= 0;)
+ ((TypeDeclaration)unit.types.get(i)).parseMethod(this, unit);
+ }
+
+ // tag unit has having read bodies
+ unit.bits |= ASTNode.HasAllMethodBodies;
+
+ // this is done to prevent any side effects on the compilation unit result
+ // line separator positions array.
+ this.scanner.lineEnds = oldLineEnds;
+ this.scanner.linePtr = oldLinePtr;
+}
}