1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
13 import net.sourceforge.phpdt.core.IBuffer;
14 import net.sourceforge.phpdt.core.ICompilationUnit;
15 import net.sourceforge.phpdt.core.IJavaElement;
16 import net.sourceforge.phpdt.core.IJavaProject;
17 import net.sourceforge.phpdt.core.IPackageFragment;
18 import net.sourceforge.phpdt.core.JavaModelException;
19 import net.sourceforge.phpdt.core.compiler.CharOperation;
21 import org.eclipse.core.resources.IContainer;
22 import org.eclipse.core.resources.IMarker;
23 import org.eclipse.core.resources.IResource;
24 import org.eclipse.core.runtime.IProgressMonitor;
25 import org.eclipse.core.runtime.Path;
28 * @see ICompilationUnit
31 public class CompilationUnit extends Openable implements ICompilationUnit {
33 public static boolean SHARED_WC_VERBOSE = false;
35 // TODO: Remove when we are certain that every client is ready for this fix
36 public static final boolean FIX_BUG25184 = true;
39 * Constructs a handle to a compilation unit with the given name in the
42 * @exception IllegalArgumentException if the name of the compilation unit
43 * does not end with ".java"
45 protected CompilationUnit(IPackageFragment parent, String name) {
46 super(COMPILATION_UNIT, parent, name);
47 // if (!Util.isJavaFileName(name)) {
48 // throw new IllegalArgumentException(org.eclipse.jdt.internal.core.Util.bind("convention.unit.notJavaName")); //$NON-NLS-1$
52 * Accepts the given visitor onto the parsed tree of this compilation unit, after
53 * having runned the name resolution.
54 * The visitor's corresponding <code>visit</code> method is called with the
55 * corresponding parse tree. If the visitor returns <code>true</code>, this method
56 * visits this parse node's members.
58 * @param visitor the visitor
59 * @exception JavaModelException if this method fails. Reasons include:
61 * <li> This element does not exist.</li>
62 * <li> The visitor failed with this exception.</li>
65 //public void accept(IAbstractSyntaxTreeVisitor visitor) throws JavaModelException {
66 // CompilationUnitVisitor.visit(this, visitor);
69 //protected void buildStructure(OpenableElementInfo info, IProgressMonitor monitor) throws JavaModelException {
71 // if (monitor != null && monitor.isCanceled()) return;
73 // // remove existing (old) infos
76 // HashMap newElements = new HashMap(11);
77 // info.setIsStructureKnown(generateInfos(info, monitor, newElements, getResource()));
78 // JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
79 // for (Iterator iter = newElements.keySet().iterator(); iter.hasNext();) {
80 // IJavaElement key = (IJavaElement) iter.next();
81 // Object value = newElements.get(key);
82 // JavaModelManager.getJavaModelManager().putInfo(key, value);
84 // // add the info for this at the end, to ensure that a getInfo cannot reply null in case the LRU cache needs
85 // // to be flushed. Might lead to performance issues.
86 // // see PR 1G2K5S7: ITPJCORE:ALL - NPE when accessing source for a binary type
87 // JavaModelManager.getJavaModelManager().putInfo(this, info);
91 // * @see ICodeAssist#codeComplete(int, ICompletionRequestor)
93 //public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException {
94 // codeComplete(this, isWorkingCopy() ? (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) getOriginalElement() : this, offset, requestor);
97 // * @see ICodeAssist#codeSelect(int, int)
99 //public IJavaElement[] codeSelect(int offset, int length) throws JavaModelException {
100 // return super.codeSelect(this, offset, length);
103 // * @see IWorkingCopy#commit(boolean, IProgressMonitor)
105 //public void commit(boolean force, IProgressMonitor monitor) throws JavaModelException {
106 // throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
109 * @see ISourceManipulation#copy(IJavaElement, IJavaElement, String, boolean, IProgressMonitor)
111 //public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
112 // if (container == null) {
113 // throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
115 // IJavaElement[] elements = new IJavaElement[] {this};
116 // IJavaElement[] containers = new IJavaElement[] {container};
117 // String[] renamings = null;
118 // if (rename != null) {
119 // renamings = new String[] {rename};
121 // getJavaModel().copy(elements, containers, null, renamings, force, monitor);
124 * Returns a new element info for this element.
126 //protected OpenableElementInfo createElementInfo() {
127 // return new CompilationUnitElementInfo();
130 // * @see ICompilationUnit#createImport(String, IJavaElement, IProgressMonitor)
132 //public IImportDeclaration createImport(String name, IJavaElement sibling, IProgressMonitor monitor) throws JavaModelException {
133 // CreateImportOperation op = new CreateImportOperation(name, this);
134 // if (sibling != null) {
135 // op.createBefore(sibling);
137 // runOperation(op, monitor);
138 // return getImport(name);
141 * @see ICompilationUnit#createPackageDeclaration(String, IProgressMonitor)
143 //public IPackageDeclaration createPackageDeclaration(String name, IProgressMonitor monitor) throws JavaModelException {
145 // CreatePackageDeclarationOperation op= new CreatePackageDeclarationOperation(name, this);
146 // runOperation(op, monitor);
147 // return getPackageDeclaration(name);
150 // * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor)
152 //public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException {
154 // //autogenerate this compilation unit
155 // IPackageFragment pkg = (IPackageFragment) getParent();
156 // String source = ""; //$NON-NLS-1$
157 // if (pkg.getElementName().length() > 0) {
158 // //not the default package...add the package declaration
159 // source = "package " + pkg.getElementName() + ";" + org.eclipse.jdt.internal.compiler.util.Util.LINE_SEPARATOR + org.eclipse.jdt.internal.compiler.util.Util.LINE_SEPARATOR; //$NON-NLS-1$ //$NON-NLS-2$
161 // CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, fName, source, force);
162 // runOperation(op, monitor);
164 // CreateTypeOperation op = new CreateTypeOperation(this, content, force);
165 // if (sibling != null) {
166 // op.createBefore(sibling);
168 // runOperation(op, monitor);
169 // return (IType) op.getResultElements()[0];
172 * @see ISourceManipulation#delete(boolean, IProgressMonitor)
174 //public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException {
175 // IJavaElement[] elements= new IJavaElement[] {this};
176 // getJavaModel().delete(elements, force, monitor);
179 * This is not a working copy, do nothing.
181 * @see IWorkingCopy#destroy()
183 public void destroy() {
188 * Returns true if this handle represents the same Java element
189 * as the given handle.
191 * <p>Compilation units must also check working copy state;
193 * @see Object#equals(java.lang.Object)
195 //public boolean equals(Object o) {
196 // return super.equals(o) && !((ICompilationUnit)o).isWorkingCopy();
199 // * @see JavaElement#equalsDOMNode(IDOMNode)
201 //protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException {
202 // String name = getElementName();
203 // if (node.getNodeType() == IDOMNode.COMPILATION_UNIT && name != null ) {
204 // String nodeName = node.getName();
205 // if (nodeName == null) return false;
206 // if (name.equals(nodeName)) {
209 // // iterate through all the types inside the receiver and see if one of them can fit
210 // IType[] types = getTypes();
211 // String typeNodeName = nodeName.substring(0, nodeName.indexOf(".java")); //$NON-NLS-1$
212 // for (int i = 0, max = types.length; i < max; i++) {
213 // if (types[i].getElementName().equals(typeNodeName)) {
222 * @see IWorkingCopy#findElements(IJavaElement)
224 //public IJavaElement[] findElements(IJavaElement element) {
225 // ArrayList children = new ArrayList();
226 // while (element != null && element.getElementType() != IJavaElement.COMPILATION_UNIT) {
227 // children.add(element);
228 // element = element.getParent();
230 // if (element == null) return null;
231 // IJavaElement currentElement = this;
232 // for (int i = children.size()-1; i >= 0; i--) {
233 // IJavaElement child = (IJavaElement)children.get(i);
234 // switch (child.getElementType()) {
235 // case IJavaElement.PACKAGE_DECLARATION:
236 // currentElement = ((ICompilationUnit)currentElement).getPackageDeclaration(child.getElementName());
238 // case IJavaElement.IMPORT_CONTAINER:
239 // currentElement = ((ICompilationUnit)currentElement).getImportContainer();
241 // case IJavaElement.IMPORT_DECLARATION:
242 // currentElement = ((IImportContainer)currentElement).getImport(child.getElementName());
244 // case IJavaElement.TYPE:
245 // if (currentElement.getElementType() == IJavaElement.COMPILATION_UNIT) {
246 // currentElement = ((ICompilationUnit)currentElement).getType(child.getElementName());
248 // currentElement = ((IType)currentElement).getType(child.getElementName());
251 // case IJavaElement.INITIALIZER:
252 // currentElement = ((IType)currentElement).getInitializer(((JavaElement)child).getOccurrenceCount());
254 // case IJavaElement.FIELD:
255 // currentElement = ((IType)currentElement).getField(child.getElementName());
257 // case IJavaElement.METHOD:
258 // return ((IType)currentElement).findMethods((IMethod)child);
262 // if (currentElement != null && currentElement.exists()) {
263 // return new IJavaElement[] {currentElement};
269 * @see IWorkingCopy#findPrimaryType()
271 //public IType findPrimaryType() {
272 // String typeName = Signature.getQualifier(this.getElementName());
273 // IType primaryType= this.getType(typeName);
274 // if (primaryType.exists()) {
275 // return primaryType;
281 * @see IWorkingCopy#findSharedWorkingCopy(IBufferFactory)
283 //public IJavaElement findSharedWorkingCopy(IBufferFactory factory) {
285 // // if factory is null, default factory must be used
286 // if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory();
288 // // In order to be shared, working copies have to denote the same compilation unit
289 // // AND use the same buffer factory.
290 // // Assuming there is a little set of buffer factories, then use a 2 level Map cache.
291 // Map sharedWorkingCopies = JavaModelManager.getJavaModelManager().sharedWorkingCopies;
293 // Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
294 // if (perFactoryWorkingCopies == null) return null;
295 // return (WorkingCopy)perFactoryWorkingCopies.get(this);
298 //protected boolean generateInfos(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
300 // if (getParent() instanceof JarPackageFragment) {
301 // // ignore .java files in jar
302 // throw newNotPresentException();
304 // // put the info now, because getting the contents requires it
305 // JavaModelManager.getJavaModelManager().putInfo(this, info);
306 // CompilationUnitElementInfo unitInfo = (CompilationUnitElementInfo) info;
308 // // generate structure
309 // CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements);
310 // IProblemFactory factory = new DefaultProblemFactory();
311 // SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(getJavaProject().getOptions(true)));
312 // requestor.parser = parser;
313 // parser.parseCompilationUnit(this, false);
314 // if (isWorkingCopy()) {
315 // CompilationUnit original = (CompilationUnit) getOriginalElement();
316 // // might be IResource.NULL_STAMP if original does not exist
317 // unitInfo.fTimestamp = ((IFile) original.getResource()).getModificationStamp();
319 // return unitInfo.isStructureKnown();
323 * @see ICompilationUnit#getAllTypes()
325 //public IType[] getAllTypes() throws JavaModelException {
326 // IJavaElement[] types = getTypes();
328 // ArrayList allTypes = new ArrayList(types.length);
329 // ArrayList typesToTraverse = new ArrayList(types.length);
330 // for (i = 0; i < types.length; i++) {
331 // typesToTraverse.add(types[i]);
333 // while (!typesToTraverse.isEmpty()) {
334 // IType type = (IType) typesToTraverse.get(0);
335 // typesToTraverse.remove(type);
336 // allTypes.add(type);
337 // types = type.getTypes();
338 // for (i = 0; i < types.length; i++) {
339 // typesToTraverse.add(types[i]);
342 // IType[] arrayOfAllTypes = new IType[allTypes.size()];
343 // allTypes.toArray(arrayOfAllTypes);
344 // return arrayOfAllTypes;
347 * @see IMember#getCompilationUnit()
349 public ICompilationUnit getCompilationUnit() {
353 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
355 public char[] getContents() {
357 IBuffer buffer = this.getBuffer();
358 return buffer == null ? null : buffer.getCharacters();
359 } catch (JavaModelException e) {
360 return CharOperation.NO_CHAR;
364 * A compilation unit has a corresponding resource unless it is contained
367 * @see IJavaElement#getCorrespondingResource()
369 //public IResource getCorrespondingResource() throws JavaModelException {
370 // IPackageFragmentRoot root= (IPackageFragmentRoot)getParent().getParent();
371 // if (root.isArchive()) {
374 // return getUnderlyingResource();
378 // * @see ICompilationUnit#getElementAt(int)
380 //public IJavaElement getElementAt(int position) throws JavaModelException {
382 // IJavaElement e= getSourceElementAt(position);
389 public char[] getFileName(){
390 return getElementName().toCharArray();
393 * @see JavaElement#getHandleMementoDelimiter()
395 protected char getHandleMementoDelimiter() {
396 return JavaElement.JEM_COMPILATIONUNIT;
399 * @see ICompilationUnit#getImport(String)
401 //public IImportDeclaration getImport(String name) {
402 // return new ImportDeclaration(getImportContainer(), name);
405 // * @see ICompilationUnit#getImportContainer()
407 //public IImportContainer getImportContainer() {
408 // return new ImportContainer(this);
413 * @see ICompilationUnit#getImports()
415 //public IImportDeclaration[] getImports() throws JavaModelException {
416 // IImportContainer container= getImportContainer();
417 // if (container.exists()) {
418 // IJavaElement[] elements= container.getChildren();
419 // IImportDeclaration[] imprts= new IImportDeclaration[elements.length];
420 // System.arraycopy(elements, 0, imprts, 0, elements.length);
422 // } else if (!exists()) {
423 // throw newNotPresentException();
425 // return new IImportDeclaration[0];
430 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getMainTypeName()
432 public char[] getMainTypeName(){
433 String name= getElementName();
435 name= name.substring(0, name.length() - 5);
436 return name.toCharArray();
439 * Returns <code>null</code>, this is not a working copy.
441 * @see IWorkingCopy#getOriginal(IJavaElement)
443 public IJavaElement getOriginal(IJavaElement workingCopyElement) {
447 * Returns <code>null</code>, this is not a working copy.
449 * @see IWorkingCopy#getOriginalElement()
451 public IJavaElement getOriginalElement() {
455 * @see ICompilationUnit#getPackageDeclaration(String)
457 //public IPackageDeclaration getPackageDeclaration(String name) {
458 // return new PackageDeclaration(this, name);
461 // * @see ICompilationUnit#getPackageDeclarations()
463 //public IPackageDeclaration[] getPackageDeclarations() throws JavaModelException {
464 // ArrayList list = getChildrenOfType(PACKAGE_DECLARATION);
465 // IPackageDeclaration[] array= new IPackageDeclaration[list.size()];
466 // list.toArray(array);
470 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName()
472 public char[][] getPackageName() {
476 * @see IJavaElement#getPath()
478 //public IPath getPath() {
479 // PackageFragmentRoot root = this.getPackageFragmentRoot();
480 // if (root.isArchive()) {
481 // return root.getPath();
483 // return this.getParent().getPath().append(this.getElementName());
487 * @see IJavaElement#getResource()
489 public IResource getResource() {
490 PackageFragmentRoot root = this.getPackageFragmentRoot();
491 if (root.isArchive()) {
492 return root.getResource();
494 return ((IContainer)this.getParent().getResource()).getFile(new Path(this.getElementName()));
499 * @see ISourceReference#getSource()
501 public String getSource() throws JavaModelException {
502 IBuffer buffer = getBuffer();
503 if (buffer == null) return ""; //$NON-NLS-1$
504 return buffer.getContents();
507 * @see ISourceReference#getSourceRange()
509 //public ISourceRange getSourceRange() throws JavaModelException {
510 // return ((CompilationUnitElementInfo) getElementInfo()).getSourceRange();
513 // * @see ICompilationUnit#getType(String)
515 //public IType getType(String name) {
516 // return new SourceType(this, name);
519 // * @see ICompilationUnit#getTypes()
521 //public IType[] getTypes() throws JavaModelException {
522 // ArrayList list = getChildrenOfType(TYPE);
523 // IType[] array= new IType[list.size()];
524 // list.toArray(array);
527 //public IResource getUnderlyingResource() throws JavaModelException {
528 // if (FIX_BUG25184) {
529 // return super.getUnderlyingResource();
531 // return getResource();
535 // * @see IWorkingCopy#getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
537 //public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException {
539 // // if factory is null, default factory must be used
540 // if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory();
542 // JavaModelManager manager = JavaModelManager.getJavaModelManager();
544 // // In order to be shared, working copies have to denote the same compilation unit
545 // // AND use the same buffer factory.
546 // // Assuming there is a little set of buffer factories, then use a 2 level Map cache.
547 // Map sharedWorkingCopies = manager.sharedWorkingCopies;
549 // Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
550 // if (perFactoryWorkingCopies == null){
551 // perFactoryWorkingCopies = new HashMap();
552 // sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
554 // WorkingCopy workingCopy = (WorkingCopy)perFactoryWorkingCopies.get(this);
555 // if (workingCopy != null) {
556 // workingCopy.useCount++;
558 // if (SHARED_WC_VERBOSE) {
559 // System.out.println("Incrementing use count of shared working copy " + workingCopy.toStringWithAncestors()); //$NON-NLS-1$
562 // return workingCopy;
564 // CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, perFactoryWorkingCopies, factory, problemRequestor);
565 // runOperation(op, pm);
566 // return op.getResultElements()[0];
570 * @see IWorkingCopy#getWorkingCopy()
572 //public IJavaElement getWorkingCopy() throws JavaModelException {
573 // return this.getWorkingCopy(null, null, null);
577 * @see IWorkingCopy#getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
579 //public IJavaElement getWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException {
580 // CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, null, factory, problemRequestor);
581 // runOperation(op, pm);
582 // return op.getResultElements()[0];
586 * @see Openable#hasBuffer()
588 protected boolean hasBuffer() {
592 * If I am not open, return true to avoid parsing.
594 * @see IParent#hasChildren()
596 public boolean hasChildren() throws JavaModelException {
598 // return getChildren().length > 0;
605 * Returns false, this is not a working copy.
607 * @see IWorkingCopy#isBasedOn(IResource)
609 public boolean isBasedOn(IResource resource) {
613 * @see IOpenable#isConsistent()
615 //public boolean isConsistent() throws JavaModelException {
616 // return JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().get(this) == null;
619 * @see Openable#isSourceElement()
621 protected boolean isSourceElement() {
625 * @see IWorkingCopy#isWorkingCopy()
627 public boolean isWorkingCopy() {
631 * @see IOpenable#makeConsistent(IProgressMonitor)
633 //public void makeConsistent(IProgressMonitor monitor) throws JavaModelException {
634 // if (!isConsistent()) { // TODO: this code isn't synchronized with regular opening of a working copy
635 // // create a new info and make it the current info
636 // OpenableElementInfo info = createElementInfo();
637 // buildStructure(info, monitor);
642 * @see ISourceManipulation#move(IJavaElement, IJavaElement, String, boolean, IProgressMonitor)
644 //public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
645 // if (container == null) {
646 // throw new IllegalArgumentException(Util.bind("operation.nullContainer")); //$NON-NLS-1$
648 // IJavaElement[] elements= new IJavaElement[] {this};
649 // IJavaElement[] containers= new IJavaElement[] {container};
651 // String[] renamings= null;
652 // if (rename != null) {
653 // renamings= new String[] {rename};
655 // getJavaModel().move(elements, containers, null, renamings, force, monitor);
659 * @see Openable#openBuffer(IProgressMonitor)
661 //protected IBuffer openBuffer(IProgressMonitor pm) throws JavaModelException {
663 // // create buffer - compilation units only use default buffer factory
664 // BufferManager bufManager = getBufferManager();
665 // IBuffer buffer = getBufferFactory().createBuffer(this);
666 // if (buffer == null) return null;
668 // // set the buffer source
669 // if (buffer.getCharacters() == null){
670 // IFile file = (IFile)this.getResource();
671 // if (file == null || !file.exists()) throw newNotPresentException();
672 // buffer.setContents(Util.getResourceContentsAsCharArray(file));
675 // // add buffer to buffer cache
676 // bufManager.addBuffer(buffer);
678 // // listen to buffer changes
679 // buffer.addBufferChangedListener(this);
683 //protected void openParent(IProgressMonitor pm) throws JavaModelException {
684 // if (FIX_BUG25184) {
685 // super.openParent(pm);
688 // super.openParent(pm);
689 // } catch(JavaModelException e){
690 // // allow parent to not exist for compilation units defined outside classpath
691 // if (!e.isDoesNotExist()){
697 //protected boolean parentExists() {
698 // if (FIX_BUG25184) {
699 // return super.parentExists();
701 // return true; // tolerate units outside classpath
706 * @see IWorkingCopy#reconcile()
708 public IMarker[] reconcile() throws JavaModelException {
709 // Reconciling is not supported on non working copies
714 * @see IWorkingCopy#reconcile(boolean, IProgressMonitor)
716 public void reconcile(
717 boolean forceProblemDetection,
718 IProgressMonitor monitor)
719 throws JavaModelException {
720 // Reconciling is not supported on non working copies
724 * @see ISourceManipulation#rename(String, boolean, IProgressMonitor)
726 //public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
727 // if (name == null) {
728 // throw new IllegalArgumentException(Util.bind("operation.nullName")); //$NON-NLS-1$
730 // IJavaElement[] elements= new IJavaElement[] {this};
731 // IJavaElement[] dests= new IJavaElement[] {this.getParent()};
732 // String[] renamings= new String[] {name};
733 // getJavaModel().rename(elements, dests, renamings, force, monitor);
736 * Does nothing - this is not a working copy.
738 * @see IWorkingCopy#restore()
740 public void restore () throws JavaModelException {
743 * @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor)
744 * @deprecated - use codeComplete(int, ICompletionRequestor)
746 //public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException {
748 // if (requestor == null){
749 // codeComplete(offset, (ICompletionRequestor)null);
754 // new ICompletionRequestor(){
755 // public void acceptAnonymousType(char[] superTypePackageName,char[] superTypeName,char[][] parameterPackageNames,char[][] parameterTypeNames,char[][] parameterNames,char[] completionName,int modifiers,int completionStart,int completionEnd, int relevance){
757 // public void acceptClass(char[] packageName, char[] className, char[] completionName, int modifiers, int completionStart, int completionEnd, int relevance) {
758 // requestor.acceptClass(packageName, className, completionName, modifiers, completionStart, completionEnd);
760 // public void acceptError(IProblem error) {
761 // if (true) return; // was disabled in 1.0
764 // IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IJavaModelMarker.TRANSIENT_PROBLEM);
765 // marker.setAttribute(IJavaModelMarker.ID, error.getID());
766 // marker.setAttribute(IMarker.CHAR_START, error.getSourceStart());
767 // marker.setAttribute(IMarker.CHAR_END, error.getSourceEnd() + 1);
768 // marker.setAttribute(IMarker.LINE_NUMBER, error.getSourceLineNumber());
769 // marker.setAttribute(IMarker.MESSAGE, error.getMessage());
770 // marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
771 // requestor.acceptError(marker);
772 // } catch(CoreException e){
775 // public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, char[] typePackageName, char[] typeName, char[] completionName, int modifiers, int completionStart, int completionEnd, int relevance) {
776 // requestor.acceptField(declaringTypePackageName, declaringTypeName, name, typePackageName, typeName, completionName, modifiers, completionStart, completionEnd);
778 // public void acceptInterface(char[] packageName,char[] interfaceName,char[] completionName,int modifiers,int completionStart,int completionEnd, int relevance) {
779 // requestor.acceptInterface(packageName, interfaceName, completionName, modifiers, completionStart, completionEnd);
781 // public void acceptKeyword(char[] keywordName,int completionStart,int completionEnd, int relevance){
782 // requestor.acceptKeyword(keywordName, completionStart, completionEnd);
784 // public void acceptLabel(char[] labelName,int completionStart,int completionEnd, int relevance){
785 // requestor.acceptLabel(labelName, completionStart, completionEnd);
787 // public void acceptLocalVariable(char[] name,char[] typePackageName,char[] typeName,int modifiers,int completionStart,int completionEnd, int relevance){
790 // public void acceptMethod(char[] declaringTypePackageName,char[] declaringTypeName,char[] selector,char[][] parameterPackageNames,char[][] parameterTypeNames,char[][] parameterNames,char[] returnTypePackageName,char[] returnTypeName,char[] completionName,int modifiers,int completionStart,int completionEnd, int relevance){
791 // // skip parameter names
792 // requestor.acceptMethod(declaringTypePackageName, declaringTypeName, selector, parameterPackageNames, parameterTypeNames, returnTypePackageName, returnTypeName, completionName, modifiers, completionStart, completionEnd);
794 // public void acceptMethodDeclaration(char[] declaringTypePackageName,char[] declaringTypeName,char[] selector,char[][] parameterPackageNames,char[][] parameterTypeNames,char[][] parameterNames,char[] returnTypePackageName,char[] returnTypeName,char[] completionName,int modifiers,int completionStart,int completionEnd, int relevance){
797 // public void acceptModifier(char[] modifierName,int completionStart,int completionEnd, int relevance){
798 // requestor.acceptModifier(modifierName, completionStart, completionEnd);
800 // public void acceptPackage(char[] packageName,char[] completionName,int completionStart,int completionEnd, int relevance){
801 // requestor.acceptPackage(packageName, completionName, completionStart, completionEnd);
803 // public void acceptType(char[] packageName,char[] typeName,char[] completionName,int completionStart,int completionEnd, int relevance){
804 // requestor.acceptType(packageName, typeName, completionName, completionStart, completionEnd);
806 // public void acceptVariableName(char[] typePackageName,char[] typeName,char[] name,char[] completionName,int completionStart,int completionEnd, int relevance){
812 * @see JavaElement#rootedAt(IJavaProject)
814 public IJavaElement rootedAt(IJavaProject project) {
817 (IPackageFragment)((JavaElement)fParent).rootedAt(project),