jdt core - build notes 3.0 stream
java development tooling core |
Here are the build notes for the Eclipse JDT/Core plug-in project org.eclipse.jdt.core, describing bug resolution and substantial changes in the HEAD branch. This present document covers all changes since Release 2.1 (also see a summary of API changes). Older changes which occurred up to Release 2.1 can be found in build notes R2.1. |
IJavaElementDelta.F_PRIMARY_WORKING_COPY
that signals that a compilation unit has become a
primary working copy, or that a primary working copy has reverted to a compilation unit (i.e. primary working copies are not notified
as being added/removed like other working copies, since the primary unit is only changing mode, also see bug 40028).
IProblem.UnnecessaryCast
, IProblem.UnnecessaryArgumentCast
, IProblem.UnnecessaryInstanceof
).
* COMPILER / Reporting Unnecessary Type Check * When enabled, the compiler will issue an error or a warning when a cast or an instanceof operation * is unnecessary. * - option id: "org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
IProblem.BooleanMethodThrowingException
)
* COMPILER / Reporting Boolean Method Declaring Thrown Exceptions * When enabled, the compiler will issue an error or a warning when a boolean method declaration * is specifying a clause for thrown exceptions. Some of them are predicates, and these should only * return a boolean value and not raise exceptions. * - option id: "org.eclipse.jdt.core.compiler.problem.booleanMethodThrowingException" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
IProblem.IndirectAccessToStaticField
, IProblem.IndirectAccessToStaticMethod
, IProblem.IndirectAccessToStaticType
).
* COMPILER / Reporting Indirect Reference to a Static Member * When enabled, the compiler will issue an error or a warning whenever a static field * or method is accessed in an indirect way. A reference to a static member should * preferably be qualified with its declaring type name. * - option id: "org.eclipse.jdt.core.compiler.problem.indirectStaticAccess" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
Parser#grammar()
, which was hosting the Java grammar as a massive comment.
From now on, the grammar is defined in its own separate file: java_1_4.g
.
JavaCore.newLibraryEntry(...)
. Only
allowing relative empty pathes so as to permit using classpath variables to denote the absence of a source attachment.
WorkingCopyOwner
parameter, that defines the working copies to consider in the operation.
When specifying an owner parameter, all working copies belonging to this owner will implicitly take precedence over primary ones
(without requiring the owner to remember all its working copies, as in 2.1 era). Note that when no owned working copy is found, a primary
unit will be considered instead, and since primary units have a built-in working copy (see ICompilationUnit.becomeWorkingCopy(...)
),
the primary unit may already be in working copy mode (very likely since an editor got opened on it). This means that an owner will already
transparently see unsaved editor contents for all units for which it has no better working copy to contribute.
The following new APIs were added:
AST.parseCompilationUnit(char[] source, String unitName, IJavaProject project, WorkingCopyOwner owner)
AST.parseCompilationUnit(IClassFile classFile, boolean resolveBindings, WorkingCopyOwner owner)
AST.parseCompilationUnit(ICompilationUnit unit, boolean resolveBindings, WorkingCopyOwner owner)
IEvaluationContext.codeComplete(String codeSnippet, int position, ICompletionRequestor requestor, WorkingCopyOwner owner)
IEvaluationContext.codeSelect(String codeSnippet, int offset, int length, WorkingCopyOwner owner)
IDOMCompilationUnit.getCompilationUnit(IPackageFragment parent, WorkingCopyOwner owner)
ICodeAssist.codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner owner)
ICodeAssist.codeSelect(int offset, int length, WorkingCopyOwner owner)
ICompilationUnit.reconcile(boolean forceProblemDetection, WorkingCopyOwner owner, IProgressMonitor monitor)
IJavaProject.findElement(IPath path, WorkingCopyOwner owner)
IJavaProject.findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner)
IJavaProject.findType(String fullyQualifiedName, WorkingCopyOwner owner)
IJavaProject.newTypeHierarchy(IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor)
IJavaProject.newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor)
IPackageFragment.getCompilationUnit(String name, WorkingCopyOwner owner)
IPackageFragment.getCompilationUnits(WorkingCopyOwner owner)
IType.codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, ICompletionRequestor requestor, WorkingCopyOwner owner)
IType.newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)
IType.newTypeHierarchy(IJavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor)
IType.newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor)
IType.resolveType(String typeName, WorkingCopyOwner owner)
JavaCore.create(IFile file, WorkingCopyOwner owner)
JavaCore.create(IResource resource, WorkingCopyOwner owner)
JavaCore.create(String handleIdentifier, WorkingCopyOwner owner)
JavaCore.createCompilationUnitFrom(IFile file, WorkingCopyOwner owner)
JavaCore.getWorkingCopies(WorkingCopyOwner owner)
SearchEngine.SearchEngine(WorkingCopyOwner workingCopyOwner)
SearchEngine.createHierarchyScope(IType type, WorkingCopyOwner owner)
IProblem.SuperfluousSemicolon
).
* COMPILER / Reporting Superfluous Semicolon * When enabled, the compiler will issue an error or a warning if a superfluous semicolon is met. * - option id: "org.eclipse.jdt.core.compiler.problem.superfluousSemicolon" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
ICompilationUnit
to get the primary compilation unit of a working copy
(it replaces IWorkingCopy.getOriginalElement()
):
/** * Returns the primary compilation unit (whose owner is the primary owner) * this working copy was created from, or this compilation unit if this a primary * compilation unit. * Note that the returned primary compilation unit can be in working copy mode. * * @return the primary compilation unit this working copy was created from, * or this compilation unit if it is primary * @since 3.0 */ ICompilationUnit getPrimary();
IJavaElement
to get the primary element of a working copy
element (it replaces IWorkingCopy.getOriginalElement(IJavaElement)
):
/** * Returns the primary element (whose compilation unit is the primary compilation unit) * this working copy element was created from, or this element if it is a descendant of a * primary compilation unit or if it is not a descendant of a working copy (e.g. it is a * binary member). * The returned element may or may not exist. * * @return the primary element this working copy element was created from, or this * element. * @since 3.0 */ IJavaElement getPrimaryElement();
NOTE: This version got backed out due to severe regression (see 38951 NPE in editor while saving contents). Until subsequent version is made available (see above), integration builds will revert to previous version (v_357).
JavaCore.newLibraryEntry(...)
will now allow an empty source attachment (new Path("")
) to
be equivalent to no source attachment (i.e. null
). This adjustment is made necessary for
library entries generated from classpath variables which cannot be set to null
. Also see
bug 38531.
* @param sourceAttachmentPath the absolute path of the corresponding source archive or folder, * ornull
if none. Note, since 3.0, an empty path is allowed to denote no source attachment. * and will be automatically converted tonull
.
IJavaProject#forceClasspathReload(IProgressMonitor)
to force reload of .classpath
file
before next automatic update occurs.
/** * Force the project to reload its.classpath
file from disk and update the classpath accordingly. * Usually, a change to the.classpath
file is automatically noticed and reconciled at the next * resource change notification event. If required to consider such a change prior to the next automatic * refresh, then this functionnality should be used to trigger a refresh. In particular, if a change to the file is performed, * during an operation where this change needs to be reflected before the operation ends, then an explicit refresh is * necessary. * * @param monitor a progress monitor for reporting operation progress * @exception JavaModelException if the classpath could not be updated. Reasons * include: * - This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
CPE_PROJECT
refers to this project (INVALID_PATH)
* - This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
* - The output location path refers to a location not contained in this project (PATH_OUTSIDE_PROJECT
)
* - The output location path is not an absolute path (RELATIVE_PATH
)
* - The output location path is nested inside a package fragment root of this project (INVALID_PATH
)
* - The classpath is being modified during resource change event notification (CORE_EXCEPTION)
* @since 3.0
*/
ICompilationUnit
:
/** * Changes this compilation unit handle into a working copy. A new IBuffer is * created using this compilation unit handle's owner. Uses the primary owner is none was * specified when this compilation unit handle was created. * * When switching to working copy mode, problems are reported to given * IProblemRequestor. * * Once in working copy mode, changes to this compilation unit or its children are done in memory. * Only the new buffer is affected. Using commitWorkingCopy(boolean, IProgressMonitor) * will bring the underlying resource in sync with this compilation unit. * * If this compilation unit was already in working copy mode, an internal counter is incremented and no * other action is taken on this compilation unit. To bring this compilation unit back into the original mode * (where it reflects the underlying resource), discardWorkingCopy must be call as many * times as becomeWorkingCopy. * * @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 monitor a progress monitor used to report progress while opening this compilation unit * or null if no progress should be reported * @exception JavaModelException if this compilation unit could not become a working copy. * @see discardWorkingCopy * @since 3.0 */ void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException;
/** * Commits the contents of this working copy to its underlying resource. * * It is possible that the contents of the original resource have changed * since this working copy was created, in which case there is an update conflict. * The value of the force parameter effects the resolution of * such a conflict: * - true - in this case the contents of this working copy are applied to * the underlying resource even though this working copy was created * before a subsequent change in the resource * - false - in this case a JavaModelException is thrown * * Since 2.1, 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. * * @param force a flag to handle the cases when the contents of the original resource have changed * since this working copy was created * @param monitor the given progress monitor * @exception JavaModelException if this working copy could not commit. Reasons include: * - A CoreException occurred while updating an underlying resource * - This element is not a working copy (INVALID_ELEMENT_TYPES) * - A update conflict (described above) (UPDATE_CONFLICT) * @since 3.0 */ void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException;
/** * Changes this compilation unit in working copy mode back to its original mode. * * This has no effect if this compilation unit was not in working copy mode. * * If becomeWorkingCopy was called several times on this * compilation unit, discardWorkingCopy must be called as * many times before it switches back to the original mode. * * @see becomeWorkingCopy * @exception JavaModelException if this working copy could not return in its original mode. * @since 3.0 */ void discardWorkingCopy() throws JavaModelException;
/** * Returns the working copy owner of this working copy. * Returns null if it is not a working copy or if it has no owner. * * @return WorkingCopyOwner the owner of this working copy or null * @since 3.0 */ WorkingCopyOwner getOwner();
/** * Returns a new working copy of this element if this element is not * a working copy, or this element if this element is already a working copy. * * Note: if intending to share a working copy amongst several clients, then * getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor) * should be used instead. * * When the working copy instance is created, an ADDED IJavaElementDelta is * reported on this working copy. * * Since 2.1, 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. * * @param monitor a progress monitor used to report progress while opening this compilation unit * or null if no progress should be reported * @exception JavaModelException if the contents of this element can * not be determined. * @return a new working copy of this element if this element is not * a working copy, or this element if this element is already a working copy * @since 3.0 */ ICompilationUnit getWorkingCopy(IProgressMonitor monitor) throws JavaModelException;
/** * Returns a shared working copy on this element using the given working copy owner to create * the buffer, or this element if this element is already a working copy. * This API can only answer an already existing working copy if it is based on the same * original compilation unit AND was using the same working copy owner (that is, as defined by Object.equals). * * The life time of a shared working copy is as follows: * - The first call to getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor) * creates a new working copy for this element * - Subsequent calls increment an internal counter. * - A call to discardWorkingCopy() decrements the internal counter. * - When this counter is 0, the working copy is discarded. * * 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 this 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 compilation unit content * upon creation. * * When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this * working copy. * * Since 2.1, 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. * * @param owner the working copy owner that creates a buffer that is used to get the content * of the working copy * @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 monitor a progress monitor used to report progress while opening this compilation unit * or null if no progress should be reported * @exception JavaModelException if the contents of this element can * not be determined. * @return a new working copy of this element using the given factory to create * the buffer, or this element if this element is already a working copy * @since 3.0 */ ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException;
IBufferFactory
:
/** * The owner of an ICompilationUnit handle in working copy mode. * An owner is used to identify a working copy and to create its buffer. * * @see ICompilationUnit#becomeWorkingCopy * @see ICompilationUnit#discardWorkingCopy * @since 3.0 */ public abstract class WorkingCopyOwner { /** * Creates a buffer for the given working copy. * The new buffer will be initialized with the contents of the underlying file * if and only if it was not already initialized by the compilation owner (a buffer is * uninitialized if its content is null). * * @param workingCopy the working copy of the buffer * @return IBuffer the created buffer for the given working copy * @see IBuffer */ public IBuffer createBuffer(ICompilationUnit workingCopy) { ... } }The intent for the primary owner is to use a buffer factory that would be provided by the org.eclipse.text infractructure. This infrastructure not being ready yet, in the meantime one can change the primary owner's
IBufferFactory
using the following internal API:
org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner.PRIMARY.factory = ...;
JavaCore
optional problem to detect incompatible required binaries, so as to flag situations where
some prerequisite binaries are required a JRE level higher than the project target platform; i.e. compiling against 1.4 libraries
when deploying for 1.1 platform is likely unwanted.
* JAVACORE / Reporting Incompatible JDK Level for Required Binaries * Indicate the severity of the problem reported when a project prerequisites another project * or library with an incompatible target JDK level (e.g. project targeting 1.1 vm, but compiled against 1.4 libraries). * - option id: "org.eclipse.jdt.core.incompatibleJDKLevel" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
"ignore"
.
"ignore"
.
* COMPILER / Reporting Possible Accidental Boolean Assignment * When enabled, the compiler will issue an error or a warning if a boolean assignment is acting as the condition * of a control statement (where it probably was meant to be a boolean comparison). * - option id: "org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment" * - possible values: { "error", "warning", "ignore" } * - default: "warning"
* COMPILER / Reporting Local Variable Declaration Hiding another Variable * When enabled, the compiler will issue an error or a warning whenever a local variable * declaration is hiding some field or local variable (either locally, inherited or defined in enclosing type). * - option id: "org.eclipse.jdt.core.compiler.problem.localVariableHiding" * - possible values: { "error", "warning", "ignore" } * - default: "warning" * * COMPILER / Reporting Field Declaration Hiding another Variable * When enabled, the compiler will issue an error or a warning whenever a field * declaration is hiding some field or local variable (either locally, inherited or defined in enclosing type). * - option id: "org.eclipse.jdt.core.compiler.problem.fieldHiding" * - possible values: { "error", "warning", "ignore" } * - default: "warning" * * COMPILER / Reporting Special Parameter Hiding another Field * When enabled, the compiler will signal cases where a constructor or setter method parameter declaration * is hiding some field (either locally, inherited or defined in enclosing type). * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.localVariableHiding". * - option id: "org.eclipse.jdt.core.compiler.problem.specialParameterHidingField" * - possible values: { "enabled", "disabled" } * - default: "disabled"