From 568d1298f0f7c3bb269f00e1ca7cc4261d853961 Mon Sep 17 00:00:00 2001 From: incastrix Date: Sun, 13 Sep 2009 16:47:29 +0000 Subject: [PATCH] Another upgrade to Platform/JDT 3.4.1 --- .../net/sourceforge/phpdt/core/IAnnotatable.java | 43 +++++ .../net/sourceforge/phpdt/core/IAnnotation.java | 86 ++++++++++ .../src/net/sourceforge/phpdt/core/IClassFile.java | 143 ++++++++++++++++ .../sourceforge/phpdt/core/IMemberValuePair.java | 171 ++++++++++++++++++++ .../src/net/sourceforge/phpdt/core/ITypeRoot.java | 98 +++++++++++ 5 files changed, 541 insertions(+), 0 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotatable.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotation.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IClassFile.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IMemberValuePair.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ITypeRoot.java diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotatable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotatable.java new file mode 100644 index 0000000..a29b762 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotatable.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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. + *

+ * This interface is not intended to be implemented by clients. + *

+ * + * @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; +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotation.java new file mode 100644 index 0000000..0d6ce60 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IAnnotation.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * 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. + *

+ * Annotations are obtained using {@link IAnnotatable#getAnnotation(String)}. + *

+ * Note that annotations are not children of their declaring element. + * To get a list of the annotations use {@link IAnnotatable#getAnnotations()}. + *

+ *

+ * This interface is not intended to be implemented or extended by clients. + *

+ * + * @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 @MyAnnot, the name + * is "MyAnnot"), or a qualified name (e.g. for @x. y. MyAnnot, the name is + * "x.y.MyAnnot"). If this annotation is coming from a class file, this is always a fully + * qualified name. + *

Note that the name has been trimmed from its whitespaces. To extract the name as it + * appears in the source, use {@link #getNameRange()}. + *

+ * This is a handle-only method. The annotation may or may not be present. + *

+ * + * @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 "value". + * + * @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 null 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 null 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). + *

+ * 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. + *

+ * This is a handle-only method. The annotation may or may not be present. + *

+ * + * @return the position relative to the order this annotation is defined in the source + */ + int getOccurrenceCount(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IClassFile.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IClassFile.java new file mode 100644 index 0000000..35c2d9f --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IClassFile.java @@ -0,0 +1,143 @@ +/******************************************************************************* + * 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 .class file). + * A class file has a single child of type IType. + * Class file elements need to be opened before they can be navigated. + * If a class file cannot be parsed, its structure remains unknown. Use + * IJavaElement.isStructureKnown to determine whether this is the + * case. + *

+ * Note: IClassFile extends ISourceReference. + * 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. + *

+ * + * @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 null is + * specified. + *

+ * 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. + *

+ *

+ * Once in working copy mode, changes to this working copy or its children are done in memory. + * Only the new buffer is affected. + *

+ *

+ * Using {@link ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor)} on the working copy + * will throw a JavaModelException as a class file is implicetly read-only. + *

+ *

+ * 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)}. + *

+ *

+ * The primary compilation unit of a class file's working copy does not exist if the class file is not + * in working copy mode (classFileWorkingCopy.getPrimary().exists() == false). + *

+ *

+ * The resource of a class file's working copy is null if the class file is in an external jar file. + *

+ * + * @param problemRequestor a requestor which will get notified of problems detected during + * reconciling as they are discovered. The requestor can be set to null indicating + * that the client is not interested in problems. + * @param owner the given {@link WorkingCopyOwner}, or null for the primary owner + * @param monitor a progress monitor used to report progress while opening this compilation unit + * or null 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 null if there is no source associated + * with the class file. + *

+ * The buffer will be automatically initialized with the source of the class file + * upon creation. + *

+ * The only valid operations on this working copy are getBuffer() or getOriginalElement. + * + * @param monitor a progress monitor used to report progress while opening this compilation unit + * or null 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 null 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: + *

+ * @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 true 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 true 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; +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IMemberValuePair.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IMemberValuePair.java new file mode 100644 index 0000000..e1464c1 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/IMemberValuePair.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * 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. + *

+ * This interface is not intended to be implemented or extended by clients. + *

+ * + * @since 3.4 + */ +public interface IMemberValuePair { + /** + * Constant indicating that the value kind is an int represented by + * an instance of {@link Integer}. + */ + int K_INT = 1; + + /** + * Constant indicating that the value kind is a byte represented by + * an instance of {@link Byte}. + */ + int K_BYTE = 2; + + /** + * Constant indicating that the value kind is a short represented by + * an instance of {@link Short}. + */ + int K_SHORT = 3; + + /** + * Constant indicating that the value kind is a char represented by + * an instance of {@link Character}. + */ + int K_CHAR = 4; + + /** + * Constant indicating that the value kind is a float represented by + * an instance of {@link Float}. + */ + int K_FLOAT = 5; + + /** + * Constant indicating that the value kind is a double represented by + * an instance of {@link Double}. + */ + int K_DOUBLE = 6; + + /** + * Constant indicating that the value kind is a long represented by + * an instance of {@link Long}. + */ + int K_LONG = 7; + + /** + * Constant indicating that the value kind is a boolean 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 MyType.class, + * the name is "MyType"), or a qualified name (e.g. for x.y.MyType.MyNestedType.class, + * 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. + *

+ * 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}. + *

+ */ + 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: + * + * If the value kind is unknown, the returned value is always either null, or an + * array containing {@link Object}s and/or nulls 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. + *

+ * If the value kind is {@link #K_UNKNOWN} and the value is not an array, then the + * value is null. + * 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 nulls for + * unknown elements. + * See {@link #K_UNKNOWN} for more details. + *

+ * @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(); + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ITypeRoot.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ITypeRoot.java new file mode 100644 index 0000000..a97f04f --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/ITypeRoot.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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 ICompilationUnit + * or an IClassFile). + * + *

+ * This interface is not intended to be implemented by clients. + *

+ * + * @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 null if no such a type exists. + * + * @return the found primary type of this Java type root, or null 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 + * null 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 null + * 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}). + *

+ * The life time of a shared working copy is as follows: + *

+ * So users of this method must discard exactly once the working copy. + *

+ * 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. + *

+ * When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this + * working copy. + *

+ * 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. + *

+ * 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)}). + *

+ * + * @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 null 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; + +} -- 1.7.1