jdt core - build notes 2.1 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 R2_1_maintenance branch. This present document covers all changes since release 2.0 (previous changes, i.e. up to release 2.0, can be found in build notes R2.0). |
IJavaProject.isOnClasspath(...)
no longer throws any exception, but rather consistently return false
in these circumstances. Indeed, it is difficult for clients to work with predicates that throw exceptions.
Although this change creates a source incompatibility, the change is binary compatible with 2.0 and within the original
spirit of the original API contract. Include in 2.1 readme.
ElementChangedEvent
as well indicating that the working copy has been
ADDED
or REMOVED
.
Until now, only shared working copies were providing such delta notifications.
IWorkingCopy.getWorkingCopy()
IWorkingCopy.getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
IWorkingCopy.destroy()
ToolFactory.createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator, boolean strictComment)
CorrectionEngine.getProblemArguments(IMarker problemMarker)
* JAVACORE / Enabling Usage of Classpath Exclusion Patterns * When set to "disabled", no entry on a project classpath can be associated with * an exclusion pattern. * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns" * - possible values: { "enabled", "disabled" } * - default: "enabled" * * JAVACORE / Enabling Usage of Classpath Multiple Output Locations * When set to "disabled", no entry on a project classpath can be associated with * a specific output location, preventing thus usage of multiple output locations. * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations" * - possible values: { "enabled", "disabled" } * - default: "enabled"
IPackageFragmentRoot.computeSourceAttachmentRootPath(IPath sourceAttachmentPath)
IJavaModelMarker.UNBOUND_CONTAINER
, use classpath problem marker ID instead (IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND
).
IJavaModelMarker.UNBOUND_VARIABLE
, use classpath problem marker ID instead (IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND
).
* COMPILER / Reporting Unused Parameter if Implementing Abstract Method * When enabled, the compiler will signal unused parameters in abstract method implementations. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter". * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract" * - possible values: { "enabled", "disabled" } * - default: "disabled" * * COMPILER / Reporting Unused Parameter if Overriding Concrete Method * When enabled, the compiler will signal unused parameters in methods overriding concrete ones. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter". * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete" * - possible values: { "enabled", "disabled" } * - default: "disabled"
F_REORDER
on IJavaElementDelta
. This flag is
positioned if a member in a compilation unit has changed its position relatively to its siblings.
ClasspathContainerInitializer.getDescription(IPath containerPath)
so as to improve readability
of our messages involving classpath containers (e.g. unbound container classpath problems). Default implementation answers
the original container path.
* COMPILER / Reporting Usage of char[] Expressions in String Concatenations * When enabled, the compiler will issue an error or a warning whenever a char[] expression * is used in String concatenations (e.g. "hello" + new char[]{'w','o','r','l','d'}). * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion" * - possible values: { "error", "warning", "ignore" } * - default: "warning"
IJavaModel.contains()
to find out if an IResource
is visible in
the Java model.
suggestSetterName(IJavaProject,char[],int,char[][])
suggestSetterName(IJavaProject,String,int,String[])
org.eclipse.jdt.core.util.CompilationUnitSorter
public static final String RELATIVE_ORDER = "relativeOrder"; public static void sort(ICompilationUnit compilationUnit, int[] positions, Comparator comparator, int options, IProgressMonitor monitor) throws JavaModelException;
ITypeHierarchyChangedListener
once
restoration has occurred.
ITypeHierarchy.store(OutputStream, IProgressMonitor)
for saving a type hierarchy.
IType.load(InputStream, IProgressMonitor)
for restoring a previously saved hierarchy.
IPackageFragmentRoot.copy(IPath, int, boolean, IClasspathEntry, IProgressMonitor)
IPackageFragmentRoot.delete(int, boolean, IProgressMonitor)
IPackageFragmentRoot.move(IPath, int, boolean, IClasspathEntry, IProgressMonitor)
IResource
APIs except that
they filter out nested source folders, and that they update the project's classpaths if specified.
IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod
).
This problem is optional, and its severity is also controlled by the JavaCore
preference "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
.
true
if the field's type is boolean.
suggestSetterName(IJavaProject,char[],int,char[][])
become suggestSetterName(IJavaProject,char[],int,boolean,char[][])
suggestSetterName(IJavaProject,String,int,String[])
become suggestSetterName(IJavaProject,String,int,boolean,String[])
interface I { int clone(); }
), and
is now an optional problem (default severity is WARNING). Corresponding problem ID is: IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod
.
* COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods * When enabled, the compiler will issue an error or a warning whenever an interface * defines a method incompatible with a non-inherited Object one. * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod" * - possible values: { "error", "warning", "ignore" } * - default: "warning"
IProblem.UnusedPrivateMethod
, IProblem.UnusedPrivateField
,
IProblem.UnusedPrivateType
and IProblem.UnusedPrivateConstructor
.
* COMPILER / Reporting Unused Private Members * When enabled, the compiler will issue an error or a warning whenever a private * method or field is declared but never used within the same unit. * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember" * - possible values: { "error", "warning", "ignore" } * - default: "ignore"
ICompletionRequestor#acceptKeyword(char[] keywordName, int completionStart, int completionEnd, int relevance)
which wasn't invoked until now. There is currently no way to distinguish in between a 'synchronized' keyword used as a modifier or as a statement.
package org.eclipse.jdt.core; public final class NamingConventions { public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName) {...} public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName) {...} public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers) {...} public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers) {...} public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName) {...} public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName) {...} public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {...} public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {...} public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames) {...} public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames) {...} public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {...} public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {...} public static char[] suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames) {...} public static String suggestGetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames) {...} public static char[] suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, char[][] excludedNames) {...} public static String suggestSetterName(IJavaProject project, String fieldName, int modifiers, String[] excludedNames) {...} }
IJavaProject.isOnClasspath(IResource)
that returns whether a given resource is on the
classpath of the project and whether it is excluded.
org.eclipse.jdt.core.ClasspathContainerInitializer
:
/** * Returnstrue
if this container initializer can be requested to perform updates * on its own container values. If so, then an update request will be performed using *ClasspathContainerInitializer#requestClasspathContainerUpdate
/ * * @param containerPath - the path of the container which requires to be updated * @param project - the project for which the container is to be updated * @return boolean - returnstrue
if the container can be updated * @since 2.1 */ public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { // By default, classpath container initializers do not accept updating containers return false; }
/** * Request a registered container definition to be updated according to a container suggestion. The container suggestion * only acts as a place-holder to pass along the information to update the matching container definition(s) held by the * container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust * the actual container definition based on suggested changes. * * IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding * container definition (after reconciling changes) at its earliest convenience, using *JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
. * Until it does so, the update will not be reflected in the Java Model. * * In order to anticipate whether the container initializer allows to update its containers, the predicate *JavaCore#canUpdateClasspathContainer
should be used. * * @param containerPath - the path of the container which requires to be updated * @param project - the project for which the container is to be updated * @param containerSuggestion - a suggestion to update the corresponding container definition * @throws CoreException whenJavaCore#setClasspathContainer
would throw any. * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) * @see ClasspathContainerInitializer#canUpdateClasspathContainer(IPath, IJavaProject) * @since 2.1 */ public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { // By default, classpath container initializers do not accept updating containers }
org.eclipse.jdt.core.JavaCore
so as to retrieve a registered
classpath container initializer:
/** * Helper method finding the classpath container initializer registered for a given classpath container ID * ornull
if none was found while iterating over the contributions to extension point to * the extension point "org.eclipse.jdt.core.classpathContainerInitializer". * * A containerID is the first segment of any container path, used to identify the registered container initializer. * * @return ClasspathContainerInitializer - the registered classpath container initializer ornull
if * none was found. * @since 2.1 */ public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID)
var1
is more relevant than var2
.public class X { int var1; Object var2; void foo() { int i = 1 + var<cursor> } }
IPackageFragmentRoot.attachSource(IPath, IPath, IProgressMonitor)
and
JavaCore.newLibraryEntry(...)
.
JavaCore.newLibraryEntry(...)
and IPackageFragmentRoot.attachSource(...)
),
then the Java Model will do its best to compute this root path automatically. The underlying algorithm
finds the first .java file, parses it, and extract the package declaration to compute the root path.
IPackageFragmentRoot.computeSourceAttachmentRootPath(IPath sourceAttachmentPath)
allows to detect the root path for a given source attachment and package fragment root.
var2
is less relevant than var1
.public class X { int var1; int var2 = var<cursor> }
var2
is more relevant than var1
.public class X { static int var1; int var2; void foo() { this.var<cursor> } }
var2
and the parameter var1
are more relevant
than field var1
.public class X { int var1; int var2; void foo(int var1) { var<cursor> } }
var
is more relevant than field varPlus
.public class X { int var; int varPlus; void foo() { var<cursor> } }
JavaCore.newSourceEntry(IPath path, IPath[] exclusionPatterns)
IClasspathEntry.getExclusionPatterns()
JavaCore.newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation)
IClasspathEntry.getOutputLocation()
* BUILDER / Cleaning Output Folder(s) * Indicate whether the JavaBuilder is allowed to clean the output folders * when performing full build operations. * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder" * - possible values: { "clean", "ignore" } * - default: "clean"
* COMPILER / Reporting Assignment with no effect * When enabled, the compiler will issue an error or a warning whenever an assignment * has no effect (e.g 'x = x'). * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment" * - possible values: { "error", "warning", "ignore" } * - default: "warning"
var2
is more relevant than var1
.public class X { Object var1; int var2; void foo() { int i = var<cursor> } }
var2
is more relevant than var1
.public class X { Object var1; int var2; void foo() { int i; i = var<cursor> } }
var2
is more relevant than var1
.public class X { Object var1; int var2; int foo() { return var<cursor> } }
var2
is more relevant than var1
.public class X { Object var1; int var2; long foo() { return (int)var<cursor> } }
var2
is more relevant than var1
.public class X { Object var1; int var2; void foo(int i) { foo(var<cursor> } }
""
meaning
tasks have normal priority).
* COMPILER / Define the Automatic Task Priorities * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low) * of the task markers issued by the compiler. * If the default is specified, the priority of each task marker is "NORMAL". * - option id: "org.eclipse.jdt.core.compiler.taskPriorities" * - possible values: { "priority[,priority]*" } where priority is one of "HIGH", "NORMAL" or "LOW" * - default: ""
/** * Helper method for returning one option value only. Equivalent to(String)this.getOptions(inheritJavaCoreOptions).get(optionName)
* Note that it may answernull
if this option does not exist, or if there is no custom value for it. ** For a complete description of the configurable options, see
* @param optionName the name of an option * @param inheritJavaCoreOptions - boolean indicating whether JavaCore options should be inherited as well * @return the String value of a given option * @see JavaCore#getDefaultOptions * @since 2.1 */ String getOption(String optionName, boolean inheritJavaCoreOptions);JavaCore#getDefaultOptions
. *
/** * Returns the table of the current custom options for this project. Projects remember their custom options, * i.e. only the options different from the the JavaCore global options for the workspace. * A boolean argument allows to directly merge the project options with global ones fromJavaCore
. ** For a complete description of the configurable options, see
* * @param inheritJavaCoreOptions - boolean indicating whether JavaCore options should be inherited as well * @return table of current settings of all options * (key type:JavaCore#getDefaultOptions
. *String
; value type:String
) * @see JavaCore#getDefaultOptions * @since 2.1 */ Map getOptions(boolean inheritJavaCoreOptions);
/** * Sets the project custom options. All and only the options explicitly included in the given table * are remembered; all previous option settings are forgotten, including ones not explicitly * mentioned. ** For a complete description of the configurable options, see
* * @param newOptions the new options (key type:JavaCore#getDefaultOptions
. *String
; value type:String
), * ornull
to flush all custom options (clients will automatically get the global JavaCore options). * @see JavaCore#getDefaultOptions * @since 2.1 */ void setOptions(Map newOptions);
JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
that allows batching
of java model operations. Only one Java element changed event is reported at the end of the batch.
For example the following code snippet notifies listeners twice:
ICompilationUnit unit = ...; unit.createType("class B {}", null, false, monitor); unit.getType("A").createField("int i;", null, false, monitor);To be notified only once, use the following:
JavaCore.run( new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { ICompilationUnit unit = ...; unit.createType("class B {}", null, false, monitor); unit.getType("A").createField("int i;", null, false, monitor); } }, monitor);
* JAVACORE / Reporting Incomplete Classpath * An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed). * - option id: "org.eclipse.jdt.core.incompleteClasspath" * - possible values: { "error", "warning"} * - default: "error" * * JAVACORE / Reporting Classpath Cycle * A project is involved in a cycle. * - option id: "org.eclipse.jdt.core.circularClasspath" * - possible values: { "error", "warning" } * - default: "error"
* COMPILER / Reporting Deprecation Inside Deprecated Code * When enabled, the compiler will signal use of deprecated API inside deprecated code. * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation". * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode" * - possible values: { "enabled", "disabled" } * - default: "disabled"
"org.eclipse.jdt.core.task"
).
org.eclipse.jdt.core.compiler.IProblem#Task
. Note that
clients of IProblemRequestor
will get detected tasks as warnings with this new ID, they
can be filtered out if needed.
""
meaning no
task is detected).
* COMPILER / Define the Automatic Task Tags * When the tag is non empty, the compiler will issue a task marker whenever it encounters * one of the corresponding tag inside any comment in Java source code. * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed. * - option id: "org.eclipse.jdt.core.taskTags" * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card * - default: ""
JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER()
)