Package org.eclipse.jdt.core.dom.rewrite
Class ImportRewrite.ImportRewriteContext
java.lang.Object
org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext
- Enclosing class:
- ImportRewrite
A
ImportRewrite.ImportRewriteContext
can optionally be used in e.g. ImportRewrite.addImport(String, ImportRewrite.ImportRewriteContext)
to
give more information about the types visible in the scope. These types can be for example inherited inner types where it is
unnecessary to add import statements for.
This class can be implemented by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Kind constant specifying that the element is a static field import.static final int
Kind constant specifying that the element is a static method import.static final int
Kind constant specifying that the element is a type import.static final int
Result constant signaling that the given element is conflicting with an other element in the context.static final int
Result constant signaling that the given element is know in the context.static final int
Result constant signaling that the given element is not know in the context.static final int
Result constant signaling that the given element must be imported explicitly (and must not be folded into an on-demand import or filtered as an implicit import). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
findInContext
(String qualifier, String name, int kind) Searches for the given element in the context and reports if the element is known (RES_NAME_FOUND
), unknown (RES_NAME_UNKNOWN
), unknown in the context but known to require an explicit import (RES_NAME_UNKNOWN_NEEDS_EXPLICIT_IMPORT
), or if its name conflicts (RES_NAME_CONFLICT
) with an other element.removeRedundantTypeAnnotations
(IAnnotationBinding[] annotations, ImportRewrite.TypeLocation location, ITypeBinding type) This method can be overridden in subclasses to remove annotations that are redundant, e.g. because of NonNullByDefault.
-
Field Details
-
RES_NAME_FOUND
public static final int RES_NAME_FOUNDResult constant signaling that the given element is know in the context.- See Also:
-
RES_NAME_UNKNOWN
public static final int RES_NAME_UNKNOWNResult constant signaling that the given element is not know in the context.- See Also:
-
RES_NAME_CONFLICT
public static final int RES_NAME_CONFLICTResult constant signaling that the given element is conflicting with an other element in the context.- See Also:
-
RES_NAME_UNKNOWN_NEEDS_EXPLICIT_IMPORT
public static final int RES_NAME_UNKNOWN_NEEDS_EXPLICIT_IMPORTResult constant signaling that the given element must be imported explicitly (and must not be folded into an on-demand import or filtered as an implicit import).- Since:
- 3.11
- See Also:
-
KIND_TYPE
public static final int KIND_TYPEKind constant specifying that the element is a type import.- See Also:
-
KIND_STATIC_FIELD
public static final int KIND_STATIC_FIELDKind constant specifying that the element is a static field import.- See Also:
-
KIND_STATIC_METHOD
public static final int KIND_STATIC_METHODKind constant specifying that the element is a static method import.- See Also:
-
-
Constructor Details
-
ImportRewriteContext
public ImportRewriteContext()
-
-
Method Details
-
findInContext
Searches for the given element in the context and reports if the element is known (RES_NAME_FOUND
), unknown (RES_NAME_UNKNOWN
), unknown in the context but known to require an explicit import (RES_NAME_UNKNOWN_NEEDS_EXPLICIT_IMPORT
), or if its name conflicts (RES_NAME_CONFLICT
) with an other element.- Parameters:
qualifier
- The qualifier of the element, can be package or the qualified name of a typename
- The simple name of the element; either a type, method or field name or * for on-demand imports.kind
- The kind of the element. Can be eitherKIND_TYPE
,KIND_STATIC_FIELD
orKIND_STATIC_METHOD
. Implementors should be prepared for new, currently unspecified kinds and returnRES_NAME_UNKNOWN
by default.- Returns:
- Returns the result of the lookup. Can be either
RES_NAME_FOUND
,RES_NAME_UNKNOWN
,RES_NAME_CONFLICT
, orRES_NAME_UNKNOWN_NEEDS_EXPLICIT_IMPORT
.
-
removeRedundantTypeAnnotations
public IAnnotationBinding[] removeRedundantTypeAnnotations(IAnnotationBinding[] annotations, ImportRewrite.TypeLocation location, ITypeBinding type) This method can be overridden in subclasses to remove annotations that are redundant, e.g. because of NonNullByDefault.- Parameters:
annotations
- The array of type annotations to be filtered.location
- Specifies how the type being annotated will be used.type
- the type being annotated- Returns:
- Returns the annotations that should be added to the type.
- Since:
- 3.13
-