import java.util.Map;
import java.util.Stack;
-import net.sourceforge.phpdt.internal.core.JavaElement;
-import net.sourceforge.phpdt.internal.core.SourceField;
-import net.sourceforge.phpdt.internal.core.SourceFieldElementInfo;
-import net.sourceforge.phpdt.internal.core.SourceMethod;
-import net.sourceforge.phpdt.internal.core.SourceTypeElementInfo;
-
+import net.sourceforge.phpdt.core.Flags;
import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IField;
import net.sourceforge.phpdt.core.IJavaElement;
/**
* @see ISourceElementRequestor
*/
- //public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
- // JavaElementInfo parentInfo = (JavaElementInfo) fInfoStack.peek();
- // JavaElement parentHandle= (JavaElement)fHandleStack.peek();
- // if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
- // Assert.isTrue(false); // Should not happen
- // }
- //
- // ICompilationUnit parentCU= (ICompilationUnit)parentHandle;
- // //create the import container and its info
- // IImportContainer importContainer= parentCU.getImportContainer();
- // if (fImportContainerInfo == null) {
- // fImportContainerInfo= new JavaElementInfo();
- // fImportContainerInfo.setIsStructureKnown(true);
- // parentInfo.addChild(importContainer);
- // fNewElements.put(importContainer, fImportContainerInfo);
- // }
- //
- // // tack on the '.*' if it is onDemand
- // String importName;
- // if (onDemand) {
- // importName= new String(name) + ".*"; //$NON-NLS-1$
- // } else {
- // importName= new String(name);
- // }
- //
- // ImportDeclaration handle = new ImportDeclaration(importContainer, importName);
- // resolveDuplicates(handle);
- //
- // SourceRefElementInfo info = new SourceRefElementInfo();
- // info.setSourceRangeStart(declarationStart);
- // info.setSourceRangeEnd(declarationEnd);
- //
- // fImportContainerInfo.addChild(handle);
- // fNewElements.put(handle, info);
- //}
+ public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
+ JavaElementInfo parentInfo = (JavaElementInfo) fInfoStack.peek();
+ JavaElement parentHandle= (JavaElement)fHandleStack.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);
+ parentInfo.addChild(importContainer);
+ fNewElements.put(importContainer, fImportContainerInfo);
+ }
+
+ // tack on the '.*' if it is onDemand
+ String importName;
+ if (onDemand) {
+ importName= new String(name) + ".*"; //$NON-NLS-1$
+ } else {
+ importName= new String(name);
+ }
+
+ ImportDeclaration handle = new ImportDeclaration(importContainer, importName);
+// ImportDeclaration handle = new ImportDeclaration(null, importName);
+// resolveDuplicates(handle);
+
+ SourceRefElementInfo info = new SourceRefElementInfo();
+ info.setSourceRangeStart(declarationStart);
+ info.setSourceRangeEnd(declarationEnd);
+
+ fImportContainerInfo.addChild(handle);
+ fNewElements.put(handle, info);
+ }
/*
* 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.
public void exitConstructor(int declarationEnd) {
exitMember(declarationEnd);
}
- ///**
- // * @see ISourceElementRequestor
- // */
- //public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
- // SourceFieldElementInfo info = (SourceFieldElementInfo) fInfoStack.pop();
- // info.setSourceRangeEnd(declarationSourceEnd);
- //
- // // remember initializer source if field is a constant
- // if (initializationStart != -1) {
- // int flags = info.flags;
- // Object typeInfo;
- // if (Flags.isStatic(flags) && Flags.isFinal(flags)
- // || ((typeInfo = fInfoStack.peek()) instanceof SourceTypeElementInfo
- // && (Flags.isInterface(((SourceTypeElementInfo)typeInfo).flags)))) {
- // int length = declarationEnd - initializationStart;
- // if (length > 0) {
- // char[] initializer = new char[length];
- // System.arraycopy(this.parser.scanner.source, initializationStart, initializer, 0, length);
- // info.initializationSource = initializer;
- // }
- // }
- // }
- // fHandleStack.pop();
- //}
+ /**
+ * @see ISourceElementRequestor
+ */
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
+ SourceFieldElementInfo info = (SourceFieldElementInfo) fInfoStack.pop();
+ info.setSourceRangeEnd(declarationSourceEnd);
+
+ // remember initializer source if field is a constant
+ if (initializationStart != -1) {
+ int flags = info.flags;
+ Object typeInfo;
+ if (Flags.isStatic(flags) && Flags.isFinal(flags)
+ || ((typeInfo = fInfoStack.peek()) instanceof SourceTypeElementInfo
+ && (Flags.isInterface(((SourceTypeElementInfo)typeInfo).flags)))) {
+ int length = declarationEnd - initializationStart;
+ if (length > 0) {
+ char[] initializer = new char[length];
+ System.arraycopy(this.parser.scanner.source, initializationStart, initializer, 0, length);
+ info.initializationSource = initializer;
+ }
+ }
+ }
+ fHandleStack.pop();
+ }
/**
* @see ISourceElementRequestor
*/