Skip to content

Commit

Permalink
Eclipse 4.16 (RC2) JDT Patch for Groovy-Eclipse: JDT commit f3c6f14
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jun 5, 2020
1 parent a0e2403 commit eb42de3
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</license>

<requires>
<import feature="org.eclipse.jdt" version="3.18.400.v20200528-0200" patch="true"/>
<import feature="org.eclipse.jdt" version="3.18.400.v20200604-0540" patch="true"/>
</requires>

<plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public final class AST {
* </p>
*
* @since 3.20
* @deprecated Clients should use the {@link #JLS_Latest} AST API instead.
*/
public static final int JLS13 = 13;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,10 @@ synchronized ITypeBinding resolveTypeBindingForName(Name name) {
IMethodBinding method = getMethodBinding(referenceExpression.getMethodBinding());
if (method == null) return null;
return method.getReturnType();
} else if (node instanceof org.eclipse.jdt.internal.compiler.ast.RecordComponent) {
org.eclipse.jdt.internal.compiler.ast.RecordComponent recordComponent = (org.eclipse.jdt.internal.compiler.ast.RecordComponent) node;
org.eclipse.jdt.internal.compiler.lookup.TypeBinding recordComponentType = recordComponent.type.resolvedType;
return this.getTypeBinding(recordComponentType);
}
return null;
}
Expand Down Expand Up @@ -1530,6 +1534,9 @@ synchronized IBinding resolveName(Name name) {
} else if (node instanceof org.eclipse.jdt.internal.compiler.ast.ReferenceExpression) {
org.eclipse.jdt.internal.compiler.ast.ReferenceExpression referenceExpression = (org.eclipse.jdt.internal.compiler.ast.ReferenceExpression) node;
return getMethodBinding(referenceExpression.getMethodBinding());
} else if (node instanceof org.eclipse.jdt.internal.compiler.ast.RecordComponent) {
org.eclipse.jdt.internal.compiler.ast.RecordComponent recordComponent = (org.eclipse.jdt.internal.compiler.ast.RecordComponent) node;
return this.getVariableBinding(recordComponent.binding);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
public final class ImportRewrite {
/**
* Used to determine how a type will be used, so that unwanted annotations can be filtered,
* which is in particular relevant for avoiding redundant null annotations in the scope of {@code @NonNullByDefault}.
* which is in particular relevant for avoiding redundant null annotations in the scope of {@code @NonNullByDefault}.
* This enum is a superset of org.eclipse.jdt.annotation.DefaultLocation, and roughly corresponds
* to the classification of type locations as introduced by JSR 308.
*
Expand All @@ -116,49 +116,49 @@ public final class ImportRewrite {
public enum TypeLocation {
/**
* see org.eclipse.jdt.annotation.DefaultLocation.PARAMETER
*
*
* @since 3.13
*/
PARAMETER,

/**
* see org.eclipse.jdt.annotation.DefaultLocation.RETURN_TYPE
*
*
* @since 3.13
*/
RETURN_TYPE,

/**
* see org.eclipse.jdt.annotation.DefaultLocation.FIELD
*
*
* @since 3.13
*/
FIELD,

/**
* see org.eclipse.jdt.annotation.DefaultLocation.TYPE_PARAMETER
*
*
* @since 3.13
*/
TYPE_PARAMETER,

/**
* see org.eclipse.jdt.annotation.DefaultLocation.TYPE_BOUND
*
*
* @since 3.13
*/
TYPE_BOUND,

/**
* see org.eclipse.jdt.annotation.DefaultLocation.TYPE_ARGUMENT
*
*
* @since 3.13
*/
TYPE_ARGUMENT,

/**
* see org.eclipse.jdt.annotation.DefaultLocation.ARRAY_CONTENTS
*
*
* @since 3.13
*/
ARRAY_CONTENTS,
Expand All @@ -167,7 +167,7 @@ public enum TypeLocation {
* The special value {@link #LOCAL_VARIABLE} is used for local variables: their nullness is determines by flow analysis,
* so top level nullness annotations are usually not needed for local variables (unless their type is a free
* type variable). Does not correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
LOCAL_VARIABLE,
Expand All @@ -176,25 +176,25 @@ public enum TypeLocation {
* The special value {@link #CAST} is used for casts.
* Casts are never affected by {@code @NonNullByDefault}
* Does not correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
CAST,

/**
* The special value {@link #INSTANCEOF} is used for {@code instanceof} expressions.
* Null annotations are not supported in this location.
* Does not correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
INSTANCEOF,

/**
* The special value {@link #NEW} is used for {@code new} expressions (object allocations).
* The special value {@link #NEW} is used for {@code new} expressions (object allocations).
* Null annotations are not supported in this location.
* Does not correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
NEW,
Expand All @@ -203,15 +203,15 @@ public enum TypeLocation {
* The special value {@link #RECEIVER} is used for the receiver type in a method declaration or method reference.
* Null annotations are not supported in this location.
* Does not correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
RECEIVER,

/**
* The special value {@link #EXCEPTION} is used for exception types in catch and throws declarations, which are
* implicitly non-null. Does not correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
EXCEPTION,
Expand All @@ -220,15 +220,15 @@ public enum TypeLocation {
* The special value {@link #OTHER} is used for locations where type annotations are illegal, like type literals
* (X.class), annotations, or as scope for static field accesses. Does not correspond to a value in
* org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
OTHER,

/**
* The special value {@link #UNKNOWN} is used for invocations that don't specify the intended type usage. Does not
* correspond to a value in org.eclipse.jdt.annotation.DefaultLocation.
*
*
* @since 3.13
*/
UNKNOWN,
Expand Down Expand Up @@ -454,7 +454,7 @@ public int findInContext(String qualifier, String name, int kind) {
this.importOrder= CharOperation.NO_STRINGS;
this.importOnDemandThreshold= 99;
this.staticImportOnDemandThreshold= 99;

this.importsKindMap = new HashMap();
}

Expand Down Expand Up @@ -532,10 +532,10 @@ public ImportRewriteContext getDefaultImportRewriteContext() {
* Note: {@link #setUseContextToFilterImplicitImports(boolean)} can be used to filter implicit imports
* when a context is used.
* </p>
*
*
* @param filterImplicitImports
* if <code>true</code>, implicit imports will be filtered
*
*
* @see #setUseContextToFilterImplicitImports(boolean)
*/
public void setFilterImplicitImports(boolean filterImplicitImports) {
Expand All @@ -552,16 +552,16 @@ public void setFilterImplicitImports(boolean filterImplicitImports) {
* whether an import can be filtered because the type is implicitly visible. Note that too many imports
* may be kept if this option is set and <code>addImport*(...)</code> methods are called without a context.
* </p>
*
*
* @param useContextToFilterImplicitImports the given setting
*
*
* @see #setFilterImplicitImports(boolean)
* @since 3.6
*/
public void setUseContextToFilterImplicitImports(boolean useContextToFilterImplicitImports) {
this.useContextToFilterImplicitImports = useContextToFilterImplicitImports;
}

private static int compareImport(char prefix, String qualifier, String name, String curr) {
if (curr.charAt(0) != prefix || !curr.endsWith(name)) {
return ImportRewriteContext.RES_NAME_UNKNOWN;
Expand Down Expand Up @@ -620,14 +620,14 @@ private static int compareImport(char prefix, String qualifier, String name, Str
|| mainTypeName.equals(Util.concatenateName(qualifier, name, '.'))) {
return ImportRewriteContext.RES_NAME_FOUND;
}

if (this.astRoot != null) {
List<AbstractTypeDeclaration> types = this.astRoot.types();
int nTypes = types.size();
for (int i = 0; i < nTypes; i++) {
AbstractTypeDeclaration type = types.get(i);
SimpleName simpleName = type.getName();
if (simpleName.getIdentifier().equals(name)) {
if (simpleName.getIdentifier().equals(name)) {
return qualifier.equals(packageName)
? ImportRewriteContext.RES_NAME_FOUND
: ImportRewriteContext.RES_NAME_CONFLICT;
Expand Down Expand Up @@ -672,7 +672,7 @@ private static int compareImport(char prefix, String qualifier, String name, Str
* to use the default context (only using the available imports)
* @return an annotation node. The returned annotation contains unqualified type names where
* an import could be added or was already known. Type names are fully qualified if an import conflict prevented an import.
*
*
* @since 3.10
*/
public Annotation addAnnotation(IAnnotationBinding annotation, AST ast, ImportRewriteContext context) {
Expand Down Expand Up @@ -959,7 +959,7 @@ private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) {
* in the code. The type binding can be an array binding, type variable or wildcard.
* If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type
* arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard
* of wildcards are ignored. If type annotations or type arguments are present at any point, the import is added up to that point and
* of wildcards are ignored. If type annotations or type arguments are present at any point, the import is added up to that point and
* the type is retained from that point with type annotations and type arguments.
* <p>
* No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead.
Expand All @@ -982,7 +982,7 @@ public Type addImport(ITypeBinding binding, AST ast) {
* in the code. The type binding can be an array binding, type variable or wildcard.
* If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type
* arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard
* of wildcards are ignored. If type annotations or type arguments are present at any point, the import is added up to that point and
* of wildcards are ignored. If type annotations or type arguments are present at any point, the import is added up to that point and
* the type is retained from that point with type annotations and type arguments
* <p>
* No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead.
Expand All @@ -1007,7 +1007,7 @@ public Type addImport(ITypeBinding binding, AST ast, ImportRewriteContext contex
* in the code. The type binding can be an array binding, type variable or wildcard.
* If the binding is a generic type, the type parameters are ignored. For parameterized types, also the type
* arguments are processed and imports added if necessary. Anonymous types inside type arguments are normalized to their base type, wildcard
* of wildcards are ignored. If type annotations or type arguments are present at any point, the import is added up to that point and
* of wildcards are ignored. If type annotations or type arguments are present at any point, the import is added up to that point and
* the type is retained from that point with type annotations and type arguments
* <p>
* No imports are added for types that are already known. If a import for a type is recorded to be removed, this record is discarded instead.
Expand All @@ -1025,7 +1025,7 @@ public Type addImport(ITypeBinding binding, AST ast, ImportRewriteContext contex
* or else qualified names if an import conflict prevented an import.
* @since 3.13
*/
public Type addImport(ITypeBinding binding, AST ast, ImportRewriteContext context, TypeLocation location) {
public Type addImport(ITypeBinding binding, AST ast, ImportRewriteContext context, TypeLocation location) {
ITypeBinding bindingPoint = checkAnnotationAndGenerics(binding);
Type type = internalAddImport(bindingPoint == null ? binding : bindingPoint, ast, context, null, /* getBase */ true, bindingPoint != null && !bindingPoint.equals(binding) ? TypeLocation.OTHER : location);
if (bindingPoint != null && !bindingPoint.equals(binding)) {
Expand Down Expand Up @@ -1315,7 +1315,7 @@ public final TextEdit rewriteImports(IProgressMonitor monitor) throws CoreExcept

CompilationUnit usedAstRoot= this.astRoot;
if (usedAstRoot == null) {
ASTParser parser= ASTParser.newParser(AST.JLS13);
ASTParser parser= ASTParser.newParser(AST.JLS14);
parser.setSource(this.compilationUnit);
parser.setFocalPosition(0); // reduced AST
parser.setResolveBindings(false);
Expand All @@ -1332,7 +1332,7 @@ public final TextEdit rewriteImports(IProgressMonitor monitor) throws CoreExcept
String qualifiedName = addedImport.substring(1);
computer.addImport(isStatic, qualifiedName);
}

for (String removedImport : this.removedImports) {
boolean isStatic = STATIC_PREFIX == removedImport.charAt(0);
String qualifiedName = removedImport.substring(1);
Expand Down Expand Up @@ -1519,7 +1519,7 @@ private Type createBaseType(AST ast, ImportRewriteContext context, ITypeBinding

String qualifiedName= getRawQualifiedName(normalizedBinding);
String res = qualifiedName.length() > 0 ? internalAddImport(qualifiedName, context) : getRawName(normalizedBinding);

if (annotsPresent) {
int dotIndex = res != null ? res.lastIndexOf('.') : -1;
if (dotIndex > 0) {
Expand Down Expand Up @@ -1556,7 +1556,7 @@ private Type getArrayType(Type elementType, AST ast, ImportRewriteContext contex
private Type internalAddImport(ITypeBinding binding, AST ast, ImportRewriteContext context, Type currentType, boolean getBase, TypeLocation location) {
Type type = null;
ITypeBinding normalizedBinding = null;

if (binding.isPrimitive()) {
type = ast.newPrimitiveType(PrimitiveType.toCode(binding.getName()));
normalizedBinding= binding;
Expand Down Expand Up @@ -1588,7 +1588,7 @@ private Type internalAddImport(ITypeBinding binding, AST ast, ImportRewriteConte
if (getBase) {
type = createBaseType(ast, context, normalizedBinding, location);
} else {
type = currentType != null ? (Type) ast.newQualifiedType(currentType, ast.newSimpleName(getRawName(normalizedBinding))) :
type = currentType != null ? (Type) ast.newQualifiedType(currentType, ast.newSimpleName(getRawName(normalizedBinding))) :
ast.newSimpleType(ast.newName(getRawName(normalizedBinding)));
type = annotateType(normalizedBinding, ast, context, type, location);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corporation and others.
* Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -416,7 +416,7 @@ private void prepareSpaces() {
private void prepareLineBreaks() {
LineBreaksPreparator breaksPreparator = new LineBreaksPreparator(this.tokenManager, this.workingOptions);
this.astRoot.accept(breaksPreparator);
breaksPreparator.finishUp(this.formatRegions);
breaksPreparator.finishUp();
this.astRoot.accept(new OneLineEnforcer(this.tokenManager, this.workingOptions));
}

Expand Down
Loading

0 comments on commit eb42de3

Please sign in to comment.