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 R3_0_maintenance branch.
This present document covers all changes since Release 2.1 (also see a summary of API changes).
Maintenance of previous releases of JDT/Core is performed in parallel branches: R2.1.x, R2.0.x, R1.0.x. |
* COMPILER / Reporting Empty Statements and Unnecessary Semicolons * When enabled, the compiler will issue an error or a warning if an empty statement or a * unnecessary semicolon is encountered. * - option id: "org.eclipse.jdt.core.compiler.problem.emptyStatement" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
/** * Adds the given listener for POST_CHANGE resource change events to the Java core. * The listener is guarantied to be notified of the POST_CHANGE resource change event before * the Java core starts processing the resource change event itself. * * Has no effect if an identical listener is already registered. * * @param listener the listener * @see #removePreResourceChangeListener(IResourceChangeListener) * @since 3.0 */ public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener); /** * Removes the given pre-processing resource changed listener. * * Has no affect if an identical listener is not registered. * * @param listener the listener * @since 3.0 */ public static void removePreProcessingResourceChangedListener(IResourceChangeListener listener);
if (bool) return; else System.out.println(); // no need to be inside elseAssociated problem ID is: IProblem.UnnecessaryElse.
* COMPILER / Reporting Unnecessary Else * When enabled, the compiler will issue an error or a warning when a statement is unnecessarily * nested within an else clause (in situation where then clause is not completing normally). * - option id: "org.eclipse.jdt.core.compiler.problem.unnecessaryElse" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
/** * Name of the User Library Container id. */ public static final String USER_LIBRARY_CONTAINER_ID= "org.eclipse.jdt.USER_LIBRARY"; //$NON-NLS-1$ /** * Returns the names of all defined user libraries. The corresponding classpath container path * is the name appended to the USER_LIBRARY_CONTAINER_ID. * @return Return an array containing the names of all known user defined. */ public static String[] getUserLibraryNames();
/** * Returns an object which identifies a container for comparison purpose. This allows * to eliminate redundant containers when accumulating classpath entries (e.g. * runtime classpath computation). When requesting a container comparison ID, one * should ensure using its corresponding container initializer. Indeed, a random container * initializer cannot be held responsible for determining comparison IDs for arbitrary * containers. *By default, containers are identical if they have same container path first segment but this may be refined by other container initializer implementations.* @param containerPath the path of the container which is being checked * @param project the project for which the container is to being checked * @return returns an Object identifying the container for comparison * @since 3.0 */ public Object getComparisonID(IPath containerPath, IJavaProject project);
JavaCore.newSourceEntry(IPath,IPath[],IPath[],IPath)
and IClasspathEntry.getInclusionPatterns()
for details./** * Sets the buffer provider of the primary working copy owner. Note that even if the * buffer provider is a working copy owner, only its createBuffer(ICompilationUnit) * method is used by the primary working copy owner. It doesn't replace the internal primary * working owner. * * This method is for internal use by the jdt-related plug-ins. * Clients outside of the jdt should not reference this method. * * @param primaryBufferProvider the primary buffer provider */ public static void setPrimaryBufferProvider(WorkingCopyOwner primaryBufferProvider);
CompilationUnit public void recordModifications() public TextEdit rewrite(IDocument document, Map options) throws RewriteException
NewASTRewrite public final void markAsRemoved(ASTNode node, TextEditGroup editGroup) public final void markAsReplaced(ASTNode node, ASTNode replacingNode, TextEditGroup editGroup) public ListRewriter getListRewrite(ASTNode parent, ChildListPropertyDescriptor childProperty) public TextEdit rewriteAST(IDocument document, Map options) throws RewriteException ... ListRewriter remove(ASTNode, TextEditGroup) public void replace(ASTNode, ASTNode, TextEditGroup) public void insertAfter(ASTNode, ASTNode, TextEditGroup) public void insertBefore(ASTNode, ASTNode, TextEditGroup) public void insertFirst(ASTNode, TextEditGroup) public void insertLast(ASTNode, TextEditGroup) public void insertAt(ASTNode, int, TextEditGroup) ...
* COMPILER / Determine whether task tags are case-sensitive * When enabled, task tags are considered in a case-sensitive way. * - option id: "org.eclipse.jdt.core.compiler.taskCaseSensitive" * - possible values: { "enabled", "disabled" } * - default: "enabled"
* COMPILER / Javadoc Comment Support * When this support is disabled, the compiler will ignore all javadoc problems options settings * and will not report any javadoc problem. It will also not find any reference in javadoc comment and * DOM AST Javadoc node will be only a flat text instead of having structured tag elements. * - option id: "org.eclipse.jdt.core.compiler.doc.comment.support" * - possible values: { "enabled", "disabled" } * - default: "enabled"See bug 52264.
* COMPILER / Inline JSR Bytecode Instruction * When enabled, the compiler will no longer generate JSR instructions, but rather inline corresponding * subroutine code sequences (mostly corresponding to try finally blocks). The generated code will thus * get bigger, but will load faster on virtual machines since the verification process is then much simpler. * This mode is anticipating support for the Java Specification Request 202. * - option id: "org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" * - possible values: { "enabled", "disabled" } * - default: "disabled" *Corresponding command line compiler option
-noJSR
has been renamed to:
-inlineJSR
: inline JSR bytecode
which means that when specified, the compiler will no longer generate JSR bytecodes, but instead inlining the corresponding subroutine (e.g. finally block).
IJavaElementDelta.F_CLASSPATH_CHANGED
that indicates that
the project's raw classpath has changed.
org.eclipse.jdt.core.dom.CompilationUnit
:
getCommentList()
: Returns a list of the comments encountered while parsing the compilation unit.getExtendedStartPosition(ASTNode)
: Returns the extended start position of the given node.getExtendedLength(ASTNode)
: Returns the extended source length of the given node.ASTNode#getStartPosition()
and ASTNode#getLength()
, the extended source range may include
comments and whitespace immediately before or after the normal source range for the node.
FieldReferenceMatch.isReadAccess()
and isWriteAccess()
.
JavaCore.run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor)
to control the scheduling rule during a Java batch operation.
SearchEngine.createJavaSearchScope(IJavaElement[], int)
that allows to filter the
classpath entries added in the scope: SOURCES, APPLICATION_LIBRARIES, SYSTEM_LIBRARIES and REQUIRED_PROJECTS.
-maxProblems <n>
: max number of problems per compilation unit (100 by default) -noJSR
: do not use JSR bytecode ICompilationUnit.reconcile(boolean, boolean, WorkingCopyOwner, IProgressMonitor)
.
* COMPILER / Reporting Unused Declared Thrown Exception in Overridind Method * When disabled, the compiler will not include overriding methods in its diagnosis for unused declared * thrown exceptions. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException". * - option id: "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding" * - possible values: { "enabled", "disabled" } * - default: "disabled"
org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants
. See bug 49908.
The old constants have been deprecated and will be removed before M7. So we encourage you to save your code formatter preferences if
you modified the default settings. The UI will provide an automatic conversion to the new options.
org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants
. See bug 49968.
org.eclipse.jdt.core.dom.AST
to take an IProgressMonitor
. This progress monitor is checked for the cancelation of the AST creation only.
org.eclipse.jdt.core.dom.AST
to parse an expression or statements or class body declarations without requiring the parsing
of the whole compilation unit. This is still subject to change before 3.0.
/** * Parses the given source between the bounds specified by the given offset (inclusive) * and the given length and creates and returns a corresponding abstract syntax tree. * * The root node of the new AST depends on the given kind. * -org.eclipse.jdt.core.dom.AST.K_CLASS_BODY_DECLARATIONS
: The root node is an instance of *org.eclipse.jdt.core.dom.TypeDeclaration
. The type declaration itself doesn't contain any information. * It is simply used to return all class body declarations inside the bodyDeclaratins() collection. * -org.eclipse.jdt.core.dom.AST.K_STATEMENTS
: The root node is an instance of *org.eclipse.jdt.core.dom.Block
. The block itself doesn't contain any information. * It is simply used to return all the statements. * -org.eclipse.jdt.core.dom.AST.K_EXPRESSION
: The root node is an instance of a subclass of *org.eclipse.jdt.core.dom.Expression
. * * Each node in the subtree carries source range(s) information relating back * to positions in the given source (the given source itself * is not remembered with the AST). * The source range usually begins at the first character of the first token * corresponding to the node; leading whitespace and comments are not * included. The source range usually extends through the last character of * the last token corresponding to the node; trailing whitespace and * comments are not included. There are a handful of exceptions * (including compilation units and the various body declarations); the * specification for these node type spells out the details. * Source ranges nest properly: the source range for a child is always * within the source range of its parent, and the source ranges of sibling * nodes never overlap. * * This method does not compute binding information; allresolveBinding
* methods applied to nodes of the resulting AST returnnull
. * *null
is returned: * 1. If a syntax error is detected while parsing, * 2. If the given source doesn't correspond to the given kind. * * @param kind the given kind to parse * @param source the string to be parsed * @param offset the given offset * @param length the given length * @param options the given options. If null,JavaCore.getOptions()
is used. * @param monitor the progress monitor used to check if the AST creation needs to be canceled * * @return ASTNode * @see ASTNode#getStartPosition() * @see ASTNode#getLength() * @see AST#K_CLASS_BODY_DECLARATIONS * @see AST#K_EXPRESSION * @see AST#K_STATEMENTS * @see JavaCore#getOptions() * @since 3.0 */ public static ASTNode parse(int kind, char[] source, int offset, int length, Map options, IProgressMonitor monitor);
org.eclipse.jdt.core.dom.AST
to parse a compilation unit and specify
the set of options to use. This is still subject to change before 3.0. The previous API was directly
using JavaCore.getOptions()
. This could be problematic in case you want to parse assert
statements.
/** * Parses the given string as a Java compilation unit and creates and * returns a corresponding abstract syntax tree. * * The given options are used to find out the compiler options to use while parsing. * This could implies the settings for the assertion support. See theJavaCore.getOptions()
* methods for further details. * * * The returned compilation unit node is the root node of a new AST. * Each node in the subtree carries source range(s) information relating back * to positions in the given source string (the given source string itself * is not remembered with the AST). * The source range usually begins at the first character of the first token * corresponding to the node; leading whitespace and comments are not * included. The source range usually extends through the last character of * the last token corresponding to the node; trailing whitespace and * comments are not included. There are a handful of exceptions * (including compilation units and the various body declarations); the * specification for these node type spells out the details. * Source ranges nest properly: the source range for a child is always * within the source range of its parent, and the source ranges of sibling * nodes never overlap. * If a syntax error is detected while parsing, the relevant node(s) of the * tree will be flagged asMALFORMED
. * * * This method does not compute binding information; allresolveBinding
* methods applied to nodes of the resulting AST returnnull
. * * * @param source the string to be parsed as a Java compilation unit * @param options options to use while parsing the file. If null,JavaCore.getOptions()
is used. * @param monitor the progress monitor used to check if the AST creation needs to be canceled * @return CompilationUnit * @see ASTNode#getFlags() * @see ASTNode#MALFORMED * @see ASTNode#getStartPosition() * @see ASTNode#getLength() * @see JavaCore#getOptions() * @since 3.0 */ public static CompilationUnit parseCompilationUnit(char[] source, Map options, IProgressMonitor monitor);
/** * Returns the scheduling rule associated with this Java element. * This is a handle-only method. * * @return the scheduling rule associated with this Java element * @since 3.0 */ ISchedulingRule getSchedulingRule();
* COMPILER / Reporting Deprecation When Overriding Deprecated Method * When enabled, the compiler will signal the declaration of a method overriding a deprecated one. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation". * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod" * - possible values: { "enabled", "disabled" } * - default: "disabled"
* COMPILER / Reporting Invalid Javadoc Comment * This is the generic control for the severity of Javadoc problems. * When enabled, the compiler will issue an error or a warning for a problem in Javadoc. * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadoc" * - possible values: { "error", "warning", "ignore" } * - default: "ignore" * * COMPILER / Visibility Level For Invalid Javadoc Tags * Set the minimum visibility level for Javadoc tag problems. Below this level problems will be ignored. * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility" * - possible values: { "public", "protected", "default", "private" } * - default: "private" * * COMPILER / Reporting Invalid Javadoc Tags * When enabled, the compiler will signal unbound or unexpected reference tags in Javadoc. * A 'throws' tag referencing an undeclared exception would be considered as unexpected. *Note that backward compatibility with previous options IDs:
Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; * also see the setting "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility". *
* The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.invalidJavadoc". * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags" * - possible values: { "disabled", "enabled" } * - default: "enabled" * * COMPILER / Reporting Missing Javadoc Tags * This is the generic control for the severity of Javadoc missing tag problems. * When enabled, the compiler will issue an error or a warning when tags are missing in Javadoc comments. *
Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; * also see the setting "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility". *
* - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocTags" * - possible values: { "error", "warning", "ignore" } * - default: "ignore" * * COMPILER / Visibility Level For Missing Javadoc Tags * Set the minimum visibility level for Javadoc missing tag problems. Below this level problems will be ignored. * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility" * - possible values: { "public", "protected", "default", "private" } * - default: "private" * * COMPILER / Reporting Missing Javadoc Tags on Overriding Methods * Specify whether the compiler will verify overriding methods in order to report Javadoc missing tag problems. * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding" * - possible values: { "enabled", "disabled" } * - default: "enabled" * * COMPILER / Reporting Missing Javadoc Comments * This is the generic control for the severity of missing Javadoc comment problems. * When enabled, the compiler will issue an error or a warning when Javadoc comments are missing. *
Note that this diagnosis can be enabled based on the visibility of the construct associated with the expected Javadoc; * also see the setting "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility". *
* - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocComments" * - possible values: { "error", "warning", "ignore" } * - default: "ignore" * * COMPILER / Visibility Level For Missing Javadoc Comments * Set the minimum visibility level for missing Javadoc problems. Below this level problems will be ignored. * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility" * - possible values: { "public", "protected", "default", "private" } * - default: "public" * * COMPILER / Reporting Missing Javadoc Comments on Overriding Methods * Specify whether the compiler will verify overriding methods in order to report missing Javadoc comment problems. * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding" * - possible values: { "enabled", "disabled" } * - default: "enabled" *
"org.eclipse.jdt.core.compiler.problem.missingJavadoc"
will be supported until 3.0M7 build and removed after.
ITypeBinding.getBinaryName()
was changed to be '.' separated:
/** * Returns the binary name of this type binding. * The binary name of a class is defined in the Java Language * Specification 2nd edition, section 13.1. * * Note that in some cases, the binary name may be unavailable. * This may happen, for example, for a local type declared in * unreachable code. * * @return the binary name of this type, or null * if the binary name is unknown * @since 3.0 */ public String getBinaryName();
ICompilationUnit
handle given a WorkingCopyOwner
as these can be replaced with ICompilationUnit.findWorkingCopy(WorkingCopyOwner)
:
IPackageFragment.getCompilationUnit(String, WorkingCopyOwner)
JavaCore.create(IFile, WorkingCopyOwner)
JavaCore.create(IResource, WorkingCopyOwner)
JavaCore.createCompilationUnitFrom(IFile, WorkingCopyOwner)
IDOMCompilationUnit.getCompilationUnit(IPackageFragment, WorkingCopyOwner)
ICompilationUnit
to find an existing working copy given a working
copy owner (it replaces IWorkingCopy.findSharedWorkingCopy(IBufferFactory)
):
/** * Finds the working copy for this compilation unit, given aWorkingCopyOwner
. * If no working copy has been created for this compilation unit associated with this * working copy owner, returnsnull
. * * Users of this method must not destroy the resulting working copy. * * @param owner the givenWorkingCopyOwner
* @return the found working copy for this compilation unit,null
if none * @see WorkingCopyOwner * @since 3.0 */ ICompilationUnit findWorkingCopy(WorkingCopyOwner owner);
IClassFile
to create a working copy on a class file (it replaces
IClassFile.getWorkingCopy(IProgressMonitor, IBufferFactory)
):
/** * Returns a working copy on the source associated with this class file using the given * owner to create the buffer, ornull
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 aregetBuffer()
orgetPrimary()
. * * @param owner the owner that creates a buffer that is used to get the content of the working copy * ornull
if the primary owner should be used * @param monitor a progress monitor used to report progress while opening this compilation unit * ornull
if no progress should be reported * @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: * - This class file does not exist (ELEMENT_DOES_NOT_EXIST) * @since 3.0 */ ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
ITypeBinding
to get the binary name of a type binding:
/** * Returns the binary name (as defined in the Java Language * Specification Chapter 13 Section 1) of this type binding. * It is however slash ('/') separated instead of dot ('.') separated as said * in the specification. * Returnsnull
if the type is defined in code that is unreachable. * * @return the binary name of this type ornull
if this type is unreachable */ String getBinaryName();
ICompilationUnit
to query whether the working copy's resource has changed
(it replaces IWorkingCopy.isBasedOn(IResource)
):
/**
* Returns whether the resource of this working copy has changed since the
* inception of this working copy.
* Returns false
if this compilation unit is not in working copy mode.
*
* @return whether the resource has changed
* @since 3.0
*/
public boolean hasResourceChanged();
IType
to create hierarchies using ICompilationUnits
instead of
IWorkingCopies
:
/** * Creates and returns a type hierarchy for this type containing * this type and all of its supertypes, considering types in the given * working copies. In other words, the list of working copies will take * precedence over their original compilation units in the workspace. * * Note that passing an empty working copy will be as if the original compilation * unit had been deleted. * * @param workingCopies the working copies that take precedence over their original compilation units * @param monitor the given progress monitor * @return a type hierarchy for this type containing this type and all of its supertypes * @exception JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource. * @since 3.0 */ ITypeHierarchy newSupertypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throws JavaModelException; /** * Creates and returns a type hierarchy for this type containing * this type, all of its supertypes, and all its subtypes in the workspace, * considering types in the given working copies. In other words, the list of working * copies that will take precedence over their original compilation units in the workspace. * * Note that passing an empty working copy will be as if the original compilation * unit had been deleted. * * @param workingCopies the working copies that take precedence over their original compilation units * @param monitor the given progress monitor * @return a type hierarchy for this type containing * this type, all of its supertypes, and all its subtypes in the workspace * @exception JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource. * @since 3.0 */ ITypeHierarchy newTypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throws JavaModelException;
SearchEngine
to create a search engine using
ICompilationUnits
instead of IWorkingCopies
:
/** * Creates a new search engine with a list of working copies that will take precedence over * their original compilation units in the subsequent search operations. * * Note that passing an empty working copy will be as if the original compilation * unit had been deleted. * * Since 3.0 the given working copies take precedence over primary working copies (if any). * * @param workingCopies the working copies that take precedence over their original compilation units * @since 3.0 */ public SearchEngine(ICompilationUnit[] workingCopies) {...}
* COMPILER / Reporting Invalid Javadoc Comment * When enabled, the compiler will issue an error or a warning when a javadoc comment is inconsistent, * misses a tag entry or contains invalid references. * - option id: "org.eclipse.jdt.core.compiler.problem.invalidJavadoc" * - possible values: { "error", "warning", "ignore" } * - default: "ignore" * COMPILER / Reporting Missing Javadoc Comment * When enabled, the compiler will signal cases where public class, interface, method, constructor or field * (considered as part of the API) has no javadoc comment. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.invalidJavadoc". * - option id: "org.eclipse.jdt.core.compiler.problem.missingJavadoc" * - possible values: { "enabled", "disabled" } * - default: "disabled"Note that backward compatibility with previous options IDs:
"org.eclipse.jdt.core.compiler.problem.invalidAnnotation"
and "org.eclipse.jdt.core.compiler.problem.missingAnnotation"
will be supported until 3.0M6 build and removed after.
ILocalVariable
element. Searching a local variable by its name is not supported.
@param
tags,
types of exceptions declared in @throws
/@exception
tags and all instance variables, methods, types or
packages declared in @see
tags.
JavaCore#COMPILER_PB_INVALID_IMPORT
and
JavaCore#COMPILER_PB_UNREACHABLE_CODE
got deprecated,
further attempts to set these preferences are now ignored and import problems or unreachable code are always reported as errors.
-warn:+...
or -warn:-...
command line
argument (as opposed to only existing -warn:...
command line argument).
-warn:+...
will not override the default warning level, but simply enable
a few more specific warnings. Similarily, -warn:-...
will only disable specific warnings.
ICodeAssit.codeSelect(...)
) now returns an ILocalVariable
element when a local variable or an argument is selected.
ILocalVariable
s are pseudo-elements:
they are not part of the Java model (exists()
always returns false
),
they are not returned when asking for the children of a method, and there is no other way to create such
an element. One can only ask for the source range (ISourceReference.getSourceRange()
) or
for the name range (ILocalVariable.getNameRange()
) of the local variable.
IJavaProject#forceClasspathReload(IProgressMonitor)
(see comment of v_368 drop below).
* COMPILER / Reporting Invalid Javadoc Annotation * When enabled, the compiler will issue an error or a warning when a javadoc annotation is inconsistent, * misses a tag entry or contains invalid references. * - option id: "org.eclipse.jdt.core.compiler.problem.invalidAnnotation" * - possible values: { "error", "warning", "ignore" } * - default: "ignore" * COMPILER / Reporting Missing Javadoc Annotation * When enabled, the compiler will signal cases where public class, interface, method, constructor or field * (considered as part of the API) has no javadoc annotation. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.invalidAnnotation". * - option id: "org.eclipse.jdt.core.compiler.problem.missingAnnotation" * - possible values: { "enabled", "disabled" } * - default: "disabled" *
This includes:
IMember.getType(String, int)
)getChildren()
on a method, a field or an initializer returns the local or anonymous types defined in this elementThis doesn't yet include:
* COMPILER / Reporting Unqualified Access to Field * When enabled, the compiler will issue an error or a warning when a field is access without any qualification. * In order to improve code readability, it should be qualified, e.g. 'x' should rather be written 'this.x'. * - option id: "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
* COMPILER / Reporting Unused Declared Thrown Exception * When enabled, the compiler will issue an error or a warning when a method or a constructor is declaring a * thrown checked exception, but never actually raises it in its body. * - option id: "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
* COMPILER / Reporting Finally Blocks Not Completing Normally * When enabled, the compiler will issue an error or a warning when a finally block does not complete normally. * - option id: "org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally" * - possible values: { "error", "warning", "ignore" } * - default: "warning"
readRawClasspath()
and readOutputLocation()
on IJavaProject
interface so as to allow user to read classpath directly from disk (.classpath
file contents). This is useful to configure
a Java project before it is associated with the Java nature, or before the automatic classpath reconciliation mechanism has performed (within
a resource modifying operation, and prior to the change notification). Note that these API additions are obsoleting the previously
added API IJavaProject#forceClasspathReload(IProgressMonitor)
(also see bug 20931)
which has thus been deprecated. Forcing the classpath reload can simply be achieved by: p.setRawClasspath(p.readRawClasspath(), p.readOutputLocation(), ...)
.
* COMPILER / Reporting Undocumented Empty Block * When enabled, the compiler will issue an error or a warning when an empty block is detected and it is not * documented with any comment. * - option id: "org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
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"