--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.core;
+
+/**
+ * Common protocol for Java elements that can be annotated.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ *
+ * @since 3.4
+ */
+public interface IAnnotatable {
+
+ /**
+ * Returns the annotation with the given name declared on this element.
+ * This is a handle-only method. The annotation may or may not exist.
+ *
+ * @param name the given simple name
+ * @return the annotation with the given name declared on this element
+ */
+ IAnnotation getAnnotation(String name);
+
+ /**
+ * Returns the annotations for this element.
+ * Returns an empty array if this method has no annotations.
+ *
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource.
+ * @return the annotations of this element,
+ * in the order declared in the source, or an empty array if none
+ * @since 3.4
+ */
+ IAnnotation[] getAnnotations() throws JavaModelException;
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.core;
+
+/**
+ * Represents an annotation on a package declaration, a type, a method, a field
+ * or a local variable in a compilation unit or a class file.
+ * <p>
+ * Annotations are obtained using {@link IAnnotatable#getAnnotation(String)}.
+ * </p><p>
+ * Note that annotations are not children of their declaring element.
+ * To get a list of the annotations use {@link IAnnotatable#getAnnotations()}.
+ * </p>
+ * <p>
+ * This interface is not intended to be implemented or extended by clients.
+ * </p>
+ *
+ * @since 3.4
+ */
+public interface IAnnotation extends IJavaElement, ISourceReference {
+
+ /**
+ * Returns the name of this annotation. If this annotation is coming from
+ * a compilation unit, this is either a simple name (e.g. for <code>@MyAnnot</code>, the name
+ * is "MyAnnot"), or a qualified name (e.g. for <code>@x. y. MyAnnot</code>, the name is
+ * "x.y.MyAnnot"). If this annotation is coming from a class file, this is always a fully
+ * qualified name.
+ * <p>Note that the name has been trimmed from its whitespaces. To extract the name as it
+ * appears in the source, use {@link #getNameRange()}.
+ * </p><p>
+ * This is a handle-only method. The annotation may or may not be present.
+ * </p>
+ *
+ * @return the name of this annotation
+ */
+ String getElementName();
+
+ /**
+ * Returns the member-value pairs of this annotation. Returns an empty
+ * array if this annotation is a marker annotation. Returns a size-1 array if this
+ * annotation is a single member annotation. In this case, the member
+ * name is always <code>"value"</code>.
+ *
+ * @return the member-value pairs of this annotation
+ * @throws JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+ IMemberValuePair[] getMemberValuePairs() throws JavaModelException;
+
+ /**
+ * Returns the source range of this annotation's name,
+ * or <code>null</code> if this annotation does not have
+ * associated source code (for example, in a binary type).
+ *
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource.
+ * @return the source range of this annotation's name,
+ * or <code>null</code> if this annotation does not have
+ * associated source code (for example, in a binary type)
+ */
+ ISourceRange getNameRange() throws JavaModelException;
+
+ /**
+ * Returns the position relative to the order this annotation is defined in the source.
+ * Numbering starts at 1 (thus the first occurrence is occurrence 1, not occurrence 0).
+ * <p>
+ * Two annotations ann1 and ann2 that are equal (e.g. 2 annotations with the same name on
+ * the same type) can be distinguished using their occurrence counts. If annotation
+ * ann1 appears first in the source, it will have an occurrence count of 1. If annotation
+ * ann2 appears right after annotation ann1, it will have an occurrence count of 2.
+ * </p><p>
+ * This is a handle-only method. The annotation may or may not be present.
+ * </p>
+ *
+ * @return the position relative to the order this annotation is defined in the source
+ */
+ int getOccurrenceCount();
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Represents an entire binary type (single <code>.class</code> file).
+ * A class file has a single child of type <code>IType</code>.
+ * Class file elements need to be opened before they can be navigated.
+ * If a class file cannot be parsed, its structure remains unknown. Use
+ * <code>IJavaElement.isStructureKnown</code> to determine whether this is the
+ * case.
+ * <p>
+ * Note: <code>IClassFile</code> extends <code>ISourceReference</code>.
+ * Source can be obtained for a class file if and only if source has been attached to this
+ * class file. The source associated with a class file is the source code of
+ * the compilation unit it was (nominally) generated from.
+ * </p>
+ *
+ * @see IPackageFragmentRoot#attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, IProgressMonitor)
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+
+public interface IClassFile extends ITypeRoot {
+
+/**
+ * Changes this class file handle into a working copy. A new {@link IBuffer} is
+ * created using the given owner. Uses the primary owner if <code>null</code> is
+ * specified.
+ * <p>
+ * When switching to working copy mode, problems are reported to the given
+ * {@link IProblemRequestor}. Note that once in working copy mode, the given
+ * {@link IProblemRequestor} is ignored. Only the original {@link IProblemRequestor}
+ * is used to report subsequent problems.
+ * </p>
+ * <p>
+ * Once in working copy mode, changes to this working copy or its children are done in memory.
+ * Only the new buffer is affected.
+ * </p>
+ * <p>
+ * Using {@link ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor)} on the working copy
+ * will throw a <code>JavaModelException</code> as a class file is implicetly read-only.
+ * </p>
+ * <p>
+ * If this class file was already in working copy mode, an internal counter is incremented and no
+ * other action is taken on this working copy. To bring this working copy back into the original mode
+ * (where it reflects the underlying resource), {@link ICompilationUnit#discardWorkingCopy} must be call as many
+ * times as {@link #becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)}.
+ * </p>
+ * <p>
+ * The primary compilation unit of a class file's working copy does not exist if the class file is not
+ * in working copy mode (<code>classFileWorkingCopy.getPrimary().exists() == false</code>).
+ * </p>
+ * <p>
+ * The resource of a class file's working copy is <code>null</code> if the class file is in an external jar file.
+ * </p>
+ *
+ * @param problemRequestor a requestor which will get notified of problems detected during
+ * reconciling as they are discovered. The requestor can be set to <code>null</code> indicating
+ * that the client is not interested in problems.
+ * @param owner the given {@link WorkingCopyOwner}, or <code>null</code> for the primary owner
+ * @param monitor a progress monitor used to report progress while opening this compilation unit
+ * or <code>null</code> if no progress should be reported
+ * @return a working copy for this class file
+ * @throws JavaModelException if this compilation unit could not become a working copy.
+ * @see ICompilationUnit#discardWorkingCopy()
+ * @since 3.2
+ * @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead.
+ * Note that if this deprecated method is used, problems will be reported to the given problem requestor
+ * as well as the problem requestor returned by the working copy owner (if not null).
+ */
+ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
+/**
+ * Returns the bytes contained in this class file.
+ *
+ * @return the bytes contained in this class file
+ *
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ * @since 3.3
+ */
+byte[] getBytes() throws JavaModelException;
+/**
+ * Returns the type contained in this class file.
+ * This is a handle-only method. The type may or may not exist.
+ *
+ * @return the type contained in this class file
+ */
+IType getType();
+/**
+ * Returns a working copy on the source associated with this class file using the given
+ * factory to create the buffer, or <code>null</code> if there is no source associated
+ * with the class file.
+ * <p>
+ * The buffer will be automatically initialized with the source of the class file
+ * upon creation.
+ * <p>
+ * The only valid operations on this working copy are <code>getBuffer()</code> or <code>getOriginalElement</code>.
+ *
+ * @param monitor a progress monitor used to report progress while opening this compilation unit
+ * or <code>null</code> if no progress should be reported
+ * @param factory the factory that creates a buffer that is used to get the content of the working copy
+ * or <code>null</code> if the internal factory should be used
+ * @return a a working copy on the source associated with this class file
+ * @exception JavaModelException if the source of this class file can
+ * not be determined. Reasons include:
+ * <ul>
+ * <li> This class file does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * </ul>
+ * @since 2.0
+ * @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead
+ */
+IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws JavaModelException;
+/**
+ * Returns whether this type represents a class. This is not guaranteed to be
+ * instantaneous, as it may require parsing the underlying file.
+ *
+ * @return <code>true</code> if the class file represents a class.
+ *
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+boolean isClass() throws JavaModelException;
+/**
+ * Returns whether this type represents an interface. This is not guaranteed to
+ * be instantaneous, as it may require parsing the underlying file.
+ *
+ * @return <code>true</code> if the class file represents an interface.
+ *
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+boolean isInterface() throws JavaModelException;
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.core;
+
+/**
+ * Represents a member-value pair of an annotation.
+ * The {@link #getValue() value} is represented by an {@link Object}. To get the exact
+ * type of this object, use its {@link #getValueKind() value kind}. If this value is an array,
+ * {@link #getValue()} returns an instance of {@link Object}[] and the value kind returns
+ * the kind of the elements in this array.
+ * <p>
+ * This interface is not intended to be implemented or extended by clients.
+ * </p>
+ *
+ * @since 3.4
+ */
+public interface IMemberValuePair {
+ /**
+ * Constant indicating that the value kind is an <code>int</code> represented by
+ * an instance of {@link Integer}.
+ */
+ int K_INT = 1;
+
+ /**
+ * Constant indicating that the value kind is a <code>byte</code> represented by
+ * an instance of {@link Byte}.
+ */
+ int K_BYTE = 2;
+
+ /**
+ * Constant indicating that the value kind is a <code>short</code> represented by
+ * an instance of {@link Short}.
+ */
+ int K_SHORT = 3;
+
+ /**
+ * Constant indicating that the value kind is a <code>char</code> represented by
+ * an instance of {@link Character}.
+ */
+ int K_CHAR = 4;
+
+ /**
+ * Constant indicating that the value kind is a <code>float</code> represented by
+ * an instance of {@link Float}.
+ */
+ int K_FLOAT = 5;
+
+ /**
+ * Constant indicating that the value kind is a <code>double</code> represented by
+ * an instance of {@link Double}.
+ */
+ int K_DOUBLE = 6;
+
+ /**
+ * Constant indicating that the value kind is a <code>long</code> represented by
+ * an instance of {@link Long}.
+ */
+ int K_LONG = 7;
+
+ /**
+ * Constant indicating that the value kind is a <code>boolean</code> represented by
+ * an instance of {@link Boolean}.
+ */
+ int K_BOOLEAN = 8;
+
+ /**
+ * Constant indicating that the value kind is a {@link String} represented by
+ * the corresponding {@link String}.
+ */
+ int K_STRING = 9;
+
+ /**
+ * Constant indicating that the value kind is an annotation represented by
+ * an instance of {@link IAnnotation}.
+ */
+ int K_ANNOTATION = 10;
+
+ /**
+ * Constant indicating that the value kind is a {@link Class} represented by
+ * the name of the class (i.e. a {@link String}. If the member-value pair is coming from
+ * a compilation unit, this is either a simple name (e.g. for <code>MyType.class</code>,
+ * the name is "MyType"), or a qualified name (e.g. for <code>x.y.MyType.MyNestedType.class</code>,
+ * the name is "x.y.MyType.MyNestedType"). If the member-value pair is coming from a class file, this is
+ * always a fully qualified name.
+ * <p>
+ * Note that one can use {@link IType#resolveType(String)} and e.g.
+ * {@link IJavaProject#findType(String, String, org.eclipse.core.runtime.IProgressMonitor)}
+ * to find the corresponding {@link IType}.
+ * </p>
+ */
+ int K_CLASS = 11;
+
+ /**
+ * Constant indicating that the value is a qualified name represented by a
+ * {@link String}. The qualified name refers to an enum constant or another
+ * compile-time constant if the code is correct (e.g. "MyEnum.FIRST").
+ */
+ int K_QUALIFIED_NAME = 12;
+
+ /**
+ * Constant indicating that the value is a simple name represented by a
+ * {@link String}. The simple name refers to an enum constant or another
+ * compile-time constant if the code is correct (e.g. "FIRST" when there is
+ * a static import for "MyEnum.FIRST").
+ */
+ int K_SIMPLE_NAME = 13;
+
+ /**
+ * Constant indicating that the value kind is unknown at this stage. The value is unknown in the
+ * following cases:
+ * <ul>
+ * <li>the value is an expression that would need to be further analyzed to determine its kind. For
+ * example, in <code>@MyAnnot(1 + 2.3)</code> the kind of the expression "1 + 2.3" is
+ * unknown</li>
+ * <li>the value is an array of size 0, e.g. <code>@MyAnnot({})</code></li>
+ * <li>the value is an array that contains at least one expression that would need to be further
+ * analyzed to determine its kind. For example, in <code>@MyAnnot({3.4, 1 + 2.3})</code>,
+ * the kind of the second element "1 + 2.3" is unknown.</li>
+ * <li>the value is an array that contains heterogeneous values, e.g.
+ * <code>@MyAnnot(1, 2.3, "abc")</code></li>
+ * </ul>
+ * If the value kind is unknown, the returned value is always either <code>null</code>, or an
+ * array containing {@link Object}s and/or <code>null</code>s for unknown elements.
+ */
+ int K_UNKNOWN = 14;
+
+ /**
+ * Returns the member's name of this member-value pair.
+ *
+ * @return the member's name of this member-value pair.
+ */
+ String getMemberName();
+
+ /**
+ * Returns the value of this member-value pair. The type of this value
+ * is function of this member-value pair's {@link #getValueKind() value kind}. It is an
+ * instance of {@link Object}[] if the value is an array.
+ * <p>
+ * If the value kind is {@link #K_UNKNOWN} and the value is not an array, then the
+ * value is <code>null</code>.
+ * If the value kind is {@link #K_UNKNOWN} and the value is an array, then the
+ * value is an array containing {@link Object}s and/or <code>null</code>s for
+ * unknown elements.
+ * See {@link #K_UNKNOWN} for more details.
+ * </p>
+ * @return the value of this member-value pair.
+ */
+ Object getValue();
+
+ /**
+ * Returns the value kind of this member-value pair. This indicates the instance of
+ * the returned {@link #getValue() value}, or the instance of the elements if the value
+ * is an array. The value kind is one of the following constants:
+ * {@link #K_ANNOTATION}, {@link #K_BOOLEAN}, {@link #K_BYTE}, {@link #K_CHAR},
+ * {@link #K_CLASS}, {@link #K_DOUBLE}, {@link #K_FLOAT}, {@link #K_INT}, {@link #K_LONG},
+ * {@link #K_QUALIFIED_NAME}, {@link #K_SIMPLE_NAME}, {@link #K_SHORT}, {@link #K_STRING},
+ * {@link #K_UNKNOWN}.
+ *
+ * @return the value kind of this member-value pair
+ */
+ int getValueKind();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+
+/**
+ * Represents an entire Java type root (either an <code>ICompilationUnit</code>
+ * or an <code>IClassFile</code>).
+ *
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ *
+ * @see ICompilationUnit Note that methods {@link #findPrimaryType()} and {@link #getElementAt(int)}
+ * were already implemented in this interface respectively since version 3.0 and version 1.0.
+ * @see IClassFile Note that method {@link #getWorkingCopy(WorkingCopyOwner, IProgressMonitor)}
+ * was already implemented in this interface since version 3.0.
+ * @since 3.3
+ */
+public interface ITypeRoot extends IJavaElement, IParent, IOpenable, ISourceReference, ICodeAssist {
+
+/**
+ * Finds the primary type of this Java type root (that is, the type with the same name as the
+ * compilation unit, or the type of a class file), or <code>null</code> if no such a type exists.
+ *
+ * @return the found primary type of this Java type root, or <code>null</code> if no such a type exists
+ */
+IType findPrimaryType();
+
+/**
+ * Returns the smallest element within this Java type root that
+ * includes the given source position (that is, a method, field, etc.), or
+ * <code>null</code> if there is no element other than the Java type root
+ * itself at the given position, or if the given position is not
+ * within the source range of the source of this Java type root.
+ *
+ * @param position a source position inside the Java type root
+ * @return the innermost Java element enclosing a given source position or <code>null</code>
+ * if none (excluding the Java type root).
+ * @throws JavaModelException if the Java type root does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+IJavaElement getElementAt(int position) throws JavaModelException;
+
+/**
+ * Returns a shared working copy on this compilation unit or class file using the given working copy owner to create
+ * the buffer. If this is already a working copy of the given owner, the element itself is returned.
+ * This API can only answer an already existing working copy if it is based on the same
+ * original Java type root AND was using the same working copy owner (that is, as defined by {@link Object#equals}).
+ * <p>
+ * The life time of a shared working copy is as follows:
+ * <ul>
+ * <li>The first call to {@link #getWorkingCopy(WorkingCopyOwner, IProgressMonitor)}
+ * creates a new working copy for this element</li>
+ * <li>Subsequent calls increment an internal counter.</li>
+ * <li>A call to {@link ICompilationUnit#discardWorkingCopy()} decrements the internal counter.</li>
+ * <li>When this counter is 0, the working copy is discarded.
+ * </ul>
+ * So users of this method must discard exactly once the working copy.
+ * <p>
+ * Note that the working copy owner will be used for the life time of the shared working copy, that is if the
+ * working copy is closed then reopened, this owner will be used.
+ * The buffer will be automatically initialized with the original's Java type root content upon creation.
+ * <p>
+ * When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this
+ * working copy.
+ * </p><p>
+ * A working copy can be created on a not-yet existing compilation unit.
+ * In particular, such a working copy can then be committed in order to create
+ * the corresponding compilation unit.
+ * </p><p>
+ * Note that possible problems of this working copy are reported using this method only
+ * if the given working copy owner returns a problem requestor for this working copy
+ * (see {@link WorkingCopyOwner#getProblemRequestor(ICompilationUnit)}).
+ * </p>
+ *
+ * @param owner the working copy owner that creates a buffer that is used to get the content
+ * of the working copy
+ * @param monitor a progress monitor used to report progress while opening this compilation unit
+ * or <code>null</code> if no progress should be reported
+ * @throws JavaModelException if the contents of this element can
+ * not be determined.
+ * @return a new working copy of this Java type root using the given owner to create
+ * the buffer, or this Java type root if it is already a working copy
+ */
+ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
+
+}