| jdt core - build notes 3.5 stream |
| Java development tools 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.5 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.4 (also see a summary of API changes).
Maintenance of previous releases of JDT/Core is performed in parallel branches: R3.4.x, R3.3.x, R3.2.x, R3.1.x, R3.0.x, R2.1.x, R2.0.x, R1.0.x. |
org.eclipse.jdt.core.WorkingCopyOwner.findSource(String, String)org.eclipse.jdt.core.WorkingCopyOwner.isPackage(String[])ReferenceMatchSearchPattern to provide matching
regions between a pattern and a name when they are compared using a given match rule/** * Answers all the regions in a given name matching a given pattern using * a specified match rule. * * Each of these regions is made of its starting index and its length in the given * name. They are all concatenated in a single array ofint* which therefore always has an even length. * * All returned regions are disjointed from each other. That means that the end * of a region is always different than the start of the following one. * For example, if two regions are returned: *{ start1, length1, start2, length2 }* thenstart1+length1will always be smaller than *start2. * * The possible comparison rules between the name and the pattern are: * . {@link #R_EXACT_MATCH exact matching} * . {@link #R_PREFIX_MATCH prefix matching} * . {@link #R_PATTERN_MATCH pattern matching} * . {@link #R_CAMELCASE_MATCH camel case matching} * . {@link #R_CAMELCASE_SAME_PART_COUNT_MATCH camel case matching with same parts count} * * Each of these rules may be combined with the * {@link #R_CASE_SENSITIVE case sensitive flag} if the match comparison * should respect the case. * * Examples: * . pattern = "NPE" * name = NullPointerException / NoPermissionException * matchRule = {@link #R_CAMELCASE_MATCH} * result: { 0, 1, 4, 1, 11, 1 } / { 0, 1, 2, 1, 12, 1 } * . pattern = "NuPoEx" * name = NullPointerException * matchRule = {@link #R_CAMELCASE_MATCH} * result: { 0, 2, 4, 2, 11, 2 } * . pattern = "IPL3" * name = "IPerspectiveListener3" * matchRule = {@link #R_CAMELCASE_MATCH} * result: { 0, 2, 12, 1, 20, 1 } * . pattern = "HashME" * name = "HashMapEntry" * matchRule = {@link #R_CAMELCASE_MATCH} * result: { 0, 5, 7, 1 } * . pattern = "N???Po*Ex?eption" * name = NullPointerException * matchRule = {@link #R_PATTERN_MATCH} | {@link #R_CASE_SENSITIVE} * result: { 0, 1, 4, 2, 11, 2, 14, 6 } * . pattern = "Ha*M*ent*" * name = "HashMapEntry" * matchRule = {@link #R_PATTERN_MATCH} * result: { 0, 2, 4, 1, 7, 3 } * * @see #camelCaseMatch(String, String, boolean) for more details on the * camel case behavior * @see CharOperation#match(char[], char[], boolean) for more details on the * pattern match behavior * * @param pattern the given pattern. Ifnull, * then an empty region (new int[0]) will be returned * showing that the name matches the pattern but no common * character has been found. * @param name the given name * @param matchRule the rule to apply for the comparison. * The following values are accepted: * . {@link #R_EXACT_MATCH} * . {@link #R_PREFIX_MATCH} * . {@link #R_PATTERN_MATCH} * . {@link #R_CAMELCASE_MATCH} * . {@link #R_CAMELCASE_SAME_PART_COUNT_MATCH} * * Each of these valid values may be also combined with * the {@link #R_CASE_SENSITIVE} flag. * * Some examples: * . {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE}: * if an exact case sensitive match is expected, * . {@link #R_PREFIX_MATCH}: * if a case insensitive prefix match is expected, * . {@link #R_CAMELCASE_MATCH}: * if a case insensitive camel case match is expected, * . {@link #R_CAMELCASE_SAME_PART_COUNT_MATCH} * | {@link #R_CASE_SENSITIVE}: * if a case sensitive camel case with same parts count match * is expected, * . etc. * * @return an array ofinthaving two slots per returned * regions (the first one is the region starting index and the second one * is the region length ornullif the given name does not * match the given pattern). * * The returned regions may be empty (new int[0]) if the * pattern isnull(whatever the match rule is). The returned * regions will also be empty if the pattern is only made of'?'* and/or'*'character(s) (e.g.'*', *'?*','???', etc.) when using a pattern * match rule. * * @since 3.5 */
ITypeBinding#getGenericTypeOfWildcardType(), ITypeBinding#getRank(), and
BindingKey#createWildcardTypeBindingKey(String genericTypeKey, char boundKind, String boundTypeKey, int rank).CONSTRUCTOR_INVOCATION and this proposal has always a
TYPE_REF required proposal to describe the type of the constructor.
The CONSTRUCTOR_INVOCATION has "()" as completion string and TYPE_REF has
"java.util.ArrayList" as completion string.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION
/**
* Completion is a reference to a constructor.
* This kind of completion might occur in a context like
* <code>"new Lis"</code> and complete it to
* <code>"new List();"</code> if List is a class that is not abstract.
* <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 constructor that is referenced
* </li>
* <li>{@link #getFlags()} -
* the modifiers flags of the constructor that is referenced
* </li>
* <li>{@link #getName()} -
* the simple name of the constructor that is referenced
* </li>
* <li>{@link #getSignature()} -
* the method signature of the constructor that is referenced
* </li>
* </ul>
* </p>
* <p>
* This kind of proposal could require a long computation, so they are computed only if completion operation is called with a {@link IProgressMonitor}
* (eg. {@link ICodeAssist#codeComplete(int, CompletionRequestor, IProgressMonitor)}).<br>
* This kind of proposal is always is only proposals with a {@link #TYPE_REF} required proposal, so this kind of required proposal must be allowed:
* <code>requestor.setAllowsRequiredProposals(CONSTRUCTOR_INVOCATION, TYPE_REF, true)</code>.
* </p>
*
* @see #getKind()
* @see CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)
*
* @since 3.5
*/
public static final int CONSTRUCTOR_INVOCATION = 26;
/**
* Completion is a reference of a constructor of an anonymous class.
* This kind of completion might occur in a context like
* <code>"new Lis^;"</code> and complete it to
* <code>"new List() {}"</code> if List is an interface or abstract class.
* <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 being implemented or subclassed
* </li>
* <li>{@link #getDeclarationKey()} -
* the type unique key of the type being implemented or subclassed
* </li>
* <li>{@link #getSignature()} -
* the method signature of the constructor that is referenced
* </li>
* <li>{@link #getKey()} -
* the method unique key of the constructor that is referenced
* if the declaring type is not an interface
* </li>
* <li>{@link #getFlags()} -
* the modifiers flags of the constructor that is referenced
* </li>
* </ul>
* </p>
* <p>
* This kind of proposal could require a long computation, so they are computed only if completion operation is called with a {@link IProgressMonitor}
* (eg. {@link ICodeAssist#codeComplete(int, CompletionRequestor, IProgressMonitor)})<br>
* This kind of proposal is always is only proposals with a {@link #TYPE_REF} required proposal, so this kind of required proposal must be allowed:
* <code>requestor.setAllowsRequiredProposals(CONSTRUCTOR_INVOCATION, TYPE_REF, true)</code>.
* </p>
*
* @see #getKind()
* @see CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)
*
* @since 3.5
*/
public static final int ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION = 27;
These new proposals can require a long computation so they are proposed only if code assist was called with a progress monitor.
To avoid that the code assist operation takes too much time a IProgressMonitor which automatically cancel the code
assist operation when a specified amount of time is reached could be used.
new IProgressMonitor() {
private final static int TIMEOUT = 500; //ms
private long endTime;
public void beginTask(String name, int totalWork) {
fEndTime= System.currentTimeMillis() + TIMEOUT;
}
public boolean isCanceled() {
return endTime <= System.currentTimeMillis();
}
...
};
eclipse.exe -vmArgs -Dorg.eclipse.jdt.core.javamodelcache.ratio=1.5
DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES
/**
* FORMATTER / Option to specify whether the formatter can join wrapped lines or not
*
* For example, the wrapped lines of method foo return statement in following test case:
* class X {
* String foo() {
* return "select x "
* + "from y "
* + "where z=a";
* }
* }
*
* will be preserved by the formatter when the new preference is used
* even if the maximum line width would give it enough space to join the lines.
* Hence produces the following output:
* class X {
* String foo() {
* return "select x "
* + "from y "
* + "where z=a";
* }
* }
*
* - option id: "org.eclipse.jdt.core.formatter.join_wrapped_lines"
* - possible values: { TRUE, FALSE }
* - default: TRUE
*
* @since 3.5
*/
DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS
/**
* FORMATTER / Option to specify whether the formatter can join text lines in comments or not
*
* For example, the following comment:
* /**
* * The foo method.
* * foo is a substitute for bar.
* */
* public class X {
* }
*
* will be unchanged by the formatter when this new preference is used,
* even if the maximum line width would give it enough space to join the lines.
*
* - option id: "org.eclipse.jdt.core.formatter.join_lines_in_comments"
* - possible values: { TRUE, FALSE }
* - default: TRUE
*
* @since 3.5
*/
For example, the wrapped lines of method foo return statement in following test case:
class X {
String foo() {
return "select x "
+ "from y "
+ "where z=a";
}
}
will be preserved by the formatter when the new preference is used, hence produces
now the following output:
class X {
String foo() {
return "select x "
+ "from y "
+ "where z=a";
}
}
Similarly, following comment:
/**
* The foo method.
* foo is a substitute for bar.
*/
public class X {
}
is now unchanged by the formatter when this new preference is used...
This diagnosis is controlled by the option:
DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXISTING_LINE_BREAKS:
/**
* FORMATTER / Option to specify whether the formatter should preserve existing line breaks or not
* - option id: "org.eclipse.jdt.core.formatter.preserve_existing_line_breaks"
* - possible values: { TRUE, FALSE }
* - default: FALSE
* @since 3.5
*/
if (DEBUG) .... This extra option is defined by
JavaCore.COMPILER_PB_DEAD_CODE_IN_TRIVIAL_IF_STATEMENT.
* Compiler option ID: Reporting Dead Code Inside Trivial If Statement.
* When enabled, the compiler will signal presence of dead code inside trivial IF statement, e.g. if (DEBUG)...
* The severity of the problem is controlled with option {@link #COMPILER_PB_DEAD_CODE}.
*
* Option id:"org.eclipse.jdt.core.compiler.problem.deadCodeInTrivialIfStatement"
* Possible values:{ "enabled", "disabled" }
* Default:"warning"
* Compiler option ID: Reporting Dead Code.
* When enabled, the compiler will issue an error or a warning if some non fatal dead code is detected. For instance, if (false) foo();
* is not reported as truly unreachable code by the Java Language Specification. If this diagnostic is enabled, then the invocation of foo() is
* going to be signaled as being dead code.
* Option id:"org.eclipse.jdt.core.compiler.problem.deadCode"
* Possible values:{ "error", "warning", "ignore" }
* Default:"warning"
if (false) deadCode(); .
This diagnosis is controlled by option:
JavaCore.COMPILER_PB_DEAD_CODE and produces a problem marker which ID is IProblem.DeadCode problem ID.
* Compiler option ID: Reporting Dead Code.
* When enabled, the compiler will issue an error or a warning if some non fatal dead code is detected. For instance, if (false) foo();
* is not reported as truly unreachable code by the Java Language Specification. If this diagnostic is enabled, then the invocation of foo() is
* going to be signaled as being dead code.
* Option id:"org.eclipse.jdt.core.compiler.problem.deadCode"
* Possible values:{ "error", "warning", "ignore" }
* Default:"ignore"
NamingConventions.suggestVariableNames().CONSTANT_FIELD_NAME).
public static String[] suggestVariableNames( int variableKind, int baseNameKind, String baseName, IJavaProject javaProject, int dim, String[] excluded, boolean evaluateDefault)
NamingConventions.getBaseName().public static String getBaseName( int variableKind, String variableName, IJavaProject javaProject)
JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES and JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES.
org.eclipse.jdt.core.dom.ASTVisitor.preVisit2(ASTNode).org.eclipse.jdt.core.dom.NodeFinder.JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD and produces a problem marker which ID is
IProblem.MissingHashCodeMethod problem ID.
Compiler option ID: Reporting Missing HashCode Method.
When enabled, the compiler will issue an error or a warning if a type
overrides Object.equals(Object) but does not override hashCode().
Option id: "org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod"
Possible values: { "error", "warning", "ignore" }
Default: "ignore"
public interface ICodeAssist {
/**
* Performs code completion at the given offset position in this compilation unit,
* reporting results to the given completion requestor. The <code>offset</code>
* is the 0-based index of the character, after which code assist is desired.
* An <code>offset</code> of -1 indicates to code assist at the beginning of this
* compilation unit.
* It considers types in the working copies with the given owner first. In other words,
* the owner's working copies will take precedence over their original compilation units
* in the workspace.
* <p>
* Note that if a working copy is empty, it will be as if the original compilation
* unit had been deleted.
* </p>
*
* @param offset the given offset position
* @param requestor the given completion requestor
* @param owner the owner of working copies that take precedence over their original compilation units
* @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
* <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> The position specified is < -1 or is greater than this compilation unit's
* source length (INDEX_OUT_OF_BOUNDS)
* </ul>
*
* @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
* @since 3.0
* @deprecated Use {@link #codeComplete(int, CompletionRequestor, WorkingCopyOwner)} instead.
*/
void codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner owner)
throws JavaModelException;
/**
* Performs code completion at the given offset position in this compilation unit,
* reporting results to the given completion requestor. The <code>offset</code>
* is the 0-based index of the character, after which code assist is desired.
* An <code>offset</code> of -1 indicates to code assist at the beginning of this
* compilation unit.
* <p>
*
* @param offset the given offset position
* @param requestor the given completion requestor
* @exception JavaModelException if code assist could not be performed. Reasons include:<ul>
* <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> The position specified is < -1 or is greater than this compilation unit's
* source length (INDEX_OUT_OF_BOUNDS)
* </ul>
*
* @exception IllegalArgumentException if <code>requestor</code> is <code>null</code>
* @since 3.0
*/
void codeComplete(int offset, CompletionRequestor requestor)
throws JavaModelException;
}
public interface IType {
/**
* Do code completion inside a code snippet in the context of the current type.
*
* If the type can access to his source code and the insertion position is valid,
* then completion is performed against source. Otherwise the completion is performed
* against type structure and given locals variables.
*
* @param snippet the code snippet
* @param insertion the position with in source where the snippet
* is inserted. This position must not be in comments.
* A possible value is -1, if the position is not known.
* @param position the position within snippet where the user
* is performing code assist.
* @param localVariableTypeNames an array (possibly empty) of fully qualified
* type names of local variables visible at the current scope
* @param localVariableNames an array (possibly empty) of local variable names
* that are visible at the current scope
* @param localVariableModifiers an array (possible empty) of modifiers for
* local variables
* @param isStatic whether the current scope is in a static context
* @param requestor the completion requestor
* @param monitor the progress monitor used to report progress
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
* @since 3.5
*/
void codeComplete(
char[] snippet,
int insertion,
int position,
char[][] localVariableTypeNames,
char[][] localVariableNames,
int[] localVariableModifiers,
boolean isStatic,
CompletionRequestor requestor,
IProgressMonitor monitor)
throws JavaModelException;
/**
* Do code completion inside a code snippet in the context of the current type.
* It considers types in the working copies with the given owner first. In other words,
* the owner's working copies will take precedence over their original compilation units
* in the workspace.
* <p>
* Note that if a working copy is empty, it will be as if the original compilation
* unit had been deleted.
* </p><p>
* If the type can access to his source code and the insertion position is valid,
* then completion is performed against source. Otherwise the completion is performed
* against type structure and given locals variables.
* </p>
*
* @param snippet the code snippet
* @param insertion the position with in source where the snippet
* is inserted. This position must not be in comments.
* A possible value is -1, if the position is not known.
* @param position the position with in snippet where the user
* is performing code assist.
* @param localVariableTypeNames an array (possibly empty) of fully qualified
* type names of local variables visible at the current scope
* @param localVariableNames an array (possibly empty) of local variable names
* that are visible at the current scope
* @param localVariableModifiers an array (possible empty) of modifiers for
* local variables
* @param isStatic whether the current scope is in a static context
* @param requestor the completion requestor
* @param owner the owner of working copies that take precedence over their original compilation units
* @param monitor the progress monitor used to report progress
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
* @since 3.5
*/
void codeComplete(
char[] snippet,
int insertion,
int position,
char[][] localVariableTypeNames,
char[][] localVariableNames,
int[] localVariableModifiers,
boolean isStatic,
CompletionRequestor requestor,
WorkingCopyOwner owner,
IProgressMonitor monitor)
throws JavaModelException;
}
public interface IEvaluationContext {
/**
* Performs a code completion at the given position in the given code snippet,
* reporting results to the given completion requestor.
* <p>
* Note that code completion does not involve evaluation.
* <p>
*
* @param codeSnippet the code snippet to complete in
* @param position the character position in the code snippet to complete at,
* or -1 indicating the beginning of the snippet
* @param requestor the code completion requestor capable of accepting all
* possible types of completions
* @param monitor the progress monitor used to report progress
* @exception JavaModelException if code completion could not be performed. Reasons include:
* <ul>
* <li>The position specified is less than -1 or is greater than the snippet's
* length (INDEX_OUT_OF_BOUNDS)</li>
* </ul>
* @since 3.5
*/
public void codeComplete(
String codeSnippet,
int position,
CompletionRequestor requestor,
IProgressMonitor monitor)
throws JavaModelException;
/**
* Performs a code completion at the given position in the given code snippet,
* reporting results to the given completion requestor.
* It considers types in the working copies with the given owner first. In other words,
* the owner's working copies will take precedence over their original compilation units
* in the workspace.
* <p>
* Note that if a working copy is empty, it will be as if the original compilation
* unit had been deleted.
* </p>
* <p>
* Note that code completion does not involve evaluation.
* <p>
*
* @param codeSnippet the code snippet to complete in
* @param position the character position in the code snippet to complete at,
* or -1 indicating the beginning of the snippet
* @param requestor the code completion requestor capable of accepting all
* possible types of completions
* @param owner the owner of working copies that take precedence over their original compilation units
* @param monitor the progress monitor used to report progress
* @exception JavaModelException if code completion could not be performed. Reasons include:
* <ul>
* <li>The position specified is less than -1 or is greater than the snippet's
* length (INDEX_OUT_OF_BOUNDS)</li>
* </ul>
* @since 3.5
*/
public void codeComplete(
String codeSnippet,
int position,
CompletionRequestor requestor,
WorkingCopyOwner owner,
IProgressMonitor monitor)
throws JavaModelException;
}
synchronized modifier
when overriding a synchronized method got disabled by default.
Compiler option ID: Reporting Missing Synchronized Modifier On Inherited Method.
When enabled, the compiler will issue an error or a warning if a method
overrides a synchronized method without having a synchronized modifier.
Option id: "org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod"
Possible values: { "error", "warning", "ignore" }
Default: "ignore"
$FALL-THROUGH$) for silencing compiler diagnosis for switch case
falling through next case. This allows to document intended fall through situations in the code.
Note: The marker comment can also be a block comment, i.e. /* $FALL-THROUGH$ */.
switch(val) {
case 0 :
doit(0);
// $FALL-THROUGH$ - also fall into next case
case 1:
doit(1);
break;
}
synchronized modifier when overriding a synchronized method.
This diagnosis is controlled by option:
JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD and produces a problem marker which ID is
IProblem.MissingSynchronizedModifierInInheritedMethod problem ID;
it may be suppressed using @SuppressWarnings("super").
Compiler option ID: Reporting Missing Synchronized Modifier On Inherited Method.
When enabled, the compiler will issue an error or a warning if a method
overrides a synchronized method without having a synchronized modifier.
Option id: "org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod"
Possible values: { "error", "warning", "ignore" }
Default: "warning"
JavaCore.COMPILER_PB_COMPARING_IDENTICAL and produces a problem marker which ID is
IProblem.ComparingIdentical problem ID.
Compiler option ID: Reporting Comparison of Identical Expressions.
When enabled, the compiler will issue an error or a warning if a comparison
is involving identical operands (e.g 'x == x').
- Option id:"org.eclipse.jdt.core.compiler.problem.comparingIdentical"
- Possible values: { "error", "warning", "ignore" }
- Default: "warning"
For earlier build notes, also see build notes up to Release 3.4.