|
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. * *nullis 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 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"
*
Note that backward compatibility with previous options IDs: "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,nullif 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, ornullif 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 * ornullif the primary owner should be used * @param monitor a progress monitor used to report progress while opening this compilation unit * ornullif 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.
* Returns null if the type is defined in code that is unreachable.
*
* @return the binary name of this type or null 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