jdt core - build notes 3.3 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.
For more information on 3.3 planning, please refer to JDT/Core release plan,
the next milestone plan,
the overall official plan,
or the build schedule.
This present document covers all changes since Release 3.2 (also see a summary of API changes).
Maintenance of previous releases of JDT/Core is performed in parallel branches: R3.2.x, R3.1.x, R3.0.x, R2.1.x, R2.0.x, R1.0.x. |
ToolFactory#createCodeFormatter(Map options, int mode)
allows to specify whether the code
formatter is going to format new code or existing code.org.eclipse.jdt.core.JavaCore#setCompilanceOptions(String, Map)
has been renamed to org.eclipse.jdt.core.JavaCore.setComplianceOptions(String, Map)
.org.eclipse.jdt.core.dom.RecoveredTypeBinding
, org.eclipse.jdt.core.dom.RecoveredVariableBinding
are not part of the API. They have been
changed to package default visibility.org.eclipse.jdt.core.search.MethodReferenceMatch#isPolymorphic()
has been removed.org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants
in order to fix bug 20793.
The implementation will be provided after 3.3M6./** * FORMATTER / Option to indent block comments that start on the first column * - option id: "org.eclipse.jdt.core.formatter.formatter.never_indent_block_comments_on_first_column" * - possible values: { TRUE, FALSE } * - default: TRUE * @see #TRUE * @see #FALSE * @since 3.3 */ public static final String FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN = JavaCore.PLUGIN_ID + ".formatter.never_indent_block_comments_on_first_column"; //$NON-NLS-1$ /** * FORMATTER / Option to indent line comments that start on the first column * - option id: "org.eclipse.jdt.core.formatter.formatter.never_indent_line_comments_on_first_column" * - possible values: { TRUE, FALSE } * - default: TRUE * @see #TRUE * @see #FALSE * @since 3.3 */ public static final String FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN = JavaCore.PLUGIN_ID + ".formatter.never_indent_line_comments_on_first_column"; //$NON-NLS-1$
org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants
in order to fix bug 79068.
The implementation will be provided after 3.3M6./** * FORMATTER / Option to wrap before the binary operator * - option id: "org.eclipse.jdt.core.formatter.wrap_before_binary_operator" * - possible values: { TRUE, FALSE } * - default: FALSE * This option is used only if the option {@link #FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION} is set. * @see #TRUE * @see #FALSE * @since 3.3 */ public static final String FORMATTER_WRAP_BEFORE_BINARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.wrap_before_binary_operator"; //$NON-NLS-1$
org.eclipse.jdt.core.ClasspathContainerInitializer
class:
#getAccessRulesStatus(IPath, IJavaProject)
#getAttributeStatus(IPath, IJavaProject, String)
#getSourceAttachmentStatus(IPath, IJavaProject)
IStatus#OK
: means that the attribute is supported and is modifiableIStatus#ERROR
: means that either the attribute is not supported or is not modifiable.IStatus#getCode()
will have respectively the #ATTRIBUTE_NOT_SUPPORTED
value
or the #ATTRIBUTE_READ_ONLY
value.IStatus#OK
if and only if the classpath container can
be updated (see #canUpdateClasspathContainer(IPath, IJavaProject)
).
org.eclipse.jdt.core.dom.AST#hasResolvedBindings()
org.eclipse.jdt.core.dom.AST#hasStatementsRecovery()
org.eclipse.jdt.core.dom.AST#hasBindingsRecovery()
org.eclipse.jdt.core.dom.ASTParser#setBindingsRecovery(boolean)
org.eclipse.jdt.core.dom.IBinding#isRecovered()
org.eclipse.jdt.core.ICompilationUnit#reconcile(int, int, WorkingCopyOwner, IProgressMonitor)
org.eclipse.jdt.core.ICompilationUnit#FORCE_PROBLEM_DETECTION
org.eclipse.jdt.core.ICompilationUnit#ENABLE_STATEMENTS_RECOVERY
org.eclipse.jdt.core.ICompilationUnit#ENABLE_BINDINGS_RECOVERY
WorkingCopyOwner
) now specifies the problem requestor
(IProblemrequestor
) used to report problems on working copies it owns
(see bug 175243).WorkingCopyOwner
class:
/** * Returns the problem requestor used by a working copy of this working copy owner. * * By default, no problem requestor is configured. Clients can override this * method to provide a requestor. * * @param workingCopy The problem requestor used for the given working copy. * IfAs a consequence of this addition,null
, then return the problem requestor used for all working * copies of the working copy owner. * @return the problem requestor to be used by working copies of this working * copy owner ornull
if no problem requestor is configured. * * @since 3.3 */ public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { return null; }
IProblemRequestor
parameter
of *WorkingCopy
methods becomes unnecessary and corresponding
methods have been deprecated:
ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor)
ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
IClassFile#becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)
WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProblemRequestor, IProgressMonitor)
ICompilationUnit#becomeWorkingCopy(IProgressMonitor)
ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)
IClassFile#becomeWorkingCopy(WorkingCopyOwner, IProgressMonitor)
WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProgressMonitor)
IPackageFragmentRoot#getNonJavaResources()
and
IPackageFragment#getNonJavaResources()
are now of type IJarEntryResource
(a subinterface
of IStorage
). This interface allows to navigate the tree of non-Java resources using the
getChildren()
and getParent()
methods.NullLocalVariableReference
- Null pointer access: The variable o can only be null at this locationPotentialNullLocalVariableReference
- Potential null pointer access: The variable o may be null at this locationRedundantNullCheckOnNullLocalVariable
- Redundant null check: The variable o can only be null at this locationNullLocalVariableComparisonYieldsFalse
- Null comparison always yields false: The variable x can only be null at this locationRedundantLocalVariableNullAssignment
- Redundant assignment: The variable x can only be null at this locationNullLocalVariableInstanceofYieldsFalse
- instanceof always yields false: The variable o can only be null at this locationRedundantNullCheckOnNonNullLocalVariable
- Redundant null check: The variable o2 cannot be null at this locationNonNullLocalVariableComparisonYieldsFalse
- Null comparison always yields false: The variable i cannot be null at this locationLocalVariableCannotBeNull
,
LocalVariableCanOnlyBeNull
, and
LocalVariableMayBeNull
have been deprecated.IClassFile#getType()
does not longer throw JavaModelException
(see bug 154667).package test; public class E1 { void m() { variable = 10; System.out.println(v); // do completion after 'v' } }When v is completed, variable is proposed as a possible local variable which are not yet declared.
nullReference
option has been repurposed and split into three
options:
COMPILER / Reporting Null Dereference When enabled, the compiler will issue an error or a warning whenever a variable that is statically known to hold a null value is used to access a field or method. - option id: "org.eclipse.jdt.core.compiler.problem.nullReference" - possible values: { "error", "warning", "ignore" } - default: "ignore" COMPILER / Reporting Potential Null Dereference When enabled, the compiler will issue an error or a warning whenever a variable that has formerly been tested against null but is not (no more) statically known to hold a non-null value is used to access a field or method. - option id: "org.eclipse.jdt.core.compiler.problem.potentialNullReference" - possible values: { "error", "warning", "ignore" } - default: "ignore" COMPILER / Reporting Redundant Null Check When enabled, the compiler will issue an error or a warning whenever a variable that is statically known to hold a null or a non-null value is tested against null. - option id: "org.eclipse.jdt.core.compiler.problem.redundantNullCheck" - possible values: { "error", "warning", "ignore" } - default: "ignore"See bug 170704 for details.
org.eclipse.jdt.core.IClassFile
:
/** * Returns the bytes contained in this class file. * * @return the bytes contained in this class file * * @exception JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource * @since 3.3 */ byte[] getBytes() throws JavaModelException;See bug 150244 for details.
org.eclipse.jdt.core.compiler.CharOperation
:/** * Compares the two char arrays lexicographically. * * Returns a negative integer if array1 lexicographically precedes the array2, * a positive integer if this array1 lexicographically follows the array2, or * zero if both arrays are equal. * * @param array1 the first array * @param array2 the second array * @return the returned value of the comparison between array1 and array2 * @throws NullPointerException if one of the arrays is null * @since 3.3 */ public static final int compareTo(char[] array1, char[] array2)
org.eclipse.jdt.core.util.CompilationUnitSorter
:/** * Reorders the declarations in the given compilation unit according to the * specified comparator. The caller is responsible for arranging in advance * that the given compilation unit is a working copy, and for applying the * returned TextEdit afterwards. * * Note: Reordering the members within a type declaration might be * more than a cosmetic change and could have potentially serious * repercussions. Firstly, the order in which the fields of a type are * initialized is significant in the Java language; reordering fields and * initializers may result in compilation errors or change the execution * behavior of the code. Secondly, reordering a class's members may affect * how its instances are serialized. This operation should therefore be used * with caution and due concern for potential negative side effects. * * * Thecompare
method of the given comparator is passed pairs * of body declarations (subclasses ofBodyDeclaration
) * representing body declarations at the same level. The nodes are from an * AST of the specified level ({@link org.eclipse.jdt.core.dom.ASTParser#newParser(int)}. * Clients will generally use AST.JLS3 since that will cover all * constructs found in Java 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 source code. * The comparator is called on body declarations of nested classes, * including anonymous and local classes, but always at the same level. * Clients need to provide a comparator implementation (there is no standard * comparator). TheRELATIVE_ORDER
property attached to these * AST nodes affords the comparator a way to preserve the original relative * order. * * * The body declarations passed as parameters to the comparator always carry * at least the following minimal signature information: * * *TypeDeclaration
*modifiers, isInterface, name, superclass, * superInterfaces, typeParameters * RELATIVE_ORDER property
* *FieldDeclaration
*modifiers, type, fragments * (VariableDeclarationFragments * with name only) * RELATIVE_ORDER property
* *MethodDeclaration
*modifiers, isConstructor, returnType, name, * typeParameters, parameters * (SingleVariableDeclarations with name, type, and modifiers only), * thrownExceptions * RELATIVE_ORDER property
* *Initializer
*modifiers * RELATIVE_ORDER property
* *AnnotationTypeDeclaration
*modifiers, name * RELATIVE_ORDER property
* *AnnotationTypeMemberDeclaration
*modifiers, name, type, default * RELATIVE_ORDER property
* *EnumDeclaration
*modifiers, name, superInterfaces * RELATIVE_ORDER property
* *EnumConstantDeclaration
*modifiers, name, arguments * RELATIVE_ORDER property
* * Clients should not rely on the AST nodes being properly parented * or on having source range information. (Future releases may provide * options for requesting additional information like source positions, full * ASTs, non-recursive sorting, etc.) * * @param unit * the CompilationUnit to sort * @param comparator * the comparator capable of ordering *BodyDeclaration
s; this comparator is passed * AST nodes from an AST of the specified AST level * @param options * bitwise-or of option flags;0
for default * behavior (reserved for future growth) * @param group * the text edit group to use when generating text edits, ornull
* @param monitor * the progress monitor to notify, ornull
if none * @return a TextEdit describing the required edits to do the sort, ornull
* if sorting is not required * @exception JavaModelException * if the compilation unit could not be sorted. Reasons * include: * - The given compilation unit does not exist * (ELEMENT_DOES_NOT_EXIST) * - The given compilation unit is not a working copy * (INVALID_ELEMENT_TYPES) * - ACoreException
occurred while * accessing the underlying resource * - The given compilation unit doesn't come from an ICompilationUnit and this ICompilationUnit is * not a working copy (NO_ELEMENTS_TO_PROCESS) * @exception IllegalArgumentException * if the given compilation unit is null or if the given * comparator is null, or ifoptions
is not one * of the supported levels. * @see org.eclipse.jdt.core.dom.BodyDeclaration * @see #RELATIVE_ORDER * @since 3.3 */ public static TextEdit sort(CompilationUnit unit, Comparator comparator, int options, TextEditGroup group, IProgressMonitor monitor) throws JavaModelException;
public class X { void foo() throws XAException, XBException {} void bar() { try { foo(); } catch(XAException e) { } catch(X| //do ctrl + space at | }In this example XBException will more relevant than XCException and XAException won't be proposed.
ClasspathVariableInitializer
schema:
<element name="classpathVariableInitializer"> <complexType> ... <attribute name="deprecated" type="string"> <annotation> <documentation> String explaining the reason why the associated variable is deprecated </documentation> <appInfo> <meta.attribute translatable="true"/> </appInfo> </annotation> </attribute> <attribute name="readOnly" type="boolean"> <annotation> <documentation> Indicates that the associated variable cannot be modified </documentation> </annotation> </attribute> </complexType> </element>When deprecated attribute is set on ClasspathVariableInitializer extension point, classpath entry validation returns a warning status if no other error was previously detected.
classpathVariableInitializer
extension point set
the TEST
classpath variable as deprecated and read-only:
<extension point="org.eclipse.jdt.core.classpathVariableInitializer"> <classpathVariableInitializer class="org.eclipse.jdt.tests.model.TestInitializer" deprecated="The reason why this variable is deprecated" readOnly="true" variable="TEST"> </classpathVariableInitializer> </extension>Calling
JavaConventions.validateClasspathEntry(IJavaProject, IClasspathEntry, boolean)
method on this variable entry will return a IStatus.WARNING
status with following message:
.
JavaCore
API methods:
/** * Returns deprecation message of a given classpath variable. * * @param variableName * @return A string if the classpath variable is deprecated,null
otherwise. * @since 3.3 */ public static String getClasspathVariableDeprecationMessage(String variableName) /** * Returns whether a given classpath variable is read-only or not. * * @param variableName * @returntrue
if the classpath variable is read-only, *false
otherwise. * @since 3.3 */ public static boolean isClasspathVariableReadOnly(String variableName)
public class CompletionProposal { ... /** * Completion is an import of reference to a static field. * <p> * The following additional context information is available * for this kind of completion proposal at little extra cost: * <ul> * <li>{@link #getDeclarationSignature()} - * the type signature of the type that declares the field that is imported * </li> * <li>{@link #getFlags()} - * the modifiers flags (including ACC_ENUM) of the field that is imported * </li> * <li>{@link #getName()} - * the simple name of the field that is imported * </li> * <li>{@link #getSignature()} - * the type signature of the field's type (as opposed to the * signature of the type in which the referenced field * is declared) * </li> * <li>{@link #getAdditionalFlags()} - * the completion flags (including ComletionFlags.StaticImport) * of the proposed import * </li> * </ul> * </p> * * @see #getKind() * * @since 3.3 */ public static final int FIELD_IMPORT; /** * Completion is an import of reference to a static method. * <p> * The following additional context information is available * for this kind of completion proposal at little extra cost: * <ul> * <li>{@link #getDeclarationSignature()} - * the type signature of the type that declares the method that is imported * </li> * <li>{@link #getFlags()} - * the modifiers flags of the method that is imported * </li> * <li>{@link #getName()} - * the simple name of the method that is imported * </li> * <li>{@link #getSignature()} - * the method signature of the method that is imported * </li> * <li>{@link #getAdditionalFlags()} - * the completion flags (including ComletionFlags.StaticImport) * of the proposed import * </li> * </ul> * </p> * * @see #getKind() * * @since 3.3 */ public static final int METHOD_IMPORT; /** * Completion is an import of reference to a type. * Only reference to reference types are allowed. * <p> * The following additional context information is available * for this kind of completion proposal at little extra cost: * <ul> * <li>{@link #getDeclarationSignature()} - * the dot-based package name of the package that contains * the type that is imported * </li> * <li>{@link #getSignature()} - * the type signature of the type that is imported * </li> * <li>{@link #getFlags()} - * the modifiers flags (including Flags.AccInterface, AccEnum, * and AccAnnotation) of the type that is imported * </li> * <li>{@link #getAdditionalFlags()} - * the completion flags (including ComletionFlags.StaticImport) * of the proposed import * </li> * </ul> * </p> * * @see #getKind() * * @since 3.3 */ public static final int TYPE_IMPORT; ... }
public class CompletionRequestor { ... /** * Returns the favorite references which are used to compute some completion proposals. * <p> * A favorite reference is a qualified reference as it can be seen in an import statement.<br> * e.g. <code>{"java.util.Arrays"}</code><br> * It can be an on demand reference.<br> * e.g. <code>{"java.util.Arrays.*"}</code> * It can be a reference to a static method or field (as in a static import)<br> * e.g. <code>{"java.util.Arrays.equals"}</code> * </p> * <p> * Currently only on demand type references (<code>"java.util.Arrays.*"</code>), * references to a static method or a static field are used to compute completion proposals. * Other kind of reference could be used in the future. * </p> * @return favorite imports * * @since 3.3 */ public String[] getFavoriteReferences() {...} /** * Set the favorite references which will be used to compute some completion proposals. * A favorite reference is a qualified reference as it can be seen in an import statement.<br> * * @param favoriteImports * * @see #getFavoriteReferences() * * @since 3.3 */ public void setFavoriteReferences(String[] favoriteImports) {...} ... }With the following example if the favorite reference is "java.util.Arrays.*" then a proposal will be the method "sort()" with a required proposal of a static import "import static java.util.Arrays.sort;". If the completion level is lesser than 1.5 the proposal will be "Arrays.sort()" with a required proposal of an import "import java.util.Arrays;".
The option JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS
can be disabled to avoid to propose static import
even if compliance is 1.5 or greater.
org.eclipse.jdt.core.JavaCore#VERSION_1_7
. It can be used to set the compliance, the source or the
target platform values. This has no impact right now beside setting the major version inside .class file to
org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants#MAJOR_VERSION_1_7
.org.eclipse.jdt.core.JavaCore#setComplianceOptions(String, Map)
to set the compiler's
options relative to a given compiler's compliance.ICompilationUnit
and IClassFile
(see bug 125504).
/** * Represents an entire Java type root (either anICompilationUnit
* or anIClassFile
). * * This interface is not intended to be implemented by clients. * * @see ICompilationUnit * @see IClassFile * @since 3.3 */ public interface ITypeRoot extends IJavaElement, IParent, IOpenable, ISourceReference, ICodeAssist { ... }
org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS
. See bug 165210 for details.org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW
. See bug 164946 for details.JavaConventions
can now validate names using specific source and compliance levels. New validate*Name
API methods
with the source and the compliance level as given parameters have been added to this class. Clients should now use these new methods instead
of deprecated ones which only verify names using the 1.3 default level.
org.eclipse.jdt.core.BindingKey
class to get the exceptions thrown by a method
(see bug 155003):
/** * Returns the thrown exception signatures of the element represented by this binding key. * If this binding key does not represent a method or does not throw any exception, * returns an empty array. * * @return the thrown exceptions signatures * @since 3.3 */ public String[] getThrownExceptions()
int f<code assist> System.out.print(foo);In this example foo is proposed as a possible completion.
TypeNameMatch
API has been polished while implementing new searchAllTypeNames(char[][] char[][],...)
API method (see next point).SearchEngine
following method
to create an instance of it:
/** * Create a type name match on a given type with specific modifiers. * * @param type The java model handle of the type * @param modifiers Modifiers of the type * @return A non-null match on the given type. */ public static TypeNameMatch createTypeNameMatch(IType type, int modifiers)Early performance tests using added
searchAllTypeNames
method with TypeNameMatchRequestor
requestor (ie. a la Open Type dialog) show interesting memory footprint reduction (around 30%). More precise measures of this
performance improvement will be done later...
SearchEngine
API method for search all type names with multiple qualifications and type names
(see bug 160324).searchAllTypeNames
method:
/** * Searches for all top-level types and member types in the given scope matching any of the given qualifications * and type names in a case sensitive way. * * Provided {@link TypeNameMatchRequestor} requestor will collect {@link TypeNameMatch} * matches found during the search. ... * @param nameMatchRequestor the {@link TypeNameMatchRequestor requestor} that collects * {@link TypeNameMatch matches} of the search. ... * @since 3.3 */ public void searchAllTypeNames( final char[][] qualifications, final char[][] typeNames, IJavaSearchScope scope, final TypeNameMatchRequestor nameMatchRequestor, int waitingPolicy, IProgressMonitor progressMonitor) throws JavaModelExceptionSimilarily to previous added
searchAllTypeNames
new API method, clients have to provide
a new requestor: TypeNameMatchRequestor
in order to get matches collected during the search.public class CompletionProposal { ... /** * Returns the required completion proposals. * The proposal can be apply only if these required completion proposals are also applied. * If the required proposal aren't applied the completion could create complations problems. * * <p> * This field is available for the following kinds of * completion proposals: * <ul> * <li><code>FIELD_REF</code> - The allowed required proposals for this kind are: * <ul> * <li><code>TYPE_REF</code></li> * </ul> * </li> * <li><code>METHOD_REF</code> - The allowed required proposals for this kind are: * <ul> * <li><code>TYPE_REF</code></li> * </ul> * </li> * </ul> * </p> * <p> * Other kinds of required proposals will be returned in the future, therefore clients of this * API must allow with {@link CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)} * only kinds which are in this list to avoid unexpected results in the future. * </p> * <p> * A required completion proposal cannot have required completion proposals. * </p> * * @return the required completion proposals, or <code>null</code> if none. * * @see CompletionRequestor#setAllowsRequiredProposals(int, int,boolean) * * @since 3.3 */ public CompletionProposal[] getRequiredProposals() {...} ... }
public class CompletionRequestor { ... /** * Returns whether a proposal of a given kind with a required proposal * of the given kind is allowed. * * @param proposalKind one of the kind constants declared * @param requiredProposalKind)one of the kind constants declared * on <code>CompletionProposal</code> * @return <code>true</code> if a proposal of a given kind with a required proposal * of the given kind is allowed by this requestor, and <code>false</code> * if it isn't of interest. * <p> * By default, all kinds of required proposals aren't allowed. * </p> * @see #setAllowsRequiredProposals(int, int, boolean) * @see CompletionProposal#getKind() * @see CompletionProposal#getRequiredProposals() * * @since 3.3 */ public boolean isAllowingRequiredProposals(int proposalKind, int requiredProposalKind) {...} /** * Sets whether a proposal of a given kind with a required proposal * of the given kind is allowed. * * Currenlty only a subset of kinds support required proposals. To see what combinations * are supported you must look at {@link CompletionProposal#getRequiredProposals()} * documentation. * * @param proposalKind one of the kind constants declared * @param requiredProposalKind)one of the kind constants declared * on <code>CompletionProposal</code> * @param allow <code>true</code> if a proposal of a given kind with a required proposal * of the given kind is allowed by this requestor, and <code>false</code> * if it isn't of interest * @see #isAllowingRequiredProposals(int, int) * @see CompletionProposal#getKind() * @see CompletionProposal#getRequiredProposals() * * @since 3.3 */ public void setAllowsRequiredProposals(int proposalKind, int requiredProposalKind)boolean allow) {...} ... }
package p; public class X { void foo() { Vector v = null; v.addEl| // complete at | location } }A completion proposal with required proposals will be returned. The main proposal will be the method
addElement()
at addEl
location with a required proposal of the type java.util.Vector
at
Vector
location.
The same kind of completion can be computed with the following examples.
package p; public class X { Vector v = null; void foo() { v.addEl| // complete at | location } }
package p; public class X { Vector bar() {return null;} void foo() { bar().addEl| // complete at | location } }
TypeNameMatch
has been changed to improve memory consumption performance.
It now creates IType handle while accepting the type information from indexes and stores their modifiers
to avoid java element opening while getting this piece of information.IType findType(String packageName, String typeQualifiedName, IPackageFragmentRoot root, ICompilationUnit[] units, IProgressMonitor progressMonitor) throws JavaModelException;
MethodReferenceMatch.isPolymorphic()
API method has been renamed to:
/** * Returns whether the reference is on a message sent from a type * which is a super type of the searched method declaring type. * Iftrue
, the method called at run-time may or may not be * the search target, depending on the run-time type of the receiver object. * * @returntrue
if the reference is on a message sent from * a super-type of the search method declaring class,false
otherwise */ public boolean isSuperInvocation()
ClasspathContainerInitializer#getFailureContainer(...)
that returns the classpath container that
should be used if a container initializer fails to initialize a container.SearchEngine
API method for search all type names (see bug 148380).searchAllTypeNames
method:
/** * Searches for all top-level types and member types in the given scope. * The search can be selecting specific types (given a package name using specific match mode * and/or a type name using another specific match mode). * * Provided {@link TypeNameMatchRequestor} requestor will collect {@link TypeNameMatch} * matches found during the search. ... * @param nameMatchRequestor the {@link TypeNameMatchRequestor requestor} that collects * {@link TypeNameMatch matches} of the search. ... * @since 3.3 */ public void searchAllTypeNames( final char[] packageName, final int packageMatchRule, final char[] typeName, final int typeMatchRule, int searchFor, IJavaSearchScope scope, final TypeNameMatchRequestor nameMatchRequestor, int waitingPolicy, IProgressMonitor progressMonitor) throws JavaModelExceptionClients have to provide a new requestor:
TypeNameMatchRequestor
in order to
get matches collected during the search.TypeNameMatch
) can resolve type and then provide corresponding java model IType
:
/** * Returns the java model type corresponding to fully qualified type name * (based on package, enclosing types and simple name). * * @return the java model type * @throws JavaModelException happens when type stored information are not valid */ public IType resolvedType() throws JavaModelException
SearchEngine
API helper method:
public void searchAllTypeNames( final char[] packageExactName, final char[] typeName, final int matchRule, int searchFor, IJavaSearchScope scope, final TypeNameRequestor nameRequestor, int waitingPolicy, IProgressMonitor progressMonitor) throws JavaModelExceptionThis should avoid to have too many similar
searchAllTypeNames
available methods...
JavaCore
API method to create a java element from an IFile
using a specific project:
/** * Returns the Java element corresponding to the given file, its project being the given * project. * ReturnsExisting API methodnull
if unable to associate the given file * with a Java element. * * The file must be one of: * . a file with one of the {@link JavaCore#getJavaLikeExtensions() * Java-like extensions} - the element returned is the correspondingICompilationUnit
* . a.class
file - the element returned is the correspondingIClassFile
* . a.jar
file - the element returned is the correspondingIPackageFragmentRoot
* * Creating a Java element has the side effect of creating and opening all of the * element's parents if they are not yet open. * * @param file the given file * @return the Java element corresponding to the given file, or *null
if unable to associate the given file * with a Java element * @since 3.3 */ public static IJavaElement create(IFile file, IJavaProject project)
JavaCore.create(IFile)
assumed that project to use was the file one
but it was not always the case, especially for class files belonging to an external class folder...IResource
and IFolder
as default project was
always well computed for this kind of resources.
isPolymorphic()
getter to MethodReferenceMatch
(see bug 73401
and bug 156491).
SearchRequestor
) accepts this kind of match,
it knows if a method reference match is a polymorphic method (ie. implemented in a super or sub type) or not.
For example, in example below:
class A { public void foo() {} } class B extends A {} class C extends B { public void foo() {} } class D extends C {} public class X { void foo() { new B().foo(); new C().foo(); new D().foo(); } }
Searching for all references to C.foo()
method get 3 matches
(instance of MethodReferenceMatch
). Two of them, new B().foo()
and
new D().foo()
are flagged as polymorphic due to the fact that these are methods
respectively of a superclass and of a subclass...
Search view has been modified to filter this kind of matches when user wants to focus only on exact references of the searched method.
public @interface MyAnnot { int foo(); } @| public class AClass {}'MyAnnot' is proposed if you do code assist at '|' location.
/** * The searched element is an interface or annotation type. * More selective than using {@link #TYPE}. * @since 3.3 */ int INTERFACE_AND_ANNOTATION= 11;
-classpath
and other classpath related
options, can bear a [-d dir]
specification that directs the
generated class files to dir
for source files fetched from the
said directories.
For example, given the source files src/X.java
and
Y.java
, X depending from Y, the command ecj src[-d bin1]
-d bin2
will produce the files bin1/X.class
and
bin2/Y.class
, while the command ecj src[-d bin] -d
none
will only produce the file bin/X.class
.
public @interface MyAnnot { int foo(); } @MyAnnot(| public class AClass {}'foo' is proposed if you do code assist at '|' location.
createPattern(IJavaElement, int, int)
behavior has been modified for generic searches.capture#2-of ? extends Number
is not compatible with capture#1-of ? extends Number
capture-of ? extends Number
is not compatible with capture-of ? extends Number
(also see bug 149573)./** * Searches for all top-level types and member types in the given scope. * The search can be selecting specific types (given a package name using specific match mode * and/or a type name using another specific match mode). * * @param packageName the full name of the package of the searched types, or a prefix for this * package, or a wild-carded string for this package. * @param typeName the dot-separated qualified name of the searched type (the qualification include * the enclosing types if the searched type is a member type), or a prefix * for this type, or a wild-carded string for this type. * @param packageMatchRule one of * . {@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names * of the searched types. * . {@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names * of the searched types. * . {@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards. * . {@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types. * combined with {@link SearchPattern#R_CASE_SENSITIVE}, * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested, * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested. * @param typeMatchRule one of * . {@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names * of the searched types. * . {@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names * of the searched types. * . {@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards. * . {@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types. * combined with {@link SearchPattern#R_CASE_SENSITIVE}, * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested, * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested. * @param searchFor determines the nature of the searched elements * . {@link IJavaSearchConstants#CLASS}: only look for classes * . {@link IJavaSearchConstants#INTERFACE}: only look for interfaces * . {@link IJavaSearchConstants#ENUM}: only look for enumeration * . {@link IJavaSearchConstants#ANNOTATION_TYPE}: only look for annotation type * . {@link IJavaSearchConstants#CLASS_AND_ENUM}: only look for classes and enumerations * . {@link IJavaSearchConstants#CLASS_AND_INTERFACE}: only look for classes and interfaces * . {@link IJavaSearchConstants#TYPE}: look for all types (ie. classes, interfaces, enum and annotation types) * @param scope the scope to search in * @param nameRequestor the requestor that collects the results of the search * @param waitingPolicy one of * . {@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately * . {@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the * underlying indexer has not finished indexing the workspace * . {@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the * underlying indexer to finish indexing the workspace * @param progressMonitor the progress monitor to report progress to, or null if no progress * monitor is provided * @exception JavaModelException if the search failed. Reasons include: * . the classpath is incorrectly set * @since 3.3 */ public void searchAllTypeNames( final char[] packageName, final int packageMatchRule, final char[] typeName, final int typeMatchRule, int searchFor, IJavaSearchScope scope, final TypeNameRequestor nameRequestor, int waitingPolicy, IProgressMonitor progressMonitor) throws JavaModelExceptionNote that already existing
searchAllTypeNames(char [], char[], int, int, IJavaSearchScope, TypeNameRequestor, int, IProgressMonitor)
API method documentation has been updated to reflected the fact
that package name is an exact name and does not accept wildcards.
For earlier build notes, also see build notes up to Release 3.2.