import net.sourceforge.phpdt.core.Flags;
import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IField;
-import net.sourceforge.phpdt.core.IImportContainer;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IMethod;
import net.sourceforge.phpdt.core.IType;
/**
* The handle to the compilation unit being parsed
*/
- protected ICompilationUnit fUnit;
+ protected ICompilationUnit unit;
/**
* The info object for the compilation unit being parsed
*/
- protected CompilationUnitElementInfo fUnitInfo;
+ protected CompilationUnitElementInfo unitInfo;
/**
* The import container info - null until created
*/
- protected JavaElementInfo fImportContainerInfo = null;
+ protected JavaElementInfo importContainerInfo = null;
/**
* Hashtable of children elements of the compilation unit.
* the parser. Keys are handles, values are corresponding
* info objects.
*/
- protected Map fNewElements;
+ protected Map newElements;
/**
* Stack of parent scope info objects. The info on the
* For example, when we locate a method, the parent info object
* will be the type the method is contained in.
*/
- protected Stack fInfoStack;
+ protected Stack infoStack;
/**
* Stack of parent handles, corresponding to the info stack. We
* keep both, since info objects do not have back pointers to
* handles.
*/
- protected Stack fHandleStack;
+ protected Stack handleStack;
/**
* The name of the source file being parsed.
protected CompilationUnitStructureRequestor(ICompilationUnit unit, CompilationUnitElementInfo unitInfo, Map newElements)
throws JavaModelException {
- this.fUnit = unit;
- this.fUnitInfo = unitInfo;
- this.fNewElements = newElements;
+ this.unit = unit;
+ this.unitInfo = unitInfo;
+ this.newElements = newElements;
this.fSourceFileName = unit.getElementName().toCharArray();
}
/**
* @see ISourceElementRequestor
*/
- public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
- JavaElementInfo parentInfo = (JavaElementInfo) fInfoStack.peek();
- JavaElement parentHandle= (JavaElement)fHandleStack.peek();
+ public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
+ //, int modifiers) {
+
+ JavaElementInfo parentInfo = (JavaElementInfo) this.infoStack.peek();
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
Assert.isTrue(false); // Should not happen
}
-
+
ICompilationUnit parentCU= (ICompilationUnit)parentHandle;
//create the import container and its info
- ImportContainer importContainer= parentCU.getImportContainer();
- if (fImportContainerInfo == null) {
- fImportContainerInfo= new JavaElementInfo();
- fImportContainerInfo.setIsStructureKnown(true);
+ ImportContainer importContainer= (ImportContainer)parentCU.getImportContainer();
+ if (this.importContainerInfo == null) {
+ this.importContainerInfo= new JavaElementInfo();
+ this.importContainerInfo.setIsStructureKnown(true);
parentInfo.addChild(importContainer);
- fNewElements.put(importContainer, fImportContainerInfo);
+ this.newElements.put(importContainer, this.importContainerInfo);
}
// tack on the '.*' if it is onDemand
}
ImportDeclaration handle = new ImportDeclaration(importContainer, importName);
-// ImportDeclaration handle = new ImportDeclaration(null, importName);
-// resolveDuplicates(handle);
+ resolveDuplicates(handle);
- SourceRefElementInfo info = new SourceRefElementInfo();
+ ImportDeclarationElementInfo info = new ImportDeclarationElementInfo();
info.setSourceRangeStart(declarationStart);
info.setSourceRangeEnd(declarationEnd);
-
- fImportContainerInfo.addChild(handle);
- fNewElements.put(handle, info);
+// info.setFlags(modifiers);
+ info.setName(name); // no trailing * if onDemand
+ info.setOnDemand(onDemand);
+
+ this.importContainerInfo.addChild(handle);
+ this.newElements.put(handle, info);
}
+ /**
+ * @see ISourceElementRequestor
+ */
+
/*
* Table of line separator position. This table is passed once at the end
* of the parse action, so as to allow computation of normalized ranges.
* @see ISourceElementRequestor
*/
public void enterCompilationUnit() {
- fInfoStack = new Stack();
- fHandleStack = new Stack();
- fInfoStack.push(fUnitInfo);
- fHandleStack.push(fUnit);
+ infoStack = new Stack();
+ handleStack = new Stack();
+ infoStack.push(unitInfo);
+ handleStack.push(unit);
}
/**
* @see ISourceElementRequestor
*/
public void enterField(int declarationStart, int modifiers, char[] type, char[] name, int nameSourceStart, int nameSourceEnd) {
- SourceTypeElementInfo parentInfo = (SourceTypeElementInfo) fInfoStack.peek();
- JavaElement parentHandle = (JavaElement) fHandleStack.peek();
+ SourceTypeElementInfo parentInfo = (SourceTypeElementInfo) infoStack.peek();
+ JavaElement parentHandle = (JavaElement) handleStack.peek();
IField handle = null;
if (parentHandle.getElementType() == IJavaElement.TYPE) {
info.setTypeName(type);
parentInfo.addChild(handle);
- fNewElements.put(handle, info);
+ newElements.put(handle, info);
- fInfoStack.push(info);
- fHandleStack.push(handle);
+ infoStack.push(info);
+ handleStack.push(handle);
}
/**
* @see ISourceElementRequestor
boolean isConstructor) {
SourceTypeElementInfo parentInfo = null;
try {
- parentInfo = (SourceTypeElementInfo) fInfoStack.peek();
+ parentInfo = (SourceTypeElementInfo) infoStack.peek();
} catch (ClassCastException e) {
// parentInfo = null;
}
- JavaElement parentHandle = (JavaElement) fHandleStack.peek();
+ JavaElement parentHandle = (JavaElement) handleStack.peek();
IMethod handle = null;
// translate nulls to empty arrays
info.setExceptionTypeNames(exceptionTypes);
if (parentInfo == null) {
- fUnitInfo.addChild(handle);
+ unitInfo.addChild(handle);
} else {
parentInfo.addChild(handle);
}
- fNewElements.put(handle, info);
- fInfoStack.push(info);
- fHandleStack.push(handle);
+ newElements.put(handle, info);
+ infoStack.push(info);
+ handleStack.push(handle);
}
/**
* Common processing for classes and interfaces.
char[] enclosingTypeName = null;
char[] qualifiedName = null;
- JavaElementInfo parentInfo = (JavaElementInfo) fInfoStack.peek();
- JavaElement parentHandle = (JavaElement) fHandleStack.peek();
+ JavaElementInfo parentInfo = (JavaElementInfo) infoStack.peek();
+ JavaElement parentHandle = (JavaElement) handleStack.peek();
IType handle = null;
String nameString = new String(name);
// }
parentInfo.addChild(handle);
- fNewElements.put(handle, info);
+ newElements.put(handle, info);
- fInfoStack.push(info);
- fHandleStack.push(handle);
+ infoStack.push(info);
+ handleStack.push(handle);
}
/**
* @see ISourceElementRequestor
*/
public void exitCompilationUnit(int declarationEnd) {
- fUnitInfo.setSourceLength(declarationEnd + 1);
+ unitInfo.setSourceLength(declarationEnd + 1);
// determine if there were any parsing errors
- fUnitInfo.setIsStructureKnown(!this.hasSyntaxErrors);
+ unitInfo.setIsStructureKnown(!this.hasSyntaxErrors);
}
/**
* @see ISourceElementRequestor
* @see ISourceElementRequestor
*/
public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
- SourceFieldElementInfo info = (SourceFieldElementInfo) fInfoStack.pop();
+ SourceFieldElementInfo info = (SourceFieldElementInfo) infoStack.pop();
info.setSourceRangeEnd(declarationSourceEnd);
// remember initializer source if field is a constant
int flags = info.flags;
Object typeInfo;
if (Flags.isStatic(flags) && Flags.isFinal(flags)
- || ((typeInfo = fInfoStack.peek()) instanceof SourceTypeElementInfo
+ || ((typeInfo = infoStack.peek()) instanceof SourceTypeElementInfo
&& (Flags.isInterface(((SourceTypeElementInfo)typeInfo).flags)))) {
int length = declarationEnd - initializationStart;
if (length > 0) {
}
}
}
- fHandleStack.pop();
+ handleStack.pop();
}
/**
* @see ISourceElementRequestor
* common processing for classes and interfaces
*/
protected void exitMember(int declarationEnd) {
- SourceRefElementInfo info = (SourceRefElementInfo) fInfoStack.pop();
+ SourceRefElementInfo info = (SourceRefElementInfo) infoStack.pop();
info.setSourceRangeEnd(declarationEnd);
- fHandleStack.pop();
+ handleStack.pop();
}
/**
* @see ISourceElementRequestor
* of the handle being created until there is no conflict.
*/
protected void resolveDuplicates(IJavaElement handle) {
- while (fNewElements.containsKey(handle)) {
+ while (newElements.containsKey(handle)) {
JavaElement h = (JavaElement) handle;
h.setOccurrenceCount(h.getOccurrenceCount() + 1);
}