From 3cf49886edd6574e85e60f3931b68208a81ca84e Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Tue, 24 Jan 2006 21:12:23 +0000 Subject: [PATCH 1/1] fixed wrong deprecation warning --- .../phpdt/internal/core/CompilationUnit.java | 1017 ++++++++++---------- 1 files changed, 509 insertions(+), 508 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java index 4d7be34..c1d6b1b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/CompilationUnit.java @@ -61,7 +61,7 @@ import org.eclipse.core.runtime.Path; */ public class CompilationUnit extends Openable implements ICompilationUnit, - net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit { + net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit { public WorkingCopyOwner owner; /** * Constructs a handle to a compilation unit with the given name in the specified package for the specified owner @@ -70,8 +70,8 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * if the name of the compilation unit does not end with ".java" */ protected CompilationUnit(PackageFragment parent, String name, WorkingCopyOwner owner) { - super(parent, name); - this.owner = owner; + super(parent, name); + this.owner = owner; } /** @@ -95,16 +95,16 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor) */ public void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { - JavaModelManager manager = JavaModelManager.getJavaModelManager(); - JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(this, false/* don't create */, - true /* record usage */, null/* no problem requestor needed */); - if (perWorkingCopyInfo == null) { - // close cu and its children - close(); + JavaModelManager manager = JavaModelManager.getJavaModelManager(); + JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(this, false/* don't create */, + true /* record usage */, null/* no problem requestor needed */); + if (perWorkingCopyInfo == null) { + // close cu and its children + close(); - BecomeWorkingCopyOperation operation = new BecomeWorkingCopyOperation(this, problemRequestor); - operation.runOperation(monitor); - } + BecomeWorkingCopyOperation operation = new BecomeWorkingCopyOperation(this, problemRequestor); + operation.runOperation(monitor); + } } //protected void buildStructure(OpenableElementInfo info, IProgressMonitor monitor) throws JavaModelException { @@ -128,95 +128,95 @@ public class CompilationUnit extends Openable implements ICompilationUnit, // JavaModelManager.getJavaModelManager().putInfo(this, info); //} protected boolean buildStructure(OpenableElementInfo info, final IProgressMonitor pm, Map newElements, - IResource underlyingResource) throws JavaModelException { - - // check if this compilation unit can be opened - if (!isWorkingCopy()) { // no check is done on root kind or exclusion pattern for working copies - if ( // ((IPackageFragment)getParent()).getKind() == IPackageFragmentRoot.K_BINARY|| - !isValidCompilationUnit() || !underlyingResource.isAccessible()) { - throw newNotPresentException(); - } - } - - // prevents reopening of non-primary working copies (they are closed when they are discarded and should not be reopened) - if (!isPrimary() && getPerWorkingCopyInfo() == null) { - throw newNotPresentException(); - } - - CompilationUnitElementInfo unitInfo = (CompilationUnitElementInfo) info; - - // get buffer contents - IBuffer buffer = getBufferManager().getBuffer(CompilationUnit.this); - if (buffer == null) { - buffer = openBuffer(pm, unitInfo); // open buffer independently from the info, since we are building the info - } - final char[] contents = buffer == null ? null : buffer.getCharacters(); - - // generate structure and compute syntax problems if needed - CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements); - JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = getPerWorkingCopyInfo(); - IJavaProject project = getJavaProject(); - boolean computeProblems = JavaProject.hasJavaNature(project.getProject()) && perWorkingCopyInfo != null - && perWorkingCopyInfo.isActive(); - IProblemFactory problemFactory = new DefaultProblemFactory(); - Map options = project.getOptions(true); - - if (underlyingResource == null) { - underlyingResource = getResource(); - } - - SourceElementParser parser = new SourceElementParser(requestor, problemFactory, - new CompilerOptions(options)); - //, true/*report local declarations*/); - requestor.parser = parser; - CompilationUnitDeclaration unit = parser.parseCompilationUnit( - new net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit() { - public char[] getContents() { - return contents; - } - - public char[] getMainTypeName() { - return CompilationUnit.this.getMainTypeName(); - } - - public char[][] getPackageName() { - return CompilationUnit.this.getPackageName(); - } - - public char[] getFileName() { - return CompilationUnit.this.getFileName(); - } - - public IResource getResource() { - return CompilationUnit.this.getResource(); - } - }, true /* full parse to find local elements */); - - // update timestamp (might be IResource.NULL_STAMP if original does not exist) - - unitInfo.timestamp = ((IFile) underlyingResource).getModificationStamp(); - // compute other problems if needed - CompilationUnitDeclaration compilationUnitDeclaration = null; - try { - if (computeProblems) { - perWorkingCopyInfo.beginReporting(); - compilationUnitDeclaration = CompilationUnitProblemFinder.process(unit, this, contents, parser, this.owner, - perWorkingCopyInfo, problemFactory, false/* don't cleanup cu */, pm); - perWorkingCopyInfo.endReporting(); - } - - // if (info instanceof ASTHolderCUInfo) { - // int astLevel = ((ASTHolderCUInfo) info).astLevel; - // net.sourceforge.phpdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, pm); - // ((ASTHolderCUInfo) info).ast = cu; - // } - } finally { - if (compilationUnitDeclaration != null) { - compilationUnitDeclaration.cleanUp(); - } - } - - return unitInfo.isStructureKnown(); + IResource underlyingResource) throws JavaModelException { + + // check if this compilation unit can be opened + if (!isWorkingCopy()) { // no check is done on root kind or exclusion pattern for working copies + if ( // ((IPackageFragment)getParent()).getKind() == IPackageFragmentRoot.K_BINARY|| + !isValidCompilationUnit() || !underlyingResource.isAccessible()) { + throw newNotPresentException(); + } + } + + // prevents reopening of non-primary working copies (they are closed when they are discarded and should not be reopened) + if (!isPrimary() && getPerWorkingCopyInfo() == null) { + throw newNotPresentException(); + } + + CompilationUnitElementInfo unitInfo = (CompilationUnitElementInfo) info; + + // get buffer contents + IBuffer buffer = getBufferManager().getBuffer(CompilationUnit.this); + if (buffer == null) { + buffer = openBuffer(pm, unitInfo); // open buffer independently from the info, since we are building the info + } + final char[] contents = buffer == null ? null : buffer.getCharacters(); + + // generate structure and compute syntax problems if needed + CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements); + JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = getPerWorkingCopyInfo(); + IJavaProject project = getJavaProject(); + boolean computeProblems = JavaProject.hasJavaNature(project.getProject()) && perWorkingCopyInfo != null + && perWorkingCopyInfo.isActive(); + IProblemFactory problemFactory = new DefaultProblemFactory(); + Map options = project.getOptions(true); + + if (underlyingResource == null) { + underlyingResource = getResource(); + } + + SourceElementParser parser = new SourceElementParser(requestor, problemFactory, + new CompilerOptions(options)); + //, true/*report local declarations*/); + requestor.parser = parser; + CompilationUnitDeclaration unit = parser.parseCompilationUnit( + new net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit() { + public char[] getContents() { + return contents; + } + + public char[] getMainTypeName() { + return CompilationUnit.this.getMainTypeName(); + } + + public char[][] getPackageName() { + return CompilationUnit.this.getPackageName(); + } + + public char[] getFileName() { + return CompilationUnit.this.getFileName(); + } + + public IResource getResource() { + return CompilationUnit.this.getResource(); + } + }, true /* full parse to find local elements */); + + // update timestamp (might be IResource.NULL_STAMP if original does not exist) + + unitInfo.timestamp = ((IFile) underlyingResource).getModificationStamp(); + // compute other problems if needed + CompilationUnitDeclaration compilationUnitDeclaration = null; + try { + if (computeProblems) { + perWorkingCopyInfo.beginReporting(); + compilationUnitDeclaration = CompilationUnitProblemFinder.process(unit, this, contents, parser, this.owner, + perWorkingCopyInfo, problemFactory, false/* don't cleanup cu */, pm); + perWorkingCopyInfo.endReporting(); + } + + // if (info instanceof ASTHolderCUInfo) { + // int astLevel = ((ASTHolderCUInfo) info).astLevel; + // net.sourceforge.phpdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, pm); + // ((ASTHolderCUInfo) info).ast = cu; + // } + } finally { + if (compilationUnitDeclaration != null) { + compilationUnitDeclaration.cleanUp(); + } + } + + return unitInfo.isStructureKnown(); } ///** @@ -236,40 +236,40 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see IWorkingCopy#commit(boolean, IProgressMonitor) */ public void commit(boolean force, IProgressMonitor monitor) throws JavaModelException { - commitWorkingCopy(force, monitor); - // throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this)); + commitWorkingCopy(force, monitor); + // throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this)); } /** * @see ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor) */ public void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException { - CommitWorkingCopyOperation op = new CommitWorkingCopyOperation(this, force); - op.runOperation(monitor); + CommitWorkingCopyOperation op = new CommitWorkingCopyOperation(this, force); + op.runOperation(monitor); } /** * @see ISourceManipulation#copy(IJavaElement, IJavaElement, String, boolean, IProgressMonitor) */ public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) - throws JavaModelException { - if (container == null) { - throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$ - } - IJavaElement[] elements = new IJavaElement[] { this }; - IJavaElement[] containers = new IJavaElement[] { container }; - String[] renamings = null; - if (rename != null) { - renamings = new String[] { rename }; - } - getJavaModel().copy(elements, containers, null, renamings, force, monitor); + throws JavaModelException { + if (container == null) { + throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$ + } + IJavaElement[] elements = new IJavaElement[] { this }; + IJavaElement[] containers = new IJavaElement[] { container }; + String[] renamings = null; + if (rename != null) { + renamings = new String[] { rename }; + } + getJavaModel().copy(elements, containers, null, renamings, force, monitor); } /** * Returns a new element info for this element. */ protected Object createElementInfo() { - return new CompilationUnitElementInfo(); + return new CompilationUnitElementInfo(); } ///** @@ -288,9 +288,9 @@ public class CompilationUnit extends Openable implements ICompilationUnit, */ public IPackageDeclaration createPackageDeclaration(String name, IProgressMonitor monitor) throws JavaModelException { - CreatePackageDeclarationOperation op = new CreatePackageDeclarationOperation(name, this); - runOperation(op, monitor); - return getPackageDeclaration(name); + CreatePackageDeclarationOperation op = new CreatePackageDeclarationOperation(name, this); + runOperation(op, monitor); + return getPackageDeclaration(name); } ///** @@ -321,8 +321,8 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see ISourceManipulation#delete(boolean, IProgressMonitor) */ public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException { - IJavaElement[] elements = new IJavaElement[] { this }; - getJavaModel().delete(elements, force, monitor); + IJavaElement[] elements = new IJavaElement[] { this }; + getJavaModel().delete(elements, force, monitor); } /** @@ -330,20 +330,20 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public void destroy() { - try { - discardWorkingCopy(); - } catch (JavaModelException e) { - e.printStackTrace(); - } + try { + discardWorkingCopy(); + } catch (JavaModelException e) { + e.printStackTrace(); + } } /* * @see ICompilationUnit#discardWorkingCopy */ public void discardWorkingCopy() throws JavaModelException { - // discard working copy and its children - DiscardWorkingCopyOperation op = new DiscardWorkingCopyOperation(this); - op.runOperation(null); + // discard working copy and its children + DiscardWorkingCopyOperation op = new DiscardWorkingCopyOperation(this); + op.runOperation(null); } /** @@ -352,96 +352,96 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see Object#equals(java.lang.Object) */ public boolean equals(Object obj) { - if (!(obj instanceof CompilationUnit)) - return false; - CompilationUnit other = (CompilationUnit) obj; - return this.owner.equals(other.owner) && super.equals(obj); + if (!(obj instanceof CompilationUnit)) + return false; + CompilationUnit other = (CompilationUnit) obj; + return this.owner.equals(other.owner) && super.equals(obj); } /** * @see JavaElement#equalsDOMNode(IDOMNode) */ protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException { - String name = getElementName(); - if (node.getNodeType() == IDOMNode.COMPILATION_UNIT && name != null) { - String nodeName = node.getName(); - if (nodeName == null) - return false; - if (name.equals(nodeName)) { - return true; - } else { - // iterate through all the types inside the receiver and see if one of them can fit - IType[] types = getTypes(); - String typeNodeName = nodeName.substring(0, nodeName.indexOf(".java")); //$NON-NLS-1$ - for (int i = 0, max = types.length; i < max; i++) { - if (types[i].getElementName().equals(typeNodeName)) { - return true; - } - } - } - } - return false; + String name = getElementName(); + if (node.getNodeType() == IDOMNode.COMPILATION_UNIT && name != null) { + String nodeName = node.getName(); + if (nodeName == null) + return false; + if (name.equals(nodeName)) { + return true; + } else { + // iterate through all the types inside the receiver and see if one of them can fit + IType[] types = getTypes(); + String typeNodeName = nodeName.substring(0, nodeName.indexOf(".java")); //$NON-NLS-1$ + for (int i = 0, max = types.length; i < max; i++) { + if (types[i].getElementName().equals(typeNodeName)) { + return true; + } + } + } + } + return false; } /** * @see IWorkingCopy#findElements(IJavaElement) */ public IJavaElement[] findElements(IJavaElement element) { - ArrayList children = new ArrayList(); - while (element != null && element.getElementType() != IJavaElement.COMPILATION_UNIT) { - children.add(element); - element = element.getParent(); - } - if (element == null) - return null; - IJavaElement currentElement = this; - for (int i = children.size() - 1; i >= 0; i--) { - IJavaElement child = (IJavaElement) children.get(i); - switch (child.getElementType()) { - // case IJavaElement.PACKAGE_DECLARATION: - // currentElement = ((ICompilationUnit)currentElement).getPackageDeclaration(child.getElementName()); - // break; - // case IJavaElement.IMPORT_CONTAINER: - // currentElement = ((ICompilationUnit)currentElement).getImportContainer(); - // break; - // case IJavaElement.IMPORT_DECLARATION: - // currentElement = ((IImportContainer)currentElement).getImport(child.getElementName()); - // break; - case IJavaElement.TYPE: - if (currentElement.getElementType() == IJavaElement.COMPILATION_UNIT) { - currentElement = ((ICompilationUnit) currentElement).getType(child.getElementName()); - } else { - currentElement = ((IType) currentElement).getType(child.getElementName()); - } - break; - // case IJavaElement.INITIALIZER: - // currentElement = ((IType)currentElement).getInitializer(((JavaElement)child).getOccurrenceCount()); - // break; - case IJavaElement.FIELD: - currentElement = ((IType) currentElement).getField(child.getElementName()); - break; - case IJavaElement.METHOD: - return ((IType) currentElement).findMethods((IMethod) child); - } - - } - if (currentElement != null && currentElement.exists()) { - return new IJavaElement[] { currentElement }; - } else { - return null; - } + ArrayList children = new ArrayList(); + while (element != null && element.getElementType() != IJavaElement.COMPILATION_UNIT) { + children.add(element); + element = element.getParent(); + } + if (element == null) + return null; + IJavaElement currentElement = this; + for (int i = children.size() - 1; i >= 0; i--) { + IJavaElement child = (IJavaElement) children.get(i); + switch (child.getElementType()) { + // case IJavaElement.PACKAGE_DECLARATION: + // currentElement = ((ICompilationUnit)currentElement).getPackageDeclaration(child.getElementName()); + // break; + // case IJavaElement.IMPORT_CONTAINER: + // currentElement = ((ICompilationUnit)currentElement).getImportContainer(); + // break; + // case IJavaElement.IMPORT_DECLARATION: + // currentElement = ((IImportContainer)currentElement).getImport(child.getElementName()); + // break; + case IJavaElement.TYPE: + if (currentElement.getElementType() == IJavaElement.COMPILATION_UNIT) { + currentElement = ((ICompilationUnit) currentElement).getType(child.getElementName()); + } else { + currentElement = ((IType) currentElement).getType(child.getElementName()); + } + break; + // case IJavaElement.INITIALIZER: + // currentElement = ((IType)currentElement).getInitializer(((JavaElement)child).getOccurrenceCount()); + // break; + case IJavaElement.FIELD: + currentElement = ((IType) currentElement).getField(child.getElementName()); + break; + case IJavaElement.METHOD: + return ((IType) currentElement).findMethods((IMethod) child); + } + + } + if (currentElement != null && currentElement.exists()) { + return new IJavaElement[] { currentElement }; + } else { + return null; + } } /** * @see IWorkingCopy#findPrimaryType() */ public IType findPrimaryType() { - String typeName = Signature.getQualifier(this.getElementName()); - IType primaryType = this.getType(typeName); - if (primaryType.exists()) { - return primaryType; - } - return null; + String typeName = Signature.getQualifier(this.getElementName()); + IType primaryType = this.getType(typeName); + if (primaryType.exists()) { + return primaryType; + } + return null; } /** @@ -450,29 +450,29 @@ public class CompilationUnit extends Openable implements ICompilationUnit, */ public IJavaElement findSharedWorkingCopy(IBufferFactory factory) { - // if factory is null, default factory must be used - if (factory == null) - factory = this.getBufferManager().getDefaultBufferFactory(); + // if factory is null, default factory must be used + if (factory == null) + factory = this.getBufferManager().getDefaultBufferFactory(); - return findWorkingCopy(BufferFactoryWrapper.create(factory)); + return findWorkingCopy(BufferFactoryWrapper.create(factory)); } /** * @see ICompilationUnit#findWorkingCopy(WorkingCopyOwner) */ public ICompilationUnit findWorkingCopy(WorkingCopyOwner workingCopyOwner) { - CompilationUnit cu = new CompilationUnit((PackageFragment) this.parent, getElementName(), workingCopyOwner); - if (workingCopyOwner == DefaultWorkingCopyOwner.PRIMARY) { - return cu; - } else { - // must be a working copy - JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = cu.getPerWorkingCopyInfo(); - if (perWorkingCopyInfo != null) { - return perWorkingCopyInfo.getWorkingCopy(); - } else { - return null; - } - } + CompilationUnit cu = new CompilationUnit((PackageFragment) this.parent, getElementName(), workingCopyOwner); + if (workingCopyOwner == DefaultWorkingCopyOwner.PRIMARY) { + return cu; + } else { + // must be a working copy + JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = cu.getPerWorkingCopyInfo(); + if (perWorkingCopyInfo != null) { + return perWorkingCopyInfo.getWorkingCopy(); + } else { + return null; + } + } } //protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) @@ -506,44 +506,44 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see ICompilationUnit#getAllTypes() */ public IType[] getAllTypes() throws JavaModelException { - IJavaElement[] types = getTypes(); - int i; - ArrayList allTypes = new ArrayList(types.length); - ArrayList typesToTraverse = new ArrayList(types.length); - for (i = 0; i < types.length; i++) { - typesToTraverse.add(types[i]); - } - while (!typesToTraverse.isEmpty()) { - IType type = (IType) typesToTraverse.get(0); - typesToTraverse.remove(type); - allTypes.add(type); - types = type.getTypes(); - for (i = 0; i < types.length; i++) { - typesToTraverse.add(types[i]); - } - } - IType[] arrayOfAllTypes = new IType[allTypes.size()]; - allTypes.toArray(arrayOfAllTypes); - return arrayOfAllTypes; + IJavaElement[] types = getTypes(); + int i; + ArrayList allTypes = new ArrayList(types.length); + ArrayList typesToTraverse = new ArrayList(types.length); + for (i = 0; i < types.length; i++) { + typesToTraverse.add(types[i]); + } + while (!typesToTraverse.isEmpty()) { + IType type = (IType) typesToTraverse.get(0); + typesToTraverse.remove(type); + allTypes.add(type); + types = type.getTypes(); + for (i = 0; i < types.length; i++) { + typesToTraverse.add(types[i]); + } + } + IType[] arrayOfAllTypes = new IType[allTypes.size()]; + allTypes.toArray(arrayOfAllTypes); + return arrayOfAllTypes; } /** * @see IMember#getCompilationUnit() */ public ICompilationUnit getCompilationUnit() { - return this; + return this; } /** * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getContents() */ public char[] getContents() { - try { - IBuffer buffer = this.getBuffer(); - return buffer == null ? null : buffer.getCharacters(); - } catch (JavaModelException e) { - return CharOperation.NO_CHAR; - } + try { + IBuffer buffer = this.getBuffer(); + return buffer == null ? null : buffer.getCharacters(); + } catch (JavaModelException e) { + return CharOperation.NO_CHAR; + } } /** @@ -552,12 +552,12 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see IJavaElement#getCorrespondingResource() */ public IResource getCorrespondingResource() throws JavaModelException { - IPackageFragmentRoot root = (IPackageFragmentRoot) getParent().getParent(); - if (root.isArchive()) { - return null; - } else { - return getUnderlyingResource(); - } + IPackageFragmentRoot root = (IPackageFragmentRoot) getParent().getParent(); + if (root.isArchive()) { + return null; + } else { + return getUnderlyingResource(); + } } /** @@ -565,23 +565,23 @@ public class CompilationUnit extends Openable implements ICompilationUnit, */ public IJavaElement getElementAt(int position) throws JavaModelException { - IJavaElement e = getSourceElementAt(position); - if (e == this) { - return null; - } else { - return e; - } + IJavaElement e = getSourceElementAt(position); + if (e == this) { + return null; + } else { + return e; + } } /** * @see IJavaElement */ public int getElementType() { - return COMPILATION_UNIT; + return COMPILATION_UNIT; } public char[] getFileName() { - return getElementName().toCharArray(); + return getElementName().toCharArray(); } /* * @see JavaElement @@ -647,10 +647,10 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getMainTypeName() */ public char[] getMainTypeName() { - String name = getElementName(); - //remove the .java - name = name.substring(0, name.length() - 5); - return name.toCharArray(); + String name = getElementName(); + //remove the .java + name = name.substring(0, name.length() - 5); + return name.toCharArray(); } /** @@ -658,15 +658,15 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public IJavaElement getOriginal(IJavaElement workingCopyElement) { - // backward compatibility - if (!isWorkingCopy()) - return null; - CompilationUnit cu = (CompilationUnit) workingCopyElement.getAncestor(COMPILATION_UNIT); - if (cu == null || !this.owner.equals(cu.owner)) { - return null; - } + // backward compatibility + if (!isWorkingCopy()) + return null; + CompilationUnit cu = (CompilationUnit) workingCopyElement.getAncestor(COMPILATION_UNIT); + if (cu == null || !this.owner.equals(cu.owner)) { + return null; + } - return workingCopyElement.getPrimaryElement(); + return workingCopyElement.getPrimaryElement(); } /** @@ -674,54 +674,54 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public IJavaElement getOriginalElement() { - // backward compatibility - if (!isWorkingCopy()) - return null; + // backward compatibility + if (!isWorkingCopy()) + return null; - return getPrimaryElement(); + return getPrimaryElement(); } /* * @see ICompilationUnit#getOwner() */ public WorkingCopyOwner getOwner() { - return isPrimary() || !isWorkingCopy() ? null : this.owner; + return isPrimary() || !isWorkingCopy() ? null : this.owner; } /** * @see ICompilationUnit#getPackageDeclaration(String) */ public IPackageDeclaration getPackageDeclaration(String name) { - return new PackageDeclaration(this, name); + return new PackageDeclaration(this, name); } /** * @see ICompilationUnit#getPackageDeclarations() */ public IPackageDeclaration[] getPackageDeclarations() throws JavaModelException { - ArrayList list = getChildrenOfType(PACKAGE_DECLARATION); - IPackageDeclaration[] array = new IPackageDeclaration[list.size()]; - list.toArray(array); - return array; + ArrayList list = getChildrenOfType(PACKAGE_DECLARATION); + IPackageDeclaration[] array = new IPackageDeclaration[list.size()]; + list.toArray(array); + return array; } /** * @see net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit#getPackageName() */ public char[][] getPackageName() { - return null; + return null; } /** * @see IJavaElement#getPath() */ public IPath getPath() { - PackageFragmentRoot root = this.getPackageFragmentRoot(); - if (root.isArchive()) { - return root.getPath(); - } else { - return this.getParent().getPath().append(this.getElementName()); - } + PackageFragmentRoot root = this.getPackageFragmentRoot(); + if (root.isArchive()) { + return root.getPath(); + } else { + return this.getParent().getPath().append(this.getElementName()); + } } /* @@ -729,79 +729,79 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * NOT incremented. */ public JavaModelManager.PerWorkingCopyInfo getPerWorkingCopyInfo() { - return JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(this, false/* don't create */, false/* don't record usage */, - null/* no problem requestor needed */); + return JavaModelManager.getJavaModelManager().getPerWorkingCopyInfo(this, false/* don't create */, false/* don't record usage */, + null/* no problem requestor needed */); } /* * @see ICompilationUnit#getPrimary() */ public ICompilationUnit getPrimary() { - return (ICompilationUnit) getPrimaryElement(true); + return (ICompilationUnit) getPrimaryElement(true); } /* * @see JavaElement#getPrimaryElement(boolean) */ public IJavaElement getPrimaryElement(boolean checkOwner) { - if (checkOwner && isPrimary()) - return this; - return new CompilationUnit((PackageFragment) getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY); + if (checkOwner && isPrimary()) + return this; + return new CompilationUnit((PackageFragment) getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY); } /** * @see IJavaElement#getResource() */ public IResource getResource() { - PackageFragmentRoot root = this.getPackageFragmentRoot(); - if (root.isArchive()) { - return root.getResource(); - } else { - return ((IContainer) this.getParent().getResource()).getFile(new Path(this.getElementName())); - } + PackageFragmentRoot root = this.getPackageFragmentRoot(); + if (root.isArchive()) { + return root.getResource(); + } else { + return ((IContainer) this.getParent().getResource()).getFile(new Path(this.getElementName())); + } } /** * @see ISourceReference#getSource() */ public String getSource() throws JavaModelException { - IBuffer buffer = getBuffer(); - if (buffer == null) - return ""; //$NON-NLS-1$ - return buffer.getContents(); + IBuffer buffer = getBuffer(); + if (buffer == null) + return ""; //$NON-NLS-1$ + return buffer.getContents(); } /** * @see ISourceReference#getSourceRange() */ public ISourceRange getSourceRange() throws JavaModelException { - return ((CompilationUnitElementInfo) getElementInfo()).getSourceRange(); + return ((CompilationUnitElementInfo) getElementInfo()).getSourceRange(); } /** * @see ICompilationUnit#getType(String) */ public IType getType(String name) { - return new SourceType(this, name); + return new SourceType(this, name); } /** * @see ICompilationUnit#getTypes() */ public IType[] getTypes() throws JavaModelException { - ArrayList list = getChildrenOfType(TYPE); - IType[] array = new IType[list.size()]; - list.toArray(array); - return array; + ArrayList list = getChildrenOfType(TYPE); + IType[] array = new IType[list.size()]; + list.toArray(array); + return array; } /** * @see IJavaElement */ public IResource getUnderlyingResource() throws JavaModelException { - if (isWorkingCopy() && !isPrimary()) - return null; - return super.getUnderlyingResource(); + if (isWorkingCopy() && !isPrimary()) + return null; + return super.getUnderlyingResource(); } ///** @@ -861,13 +861,13 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) - throws JavaModelException { + throws JavaModelException { - // if factory is null, default factory must be used - if (factory == null) - factory = this.getBufferManager().getDefaultBufferFactory(); + // if factory is null, default factory must be used + if (factory == null) + factory = this.getBufferManager().getDefaultBufferFactory(); - return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm); + return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm); } /** @@ -875,15 +875,15 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public IJavaElement getWorkingCopy() throws JavaModelException { - return getWorkingCopy(null); + return getWorkingCopy(null); } /** * @see ICompilationUnit#getWorkingCopy(IProgressMonitor) */ public ICompilationUnit getWorkingCopy(IProgressMonitor monitor) throws JavaModelException { - return getWorkingCopy(new WorkingCopyOwner() {/* non shared working copy */ - }, null/* no problem requestor */, monitor); + return getWorkingCopy(new WorkingCopyOwner() {/* non shared working copy */ + }, null/* no problem requestor */, monitor); } /** @@ -891,29 +891,29 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) - throws JavaModelException { - return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, monitor); + throws JavaModelException { + return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, monitor); } /** * @see ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor) */ public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, - IProgressMonitor monitor) throws JavaModelException { - if (!isPrimary()) - return this; + IProgressMonitor monitor) throws JavaModelException { + if (!isPrimary()) + return this; - JavaModelManager manager = JavaModelManager.getJavaModelManager(); + JavaModelManager manager = JavaModelManager.getJavaModelManager(); - CompilationUnit workingCopy = new CompilationUnit((PackageFragment) getParent(), getElementName(), workingCopyOwner); - JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(workingCopy, false/* don't create */, - true/* record usage */, null/* not used since don't create */); - if (perWorkingCopyInfo != null) { - return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above - } - BecomeWorkingCopyOperation op = new BecomeWorkingCopyOperation(workingCopy, problemRequestor); - op.runOperation(monitor); - return workingCopy; + CompilationUnit workingCopy = new CompilationUnit((PackageFragment) getParent(), getElementName(), workingCopyOwner); + JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(workingCopy, false/* don't create */, + true/* record usage */, null/* not used since don't create */); + if (perWorkingCopyInfo != null) { + return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above + } + BecomeWorkingCopyOperation op = new BecomeWorkingCopyOperation(workingCopy, problemRequestor); + op.runOperation(monitor); + return workingCopy; } /** @@ -922,35 +922,35 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see IParent#hasChildren() */ public boolean hasChildren() throws JavaModelException { - // if (isOpen()) { - // return getChildren().length > 0; - // } else { - // return true; - // } - return false; + // if (isOpen()) { + // return getChildren().length > 0; + // } else { + // return true; + // } + return false; } /** * @see Openable#hasBuffer() */ protected boolean hasBuffer() { - return true; + return true; } /* * @see ICompilationUnit#hasResourceChanged() */ public boolean hasResourceChanged() { - if (!isWorkingCopy()) - return false; + if (!isWorkingCopy()) + return false; - // if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the - // cached - // timestamp - Object info = JavaModelManager.getJavaModelManager().getInfo(this); - if (info == null) - return false; - return ((CompilationUnitElementInfo) info).timestamp != getResource().getModificationStamp(); + // if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the + // cached + // timestamp + Object info = JavaModelManager.getJavaModelManager().getInfo(this); + if (info == null) + return false; + return ((CompilationUnitElementInfo) info).timestamp != getResource().getModificationStamp(); } /** @@ -958,18 +958,18 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public boolean isBasedOn(IResource resource) { - if (!isWorkingCopy()) - return false; - if (!getResource().equals(resource)) - return false; - return !hasResourceChanged(); + if (!isWorkingCopy()) + return false; + if (!getResource().equals(resource)) + return false; + return !hasResourceChanged(); } /** * @see IOpenable#isConsistent() */ public boolean isConsistent() { - return JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().get(this) == null; + return JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().get(this) == null; } /** @@ -977,73 +977,73 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see IOpenable */ public boolean isOpen() { - Object info = JavaModelManager.getJavaModelManager().getInfo(this); - return info != null && ((CompilationUnitElementInfo) info).isOpen(); + Object info = JavaModelManager.getJavaModelManager().getInfo(this); + return info != null && ((CompilationUnitElementInfo) info).isOpen(); } public boolean isPrimary() { - return this.owner == DefaultWorkingCopyOwner.PRIMARY; + return this.owner == DefaultWorkingCopyOwner.PRIMARY; } /** * @see Openable#isSourceElement() */ protected boolean isSourceElement() { - return true; + return true; } protected boolean isValidCompilationUnit() { - IPackageFragmentRoot root = getPackageFragmentRoot(); - try { - if (root.getKind() != IPackageFragmentRoot.K_SOURCE) - return false; - } catch (JavaModelException e) { - return false; - } - // IResource resource = getResource(); - // if (resource != null) { - // char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); - // char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); - // if (ProjectPrefUtil.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false; - // } - if (!Util.isValidCompilationUnitName(getElementName())) - return false; - return true; + IPackageFragmentRoot root = getPackageFragmentRoot(); + try { + if (root.getKind() != IPackageFragmentRoot.K_SOURCE) + return false; + } catch (JavaModelException e) { + return false; + } + // IResource resource = getResource(); + // if (resource != null) { + // char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); + // char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); + // if (ProjectPrefUtil.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false; + // } + if (!Util.isValidCompilationUnitName(getElementName())) + return false; + return true; } /* * @see ICompilationUnit#isWorkingCopy() */ public boolean isWorkingCopy() { - // For backward compatibility, non primary working copies are always returning true; in removal - // delta, clients can still check that element was a working copy before being discarded. - return !isPrimary() || getPerWorkingCopyInfo() != null; + // For backward compatibility, non primary working copies are always returning true; in removal + // delta, clients can still check that element was a working copy before being discarded. + return !isPrimary() || getPerWorkingCopyInfo() != null; } /** * @see IOpenable#makeConsistent(IProgressMonitor) */ public void makeConsistent(IProgressMonitor monitor) throws JavaModelException { - makeConsistent(false/* don't create AST */, 0, monitor); + makeConsistent(false/* don't create AST */, 0, monitor); } public Object makeConsistent(boolean createAST, int astLevel, IProgressMonitor monitor) throws JavaModelException { - if (isConsistent()) - return null; - - // create a new info and make it the current info - // (this will remove the info and its children just before storing the new infos) - // if (createAST) { - // ASTHolderCUInfo info = new ASTHolderCUInfo(); - // info.astLevel = astLevel; - // openWhenClosed(info, monitor); - // net.sourceforge.phpdt.core.dom.CompilationUnit result = info.ast; - // info.ast = null; - // return result; - // } else { - openWhenClosed(createElementInfo(), monitor); - return null; - // } + if (isConsistent()) + return null; + + // create a new info and make it the current info + // (this will remove the info and its children just before storing the new infos) + // if (createAST) { + // ASTHolderCUInfo info = new ASTHolderCUInfo(); + // info.astLevel = astLevel; + // openWhenClosed(info, monitor); + // net.sourceforge.phpdt.core.dom.CompilationUnit result = info.ast; + // info.ast = null; + // return result; + // } else { + openWhenClosed(createElementInfo(), monitor); + return null; + // } } //public net.sourceforge.phpdt.core.dom.CompilationUnit makeConsistent(boolean createAST, int astLevel, IProgressMonitor monitor) @@ -1069,18 +1069,18 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @see ISourceManipulation#move(IJavaElement, IJavaElement, String, boolean, IProgressMonitor) */ public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) - throws JavaModelException { - if (container == null) { - throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$ - } - IJavaElement[] elements = new IJavaElement[] { this }; - IJavaElement[] containers = new IJavaElement[] { container }; + throws JavaModelException { + if (container == null) { + throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$ + } + IJavaElement[] elements = new IJavaElement[] { this }; + IJavaElement[] containers = new IJavaElement[] { container }; - String[] renamings = null; - if (rename != null) { - renamings = new String[] { rename }; - } - getJavaModel().move(elements, containers, null, renamings, force, monitor); + String[] renamings = null; + if (rename != null) { + renamings = new String[] { rename }; + } + getJavaModel().move(elements, containers, null, renamings, force, monitor); } ///** @@ -1113,59 +1113,59 @@ public class CompilationUnit extends Openable implements ICompilationUnit, */ protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws JavaModelException { - // create buffer - boolean isWorkingCopy = isWorkingCopy(); - IBuffer buffer = isWorkingCopy ? this.owner.createBuffer(this) : BufferManager.getDefaultBufferManager().createBuffer(this); - if (buffer == null) - return null; - - // set the buffer source - if (buffer.getCharacters() == null) { - if (isWorkingCopy) { - ICompilationUnit original; - if (!isPrimary() - && (original = new CompilationUnit((PackageFragment) getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY)) - .isOpen()) { - buffer.setContents(original.getSource()); - } else { - IFile file = (IFile) getResource(); - if (file == null || !file.exists()) { - // initialize buffer with empty contents - buffer.setContents(CharOperation.NO_CHAR); - } else { - buffer.setContents(Util.getResourceContentsAsCharArray(file)); - } - } - } else { - IFile file = (IFile) this.getResource(); - if (file == null || !file.exists()) - throw newNotPresentException(); - buffer.setContents(Util.getResourceContentsAsCharArray(file)); - } - } - - // add buffer to buffer cache - BufferManager bufManager = getBufferManager(); - bufManager.addBuffer(buffer); - - // listen to buffer changes - buffer.addBufferChangedListener(this); - - return buffer; + // create buffer + boolean isWorkingCopy = isWorkingCopy(); + IBuffer buffer = isWorkingCopy ? this.owner.createBuffer(this) : BufferManager.getDefaultBufferManager().createBuffer(this); + if (buffer == null) + return null; + + // set the buffer source + if (buffer.getCharacters() == null) { + if (isWorkingCopy) { + ICompilationUnit original; + if (!isPrimary() + && (original = new CompilationUnit((PackageFragment) getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY)) + .isOpen()) { + buffer.setContents(original.getSource()); + } else { + IFile file = (IFile) getResource(); + if (file == null || !file.exists()) { + // initialize buffer with empty contents + buffer.setContents(CharOperation.NO_CHAR); + } else { + buffer.setContents(Util.getResourceContentsAsCharArray(file)); + } + } + } else { + IFile file = (IFile) this.getResource(); + if (file == null || !file.exists()) + throw newNotPresentException(); + buffer.setContents(Util.getResourceContentsAsCharArray(file)); + } + } + + // add buffer to buffer cache + BufferManager bufManager = getBufferManager(); + bufManager.addBuffer(buffer); + + // listen to buffer changes + buffer.addBufferChangedListener(this); + + return buffer; } /* * @see Openable#openParent */ protected void openParent(Object childInfo, HashMap newElements, IProgressMonitor pm) throws JavaModelException { - try { - super.openParent(childInfo, newElements, pm); - } catch (JavaModelException e) { - // allow parent to not exist for working copies defined outside classpath - if (!isWorkingCopy() && !e.isDoesNotExist()) { - throw e; - } - } + try { + super.openParent(childInfo, newElements, pm); + } catch (JavaModelException e) { + // allow parent to not exist for working copies defined outside classpath + if (!isWorkingCopy() && !e.isDoesNotExist()) { + throw e; + } + } } /** @@ -1173,15 +1173,15 @@ public class CompilationUnit extends Openable implements ICompilationUnit, * @deprecated */ public IMarker[] reconcile() throws JavaModelException { - reconcile(NO_AST, false/* don't force problem detection */, null/* use primary owner */, null/* no progress monitor */); - return null; + reconcile(NO_AST, false/* don't force problem detection */, null/* use primary owner */, null/* no progress monitor */); + return null; } /** * @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) */ public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws JavaModelException { - reconcile(NO_AST, forceProblemDetection, null/* use primary owner */, monitor); + reconcile(NO_AST, forceProblemDetection, null/* use primary owner */, monitor); } /** @@ -1190,44 +1190,44 @@ public class CompilationUnit extends Openable implements ICompilationUnit, */ //public net.sourceforge.phpdt.core.dom.CompilationUnit reconcile( public Object reconcile(int astLevel, boolean forceProblemDetection, WorkingCopyOwner workingCopyOwner, IProgressMonitor monitor) - throws JavaModelException { - - if (!isWorkingCopy()) - return null; // Reconciling is not supported on non working copies - if (workingCopyOwner == null) - workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY; - - boolean createAST = false; - // if (astLevel == AST.JLS2) { - // // client asking for level 2 AST; these are supported - // createAST = true; - // } else if (astLevel == AST.JLS3) { - // // client asking for level 3 ASTs; these are not supported - // // TODO (jerome) - these should also be supported in 1.5 stream - // createAST = false; - // } else { - // // client asking for no AST (0) or unknown ast level - // // either way, request denied - // createAST = false; - // } - ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, createAST, astLevel, forceProblemDetection, - workingCopyOwner); - op.runOperation(monitor); - // return op.ast; - return null; + throws JavaModelException { + + if (!isWorkingCopy()) + return null; // Reconciling is not supported on non working copies + if (workingCopyOwner == null) + workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY; + + boolean createAST = false; + // if (astLevel == AST.JLS2) { + // // client asking for level 2 AST; these are supported + // createAST = true; + // } else if (astLevel == AST.JLS3) { + // // client asking for level 3 ASTs; these are not supported + // // TODO (jerome) - these should also be supported in 1.5 stream + // createAST = false; + // } else { + // // client asking for no AST (0) or unknown ast level + // // either way, request denied + // createAST = false; + // } + ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, createAST, astLevel, forceProblemDetection, + workingCopyOwner); + op.runOperation(monitor); + // return op.ast; + return null; } /** * @see ISourceManipulation#rename(String, boolean, IProgressMonitor) */ public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException { - if (name == null) { - throw new IllegalArgumentException(Util.bind("operation.nullName")); //$NON-NLS-1$ - } - IJavaElement[] elements = new IJavaElement[] { this }; - IJavaElement[] dests = new IJavaElement[] { this.getParent() }; - String[] renamings = new String[] { name }; - getJavaModel().rename(elements, dests, renamings, force, monitor); + if (name == null) { + throw new IllegalArgumentException(Util.bind("operation.nullName")); //$NON-NLS-1$ + } + IJavaElement[] elements = new IJavaElement[] { this }; + IJavaElement[] dests = new IJavaElement[] { this.getParent() }; + String[] renamings = new String[] { name }; + getJavaModel().rename(elements, dests, renamings, force, monitor); } /* @@ -1235,22 +1235,22 @@ public class CompilationUnit extends Openable implements ICompilationUnit, */ public void restore() throws JavaModelException { - if (!isWorkingCopy()) - return; + if (!isWorkingCopy()) + return; - CompilationUnit original = (CompilationUnit) getOriginalElement(); - IBuffer buffer = this.getBuffer(); - if (buffer == null) - return; - buffer.setContents(original.getContents()); - updateTimeStamp(original); - makeConsistent(null); + CompilationUnit original = (CompilationUnit) getOriginalElement(); + IBuffer buffer = this.getBuffer(); + if (buffer == null) + return; + buffer.setContents(original.getContents()); + updateTimeStamp(original); + makeConsistent(null); } - /** - * @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor) - * @deprecated - use codeComplete(int, ICompletionRequestor) - */ +// /** +// * @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor) +// * @deprecated - use codeComplete(int, ICompletionRequestor) +// */ //public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException { // // if (requestor == null){ @@ -1339,14 +1339,15 @@ public class CompilationUnit extends Openable implements ICompilationUnit, // (IPackageFragment)((JavaElement)parent).rootedAt(project), // name); //} + /* * Assume that this is a working copy */ protected void updateTimeStamp(CompilationUnit original) throws JavaModelException { - long timeStamp = ((IFile) original.getResource()).getModificationStamp(); - if (timeStamp == IResource.NULL_STAMP) { - throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE)); - } - ((CompilationUnitElementInfo) getElementInfo()).timestamp = timeStamp; + long timeStamp = ((IFile) original.getResource()).getModificationStamp(); + if (timeStamp == IResource.NULL_STAMP) { + throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE)); + } + ((CompilationUnitElementInfo) getElementInfo()).timestamp = timeStamp; } } \ No newline at end of file -- 1.7.1